Skip to content

Watermark

NPM Version

Watermark adds watermark effects to pages.

Setup

  1. Install the plugin
bash
$ npm add @winner-fed/plugin-watermark -D
bash
$ yarn add @winner-fed/plugin-watermark -D
bash
$ pnpm add @winner-fed/plugin-watermark -D
bash
$ bun add @winner-fed/plugin-watermark -D
  1. Enable the plugin in the .winrc configuration file
ts
import { defineConfig } from 'win';

export default defineConfig({
  plugins: ['@winner-fed/plugin-watermark'],
  /**
   * @name Watermark plugin
   * @doc https://winjs-dev.github.io/winjs-docs/plugins/watermark.html
   */
  watermark: {},
});
  1. Import and use in your project
ts
import { Watermark, WatermarkOptions } from 'winjs';

const watermark = new Watermark({
  container: document.body,
  text: 'Test Watermark',
} as WatermarkOptions);

watermark.show();

API

Basic Parameters

ParameterDescriptionTypeDefault
containerWatermark mount nodeHTMLElement | string-
imageImage source, recommend exporting 2x or 3x images, image rendering takes prioritystring-
textWatermark text, array indicates multi-line watermarkstring | string\[\]-
zIndexWatermark z-indexnumber9999
widthSingle watermark widthnumber120
heightSingle watermark heightnumber64
opacityWatermark opacitynumber0.15
rotateRotation anglenumber-22
fontSizeFont sizenumber16
fontWeightFont weightnumber | stringnormal
fontStyleFont stylestringnormal
fontVariantFont variantstringnormal
fontColorFont colorstring#000
fontFamilyWatermark text font familystringsans-serif
blindTextBlind watermark textstring-
blindOpacityBlind watermark opacitynumber0.005

Advanced Parameters

ParameterDescriptionTypeDefault
monitorWhether to enable protection modebooleantrue
modeDisplay mode, interval means staggered displaystringinterval
gapXHorizontal spacing between watermarksnumber100
gapYVertical spacing between watermarksnumber100
offsetLeftHorizontal offset for watermark drawing on canvasnumber0
offsetTopVertical offset for watermark drawing on canvasnumber0
packWhether to use watermark component to wrap contentbooleantrue

Methods

NameDescriptionType
updateUpdate watermark configuration and re-render(opts: WatermarkOptions) => void
showShow watermark() => void
hideHide watermark() => void
destroyDestroy watermark() => void

Released under the MIT License.