@univerjs/watermark 0.5.0-alpha.0 → 0.5.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -1,13 +1,10 @@
1
- var he = Object.defineProperty;
2
- var ve = (e, t, a) => t in e ? he(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
3
- var k = (e, t, a) => ve(e, typeof t != "symbol" ? t + "" : t, a);
4
- import { CommandType as fe, LocaleService as R, Inject as j, ILocalStorageService as F, Disposable as ee, useDependency as x, useObservable as we, IUniverInstanceService as ke, DOCS_ZEN_EDITOR_UNIT_ID_KEY as Se, UserManagerService as xe, RxDisposable as _e, Injector as ye, ICommandService as Ce, Plugin as Ie, UniverInstanceType as V, IConfigService as je } from "@univerjs/core";
5
- import { Layer as Ne, IRenderManagerService as Te } from "@univerjs/engine-render";
6
- import { ISidebarService as te, ILocalFileService as We, IClipboardInterfaceService as be, MenuItemType as Re, RibbonStartGroup as Pe, ComponentManager as Le, IMenuManagerService as Me } from "@univerjs/ui";
7
- import Oe, { forwardRef as P, useRef as Ee, createElement as L, useState as z, useCallback as Fe, useEffect as Ae } from "react";
8
- import { Button as Y, InputNumber as g, Checkbox as X, Input as Ue, Select as re, Dropdown as $e, ColorPicker as De } from "@univerjs/design";
9
- import { Subject as G, switchMap as He, of as Z } from "rxjs";
10
- const ae = "UNIVER_WATERMARK_MENU", ne = "WATERMARK_PANEL", ie = "WATERMARK_PANEL_FOOTER", S = "UNIVER_WATERMARK_STORAGE_KEY", Ye = 10, Xe = ["image/png", "image/jpeg", "image/jpg", "image/bmp"], O = {
1
+ var O = Object.defineProperty;
2
+ var D = (e, t, r) => t in e ? O(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var l = (e, t, r) => D(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { Inject as W, ILocalStorageService as E, Disposable as j, UserManagerService as L, RxDisposable as Y, Injector as N, Plugin as X, UniverInstanceType as $, IConfigService as K } from "@univerjs/core";
5
+ import { Layer as G, IRenderManagerService as V } from "@univerjs/engine-render";
6
+ import { Subject as U } from "rxjs";
7
+ const _ = "UNIVER_WATERMARK_STORAGE_KEY", H = 10, pe = ["image/png", "image/jpeg", "image/jpg", "image/bmp"], z = {
11
8
  content: "",
12
9
  fontSize: 16,
13
10
  color: "rgb(0,0,0)",
@@ -21,7 +18,7 @@ const ae = "UNIVER_WATERMARK_MENU", ne = "WATERMARK_PANEL", ie = "WATERMARK_PANE
21
18
  spacingY: 100,
22
19
  rotate: 0,
23
20
  opacity: 0.15
24
- }, se = {
21
+ }, B = {
25
22
  url: "",
26
23
  width: 100,
27
24
  height: 100,
@@ -34,7 +31,7 @@ const ae = "UNIVER_WATERMARK_MENU", ne = "WATERMARK_PANEL", ie = "WATERMARK_PANE
34
31
  spacingY: 100,
35
32
  rotate: 0,
36
33
  opacity: 0.15
37
- }, Be = {
34
+ }, q = {
38
35
  name: !0,
39
36
  email: !1,
40
37
  phone: !1,
@@ -51,140 +48,29 @@ const ae = "UNIVER_WATERMARK_MENU", ne = "WATERMARK_PANEL", ie = "WATERMARK_PANE
51
48
  spacingY: 100,
52
49
  rotate: -30,
53
50
  opacity: 0.15
54
- }, K = {
55
- type: fe.OPERATION,
56
- id: "univer.operation.open-watermark-panel",
57
- handler(e) {
58
- const t = e.get(te), a = e.get(R);
59
- return t.open({
60
- header: { title: a.t("univer-watermark.title") },
61
- children: { label: ne },
62
- footer: { label: ie },
63
- onClose: () => {
64
- },
65
- width: 330
66
- }), !0;
67
- }
68
51
  };
69
- var m = /* @__PURE__ */ ((e) => (e.UserInfo = "userInfo", e.Text = "text", e.Image = "image", e))(m || {}), f = function() {
70
- return f = Object.assign || function(e) {
71
- for (var t, a = 1, r = arguments.length; a < r; a++) {
72
- t = arguments[a];
73
- for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
74
- }
75
- return e;
76
- }, f.apply(this, arguments);
77
- }, Ke = function(e, t) {
78
- var a = {};
79
- for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (a[r] = e[r]);
80
- if (e != null && typeof Object.getOwnPropertySymbols == "function")
81
- for (var n = 0, r = Object.getOwnPropertySymbols(e); n < r.length; n++)
82
- t.indexOf(r[n]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[n]) && (a[r[n]] = e[r[n]]);
83
- return a;
84
- }, M = P(function(e, t) {
85
- var a = e.icon, r = e.id, n = e.className, i = e.extend, l = Ke(e, ["icon", "id", "className", "extend"]), d = "univerjs-icon univerjs-icon-".concat(r, " ").concat(n || "").trim(), u = Ee("_".concat(Ge()));
86
- return oe(a, "".concat(r), { defIds: a.defIds, idSuffix: u.current }, f({ ref: t, className: d }, l), i);
87
- });
88
- function oe(e, t, a, r, n) {
89
- return L(e.tag, f(f({ key: t }, Ve(e, a, n)), r), (ze(e, a).children || []).map(function(i, l) {
90
- return oe(i, "".concat(t, "-").concat(e.tag, "-").concat(l), a, void 0, n);
91
- }));
92
- }
93
- function Ve(e, t, a) {
94
- var r = f({}, e.attrs);
95
- a != null && a.colorChannel1 && r.fill === "colorChannel1" && (r.fill = a.colorChannel1);
96
- var n = t.defIds;
97
- return !n || n.length === 0 || (e.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + t.idSuffix), Object.entries(r).forEach(function(i) {
98
- var l = i[0], d = i[1];
99
- typeof d == "string" && (r[l] = d.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
100
- })), r;
101
- }
102
- function ze(e, t) {
103
- var a, r = t.defIds;
104
- return !r || r.length === 0 ? e : e.tag === "defs" && (!((a = e.children) === null || a === void 0) && a.length) ? f(f({}, e), { children: e.children.map(function(n) {
105
- return typeof n.attrs.id == "string" && r && r.indexOf(n.attrs.id) > -1 ? f(f({}, n), { attrs: f(f({}, n.attrs), { id: n.attrs.id + t.idSuffix }) }) : n;
106
- }) }) : e;
107
- }
108
- function Ge() {
109
- return Math.random().toString(36).substring(2, 8);
110
- }
111
- M.displayName = "UniverIcon";
112
- var Ze = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M4.65791 1.30005C3.77355 1.30005 3.05664 2.01696 3.05664 2.90132V12.8588C3.05664 13.8755 3.88086 14.6998 4.89759 14.6998H9.1016C11.2233 14.6998 12.9433 12.9798 12.9433 10.8581C12.9433 9.13925 11.8145 7.68407 10.2578 7.1934C10.8806 6.56856 11.2655 5.70659 11.2655 4.75472C11.2655 2.84676 9.71883 1.30005 7.81087 1.30005H4.65791ZM4.25664 2.90132C4.25664 2.6797 4.4363 2.50005 4.65791 2.50005H7.81087C9.05609 2.50005 10.0655 3.5095 10.0655 4.75472C10.0655 5.99993 9.05609 7.00938 7.81087 7.00938H4.25664V2.90132ZM4.25664 12.8588V8.21636H9.1016C10.5606 8.21636 11.7433 9.39909 11.7433 10.8581C11.7433 12.317 10.5606 13.4998 9.1016 13.4998H4.89759C4.5436 13.4998 4.25664 13.2128 4.25664 12.8588Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, le = P(function(e, t) {
113
- return L(M, Object.assign({}, e, {
114
- id: "bold-single",
115
- ref: t,
116
- icon: Ze
117
- }));
118
- });
119
- le.displayName = "BoldSingle";
120
- var qe = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "mask", attrs: { id: "mask0_102_1198", style: { maskType: "alpha" }, width: 16, height: 16, x: 0, y: 0, maskUnits: "userSpaceOnUse" }, children: [{ tag: "path", attrs: { fill: "#DCDCDC", d: "M0 0H16V16H0z" } }] }, { tag: "g", attrs: { mask: "url(#mask0_102_1198)" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.68731 9.98425C5.73282 9.87144 5.77827 9.75442 5.82366 9.63323L6.3312 8.27586H9.65859L10.3523 10.1159C10.405 10.284 10.4868 10.4276 10.6023 10.5378C10.74 10.669 10.9119 10.7236 11.1014 10.714C11.3544 10.7131 11.5919 10.6379 11.6996 10.4032L11.7013 10.3992C11.7901 10.1937 11.7749 9.9634 11.6929 9.7289L8.85351 1.86337C8.79546 1.68828 8.6901 1.54881 8.54213 1.45002C8.38836 1.33863 8.1989 1.29112 7.98798 1.29112C7.78272 1.29112 7.59752 1.34014 7.4446 1.45198C7.30481 1.55223 7.20617 1.69184 7.14935 1.86343L4.324 9.70145L4.32281 9.70495C4.27002 9.86052 4.23828 10.0056 4.23828 10.1346C4.23828 10.2646 4.27116 10.3937 4.36281 10.4909C4.50256 10.6468 4.6921 10.714 4.90604 10.714C5.0369 10.714 5.15805 10.6745 5.26156 10.5916C5.3633 10.5247 5.44621 10.4332 5.51101 10.3217C5.57988 10.2177 5.63858 10.1051 5.68731 9.98425ZM6.72105 7.00152L8.00144 3.32827L9.28183 7.00152H6.72105Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "rect", attrs: { width: 11.58, height: 2.56, x: 2.21, y: 12.2, fill: "colorChannel1", rx: 1.28 } }] }] }, ce = P(function(e, t) {
121
- return L(M, Object.assign({}, e, {
122
- id: "font-color",
123
- ref: t,
124
- icon: qe
125
- }));
126
- });
127
- ce.displayName = "FontColor";
128
- var Je = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M9.80385 1.40005H11.9997C12.3311 1.40005 12.5997 1.66868 12.5997 2.00005C12.5997 2.33143 12.3311 2.60005 11.9997 2.60005H10.1185L7.12251 13.4001H9.33324C9.66461 13.4001 9.93324 13.6687 9.93324 14.0001C9.93324 14.3314 9.66461 14.6001 9.33324 14.6001H6.34785C6.33847 14.6003 6.32905 14.6003 6.31962 14.6001H3.9999C3.66853 14.6001 3.3999 14.3314 3.3999 14.0001C3.3999 13.6687 3.66853 13.4001 3.9999 13.4001H5.87719L8.87322 2.60005H6.66641C6.33504 2.60005 6.06641 2.33143 6.06641 2.00005C6.06641 1.66868 6.33504 1.40005 6.66641 1.40005H9.52916C9.61698 1.37929 9.71064 1.3781 9.80385 1.40005Z" } }] }, me = P(function(e, t) {
129
- return L(M, Object.assign({}, e, {
130
- id: "italic-single",
131
- ref: t,
132
- icon: Je
133
- }));
134
- });
135
- me.displayName = "ItalicSingle";
136
- var Qe = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.93949 12.3363L1.94048 12.3357 1.95034 12.33C1.95981 12.3245 1.97499 12.3158 1.99548 12.3043 2.0365 12.2813 2.09866 12.2474 2.17888 12.2061 2.33971 12.1234 2.57112 12.0123 2.84885 11.9012 3.41339 11.6754 4.12822 11.4664 4.81552 11.4664 5.82167 11.4664 6.71309 11.8774 7.74399 12.3643 7.7595 12.3717 7.77504 12.379 7.79061 12.3864 8.77119 12.8497 9.88765 13.3772 11.185 13.3772 12.0901 13.3772 12.9676 13.1085 13.5973 12.8566 13.9167 12.7289 14.1829 12.6011 14.3704 12.5047 14.4644 12.4564 14.5391 12.4157 14.5914 12.3864 14.6175 12.3717 14.6381 12.3599 14.6527 12.3514L14.6702 12.3412 14.6755 12.3381 14.6772 12.337 14.6782 12.3365C14.6782 12.3365 14.6784 12.3363 14.3697 11.8218L14.6782 12.3365C14.9623 12.166 15.0547 11.7973 14.8842 11.5131 14.7138 11.2291 14.3454 11.1369 14.0613 11.3071L14.06 11.3079 14.0502 11.3137C14.0407 11.3192 14.0255 11.3279 14.005 11.3394 13.964 11.3623 13.9019 11.3963 13.8216 11.4375 13.6608 11.5202 13.4294 11.6314 13.1517 11.7424 12.5871 11.9683 11.8723 12.1772 11.185 12.1772 10.1788 12.1772 9.28742 11.7663 8.25652 11.2793 8.24101 11.272 8.22547 11.2646 8.2099 11.2573 7.22931 10.7939 6.11286 10.2664 4.81552 10.2664 3.91046 10.2664 3.03292 10.5351 2.40318 10.787 2.08377 10.9148 1.81757 11.0425 1.63007 11.139 1.53613 11.1873 1.46144 11.228 1.40916 11.2573 1.383 11.2719 1.36241 11.2837 1.34778 11.2922L1.33033 11.3024 1.32504 11.3056 1.32327 11.3066 1.32233 11.3072C1.32233 11.3072 1.32209 11.3073 1.63068 11.8217L1.32233 11.3072C1.03818 11.4777.945803 11.8464 1.11629 12.1305 1.28674 12.4146 1.65536 12.5066 1.93949 12.3363zM1.93949 8.51464L1.94048 8.51406 1.95034 8.50829C1.95981 8.50279 1.97499 8.49407 1.99548 8.4826 2.0365 8.45963 2.09866 8.4257 2.17888 8.38443 2.33971 8.30172 2.57112 8.19061 2.84885 8.07952 3.41339 7.85371 4.12822 7.64473 4.81552 7.64473 5.82167 7.64473 6.71309 8.05572 7.74399 8.54267 7.7595 8.54999 7.77504 8.55733 7.79061 8.56469 8.77119 9.02803 9.88765 9.55557 11.185 9.55557 12.0901 9.55557 12.9676 9.28684 13.5973 9.03494 13.9167 8.90718 14.1829 8.77943 14.3704 8.683 14.4644 8.63469 14.5391 8.59398 14.5914 8.5647 14.6175 8.55006 14.6381 8.53825 14.6527 8.52975L14.6702 8.51954 14.6755 8.51641 14.6772 8.51535 14.6782 8.51479C14.6782 8.51479 14.6784 8.51464 14.3697 8.00015L14.6782 8.51479C14.9623 8.3443 15.0547 7.9756 14.8842 7.69145 14.7138 7.4074 14.3454 7.31523 14.0613 7.48547L14.06 7.48623 14.0502 7.492C14.0407 7.4975 14.0255 7.50622 14.005 7.5177 13.964 7.54067 13.9019 7.5746 13.8216 7.61586 13.6608 7.69857 13.4294 7.80968 13.1517 7.92077 12.5871 8.14659 11.8723 8.35557 11.185 8.35557 10.1788 8.35557 9.28742 7.94457 8.25652 7.45762 8.24101 7.4503 8.22547 7.44296 8.2099 7.4356 7.22931 6.97226 6.11286 6.44473 4.81552 6.44473 3.91046 6.44473 3.03292 6.71346 2.40318 6.96535 2.08377 7.09311 1.81757 7.22086 1.63007 7.31729 1.53613 7.3656 1.46144 7.40631 1.40916 7.43559 1.383 7.45024 1.36241 7.46205 1.34778 7.47054L1.33033 7.48075 1.32504 7.48389 1.32327 7.48494 1.32233 7.48551C1.32233 7.48551 1.32209 7.48565 1.63068 7.99997L1.32233 7.48551C1.03818 7.656.945803 8.0247 1.11629 8.30884 1.28674 8.59292 1.65536 8.68496 1.93949 8.51464zM1.93949 4.69296L1.94048 4.69238 1.95034 4.68661C1.95981 4.68111 1.97499 4.67239 1.99548 4.66092 2.0365 4.63795 2.09866 4.60402 2.17888 4.56276 2.33971 4.48004 2.57112 4.36893 2.84885 4.25784 3.41339 4.03203 4.12822 3.82305 4.81552 3.82305 5.82167 3.82305 6.71309 4.23404 7.74399 4.72099 7.7595 4.72831 7.77504 4.73566 7.79061 4.74301 8.77119 5.20635 9.88765 5.73389 11.185 5.73389 12.0901 5.73389 12.9676 5.46516 13.5973 5.21326 13.9167 5.0855 14.1829 4.95775 14.3704 4.86132 14.4644 4.81301 14.5391 4.7723 14.5914 4.74302 14.6175 4.72838 14.6381 4.71657 14.6527 4.70807L14.6702 4.69786 14.6755 4.69473 14.6772 4.69367 14.6782 4.69311C14.6782 4.69311 14.6784 4.69296 14.3697 4.17847L14.6782 4.69311C14.9623 4.52262 15.0547 4.15392 14.8842 3.86977 14.7138 3.58572 14.3454 3.49355 14.0613 3.66379L14.06 3.66455 14.0502 3.67032C14.0407 3.67582 14.0255 3.68454 14.005 3.69602 13.964 3.71899 13.9019 3.75292 13.8216 3.79418 13.6608 3.87689 13.4294 3.988 13.1517 4.09909 12.5871 4.32491 11.8723 4.53389 11.185 4.53389 10.1788 4.53389 9.28742 4.12289 8.25652 3.63594 8.24101 3.62862 8.22547 3.62128 8.2099 3.61392 7.22931 3.15058 6.11286 2.62305 4.81552 2.62305 3.91046 2.62305 3.03292 2.89178 2.40318 3.14367 2.08377 3.27143 1.81757 3.39918 1.63007 3.49561 1.53613 3.54392 1.46144 3.58463 1.40916 3.61391 1.383 3.62856 1.36241 3.64037 1.34778 3.64886L1.33033 3.65907 1.32504 3.66221 1.32327 3.66326 1.32233 3.66383C1.32233 3.66383 1.32209 3.66397 1.63068 4.17829L1.32233 3.66383C1.03818 3.83432.945803 4.20302 1.11629 4.48716 1.28674 4.77124 1.65536 4.86329 1.93949 4.69296z", fillRule: "evenodd", clipRule: "evenodd" } }] }, de = P(function(e, t) {
137
- return L(M, Object.assign({}, e, {
138
- id: "watermark-single",
139
- ref: t,
140
- icon: Qe
141
- }));
142
- });
143
- de.displayName = "WatermarkSingle";
144
- var ue = { exports: {} }, A = {};
145
- /**
146
- * @license React
147
- * react-jsx-runtime.production.min.js
148
- *
149
- * Copyright (c) Facebook, Inc. and its affiliates.
150
- *
151
- * This source code is licensed under the MIT license found in the
152
- * LICENSE file in the root directory of this source tree.
153
- */
154
- var et = Oe, tt = Symbol.for("react.element"), rt = Symbol.for("react.fragment"), at = Object.prototype.hasOwnProperty, nt = et.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, it = { key: !0, ref: !0, __self: !0, __source: !0 };
155
- function pe(e, t, a) {
156
- var r, n = {}, i = null, l = null;
157
- a !== void 0 && (i = "" + a), t.key !== void 0 && (i = "" + t.key), t.ref !== void 0 && (l = t.ref);
158
- for (r in t) at.call(t, r) && !it.hasOwnProperty(r) && (n[r] = t[r]);
159
- if (e && e.defaultProps) for (r in t = e.defaultProps, t) n[r] === void 0 && (n[r] = t[r]);
160
- return { $$typeof: tt, type: e, key: i, ref: l, props: n, _owner: nt.current };
161
- }
162
- A.Fragment = rt;
163
- A.jsx = pe;
164
- A.jsxs = pe;
165
- ue.exports = A;
166
- var s = ue.exports, st = Object.defineProperty, ot = Object.getOwnPropertyDescriptor, lt = (e, t, a, r) => {
167
- for (var n = r > 1 ? void 0 : r ? ot(t, a) : t, i = e.length - 1, l; i >= 0; i--)
168
- (l = e[i]) && (n = (r ? l(t, a, n) : l(n)) || n);
169
- return r && n && st(t, a, n), n;
170
- }, ct = (e, t) => (a, r) => t(a, r, e);
171
- let T = class extends ee {
52
+ var c = /* @__PURE__ */ ((e) => (e.UserInfo = "userInfo", e.Text = "text", e.Image = "image", e))(c || {}), F = Object.defineProperty, J = Object.getOwnPropertyDescriptor, Q = (e, t, r, i) => {
53
+ for (var a = i > 1 ? void 0 : i ? J(t, r) : t, s = e.length - 1, n; s >= 0; s--)
54
+ (n = e[s]) && (a = (i ? n(t, r, a) : n(a)) || a);
55
+ return i && a && F(t, r, a), a;
56
+ }, Z = (e, t) => (r, i) => t(r, i, e);
57
+ let w = class extends j {
172
58
  constructor(t) {
173
59
  super();
174
- k(this, "_updateConfig$", new G());
175
- k(this, "updateConfig$", this._updateConfig$.asObservable());
176
- k(this, "_refresh$", new G());
177
- k(this, "refresh$", this._refresh$.asObservable());
60
+ l(this, "_updateConfig$", new U());
61
+ l(this, "updateConfig$", this._updateConfig$.asObservable());
62
+ l(this, "_refresh$", new U());
63
+ l(this, "refresh$", this._refresh$.asObservable());
178
64
  this._localStorageService = t;
179
65
  }
180
66
  async getWatermarkConfig() {
181
- return await this._localStorageService.getItem(S);
67
+ return await this._localStorageService.getItem(_);
182
68
  }
183
69
  updateWatermarkConfig(t) {
184
- this._localStorageService.setItem(S, t), this._updateConfig$.next(t);
70
+ this._localStorageService.setItem(_, t), this._updateConfig$.next(t);
185
71
  }
186
72
  deleteWatermarkConfig() {
187
- this._localStorageService.removeItem(S), this._updateConfig$.next(null);
73
+ this._localStorageService.removeItem(_), this._updateConfig$.next(null);
188
74
  }
189
75
  refresh() {
190
76
  this._refresh$.next(Math.random());
@@ -193,702 +79,174 @@ let T = class extends ee {
193
79
  this._refresh$.complete(), this._updateConfig$.complete();
194
80
  }
195
81
  };
196
- T = lt([
197
- ct(0, j(F))
198
- ], T);
199
- const mt = "univer-watermark-panel", dt = "univer-watermark-panel-type-title", ut = "univer-watermark-panel-type-select", pt = "univer-watermark-panel-setting", gt = "univer-watermark-panel-footer", ht = "univer-watermark-panel-footer-button-wrapper", vt = "univer-watermark-panel-footer-reset", ft = "univer-watermark-text-setting", wt = "univer-watermark-text-setting-header", kt = "univer-watermark-text-setting-font-content", St = "univer-watermark-text-setting-font-style-part", xt = "univer-watermark-text-setting-layout-font-wrapper", _t = "univer-watermark-image-setting", yt = "univer-watermark-input", Ct = "univer-watermark-input-content", It = "univer-watermark-icon", jt = "univer-watermark-icon-wrapper", Nt = "univer-watermark-icon-wrapper-select", Tt = "univer-watermark-color-picker-wrapper", o = {
200
- watermarkPanel: mt,
201
- watermarkPanelTypeTitle: dt,
202
- watermarkPanelTypeSelect: ut,
203
- watermarkPanelSetting: pt,
204
- watermarkPanelFooter: gt,
205
- watermarkPanelFooterButtonWrapper: ht,
206
- watermarkPanelFooterReset: vt,
207
- watermarkTextSetting: ft,
208
- watermarkTextSettingHeader: wt,
209
- watermarkTextSettingFontContent: kt,
210
- watermarkTextSettingFontStylePart: St,
211
- watermarkTextSettingLayoutFontWrapper: xt,
212
- watermarkImageSetting: _t,
213
- watermarkInput: yt,
214
- watermarkInputContent: Ct,
215
- watermarkIcon: It,
216
- watermarkIconWrapper: jt,
217
- watermarkIconWrapperSelect: Nt,
218
- watermarkColorPickerWrapper: Tt
219
- }, Wt = ({ config: e, onChange: t }) => {
220
- const a = x(We), r = x(R);
221
- if (!e) return null;
222
- const n = async () => {
223
- const i = await a.openFile({
224
- multiple: !1,
225
- accept: Xe.map((p) => `.${p.replace("image/", "")}`).join(",")
226
- });
227
- if (i.length === 0)
228
- return !1;
229
- const d = i[0], u = new FileReader();
230
- u.onload = function(p) {
231
- var c;
232
- if ((c = p.target) != null && c.result) {
233
- const h = p.target.result, v = new Image();
234
- v.onload = function() {
235
- t({ ...e, url: h, width: Math.max(20, v.width), height: Math.max(v.height, 20), originRatio: v.width / v.height });
236
- }, v.src = h;
237
- }
238
- }, u.readAsDataURL(d);
239
- };
240
- return /* @__PURE__ */ s.jsxs("div", { className: o.watermarkImageSetting, children: [
241
- /* @__PURE__ */ s.jsx("div", { className: o.watermarkTextSettingHeader, children: r.t("univer-watermark.image") }),
242
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingLayout, children: [
243
- /* @__PURE__ */ s.jsx("span", { children: r.t("univer-watermark.image") }),
244
- /* @__PURE__ */ s.jsx(
245
- Y,
246
- {
247
- onClick: n,
248
- style: { marginLeft: 8 },
249
- children: e.url ? r.t("univer-watermark.replaceImage") : r.t("univer-watermark.uploadImage")
250
- }
251
- ),
252
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingFontStylePart, children: [
253
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingLayoutFontWrapper, children: [
254
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.opacity") }),
255
- /* @__PURE__ */ s.jsx(
256
- g,
257
- {
258
- value: e.opacity,
259
- onChange: (i) => {
260
- i != null && t({ ...e, opacity: Number.parseFloat(i.toString()) });
261
- },
262
- max: 1,
263
- min: 0,
264
- step: 0.05,
265
- className: o.watermarkInput
266
- }
267
- )
268
- ] }),
269
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingLayoutFontWrapper, children: [
270
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.keepRatio") }),
271
- /* @__PURE__ */ s.jsx(
272
- X,
273
- {
274
- checked: e.maintainAspectRatio,
275
- onChange: (i) => {
276
- t(i === !0 ? { ...e, maintainAspectRatio: i, height: Math.round(e.width / e.originRatio) } : { ...e, maintainAspectRatio: i });
277
- }
278
- }
279
- )
280
- ] })
281
- ] })
282
- ] }),
283
- /* @__PURE__ */ s.jsx("div", { className: o.watermarkTextSettingLayout, children: /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingFontStylePart, children: [
284
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingLayoutFontWrapper, children: [
285
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.width") }),
286
- /* @__PURE__ */ s.jsx(
287
- g,
288
- {
289
- value: e.width,
290
- onChange: (i) => {
291
- if (i != null) {
292
- const l = Math.max(20, Number.parseInt(i.toString()));
293
- e.maintainAspectRatio ? t({ ...e, width: l, height: Math.round(l / e.originRatio) }) : t({ ...e, width: l });
294
- }
295
- },
296
- min: 20,
297
- className: o.watermarkInput
298
- }
299
- )
300
- ] }),
301
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingLayoutFontWrapper, children: [
302
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.height") }),
303
- /* @__PURE__ */ s.jsx(
304
- g,
305
- {
306
- value: e.height,
307
- onChange: (i) => {
308
- if (i != null) {
309
- const l = Math.max(20, Number.parseInt(i.toString()));
310
- e.maintainAspectRatio ? t({ ...e, height: l, width: Math.round(l * e.originRatio) }) : t({ ...e, height: Number.parseInt(i.toString()) });
311
- }
312
- },
313
- min: 20,
314
- className: o.watermarkInput
315
- }
316
- )
317
- ] })
318
- ] }) }),
319
- /* @__PURE__ */ s.jsx("div", { className: o.watermarkTextSettingHeader, children: r.t("univer-watermark.layout") }),
320
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingLayout, children: [
321
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingFontStylePart, children: [
322
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingLayoutFontWrapper, children: [
323
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.rotate") }),
324
- /* @__PURE__ */ s.jsx(
325
- g,
326
- {
327
- value: e.rotate,
328
- onChange: (i) => {
329
- i != null && t({ ...e, rotate: Number.parseInt(i.toString()) });
330
- },
331
- max: 360,
332
- min: -360,
333
- className: o.watermarkInput
334
- }
335
- )
336
- ] }),
337
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingLayoutFontWrapper, children: [
338
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.repeat") }),
339
- /* @__PURE__ */ s.jsx(
340
- X,
341
- {
342
- checked: e.repeat,
343
- onChange: (i) => t({ ...e, repeat: i })
344
- }
345
- )
346
- ] })
347
- ] }),
348
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingFontStylePart, children: [
349
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingLayoutFontWrapper, children: [
350
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.spacingX") }),
351
- /* @__PURE__ */ s.jsx(
352
- g,
353
- {
354
- value: e.spacingX,
355
- onChange: (i) => {
356
- i != null && t({ ...e, spacingX: Number.parseInt(i.toString()) });
357
- },
358
- min: 0,
359
- className: o.watermarkInput
360
- }
361
- )
362
- ] }),
363
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingLayoutFontWrapper, children: [
364
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.spacingY") }),
365
- /* @__PURE__ */ s.jsx(
366
- g,
367
- {
368
- value: e.spacingY,
369
- onChange: (i) => {
370
- i != null && t({ ...e, spacingY: Number.parseInt(i.toString()) });
371
- },
372
- min: 0,
373
- className: o.watermarkInput
374
- }
375
- )
376
- ] })
377
- ] }),
378
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingFontStylePart, children: [
379
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingLayoutFontWrapper, children: [
380
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.startX") }),
381
- /* @__PURE__ */ s.jsx(
382
- g,
383
- {
384
- value: e.x,
385
- onChange: (i) => {
386
- i != null && t({ ...e, x: Number.parseInt(i.toString()) });
387
- },
388
- min: 0,
389
- className: o.watermarkInput
390
- }
391
- )
392
- ] }),
393
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingLayoutFontWrapper, children: [
394
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.startY") }),
395
- /* @__PURE__ */ s.jsx(
396
- g,
397
- {
398
- value: e.y,
399
- onChange: (i) => {
400
- i != null && t({ ...e, y: Number.parseInt(i.toString()) });
401
- },
402
- min: 0,
403
- className: o.watermarkInput
404
- }
405
- )
406
- ] })
407
- ] })
408
- ] })
409
- ] });
410
- };
411
- function ge(e) {
412
- var t, a, r = "";
413
- if (typeof e == "string" || typeof e == "number") r += e;
414
- else if (typeof e == "object") if (Array.isArray(e)) {
415
- var n = e.length;
416
- for (t = 0; t < n; t++) e[t] && (a = ge(e[t])) && (r && (r += " "), r += a);
417
- } else for (a in e) e[a] && (r && (r += " "), r += a);
418
- return r;
419
- }
420
- function q() {
421
- for (var e, t, a = 0, r = "", n = arguments.length; a < n; a++) (e = arguments[a]) && (t = ge(e)) && (r && (r += " "), r += t);
422
- return r;
423
- }
424
- const bt = (e) => {
425
- var n;
426
- const { config: t, onChange: a } = e, r = x(R);
427
- return t ? /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSetting, children: [
428
- /* @__PURE__ */ s.jsx("div", { className: o.watermarkTextSettingHeader, children: r.t("univer-watermark.style") }),
429
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingFontContent, children: [
430
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.content") }),
431
- /* @__PURE__ */ s.jsx(
432
- Ue,
433
- {
434
- value: t.content,
435
- onChange: (i) => a({ ...t, content: i }),
436
- className: o.watermarkInputContent,
437
- placeholder: r.t("univer-watermark.textPlaceholder")
438
- }
439
- )
440
- ] }),
441
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingFontStyle, children: [
442
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingFontStylePart, children: [
443
- /* @__PURE__ */ s.jsxs("div", { children: [
444
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.fontSize") }),
445
- /* @__PURE__ */ s.jsx(
446
- g,
447
- {
448
- value: t.fontSize,
449
- onChange: (i) => {
450
- i != null && a({ ...t, fontSize: Number.parseInt(i.toString()) });
451
- },
452
- max: 72,
453
- min: 12,
454
- className: o.watermarkInput
455
- }
456
- )
457
- ] }),
458
- /* @__PURE__ */ s.jsxs("div", { style: { margin: "0 8px" }, children: [
459
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.direction") }),
460
- /* @__PURE__ */ s.jsx(
461
- re,
462
- {
463
- value: t.direction,
464
- onChange: (i) => a({ ...t, direction: i }),
465
- options: [
466
- { label: r.t("univer-watermark.ltr"), value: "ltr" },
467
- { label: r.t("univer-watermark.rtl"), value: "rtl" }
468
- ]
469
- }
470
- )
471
- ] }),
472
- /* @__PURE__ */ s.jsxs("div", { children: [
473
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.opacity") }),
474
- /* @__PURE__ */ s.jsx(
475
- g,
476
- {
477
- value: t.opacity,
478
- onChange: (i) => {
479
- i != null && a({ ...t, opacity: Number.parseFloat(i.toString()) });
480
- },
481
- max: 1,
482
- min: 0,
483
- step: 0.05,
484
- className: o.watermarkInput
485
- }
486
- )
487
- ] })
488
- ] }),
489
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingFontStylePart, children: [
490
- /* @__PURE__ */ s.jsx("div", { className: o.watermarkIconWrapper, children: /* @__PURE__ */ s.jsx(
491
- $e,
492
- {
493
- overlay: /* @__PURE__ */ s.jsx("div", { className: o.watermarkColorPickerWrapper, children: /* @__PURE__ */ s.jsx(De, { color: t.color, onChange: (i) => a({ ...t, color: i }) }) }),
494
- children: /* @__PURE__ */ s.jsx(ce, { className: o.watermarkIcon, extend: { colorChannel1: (n = t.color) != null ? n : "rgb(var(--primary-color))" } })
495
- }
496
- ) }),
497
- /* @__PURE__ */ s.jsx("div", { className: q(o.watermarkIconWrapper, { [o.watermarkIconWrapperSelect]: t.bold }), onClick: () => {
498
- a({ ...t, bold: !t.bold });
499
- }, children: /* @__PURE__ */ s.jsx(le, { className: o.watermarkIcon }) }),
500
- /* @__PURE__ */ s.jsx("div", { className: q(o.watermarkIconWrapper, { [o.watermarkIconWrapperSelect]: t.italic }), onClick: () => {
501
- a({ ...t, italic: !t.italic });
502
- }, children: /* @__PURE__ */ s.jsx(me, { className: o.watermarkIcon }) })
503
- ] })
504
- ] }),
505
- /* @__PURE__ */ s.jsx("div", { className: o.watermarkTextSettingHeader, children: r.t("univer-watermark.layout") }),
506
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingLayout, children: [
507
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingFontStylePart, children: [
508
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingLayoutFontWrapper, children: [
509
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.rotate") }),
510
- /* @__PURE__ */ s.jsx(
511
- g,
512
- {
513
- value: t.rotate,
514
- onChange: (i) => {
515
- i != null && a({ ...t, rotate: Number.parseInt(i.toString()) });
516
- },
517
- max: 360,
518
- min: -360,
519
- className: o.watermarkInput
520
- }
521
- )
522
- ] }),
523
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingLayoutFontWrapper, children: [
524
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.repeat") }),
525
- /* @__PURE__ */ s.jsx(
526
- X,
527
- {
528
- checked: t.repeat,
529
- onChange: (i) => a({ ...t, repeat: i })
530
- }
531
- )
532
- ] })
533
- ] }),
534
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingFontStylePart, children: [
535
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingLayoutFontWrapper, children: [
536
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.spacingX") }),
537
- /* @__PURE__ */ s.jsx(
538
- g,
539
- {
540
- value: t.spacingX,
541
- onChange: (i) => {
542
- i != null && a({ ...t, spacingX: Number.parseInt(i.toString()) });
543
- },
544
- min: 0,
545
- className: o.watermarkInput
546
- }
547
- )
548
- ] }),
549
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingLayoutFontWrapper, children: [
550
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.spacingY") }),
551
- /* @__PURE__ */ s.jsx(
552
- g,
553
- {
554
- value: t.spacingY,
555
- onChange: (i) => {
556
- i != null && a({ ...t, spacingY: Number.parseInt(i.toString()) });
557
- },
558
- min: 0,
559
- className: o.watermarkInput
560
- }
561
- )
562
- ] })
563
- ] }),
564
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingFontStylePart, children: [
565
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingLayoutFontWrapper, children: [
566
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.startX") }),
567
- /* @__PURE__ */ s.jsx(
568
- g,
569
- {
570
- value: t.x,
571
- onChange: (i) => {
572
- i != null && a({ ...t, x: Number.parseInt(i.toString()) });
573
- },
574
- min: 0,
575
- className: o.watermarkInput
576
- }
577
- )
578
- ] }),
579
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkTextSettingLayoutFontWrapper, children: [
580
- /* @__PURE__ */ s.jsx("div", { children: r.t("univer-watermark.startY") }),
581
- /* @__PURE__ */ s.jsx(
582
- g,
583
- {
584
- value: t.y,
585
- onChange: (i) => {
586
- i != null && a({ ...t, y: Number.parseInt(i.toString()) });
587
- },
588
- min: 0,
589
- className: o.watermarkInput
590
- }
591
- )
592
- ] })
593
- ] })
594
- ] })
595
- ] }) : null;
596
- }, Rt = () => {
597
- const [e, t] = z(m.Text), [a, r] = z(), n = x(T), i = x(F), l = we(n.refresh$), d = x(R);
598
- function u(c, h) {
599
- r(c), n.updateWatermarkConfig({ type: h != null ? h : e, config: c });
600
- }
601
- const p = Fe(async () => {
602
- const c = await i.getItem(S);
603
- c ? (t(c.type), r(c.config)) : r({ text: O });
604
- }, []);
605
- return Ae(() => {
606
- p();
607
- }, [l, p]), /* @__PURE__ */ s.jsxs("div", { className: o.watermarkPanel, children: [
608
- /* @__PURE__ */ s.jsx("div", { className: o.watermarkPanelTypeTitle, children: d.t("univer-watermark.type") }),
609
- /* @__PURE__ */ s.jsx(
610
- re,
611
- {
612
- value: e,
613
- onChange: (c) => {
614
- t(c), c === m.Text ? u({ text: O }, m.Text) : c === m.Image && u({ image: se }, m.Image);
615
- },
616
- options: [
617
- { label: d.t("univer-watermark.text"), value: m.Text },
618
- { label: d.t("univer-watermark.image"), value: m.Image }
619
- ],
620
- className: o.watermarkPanelTypeSelect
621
- }
622
- ),
623
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkPanelSetting, children: [
624
- e === m.Text && /* @__PURE__ */ s.jsx(bt, { config: a == null ? void 0 : a.text, onChange: (c) => u({ text: c }) }),
625
- e === m.Image && /* @__PURE__ */ s.jsx(Wt, { config: a == null ? void 0 : a.image, onChange: (c) => u({ image: c }) })
626
- ] })
627
- ] });
628
- }, Pt = () => {
629
- const e = x(te), t = x(T), a = x(R), r = x(be);
630
- return /* @__PURE__ */ s.jsxs("div", { className: o.watermarkPanelFooter, children: [
631
- /* @__PURE__ */ s.jsx(
632
- "div",
633
- {
634
- className: o.watermarkPanelFooterReset,
635
- onClick: () => {
636
- t.updateWatermarkConfig({
637
- type: m.Text,
638
- config: { text: O }
639
- }), t.refresh();
640
- },
641
- children: a.t("univer-watermark.cancel")
642
- }
643
- ),
644
- /* @__PURE__ */ s.jsxs("div", { className: o.watermarkPanelFooterButtonWrapper, children: [
645
- /* @__PURE__ */ s.jsx(
646
- Y,
647
- {
648
- style: { marginRight: 8 },
649
- onClick: async () => {
650
- const n = await t.getWatermarkConfig();
651
- let i;
652
- (n == null ? void 0 : n.type) === m.Text ? i = n.config.text : (n == null ? void 0 : n.type) === m.Image && (i = n.config.image), r.writeText(JSON.stringify(i));
653
- },
654
- children: a.t("univer-watermark.copy")
655
- }
656
- ),
657
- /* @__PURE__ */ s.jsx(
658
- Y,
659
- {
660
- onClick: async () => {
661
- var i, l;
662
- const n = await t.getWatermarkConfig();
663
- ((n == null ? void 0 : n.type) === m.Text && !((i = n.config.text) != null && i.content) || (n == null ? void 0 : n.type) === m.Image && !((l = n.config.image) != null && l.url)) && t.deleteWatermarkConfig(), e.close();
664
- },
665
- children: a.t("univer-watermark.close")
666
- }
667
- )
668
- ] })
669
- ] });
670
- };
671
- function Lt(e) {
672
- return {
673
- id: K.id,
674
- title: "univer-watermark.title",
675
- tooltip: "univer-watermark.title",
676
- icon: ae,
677
- type: Re.BUTTON,
678
- hidden$: Mt(e)
679
- };
680
- }
681
- function Mt(e) {
682
- return e.get(ke).focused$.pipe(
683
- He((a) => a === Se ? Z(!0) : Z(!1))
684
- );
685
- }
686
- const Ot = {
687
- [Pe.OTHERS]: {
688
- [K.id]: {
689
- order: 0,
690
- menuItemFactory: Lt
691
- }
692
- }
693
- };
694
- var Et = Object.defineProperty, Ft = Object.getOwnPropertyDescriptor, At = (e, t, a, r) => {
695
- for (var n = r > 1 ? void 0 : r ? Ft(t, a) : t, i = e.length - 1, l; i >= 0; i--)
696
- (l = e[i]) && (n = (r ? l(t, a, n) : l(n)) || n);
697
- return r && n && Et(t, a, n), n;
698
- }, J = (e, t) => (a, r) => t(a, r, e);
699
- let E = class extends ee {
700
- constructor(e, t) {
701
- super(), this._menuManagerService = e, this._componentManager = t, this._initMenu(), this._initComponents();
702
- }
703
- _initComponents() {
704
- [
705
- [ae, de],
706
- [ne, Rt],
707
- [ie, Pt]
708
- ].forEach(([e, t]) => {
709
- this.disposeWithMe(this._componentManager.register(e, t));
710
- });
711
- }
712
- _initMenu() {
713
- this._menuManagerService.mergeMenu(Ot);
714
- }
715
- };
716
- E = At([
717
- J(0, Me),
718
- J(1, j(Le))
719
- ], E);
720
- function Ut(e, t, a, r) {
721
- const n = t.type, i = t.config;
722
- n === m.UserInfo && i.userInfo ? $t(e, i.userInfo, r) : n === m.Image && i.image ? Ht(e, i.image, a) : n === m.Text && i.text && Dt(e, i.text);
82
+ w = Q([
83
+ Z(0, W(E))
84
+ ], w);
85
+ function x(e, t, r, i) {
86
+ const a = t.type, s = t.config;
87
+ a === c.UserInfo && s.userInfo ? ee(e, s.userInfo, i) : a === c.Image && s.image ? re(e, s.image, r) : a === c.Text && s.text && te(e, s.text);
723
88
  }
724
- function $t(e, t, a) {
725
- const { x: r, y: n, repeat: i, spacingX: l, spacingY: d, rotate: u, opacity: p, name: c, fontSize: h, color: v, bold: W, italic: N, direction: w } = t;
726
- if (!a)
89
+ function ee(e, t, r) {
90
+ const { x: i, y: a, repeat: s, spacingX: n, spacingY: S, rotate: v, opacity: m, name: p, fontSize: I, color: y, bold: C, italic: u, direction: o } = t;
91
+ if (!r)
727
92
  return;
728
- let _ = "";
729
- if (c && (_ += `${a.name} `), !_)
93
+ let f = "";
94
+ if (p && (f += `${r.name} `), !f)
730
95
  return;
731
- e.save(), e.globalAlpha = p, e.direction = w;
732
- let I = "";
733
- if (N && (I += "italic "), W && (I += "bold "), I += `${h}px Arial`, e.font = I, e.fillStyle = v, i) {
734
- const y = e.canvas.width, C = e.canvas.height;
735
- for (let U = n; U < C; U += h + d)
736
- for (let $ = r; $ < y; $ += e.measureText(_).width + l)
737
- e.save(), e.translate($, U), e.rotate(Math.PI / 180 * u), e.fillText(_, 0, 0), e.restore();
96
+ e.save(), e.globalAlpha = m, e.direction = o;
97
+ let d = "";
98
+ if (u && (d += "italic "), C && (d += "bold "), d += `${I}px Arial`, e.font = d, e.fillStyle = y, s) {
99
+ const g = e.canvas.width, h = e.canvas.height;
100
+ for (let b = a; b < h; b += I + S)
101
+ for (let k = i; k < g; k += e.measureText(f).width + n)
102
+ e.save(), e.translate(k, b), e.rotate(Math.PI / 180 * v), e.fillText(f, 0, 0), e.restore();
738
103
  } else
739
- e.save(), e.translate(r, n), e.rotate(Math.PI / 180 * u), e.fillText(_, 0, 0), e.restore();
104
+ e.save(), e.translate(i, a), e.rotate(Math.PI / 180 * v), e.fillText(f, 0, 0), e.restore();
740
105
  e.restore();
741
106
  }
742
- function Dt(e, t) {
743
- const { x: a, y: r, repeat: n, spacingX: i, spacingY: l, rotate: d, opacity: u, content: p, fontSize: c, color: h, bold: v, italic: W, direction: N } = t;
744
- e.save(), e.globalAlpha = u, e.direction = N;
745
- let w = "";
746
- if (W && (w += "italic "), v && (w += "bold "), w += `${c}px Arial`, e.font = w, e.fillStyle = h, p)
747
- if (n) {
748
- const _ = e.canvas.width, I = e.canvas.height;
749
- for (let y = r; y < I; y += c + l)
750
- for (let C = a; C < _; C += e.measureText(p).width + i)
751
- e.save(), e.translate(C, y), e.rotate(Math.PI / 180 * d), e.fillText(p, 0, 0), e.restore();
107
+ function te(e, t) {
108
+ const { x: r, y: i, repeat: a, spacingX: s, spacingY: n, rotate: S, opacity: v, content: m, fontSize: p, color: I, bold: y, italic: C, direction: u } = t;
109
+ e.save(), e.globalAlpha = v, e.direction = u;
110
+ let o = "";
111
+ if (C && (o += "italic "), y && (o += "bold "), o += `${p}px Arial`, e.font = o, e.fillStyle = I, m)
112
+ if (a) {
113
+ const f = e.canvas.width, d = e.canvas.height;
114
+ for (let g = i; g < d; g += p + n)
115
+ for (let h = r; h < f; h += e.measureText(m).width + s)
116
+ e.save(), e.translate(h, g), e.rotate(Math.PI / 180 * S), e.fillText(m, 0, 0), e.restore();
752
117
  } else
753
- e.save(), e.translate(a, r), e.rotate(Math.PI / 180 * d), e.fillText(p, 0, 0), e.restore();
118
+ e.save(), e.translate(r, i), e.rotate(Math.PI / 180 * S), e.fillText(m, 0, 0), e.restore();
754
119
  e.restore();
755
120
  }
756
- function Ht(e, t, a) {
757
- const { x: r, y: n, repeat: i, spacingX: l, spacingY: d, rotate: u, opacity: p, width: c, height: h, maintainAspectRatio: v, originRatio: W } = t;
758
- if (!(a != null && a.complete))
121
+ function re(e, t, r) {
122
+ const { x: i, y: a, repeat: s, spacingX: n, spacingY: S, rotate: v, opacity: m, width: p, height: I, maintainAspectRatio: y, originRatio: C } = t;
123
+ if (!(r != null && r.complete))
759
124
  return;
760
- e.save(), e.globalAlpha = p;
761
- const N = c, w = v ? c / W : h;
762
- if (i) {
763
- const _ = e.canvas.width, I = e.canvas.height;
764
- for (let y = n; y < I; y += w + d)
765
- for (let C = r; C < _; C += N + l)
766
- e.save(), e.translate(C, y), e.rotate(Math.PI / 180 * u), e.drawImage(a, 0, 0, N, w), e.restore();
125
+ e.save(), e.globalAlpha = m;
126
+ const u = p, o = y ? p / C : I;
127
+ if (s) {
128
+ const f = e.canvas.width, d = e.canvas.height;
129
+ for (let g = a; g < d; g += o + S)
130
+ for (let h = i; h < f; h += u + n)
131
+ e.save(), e.translate(h, g), e.rotate(Math.PI / 180 * v), e.drawImage(r, 0, 0, u, o), e.restore();
767
132
  } else
768
- e.save(), e.translate(r, n), e.rotate(Math.PI / 180 * u), e.drawImage(a, 0, 0, N, w), e.restore();
133
+ e.save(), e.translate(i, a), e.rotate(Math.PI / 180 * v), e.drawImage(r, 0, 0, u, o), e.restore();
769
134
  e.restore();
770
135
  }
771
- class Yt extends Ne {
136
+ class ae extends G {
772
137
  constructor() {
773
138
  super(...arguments);
774
- k(this, "_config");
775
- k(this, "_image");
776
- k(this, "_user");
139
+ l(this, "_config");
140
+ l(this, "_image");
141
+ l(this, "_user");
777
142
  }
778
- render(a, r = !1) {
779
- var i;
780
- super.render(a, r);
781
- const n = a || ((i = this.scene.getEngine()) == null ? void 0 : i.getCanvas().getContext());
782
- return n && n.getId() && this._renderWatermark(n), this;
143
+ render(r, i = !1) {
144
+ var s;
145
+ super.render(r, i);
146
+ const a = r || ((s = this.scene.getEngine()) == null ? void 0 : s.getCanvas().getContext());
147
+ return a && a.getId() && this._renderWatermark(a), this;
783
148
  }
784
- updateConfig(a, r) {
785
- var n;
786
- this._config = a, ((n = this._config) == null ? void 0 : n.type) === m.Image && this._config.config.image && (this._image = new Image(), this._image.src = this._config.config.image.url), r && (this._user = r);
149
+ updateConfig(r, i) {
150
+ var a;
151
+ this._config = r, ((a = this._config) == null ? void 0 : a.type) === c.Image && this._config.config.image && (this._image = new Image(), this._image.src = this._config.config.image.url), i && (this._user = i);
787
152
  }
788
- _renderWatermark(a) {
789
- this._config && Ut(a, this._config, this._image, this._user);
153
+ _renderWatermark(r) {
154
+ this._config && x(r, this._config, this._image, this._user);
790
155
  }
791
156
  }
792
- var Xt = Object.defineProperty, Bt = Object.getOwnPropertyDescriptor, Kt = (e, t, a, r) => {
793
- for (var n = r > 1 ? void 0 : r ? Bt(t, a) : t, i = e.length - 1, l; i >= 0; i--)
794
- (l = e[i]) && (n = (r ? l(t, a, n) : l(n)) || n);
795
- return r && n && Xt(t, a, n), n;
796
- }, D = (e, t) => (a, r) => t(a, r, e);
797
- let B = class extends _e {
798
- constructor(t, a, r, n) {
157
+ var ie = Object.defineProperty, se = Object.getOwnPropertyDescriptor, ne = (e, t, r, i) => {
158
+ for (var a = i > 1 ? void 0 : i ? se(t, r) : t, s = e.length - 1, n; s >= 0; s--)
159
+ (n = e[s]) && (a = (i ? n(t, r, a) : n(a)) || a);
160
+ return i && a && ie(t, r, a), a;
161
+ }, A = (e, t) => (r, i) => t(r, i, e);
162
+ let P = class extends Y {
163
+ constructor(t, r, i, a) {
799
164
  super();
800
- k(this, "_watermarkLayer");
801
- this._context = t, this._watermarkService = a, this._localStorageService = r, this._userManagerService = n, this._watermarkLayer = new Yt(t.scene, [], Ye), this._initAddRender(), this._initWatermarkUpdate(), this._initWatermarkConfig();
165
+ l(this, "_watermarkLayer");
166
+ this._context = t, this._watermarkService = r, this._localStorageService = i, this._userManagerService = a, this._watermarkLayer = new ae(t.scene, [], H), this._initAddRender(), this._initWatermarkUpdate(), this._initWatermarkConfig();
802
167
  }
803
168
  _initAddRender() {
804
169
  const { scene: t } = this._context;
805
170
  t.addLayer(this._watermarkLayer);
806
171
  }
807
172
  async _initWatermarkConfig() {
808
- var a;
809
- const t = await this._localStorageService.getItem(S);
810
- t && (this._watermarkService.updateWatermarkConfig(t), (a = this._context.mainComponent) == null || a.makeDirty());
173
+ var r;
174
+ const t = await this._localStorageService.getItem(_);
175
+ t && (this._watermarkService.updateWatermarkConfig(t), (r = this._context.mainComponent) == null || r.makeDirty());
811
176
  }
812
177
  _initWatermarkUpdate() {
813
178
  this.disposeWithMe(
814
179
  this._watermarkService.updateConfig$.subscribe((t) => {
815
- var a, r;
180
+ var r, i;
816
181
  if (!t) {
817
- this._watermarkLayer.updateConfig(), (a = this._context.mainComponent) == null || a.makeDirty();
182
+ this._watermarkLayer.updateConfig(), (r = this._context.mainComponent) == null || r.makeDirty();
818
183
  return;
819
184
  }
820
- t.type === m.UserInfo ? this._watermarkLayer.updateConfig(t, this._userManagerService.getCurrentUser()) : this._watermarkLayer.updateConfig(t), (r = this._context.mainComponent) == null || r.makeDirty();
185
+ t.type === c.UserInfo ? this._watermarkLayer.updateConfig(t, this._userManagerService.getCurrentUser()) : this._watermarkLayer.updateConfig(t), (i = this._context.mainComponent) == null || i.makeDirty();
821
186
  })
822
187
  );
823
188
  }
824
189
  };
825
- B = Kt([
826
- D(1, j(T)),
827
- D(2, j(F)),
828
- D(3, j(xe))
829
- ], B);
830
- var Vt = Object.defineProperty, zt = Object.getOwnPropertyDescriptor, Gt = (e, t, a, r) => {
831
- for (var n = r > 1 ? void 0 : r ? zt(t, a) : t, i = e.length - 1, l; i >= 0; i--)
832
- (l = e[i]) && (n = (r ? l(t, a, n) : l(n)) || n);
833
- return r && n && Vt(t, a, n), n;
834
- }, b = (e, t) => (a, r) => t(a, r, e);
835
- const Zt = "UNIVER_WATERMARK_PLUGIN";
836
- var H;
837
- let Q = (H = class extends Ie {
838
- constructor(e = {}, t, a, r, n, i) {
839
- super(), this._config = e, this._injector = t, this._configService = a, this._commandService = r, this._renderManagerSrv = n, this._localStorageService = i;
840
- const { menu: l } = this._config;
841
- l && this._configService.setConfig("menu", l, { merge: !0 }), this._initWatermarkStorage(), this._initDependencies(), this._initRegisterCommand();
190
+ P = ne([
191
+ A(1, W(w)),
192
+ A(2, W(E)),
193
+ A(3, W(L))
194
+ ], P);
195
+ var oe = Object.defineProperty, le = Object.getOwnPropertyDescriptor, ce = (e, t, r, i) => {
196
+ for (var a = i > 1 ? void 0 : i ? le(t, r) : t, s = e.length - 1, n; s >= 0; s--)
197
+ (n = e[s]) && (a = (i ? n(t, r, a) : n(a)) || a);
198
+ return i && a && oe(t, r, a), a;
199
+ }, R = (e, t) => (r, i) => t(r, i, e);
200
+ const fe = "UNIVER_WATERMARK_PLUGIN";
201
+ var M;
202
+ let T = (M = class extends X {
203
+ constructor(e = {}, t, r, i, a) {
204
+ super(), this._config = e, this._injector = t, this._configService = r, this._renderManagerSrv = i, this._localStorageService = a;
205
+ const { menu: s } = this._config;
206
+ s && this._configService.setConfig("menu", s, { merge: !0 }), this._initWatermarkStorage(), this._initDependencies();
842
207
  }
843
208
  async _initWatermarkStorage() {
844
209
  const { menu: e, ...t } = this._config;
845
210
  if (t.userWatermarkSettings)
846
- this._localStorageService.setItem(S, { type: m.UserInfo, config: { userInfo: { ...Be, ...t.userWatermarkSettings } } });
211
+ this._localStorageService.setItem(_, { type: c.UserInfo, config: { userInfo: { ...q, ...t.userWatermarkSettings } } });
847
212
  else if (t.textWatermarkSettings)
848
- this._localStorageService.setItem(S, { type: m.Text, config: { text: { ...O, ...t.textWatermarkSettings } } });
213
+ this._localStorageService.setItem(_, { type: c.Text, config: { text: { ...z, ...t.textWatermarkSettings } } });
849
214
  else if (t.imageWatermarkSettings)
850
- this._localStorageService.setItem(S, { type: m.Image, config: { image: { ...se, ...t.imageWatermarkSettings } } });
215
+ this._localStorageService.setItem(_, { type: c.Image, config: { image: { ...B, ...t.imageWatermarkSettings } } });
851
216
  else {
852
- const a = await this._localStorageService.getItem(S);
853
- (a == null ? void 0 : a.type) === m.UserInfo && this._localStorageService.removeItem(S);
217
+ const r = await this._localStorageService.getItem(_);
218
+ (r == null ? void 0 : r.type) === c.UserInfo && this._localStorageService.removeItem(_);
854
219
  }
855
220
  }
856
221
  _initDependencies() {
857
- [[T], [E]].forEach((e) => {
222
+ [[w]].forEach((e) => {
858
223
  this._injector.add(e);
859
224
  });
860
225
  }
861
- _initRegisterCommand() {
862
- [
863
- K
864
- ].forEach((e) => this._commandService.registerCommand(e));
865
- }
866
226
  onRendered() {
867
- const e = this._injector;
868
- e.get(T);
869
- const { userWatermarkSettings: t, textWatermarkSettings: a, imageWatermarkSettings: r, showMenu: n = !0 } = this._config;
870
- !(t || a || r) && n && e.get(E), this._initRenderDependencies();
227
+ this._injector.get(w), this._initRenderDependencies();
871
228
  }
872
229
  _initRenderDependencies() {
873
230
  [
874
- [B]
231
+ [P]
875
232
  ].forEach((e) => {
876
- this._renderManagerSrv.registerRenderModule(V.UNIVER_SHEET, e), this._renderManagerSrv.registerRenderModule(V.UNIVER_DOC, e);
233
+ this._renderManagerSrv.registerRenderModule($.UNIVER_SHEET, e), this._renderManagerSrv.registerRenderModule($.UNIVER_DOC, e);
877
234
  });
878
235
  }
879
- }, k(H, "pluginName", Zt), H);
880
- Q = Gt([
881
- b(1, j(ye)),
882
- b(2, je),
883
- b(3, j(Ce)),
884
- b(4, Te),
885
- b(5, j(F))
886
- ], Q);
236
+ }, l(M, "pluginName", fe), M);
237
+ T = ce([
238
+ R(1, W(N)),
239
+ R(2, K),
240
+ R(3, V),
241
+ R(4, W(E))
242
+ ], T);
887
243
  export {
888
- m as IWatermarkTypeEnum,
889
- Q as UniverWatermarkPlugin,
890
- se as WatermarkImageBaseConfig,
891
- T as WatermarkService,
892
- O as WatermarkTextBaseConfig,
893
- Be as WatermarkUserInfoBaseConfig
244
+ c as IWatermarkTypeEnum,
245
+ _ as UNIVER_WATERMARK_STORAGE_KEY,
246
+ T as UniverWatermarkPlugin,
247
+ pe as WATERMARK_IMAGE_ALLOW_IMAGE_LIST,
248
+ B as WatermarkImageBaseConfig,
249
+ w as WatermarkService,
250
+ z as WatermarkTextBaseConfig,
251
+ q as WatermarkUserInfoBaseConfig
894
252
  };