图片
Facade API | 可付费升级 | 需要 Univer 服务端 | Univer on Node.js | Preset |
---|---|---|---|---|
- | - | - | - | UniverSheetsDrawingPreset |
插入浮动图片和单元格图片,支持调整大小和位置。
该功能包含以下插件包:
@univerjs/docs-drawing
- docs 插图插件@univerjs/drawing
- 基础插图插件@univerjs/drawing-ui
- 基础插图 UI 插件@univerjs/sheets-drawing
- sheet 插图插件@univerjs/sheets-drawing-ui
- sheet 插图 UI 插件
Presets 安装
import { createUniver, defaultTheme, LocaleType, merge } from '@univerjs/presets';
import { UniverSheetsCorePreset } from '@univerjs/presets/preset-sheets-core';
import UniverPresetSheetsCoreZhCN from '@univerjs/presets/preset-sheets-core/locales/zh-CN';
import { UniverSheetsDrawingPreset } from '@univerjs/presets/preset-sheets-drawing';
import UniverPresetSheetsDrawingZhCN from '@univerjs/presets/preset-sheets-drawing/locales/zh-CN';
import '@univerjs/presets/lib/styles/preset-sheets-core.css'
import '@univerjs/presets/lib/styles/preset-sheets-drawing.css'
const { univerAPI } = createUniver({
locale: LocaleType.ZH_CN,
locales: {
[LocaleType.ZH_CN]: merge(
{},
UniverPresetSheetsCoreZhCN,
UniverPresetSheetsDrawingZhCN
),
},
theme: defaultTheme,
presets: [
UniverSheetsCorePreset(),
UniverSheetsDrawingPreset()
]
});
手动组合安装
npm install @univerjs/docs-drawing @univerjs/drawing @univerjs/drawing-ui @univerjs/sheets-drawing @univerjs/sheets-drawing-ui
import { LocaleType, merge, Univer } from '@univerjs/core';
import { defaultTheme } from "@univerjs/design";
import { UniverDocsDrawingPlugin } from '@univerjs/docs-drawing';
import { IImageIoService, UniverDrawingPlugin } from '@univerjs/drawing';
import { UniverDrawingUIPlugin } from '@univerjs/drawing-ui';
import { UniverSheetsDrawingPlugin } from '@univerjs/sheets-drawing';
import { UniverSheetsDrawingUIPlugin } from '@univerjs/sheets-drawing-ui';
import DrawingUIZhCN from '@univerjs/drawing-ui/locale/zh-CN';
import SheetsDrawingUIZhCN from '@univerjs/sheets-drawing-ui/locale/zh-CN';
import '@univerjs/drawing-ui/lib/index.css';
import '@univerjs/sheets-drawing-ui/lib/index.css';
const univer = new Univer({
theme: defaultTheme,
locale: LocaleType.ZH_CN,
locales: {
[LocaleType.ZH_CN]: merge(
DrawingUIZhCN,
SheetsDrawingUIZhCN,
),
},
});
// 当不使用协同插件时,注册代码如下:
univer.registerPlugin(UniverDrawingPlugin);
univer.registerPlugin(UniverDrawingUIPlugin);
univer.registerPlugin(UniverSheetsDrawingPlugin);
univer.registerPlugin(UniverSheetsDrawingUIPlugin);
// 使用协同插件时,需要提供 `override` 配置:
univer.registerPlugin(UniverDrawingPlugin, {
override: [[IImageIoService, null]], // 协同插件将会提供该实现
});