@baohu/canvas-editor-ui 1.0.0 → 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.
@@ -1,6 +1,6 @@
1
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
- (function(p,l){typeof exports=="object"&&typeof module!="undefined"?l(exports,require("@baohu/canvas-editor")):typeof define=="function"&&define.amd?define(["exports","@baohu/canvas-editor"],l):(p=typeof globalThis!="undefined"?globalThis:p||self,l(p.CanvasEditorUI={},p["canvas-editor"]))})(this,function(p,l){"use strict";const B=(a=>a&&a.__esModule?a:{default:a})(l),_={undo:"撤销",redo:"重做",painter:"格式刷(双击可连续使用)",format:"清除格式",font:"字体",size:"字号",sizeAdd:"增大字号",sizeMinus:"减小字号",bold:"加粗",italic:"斜体",underline:"下划线",strikeout:"删除线",superscript:"上标",subscript:"下标",color:"字体颜色",highlight:"高亮",title:"标题",text:"正文",left:"左对齐",center:"居中对齐",right:"右对齐",alignment:"两端对齐",justify:"分散对齐",rowMargin:"行间距",list:"列表",listDecimal:"有序列表",listCheckbox:"复选框列表",listDisc:"实心圆点列表",listCircle:"空心圆点列表",listSquare:"实心方块列表",table:"表格",image:"图片",hyperlink:"超链接",hyperlinkText:"文本",hyperlinkUrl:"链接",separator:"分割线",pageBreak:"分页符",control:"控件",controlType:"类型",controlText:"文本",controlSelect:"下拉框",controlCheckbox:"复选框",controlRadio:"单选框",controlDate:"日期",controlNumber:"数值",controlPlaceholder:"占位符",controlValueSets:"选项",controlValueSetsPlaceholder:`每行一个选项,如:
2
+ (function(p,c){typeof exports=="object"&&typeof module!="undefined"?c(exports,require("@baohu/canvas-editor")):typeof define=="function"&&define.amd?define(["exports","@baohu/canvas-editor"],c):(p=typeof globalThis!="undefined"?globalThis:p||self,c(p.CanvasEditorUI={},p["canvas-editor"]))})(this,function(p,c){"use strict";const B=(a=>a&&a.__esModule?a:{default:a})(c),_={undo:"撤销",redo:"重做",painter:"格式刷(双击可连续使用)",format:"清除格式",font:"字体",size:"字号",sizeAdd:"增大字号",sizeMinus:"减小字号",bold:"加粗",italic:"斜体",underline:"下划线",strikeout:"删除线",superscript:"上标",subscript:"下标",color:"字体颜色",highlight:"高亮",title:"标题",text:"正文",left:"左对齐",center:"居中对齐",right:"右对齐",alignment:"两端对齐",justify:"分散对齐",rowMargin:"行间距",list:"列表",listDecimal:"有序列表",listCheckbox:"复选框列表",listDisc:"实心圆点列表",listCircle:"空心圆点列表",listSquare:"实心方块列表",table:"表格",image:"图片",hyperlink:"超链接",hyperlinkText:"文本",hyperlinkUrl:"链接",separator:"分割线",pageBreak:"分页符",control:"控件",controlType:"类型",controlText:"文本",controlSelect:"下拉框",controlCheckbox:"复选框",controlRadio:"单选框",controlDate:"日期",controlNumber:"数值",controlPlaceholder:"占位符",controlValueSets:"选项",controlValueSetsPlaceholder:`每行一个选项,如:
3
3
  有
4
- 无`,controlDateFormat:"日期格式",checkbox:"复选框",date:"日期",search:"查找替换",searchKeyword:"查找",searchReplace:"替换为",searchReplacePlaceholder:"留空则只查找",print:"打印",pdf:"导出 PDF",confirm:"确定",cancel:"取消",pageNo:"页面",wordCount:"字数",rowCol:"行列",pageModePaging:"分页",pageModeContinuity:"连页",scaleMinus:"缩小",scaleAdd:"放大",scaleRecovery:"恢复 100%",paperDirection:"纸张方向",paperMargin:"页边距",marginTop:"上边距",marginRight:"右边距",marginBottom:"下边距",marginLeft:"左边距",modeEdit:"编辑模式",modeClean:"清洁模式",modeReadonly:"只读模式",modeForm:"表单模式",modePrint:"打印模式",modeDesign:"设计模式",fullscreen:"全屏"},$="ceu";function c(a,n={},...s){const e=document.createElement(a);return Object.keys(n).forEach(t=>{const o=n[t];o===void 0||o===!1||(t==="class"?e.className=String(o):e.setAttribute(t,o===!0?"":String(o)))}),s.forEach(t=>{t==null||t===!1||e.append(t)}),e}function r(a){return`${$}-${a}`}function F(a,n){let s=null;const e=(...t)=>{s&&clearTimeout(s),s=setTimeout(()=>{s=null,a(...t)},n)};return e.cancel=()=>{s&&clearTimeout(s),s=null},e}function P(a){return new Promise((n,s)=>{const e=new FileReader;e.onload=()=>n(e.result),e.onerror=s,e.readAsDataURL(a)})}function U(a){return new Promise((n,s)=>{const e=new Image;e.onload=()=>n(e),e.onerror=s,e.src=a})}function q(a,n){const s=URL.createObjectURL(a);c("a",{href:s,download:n}).click(),URL.revokeObjectURL(s)}function D(a,n){const s=t=>String(t).padStart(2,"0"),e=`${a.getFullYear()}-${s(a.getMonth()+1)}-${s(a.getDate())}`;return n?`${e} ${s(a.getHours())}:${s(a.getMinutes())}:${s(a.getSeconds())}`:e}class L{constructor(n){var s;this.inputList=[],this.options=n,this.mask=c("div",{class:r("dialog-mask")}),this.container=this.render(),this.mask.setAttribute(l.EDITOR_COMPONENT,l.EditorComponent.COMPONENT),this.container.setAttribute(l.EDITOR_COMPONENT,l.EditorComponent.COMPONENT),document.body.append(this.mask,this.container),this.keydownHandler=e=>{e.key==="Escape"&&this.close()},document.addEventListener("keydown",this.keydownHandler),(s=this.inputList[0])==null||s.focus()}render(){const{title:n,fields:s,confirmText:e="确定",cancelText:t="取消"}=this.options,o=c("i",{class:r("dialog__close")});o.onclick=()=>this.close();const i=c("div",{class:r("dialog__body")});s.forEach(v=>{const m=this.createInput(v);this.inputList.push(m);const z=v.label?c("span",{class:`${r("dialog__label")}${v.required?` ${r("dialog__label--required")}`:""}`},v.label):null;i.append(c("label",{class:r("dialog__field")},z,m))});const d=c("button",{type:"button"},t);d.onclick=()=>this.close();const h=c("button",{type:"button",class:r("dialog__confirm")},e);h.onclick=()=>this.confirm();const g=c("div",{class:r("dialog")},c("div",{class:r("dialog__title")},c("span",{},n),o),i,c("div",{class:r("dialog__footer")},d,h));return g.addEventListener("keydown",v=>{const m=v.target;v.key==="Enter"&&m.tagName==="INPUT"&&(v.preventDefault(),this.confirm())}),c("div",{class:r("dialog-container")},g)}createInput(n){var e;let s;return n.type==="select"?(s=c("select",{name:n.name}),(e=n.options)==null||e.forEach(t=>{s.append(c("option",{value:t.value},t.label))})):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}confirm(){const{fields:n,onConfirm:s}=this.options,e={};let t=!0;this.inputList.forEach((o,i)=>{e[o.name]=o.value;const d=n[i].required&&!o.value.trim();o.classList.toggle(r("dialog__input--error"),!!d),d&&(t=!1)}),t&&(s&&s(e)===!1||this.dispose())}close(){var n,s;(s=(n=this.options).onClose)==null||s.call(n),this.dispose()}dispose(){document.removeEventListener("keydown",this.keydownHandler),this.mask.remove(),this.container.remove()}}const f=new Set;function I(a){f.forEach(n=>{n.el.contains(a.target)||n.close()})}class H{constructor(n,s,e="bottom"){this.panel=c("div",{class:`${r("dropdown__panel")} ${r(`dropdown__panel--${e}`)}`},s),this.el=c("div",{class:r("dropdown")},n,this.panel),n.addEventListener("click",()=>this.toggle())}toggle(){f.has(this)?this.close():this.open()}open(){f.forEach(s=>s.close()),this.panel.classList.add(r("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",I),f.add(this)}close(){this.panel.classList.remove(r("dropdown__panel--visible")),f.delete(this),f.size||document.removeEventListener("mousedown",I)}}function w(a,n){const s=c("ul",{class:r("option-list")});return a.forEach(e=>{const t=c("li",{"data-value":e.value,style:e.style},e.icon?c("i",{class:r("icon"),style:`background-image:url("${e.icon}")`}):null,e.label);t.addEventListener("mousedown",o=>o.preventDefault()),t.addEventListener("click",()=>n(e.value)),s.append(t)}),s}function x(a,n){a.querySelectorAll("li").forEach(s=>{s.classList.toggle(r("active"),s.dataset.value===n)})}const X="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",j="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",Y="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",G="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",K="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",W="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",C="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",y=["pageNo","wordCount","rowCol","pageMode","scale","paperDirection","paperMargin","fullscreen"],Z=["pageNo","wordCount","rowCol"];function b(a,n,s){const e=c("div",{class:r("statusbar__button"),title:n},c("i",{class:r("icon"),style:`background-image:url("${a}")`}));return e.addEventListener("click",s),e}class J{constructor(n,s=y){this.disposeList=[],this.updaterList=[],this.on=(o,i)=>{const{eventBus:d}=this.ui.editor;d.on(o,i),this.disposeList.push(()=>d.off(o,i))},this.ui=n;const e=c("div",{class:r("statusbar__left")}),t=c("div",{class:r("statusbar__right")});this.el=c("div",{class:r("statusbar")},e,t),this.el.setAttribute(l.EDITOR_COMPONENT,l.EditorComponent.FOOTER),this.el.addEventListener("mousedown",o=>o.preventDefault()),s.forEach(o=>{const i=this.createItem(o);i&&(i.classList.add(r("statusbar__item")),(Z.includes(o)?e:t).append(i))})}createItem(n){const{editor:s,locale:e}=this.ui;switch(n){case"pageNo":{const t=c("span",{},"1"),o=c("span",{},String(this.ui.getPageSize()));return this.on("intersectionPageNoChange",i=>{t.innerText=String(i+1)}),this.on("pageSizeChange",i=>{o.innerText=String(i)}),c("span",{},`${e.pageNo}:`,t,"/",o)}case"wordCount":{const t=c("span",{},"0"),o=F(async()=>{t.innerText=String(await s.command.getWordCount())},300);return this.on("contentChange",o),this.disposeList.push(o.cancel),o(),c("span",{},`${e.wordCount}:`,t)}case"rowCol":{const t=c("span",{},"1:1");return this.on("rangeStyleChange",()=>{const o=s.command.getRangeContext();o&&(t.innerText=`${o.startRowNo+1}:${o.startColNo+1}`)}),c("span",{},`${e.rowCol}:`,t)}case"pageMode":{const t=b(j,"",()=>{}),o=w([{label:e.pageModePaging,value:l.PageMode.PAGING},{label:e.pageModeContinuity,value:l.PageMode.CONTINUITY}],h=>{i.close(),s.command.executePageMode(h)}),i=new H(t,o,"top"),d=h=>{x(o,h),t.title=h===l.PageMode.CONTINUITY?e.pageModeContinuity:e.pageModePaging};return d(s.command.getOptions().pageMode),this.on("pageModeChange",d),i.el}case"scale":{const t=c("span",{class:r("statusbar__scale"),title:e.scaleRecovery}),o=i=>{t.innerText=`${Math.round(i*100)}%`};return o(s.command.getOptions().scale),this.on("pageScaleChange",o),t.addEventListener("click",()=>s.command.executePageScaleRecovery()),c("div",{class:r("statusbar__group")},b(G,e.scaleMinus,()=>s.command.executePageScaleMinus()),t,b(Y,e.scaleAdd,()=>s.command.executePageScaleAdd()))}case"paperDirection":return b(K,e.paperDirection,()=>{const{paperDirection:t}=s.command.getOptions();s.command.executePaperDirection(t===l.PaperDirection.HORIZONTAL?l.PaperDirection.VERTICAL:l.PaperDirection.HORIZONTAL)});case"paperMargin":return b(W,e.paperMargin,()=>this.openPaperMarginDialog());case"mode":{const t=[{label:e.modeEdit,value:l.EditorMode.EDIT},{label:e.modeClean,value:l.EditorMode.CLEAN},{label:e.modeReadonly,value:l.EditorMode.READONLY},{label:e.modeForm,value:l.EditorMode.FORM},{label:e.modePrint,value:l.EditorMode.PRINT},{label:e.modeDesign,value:l.EditorMode.DESIGN}],o=c("span",{class:r("statusbar__mode")}),i=w(t,g=>{d.close(),this.ui.setMode(g)}),d=new H(o,i,"top"),h=()=>{var v;const g=s.command.getOptions().mode;o.innerText=((v=t.find(m=>m.value===g))==null?void 0:v.label)||g,x(i,g)};return h(),this.updaterList.push(h),d.el}case"fullscreen":{const t=b(C,e.fullscreen,()=>{document.fullscreenElement?document.exitFullscreen():this.ui.root.requestFullscreen()}),o=()=>{const i=document.fullscreenElement?X:C;t.querySelector("i").style.backgroundImage=`url("${i}")`};return document.addEventListener("fullscreenchange",o),this.disposeList.push(()=>document.removeEventListener("fullscreenchange",o)),t}default:return console.warn(`[canvas-editor-ui] unknown statusbar item: ${n}`),null}}openPaperMarginDialog(){const{editor:n,locale:s}=this.ui,e=["top","right","bottom","left"],t=[s.marginTop,s.marginRight,s.marginBottom,s.marginLeft],o=n.command.getPaperMargin();new L({title:s.paperMargin,confirmText:s.confirm,cancelText:s.cancel,fields:e.map((i,d)=>({type:"number",name:i,label:t[d],required:!0,value:String(o[d])})),onConfirm:i=>{const[d,h,g,v]=e.map(z=>Number(i[z])),m=[d,h,g,v];if(m.some(z=>isNaN(z)||z<0))return!1;n.command.executeSetPaperMargin(m)}})}update(){this.updaterList.forEach(n=>n())}destroy(){this.disposeList.forEach(n=>n()),this.el.remove()}}const Q="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",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='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",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='M2%2013h12v1H2v-1zm2-3h8v1H4v-1zM2%207h12v1H2V7zm0-6h12v1H2V1zm2%203h8v1H4V4z'%20fill='%233D4757'%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_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",se="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",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%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",oe="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",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='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",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='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",ce="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",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_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",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='M10.017%203L8.08%2013H9v1H6v-1h1.182L9%203H8V2h3v1h-.983z'%20fill='%233D4757'/%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%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",ge="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",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='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",ue="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",S="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",pe="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",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='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",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='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",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='M2%2013h12v1H2v-1zm4-3h8v1H6v-1zM2%207h12v1H2V7zm0-6h12v1H2V1zm4%203h8v1H6V4z'%20fill='%233D4757'%20fill-rule='evenodd'/%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%20d='M2%2014h12v1H2v-1zm7-5h5v1H9V9zm0-3h5v1H9V6zM2%201h12v1H2V1zm2.5%203L7%207H2zm0%208L7%209H2z'%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%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",Me="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",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='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",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%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",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.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",ye="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",Te="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",_e="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",De="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",Ie="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",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='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",k=["Microsoft YaHei","宋体","黑体","仿宋","楷体","华文宋体","华文黑体","华文仿宋","华文楷体","华文隶书","华文行楷","Arial","Segoe UI","Times New Roman"].map(a=>({label:a==="Microsoft YaHei"?"微软雅黑":a,value:a,style:`font-family:'${a}'`})),R=[["初号",56],["小初",48],["一号",34],["小一",32],["二号",29],["小二",24],["三号",21],["小三",20],["四号",18],["小四",16],["五号",14],["小五",12],["六号",10],["小六",8],["七号",7],["八号",6]].map(([a,n])=>({label:String(a),value:String(n)})),Se=["1","1.25","1.5","1.75","2","2.5","3"],E=[{label:"———— 实线",dashArray:[]},{label:"··········· 点线",dashArray:[1,1]},{label:"- - - - - 短虚线",dashArray:[3,1]},{label:"— — — 长虚线",dashArray:[4,4]},{label:"—·—·— 点划线",dashArray:[7,3,3,3]},{label:"—··—·· 双点划线",dashArray:[6,2,2,2,2,2]}];function u(a,n,s,e,t={}){return{key:a,title:n,icon:s,onClick:e,...t}}function V(a,n,s,e,t,o){return{key:a,title:n,render:i=>{const d=c("span",{class:r("select__label")}),h=c("div",{class:r("select"),title:n,style:`width:${e}px`},d),g=w(s,m=>{v.close(),t(i,m)}),v=new H(h,g);return v.el},update:(i,d)=>{const h=o(i),g=s.find(v=>v.value===h);d.querySelector(`.${r("select__label")}`).innerText=g?g.label:h||"",x(d,h)}}}function M(a,n,s,e,t={}){return{key:a,title:n,render:o=>{const i=c("div",{class:`${r("toolbar__button")} ${r("toolbar__button--arrow")}`,title:n},c("i",{class:r("icon"),style:`background-image:url("${s}")`})),d=c("div"),h=new H(i,d);return i.addEventListener("click",()=>{d.innerHTML="",d.append(e(o,()=>h.close()))},!0),h.el},...t}}function A(a,n,s,e,t){return{key:a,title:n,render:o=>{const i=c("input",{type:"color",class:r("color__input")});i.addEventListener("input",()=>e(o,i.value));const d=c("span",{class:r("color__bar")}),h=c("div",{class:`${r("toolbar__button")} ${r("color")}`,title:n},c("i",{class:r("icon"),style:`background-image:url("${s}")`}),d,i);return h.addEventListener("click",()=>i.click()),h},update:(o,i)=>{const d=t(o);i.querySelector(`.${r("color__bar")}`).style.background=d||"transparent"}}}function ke(a){const n=c("input",{type:"file",accept:"image/*"});n.addEventListener("change",async()=>{var o;const s=(o=n.files)==null?void 0:o[0];if(!s)return;const e=await P(s),t=await U(e);a.editor.command.executeImage({value:e,width:t.width,height:t.height})}),n.click()}function Re({editor:a,locale:n}){new L({title:n.hyperlink,confirmText:n.confirm,cancelText:n.cancel,fields:[{type:"text",name:"text",label:n.hyperlinkText,required:!0,value:a.command.getRangeText()},{type:"text",name:"url",label:n.hyperlinkUrl,required:!0,placeholder:"https://"}],onConfirm:({text:s,url:e})=>{a.command.executeHyperlink({url:e,valueList:l.splitText(s).map(t=>({value:t}))})}})}const O=[l.ControlType.SELECT,l.ControlType.CHECKBOX,l.ControlType.RADIO];function Ee({editor:a,locale:n}){new L({title:n.control,confirmText:n.confirm,cancelText:n.cancel,fields:[{type:"select",name:"type",label:n.controlType,options:[{label:n.controlText,value:l.ControlType.TEXT},{label:n.controlSelect,value:l.ControlType.SELECT},{label:n.controlCheckbox,value:l.ControlType.CHECKBOX},{label:n.controlRadio,value:l.ControlType.RADIO},{label:n.controlDate,value:l.ControlType.DATE},{label:n.controlNumber,value:l.ControlType.NUMBER}]},{type:"text",name:"placeholder",label:n.controlPlaceholder},{type:"textarea",name:"valueSets",label:n.controlValueSets,placeholder:n.controlValueSetsPlaceholder,height:80},{type:"select",name:"dateFormat",label:n.controlDateFormat,options:[{label:"yyyy-MM-dd",value:"yyyy-MM-dd"},{label:"yyyy-MM-dd HH:mm:ss",value:"yyyy-MM-dd HH:mm:ss"}]}],onConfirm:s=>{const e=s.type,t=s.valueSets.split(`
5
- `).map(i=>i.trim()).filter(Boolean).map(i=>({value:i,code:i}));if(O.includes(e)&&!t.length)return!1;const o={type:e,value:null,placeholder:s.placeholder||void 0};O.includes(e)&&(o.code=null,o.valueSets=t),e===l.ControlType.DATE&&(o.dateFormat=s.dateFormat),a.command.executeInsertControl({type:l.ElementType.CONTROL,value:"",control:o})}})}function Ve({editor:a,locale:n}){new L({title:n.search,confirmText:n.confirm,cancelText:n.cancel,fields:[{type:"text",name:"keyword",label:n.searchKeyword,required:!0,value:a.command.getRangeText()},{type:"text",name:"replace",label:n.searchReplace,placeholder:n.searchReplacePlaceholder}],onConfirm:({keyword:s,replace:e})=>{a.command.executeSearch(s),e&&a.command.executeReplace(e)},onClose:()=>a.command.executeSearch(null)})}function Ae(a,n){const e=c("div",{class:r("table-picker__title")},a.locale.table),t=c("div",{class:r("table-picker__grid")}),o=[];for(let i=1;i<=10;i++)for(let d=1;d<=10;d++){const h=c("span",{"data-row":i,"data-col":d});o.push(h),t.append(h)}return t.addEventListener("mouseover",i=>{const d=i.target,h=Number(d.dataset.row),g=Number(d.dataset.col);!h||!g||(e.innerText=`${h} × ${g}`,o.forEach(v=>{v.classList.toggle(r("active"),Number(v.dataset.row)<=h&&Number(v.dataset.col)<=g)}))}),t.addEventListener("mousedown",i=>i.preventDefault()),t.addEventListener("click",i=>{const d=i.target,h=Number(d.dataset.row),g=Number(d.dataset.col);!h||!g||(n(),a.editor.command.executeInsertTable(h,g))}),c("div",{class:r("table-picker")},e,t)}const Oe=[["left",l.RowFlex.LEFT,ge],["center",l.RowFlex.CENTER,te],["right",l.RowFlex.RIGHT,fe],["alignment",l.RowFlex.ALIGNMENT,Q],["justify",l.RowFlex.JUSTIFY,he]];function Ne(a){const n=[u("undo",a.undo,Ce,({editor:e})=>e.command.executeUndo(),{isDisabled:({style:e})=>!!e&&!e.undo}),u("redo",a.redo,we,({editor:e})=>e.command.executeRedo(),{isDisabled:({style:e})=>!!e&&!e.redo}),{key:"painter",title:a.painter,icon:S,isActive:({style:e})=>!!(e!=null&&e.painter),render:({editor:e})=>{const t=c("div",{class:r("toolbar__button"),title:a.painter},c("i",{class:r("icon"),style:`background-image:url("${S}")`}));let o=null;return t.addEventListener("click",()=>{o&&clearTimeout(o),o=setTimeout(()=>{o=null,e.command.executePainter({isDblclick:!1})},200)}),t.addEventListener("dblclick",()=>{o&&clearTimeout(o),o=null,e.command.executePainter({isDblclick:!0})}),t}},u("format",a.format,ie,({editor:e})=>e.command.executeFormat()),V("font",a.font,k,90,({editor:e},t)=>e.command.executeFont(t),({editor:e,style:t})=>(t==null?void 0:t.font)||e.command.getOptions().defaultFont),V("size",a.size,R,54,({editor:e},t)=>e.command.executeSize(Number(t)),({editor:e,style:t})=>String(t?t.size:e.command.getOptions().defaultSize)),u("sizeAdd",a.sizeAdd,ze,({editor:e})=>e.command.executeSizeAdd()),u("sizeMinus",a.sizeMinus,Le,({editor:e})=>e.command.executeSizeMinus()),u("bold",a.bold,ee,({editor:e})=>e.command.executeBold(),{isActive:({style:e})=>!!(e!=null&&e.bold)}),u("italic",a.italic,de,({editor:e})=>e.command.executeItalic(),{isActive:({style:e})=>!!(e!=null&&e.italic)}),u("underline",a.underline,Ie,({editor:e})=>e.command.executeUnderline(),{isActive:({style:e})=>!!(e!=null&&e.underline)}),u("strikeout",a.strikeout,He,({editor:e})=>e.command.executeStrikeout(),{isActive:({style:e})=>!!(e!=null&&e.strikeout)}),u("superscript",a.superscript,Te,({editor:e})=>e.command.executeSuperscript(),{isActive:({style:e})=>(e==null?void 0:e.type)===l.ElementType.SUPERSCRIPT}),u("subscript",a.subscript,ye,({editor:e})=>e.command.executeSubscript(),{isActive:({style:e})=>(e==null?void 0:e.type)===l.ElementType.SUBSCRIPT}),A("color",a.color,se,({editor:e},t)=>e.command.executeColor(t),({style:e})=>(e==null?void 0:e.color)||"#000000"),A("highlight",a.highlight,le,({editor:e},t)=>e.command.executeHighlight(t),({style:e})=>(e==null?void 0:e.highlight)||null),M("title",a.title,De,({editor:e,style:t},o)=>{const i=[l.TitleLevel.FIRST,l.TitleLevel.SECOND,l.TitleLevel.THIRD,l.TitleLevel.FOURTH,l.TitleLevel.FIFTH,l.TitleLevel.SIXTH],d=[{label:a.text,value:""},...i.map((g,v)=>({label:`${a.title}${v+1}`,value:g,style:`font-size:${26-v*2}px;font-weight:bold`}))],h=w(d,g=>{o(),e.command.executeTitle(g||null)});return x(h,(t==null?void 0:t.level)||""),h}),...Oe.map(([e,t,o])=>u(e,a[e],o,({editor:i})=>i.command.executeRowFlex(t),{isActive:({style:i})=>((i==null?void 0:i.rowFlex)||l.RowFlex.LEFT)===t})),M("rowMargin",a.rowMargin,xe,({editor:e,style:t},o)=>{const i=w(Se.map(d=>({label:d,value:d})),d=>{o(),e.command.executeRowMargin(Number(d))});return x(i,t?String(t.rowMargin):null),i}),M("list",a.list,ve,({editor:e,style:t},o)=>{const i=[{label:a.listDecimal,value:`${l.ListType.OL}|${l.ListStyle.DECIMAL}`},{label:a.listCheckbox,value:`${l.ListType.UL}|${l.ListStyle.CHECKBOX}`},{label:a.listDisc,value:`${l.ListType.UL}|${l.ListStyle.DISC}`},{label:a.listCircle,value:`${l.ListType.UL}|${l.ListStyle.CIRCLE}`},{label:a.listSquare,value:`${l.ListType.UL}|${l.ListStyle.SQUARE}`}],d=w(i,h=>{o();const[g,v]=h.split("|");e.command.executeList(g,v)});return x(d,t!=null&&t.listType?`${t.listType}|${t.listStyle}`:null),d},{isActive:({style:e})=>!!(e!=null&&e.listType)}),M("table",a.table,_e,Ae),u("image",a.image,re,ke),u("hyperlink",a.hyperlink,ce,Re),M("separator",a.separator,Me,({editor:e},t)=>w(E.map((o,i)=>({label:o.label,value:String(i)})),o=>{t(),e.command.executeSeparator(E[Number(o)].dashArray)})),u("pageBreak",a.pageBreak,ue,({editor:e})=>e.command.executePageBreak()),u("control",a.control,ae,Ee),u("checkbox",a.checkbox,ne,({editor:e})=>e.command.executeInsertElementList([{type:l.ElementType.CHECKBOX,value:"",checkbox:{value:!1}}])),M("date",a.date,oe,({editor:e},t)=>{const o=new Date,i=[{format:"yyyy-MM-dd",text:D(o,!1)},{format:"yyyy-MM-dd HH:mm:ss",text:D(o,!0)}];return w(i.map((d,h)=>({label:d.text,value:String(h)})),d=>{t();const{format:h,text:g}=i[Number(d)];e.command.executeInsertElementList([{type:l.ElementType.DATE,value:"",dateFormat:h,valueList:[{value:g}]}])})}),u("search",a.search,be,Ve,{keepEnabledInReadonly:!0}),u("print",a.print,me,({editor:e})=>e.command.executePrint(),{keepEnabledInReadonly:!0}),u("pdf",a.pdf,pe,async({editor:e})=>{const t=await e.command.getPdf();q(t,`document-${Date.now()}.pdf`)},{keepEnabledInReadonly:!0})],s={};return n.forEach(e=>{s[e.key]=e}),s}const T=["undo","redo","painter","format","|","font","size","sizeAdd","sizeMinus","bold","italic","underline","strikeout","superscript","subscript","color","highlight","|","title","left","center","right","alignment","justify","rowMargin","list","|","table","image","hyperlink","separator","pageBreak","checkbox","date","|","search"],Be=[l.EditorMode.READONLY,l.EditorMode.PRINT];class $e{constructor(n,s=T){this.style=null,this.renderedList=[],this.ui=n,this.el=c("div",{class:r("toolbar")}),this.el.setAttribute(l.EDITOR_COMPONENT,l.EditorComponent.MENU),this.el.addEventListener("mousedown",e=>{const t=e.target.tagName;t!=="INPUT"&&t!=="SELECT"&&t!=="TEXTAREA"&&e.preventDefault()}),this.render(s),this.rangeStyleChange=e=>{this.style=e,this.update()},n.editor.eventBus.on("rangeStyleChange",this.rangeStyleChange),this.update()}getContext(){return{editor:this.ui.editor,ui:this.ui,locale:this.ui.locale,style:this.style}}render(n){const s=Ne(this.ui.locale),e=this.getContext();n.forEach(t=>{if(t==="|"){this.el.append(c("span",{class:r("toolbar__divider")}));return}const o=typeof t=="string"?s[t]:t;if(!o){console.warn(`[canvas-editor-ui] unknown toolbar item: ${t}`);return}const i=o.render?o.render(e):this.renderButton(o);i.classList.add(r("toolbar__item")),i.dataset.key=o.key,this.el.append(i),this.renderedList.push({item:o,el:i})})}renderButton(n){const s=c("div",{class:r("toolbar__button"),title:n.title},n.icon?c("i",{class:r("icon"),style:`background-image:url("${n.icon}")`}):null,n.text?c("span",{class:r("toolbar__text")},n.text):null);return s.addEventListener("click",()=>{var e;s.classList.contains(r("disabled"))||(e=n.onClick)==null||e.call(n,this.getContext(),s)}),s}update(){const n=this.getContext(),s=this.ui.editor.command.getOptions().mode,e=Be.includes(s);this.renderedList.forEach(({item:t,el:o})=>{var d,h,g;const i=e&&!t.keepEnabledInReadonly||!!((d=t.isDisabled)!=null&&d.call(t,n));o.classList.toggle(r("disabled"),i),o.classList.toggle(r("active"),!!((h=t.isActive)!=null&&h.call(t,n))),(g=t.update)==null||g.call(t,n,o)})}destroy(){this.ui.editor.eventBus.off("rangeStyleChange",this.rangeStyleChange),this.el.remove()}}let Fe=0;class N{constructor(n,s={}){this.toolbar=null,this.statusbar=null,this.locale={..._,...s.locale};const e=`${r("root")}-${++Fe}`,t=c("div",{class:r("editor")});this.main=c("div",{class:r("main")},t),this.root=c("div",{class:r("root"),id:e},this.main),n.append(this.root),this.editor=new B.default(t,s.data||{main:[]},{scrollContainerSelector:`#${e} .${r("main")}`,...s.options}),s.toolbar!==!1&&(this.toolbar=new $e(this,s.toolbar||T),this.root.prepend(this.toolbar.el)),s.statusbar!==!1&&(this.statusbar=new J(this,s.statusbar||y),this.root.append(this.statusbar.el)),this.mode=this.editor.command.getOptions().mode,this.renderChange=()=>{this.editor.command.getOptions().mode!==this.mode&&this.syncMode()},this.editor.eventBus.on("renderChange",this.renderChange)}syncMode(){var n,s;this.mode=this.editor.command.getOptions().mode,(n=this.toolbar)==null||n.update(),(s=this.statusbar)==null||s.update()}getPageSize(){return this.main.querySelectorAll("canvas[data-index]").length||1}setMode(n){this.editor.command.executeMode(n),this.syncMode()}destroy(){var n,s;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()}}function Pe(a,n){const s=typeof a=="string"?document.querySelector(a):a;if(!s)throw new Error(`[canvas-editor-ui] container not found: ${a}`);return new N(s,n)}p.DEFAULT_STATUSBAR=y,p.DEFAULT_TOOLBAR=T,p.Dialog=L,p.EditorUI=N,p.FONT_LIST=k,p.SIZE_LIST=R,p.createEditorUI=Pe,p.defaultLocale=_,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
4
+ 无`,controlDateFormat:"日期格式",checkbox:"复选框",checkboxCross:"叉选",checkboxCheck:"勾选",date:"日期",search:"查找替换",searchKeyword:"查找",searchReplace:"替换为",searchReplacePlaceholder:"留空则只查找",print:"打印",pdf:"导出 PDF",confirm:"确定",cancel:"取消",pageNo:"页面",wordCount:"字数",rowCol:"行列",pageModePaging:"分页",pageModeContinuity:"连页",scaleMinus:"缩小",scaleAdd:"放大",scaleRecovery:"恢复 100%",paperDirection:"纸张方向",paperMargin:"页边距",marginTop:"上边距",marginRight:"右边距",marginBottom:"下边距",marginLeft:"左边距",modeEdit:"编辑模式",modeClean:"清洁模式",modeReadonly:"只读模式",modeForm:"表单模式",modePrint:"打印模式",modeDesign:"设计模式",fullscreen:"全屏"},$="ceu";function l(a,n={},...s){const e=document.createElement(a);return Object.keys(n).forEach(t=>{const o=n[t];o===void 0||o===!1||(t==="class"?e.className=String(o):e.setAttribute(t,o===!0?"":String(o)))}),s.forEach(t=>{t==null||t===!1||e.append(t)}),e}function r(a){return`${$}-${a}`}function F(a,n){let s=null;const e=(...t)=>{s&&clearTimeout(s),s=setTimeout(()=>{s=null,a(...t)},n)};return e.cancel=()=>{s&&clearTimeout(s),s=null},e}function P(a){return new Promise((n,s)=>{const e=new FileReader;e.onload=()=>n(e.result),e.onerror=s,e.readAsDataURL(a)})}function U(a){return new Promise((n,s)=>{const e=new Image;e.onload=()=>n(e),e.onerror=s,e.src=a})}function q(a,n){const s=URL.createObjectURL(a);l("a",{href:s,download:n}).click(),URL.revokeObjectURL(s)}function C(a,n){const s=t=>String(t).padStart(2,"0"),e=`${a.getFullYear()}-${s(a.getMonth()+1)}-${s(a.getDate())}`;return n?`${e} ${s(a.getHours())}:${s(a.getMinutes())}:${s(a.getSeconds())}`:e}class L{constructor(n){var s;this.inputList=[],this.options=n,this.mask=l("div",{class:r("dialog-mask")}),this.container=this.render(),this.mask.setAttribute(c.EDITOR_COMPONENT,c.EditorComponent.COMPONENT),this.container.setAttribute(c.EDITOR_COMPONENT,c.EditorComponent.COMPONENT),document.body.append(this.mask,this.container),this.keydownHandler=e=>{e.key==="Escape"&&this.close()},document.addEventListener("keydown",this.keydownHandler),(s=this.inputList[0])==null||s.focus()}render(){const{title:n,fields:s,confirmText:e="确定",cancelText:t="取消"}=this.options,o=l("i",{class:r("dialog__close")});o.onclick=()=>this.close();const i=l("div",{class:r("dialog__body")});s.forEach(u=>{const m=this.createInput(u);this.inputList.push(m);const z=u.label?l("span",{class:`${r("dialog__label")}${u.required?` ${r("dialog__label--required")}`:""}`},u.label):null;i.append(l("label",{class:r("dialog__field")},z,m))});const d=l("button",{type:"button"},t);d.onclick=()=>this.close();const h=l("button",{type:"button",class:r("dialog__confirm")},e);h.onclick=()=>this.confirm();const g=l("div",{class:r("dialog")},l("div",{class:r("dialog__title")},l("span",{},n),o),i,l("div",{class:r("dialog__footer")},d,h));return g.addEventListener("keydown",u=>{const m=u.target;u.key==="Enter"&&m.tagName==="INPUT"&&(u.preventDefault(),this.confirm())}),l("div",{class:r("dialog-container")},g)}createInput(n){var e;let s;return n.type==="select"?(s=l("select",{name:n.name}),(e=n.options)==null||e.forEach(t=>{s.append(l("option",{value:t.value},t.label))})):n.type==="textarea"?(s=l("textarea",{name:n.name}),n.height&&(s.style.height=`${n.height}px`)):s=l("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}confirm(){const{fields:n,onConfirm:s}=this.options,e={};let t=!0;this.inputList.forEach((o,i)=>{e[o.name]=o.value;const d=n[i].required&&!o.value.trim();o.classList.toggle(r("dialog__input--error"),!!d),d&&(t=!1)}),t&&(s&&s(e)===!1||this.dispose())}close(){var n,s;(s=(n=this.options).onClose)==null||s.call(n),this.dispose()}dispose(){document.removeEventListener("keydown",this.keydownHandler),this.mask.remove(),this.container.remove()}}const f=new Set;function D(a){f.forEach(n=>{n.el.contains(a.target)||n.close()})}class H{constructor(n,s,e="bottom"){this.panel=l("div",{class:`${r("dropdown__panel")} ${r(`dropdown__panel--${e}`)}`},s),this.el=l("div",{class:r("dropdown")},n,this.panel),n.addEventListener("click",()=>this.toggle())}toggle(){f.has(this)?this.close():this.open()}open(){f.forEach(s=>s.close()),this.panel.classList.add(r("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",D),f.add(this)}close(){this.panel.classList.remove(r("dropdown__panel--visible")),f.delete(this),f.size||document.removeEventListener("mousedown",D)}}function w(a,n){const s=l("ul",{class:r("option-list")});return a.forEach(e=>{const t=l("li",{"data-value":e.value,style:e.style},e.icon?l("i",{class:r("icon"),style:`background-image:url("${e.icon}")`}):null,e.label);t.addEventListener("mousedown",o=>o.preventDefault()),t.addEventListener("click",()=>n(e.value)),s.append(t)}),s}function x(a,n){a.querySelectorAll("li").forEach(s=>{s.classList.toggle(r("active"),s.dataset.value===n)})}const X="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",j="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",Y="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",K="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",G="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",W="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",k="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",y=["pageNo","wordCount","rowCol","pageMode","scale","paperDirection","paperMargin","fullscreen"],Z=["pageNo","wordCount","rowCol"];function M(a,n,s){const e=l("div",{class:r("statusbar__button"),title:n},l("i",{class:r("icon"),style:`background-image:url("${a}")`}));return e.addEventListener("click",s),e}class J{constructor(n,s=y){this.disposeList=[],this.updaterList=[],this.on=(o,i)=>{const{eventBus:d}=this.ui.editor;d.on(o,i),this.disposeList.push(()=>d.off(o,i))},this.ui=n;const e=l("div",{class:r("statusbar__left")}),t=l("div",{class:r("statusbar__right")});this.el=l("div",{class:r("statusbar")},e,t),this.el.setAttribute(c.EDITOR_COMPONENT,c.EditorComponent.FOOTER),this.el.addEventListener("mousedown",o=>o.preventDefault()),s.forEach(o=>{const i=this.createItem(o);i&&(i.classList.add(r("statusbar__item")),(Z.includes(o)?e:t).append(i))})}createItem(n){const{editor:s,locale:e}=this.ui;switch(n){case"pageNo":{const t=l("span",{},"1"),o=l("span",{},String(this.ui.getPageSize()));return this.on("intersectionPageNoChange",i=>{t.innerText=String(i+1)}),this.on("pageSizeChange",i=>{o.innerText=String(i)}),l("span",{},`${e.pageNo}:`,t,"/",o)}case"wordCount":{const t=l("span",{},"0"),o=F(async()=>{t.innerText=String(await s.command.getWordCount())},300);return this.on("contentChange",o),this.disposeList.push(o.cancel),o(),l("span",{},`${e.wordCount}:`,t)}case"rowCol":{const t=l("span",{},"1:1");return this.on("rangeStyleChange",()=>{const o=s.command.getRangeContext();o&&(t.innerText=`${o.startRowNo+1}:${o.startColNo+1}`)}),l("span",{},`${e.rowCol}:`,t)}case"pageMode":{const t=M(j,"",()=>{}),o=w([{label:e.pageModePaging,value:c.PageMode.PAGING},{label:e.pageModeContinuity,value:c.PageMode.CONTINUITY}],h=>{i.close(),s.command.executePageMode(h)}),i=new H(t,o,"top"),d=h=>{x(o,h),t.title=h===c.PageMode.CONTINUITY?e.pageModeContinuity:e.pageModePaging};return d(s.command.getOptions().pageMode),this.on("pageModeChange",d),i.el}case"scale":{const t=l("span",{class:r("statusbar__scale"),title:e.scaleRecovery}),o=i=>{t.innerText=`${Math.round(i*100)}%`};return o(s.command.getOptions().scale),this.on("pageScaleChange",o),t.addEventListener("click",()=>s.command.executePageScaleRecovery()),l("div",{class:r("statusbar__group")},M(K,e.scaleMinus,()=>s.command.executePageScaleMinus()),t,M(Y,e.scaleAdd,()=>s.command.executePageScaleAdd()))}case"paperDirection":return M(G,e.paperDirection,()=>{const{paperDirection:t}=s.command.getOptions();s.command.executePaperDirection(t===c.PaperDirection.HORIZONTAL?c.PaperDirection.VERTICAL:c.PaperDirection.HORIZONTAL)});case"paperMargin":return M(W,e.paperMargin,()=>this.openPaperMarginDialog());case"mode":{const t=[{label:e.modeEdit,value:c.EditorMode.EDIT},{label:e.modeClean,value:c.EditorMode.CLEAN},{label:e.modeReadonly,value:c.EditorMode.READONLY},{label:e.modeForm,value:c.EditorMode.FORM},{label:e.modePrint,value:c.EditorMode.PRINT},{label:e.modeDesign,value:c.EditorMode.DESIGN}],o=l("span",{class:r("statusbar__mode")}),i=w(t,g=>{d.close(),this.ui.setMode(g)}),d=new H(o,i,"top"),h=()=>{var u;const g=s.command.getOptions().mode;o.innerText=((u=t.find(m=>m.value===g))==null?void 0:u.label)||g,x(i,g)};return h(),this.updaterList.push(h),d.el}case"fullscreen":{const t=M(k,e.fullscreen,()=>{document.fullscreenElement?document.exitFullscreen():this.ui.root.requestFullscreen()}),o=()=>{const i=document.fullscreenElement?X:k;t.querySelector("i").style.backgroundImage=`url("${i}")`};return document.addEventListener("fullscreenchange",o),this.disposeList.push(()=>document.removeEventListener("fullscreenchange",o)),t}default:return console.warn(`[canvas-editor-ui] unknown statusbar item: ${n}`),null}}openPaperMarginDialog(){const{editor:n,locale:s}=this.ui,e=["top","right","bottom","left"],t=[s.marginTop,s.marginRight,s.marginBottom,s.marginLeft],o=n.command.getPaperMargin();new L({title:s.paperMargin,confirmText:s.confirm,cancelText:s.cancel,fields:e.map((i,d)=>({type:"number",name:i,label:t[d],required:!0,value:String(o[d])})),onConfirm:i=>{const[d,h,g,u]=e.map(z=>Number(i[z])),m=[d,h,g,u];if(m.some(z=>isNaN(z)||z<0))return!1;n.command.executeSetPaperMargin(m)}})}update(){this.updaterList.forEach(n=>n())}destroy(){this.disposeList.forEach(n=>n()),this.el.remove()}}const Q="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",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='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",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='M2%2013h12v1H2v-1zm2-3h8v1H4v-1zM2%207h12v1H2V7zm0-6h12v1H2V1zm2%203h8v1H4V4z'%20fill='%233D4757'%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_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",se="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",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%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",oe="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",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='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",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%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",le="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",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_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",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='M10.017%203L8.08%2013H9v1H6v-1h1.182L9%203H8V2h3v1h-.983z'%20fill='%233D4757'/%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%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",ge="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",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='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",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: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",S="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",pe="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",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='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",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='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",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='M2%2013h12v1H2v-1zm4-3h8v1H6v-1zM2%207h12v1H2V7zm0-6h12v1H2V1zm4%203h8v1H6V4z'%20fill='%233D4757'%20fill-rule='evenodd'/%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%20d='M2%2014h12v1H2v-1zm7-5h5v1H9V9zm0-3h5v1H9V6zM2%201h12v1H2V1zm2.5%203L7%207H2zm0%208L7%209H2z'%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%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",Me="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",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='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",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%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",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.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",ye="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",Te="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",_e="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",Ce="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",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='M5%202v6a3%203%200%20106%200V2h1v6a4%204%200%2011-8%200V2h1zM4%2013h8v1H4z'%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%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",I=["Microsoft YaHei","宋体","黑体","仿宋","楷体","华文宋体","华文黑体","华文仿宋","华文楷体","华文隶书","华文行楷","Arial","Segoe UI","Times New Roman"].map(a=>({label:a==="Microsoft YaHei"?"微软雅黑":a,value:a,style:`font-family:'${a}'`})),R=[["初号",56],["小初",48],["一号",34],["小一",32],["二号",29],["小二",24],["三号",21],["小三",20],["四号",18],["小四",16],["五号",14],["小五",12],["六号",10],["小六",8],["七号",7],["八号",6]].map(([a,n])=>({label:String(a),value:String(n)})),Se=["1","1.25","1.5","1.75","2","2.5","3"],V=[{label:"———— 实线",dashArray:[]},{label:"··········· 点线",dashArray:[1,1]},{label:"- - - - - 短虚线",dashArray:[3,1]},{label:"— — — 长虚线",dashArray:[4,4]},{label:"—·—·— 点划线",dashArray:[7,3,3,3]},{label:"—··—·· 双点划线",dashArray:[6,2,2,2,2,2]}];function v(a,n,s,e,t={}){return{key:a,title:n,icon:s,onClick:e,...t}}function A(a,n,s,e,t,o){return{key:a,title:n,render:i=>{const d=l("span",{class:r("select__label")}),h=l("div",{class:r("select"),title:n,style:`width:${e}px`},d),g=w(s,m=>{u.close(),t(i,m)}),u=new H(h,g);return u.el},update:(i,d)=>{const h=o(i),g=s.find(u=>u.value===h);d.querySelector(`.${r("select__label")}`).innerText=g?g.label:h||"",x(d,h)}}}function b(a,n,s,e,t={}){return{key:a,title:n,render:o=>{const i=l("div",{class:`${r("toolbar__button")} ${r("toolbar__button--arrow")}`,title:n},l("i",{class:r("icon"),style:`background-image:url("${s}")`})),d=l("div"),h=new H(i,d);return i.addEventListener("click",()=>{d.innerHTML="",d.append(e(o,()=>h.close()))},!0),h.el},...t}}function E(a,n,s,e,t){return{key:a,title:n,render:o=>{const i=l("input",{type:"color",class:r("color__input")});i.addEventListener("input",()=>e(o,i.value));const d=l("span",{class:r("color__bar")}),h=l("div",{class:`${r("toolbar__button")} ${r("color")}`,title:n},l("i",{class:r("icon"),style:`background-image:url("${s}")`}),d,i);return h.addEventListener("click",()=>i.click()),h},update:(o,i)=>{const d=t(o);i.querySelector(`.${r("color__bar")}`).style.background=d||"transparent"}}}function Ie(a){const n=l("input",{type:"file",accept:"image/*"});n.addEventListener("change",async()=>{var o;const s=(o=n.files)==null?void 0:o[0];if(!s)return;const e=await P(s),t=await U(e);a.editor.command.executeImage({value:e,width:t.width,height:t.height})}),n.click()}function Re({editor:a,locale:n}){new L({title:n.hyperlink,confirmText:n.confirm,cancelText:n.cancel,fields:[{type:"text",name:"text",label:n.hyperlinkText,required:!0,value:a.command.getRangeText()},{type:"text",name:"url",label:n.hyperlinkUrl,required:!0,placeholder:"https://"}],onConfirm:({text:s,url:e})=>{a.command.executeHyperlink({url:e,valueList:c.splitText(s).map(t=>({value:t}))})}})}const O=[c.ControlType.SELECT,c.ControlType.CHECKBOX,c.ControlType.RADIO];function Ve({editor:a,locale:n}){new L({title:n.control,confirmText:n.confirm,cancelText:n.cancel,fields:[{type:"select",name:"type",label:n.controlType,options:[{label:n.controlText,value:c.ControlType.TEXT},{label:n.controlSelect,value:c.ControlType.SELECT},{label:n.controlCheckbox,value:c.ControlType.CHECKBOX},{label:n.controlRadio,value:c.ControlType.RADIO},{label:n.controlDate,value:c.ControlType.DATE},{label:n.controlNumber,value:c.ControlType.NUMBER}]},{type:"text",name:"placeholder",label:n.controlPlaceholder},{type:"textarea",name:"valueSets",label:n.controlValueSets,placeholder:n.controlValueSetsPlaceholder,height:80},{type:"select",name:"dateFormat",label:n.controlDateFormat,options:[{label:"yyyy-MM-dd",value:"yyyy-MM-dd"},{label:"yyyy-MM-dd HH:mm:ss",value:"yyyy-MM-dd HH:mm:ss"}]}],onConfirm:s=>{const e=s.type,t=s.valueSets.split(`
5
+ `).map(i=>i.trim()).filter(Boolean).map(i=>({value:i,code:i}));if(O.includes(e)&&!t.length)return!1;const o={type:e,value:null,placeholder:s.placeholder||void 0};O.includes(e)&&(o.code=null,o.valueSets=t),e===c.ControlType.CHECKBOX&&(o.markType=c.CheckboxMarkType.CROSS),e===c.ControlType.DATE&&(o.dateFormat=s.dateFormat),a.command.executeInsertControl({type:c.ElementType.CONTROL,value:"",control:o})}})}function Ae({editor:a,locale:n}){new L({title:n.search,confirmText:n.confirm,cancelText:n.cancel,fields:[{type:"text",name:"keyword",label:n.searchKeyword,required:!0,value:a.command.getRangeText()},{type:"text",name:"replace",label:n.searchReplace,placeholder:n.searchReplacePlaceholder}],onConfirm:({keyword:s,replace:e})=>{a.command.executeSearch(s),e&&a.command.executeReplace(e)},onClose:()=>a.command.executeSearch(null)})}function Ee(a,n){const e=l("div",{class:r("table-picker__title")},a.locale.table),t=l("div",{class:r("table-picker__grid")}),o=[];for(let i=1;i<=10;i++)for(let d=1;d<=10;d++){const h=l("span",{"data-row":i,"data-col":d});o.push(h),t.append(h)}return t.addEventListener("mouseover",i=>{const d=i.target,h=Number(d.dataset.row),g=Number(d.dataset.col);!h||!g||(e.innerText=`${h} × ${g}`,o.forEach(u=>{u.classList.toggle(r("active"),Number(u.dataset.row)<=h&&Number(u.dataset.col)<=g)}))}),t.addEventListener("mousedown",i=>i.preventDefault()),t.addEventListener("click",i=>{const d=i.target,h=Number(d.dataset.row),g=Number(d.dataset.col);!h||!g||(n(),a.editor.command.executeInsertTable(h,g))}),l("div",{class:r("table-picker")},e,t)}const Oe=[["left",c.RowFlex.LEFT,ge],["center",c.RowFlex.CENTER,te],["right",c.RowFlex.RIGHT,fe],["alignment",c.RowFlex.ALIGNMENT,Q],["justify",c.RowFlex.JUSTIFY,he]];function Ne(a){const n=[v("undo",a.undo,ke,({editor:e})=>e.command.executeUndo(),{isDisabled:({style:e})=>!!e&&!e.undo}),v("redo",a.redo,we,({editor:e})=>e.command.executeRedo(),{isDisabled:({style:e})=>!!e&&!e.redo}),{key:"painter",title:a.painter,icon:S,isActive:({style:e})=>!!(e!=null&&e.painter),render:({editor:e})=>{const t=l("div",{class:r("toolbar__button"),title:a.painter},l("i",{class:r("icon"),style:`background-image:url("${S}")`}));let o=null;return t.addEventListener("click",()=>{o&&clearTimeout(o),o=setTimeout(()=>{o=null,e.command.executePainter({isDblclick:!1})},200)}),t.addEventListener("dblclick",()=>{o&&clearTimeout(o),o=null,e.command.executePainter({isDblclick:!0})}),t}},v("format",a.format,ie,({editor:e})=>e.command.executeFormat()),A("font",a.font,I,90,({editor:e},t)=>e.command.executeFont(t),({editor:e,style:t})=>(t==null?void 0:t.font)||e.command.getOptions().defaultFont),A("size",a.size,R,54,({editor:e},t)=>e.command.executeSize(Number(t)),({editor:e,style:t})=>String(t?t.size:e.command.getOptions().defaultSize)),v("sizeAdd",a.sizeAdd,ze,({editor:e})=>e.command.executeSizeAdd()),v("sizeMinus",a.sizeMinus,Le,({editor:e})=>e.command.executeSizeMinus()),v("bold",a.bold,ee,({editor:e})=>e.command.executeBold(),{isActive:({style:e})=>!!(e!=null&&e.bold)}),v("italic",a.italic,de,({editor:e})=>e.command.executeItalic(),{isActive:({style:e})=>!!(e!=null&&e.italic)}),v("underline",a.underline,De,({editor:e})=>e.command.executeUnderline(),{isActive:({style:e})=>!!(e!=null&&e.underline)}),v("strikeout",a.strikeout,He,({editor:e})=>e.command.executeStrikeout(),{isActive:({style:e})=>!!(e!=null&&e.strikeout)}),v("superscript",a.superscript,Te,({editor:e})=>e.command.executeSuperscript(),{isActive:({style:e})=>(e==null?void 0:e.type)===c.ElementType.SUPERSCRIPT}),v("subscript",a.subscript,ye,({editor:e})=>e.command.executeSubscript(),{isActive:({style:e})=>(e==null?void 0:e.type)===c.ElementType.SUBSCRIPT}),E("color",a.color,se,({editor:e},t)=>e.command.executeColor(t),({style:e})=>(e==null?void 0:e.color)||"#000000"),E("highlight",a.highlight,ce,({editor:e},t)=>e.command.executeHighlight(t),({style:e})=>(e==null?void 0:e.highlight)||null),b("title",a.title,Ce,({editor:e,style:t},o)=>{const i=[c.TitleLevel.FIRST,c.TitleLevel.SECOND,c.TitleLevel.THIRD,c.TitleLevel.FOURTH,c.TitleLevel.FIFTH,c.TitleLevel.SIXTH],d=[{label:a.text,value:""},...i.map((g,u)=>({label:`${a.title}${u+1}`,value:g,style:`font-size:${26-u*2}px;font-weight:bold`}))],h=w(d,g=>{o(),e.command.executeTitle(g||null)});return x(h,(t==null?void 0:t.level)||""),h}),...Oe.map(([e,t,o])=>v(e,a[e],o,({editor:i})=>i.command.executeRowFlex(t),{isActive:({style:i})=>((i==null?void 0:i.rowFlex)||c.RowFlex.LEFT)===t})),b("rowMargin",a.rowMargin,xe,({editor:e,style:t},o)=>{const i=w(Se.map(d=>({label:d,value:d})),d=>{o(),e.command.executeRowMargin(Number(d))});return x(i,t?String(t.rowMargin):null),i}),b("list",a.list,ue,({editor:e,style:t},o)=>{const i=[{label:a.listDecimal,value:`${c.ListType.OL}|${c.ListStyle.DECIMAL}`},{label:a.listCheckbox,value:`${c.ListType.UL}|${c.ListStyle.CHECKBOX}`},{label:a.listDisc,value:`${c.ListType.UL}|${c.ListStyle.DISC}`},{label:a.listCircle,value:`${c.ListType.UL}|${c.ListStyle.CIRCLE}`},{label:a.listSquare,value:`${c.ListType.UL}|${c.ListStyle.SQUARE}`}],d=w(i,h=>{o();const[g,u]=h.split("|");e.command.executeList(g,u)});return x(d,t!=null&&t.listType?`${t.listType}|${t.listStyle}`:null),d},{isActive:({style:e})=>!!(e!=null&&e.listType)}),b("table",a.table,_e,Ee),v("image",a.image,re,Ie),v("hyperlink",a.hyperlink,le,Re),b("separator",a.separator,Me,({editor:e},t)=>w(V.map((o,i)=>({label:o.label,value:String(i)})),o=>{t(),e.command.executeSeparator(V[Number(o)].dashArray)})),v("pageBreak",a.pageBreak,ve,({editor:e})=>e.command.executePageBreak()),v("control",a.control,ae,Ve),b("checkbox",a.checkbox,ne,({editor:e},t)=>{const o=w([{label:`☒ ${a.checkboxCross}`,value:c.CheckboxMarkType.CROSS},{label:`☑ ${a.checkboxCheck}`,value:c.CheckboxMarkType.CHECK}],i=>{t(),e.command.executeInsertElementList([{type:c.ElementType.CHECKBOX,value:"",checkbox:{value:!1,markType:i}}])});return x(o,c.CheckboxMarkType.CROSS),o}),b("date",a.date,oe,({editor:e},t)=>{const o=new Date,i=[{format:"yyyy-MM-dd",text:C(o,!1)},{format:"yyyy-MM-dd HH:mm:ss",text:C(o,!0)}];return w(i.map((d,h)=>({label:d.text,value:String(h)})),d=>{t();const{format:h,text:g}=i[Number(d)];e.command.executeInsertElementList([{type:c.ElementType.DATE,value:"",dateFormat:h,valueList:[{value:g}]}])})}),v("search",a.search,be,Ae,{keepEnabledInReadonly:!0}),v("print",a.print,me,({editor:e})=>e.command.executePrint(),{keepEnabledInReadonly:!0}),v("pdf",a.pdf,pe,async({editor:e})=>{const t=await e.command.getPdf();q(t,`document-${Date.now()}.pdf`)},{keepEnabledInReadonly:!0})],s={};return n.forEach(e=>{s[e.key]=e}),s}const T=["undo","redo","painter","format","|","font","size","sizeAdd","sizeMinus","bold","italic","underline","strikeout","superscript","subscript","color","highlight","|","title","left","center","right","alignment","justify","rowMargin","list","|","table","image","hyperlink","separator","pageBreak","checkbox","date","|","search"],Be=[c.EditorMode.READONLY,c.EditorMode.PRINT];class $e{constructor(n,s=T){this.style=null,this.renderedList=[],this.ui=n,this.el=l("div",{class:r("toolbar")}),this.el.setAttribute(c.EDITOR_COMPONENT,c.EditorComponent.MENU),this.el.addEventListener("mousedown",e=>{const t=e.target.tagName;t!=="INPUT"&&t!=="SELECT"&&t!=="TEXTAREA"&&e.preventDefault()}),this.render(s),this.rangeStyleChange=e=>{this.style=e,this.update()},n.editor.eventBus.on("rangeStyleChange",this.rangeStyleChange),this.update()}getContext(){return{editor:this.ui.editor,ui:this.ui,locale:this.ui.locale,style:this.style}}render(n){const s=Ne(this.ui.locale),e=this.getContext();n.forEach(t=>{if(t==="|"){this.el.append(l("span",{class:r("toolbar__divider")}));return}const o=typeof t=="string"?s[t]:t;if(!o){console.warn(`[canvas-editor-ui] unknown toolbar item: ${t}`);return}const i=o.render?o.render(e):this.renderButton(o);i.classList.add(r("toolbar__item")),i.dataset.key=o.key,this.el.append(i),this.renderedList.push({item:o,el:i})})}renderButton(n){const s=l("div",{class:r("toolbar__button"),title:n.title},n.icon?l("i",{class:r("icon"),style:`background-image:url("${n.icon}")`}):null,n.text?l("span",{class:r("toolbar__text")},n.text):null);return s.addEventListener("click",()=>{var e;s.classList.contains(r("disabled"))||(e=n.onClick)==null||e.call(n,this.getContext(),s)}),s}update(){const n=this.getContext(),s=this.ui.editor.command.getOptions().mode,e=Be.includes(s);this.renderedList.forEach(({item:t,el:o})=>{var d,h,g;const i=e&&!t.keepEnabledInReadonly||!!((d=t.isDisabled)!=null&&d.call(t,n));o.classList.toggle(r("disabled"),i),o.classList.toggle(r("active"),!!((h=t.isActive)!=null&&h.call(t,n))),(g=t.update)==null||g.call(t,n,o)})}destroy(){this.ui.editor.eventBus.off("rangeStyleChange",this.rangeStyleChange),this.el.remove()}}let Fe=0;class N{constructor(n,s={}){this.toolbar=null,this.statusbar=null,this.locale={..._,...s.locale};const e=`${r("root")}-${++Fe}`,t=l("div",{class:r("editor")});this.main=l("div",{class:r("main")},t),this.root=l("div",{class:r("root"),id:e},this.main),n.append(this.root),this.editor=new B.default(t,s.data||{main:[]},{scrollContainerSelector:`#${e} .${r("main")}`,...s.options}),s.toolbar!==!1&&(this.toolbar=new $e(this,s.toolbar||T),this.root.prepend(this.toolbar.el)),s.statusbar!==!1&&(this.statusbar=new J(this,s.statusbar||y),this.root.append(this.statusbar.el)),this.mode=this.editor.command.getOptions().mode,this.renderChange=()=>{this.editor.command.getOptions().mode!==this.mode&&this.syncMode()},this.editor.eventBus.on("renderChange",this.renderChange)}syncMode(){var n,s;this.mode=this.editor.command.getOptions().mode,(n=this.toolbar)==null||n.update(),(s=this.statusbar)==null||s.update()}getPageSize(){return this.main.querySelectorAll("canvas[data-index]").length||1}setMode(n){this.editor.command.executeMode(n),this.syncMode()}destroy(){var n,s;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()}}function Pe(a,n){const s=typeof a=="string"?document.querySelector(a):a;if(!s)throw new Error(`[canvas-editor-ui] container not found: ${a}`);return new N(s,n)}p.DEFAULT_STATUSBAR=y,p.DEFAULT_TOOLBAR=T,p.Dialog=L,p.EditorUI=N,p.FONT_LIST=I,p.SIZE_LIST=R,p.createEditorUI=Pe,p.defaultLocale=_,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
6
6
  //# sourceMappingURL=canvas-editor-ui.umd.js.map