Univer
Univer Sheet
Features
Floating Images

Floating Images

📊 Univer Sheet📝 Univer Doc

Insert floating images, support drag to adjust size and position.

Installation

pnpm add @univerjs/drawing @univerjs/sheets-drawing @univerjs/drawing-ui @univerjs/sheets-drawing-ui

Import

import '@univerjs/drawing-ui/lib/index.css';
import '@univerjs/sheets-drawing-ui/lib/index.css';
 
import { UniverDrawingPlugin } from '@univerjs/drawing';
import { UniverDrawingUIPlugin } from '@univerjs/drawing-ui';
import { UniverSheetsDrawingPlugin } from '@univerjs/sheets-drawing';
import { UniverSheetsDrawingUIPlugin } from '@univerjs/sheets-drawing-ui';

Internationalization

import { LocaleType, Tools } from '@univerjs/core';
import DrawingUIEnUS from '@univerjs/drawing-ui/locale/en-US';
import SheetsDrawingUIEnUS from '@univerjs/sheets-drawing-ui/locale/en-US';
 
const univer = new Univer({
  theme: defaultTheme,
  locale: LocaleType.EN_US,
  locales: {
    [LocaleType.EN_US]: Tools.deepMerge(
      DrawingUIEnUS,
      SheetsDrawingUIEnUS
    ),
  },
});

Register

When not using the collaborative plugin, the registration code is as follows:

univer.registerPlugin(UniverDrawingPlugin);
univer.registerPlugin(UniverDrawingUIPlugin);
univer.registerPlugin(UniverSheetsDrawingPlugin);
univer.registerPlugin(UniverSheetsDrawingUIPlugin);

When using the collaborative plugin, the registration code is as follows:

import { IImageIoService } from '@univerjs/drawing'
 
univer.registerPlugin(UniverDrawingPlugin, {
  override: [[IImageIoService, null]], // The collaborative plugin will provide this implementation
});
univer.registerPlugin(UniverDrawingUIPlugin);
univer.registerPlugin(UniverSheetsDrawingPlugin);
univer.registerPlugin(UniverSheetsDrawingUIPlugin);

Copyright © 2021-2024 DreamNum Co,Ltd. All Rights Reserved.