Watermark
Watermark feature aims to provide a flexible and secure watermark solution for web pages or applications. With this feature, developers can dynamically generate text or image watermarks on the page to prevent unauthorized use or dissemination of content, and it supports various configurations.
Preset Mode
Watermark does not provide a preset, but it supports mixing with its plugins.
Installation
npm install @univerjs/watermarkUsage
import { UniverWatermarkPlugin } from '@univerjs/watermark'
import '@univerjs/watermark/facade'
const { univerAPI } = createUniver({
// ...
presets: [
UniverDocsCorePreset(),
],
plugins: [
[UniverWatermarkPlugin, {
textWatermarkSettings: {
content: 'Hello, Univer!',
fontSize: 36,
},
}],
],
})Plugin Mode
Installation
npm install @univerjs/watermarkUsage
import { UniverWatermarkPlugin } from '@univerjs/watermark'
import '@univerjs/watermark/facade'
const univer = new Univer({
// ...
})
univer.registerPlugin(UniverWatermarkPlugin, {
textWatermarkSettings: {
content: 'Hello, Univer!',
fontSize: 36,
},
}) Plugins and Configuration
@univerjs/watermark
This plugin provides the core implementation of watermark functionality. It allows developers to add text or image watermarks to applications and offers various configuration options to customize the appearance and behavior of the watermark. It provides the UniverWatermarkPlugin plugin.
Reference: @univerjs/watermark
Facade API
Importing
Plugin mode note
Only plugin mode requires manually importing the Facade package. Preset mode already includes the corresponding Facade package, so no extra import is needed.
import '@univerjs/watermark/facade'Set Watermark
univerAPI.addWatermark('text', { content: 'hello', repeat: true })Remove Watermark
univerAPI.deleteWatermark()How is this guide?
