核心功能
Facade API | 付费版本 | 需要 Univer 服务端 | Univer on Node.js | Preset |
---|---|---|---|---|
✅ | - | - | ✅ | UniverSheetsCorePreset |
核心功能是实现电子表格的基础功能,包含了 Univer Sheets 的核心功能,如创建工作簿、单元格编辑、单元格选择、公式、数字格式等。
该功能包含以下插件包:
@univerjs/engine-render
- 渲染引擎插件@univerjs/engine-formula
- 公式引擎插件@univerjs/ui
- 基础UI插件@univerjs/docs
- doc 插件@univerjs/docs-ui
- doc UI 插件@univerjs/sheets
- sheet 插件@univerjs/sheets-ui
- sheet UI 插件@univerjs/sheets-formula
- 公式插件@univerjs/sheets-formula-ui
- 公式 UI 插件@univerjs/sheets-numfmt
- 数字格式插件
Presets 安装
npm install @univerjs/presets
import { createUniver, defaultTheme, LocaleType, Tools } from '@univerjs/presets';
import { UniverSheetsCorePreset } from '@univerjs/presets/preset-sheets-core';
import UniverPresetSheetsCoreZhCN from '@univerjs/presets/preset-sheets-core/locales/zh-CN';
const { univerAPI } = createUniver({
locale: LocaleType.ZH_CN,
locales: {
zhCN: Tools.deepMerge(
{},
UniverPresetSheetsCoreZhCN
),
},
theme: defaultTheme,
presets: [
UniverSheetsCorePreset(),
]
});
高级安装
npm install @univerjs/core @univerjs/design @univerjs/engine-render @univerjs/engine-formula @univerjs/ui @univerjs/docs @univerjs/docs-ui @univerjs/sheets @univerjs/sheets-ui @univerjs/sheets-formula @univerjs/sheets-formula-ui @univerjs/sheets-numfmt
import { Univer, LocaleType, Tools } from '@univerjs/core';
import { defaultTheme } from "@univerjs/design";
import { UniverRenderEnginePlugin } from "@univerjs/engine-render";
import { UniverFormulaEnginePlugin } from "@univerjs/engine-formula";
import { UniverUIPlugin } from "@univerjs/ui";
import { UniverDocsPlugin } from "@univerjs/docs";
import { UniverDocsUIPlugin } from "@univerjs/docs-ui";
import { UniverSheetsPlugin } from "@univerjs/sheets";
import { UniverSheetsUIPlugin } from "@univerjs/sheets-ui";
import { UniverSheetsFormulaPlugin } from "@univerjs/sheets-formula";
import { UniverSheetsFormulaUIPlugin } from "@univerjs/sheets-formula-ui";
import { UniverSheetsNumfmtPlugin } from '@univerjs/sheets-numfmt';
import DesignZhCN from '@univerjs/design/locale/zh-CN';
import UIZhCN from '@univerjs/ui/locale/zh-CN';
import DocsUIZhCN from '@univerjs/docs-ui/locale/zh-CN';
import SheetsZhCN from '@univerjs/sheets/locale/zh-CN';
import SheetsUIZhCN from '@univerjs/sheets-ui/locale/zh-CN';
import SheetsFormulaUIZhCN from '@univerjs/sheets-formula-ui/locale/zh-CN';
import SheetsNumfmtZhCN from '@univerjs/sheets-numfmt/locale/zh-CN';
import "@univerjs/design/lib/index.css";
import "@univerjs/ui/lib/index.css";
import "@univerjs/docs-ui/lib/index.css";
import "@univerjs/sheets-ui/lib/index.css";
import "@univerjs/sheets-formula-ui/lib/index.css";
import '@univerjs/sheets-numfmt/lib/index.css';
import '@univerjs/engine-formula/facade';
import '@univerjs/ui/facade';
import '@univerjs/docs-ui/facade';
import '@univerjs/sheets/facade';
import '@univerjs/sheets-ui/facade';
import '@univerjs/sheets-formula/facade';
import '@univerjs/sheets-numfmt/facade';
const univer = new Univer({
theme: defaultTheme,
locale: LocaleType.ZH_CN,
locales: {
[LocaleType.ZH_CN]: Tools.deepMerge(
DesignZhCN,
UIZhCN,
DocsUIZhCN,
SheetsZhCN,
SheetsUIZhCN,
SheetsFormulaUIZhCN,
SheetsNumfmtZhCN
),
},
});
univer.registerPlugin(UniverRenderEnginePlugin);
univer.registerPlugin(UniverFormulaEnginePlugin);
univer.registerPlugin(UniverUIPlugin, {
container: 'app',
});
univer.registerPlugin(UniverDocsPlugin);
univer.registerPlugin(UniverDocsUIPlugin);
univer.registerPlugin(UniverSheetsPlugin);
univer.registerPlugin(UniverSheetsUIPlugin);
univer.registerPlugin(UniverSheetsFormulaPlugin);
univer.registerPlugin(UniverSheetsFormulaUIPlugin);
univer.registerPlugin(UniverSheetsNumfmtPlugin);
Univer on Node.js 高级安装
npm install @univerjs/core @univerjs/design @univerjs/engine-render @univerjs/engine-formula @univerjs/docs @univerjs/sheets @univerjs/sheets-formula @univerjs/sheets-numfmt
import { LocaleType, Tools } from '@univerjs/core';
import { defaultTheme } from "@univerjs/design";
import { UniverRenderEnginePlugin } from "@univerjs/engine-render";
import { UniverFormulaEnginePlugin } from "@univerjs/engine-formula";
import { UniverDocsPlugin } from "@univerjs/docs";
import { UniverSheetsPlugin } from "@univerjs/sheets";
import { UniverSheetsFormulaPlugin } from "@univerjs/sheets-formula";
import { UniverSheetsNumfmtPlugin } from '@univerjs/sheets-numfmt';
import '@univerjs/engine-formula/facade';
import '@univerjs/sheets/facade';
import '@univerjs/sheets-formula/facade';
import '@univerjs/sheets-numfmt/facade';
const univer = new Univer({
theme: defaultTheme,
locale: LocaleType.ZH_CN,
});
univer.registerPlugin(UniverRenderEnginePlugin);
univer.registerPlugin(UniverFormulaEnginePlugin);
univer.registerPlugin(UniverDocsPlugin);
univer.registerPlugin(UniverSheetsPlugin);
univer.registerPlugin(UniverSheetsFormulaPlugin);
univer.registerPlugin(UniverSheetsNumfmtPlugin);
配置
@univerjs/core
@univerjs/core
在初始化时提供了一些配置项,可用于配置主题、国际化等。
new Univer({
theme: IStyleSheet;
locale: LocaleType;
locales: ILocales;
logLevel?: LogLevel;
});
完整的配置项参考 IUniverConfig。
@univerjs/ui
@univerjs/ui
提供了一些配置项,可用于基础布局的配置。
univer.registerPlugin(UniverUIPlugin, {
container?: string | HTMLElement;
header?: boolean;
toolbar?: boolean;
footer?: boolean;
contextMenu?: boolean;
disableAutoFocus?: true;
override?: DependencyOverride;
menu?: MenuConfig;
});
container
- 容器元素,可以是字符串或者 DOM 元素。header
- 是否显示头部。toolbar
- 是否显示头部工具栏。 0.2.0+footer
- 是否显示底部。contextMenu
- 是否显示右键菜单。disableAutoFocus
- 是否禁用自动聚焦。override
- 依赖注入的覆盖配置。menu
- 菜单配置,详见定制菜单项(隐藏菜单项)