@baohu/canvas-editor-ui 0.0.0-stage → 1.1.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.
@@ -0,0 +1,1085 @@
1
+ (function(){"use strict";try{if(typeof document!="undefined"){var e=document.createElement("style");e.id="canvas-editor-ui-style",e.appendChild(document.createTextNode(`.ceu-root{position:relative;display:flex;flex-direction:column;width:100%;height:100%;min-height:0;background:#f2f4f7;color:#3d4757;font-size:12px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,PingFang SC,Microsoft YaHei,sans-serif;box-sizing:border-box}.ceu-root *,.ceu-dialog-container *{box-sizing:border-box}.ceu-main{position:relative;flex:1;min-height:0;overflow:auto}.ceu-editor>div{margin:20px auto}.ceu-icon{display:inline-block;width:16px;height:16px;background-repeat:no-repeat;background-size:100% 100%}.ceu-active{background:#19375814}.ceu-disabled{opacity:.4;pointer-events:none}.ceu-toolbar{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:4px 2px;padding:8px 12px;background:#f2f4f7;border-bottom:1px solid #e2e6ed;user-select:none}.ceu-toolbar__divider{width:1px;height:16px;margin:0 6px;background:#cfd2d8}.ceu-toolbar__button,.ceu-statusbar__button{position:relative;display:flex;align-items:center;justify-content:center;min-width:24px;height:24px;padding:0 4px;cursor:pointer}.ceu-toolbar__button:hover,.ceu-statusbar__button:hover,.ceu-select:hover{background:#1937580a}.ceu-toolbar__item.ceu-active>.ceu-toolbar__button,.ceu-toolbar__button.ceu-active{background:#19375814}.ceu-toolbar__text{margin-left:2px;white-space:nowrap}.ceu-toolbar__button--arrow:after,.ceu-select:after{content:"";width:0;height:0;margin-left:3px;border:3px solid transparent;border-top:4px solid #767c85;transform:translateY(2px)}.ceu-select{display:flex;align-items:center;justify-content:space-between;height:24px;padding:0 4px;cursor:pointer}.ceu-select__label{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.ceu-color{flex-direction:column}.ceu-color .ceu-icon{width:14px;height:12px}.ceu-color__bar{width:14px;height:3px;margin-top:1px;border:1px solid #e2e6ed}.ceu-color__input{position:absolute;left:0;bottom:0;width:0;height:0;padding:0;border:0;opacity:0;pointer-events:none}.ceu-dropdown{position:relative}.ceu-dropdown__panel{position:absolute;left:0;z-index:10;display:none;min-width:100%;padding:6px;background:#fff;border:1px solid #e2e6ed;border-radius:2px;box-shadow:0 2px 12px #38383833}.ceu-dropdown__panel--bottom{top:calc(100% + 4px)}.ceu-dropdown__panel--top{bottom:calc(100% + 4px)}.ceu-dropdown__panel--visible{display:block}.ceu-option-list{margin:0;padding:0;list-style:none;max-height:300px;overflow-y:auto}.ceu-option-list li{display:flex;align-items:center;gap:6px;padding:5px 10px;white-space:nowrap;cursor:pointer}.ceu-option-list li:hover{background:#ebecef}.ceu-option-list li.ceu-active{background:#e2e6ed}.ceu-table-picker__title{padding:2px 2px 6px;color:#3d4757}.ceu-table-picker__grid{display:grid;grid-template-columns:repeat(10,16px);gap:3px}.ceu-table-picker__grid span{width:16px;height:16px;border:1px solid #e2e6ed;cursor:pointer}.ceu-table-picker__grid span.ceu-active{background:#4991f226;border-color:#4991f280}.ceu-statusbar{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:4px 12px;min-height:30px;padding:2px 8px 2px 16px;background:#f2f4f7;border-top:1px solid #e2e6ed;user-select:none}.ceu-statusbar__left,.ceu-statusbar__right,.ceu-statusbar__group{display:flex;align-items:center;gap:4px}.ceu-statusbar__left{gap:12px}.ceu-statusbar__left>span{white-space:nowrap;letter-spacing:1px}.ceu-statusbar__scale,.ceu-statusbar__mode{display:inline-block;padding:0 6px;line-height:24px;white-space:nowrap;cursor:pointer}.ceu-statusbar__scale:hover,.ceu-statusbar__mode:hover{background:#1937580a}.ceu-statusbar .ceu-dropdown__panel{left:auto;right:0}.ceu-dialog-mask{position:fixed;inset:0;z-index:2000;background:#00000080}.ceu-dialog-container{position:fixed;inset:0;z-index:2001;display:flex;align-items:center;justify-content:center;overflow:auto;font-size:14px;color:#3d4757}.ceu-dialog{width:420px;max-width:calc(100vw - 32px);padding:0 24px 24px;background:#fff;border:1px solid #e2e6ed;border-radius:2px;box-shadow:0 2px 12px #38383833}.ceu-dialog__title{display:flex;align-items:center;justify-content:space-between;height:56px;margin-bottom:20px;border-bottom:1px solid #e2e6ed}.ceu-dialog__close{width:16px;height:16px;cursor:pointer;background:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8.9%208.192l4.242%204.243-.707.707L8.192%208.9%203.95%2013.142l-.707-.707%204.242-4.243L3.243%203.95l.707-.707%204.242%204.242%204.243-4.242.707.707L8.9%208.192z'%20fill='%236A6A6A'%20fill-rule='evenodd'/%3e%3c/svg%3e") no-repeat}.ceu-dialog__field{display:flex;align-items:center;gap:12px;margin-bottom:16px}.ceu-dialog__label{position:relative;flex-shrink:0;width:64px;text-align:right}.ceu-dialog__label--required:before{content:"*";position:absolute;left:-8px;color:#f56c6c}.ceu-dialog__field input,.ceu-dialog__field textarea,.ceu-dialog__field select{flex:1;min-width:0;height:30px;padding:5px;font:inherit;border:1px solid #d3d3d3;border-radius:2px;outline:none}.ceu-dialog__field textarea{resize:vertical}.ceu-dialog__field input:focus,.ceu-dialog__field textarea:focus,.ceu-dialog__field select:focus{border-color:#4991f2}.ceu-dialog__field .ceu-dialog__input--error{border-color:#f56c6c}.ceu-dialog__footer{display:flex;justify-content:flex-end;gap:12px;margin-top:8px}.ceu-dialog__footer button{padding:0 16px;line-height:26px;font:inherit;background:#fff;border:1px solid #e2e6ed;border-radius:2px;cursor:pointer}.ceu-dialog__footer button:hover{background:#1937580a}.ceu-dialog__footer .ceu-dialog__confirm{color:#fff;background:#4991f2;border-color:#4991f2}.ceu-dialog__footer .ceu-dialog__confirm:hover{background:#5b9cf3}`)),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
2
+ import X, { EDITOR_COMPONENT as T, EditorComponent as k, EditorMode as w, PageMode as S, PaperDirection as V, RowFlex as L, ElementType as E, TitleLevel as z, ListType as _, ListStyle as y, CheckboxMarkType as D, splitText as Y, ControlType as m } from "@baohu/canvas-editor";
3
+ const j = {
4
+ undo: "撤销",
5
+ redo: "重做",
6
+ painter: "格式刷(双击可连续使用)",
7
+ format: "清除格式",
8
+ font: "字体",
9
+ size: "字号",
10
+ sizeAdd: "增大字号",
11
+ sizeMinus: "减小字号",
12
+ bold: "加粗",
13
+ italic: "斜体",
14
+ underline: "下划线",
15
+ strikeout: "删除线",
16
+ superscript: "上标",
17
+ subscript: "下标",
18
+ color: "字体颜色",
19
+ highlight: "高亮",
20
+ title: "标题",
21
+ text: "正文",
22
+ left: "左对齐",
23
+ center: "居中对齐",
24
+ right: "右对齐",
25
+ alignment: "两端对齐",
26
+ justify: "分散对齐",
27
+ rowMargin: "行间距",
28
+ list: "列表",
29
+ listDecimal: "有序列表",
30
+ listCheckbox: "复选框列表",
31
+ listDisc: "实心圆点列表",
32
+ listCircle: "空心圆点列表",
33
+ listSquare: "实心方块列表",
34
+ table: "表格",
35
+ image: "图片",
36
+ hyperlink: "超链接",
37
+ hyperlinkText: "文本",
38
+ hyperlinkUrl: "链接",
39
+ separator: "分割线",
40
+ pageBreak: "分页符",
41
+ control: "控件",
42
+ controlType: "类型",
43
+ controlText: "文本",
44
+ controlSelect: "下拉框",
45
+ controlCheckbox: "复选框",
46
+ controlRadio: "单选框",
47
+ controlDate: "日期",
48
+ controlNumber: "数值",
49
+ controlPlaceholder: "占位符",
50
+ controlValueSets: "选项",
51
+ controlValueSetsPlaceholder: `每行一个选项,如:
52
+ 有
53
+ 无`,
54
+ controlDateFormat: "日期格式",
55
+ checkbox: "复选框",
56
+ checkboxCross: "叉选",
57
+ checkboxCheck: "勾选",
58
+ date: "日期",
59
+ search: "查找替换",
60
+ searchKeyword: "查找",
61
+ searchReplace: "替换为",
62
+ searchReplacePlaceholder: "留空则只查找",
63
+ print: "打印",
64
+ pdf: "导出 PDF",
65
+ confirm: "确定",
66
+ cancel: "取消",
67
+ pageNo: "页面",
68
+ wordCount: "字数",
69
+ rowCol: "行列",
70
+ pageModePaging: "分页",
71
+ pageModeContinuity: "连页",
72
+ scaleMinus: "缩小",
73
+ scaleAdd: "放大",
74
+ scaleRecovery: "恢复 100%",
75
+ paperDirection: "纸张方向",
76
+ paperMargin: "页边距",
77
+ marginTop: "上边距",
78
+ marginRight: "右边距",
79
+ marginBottom: "下边距",
80
+ marginLeft: "左边距",
81
+ modeEdit: "编辑模式",
82
+ modeClean: "清洁模式",
83
+ modeReadonly: "只读模式",
84
+ modeForm: "表单模式",
85
+ modePrint: "打印模式",
86
+ modeDesign: "设计模式",
87
+ fullscreen: "全屏"
88
+ }, K = "ceu";
89
+ function c(a, n = {}, ...s) {
90
+ const e = document.createElement(a);
91
+ return Object.keys(n).forEach((t) => {
92
+ const o = n[t];
93
+ o === void 0 || o === !1 || (t === "class" ? e.className = String(o) : e.setAttribute(t, o === !0 ? "" : String(o)));
94
+ }), s.forEach((t) => {
95
+ t == null || t === !1 || e.append(t);
96
+ }), e;
97
+ }
98
+ function l(a) {
99
+ return `${K}-${a}`;
100
+ }
101
+ function G(a, n) {
102
+ let s = null;
103
+ const e = (...t) => {
104
+ s && clearTimeout(s), s = setTimeout(() => {
105
+ s = null, a(...t);
106
+ }, n);
107
+ };
108
+ return e.cancel = () => {
109
+ s && clearTimeout(s), s = null;
110
+ }, e;
111
+ }
112
+ function W(a) {
113
+ return new Promise((n, s) => {
114
+ const e = new FileReader();
115
+ e.onload = () => n(e.result), e.onerror = s, e.readAsDataURL(a);
116
+ });
117
+ }
118
+ function Z(a) {
119
+ return new Promise((n, s) => {
120
+ const e = new Image();
121
+ e.onload = () => n(e), e.onerror = s, e.src = a;
122
+ });
123
+ }
124
+ function J(a, n) {
125
+ const s = URL.createObjectURL(a);
126
+ c("a", { href: s, download: n }).click(), URL.revokeObjectURL(s);
127
+ }
128
+ function R(a, n) {
129
+ const s = (t) => String(t).padStart(2, "0"), e = `${a.getFullYear()}-${s(a.getMonth() + 1)}-${s(
130
+ a.getDate()
131
+ )}`;
132
+ return n ? `${e} ${s(a.getHours())}:${s(a.getMinutes())}:${s(
133
+ a.getSeconds()
134
+ )}` : e;
135
+ }
136
+ class I {
137
+ constructor(n) {
138
+ var s;
139
+ this.inputList = [], this.options = n, this.mask = c("div", { class: l("dialog-mask") }), this.container = this.render(), this.mask.setAttribute(T, k.COMPONENT), this.container.setAttribute(T, k.COMPONENT), document.body.append(this.mask, this.container), this.keydownHandler = (e) => {
140
+ e.key === "Escape" && this.close();
141
+ }, document.addEventListener("keydown", this.keydownHandler), (s = this.inputList[0]) == null || s.focus();
142
+ }
143
+ render() {
144
+ const { title: n, fields: s, confirmText: e = "确定", cancelText: t = "取消" } = this.options, o = c("i", { class: l("dialog__close") });
145
+ o.onclick = () => this.close();
146
+ const i = c("div", { class: l("dialog__body") });
147
+ s.forEach((g) => {
148
+ const u = this.createInput(g);
149
+ this.inputList.push(u);
150
+ const M = g.label ? c(
151
+ "span",
152
+ {
153
+ class: `${l("dialog__label")}${g.required ? ` ${l("dialog__label--required")}` : ""}`
154
+ },
155
+ g.label
156
+ ) : null;
157
+ i.append(c("label", { class: l("dialog__field") }, M, u));
158
+ });
159
+ const r = c("button", { type: "button" }, t);
160
+ r.onclick = () => this.close();
161
+ const d = c(
162
+ "button",
163
+ { type: "button", class: l("dialog__confirm") },
164
+ e
165
+ );
166
+ d.onclick = () => this.confirm();
167
+ const h = c(
168
+ "div",
169
+ { class: l("dialog") },
170
+ c("div", { class: l("dialog__title") }, c("span", {}, n), o),
171
+ i,
172
+ c("div", { class: l("dialog__footer") }, r, d)
173
+ );
174
+ return h.addEventListener("keydown", (g) => {
175
+ const u = g.target;
176
+ g.key === "Enter" && u.tagName === "INPUT" && (g.preventDefault(), this.confirm());
177
+ }), c("div", { class: l("dialog-container") }, h);
178
+ }
179
+ createInput(n) {
180
+ var e;
181
+ let s;
182
+ return n.type === "select" ? (s = c("select", { name: n.name }), (e = n.options) == null || e.forEach((t) => {
183
+ s.append(c("option", { value: t.value }, t.label));
184
+ })) : n.type === "textarea" ? (s = c("textarea", { name: n.name }), n.height && (s.style.height = `${n.height}px`)) : s = c("input", { name: n.name, type: n.type }), n.value !== void 0 && (s.value = n.value), n.placeholder && !(s instanceof HTMLSelectElement) && (s.placeholder = n.placeholder), s;
185
+ }
186
+ confirm() {
187
+ const { fields: n, onConfirm: s } = this.options, e = {};
188
+ let t = !0;
189
+ this.inputList.forEach((o, i) => {
190
+ e[o.name] = o.value;
191
+ const r = n[i].required && !o.value.trim();
192
+ o.classList.toggle(l("dialog__input--error"), !!r), r && (t = !1);
193
+ }), t && (s && s(e) === !1 || this.dispose());
194
+ }
195
+ close() {
196
+ var n, s;
197
+ (s = (n = this.options).onClose) == null || s.call(n), this.dispose();
198
+ }
199
+ dispose() {
200
+ document.removeEventListener("keydown", this.keydownHandler), this.mask.remove(), this.container.remove();
201
+ }
202
+ }
203
+ const x = /* @__PURE__ */ new Set();
204
+ function A(a) {
205
+ x.forEach((n) => {
206
+ n.el.contains(a.target) || n.close();
207
+ });
208
+ }
209
+ class C {
210
+ constructor(n, s, e = "bottom") {
211
+ this.panel = c(
212
+ "div",
213
+ { class: `${l("dropdown__panel")} ${l(`dropdown__panel--${e}`)}` },
214
+ s
215
+ ), this.el = c("div", { class: l("dropdown") }, n, this.panel), n.addEventListener("click", () => this.toggle());
216
+ }
217
+ toggle() {
218
+ x.has(this) ? this.close() : this.open();
219
+ }
220
+ open() {
221
+ x.forEach((s) => s.close()), this.panel.classList.add(l("dropdown__panel--visible")), this.panel.style.left = "", this.panel.style.right = "", this.panel.getBoundingClientRect().right > window.innerWidth && (this.panel.style.left = "auto", this.panel.style.right = "0"), x.size || document.addEventListener("mousedown", A), x.add(this);
222
+ }
223
+ close() {
224
+ this.panel.classList.remove(l("dropdown__panel--visible")), x.delete(this), x.size || document.removeEventListener("mousedown", A);
225
+ }
226
+ }
227
+ function p(a, n) {
228
+ const s = c("ul", { class: l("option-list") });
229
+ return a.forEach((e) => {
230
+ const t = c(
231
+ "li",
232
+ { "data-value": e.value, style: e.style },
233
+ e.icon ? c("i", {
234
+ class: l("icon"),
235
+ style: `background-image:url("${e.icon}")`
236
+ }) : null,
237
+ e.label
238
+ );
239
+ t.addEventListener("mousedown", (o) => o.preventDefault()), t.addEventListener("click", () => n(e.value)), s.append(t);
240
+ }), s;
241
+ }
242
+ function b(a, n) {
243
+ a.querySelectorAll("li").forEach((s) => {
244
+ s.classList.toggle(l("active"), s.dataset.value === n);
245
+ });
246
+ }
247
+ const Q = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M9%209h1v4H9z'/%3e%3cpath%20d='M9%209h4v1H9zM7%207H6V3h1z'/%3e%3cpath%20d='M7%207H3V6h4z'/%3e%3c/g%3e%3c/svg%3e", ee = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cg%20transform='translate(2%201)'%3e%3crect%20stroke='%233D4757'%20x='.5'%20y='.5'%20width='11'%20height='8'%20rx='1'/%3e%3cpath%20fill='%233D4757'%20fill-rule='nonzero'%20d='M2%203h4v1H2zm0%202h8v1H2z'/%3e%3c/g%3e%3cg%20fill='%233D4757'%20fill-rule='nonzero'%3e%3cpath%20d='M14%2015h-1v-5H3v5H2V9h12v6z'/%3e%3cpath%20d='M4%2012h4v1H4zm0%202h8v1H4z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e", te = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7%207V3h2v4h4v2H9v4H7V9H3V7h4z'%20fill='%23636363'%20fill-rule='evenodd'/%3e%3c/svg%3e", ne = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M3%207h10v2H3z'%20fill='%23636363'%20fill-rule='evenodd'/%3e%3c/svg%3e", se = "data:image/svg+xml,%3csvg%20version='1.1'%20id='图层_1'%20xmlns='http://www.w3.org/2000/svg'%20x='0'%20y='0'%20viewBox='0%200%2016%2016'%20xml:space='preserve'%3e%3cstyle%3e.st0{fill:%233d4757}%3c/style%3e%3cg%20id='_x30_1-文字_x2F_04页面_x2F_纸张方向-16px'%3e%3cg%20id='编组'%20transform='translate(1%201)'%3e%3cpath%20id='合并形状'%20class='st0'%20d='M14%206v7c0%20.6-.4%201-1%201H4c-.6%200-1-.4-1-1V6c0-.6.4-1%201-1h9c.6%200%201%20.4%201%201zm-1%200H4v7h9V6z'/%3e%3cpath%20id='路径'%20class='st0'%20d='M9%204H8V1H1v9h1v1H1c-.6%200-1-.4-1-1V1c0-.6.4-1%201-1h7c.6%200%201%20.4%201%201v3z'/%3e%3cpath%20id='矩形'%20class='st0'%20d='M11%207h1v5h-1z'/%3e%3cpath%20id='矩形-copy-2'%20class='st0'%20d='M2%202h5v1H2z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e", ae = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3crect%20stroke='%233D4757'%20x='2.5'%20y='1.5'%20width='11'%20height='13'%20rx='1'/%3e%3cpath%20fill='%233D4757'%20fill-rule='nonzero'%20d='M3%204h10v1H3zm0%207h10v1H3z'/%3e%3cpath%20fill='%233D4757'%20fill-rule='nonzero'%20d='M5%2014V2h1v12zm5%200V2h1v12z'/%3e%3c/g%3e%3c/svg%3e", B = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M3%203h1v4H3z'/%3e%3cpath%20d='M3%203h4v1H3zm10%2010h-1V9h1z'/%3e%3cpath%20d='M13%2013H9v-1h4z'/%3e%3c/g%3e%3c/svg%3e", U = [
248
+ "pageNo",
249
+ "wordCount",
250
+ "rowCol",
251
+ "pageMode",
252
+ "scale",
253
+ "paperDirection",
254
+ "paperMargin",
255
+ "fullscreen"
256
+ ], oe = ["pageNo", "wordCount", "rowCol"];
257
+ function H(a, n, s) {
258
+ const e = c(
259
+ "div",
260
+ { class: l("statusbar__button"), title: n },
261
+ c("i", { class: l("icon"), style: `background-image:url("${a}")` })
262
+ );
263
+ return e.addEventListener("click", s), e;
264
+ }
265
+ class ie {
266
+ constructor(n, s = U) {
267
+ this.disposeList = [], this.updaterList = [], this.on = (o, i) => {
268
+ const { eventBus: r } = this.ui.editor;
269
+ r.on(o, i), this.disposeList.push(() => r.off(o, i));
270
+ }, this.ui = n;
271
+ const e = c("div", { class: l("statusbar__left") }), t = c("div", { class: l("statusbar__right") });
272
+ this.el = c("div", { class: l("statusbar") }, e, t), this.el.setAttribute(T, k.FOOTER), this.el.addEventListener("mousedown", (o) => o.preventDefault()), s.forEach((o) => {
273
+ const i = this.createItem(o);
274
+ i && (i.classList.add(l("statusbar__item")), (oe.includes(o) ? e : t).append(i));
275
+ });
276
+ }
277
+ createItem(n) {
278
+ const { editor: s, locale: e } = this.ui;
279
+ switch (n) {
280
+ case "pageNo": {
281
+ const t = c("span", {}, "1"), o = c("span", {}, String(this.ui.getPageSize()));
282
+ return this.on("intersectionPageNoChange", (i) => {
283
+ t.innerText = String(i + 1);
284
+ }), this.on("pageSizeChange", (i) => {
285
+ o.innerText = String(i);
286
+ }), c("span", {}, `${e.pageNo}:`, t, "/", o);
287
+ }
288
+ case "wordCount": {
289
+ const t = c("span", {}, "0"), o = G(async () => {
290
+ t.innerText = String(await s.command.getWordCount());
291
+ }, 300);
292
+ return this.on("contentChange", o), this.disposeList.push(o.cancel), o(), c("span", {}, `${e.wordCount}:`, t);
293
+ }
294
+ case "rowCol": {
295
+ const t = c("span", {}, "1:1");
296
+ return this.on("rangeStyleChange", () => {
297
+ const o = s.command.getRangeContext();
298
+ o && (t.innerText = `${o.startRowNo + 1}:${o.startColNo + 1}`);
299
+ }), c("span", {}, `${e.rowCol}:`, t);
300
+ }
301
+ case "pageMode": {
302
+ const t = H(ee, "", () => {
303
+ }), o = p(
304
+ [
305
+ { label: e.pageModePaging, value: S.PAGING },
306
+ { label: e.pageModeContinuity, value: S.CONTINUITY }
307
+ ],
308
+ (d) => {
309
+ i.close(), s.command.executePageMode(d);
310
+ }
311
+ ), i = new C(t, o, "top"), r = (d) => {
312
+ b(o, d), t.title = d === S.CONTINUITY ? e.pageModeContinuity : e.pageModePaging;
313
+ };
314
+ return r(s.command.getOptions().pageMode), this.on("pageModeChange", r), i.el;
315
+ }
316
+ case "scale": {
317
+ const t = c("span", {
318
+ class: l("statusbar__scale"),
319
+ title: e.scaleRecovery
320
+ }), o = (i) => {
321
+ t.innerText = `${Math.round(i * 100)}%`;
322
+ };
323
+ return o(s.command.getOptions().scale), this.on("pageScaleChange", o), t.addEventListener(
324
+ "click",
325
+ () => s.command.executePageScaleRecovery()
326
+ ), c(
327
+ "div",
328
+ { class: l("statusbar__group") },
329
+ H(
330
+ ne,
331
+ e.scaleMinus,
332
+ () => s.command.executePageScaleMinus()
333
+ ),
334
+ t,
335
+ H(
336
+ te,
337
+ e.scaleAdd,
338
+ () => s.command.executePageScaleAdd()
339
+ )
340
+ );
341
+ }
342
+ case "paperDirection":
343
+ return H(se, e.paperDirection, () => {
344
+ const { paperDirection: t } = s.command.getOptions();
345
+ s.command.executePaperDirection(
346
+ t === V.HORIZONTAL ? V.VERTICAL : V.HORIZONTAL
347
+ );
348
+ });
349
+ case "paperMargin":
350
+ return H(
351
+ ae,
352
+ e.paperMargin,
353
+ () => this.openPaperMarginDialog()
354
+ );
355
+ case "mode": {
356
+ const t = [
357
+ { label: e.modeEdit, value: w.EDIT },
358
+ { label: e.modeClean, value: w.CLEAN },
359
+ { label: e.modeReadonly, value: w.READONLY },
360
+ { label: e.modeForm, value: w.FORM },
361
+ { label: e.modePrint, value: w.PRINT },
362
+ { label: e.modeDesign, value: w.DESIGN }
363
+ ], o = c("span", { class: l("statusbar__mode") }), i = p(t, (h) => {
364
+ r.close(), this.ui.setMode(h);
365
+ }), r = new C(o, i, "top"), d = () => {
366
+ var g;
367
+ const h = s.command.getOptions().mode;
368
+ o.innerText = ((g = t.find((u) => u.value === h)) == null ? void 0 : g.label) || h, b(i, h);
369
+ };
370
+ return d(), this.updaterList.push(d), r.el;
371
+ }
372
+ case "fullscreen": {
373
+ const t = H(B, e.fullscreen, () => {
374
+ document.fullscreenElement ? document.exitFullscreen() : this.ui.root.requestFullscreen();
375
+ }), o = () => {
376
+ const i = document.fullscreenElement ? Q : B;
377
+ t.querySelector("i").style.backgroundImage = `url("${i}")`;
378
+ };
379
+ return document.addEventListener("fullscreenchange", o), this.disposeList.push(
380
+ () => document.removeEventListener("fullscreenchange", o)
381
+ ), t;
382
+ }
383
+ default:
384
+ return console.warn(`[canvas-editor-ui] unknown statusbar item: ${n}`), null;
385
+ }
386
+ }
387
+ openPaperMarginDialog() {
388
+ const { editor: n, locale: s } = this.ui, e = ["top", "right", "bottom", "left"], t = [
389
+ s.marginTop,
390
+ s.marginRight,
391
+ s.marginBottom,
392
+ s.marginLeft
393
+ ], o = n.command.getPaperMargin();
394
+ new I({
395
+ title: s.paperMargin,
396
+ confirmText: s.confirm,
397
+ cancelText: s.cancel,
398
+ fields: e.map((i, r) => ({
399
+ type: "number",
400
+ name: i,
401
+ label: t[r],
402
+ required: !0,
403
+ value: String(o[r])
404
+ })),
405
+ onConfirm: (i) => {
406
+ const [r, d, h, g] = e.map(
407
+ (M) => Number(i[M])
408
+ ), u = [r, d, h, g];
409
+ if (u.some((M) => isNaN(M) || M < 0)) return !1;
410
+ n.command.executeSetPaperMargin(u);
411
+ }
412
+ });
413
+ }
414
+ // 外部状态(如编辑模式)变化后刷新
415
+ update() {
416
+ this.updaterList.forEach((n) => n());
417
+ }
418
+ destroy() {
419
+ this.disposeList.forEach((n) => n()), this.el.remove();
420
+ }
421
+ }
422
+ const ce = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2%2013h12v1H2v-1zm0-3h12v1H2v-1zm0-3h12v1H2V7zm0-6h12v1H2V1zm0%203h12v1H2V4z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e", le = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8.131%206.9c2.035%200%202.569-.9%202.569-1.869%200-.968-.64-1.831-2.623-1.831H5.2v3.7h2.931zm.524%205.9c2.045%200%202.545-1.305%202.545-2.3%200-.985-.506-2.4-2.81-2.4H5.2v4.7h3.455zM4%202h4.71c2.367%200%203.19%201.583%203.19%203s-.325%201.852-1.1%202.5c1.2.5%201.569%201.379%201.6%203%20.03%201.606-.586%203.5-3.769%203.5H4V2z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e", re = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2%2013h12v1H2v-1zm2-3h8v1H4v-1zM2%207h12v1H2V7zm0-6h12v1H2V1zm2%203h8v1H4V4z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e", de = "data:image/svg+xml,%3csvg%20version='1.1'%20id='图层_1'%20xmlns='http://www.w3.org/2000/svg'%20x='0'%20y='0'%20viewBox='0%200%2016%2016'%20xml:space='preserve'%3e%3cstyle%3e.st0{fill:%233d4757}%3c/style%3e%3cg%20id='_x30_1-文字_x2F_01开始_x2F_任务列表-16px'%3e%3cpath%20id='合并形状'%20class='st0'%20d='M10.1%202H2v11h11V8.7l1-1V13c0%20.6-.4%201-1%201H2c-.6%200-1-.4-1-1V2c0-.6.4-1%201-1h9.1l-1%201z'/%3e%3cpath%20id='路径'%20class='st0'%20d='M7.7%208.5l5.7-5.8.9.8-6.1%205.9-.5.5-3.9-3.4.8-.7z'/%3e%3c/g%3e%3c/svg%3e", he = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7.997%203.429L6.398%208h3.2L7.997%203.429zM8.497%202L12%2012h-1L9.949%209h-3.9L5%2012H4L7.496%202h1z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e", ge = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20d='M9.793%201.5H3a.5.5%200%2000-.5.5v12a.5.5%200%2000.5.5h9a.5.5%200%2000.5-.5V4.207L9.793%201.5z'%20stroke='%233D4757'/%3e%3cg%20fill='%233D4757'%3e%3cpath%20d='M7%207h1v5H7z'/%3e%3cpath%20d='M5%207h5v1H5z'/%3e%3c/g%3e%3cpath%20fill='%233D4757'%20fill-rule='nonzero'%20d='M9%202h1v3H9z'/%3e%3cpath%20fill='%233D4757'%20fill-rule='nonzero'%20d='M9%204h3v1H9z'/%3e%3c/g%3e%3c/svg%3e", ve = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M7.5%2014.154a5.654%205.654%200%20100-11.308%205.654%205.654%200%20000%2011.308zm0%20.846a6.5%206.5%200%20110-13%206.5%206.5%200%20010%2013z'%20fill-rule='nonzero'/%3e%3cpath%20d='M8%208h4v1H7V4h1v4z'/%3e%3c/g%3e%3c/svg%3e", ue = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M8.213%2013H6.8l6.636-6.636-4.243-4.243-7.07%207.071L5.928%2013H4.515L1.06%209.546a.5.5%200%20010-.707L8.839%201.06a.5.5%200%2001.707%200l4.95%204.95a.5.5%200%20010%20.707L8.213%2013z'%20fill-rule='nonzero'/%3e%3cpath%20d='M4.536%206.364l4.95%204.95-.707.707-4.95-4.95zM4.521%2013h10.03v1H5.496z'/%3e%3c/g%3e%3c/svg%3e", me = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M13.31%205h-1.92a2.203%202.203%200%2000-.39-.034c-.135%200-.27.012-.402.034H10v.18c-.578.256-1%20.714-1%201.214v1.928c0%20.196.117.43.3.658v1.23a3.543%203.543%200%2001-.3-.4V11H8V1h1v4.265C9%204.763%2010%204%2010.942%204c1.19%200%201.92.422%202.367%201zM2%206c-.03-.498-.175-2%202.5-2C7.11%204%207%205%207%206.902V11H5.984v-.993c.38.662-.115.993-1.484.993C2.708%2011%202%209.931%202%209c0-1.428.447-2%202.5-2h1.484c0-1%20.031-2-1.484-2-1.533%200-1.577.485-1.577%201H2zm2.5%202C3.601%208%203%207.768%203%209c0%201.31.438%201%201.5%201%20.617%200%201.484-.665%201.484-1.847V8H4.5z'/%3e%3cpath%20d='M13.085%206.316l-2.814%203a1%201%200%20101.458%201.368l2.815-3a1%201%200%2000-1.459-1.368z'%20fill-rule='nonzero'/%3e%3c/g%3e%3c/svg%3e", pe = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20transform='rotate(45%205.5%2013.328)'%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M7%206H6V3.515a2.5%202.5%200%2010-5%200V6H0V3.515a3.5%203.5%200%20117%200V6zm0%204v2.5a3.5%203.5%200%2001-7%200V10h1v2.5a2.5%202.5%200%20105%200V10h1z'%20fill-rule='nonzero'/%3e%3crect%20x='3.062'%20y='5.209'%20width='1'%20height='5.5'%20rx='.5'/%3e%3c/g%3e%3c/svg%3e", we = "data:image/svg+xml,%3csvg%20version='1.1'%20id='图层_1'%20xmlns='http://www.w3.org/2000/svg'%20x='0'%20y='0'%20viewBox='0%200%2016%2016'%20xml:space='preserve'%3e%3cstyle%3e.st0{fill:%233d4757}%3c/style%3e%3cg%20id='_x30_0-公共_x2F_02工具栏_x2F_插入图片-16px-'%3e%3cg%20id='Group-19'%20transform='translate(1%201)'%3e%3cpath%20id='Combined-Shape'%20class='st0'%20d='M1%200h12c.6%200%201%20.4%201%201v11c0%20.6-.4%201-1%201H1c-.6%200-1-.4-1-1V1c0-.6.4-1%201-1zm0%201v11h12V1H1z'/%3e%3ccircle%20id='椭圆形'%20class='st0'%20cx='10'%20cy='4'%20r='1'/%3e%3cpath%20id='Path'%20class='st0'%20d='M8.5%2011.2l-4-4.1L1%2010.7V9.2c1.7-1.6%202.7-2.5%203-2.8.4-.5.7-.4%201%200L8.5%2010%2011%207.3c.4-.5.6-.5%201-.1l2%202.8v1.5l-2.5-3.4-3%203.1z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e", fe = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M10.017%203L8.08%2013H9v1H6v-1h1.182L9%203H8V2h3v1h-.983z'%20fill='%233D4757'/%3e%3c/svg%3e", xe = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20stroke='%233D4757'%20fill='%233D4757'%20d='M2%2010.5H14M2%2013.5H14'%20stroke-linecap='round'%20stroke-linejoin='miter'%3e%3c/path%3e%3cpath%20stroke='%233D4757'%20fill='%233D4757'%20d='M14%203.5L12%201.5M14%203.5L12%205.5M14%203.5L2%203.5M4%201.5L2%203.5M2%203.5L4%205.5'%20stroke-linecap='round'%20stroke-linejoin='miter'%3e%3c/path%3e%3c/svg%3e", be = "data:image/svg+xml,%3csvg%20height='16'%20viewBox='0%200%2016%2016'%20width='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2%2013h12v1H2zm0-3h8v1H2zm0-3h12v1H2zm0-6h12v1H2zm0%203h8v1H2z'%20fill='%233d4757'%20fill-rule='evenodd'/%3e%3c/svg%3e", Me = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20fill='%233D4757'%20d='M7%2012h7v1H7zm0-5h7v1H7zm0-5h7v1H7zM3%204V2H2V1h2v3h1v1H2V4h1z'/%3e%3cpath%20d='M2%206h3v1H2V6zm0%203h3v1H2V9z'%20fill='%234F4F4F'/%3e%3cpath%20fill='%233D4757'%20fill-rule='nonzero'%20d='M4.5%206L5%207l-2.5%203L2%209z'/%3e%3cpath%20d='M4%2014l-1-2H2v-1h3v1H4l1%202v1H2v-1h2z'%20fill='%233D4757'/%3e%3c/g%3e%3c/svg%3e", ze = "data:image/svg+xml,%3csvg%20version='1.1'%20id='图层_1'%20xmlns='http://www.w3.org/2000/svg'%20x='0'%20y='0'%20viewBox='0%200%2016%2016'%20xml:space='preserve'%3e%3cstyle%3e.st0{fill:none;stroke:%233d4757}.st1{fill:%233d4757}%3c/style%3e%3cg%20id='_x30_1-文字_x2F_02插入_x2F_分页-16px'%3e%3cpath%20id='矩形'%20class='st0'%20d='M5.5%202.5h7c.6%200%201%20.4%201%201v3c0%20.6-.4%201-1%201h-7c-.6%200-1-.4-1-1v-3c0-.6.4-1%201-1z'/%3e%3cpath%20id='三角形'%20class='st1'%20d='M4%208.5L1%206v5z'/%3e%3cpath%20id='合并形状'%20class='st0'%20d='M10.8%209.5H5c-.3%200-.5.2-.5.5v4c0%20.3.2.5.5.5h8c.3%200%20.5-.2.5-.5v-1.8l-2.7-2.7z'/%3e%3cpath%20id='矩形_1_'%20class='st1'%20d='M10%2010h1v3h-1z'/%3e%3cpath%20id='矩形-copy-2'%20class='st1'%20d='M10%2012h3v1h-3z'/%3e%3c/g%3e%3c/svg%3e", $ = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20d='M7.5%202v2.5H4a.5.5%200%2000-.5.5v2a.5.5%200%2000.5.5h9a.5.5%200%2000.5-.5V5a.5.5%200%2000-.5-.5H9.5V2a.5.5%200%2000-.5-.5H8a.5.5%200%2000-.5.5z'%20stroke='%233D4757'/%3e%3cpath%20fill='%233D4757'%20d='M13%207h1v4h-1z'/%3e%3cpath%20d='M11%2013a2%202%200%20002-2V8.764A3%203%200%20118.764%2013H11z'%20fill='%233D4757'/%3e%3cpath%20fill='%233D4757'%20d='M1%2013h10v1H1z'/%3e%3cpath%20d='M1%2013a2%202%200%20002-2V8.764A3%203%200%20011%2014v-1z'%20fill='%233D4757'/%3e%3cpath%20fill='%233D4757'%20d='M3%207h1v4H3z'/%3e%3c/g%3e%3c/svg%3e", He = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M10%201l4%204v9a1%201%200%2001-1%201H3a1%201%200%2001-1-1V2a1%201%200%20011-1h7zm-.414%201H3v12h10V5.414L9.586%202z'/%3e%3cpath%20d='M9%201h1v4h4v1H9z'/%3e%3cpath%20d='M8%207h1v4.293l1.646-1.647.708.708L8.5%2013.207l-2.854-2.853.708-.708L8%2011.293z'%20transform='translate(-.5)'/%3e%3c/g%3e%3c/svg%3e", Le = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M12%204h-1V2H5v2H4V2a1%201%200%20011-1h6a1%201%200%20011%201v2zm0%205v4a1%201%200%2001-1%201H5a1%201%200%2001-1-1V9h1v4h6V9h1z'/%3e%3cpath%20d='M12%2012v-1h2V5H2v6h2v1H2a1%201%200%2001-1-1V5a1%201%200%20011-1h12a1%201%200%20011%201v6a1%201%200%2001-1%201h-2z'/%3e%3cpath%20d='M3%208h10v1H3zm8-2h2v1h-2z'/%3e%3c/g%3e%3c/svg%3e", _e = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M3%2014v-3a4%204%200%20014-4h3V6H7a5%205%200%2000-5%205v3h1zm7.016-11.282v7.543l4.29-3.73z'%20fill='%233D4757'/%3e%3c/svg%3e", ye = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2%2013h12v1H2v-1zm4-3h8v1H6v-1zM2%207h12v1H2V7zm0-6h12v1H2V1zm4%203h8v1H6V4z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e", Ee = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2%2014h12v1H2v-1zm7-5h5v1H9V9zm0-3h5v1H9V6zM2%201h12v1H2V1zm2.5%203L7%207H2zm0%208L7%209H2z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e", De = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3ccircle%20stroke='%233D4757'%20cx='6'%20cy='6'%20r='4.5'/%3e%3cpath%20d='M10.061%2010.968L8.707%209.414l.707-.707%201.514%201.457.435-.404%202.632%202.462a1.154%201.154%200%2001.05%201.635%201.184%201.184%200%2001-1.655.064l-2.788-2.527.46-.426z'%20fill='%233D4757'%20fill-rule='nonzero'/%3e%3c/g%3e%3c/svg%3e", Te = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M3.9%202.8l2.01%202.506c.2.25.58.25.78%200L8.7%202.799l2.01%202.507c.2.25.58.25.78%200l2.4-2.993-.78-.626-2.01%202.507-2.01-2.507a.5.5%200%2000-.78%200L6.3%204.194%204.29%201.687a.5.5%200%2000-.78%200l-2.4%203%20.78.625L3.9%202.8zM1%208h13v1H1zm0%204h3v1H1zm5%200h3v1H6zm5%200h3v1h-3z'%20fill='%233D4757'/%3e%3c/svg%3e", ke = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M6.215%203.29H7.64L11.855%2014H10.52l-1.14-3H4.46l-1.14%203H2L6.215%203.29zM4.85%209.965h4.14L6.965%204.61h-.06L4.85%209.965z'/%3e%3cpath%20d='M12%204V2h1v2h2v1h-2v2h-1V5h-2V4h2z'%20fill-rule='nonzero'/%3e%3c/g%3e%3c/svg%3e", Ce = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20fill-rule='nonzero'%20d='M11%204h4v1h-4z'/%3e%3cpath%20d='M6.215%203.29H7.64L11.855%2014H10.52l-1.14-3H4.46l-1.14%203H2L6.215%203.29zM4.85%209.965h4.14L6.965%204.61h-.06L4.85%209.965z'/%3e%3c/g%3e%3c/svg%3e", Ie = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M10.42%207.903H6.692a9.182%209.182%200%2001-.41-.172%205.54%205.54%200%2001-.814-.447%202.955%202.955%200%2001-.655-.595%202.728%202.728%200%2001-.44-.777%202.877%202.877%200%2001-.162-1.006c0-.472.094-.888.282-1.25.188-.36.453-.663.793-.907s.747-.43%201.22-.558A5.97%205.97%200%20018.063%202c.504%200%20.95.049%201.337.147.387.097.725.23%201.013.398.287.169.53.365.73.59a3.337%203.337%200%2001.772%201.486c.03.13.054.255.073.379h-1.276a2.393%202.393%200%2000-.22-.615%202.315%202.315%200%2000-.59-.724%202.467%202.467%200%2000-.834-.44%203.376%203.376%200%2000-1.005-.146%204.69%204.69%200%2000-.958.097%202.77%202.77%200%2000-.839.314%201.765%201.765%200%2000-.597.566c-.152.233-.229.518-.229.854%200%20.348.086.642.258.884.171.241.401.449.689.622.287.174.615.323.983.448s.749.247%201.142.367c.31.097.62.196.934.297a8.439%208.439%200%2001.973.38zm1.376%201c.175.217.315.466.418.746.105.285.158.612.158.98%200%20.554-.104%201.041-.312%201.462-.207.42-.496.772-.867%201.054-.37.282-.81.495-1.32.64A6.12%206.12%200%20018.205%2014c-.543%200-1.071-.09-1.586-.273a4.44%204.44%200%2001-1.374-.773%203.873%203.873%200%2001-.97-1.217%203.695%203.695%200%2001-.395-1.612h1.27c.028.407.122.78.282%201.12a2.835%202.835%200%20001.581%201.465c.363.138.76.207%201.192.207.387%200%20.758-.042%201.112-.126a2.85%202.85%200%2000.938-.399%202.01%202.01%200%2000.647-.708c.16-.29.241-.642.241-1.054%200-.337-.087-.623-.261-.86a2.333%202.333%200%2000-.69-.61%204.651%204.651%200%2000-.495-.257h2.099z'/%3e%3cpath%20d='M3%207h10v1H3z'/%3e%3c/g%3e%3c/svg%3e", Se = "data:image/svg+xml,%3csvg%20version='1.1'%20id='图层_1'%20xmlns='http://www.w3.org/2000/svg'%20x='0'%20y='0'%20viewBox='0%200%2016%2016'%20xml:space='preserve'%3e%3cstyle%3e.st0{fill:%233d4757}%3c/style%3e%3cg%20id='_x30_0-公共_x2F_02工具栏_x2F_subscript'%3e%3cpath%20id='_x32_'%20class='st0'%20d='M15%2013.3v.7h-3c0-.3.1-.5.3-.8.2-.2.5-.6%201-1%20.4-.3.6-.5.7-.7.1-.2.2-.3.2-.5s-.1-.3-.2-.4c-.1-.1-.2-.1-.4-.1s-.3%200-.4.1-.2.4-.2.7l-.9-.1c.1-.4.2-.7.5-.9.3-.2.6-.3%201-.3s.8.1%201%20.3c.3.2.4.5.4.8%200%20.2%200%20.4-.1.5-.1.2-.2.3-.3.5-.1.1-.3.3-.6.5s-.4.4-.5.4c-.1.1-.1.2-.2.3H15z'/%3e%3cpath%20id='合并形状'%20class='st0'%20d='M7.2%208.5l4%205.5H9.8L6.5%209.4%203.2%2014H1.8l4-5.5-4-5.5h1.4l3.3%204.6L9.8%203h1.3L7.2%208.5z'/%3e%3c/g%3e%3c/svg%3e", Ve = "data:image/svg+xml,%3csvg%20version='1.1'%20id='图层_1'%20xmlns='http://www.w3.org/2000/svg'%20x='0'%20y='0'%20viewBox='0%200%2016%2016'%20xml:space='preserve'%3e%3cstyle%3e.st0{fill:%233d4757}%3c/style%3e%3cg%20id='_x30_0-公共_x2F_02工具栏_x2F_superscript'%3e%3cpath%20id='_x32_'%20class='st0'%20d='M15%206.3V7h-3c0-.3.1-.5.3-.8.2-.2.5-.6%201-1%20.3-.2.6-.5.7-.6.1-.2.2-.3.2-.5s-.1-.3-.2-.4c-.1-.1-.2-.1-.4-.1s-.3%200-.4.1-.2.3-.2.6l-.9-.1c.1-.4.2-.7.5-.9s.6-.3%201-.3.8.1%201%20.3c.3.2.4.5.4.8%200%20.2%200%20.4-.1.5s-.2.4-.4.5c-.1.1-.3.3-.6.5s-.4.4-.4.5c-.1.1-.1.2-.2.3l1.7-.1z'/%3e%3cpath%20id='合并形状'%20class='st0'%20d='M7.4%208.5l4%205.5H10L6.7%209.4%203.4%2014H2l4-5.5L2%203h1.4l3.3%204.6L10%203h1.3L7.4%208.5z'/%3e%3c/g%3e%3c/svg%3e", Re = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3crect%20x='.5'%20y='.5'%20width='12'%20height='12'%20rx='1'%20transform='translate(1%201)'%20stroke='%233D4757'/%3e%3cpath%20fill='%233D4757'%20fill-rule='nonzero'%20d='M2%209h12v1H2zm0-4h12v1H2z'/%3e%3cpath%20fill='%233D4757'%20fill-rule='nonzero'%20d='M5%201h1v13H5zm4%200h1v13H9z'/%3e%3c/g%3e%3c/svg%3e", Ae = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M14%201a1%201%200%20011%201v12a1%201%200%2001-1%201H2a1%201%200%2001-1-1V2a1%201%200%20011-1h12zm0%201H2v12h12V2z'%20fill-rule='nonzero'/%3e%3cpath%20fill-rule='nonzero'%20d='M4%2011h8v1H4zm0-3h4v1H4zm0-3h2v1H4z'/%3e%3cpath%20d='M9%205h1v4H9z'/%3e%3cpath%20d='M7%205h5v1H7z'/%3e%3c/g%3e%3c/svg%3e", Be = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M5%202v6a3%203%200%20106%200V2h1v6a4%204%200%2011-8%200V2h1zM4%2013h8v1H4z'%20fill='%233D4757'/%3e%3c/svg%3e", $e = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6%202.763v7.544l-4.29-3.73zM13%2014v-3a4%204%200%2000-4-4H6V6h3a5%205%200%20015%205v3h-1z'%20fill='%233D4757'/%3e%3c/svg%3e", Ne = [
423
+ "Microsoft YaHei",
424
+ "宋体",
425
+ "黑体",
426
+ "仿宋",
427
+ "楷体",
428
+ "华文宋体",
429
+ "华文黑体",
430
+ "华文仿宋",
431
+ "华文楷体",
432
+ "华文隶书",
433
+ "华文行楷",
434
+ "Arial",
435
+ "Segoe UI",
436
+ "Times New Roman"
437
+ ].map((a) => ({
438
+ label: a === "Microsoft YaHei" ? "微软雅黑" : a,
439
+ value: a,
440
+ style: `font-family:'${a}'`
441
+ })), Oe = [
442
+ ["初号", 56],
443
+ ["小初", 48],
444
+ ["一号", 34],
445
+ ["小一", 32],
446
+ ["二号", 29],
447
+ ["小二", 24],
448
+ ["三号", 21],
449
+ ["小三", 20],
450
+ ["四号", 18],
451
+ ["小四", 16],
452
+ ["五号", 14],
453
+ ["小五", 12],
454
+ ["六号", 10],
455
+ ["小六", 8],
456
+ ["七号", 7],
457
+ ["八号", 6]
458
+ ].map(([a, n]) => ({ label: String(a), value: String(n) })), Fe = ["1", "1.25", "1.5", "1.75", "2", "2.5", "3"], N = [
459
+ { label: "———— 实线", dashArray: [] },
460
+ { label: "··········· 点线", dashArray: [1, 1] },
461
+ { label: "- - - - - 短虚线", dashArray: [3, 1] },
462
+ { label: "— — — 长虚线", dashArray: [4, 4] },
463
+ { label: "—·—·— 点划线", dashArray: [7, 3, 3, 3] },
464
+ { label: "—··—·· 双点划线", dashArray: [6, 2, 2, 2, 2, 2] }
465
+ ];
466
+ function v(a, n, s, e, t = {}) {
467
+ return { key: a, title: n, icon: s, onClick: e, ...t };
468
+ }
469
+ function O(a, n, s, e, t, o) {
470
+ return {
471
+ key: a,
472
+ title: n,
473
+ render: (i) => {
474
+ const r = c("span", { class: l("select__label") }), d = c(
475
+ "div",
476
+ { class: l("select"), title: n, style: `width:${e}px` },
477
+ r
478
+ ), h = p(s, (u) => {
479
+ g.close(), t(i, u);
480
+ }), g = new C(d, h);
481
+ return g.el;
482
+ },
483
+ update: (i, r) => {
484
+ const d = o(i), h = s.find((g) => g.value === d);
485
+ r.querySelector(`.${l("select__label")}`).innerText = h ? h.label : d || "", b(r, d);
486
+ }
487
+ };
488
+ }
489
+ function f(a, n, s, e, t = {}) {
490
+ return {
491
+ key: a,
492
+ title: n,
493
+ render: (o) => {
494
+ const i = c(
495
+ "div",
496
+ { class: `${l("toolbar__button")} ${l("toolbar__button--arrow")}`, title: n },
497
+ c("i", { class: l("icon"), style: `background-image:url("${s}")` })
498
+ ), r = c("div"), d = new C(i, r);
499
+ return i.addEventListener(
500
+ "click",
501
+ () => {
502
+ r.innerHTML = "", r.append(e(o, () => d.close()));
503
+ },
504
+ !0
505
+ ), d.el;
506
+ },
507
+ ...t
508
+ };
509
+ }
510
+ function F(a, n, s, e, t) {
511
+ return {
512
+ key: a,
513
+ title: n,
514
+ render: (o) => {
515
+ const i = c("input", { type: "color", class: l("color__input") });
516
+ i.addEventListener("input", () => e(o, i.value));
517
+ const r = c("span", { class: l("color__bar") }), d = c(
518
+ "div",
519
+ { class: `${l("toolbar__button")} ${l("color")}`, title: n },
520
+ c("i", { class: l("icon"), style: `background-image:url("${s}")` }),
521
+ r,
522
+ i
523
+ );
524
+ return d.addEventListener("click", () => i.click()), d;
525
+ },
526
+ update: (o, i) => {
527
+ const r = t(o);
528
+ i.querySelector(`.${l("color__bar")}`).style.background = r || "transparent";
529
+ }
530
+ };
531
+ }
532
+ function Pe(a) {
533
+ const n = c("input", { type: "file", accept: "image/*" });
534
+ n.addEventListener("change", async () => {
535
+ var o;
536
+ const s = (o = n.files) == null ? void 0 : o[0];
537
+ if (!s) return;
538
+ const e = await W(s), t = await Z(e);
539
+ a.editor.command.executeImage({
540
+ value: e,
541
+ width: t.width,
542
+ height: t.height
543
+ });
544
+ }), n.click();
545
+ }
546
+ function Ue({ editor: a, locale: n }) {
547
+ new I({
548
+ title: n.hyperlink,
549
+ confirmText: n.confirm,
550
+ cancelText: n.cancel,
551
+ fields: [
552
+ {
553
+ type: "text",
554
+ name: "text",
555
+ label: n.hyperlinkText,
556
+ required: !0,
557
+ value: a.command.getRangeText()
558
+ },
559
+ {
560
+ type: "text",
561
+ name: "url",
562
+ label: n.hyperlinkUrl,
563
+ required: !0,
564
+ placeholder: "https://"
565
+ }
566
+ ],
567
+ onConfirm: ({ text: s, url: e }) => {
568
+ a.command.executeHyperlink({
569
+ url: e,
570
+ valueList: Y(s).map((t) => ({ value: t }))
571
+ });
572
+ }
573
+ });
574
+ }
575
+ const P = [
576
+ m.SELECT,
577
+ m.CHECKBOX,
578
+ m.RADIO
579
+ ];
580
+ function qe({ editor: a, locale: n }) {
581
+ new I({
582
+ title: n.control,
583
+ confirmText: n.confirm,
584
+ cancelText: n.cancel,
585
+ fields: [
586
+ {
587
+ type: "select",
588
+ name: "type",
589
+ label: n.controlType,
590
+ options: [
591
+ { label: n.controlText, value: m.TEXT },
592
+ { label: n.controlSelect, value: m.SELECT },
593
+ { label: n.controlCheckbox, value: m.CHECKBOX },
594
+ { label: n.controlRadio, value: m.RADIO },
595
+ { label: n.controlDate, value: m.DATE },
596
+ { label: n.controlNumber, value: m.NUMBER }
597
+ ]
598
+ },
599
+ {
600
+ type: "text",
601
+ name: "placeholder",
602
+ label: n.controlPlaceholder
603
+ },
604
+ {
605
+ type: "textarea",
606
+ name: "valueSets",
607
+ label: n.controlValueSets,
608
+ placeholder: n.controlValueSetsPlaceholder,
609
+ height: 80
610
+ },
611
+ {
612
+ type: "select",
613
+ name: "dateFormat",
614
+ label: n.controlDateFormat,
615
+ options: [
616
+ { label: "yyyy-MM-dd", value: "yyyy-MM-dd" },
617
+ { label: "yyyy-MM-dd HH:mm:ss", value: "yyyy-MM-dd HH:mm:ss" }
618
+ ]
619
+ }
620
+ ],
621
+ onConfirm: (s) => {
622
+ const e = s.type, t = s.valueSets.split(`
623
+ `).map((i) => i.trim()).filter(Boolean).map((i) => ({ value: i, code: i }));
624
+ if (P.includes(e) && !t.length)
625
+ return !1;
626
+ const o = {
627
+ type: e,
628
+ value: null,
629
+ placeholder: s.placeholder || void 0
630
+ };
631
+ P.includes(e) && (o.code = null, o.valueSets = t), e === m.CHECKBOX && (o.markType = D.CROSS), e === m.DATE && (o.dateFormat = s.dateFormat), a.command.executeInsertControl({
632
+ type: E.CONTROL,
633
+ value: "",
634
+ control: o
635
+ });
636
+ }
637
+ });
638
+ }
639
+ function Xe({ editor: a, locale: n }) {
640
+ new I({
641
+ title: n.search,
642
+ confirmText: n.confirm,
643
+ cancelText: n.cancel,
644
+ fields: [
645
+ {
646
+ type: "text",
647
+ name: "keyword",
648
+ label: n.searchKeyword,
649
+ required: !0,
650
+ value: a.command.getRangeText()
651
+ },
652
+ {
653
+ type: "text",
654
+ name: "replace",
655
+ label: n.searchReplace,
656
+ placeholder: n.searchReplacePlaceholder
657
+ }
658
+ ],
659
+ onConfirm: ({ keyword: s, replace: e }) => {
660
+ a.command.executeSearch(s), e && a.command.executeReplace(e);
661
+ },
662
+ onClose: () => a.command.executeSearch(null)
663
+ });
664
+ }
665
+ function Ye(a, n) {
666
+ const e = c("div", { class: l("table-picker__title") }, a.locale.table), t = c("div", { class: l("table-picker__grid") }), o = [];
667
+ for (let i = 1; i <= 10; i++)
668
+ for (let r = 1; r <= 10; r++) {
669
+ const d = c("span", { "data-row": i, "data-col": r });
670
+ o.push(d), t.append(d);
671
+ }
672
+ return t.addEventListener("mouseover", (i) => {
673
+ const r = i.target, d = Number(r.dataset.row), h = Number(r.dataset.col);
674
+ !d || !h || (e.innerText = `${d} × ${h}`, o.forEach((g) => {
675
+ g.classList.toggle(
676
+ l("active"),
677
+ Number(g.dataset.row) <= d && Number(g.dataset.col) <= h
678
+ );
679
+ }));
680
+ }), t.addEventListener("mousedown", (i) => i.preventDefault()), t.addEventListener("click", (i) => {
681
+ const r = i.target, d = Number(r.dataset.row), h = Number(r.dataset.col);
682
+ !d || !h || (n(), a.editor.command.executeInsertTable(d, h));
683
+ }), c("div", { class: l("table-picker") }, e, t);
684
+ }
685
+ const je = [
686
+ ["left", L.LEFT, be],
687
+ ["center", L.CENTER, re],
688
+ ["right", L.RIGHT, ye],
689
+ ["alignment", L.ALIGNMENT, ce],
690
+ ["justify", L.JUSTIFY, xe]
691
+ ];
692
+ function Ke(a) {
693
+ const n = [
694
+ v("undo", a.undo, $e, ({ editor: e }) => e.command.executeUndo(), {
695
+ isDisabled: ({ style: e }) => !!e && !e.undo
696
+ }),
697
+ v("redo", a.redo, _e, ({ editor: e }) => e.command.executeRedo(), {
698
+ isDisabled: ({ style: e }) => !!e && !e.redo
699
+ }),
700
+ {
701
+ key: "painter",
702
+ title: a.painter,
703
+ icon: $,
704
+ isActive: ({ style: e }) => !!(e != null && e.painter),
705
+ render: ({ editor: e }) => {
706
+ const t = c(
707
+ "div",
708
+ { class: l("toolbar__button"), title: a.painter },
709
+ c("i", {
710
+ class: l("icon"),
711
+ style: `background-image:url("${$}")`
712
+ })
713
+ );
714
+ let o = null;
715
+ return t.addEventListener("click", () => {
716
+ o && clearTimeout(o), o = setTimeout(() => {
717
+ o = null, e.command.executePainter({ isDblclick: !1 });
718
+ }, 200);
719
+ }), t.addEventListener("dblclick", () => {
720
+ o && clearTimeout(o), o = null, e.command.executePainter({ isDblclick: !0 });
721
+ }), t;
722
+ }
723
+ },
724
+ v(
725
+ "format",
726
+ a.format,
727
+ ue,
728
+ ({ editor: e }) => e.command.executeFormat()
729
+ ),
730
+ O(
731
+ "font",
732
+ a.font,
733
+ Ne,
734
+ 90,
735
+ ({ editor: e }, t) => e.command.executeFont(t),
736
+ ({ editor: e, style: t }) => (t == null ? void 0 : t.font) || e.command.getOptions().defaultFont
737
+ ),
738
+ O(
739
+ "size",
740
+ a.size,
741
+ Oe,
742
+ 54,
743
+ ({ editor: e }, t) => e.command.executeSize(Number(t)),
744
+ ({ editor: e, style: t }) => String(t ? t.size : e.command.getOptions().defaultSize)
745
+ ),
746
+ v(
747
+ "sizeAdd",
748
+ a.sizeAdd,
749
+ ke,
750
+ ({ editor: e }) => e.command.executeSizeAdd()
751
+ ),
752
+ v(
753
+ "sizeMinus",
754
+ a.sizeMinus,
755
+ Ce,
756
+ ({ editor: e }) => e.command.executeSizeMinus()
757
+ ),
758
+ v("bold", a.bold, le, ({ editor: e }) => e.command.executeBold(), {
759
+ isActive: ({ style: e }) => !!(e != null && e.bold)
760
+ }),
761
+ v("italic", a.italic, fe, ({ editor: e }) => e.command.executeItalic(), {
762
+ isActive: ({ style: e }) => !!(e != null && e.italic)
763
+ }),
764
+ v("underline", a.underline, Be, ({ editor: e }) => e.command.executeUnderline(), {
765
+ isActive: ({ style: e }) => !!(e != null && e.underline)
766
+ }),
767
+ v("strikeout", a.strikeout, Ie, ({ editor: e }) => e.command.executeStrikeout(), {
768
+ isActive: ({ style: e }) => !!(e != null && e.strikeout)
769
+ }),
770
+ v("superscript", a.superscript, Ve, ({ editor: e }) => e.command.executeSuperscript(), {
771
+ isActive: ({ style: e }) => (e == null ? void 0 : e.type) === E.SUPERSCRIPT
772
+ }),
773
+ v("subscript", a.subscript, Se, ({ editor: e }) => e.command.executeSubscript(), {
774
+ isActive: ({ style: e }) => (e == null ? void 0 : e.type) === E.SUBSCRIPT
775
+ }),
776
+ F(
777
+ "color",
778
+ a.color,
779
+ he,
780
+ ({ editor: e }, t) => e.command.executeColor(t),
781
+ ({ style: e }) => (e == null ? void 0 : e.color) || "#000000"
782
+ ),
783
+ F(
784
+ "highlight",
785
+ a.highlight,
786
+ me,
787
+ ({ editor: e }, t) => e.command.executeHighlight(t),
788
+ ({ style: e }) => (e == null ? void 0 : e.highlight) || null
789
+ ),
790
+ f("title", a.title, Ae, ({ editor: e, style: t }, o) => {
791
+ const i = [
792
+ z.FIRST,
793
+ z.SECOND,
794
+ z.THIRD,
795
+ z.FOURTH,
796
+ z.FIFTH,
797
+ z.SIXTH
798
+ ], r = [
799
+ { label: a.text, value: "" },
800
+ ...i.map((h, g) => ({
801
+ label: `${a.title}${g + 1}`,
802
+ value: h,
803
+ style: `font-size:${26 - g * 2}px;font-weight:bold`
804
+ }))
805
+ ], d = p(r, (h) => {
806
+ o(), e.command.executeTitle(h || null);
807
+ });
808
+ return b(d, (t == null ? void 0 : t.level) || ""), d;
809
+ }),
810
+ ...je.map(
811
+ ([e, t, o]) => v(e, a[e], o, ({ editor: i }) => i.command.executeRowFlex(t), {
812
+ isActive: ({ style: i }) => ((i == null ? void 0 : i.rowFlex) || L.LEFT) === t
813
+ })
814
+ ),
815
+ f(
816
+ "rowMargin",
817
+ a.rowMargin,
818
+ Ee,
819
+ ({ editor: e, style: t }, o) => {
820
+ const i = p(
821
+ Fe.map((r) => ({ label: r, value: r })),
822
+ (r) => {
823
+ o(), e.command.executeRowMargin(Number(r));
824
+ }
825
+ );
826
+ return b(i, t ? String(t.rowMargin) : null), i;
827
+ }
828
+ ),
829
+ f(
830
+ "list",
831
+ a.list,
832
+ Me,
833
+ ({ editor: e, style: t }, o) => {
834
+ const i = [
835
+ { label: a.listDecimal, value: `${_.OL}|${y.DECIMAL}` },
836
+ { label: a.listCheckbox, value: `${_.UL}|${y.CHECKBOX}` },
837
+ { label: a.listDisc, value: `${_.UL}|${y.DISC}` },
838
+ { label: a.listCircle, value: `${_.UL}|${y.CIRCLE}` },
839
+ { label: a.listSquare, value: `${_.UL}|${y.SQUARE}` }
840
+ ], r = p(i, (d) => {
841
+ o();
842
+ const [h, g] = d.split("|");
843
+ e.command.executeList(h, g);
844
+ });
845
+ return b(
846
+ r,
847
+ t != null && t.listType ? `${t.listType}|${t.listStyle}` : null
848
+ ), r;
849
+ },
850
+ { isActive: ({ style: e }) => !!(e != null && e.listType) }
851
+ ),
852
+ f("table", a.table, Re, Ye),
853
+ v("image", a.image, we, Pe),
854
+ v("hyperlink", a.hyperlink, pe, Ue),
855
+ f(
856
+ "separator",
857
+ a.separator,
858
+ Te,
859
+ ({ editor: e }, t) => p(
860
+ N.map((o, i) => ({
861
+ label: o.label,
862
+ value: String(i)
863
+ })),
864
+ (o) => {
865
+ t(), e.command.executeSeparator(
866
+ N[Number(o)].dashArray
867
+ );
868
+ }
869
+ )
870
+ ),
871
+ v(
872
+ "pageBreak",
873
+ a.pageBreak,
874
+ ze,
875
+ ({ editor: e }) => e.command.executePageBreak()
876
+ ),
877
+ v("control", a.control, ge, qe),
878
+ f("checkbox", a.checkbox, de, ({ editor: e }, t) => {
879
+ const o = p(
880
+ [
881
+ { label: `☒ ${a.checkboxCross}`, value: D.CROSS },
882
+ { label: `☑ ${a.checkboxCheck}`, value: D.CHECK }
883
+ ],
884
+ (i) => {
885
+ t(), e.command.executeInsertElementList([
886
+ {
887
+ type: E.CHECKBOX,
888
+ value: "",
889
+ checkbox: { value: !1, markType: i }
890
+ }
891
+ ]);
892
+ }
893
+ );
894
+ return b(o, D.CROSS), o;
895
+ }),
896
+ f("date", a.date, ve, ({ editor: e }, t) => {
897
+ const o = /* @__PURE__ */ new Date(), i = [
898
+ { format: "yyyy-MM-dd", text: R(o, !1) },
899
+ { format: "yyyy-MM-dd HH:mm:ss", text: R(o, !0) }
900
+ ];
901
+ return p(
902
+ i.map((r, d) => ({
903
+ label: r.text,
904
+ value: String(d)
905
+ })),
906
+ (r) => {
907
+ t();
908
+ const { format: d, text: h } = i[Number(r)];
909
+ e.command.executeInsertElementList([
910
+ {
911
+ type: E.DATE,
912
+ value: "",
913
+ dateFormat: d,
914
+ valueList: [{ value: h }]
915
+ }
916
+ ]);
917
+ }
918
+ );
919
+ }),
920
+ v("search", a.search, De, Xe, {
921
+ keepEnabledInReadonly: !0
922
+ }),
923
+ v("print", a.print, Le, ({ editor: e }) => e.command.executePrint(), {
924
+ keepEnabledInReadonly: !0
925
+ }),
926
+ v(
927
+ "pdf",
928
+ a.pdf,
929
+ He,
930
+ async ({ editor: e }) => {
931
+ const t = await e.command.getPdf();
932
+ J(t, `document-${Date.now()}.pdf`);
933
+ },
934
+ { keepEnabledInReadonly: !0 }
935
+ )
936
+ ], s = {};
937
+ return n.forEach((e) => {
938
+ s[e.key] = e;
939
+ }), s;
940
+ }
941
+ const q = [
942
+ "undo",
943
+ "redo",
944
+ "painter",
945
+ "format",
946
+ "|",
947
+ "font",
948
+ "size",
949
+ "sizeAdd",
950
+ "sizeMinus",
951
+ "bold",
952
+ "italic",
953
+ "underline",
954
+ "strikeout",
955
+ "superscript",
956
+ "subscript",
957
+ "color",
958
+ "highlight",
959
+ "|",
960
+ "title",
961
+ "left",
962
+ "center",
963
+ "right",
964
+ "alignment",
965
+ "justify",
966
+ "rowMargin",
967
+ "list",
968
+ "|",
969
+ "table",
970
+ "image",
971
+ "hyperlink",
972
+ "separator",
973
+ "pageBreak",
974
+ "checkbox",
975
+ "date",
976
+ "|",
977
+ "search"
978
+ ], Ge = [w.READONLY, w.PRINT];
979
+ class We {
980
+ constructor(n, s = q) {
981
+ this.style = null, this.renderedList = [], this.ui = n, this.el = c("div", { class: l("toolbar") }), this.el.setAttribute(T, k.MENU), this.el.addEventListener("mousedown", (e) => {
982
+ const t = e.target.tagName;
983
+ t !== "INPUT" && t !== "SELECT" && t !== "TEXTAREA" && e.preventDefault();
984
+ }), this.render(s), this.rangeStyleChange = (e) => {
985
+ this.style = e, this.update();
986
+ }, n.editor.eventBus.on("rangeStyleChange", this.rangeStyleChange), this.update();
987
+ }
988
+ getContext() {
989
+ return {
990
+ editor: this.ui.editor,
991
+ ui: this.ui,
992
+ locale: this.ui.locale,
993
+ style: this.style
994
+ };
995
+ }
996
+ render(n) {
997
+ const s = Ke(this.ui.locale), e = this.getContext();
998
+ n.forEach((t) => {
999
+ if (t === "|") {
1000
+ this.el.append(c("span", { class: l("toolbar__divider") }));
1001
+ return;
1002
+ }
1003
+ const o = typeof t == "string" ? s[t] : t;
1004
+ if (!o) {
1005
+ console.warn(`[canvas-editor-ui] unknown toolbar item: ${t}`);
1006
+ return;
1007
+ }
1008
+ const i = o.render ? o.render(e) : this.renderButton(o);
1009
+ i.classList.add(l("toolbar__item")), i.dataset.key = o.key, this.el.append(i), this.renderedList.push({ item: o, el: i });
1010
+ });
1011
+ }
1012
+ renderButton(n) {
1013
+ const s = c(
1014
+ "div",
1015
+ { class: l("toolbar__button"), title: n.title },
1016
+ n.icon ? c("i", {
1017
+ class: l("icon"),
1018
+ style: `background-image:url("${n.icon}")`
1019
+ }) : null,
1020
+ n.text ? c("span", { class: l("toolbar__text") }, n.text) : null
1021
+ );
1022
+ return s.addEventListener("click", () => {
1023
+ var e;
1024
+ s.classList.contains(l("disabled")) || (e = n.onClick) == null || e.call(n, this.getContext(), s);
1025
+ }), s;
1026
+ }
1027
+ // 根据光标样式与编辑模式刷新按钮状态
1028
+ update() {
1029
+ const n = this.getContext(), s = this.ui.editor.command.getOptions().mode, e = Ge.includes(s);
1030
+ this.renderedList.forEach(({ item: t, el: o }) => {
1031
+ var r, d, h;
1032
+ const i = e && !t.keepEnabledInReadonly || !!((r = t.isDisabled) != null && r.call(t, n));
1033
+ o.classList.toggle(l("disabled"), i), o.classList.toggle(l("active"), !!((d = t.isActive) != null && d.call(t, n))), (h = t.update) == null || h.call(t, n, o);
1034
+ });
1035
+ }
1036
+ destroy() {
1037
+ this.ui.editor.eventBus.off("rangeStyleChange", this.rangeStyleChange), this.el.remove();
1038
+ }
1039
+ }
1040
+ let Ze = 0;
1041
+ class Je {
1042
+ constructor(n, s = {}) {
1043
+ this.toolbar = null, this.statusbar = null, this.locale = { ...j, ...s.locale };
1044
+ const e = `${l("root")}-${++Ze}`, t = c("div", { class: l("editor") });
1045
+ this.main = c("div", { class: l("main") }, t), this.root = c("div", { class: l("root"), id: e }, this.main), n.append(this.root), this.editor = new X(t, s.data || { main: [] }, {
1046
+ scrollContainerSelector: `#${e} .${l("main")}`,
1047
+ ...s.options
1048
+ }), s.toolbar !== !1 && (this.toolbar = new We(this, s.toolbar || q), this.root.prepend(this.toolbar.el)), s.statusbar !== !1 && (this.statusbar = new ie(this, s.statusbar || U), this.root.append(this.statusbar.el)), this.mode = this.editor.command.getOptions().mode, this.renderChange = () => {
1049
+ this.editor.command.getOptions().mode !== this.mode && this.syncMode();
1050
+ }, this.editor.eventBus.on("renderChange", this.renderChange);
1051
+ }
1052
+ syncMode() {
1053
+ var n, s;
1054
+ this.mode = this.editor.command.getOptions().mode, (n = this.toolbar) == null || n.update(), (s = this.statusbar) == null || s.update();
1055
+ }
1056
+ // 当前总页数(编辑器仅在页数变化时通知,初始值从页面画布读取)
1057
+ getPageSize() {
1058
+ return this.main.querySelectorAll("canvas[data-index]").length || 1;
1059
+ }
1060
+ // 切换编辑模式并刷新工具栏可用状态
1061
+ setMode(n) {
1062
+ this.editor.command.executeMode(n), this.syncMode();
1063
+ }
1064
+ destroy() {
1065
+ var n, s;
1066
+ this.editor.eventBus.off("renderChange", this.renderChange), (n = this.toolbar) == null || n.destroy(), (s = this.statusbar) == null || s.destroy(), this.editor.destroy(), this.root.remove();
1067
+ }
1068
+ }
1069
+ function e0(a, n) {
1070
+ const s = typeof a == "string" ? document.querySelector(a) : a;
1071
+ if (!s)
1072
+ throw new Error(`[canvas-editor-ui] container not found: ${a}`);
1073
+ return new Je(s, n);
1074
+ }
1075
+ export {
1076
+ U as DEFAULT_STATUSBAR,
1077
+ q as DEFAULT_TOOLBAR,
1078
+ I as Dialog,
1079
+ Je as EditorUI,
1080
+ Ne as FONT_LIST,
1081
+ Oe as SIZE_LIST,
1082
+ e0 as createEditorUI,
1083
+ j as defaultLocale
1084
+ };
1085
+ //# sourceMappingURL=canvas-editor-ui.esm.js.map