Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

watermark-lite

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

watermark-lite

💻 a lightweight watermark plugin 一个轻量级水印插件

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

watermark-lite

💻 A lightweight watermark plugin

github stars npm version npm downloads bundle JSDocs License

Xiaohe / github@xiaohe0601 / gitee@xiaohe0601

🎉 Features

  • 🪶 Lightweight and easy-to-use API design

  • 🖌️ Rich customization options

  • 🔐 Monitors DOM behavior and automatically rebuilds the watermark

  • 🧀 Full support for TypeScript

  • 👌 No framework restrictions

🚁 Installation

PNPM
pnpm add watermark-lite
YARN
yarn add watermark-lite
NPM
npm install watermark-lite

🛹 Usage

Basic Usage
import { Watermark } from "watermark-lite";

const wm = new Watermark();

// Display the watermark
wm.mount({
  text: "watermark text"
});

// To modify the watermark text or style, just call the `mount` method again
wm.mount({
  text: "modified watermark text"
});

// Remove the watermark
wm.unmount();
Default Instance

Since version 0.0.7, you can directly use the exported default instance

import { watermark } from "watermark-lite";

watermark.mount({
  text: "watermark text"
});

You can also use the alias wm for watermark

import { wm } from "watermark-lite";

wm.mount({
  text: "watermark text"
});
Custom Watermark Style
wm.mount({
  text: "watermark text",
  fontSize: "14px",
  fontFamily: "inherit",
  color: "#000000",
  opacity: 0.15,
  rotate: 15
});
Custom Watermark Parent Element

By default, the watermark is mounted under document.body. You can change the parent element using the parentEl parameter, which supports passing in an element id or HTMLElement

wm.mount({
  text: "watermark text",
  parentEl: "app"
});
About Single-Page Applications

For single-page applications, make sure to call the unmount method at the appropriate time to avoid repeated listeners and potential memory leaks

// The following is an example using Vue3, but the plugin itself is not limited to any framework

import { onBeforeUnmount, onMounted } from "vue";
import { Watermark } from "watermark-lite";

const wm = new Watermark();

onMounted(() => {
  wm.mount({
    text: "watermark text"
  });
});

onBeforeUnmount(() => {
  wm.unmount();
});
Configuration Options
ParameterDescriptionTypeDefault
elwatermark element idstringwatermark
textwatermark textstringdefault watermark
xwatermark starting x-coordinate (px)number0
ywatermark starting y-coordinate (px)number0
rowsnumber of watermark rowsnumberauto-calculated
colsnumber of watermark columnsnumberauto-calculated
xGapwatermark x-axis spacing (px)number50
yGapwatermark y-axis spacing (px)number50
zIndexz-index of the watermarknumber / string99999
itemIdPrefixprefix for watermark item idsstringwatermark-item
itemWidthwidth of the watermark item (px)number100
itemHeightheight of the watermark item (px)number100
fontSizewatermark font sizestring14px
fontFamilywatermark fontstringinherit
colorwatermark text colorstring#000000
opacitywatermark opacity (range: 0 ~ 1)number0.15
rotate 0.1.0watermark rotate (range: 0 ~ 360)number15
parentElparent element for watermarkstring / HTMLElementdocument.body
monitormonitor watermark changes and automatically rebuildbooleantrue
angle 0.1.0 removedwatermark rotate (range: 0 ~ 360) (removed in 0.1.0, use rotate instead)number15
Type Definitions

See jsdocs.io

🐶 Discussion & Communication

🏆 License

Keywords

FAQs

Package last updated on 16 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc