@baohu/canvas-editor-ui 0.0.0-stage → 1.0.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,1073 @@
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 q, { EDITOR_COMPONENT as E, EditorComponent as T, EditorMode as p, PageMode as S, PaperDirection as C, RowFlex as H, ElementType as D, TitleLevel as b, ListType as _, ListStyle as y, splitText as X, ControlType as m } from "@baohu/canvas-editor";
3
+ const Y = {
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
+ date: "日期",
57
+ search: "查找替换",
58
+ searchKeyword: "查找",
59
+ searchReplace: "替换为",
60
+ searchReplacePlaceholder: "留空则只查找",
61
+ print: "打印",
62
+ pdf: "导出 PDF",
63
+ confirm: "确定",
64
+ cancel: "取消",
65
+ pageNo: "页面",
66
+ wordCount: "字数",
67
+ rowCol: "行列",
68
+ pageModePaging: "分页",
69
+ pageModeContinuity: "连页",
70
+ scaleMinus: "缩小",
71
+ scaleAdd: "放大",
72
+ scaleRecovery: "恢复 100%",
73
+ paperDirection: "纸张方向",
74
+ paperMargin: "页边距",
75
+ marginTop: "上边距",
76
+ marginRight: "右边距",
77
+ marginBottom: "下边距",
78
+ marginLeft: "左边距",
79
+ modeEdit: "编辑模式",
80
+ modeClean: "清洁模式",
81
+ modeReadonly: "只读模式",
82
+ modeForm: "表单模式",
83
+ modePrint: "打印模式",
84
+ modeDesign: "设计模式",
85
+ fullscreen: "全屏"
86
+ }, j = "ceu";
87
+ function c(a, n = {}, ...s) {
88
+ const e = document.createElement(a);
89
+ return Object.keys(n).forEach((t) => {
90
+ const i = n[t];
91
+ i === void 0 || i === !1 || (t === "class" ? e.className = String(i) : e.setAttribute(t, i === !0 ? "" : String(i)));
92
+ }), s.forEach((t) => {
93
+ t == null || t === !1 || e.append(t);
94
+ }), e;
95
+ }
96
+ function l(a) {
97
+ return `${j}-${a}`;
98
+ }
99
+ function G(a, n) {
100
+ let s = null;
101
+ const e = (...t) => {
102
+ s && clearTimeout(s), s = setTimeout(() => {
103
+ s = null, a(...t);
104
+ }, n);
105
+ };
106
+ return e.cancel = () => {
107
+ s && clearTimeout(s), s = null;
108
+ }, e;
109
+ }
110
+ function K(a) {
111
+ return new Promise((n, s) => {
112
+ const e = new FileReader();
113
+ e.onload = () => n(e.result), e.onerror = s, e.readAsDataURL(a);
114
+ });
115
+ }
116
+ function W(a) {
117
+ return new Promise((n, s) => {
118
+ const e = new Image();
119
+ e.onload = () => n(e), e.onerror = s, e.src = a;
120
+ });
121
+ }
122
+ function Z(a, n) {
123
+ const s = URL.createObjectURL(a);
124
+ c("a", { href: s, download: n }).click(), URL.revokeObjectURL(s);
125
+ }
126
+ function V(a, n) {
127
+ const s = (t) => String(t).padStart(2, "0"), e = `${a.getFullYear()}-${s(a.getMonth() + 1)}-${s(
128
+ a.getDate()
129
+ )}`;
130
+ return n ? `${e} ${s(a.getHours())}:${s(a.getMinutes())}:${s(
131
+ a.getSeconds()
132
+ )}` : e;
133
+ }
134
+ class k {
135
+ constructor(n) {
136
+ var s;
137
+ this.inputList = [], this.options = n, this.mask = c("div", { class: l("dialog-mask") }), this.container = this.render(), this.mask.setAttribute(E, T.COMPONENT), this.container.setAttribute(E, T.COMPONENT), document.body.append(this.mask, this.container), this.keydownHandler = (e) => {
138
+ e.key === "Escape" && this.close();
139
+ }, document.addEventListener("keydown", this.keydownHandler), (s = this.inputList[0]) == null || s.focus();
140
+ }
141
+ render() {
142
+ const { title: n, fields: s, confirmText: e = "确定", cancelText: t = "取消" } = this.options, i = c("i", { class: l("dialog__close") });
143
+ i.onclick = () => this.close();
144
+ const o = c("div", { class: l("dialog__body") });
145
+ s.forEach((g) => {
146
+ const u = this.createInput(g);
147
+ this.inputList.push(u);
148
+ const x = g.label ? c(
149
+ "span",
150
+ {
151
+ class: `${l("dialog__label")}${g.required ? ` ${l("dialog__label--required")}` : ""}`
152
+ },
153
+ g.label
154
+ ) : null;
155
+ o.append(c("label", { class: l("dialog__field") }, x, u));
156
+ });
157
+ const r = c("button", { type: "button" }, t);
158
+ r.onclick = () => this.close();
159
+ const d = c(
160
+ "button",
161
+ { type: "button", class: l("dialog__confirm") },
162
+ e
163
+ );
164
+ d.onclick = () => this.confirm();
165
+ const h = c(
166
+ "div",
167
+ { class: l("dialog") },
168
+ c("div", { class: l("dialog__title") }, c("span", {}, n), i),
169
+ o,
170
+ c("div", { class: l("dialog__footer") }, r, d)
171
+ );
172
+ return h.addEventListener("keydown", (g) => {
173
+ const u = g.target;
174
+ g.key === "Enter" && u.tagName === "INPUT" && (g.preventDefault(), this.confirm());
175
+ }), c("div", { class: l("dialog-container") }, h);
176
+ }
177
+ createInput(n) {
178
+ var e;
179
+ let s;
180
+ return n.type === "select" ? (s = c("select", { name: n.name }), (e = n.options) == null || e.forEach((t) => {
181
+ s.append(c("option", { value: t.value }, t.label));
182
+ })) : 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;
183
+ }
184
+ confirm() {
185
+ const { fields: n, onConfirm: s } = this.options, e = {};
186
+ let t = !0;
187
+ this.inputList.forEach((i, o) => {
188
+ e[i.name] = i.value;
189
+ const r = n[o].required && !i.value.trim();
190
+ i.classList.toggle(l("dialog__input--error"), !!r), r && (t = !1);
191
+ }), t && (s && s(e) === !1 || this.dispose());
192
+ }
193
+ close() {
194
+ var n, s;
195
+ (s = (n = this.options).onClose) == null || s.call(n), this.dispose();
196
+ }
197
+ dispose() {
198
+ document.removeEventListener("keydown", this.keydownHandler), this.mask.remove(), this.container.remove();
199
+ }
200
+ }
201
+ const f = /* @__PURE__ */ new Set();
202
+ function A(a) {
203
+ f.forEach((n) => {
204
+ n.el.contains(a.target) || n.close();
205
+ });
206
+ }
207
+ class I {
208
+ constructor(n, s, e = "bottom") {
209
+ this.panel = c(
210
+ "div",
211
+ { class: `${l("dropdown__panel")} ${l(`dropdown__panel--${e}`)}` },
212
+ s
213
+ ), this.el = c("div", { class: l("dropdown") }, n, this.panel), n.addEventListener("click", () => this.toggle());
214
+ }
215
+ toggle() {
216
+ f.has(this) ? this.close() : this.open();
217
+ }
218
+ open() {
219
+ f.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"), f.size || document.addEventListener("mousedown", A), f.add(this);
220
+ }
221
+ close() {
222
+ this.panel.classList.remove(l("dropdown__panel--visible")), f.delete(this), f.size || document.removeEventListener("mousedown", A);
223
+ }
224
+ }
225
+ function w(a, n) {
226
+ const s = c("ul", { class: l("option-list") });
227
+ return a.forEach((e) => {
228
+ const t = c(
229
+ "li",
230
+ { "data-value": e.value, style: e.style },
231
+ e.icon ? c("i", {
232
+ class: l("icon"),
233
+ style: `background-image:url("${e.icon}")`
234
+ }) : null,
235
+ e.label
236
+ );
237
+ t.addEventListener("mousedown", (i) => i.preventDefault()), t.addEventListener("click", () => n(e.value)), s.append(t);
238
+ }), s;
239
+ }
240
+ function L(a, n) {
241
+ a.querySelectorAll("li").forEach((s) => {
242
+ s.classList.toggle(l("active"), s.dataset.value === n);
243
+ });
244
+ }
245
+ const J = "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", Q = "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", 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='M7%207V3h2v4h4v2H9v4H7V9H3V7h4z'%20fill='%23636363'%20fill-rule='evenodd'/%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='M3%207h10v2H3z'%20fill='%23636363'%20fill-rule='evenodd'/%3e%3c/svg%3e", ne = "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", se = "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", R = "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", P = [
246
+ "pageNo",
247
+ "wordCount",
248
+ "rowCol",
249
+ "pageMode",
250
+ "scale",
251
+ "paperDirection",
252
+ "paperMargin",
253
+ "fullscreen"
254
+ ], ae = ["pageNo", "wordCount", "rowCol"];
255
+ function M(a, n, s) {
256
+ const e = c(
257
+ "div",
258
+ { class: l("statusbar__button"), title: n },
259
+ c("i", { class: l("icon"), style: `background-image:url("${a}")` })
260
+ );
261
+ return e.addEventListener("click", s), e;
262
+ }
263
+ class ie {
264
+ constructor(n, s = P) {
265
+ this.disposeList = [], this.updaterList = [], this.on = (i, o) => {
266
+ const { eventBus: r } = this.ui.editor;
267
+ r.on(i, o), this.disposeList.push(() => r.off(i, o));
268
+ }, this.ui = n;
269
+ const e = c("div", { class: l("statusbar__left") }), t = c("div", { class: l("statusbar__right") });
270
+ this.el = c("div", { class: l("statusbar") }, e, t), this.el.setAttribute(E, T.FOOTER), this.el.addEventListener("mousedown", (i) => i.preventDefault()), s.forEach((i) => {
271
+ const o = this.createItem(i);
272
+ o && (o.classList.add(l("statusbar__item")), (ae.includes(i) ? e : t).append(o));
273
+ });
274
+ }
275
+ createItem(n) {
276
+ const { editor: s, locale: e } = this.ui;
277
+ switch (n) {
278
+ case "pageNo": {
279
+ const t = c("span", {}, "1"), i = c("span", {}, String(this.ui.getPageSize()));
280
+ return this.on("intersectionPageNoChange", (o) => {
281
+ t.innerText = String(o + 1);
282
+ }), this.on("pageSizeChange", (o) => {
283
+ i.innerText = String(o);
284
+ }), c("span", {}, `${e.pageNo}:`, t, "/", i);
285
+ }
286
+ case "wordCount": {
287
+ const t = c("span", {}, "0"), i = G(async () => {
288
+ t.innerText = String(await s.command.getWordCount());
289
+ }, 300);
290
+ return this.on("contentChange", i), this.disposeList.push(i.cancel), i(), c("span", {}, `${e.wordCount}:`, t);
291
+ }
292
+ case "rowCol": {
293
+ const t = c("span", {}, "1:1");
294
+ return this.on("rangeStyleChange", () => {
295
+ const i = s.command.getRangeContext();
296
+ i && (t.innerText = `${i.startRowNo + 1}:${i.startColNo + 1}`);
297
+ }), c("span", {}, `${e.rowCol}:`, t);
298
+ }
299
+ case "pageMode": {
300
+ const t = M(Q, "", () => {
301
+ }), i = w(
302
+ [
303
+ { label: e.pageModePaging, value: S.PAGING },
304
+ { label: e.pageModeContinuity, value: S.CONTINUITY }
305
+ ],
306
+ (d) => {
307
+ o.close(), s.command.executePageMode(d);
308
+ }
309
+ ), o = new I(t, i, "top"), r = (d) => {
310
+ L(i, d), t.title = d === S.CONTINUITY ? e.pageModeContinuity : e.pageModePaging;
311
+ };
312
+ return r(s.command.getOptions().pageMode), this.on("pageModeChange", r), o.el;
313
+ }
314
+ case "scale": {
315
+ const t = c("span", {
316
+ class: l("statusbar__scale"),
317
+ title: e.scaleRecovery
318
+ }), i = (o) => {
319
+ t.innerText = `${Math.round(o * 100)}%`;
320
+ };
321
+ return i(s.command.getOptions().scale), this.on("pageScaleChange", i), t.addEventListener(
322
+ "click",
323
+ () => s.command.executePageScaleRecovery()
324
+ ), c(
325
+ "div",
326
+ { class: l("statusbar__group") },
327
+ M(
328
+ te,
329
+ e.scaleMinus,
330
+ () => s.command.executePageScaleMinus()
331
+ ),
332
+ t,
333
+ M(
334
+ ee,
335
+ e.scaleAdd,
336
+ () => s.command.executePageScaleAdd()
337
+ )
338
+ );
339
+ }
340
+ case "paperDirection":
341
+ return M(ne, e.paperDirection, () => {
342
+ const { paperDirection: t } = s.command.getOptions();
343
+ s.command.executePaperDirection(
344
+ t === C.HORIZONTAL ? C.VERTICAL : C.HORIZONTAL
345
+ );
346
+ });
347
+ case "paperMargin":
348
+ return M(
349
+ se,
350
+ e.paperMargin,
351
+ () => this.openPaperMarginDialog()
352
+ );
353
+ case "mode": {
354
+ const t = [
355
+ { label: e.modeEdit, value: p.EDIT },
356
+ { label: e.modeClean, value: p.CLEAN },
357
+ { label: e.modeReadonly, value: p.READONLY },
358
+ { label: e.modeForm, value: p.FORM },
359
+ { label: e.modePrint, value: p.PRINT },
360
+ { label: e.modeDesign, value: p.DESIGN }
361
+ ], i = c("span", { class: l("statusbar__mode") }), o = w(t, (h) => {
362
+ r.close(), this.ui.setMode(h);
363
+ }), r = new I(i, o, "top"), d = () => {
364
+ var g;
365
+ const h = s.command.getOptions().mode;
366
+ i.innerText = ((g = t.find((u) => u.value === h)) == null ? void 0 : g.label) || h, L(o, h);
367
+ };
368
+ return d(), this.updaterList.push(d), r.el;
369
+ }
370
+ case "fullscreen": {
371
+ const t = M(R, e.fullscreen, () => {
372
+ document.fullscreenElement ? document.exitFullscreen() : this.ui.root.requestFullscreen();
373
+ }), i = () => {
374
+ const o = document.fullscreenElement ? J : R;
375
+ t.querySelector("i").style.backgroundImage = `url("${o}")`;
376
+ };
377
+ return document.addEventListener("fullscreenchange", i), this.disposeList.push(
378
+ () => document.removeEventListener("fullscreenchange", i)
379
+ ), t;
380
+ }
381
+ default:
382
+ return console.warn(`[canvas-editor-ui] unknown statusbar item: ${n}`), null;
383
+ }
384
+ }
385
+ openPaperMarginDialog() {
386
+ const { editor: n, locale: s } = this.ui, e = ["top", "right", "bottom", "left"], t = [
387
+ s.marginTop,
388
+ s.marginRight,
389
+ s.marginBottom,
390
+ s.marginLeft
391
+ ], i = n.command.getPaperMargin();
392
+ new k({
393
+ title: s.paperMargin,
394
+ confirmText: s.confirm,
395
+ cancelText: s.cancel,
396
+ fields: e.map((o, r) => ({
397
+ type: "number",
398
+ name: o,
399
+ label: t[r],
400
+ required: !0,
401
+ value: String(i[r])
402
+ })),
403
+ onConfirm: (o) => {
404
+ const [r, d, h, g] = e.map(
405
+ (x) => Number(o[x])
406
+ ), u = [r, d, h, g];
407
+ if (u.some((x) => isNaN(x) || x < 0)) return !1;
408
+ n.command.executeSetPaperMargin(u);
409
+ }
410
+ });
411
+ }
412
+ // 外部状态(如编辑模式)变化后刷新
413
+ update() {
414
+ this.updaterList.forEach((n) => n());
415
+ }
416
+ destroy() {
417
+ this.disposeList.forEach((n) => n()), this.el.remove();
418
+ }
419
+ }
420
+ const oe = "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", 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='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", 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='M2%2013h12v1H2v-1zm2-3h8v1H4v-1zM2%207h12v1H2V7zm0-6h12v1H2V1zm2%203h8v1H4V4z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e", re = "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", de = "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", he = "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", ge = "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", ve = "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", 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='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", me = "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", pe = "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", we = "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", fe = "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", xe = "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", be = "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", Me = "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", 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='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", ze = "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", 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='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", 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='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", _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='M2%2013h12v1H2v-1zm4-3h8v1H6v-1zM2%207h12v1H2V7zm0-6h12v1H2V1zm4%203h8v1H6V4z'%20fill='%233D4757'%20fill-rule='evenodd'/%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%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", Ee = "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", Te = "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", 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%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", 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='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", Ce = "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", Ve = "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", 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='M5%202v6a3%203%200%20106%200V2h1v6a4%204%200%2011-8%200V2h1zM4%2013h8v1H4z'%20fill='%233D4757'/%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='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", $e = [
421
+ "Microsoft YaHei",
422
+ "宋体",
423
+ "黑体",
424
+ "仿宋",
425
+ "楷体",
426
+ "华文宋体",
427
+ "华文黑体",
428
+ "华文仿宋",
429
+ "华文楷体",
430
+ "华文隶书",
431
+ "华文行楷",
432
+ "Arial",
433
+ "Segoe UI",
434
+ "Times New Roman"
435
+ ].map((a) => ({
436
+ label: a === "Microsoft YaHei" ? "微软雅黑" : a,
437
+ value: a,
438
+ style: `font-family:'${a}'`
439
+ })), Ne = [
440
+ ["初号", 56],
441
+ ["小初", 48],
442
+ ["一号", 34],
443
+ ["小一", 32],
444
+ ["二号", 29],
445
+ ["小二", 24],
446
+ ["三号", 21],
447
+ ["小三", 20],
448
+ ["四号", 18],
449
+ ["小四", 16],
450
+ ["五号", 14],
451
+ ["小五", 12],
452
+ ["六号", 10],
453
+ ["小六", 8],
454
+ ["七号", 7],
455
+ ["八号", 6]
456
+ ].map(([a, n]) => ({ label: String(a), value: String(n) })), Oe = ["1", "1.25", "1.5", "1.75", "2", "2.5", "3"], $ = [
457
+ { label: "———— 实线", dashArray: [] },
458
+ { label: "··········· 点线", dashArray: [1, 1] },
459
+ { label: "- - - - - 短虚线", dashArray: [3, 1] },
460
+ { label: "— — — 长虚线", dashArray: [4, 4] },
461
+ { label: "—·—·— 点划线", dashArray: [7, 3, 3, 3] },
462
+ { label: "—··—·· 双点划线", dashArray: [6, 2, 2, 2, 2, 2] }
463
+ ];
464
+ function v(a, n, s, e, t = {}) {
465
+ return { key: a, title: n, icon: s, onClick: e, ...t };
466
+ }
467
+ function N(a, n, s, e, t, i) {
468
+ return {
469
+ key: a,
470
+ title: n,
471
+ render: (o) => {
472
+ const r = c("span", { class: l("select__label") }), d = c(
473
+ "div",
474
+ { class: l("select"), title: n, style: `width:${e}px` },
475
+ r
476
+ ), h = w(s, (u) => {
477
+ g.close(), t(o, u);
478
+ }), g = new I(d, h);
479
+ return g.el;
480
+ },
481
+ update: (o, r) => {
482
+ const d = i(o), h = s.find((g) => g.value === d);
483
+ r.querySelector(`.${l("select__label")}`).innerText = h ? h.label : d || "", L(r, d);
484
+ }
485
+ };
486
+ }
487
+ function z(a, n, s, e, t = {}) {
488
+ return {
489
+ key: a,
490
+ title: n,
491
+ render: (i) => {
492
+ const o = c(
493
+ "div",
494
+ { class: `${l("toolbar__button")} ${l("toolbar__button--arrow")}`, title: n },
495
+ c("i", { class: l("icon"), style: `background-image:url("${s}")` })
496
+ ), r = c("div"), d = new I(o, r);
497
+ return o.addEventListener(
498
+ "click",
499
+ () => {
500
+ r.innerHTML = "", r.append(e(i, () => d.close()));
501
+ },
502
+ !0
503
+ ), d.el;
504
+ },
505
+ ...t
506
+ };
507
+ }
508
+ function O(a, n, s, e, t) {
509
+ return {
510
+ key: a,
511
+ title: n,
512
+ render: (i) => {
513
+ const o = c("input", { type: "color", class: l("color__input") });
514
+ o.addEventListener("input", () => e(i, o.value));
515
+ const r = c("span", { class: l("color__bar") }), d = c(
516
+ "div",
517
+ { class: `${l("toolbar__button")} ${l("color")}`, title: n },
518
+ c("i", { class: l("icon"), style: `background-image:url("${s}")` }),
519
+ r,
520
+ o
521
+ );
522
+ return d.addEventListener("click", () => o.click()), d;
523
+ },
524
+ update: (i, o) => {
525
+ const r = t(i);
526
+ o.querySelector(`.${l("color__bar")}`).style.background = r || "transparent";
527
+ }
528
+ };
529
+ }
530
+ function Fe(a) {
531
+ const n = c("input", { type: "file", accept: "image/*" });
532
+ n.addEventListener("change", async () => {
533
+ var i;
534
+ const s = (i = n.files) == null ? void 0 : i[0];
535
+ if (!s) return;
536
+ const e = await K(s), t = await W(e);
537
+ a.editor.command.executeImage({
538
+ value: e,
539
+ width: t.width,
540
+ height: t.height
541
+ });
542
+ }), n.click();
543
+ }
544
+ function Pe({ editor: a, locale: n }) {
545
+ new k({
546
+ title: n.hyperlink,
547
+ confirmText: n.confirm,
548
+ cancelText: n.cancel,
549
+ fields: [
550
+ {
551
+ type: "text",
552
+ name: "text",
553
+ label: n.hyperlinkText,
554
+ required: !0,
555
+ value: a.command.getRangeText()
556
+ },
557
+ {
558
+ type: "text",
559
+ name: "url",
560
+ label: n.hyperlinkUrl,
561
+ required: !0,
562
+ placeholder: "https://"
563
+ }
564
+ ],
565
+ onConfirm: ({ text: s, url: e }) => {
566
+ a.command.executeHyperlink({
567
+ url: e,
568
+ valueList: X(s).map((t) => ({ value: t }))
569
+ });
570
+ }
571
+ });
572
+ }
573
+ const F = [
574
+ m.SELECT,
575
+ m.CHECKBOX,
576
+ m.RADIO
577
+ ];
578
+ function Ue({ editor: a, locale: n }) {
579
+ new k({
580
+ title: n.control,
581
+ confirmText: n.confirm,
582
+ cancelText: n.cancel,
583
+ fields: [
584
+ {
585
+ type: "select",
586
+ name: "type",
587
+ label: n.controlType,
588
+ options: [
589
+ { label: n.controlText, value: m.TEXT },
590
+ { label: n.controlSelect, value: m.SELECT },
591
+ { label: n.controlCheckbox, value: m.CHECKBOX },
592
+ { label: n.controlRadio, value: m.RADIO },
593
+ { label: n.controlDate, value: m.DATE },
594
+ { label: n.controlNumber, value: m.NUMBER }
595
+ ]
596
+ },
597
+ {
598
+ type: "text",
599
+ name: "placeholder",
600
+ label: n.controlPlaceholder
601
+ },
602
+ {
603
+ type: "textarea",
604
+ name: "valueSets",
605
+ label: n.controlValueSets,
606
+ placeholder: n.controlValueSetsPlaceholder,
607
+ height: 80
608
+ },
609
+ {
610
+ type: "select",
611
+ name: "dateFormat",
612
+ label: n.controlDateFormat,
613
+ options: [
614
+ { label: "yyyy-MM-dd", value: "yyyy-MM-dd" },
615
+ { label: "yyyy-MM-dd HH:mm:ss", value: "yyyy-MM-dd HH:mm:ss" }
616
+ ]
617
+ }
618
+ ],
619
+ onConfirm: (s) => {
620
+ const e = s.type, t = s.valueSets.split(`
621
+ `).map((o) => o.trim()).filter(Boolean).map((o) => ({ value: o, code: o }));
622
+ if (F.includes(e) && !t.length)
623
+ return !1;
624
+ const i = {
625
+ type: e,
626
+ value: null,
627
+ placeholder: s.placeholder || void 0
628
+ };
629
+ F.includes(e) && (i.code = null, i.valueSets = t), e === m.DATE && (i.dateFormat = s.dateFormat), a.command.executeInsertControl({
630
+ type: D.CONTROL,
631
+ value: "",
632
+ control: i
633
+ });
634
+ }
635
+ });
636
+ }
637
+ function qe({ editor: a, locale: n }) {
638
+ new k({
639
+ title: n.search,
640
+ confirmText: n.confirm,
641
+ cancelText: n.cancel,
642
+ fields: [
643
+ {
644
+ type: "text",
645
+ name: "keyword",
646
+ label: n.searchKeyword,
647
+ required: !0,
648
+ value: a.command.getRangeText()
649
+ },
650
+ {
651
+ type: "text",
652
+ name: "replace",
653
+ label: n.searchReplace,
654
+ placeholder: n.searchReplacePlaceholder
655
+ }
656
+ ],
657
+ onConfirm: ({ keyword: s, replace: e }) => {
658
+ a.command.executeSearch(s), e && a.command.executeReplace(e);
659
+ },
660
+ onClose: () => a.command.executeSearch(null)
661
+ });
662
+ }
663
+ function Xe(a, n) {
664
+ const e = c("div", { class: l("table-picker__title") }, a.locale.table), t = c("div", { class: l("table-picker__grid") }), i = [];
665
+ for (let o = 1; o <= 10; o++)
666
+ for (let r = 1; r <= 10; r++) {
667
+ const d = c("span", { "data-row": o, "data-col": r });
668
+ i.push(d), t.append(d);
669
+ }
670
+ return t.addEventListener("mouseover", (o) => {
671
+ const r = o.target, d = Number(r.dataset.row), h = Number(r.dataset.col);
672
+ !d || !h || (e.innerText = `${d} × ${h}`, i.forEach((g) => {
673
+ g.classList.toggle(
674
+ l("active"),
675
+ Number(g.dataset.row) <= d && Number(g.dataset.col) <= h
676
+ );
677
+ }));
678
+ }), t.addEventListener("mousedown", (o) => o.preventDefault()), t.addEventListener("click", (o) => {
679
+ const r = o.target, d = Number(r.dataset.row), h = Number(r.dataset.col);
680
+ !d || !h || (n(), a.editor.command.executeInsertTable(d, h));
681
+ }), c("div", { class: l("table-picker") }, e, t);
682
+ }
683
+ const Ye = [
684
+ ["left", H.LEFT, xe],
685
+ ["center", H.CENTER, le],
686
+ ["right", H.RIGHT, _e],
687
+ ["alignment", H.ALIGNMENT, oe],
688
+ ["justify", H.JUSTIFY, fe]
689
+ ];
690
+ function je(a) {
691
+ const n = [
692
+ v("undo", a.undo, Be, ({ editor: e }) => e.command.executeUndo(), {
693
+ isDisabled: ({ style: e }) => !!e && !e.undo
694
+ }),
695
+ v("redo", a.redo, Le, ({ editor: e }) => e.command.executeRedo(), {
696
+ isDisabled: ({ style: e }) => !!e && !e.redo
697
+ }),
698
+ {
699
+ key: "painter",
700
+ title: a.painter,
701
+ icon: B,
702
+ isActive: ({ style: e }) => !!(e != null && e.painter),
703
+ render: ({ editor: e }) => {
704
+ const t = c(
705
+ "div",
706
+ { class: l("toolbar__button"), title: a.painter },
707
+ c("i", {
708
+ class: l("icon"),
709
+ style: `background-image:url("${B}")`
710
+ })
711
+ );
712
+ let i = null;
713
+ return t.addEventListener("click", () => {
714
+ i && clearTimeout(i), i = setTimeout(() => {
715
+ i = null, e.command.executePainter({ isDblclick: !1 });
716
+ }, 200);
717
+ }), t.addEventListener("dblclick", () => {
718
+ i && clearTimeout(i), i = null, e.command.executePainter({ isDblclick: !0 });
719
+ }), t;
720
+ }
721
+ },
722
+ v(
723
+ "format",
724
+ a.format,
725
+ ve,
726
+ ({ editor: e }) => e.command.executeFormat()
727
+ ),
728
+ N(
729
+ "font",
730
+ a.font,
731
+ $e,
732
+ 90,
733
+ ({ editor: e }, t) => e.command.executeFont(t),
734
+ ({ editor: e, style: t }) => (t == null ? void 0 : t.font) || e.command.getOptions().defaultFont
735
+ ),
736
+ N(
737
+ "size",
738
+ a.size,
739
+ Ne,
740
+ 54,
741
+ ({ editor: e }, t) => e.command.executeSize(Number(t)),
742
+ ({ editor: e, style: t }) => String(t ? t.size : e.command.getOptions().defaultSize)
743
+ ),
744
+ v(
745
+ "sizeAdd",
746
+ a.sizeAdd,
747
+ Te,
748
+ ({ editor: e }) => e.command.executeSizeAdd()
749
+ ),
750
+ v(
751
+ "sizeMinus",
752
+ a.sizeMinus,
753
+ Ie,
754
+ ({ editor: e }) => e.command.executeSizeMinus()
755
+ ),
756
+ v("bold", a.bold, ce, ({ editor: e }) => e.command.executeBold(), {
757
+ isActive: ({ style: e }) => !!(e != null && e.bold)
758
+ }),
759
+ v("italic", a.italic, we, ({ editor: e }) => e.command.executeItalic(), {
760
+ isActive: ({ style: e }) => !!(e != null && e.italic)
761
+ }),
762
+ v("underline", a.underline, Re, ({ editor: e }) => e.command.executeUnderline(), {
763
+ isActive: ({ style: e }) => !!(e != null && e.underline)
764
+ }),
765
+ v("strikeout", a.strikeout, ke, ({ editor: e }) => e.command.executeStrikeout(), {
766
+ isActive: ({ style: e }) => !!(e != null && e.strikeout)
767
+ }),
768
+ v("superscript", a.superscript, Ce, ({ editor: e }) => e.command.executeSuperscript(), {
769
+ isActive: ({ style: e }) => (e == null ? void 0 : e.type) === D.SUPERSCRIPT
770
+ }),
771
+ v("subscript", a.subscript, Se, ({ editor: e }) => e.command.executeSubscript(), {
772
+ isActive: ({ style: e }) => (e == null ? void 0 : e.type) === D.SUBSCRIPT
773
+ }),
774
+ O(
775
+ "color",
776
+ a.color,
777
+ de,
778
+ ({ editor: e }, t) => e.command.executeColor(t),
779
+ ({ style: e }) => (e == null ? void 0 : e.color) || "#000000"
780
+ ),
781
+ O(
782
+ "highlight",
783
+ a.highlight,
784
+ ue,
785
+ ({ editor: e }, t) => e.command.executeHighlight(t),
786
+ ({ style: e }) => (e == null ? void 0 : e.highlight) || null
787
+ ),
788
+ z("title", a.title, Ae, ({ editor: e, style: t }, i) => {
789
+ const o = [
790
+ b.FIRST,
791
+ b.SECOND,
792
+ b.THIRD,
793
+ b.FOURTH,
794
+ b.FIFTH,
795
+ b.SIXTH
796
+ ], r = [
797
+ { label: a.text, value: "" },
798
+ ...o.map((h, g) => ({
799
+ label: `${a.title}${g + 1}`,
800
+ value: h,
801
+ style: `font-size:${26 - g * 2}px;font-weight:bold`
802
+ }))
803
+ ], d = w(r, (h) => {
804
+ i(), e.command.executeTitle(h || null);
805
+ });
806
+ return L(d, (t == null ? void 0 : t.level) || ""), d;
807
+ }),
808
+ ...Ye.map(
809
+ ([e, t, i]) => v(e, a[e], i, ({ editor: o }) => o.command.executeRowFlex(t), {
810
+ isActive: ({ style: o }) => ((o == null ? void 0 : o.rowFlex) || H.LEFT) === t
811
+ })
812
+ ),
813
+ z(
814
+ "rowMargin",
815
+ a.rowMargin,
816
+ ye,
817
+ ({ editor: e, style: t }, i) => {
818
+ const o = w(
819
+ Oe.map((r) => ({ label: r, value: r })),
820
+ (r) => {
821
+ i(), e.command.executeRowMargin(Number(r));
822
+ }
823
+ );
824
+ return L(o, t ? String(t.rowMargin) : null), o;
825
+ }
826
+ ),
827
+ z(
828
+ "list",
829
+ a.list,
830
+ be,
831
+ ({ editor: e, style: t }, i) => {
832
+ const o = [
833
+ { label: a.listDecimal, value: `${_.OL}|${y.DECIMAL}` },
834
+ { label: a.listCheckbox, value: `${_.UL}|${y.CHECKBOX}` },
835
+ { label: a.listDisc, value: `${_.UL}|${y.DISC}` },
836
+ { label: a.listCircle, value: `${_.UL}|${y.CIRCLE}` },
837
+ { label: a.listSquare, value: `${_.UL}|${y.SQUARE}` }
838
+ ], r = w(o, (d) => {
839
+ i();
840
+ const [h, g] = d.split("|");
841
+ e.command.executeList(h, g);
842
+ });
843
+ return L(
844
+ r,
845
+ t != null && t.listType ? `${t.listType}|${t.listStyle}` : null
846
+ ), r;
847
+ },
848
+ { isActive: ({ style: e }) => !!(e != null && e.listType) }
849
+ ),
850
+ z("table", a.table, Ve, Xe),
851
+ v("image", a.image, pe, Fe),
852
+ v("hyperlink", a.hyperlink, me, Pe),
853
+ z(
854
+ "separator",
855
+ a.separator,
856
+ Ee,
857
+ ({ editor: e }, t) => w(
858
+ $.map((i, o) => ({
859
+ label: i.label,
860
+ value: String(o)
861
+ })),
862
+ (i) => {
863
+ t(), e.command.executeSeparator(
864
+ $[Number(i)].dashArray
865
+ );
866
+ }
867
+ )
868
+ ),
869
+ v(
870
+ "pageBreak",
871
+ a.pageBreak,
872
+ Me,
873
+ ({ editor: e }) => e.command.executePageBreak()
874
+ ),
875
+ v("control", a.control, he, Ue),
876
+ v(
877
+ "checkbox",
878
+ a.checkbox,
879
+ re,
880
+ ({ editor: e }) => e.command.executeInsertElementList([
881
+ { type: D.CHECKBOX, value: "", checkbox: { value: !1 } }
882
+ ])
883
+ ),
884
+ z("date", a.date, ge, ({ editor: e }, t) => {
885
+ const i = /* @__PURE__ */ new Date(), o = [
886
+ { format: "yyyy-MM-dd", text: V(i, !1) },
887
+ { format: "yyyy-MM-dd HH:mm:ss", text: V(i, !0) }
888
+ ];
889
+ return w(
890
+ o.map((r, d) => ({
891
+ label: r.text,
892
+ value: String(d)
893
+ })),
894
+ (r) => {
895
+ t();
896
+ const { format: d, text: h } = o[Number(r)];
897
+ e.command.executeInsertElementList([
898
+ {
899
+ type: D.DATE,
900
+ value: "",
901
+ dateFormat: d,
902
+ valueList: [{ value: h }]
903
+ }
904
+ ]);
905
+ }
906
+ );
907
+ }),
908
+ v("search", a.search, De, qe, {
909
+ keepEnabledInReadonly: !0
910
+ }),
911
+ v("print", a.print, He, ({ editor: e }) => e.command.executePrint(), {
912
+ keepEnabledInReadonly: !0
913
+ }),
914
+ v(
915
+ "pdf",
916
+ a.pdf,
917
+ ze,
918
+ async ({ editor: e }) => {
919
+ const t = await e.command.getPdf();
920
+ Z(t, `document-${Date.now()}.pdf`);
921
+ },
922
+ { keepEnabledInReadonly: !0 }
923
+ )
924
+ ], s = {};
925
+ return n.forEach((e) => {
926
+ s[e.key] = e;
927
+ }), s;
928
+ }
929
+ const U = [
930
+ "undo",
931
+ "redo",
932
+ "painter",
933
+ "format",
934
+ "|",
935
+ "font",
936
+ "size",
937
+ "sizeAdd",
938
+ "sizeMinus",
939
+ "bold",
940
+ "italic",
941
+ "underline",
942
+ "strikeout",
943
+ "superscript",
944
+ "subscript",
945
+ "color",
946
+ "highlight",
947
+ "|",
948
+ "title",
949
+ "left",
950
+ "center",
951
+ "right",
952
+ "alignment",
953
+ "justify",
954
+ "rowMargin",
955
+ "list",
956
+ "|",
957
+ "table",
958
+ "image",
959
+ "hyperlink",
960
+ "separator",
961
+ "pageBreak",
962
+ "checkbox",
963
+ "date",
964
+ "|",
965
+ "search"
966
+ ], Ge = [p.READONLY, p.PRINT];
967
+ class Ke {
968
+ constructor(n, s = U) {
969
+ this.style = null, this.renderedList = [], this.ui = n, this.el = c("div", { class: l("toolbar") }), this.el.setAttribute(E, T.MENU), this.el.addEventListener("mousedown", (e) => {
970
+ const t = e.target.tagName;
971
+ t !== "INPUT" && t !== "SELECT" && t !== "TEXTAREA" && e.preventDefault();
972
+ }), this.render(s), this.rangeStyleChange = (e) => {
973
+ this.style = e, this.update();
974
+ }, n.editor.eventBus.on("rangeStyleChange", this.rangeStyleChange), this.update();
975
+ }
976
+ getContext() {
977
+ return {
978
+ editor: this.ui.editor,
979
+ ui: this.ui,
980
+ locale: this.ui.locale,
981
+ style: this.style
982
+ };
983
+ }
984
+ render(n) {
985
+ const s = je(this.ui.locale), e = this.getContext();
986
+ n.forEach((t) => {
987
+ if (t === "|") {
988
+ this.el.append(c("span", { class: l("toolbar__divider") }));
989
+ return;
990
+ }
991
+ const i = typeof t == "string" ? s[t] : t;
992
+ if (!i) {
993
+ console.warn(`[canvas-editor-ui] unknown toolbar item: ${t}`);
994
+ return;
995
+ }
996
+ const o = i.render ? i.render(e) : this.renderButton(i);
997
+ o.classList.add(l("toolbar__item")), o.dataset.key = i.key, this.el.append(o), this.renderedList.push({ item: i, el: o });
998
+ });
999
+ }
1000
+ renderButton(n) {
1001
+ const s = c(
1002
+ "div",
1003
+ { class: l("toolbar__button"), title: n.title },
1004
+ n.icon ? c("i", {
1005
+ class: l("icon"),
1006
+ style: `background-image:url("${n.icon}")`
1007
+ }) : null,
1008
+ n.text ? c("span", { class: l("toolbar__text") }, n.text) : null
1009
+ );
1010
+ return s.addEventListener("click", () => {
1011
+ var e;
1012
+ s.classList.contains(l("disabled")) || (e = n.onClick) == null || e.call(n, this.getContext(), s);
1013
+ }), s;
1014
+ }
1015
+ // 根据光标样式与编辑模式刷新按钮状态
1016
+ update() {
1017
+ const n = this.getContext(), s = this.ui.editor.command.getOptions().mode, e = Ge.includes(s);
1018
+ this.renderedList.forEach(({ item: t, el: i }) => {
1019
+ var r, d, h;
1020
+ const o = e && !t.keepEnabledInReadonly || !!((r = t.isDisabled) != null && r.call(t, n));
1021
+ i.classList.toggle(l("disabled"), o), i.classList.toggle(l("active"), !!((d = t.isActive) != null && d.call(t, n))), (h = t.update) == null || h.call(t, n, i);
1022
+ });
1023
+ }
1024
+ destroy() {
1025
+ this.ui.editor.eventBus.off("rangeStyleChange", this.rangeStyleChange), this.el.remove();
1026
+ }
1027
+ }
1028
+ let We = 0;
1029
+ class Ze {
1030
+ constructor(n, s = {}) {
1031
+ this.toolbar = null, this.statusbar = null, this.locale = { ...Y, ...s.locale };
1032
+ const e = `${l("root")}-${++We}`, t = c("div", { class: l("editor") });
1033
+ 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 q(t, s.data || { main: [] }, {
1034
+ scrollContainerSelector: `#${e} .${l("main")}`,
1035
+ ...s.options
1036
+ }), s.toolbar !== !1 && (this.toolbar = new Ke(this, s.toolbar || U), this.root.prepend(this.toolbar.el)), s.statusbar !== !1 && (this.statusbar = new ie(this, s.statusbar || P), this.root.append(this.statusbar.el)), this.mode = this.editor.command.getOptions().mode, this.renderChange = () => {
1037
+ this.editor.command.getOptions().mode !== this.mode && this.syncMode();
1038
+ }, this.editor.eventBus.on("renderChange", this.renderChange);
1039
+ }
1040
+ syncMode() {
1041
+ var n, s;
1042
+ this.mode = this.editor.command.getOptions().mode, (n = this.toolbar) == null || n.update(), (s = this.statusbar) == null || s.update();
1043
+ }
1044
+ // 当前总页数(编辑器仅在页数变化时通知,初始值从页面画布读取)
1045
+ getPageSize() {
1046
+ return this.main.querySelectorAll("canvas[data-index]").length || 1;
1047
+ }
1048
+ // 切换编辑模式并刷新工具栏可用状态
1049
+ setMode(n) {
1050
+ this.editor.command.executeMode(n), this.syncMode();
1051
+ }
1052
+ destroy() {
1053
+ var n, s;
1054
+ 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();
1055
+ }
1056
+ }
1057
+ function Qe(a, n) {
1058
+ const s = typeof a == "string" ? document.querySelector(a) : a;
1059
+ if (!s)
1060
+ throw new Error(`[canvas-editor-ui] container not found: ${a}`);
1061
+ return new Ze(s, n);
1062
+ }
1063
+ export {
1064
+ P as DEFAULT_STATUSBAR,
1065
+ U as DEFAULT_TOOLBAR,
1066
+ k as Dialog,
1067
+ Ze as EditorUI,
1068
+ $e as FONT_LIST,
1069
+ Ne as SIZE_LIST,
1070
+ Qe as createEditorUI,
1071
+ Y as defaultLocale
1072
+ };
1073
+ //# sourceMappingURL=canvas-editor-ui.esm.js.map