@bireturn/word-editor 1.0.12 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/word-editor.css +1 -1
- package/lib/word-editor.es.js +3 -3
- package/lib/word-editor.umd.js +1 -1
- package/package.json +1 -1
package/lib/word-editor.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.vue-recycle-scroller__resize-observer[data-v-08cc04ab]{position:absolute;top:0;right:0;bottom:0;left:0;opacity:0;pointer-events:none;z-index:-1}.vue-recycle-scroller{position:relative}.vue-recycle-scroller.direction-vertical:not(.page-mode){overflow-y:auto}.vue-recycle-scroller.direction-horizontal:not(.page-mode){overflow-x:auto}.vue-recycle-scroller.grid-mode:not(.page-mode){overflow:auto}.vue-recycle-scroller.direction-horizontal{display:flex}.vue-recycle-scroller__slot{flex:auto 0 0}.vue-recycle-scroller__item-wrapper{flex:1;box-sizing:border-box;overflow:hidden;position:relative}.vue-recycle-scroller.ready .vue-recycle-scroller__item-view{position:absolute;top:0;left:0;will-change:transform}.vue-recycle-scroller.direction-vertical .vue-recycle-scroller__item-wrapper{width:100%}.vue-recycle-scroller.direction-horizontal .vue-recycle-scroller__item-wrapper{height:100%}.vue-recycle-scroller.ready.direction-vertical .vue-recycle-scroller__item-view{width:100%}.vue-recycle-scroller.ready.direction-horizontal .vue-recycle-scroller__item-view{height:100%}.we-vt-table--context-menu-clild-wrapper,.we-vt-table--context-menu-wrapper{box-shadow:0 4px 12px #00000014,0 0 0 1px #0000000a!important;border:none!important;border-radius:var(--modern-menu-radius)!important}.we-vt-context-menu--option-wrapper li.link--active,.we-vt-table--context-menu-clild-wrapper li.link--active{background-color:transparent!important;border-color:transparent!important}.we-vt-table--context-menu-wrapper .we-vt-context-menu--option-wrapper .modern-menu-item:first-child .modern-menu-link:hover{background:var(--modern-menu-item-hover-bg)!important;color:var(--modern-menu-item-hover-color)!important}.virtual-table-menu.modern-virtual-menu{z-index:9999;position:fixed}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper{background:var(--modern-menu-bg);border:1px solid var(--modern-menu-border);border-radius:var(--modern-menu-radius);box-shadow:var(--modern-menu-shadow);padding:4px;min-width:160px;list-style:none;margin:0;transition:all var(--modern-menu-animation-duration) var(--modern-menu-animation-easing);animation:menuFadeIn .15s ease-out}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item{position:relative;padding:0;margin-bottom:0}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item:last-child{margin-bottom:0}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item .modern-menu-link{display:flex;align-items:center;gap:8px;padding:6px 10px;border-radius:var(--modern-menu-item-radius);color:var(--modern-menu-item-color);text-decoration:none;font-size:13px;font-weight:400;cursor:pointer;line-height:1.4;transition:all var(--modern-menu-animation-duration) var(--modern-menu-animation-easing)}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item .modern-menu-link .menu-icon{flex-shrink:0;color:var(--modern-menu-icon-color);transition:color var(--modern-menu-animation-duration) var(--modern-menu-animation-easing)}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item .modern-menu-link .menu-label{flex:1;white-space:nowrap}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item .modern-menu-link .submenu-arrow{flex-shrink:0;color:var(--modern-menu-icon-color);transition:color var(--modern-menu-animation-duration) var(--modern-menu-animation-easing)}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item .modern-menu-link:hover{background:var(--modern-menu-item-hover-bg);color:var(--modern-menu-item-hover-color)}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item .modern-menu-link:hover .menu-icon,.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item .modern-menu-link:hover .submenu-arrow{color:var(--modern-menu-icon-hover-color)}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item.link--disabled .modern-menu-link{color:var(--modern-menu-item-disabled-color);cursor:not-allowed}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item.link--disabled .modern-menu-link:hover{background:transparent;color:var(--modern-menu-item-disabled-color)}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item.link--disabled .modern-menu-link:hover .menu-icon,.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item.link--disabled .modern-menu-link:hover .submenu-arrow{color:var(--modern-menu-icon-disabled-color)}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item.has-children{position:relative}.virtual-table-menu.modern-virtual-menu .modern-submenu{position:absolute;left:calc(100% + 4px);top:0;min-width:140px;background:var(--modern-submenu-bg);border:1px solid var(--modern-menu-border);border-radius:var(--modern-submenu-radius);box-shadow:var(--modern-submenu-shadow);padding:4px;list-style:none;z-index:10000;margin:0;animation:submenuFadeIn .12s ease-out}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item{padding:0;margin-bottom:0}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item:last-child{margin-bottom:0}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item .modern-submenu-link{display:flex;align-items:center;gap:6px;padding:5px 8px;border-radius:var(--modern-submenu-item-radius);color:var(--modern-menu-item-color);text-decoration:none;font-size:12px;font-weight:400;cursor:pointer;line-height:1.4;transition:all var(--modern-menu-animation-duration) var(--modern-menu-animation-easing)}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item .modern-submenu-link .submenu-icon{flex-shrink:0;color:var(--modern-menu-icon-color);transition:color var(--modern-menu-animation-duration) var(--modern-menu-animation-easing)}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item .modern-submenu-link .submenu-label{flex:1;white-space:nowrap}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item .modern-submenu-link:hover{background:var(--modern-menu-item-hover-bg);color:var(--modern-menu-item-hover-color)}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item .modern-submenu-link:hover .submenu-icon{color:var(--modern-menu-icon-hover-color)}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item.link--disabled .modern-submenu-link{color:var(--modern-menu-item-disabled-color);cursor:not-allowed}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item.link--disabled .modern-submenu-link:hover{background:transparent;color:var(--modern-menu-item-disabled-color)}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item.link--disabled .modern-submenu-link:hover .submenu-icon{color:var(--modern-menu-icon-disabled-color)}@keyframes menuFadeIn{0%{opacity:0;transform:scale(.98) translateY(-4px)}to{opacity:1;transform:scale(1) translateY(0)}}@keyframes submenuFadeIn{0%{opacity:0;transform:scale(.98) translate(-4px)}to{opacity:1;transform:scale(1) translate(0)}}.virtual-table[data-v-885af7f2]{width:100%;height:100%;background-color:var(--we-vt-table-body-background-color, #fff);display:flex;flex-direction:column}.virtual-table .virtual-table-header[data-v-885af7f2]{display:flex}.virtual-table .virtual-table-wrapper[data-v-885af7f2]{flex:1;font-family:"FangSong"}.virtual-table .virtual-table-row[data-v-885af7f2]{display:flex;min-height:20px}.virtual-table .virtual-table-row.current-row[data-v-885af7f2]{background-color:var(--el-table-row-hover-bg-color);color:var(--el-color-primary)}.virtual-table .virtual-table-cell[data-v-885af7f2]{position:relative}.virtual-table .content-wrapper[data-v-885af7f2]{flex:1;min-height:20px;color:#606266;font-size:14px;font-weight:400}.virtual-table .virtual-table-inline-editing-trigger[data-v-885af7f2]{white-space:pre-line;word-break:break-all;border:1px transparent dotted}.virtual-table .virtual-table-inline-editing-trigger[data-v-885af7f2]:hover{border-color:var(--el-color-primary)}.a4-pages-container[data-v-885af7f2]{width:100%;height:100%;overflow:auto;background-color:#f0f0f0;padding:20px;display:flex;flex-direction:column;align-items:center;font-family:"FangSong"}.a4-page[data-v-885af7f2]{background:#fff;box-shadow:0 2px 8px #00000026;position:relative;margin:0 auto;box-sizing:border-box;display:flex;flex-direction:column;flex-shrink:0}.a4-table-header[data-v-885af7f2]{background:#fff;z-index:10;border-bottom:1px solid #e8e8e8;margin-bottom:10px;padding-bottom:10px;overflow-x:auto;min-width:0;margin-top:10px}.a4-table-header[data-v-885af7f2]::-webkit-scrollbar{height:4px}.a4-table-header[data-v-885af7f2]::-webkit-scrollbar-track{background:transparent}.a4-table-header[data-v-885af7f2]::-webkit-scrollbar-thumb{background:#ddd;border-radius:2px}.a4-page-content[data-v-885af7f2]{min-width:0;min-height:0;position:relative;flex:1 1 auto}.a4-page-content[data-v-885af7f2]::-webkit-scrollbar{height:6px}.a4-page-content[data-v-885af7f2]::-webkit-scrollbar-track{background:#f1f1f1;border-radius:3px}.a4-page-content[data-v-885af7f2]::-webkit-scrollbar-thumb{background:#888;border-radius:3px}.a4-page-content[data-v-885af7f2]::-webkit-scrollbar-thumb:hover{background:#555}.a4-page-header[data-v-885af7f2]{flex-shrink:0;width:100%;overflow:hidden}.a4-page-footer[data-v-885af7f2]{flex-shrink:0;width:100%;text-align:center;color:#666;font-size:12px;background:#fff;min-height:20px;padding:4px 0 8px}.page-number[data-v-885af7f2]{display:inline-block}.a4-page .virtual-table-row[data-v-885af7f2]{display:flex;transition:background-color .2s;width:100%}.a4-page .virtual-table-cell[data-v-885af7f2]{overflow:hidden;text-overflow:ellipsis;box-sizing:border-box}.a4-page .virtual-table-header[data-v-885af7f2]{min-width:fit-content}.a4-page .we-vt-header--column[data-v-885af7f2]{flex-shrink:0;padding:8px;box-sizing:border-box}.a4-page .virtual-table-row[data-v-885af7f2]:hover{background-color:#fafafa}.a4-page .virtual-table-row.row--current[data-v-885af7f2]{background-color:var(--el-table-row-hover-bg-color);color:var(--el-color-primary)}.virtual-table-row.row--highlight[data-v-885af7f2]{animation:rowHighlight-885af7f2 1.5s ease-in-out}@keyframes rowHighlight-885af7f2{0%{background-color:transparent}25%{background-color:gold;transform:scale(1.01)}50%{background-color:#ffeb3b}to{background-color:transparent;transform:scale(1)}}.a4-page-placeholder[data-v-885af7f2]{background:#fff;box-shadow:0 2px 8px #00000026;position:relative;margin:0 auto;box-sizing:border-box;display:flex;align-items:center;justify-content:center;flex-shrink:0}.a4-page-loading[data-v-885af7f2]{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:400px;width:100%}.loading-spinner[data-v-885af7f2]{width:40px;height:40px;border:3px solid #f3f3f3;border-top:3px solid var(--el-color-primary);border-radius:50%;animation:spin-885af7f2 1s linear infinite}@keyframes spin-885af7f2{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.loading-text[data-v-885af7f2]{margin-top:20px;color:#666;font-size:14px}@media print{.a4-pages-container[data-v-885af7f2]{background:none;padding:0}.a4-page[data-v-885af7f2]{box-shadow:none;margin:0;page-break-after:always}.a4-page[data-v-885af7f2]:last-child{page-break-after:auto}.a4-page-footer[data-v-885af7f2]{position:fixed;bottom:0}}.catalog-node__label[data-v-ac882917]{display:flex;align-items:center;gap:4px;height:30px;padding-right:10px;border-radius:6px;cursor:pointer;color:#3f4654;font-size:13px;transition:background-color .15s ease,color .15s ease}.catalog-node__label[data-v-ac882917]:hover{background-color:#f1f3f6;color:#1f2937}.catalog-node__label.is-active[data-v-ac882917]{background-color:#e8f0fe;color:#2563eb;font-weight:500}.catalog-node__toggle[data-v-ac882917]{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;flex-shrink:0;color:#9aa3b2}.catalog-node__toggle[data-v-ac882917]:hover{color:#2563eb}.catalog-node__text[data-v-ac882917]{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.catalog[data-v-8becafa1]{display:flex;flex-direction:column;width:268px;height:100%;flex-shrink:0;background-color:#fafbfc;border-right:1px solid #e7e9ee}.catalog--collapsed[data-v-8becafa1]{width:44px;align-items:center;padding-top:10px}.catalog__header[data-v-8becafa1]{display:flex;align-items:center;justify-content:space-between;height:48px;padding:0 12px 0 14px;border-bottom:1px solid #e7e9ee}.catalog__title[data-v-8becafa1]{display:inline-flex;align-items:center;gap:6px;font-size:14px;font-weight:600;color:#1f2937}.catalog__icon-btn[data-v-8becafa1]{display:inline-flex;align-items:center;justify-content:center;width:30px;height:30px;padding:0;border:none;border-radius:6px;background:transparent;color:#6b7280;cursor:pointer;transition:background-color .15s ease,color .15s ease}.catalog__icon-btn[data-v-8becafa1]:hover{background-color:#eef0f4;color:#2563eb}.catalog__body[data-v-8becafa1]{flex:1;overflow-y:auto;padding:8px}.catalog__empty[data-v-8becafa1]{padding:24px 12px;text-align:center;font-size:13px;color:#9aa3b2}.doc-para[data-v-b9e67b24]{margin:0;min-height:20px;line-height:1.43;font-size:14px;color:#000;word-break:break-word}.doc-title[data-v-b9e67b24]{margin:0;line-height:1.4;font-size:14px;color:#000;word-break:break-word}.doc-link[data-v-b9e67b24]{color:#00f;text-decoration:underline}.doc-image[data-v-b9e67b24]{max-width:100%;vertical-align:middle}.ctrl-input[data-v-b9e67b24]{display:inline-block;border-bottom:1px solid #000;min-width:60px;vertical-align:bottom;padding:0 2px;line-height:1.4}.ctrl-options[data-v-b9e67b24]{display:inline-flex;flex-wrap:wrap;gap:8px;align-items:center;vertical-align:middle}.ctrl-options--vertical[data-v-b9e67b24]{display:flex;flex-direction:column;align-items:flex-start;gap:2px}.ctrl-option[data-v-b9e67b24]{display:inline-flex;align-items:center;gap:3px;padding-left:6px;cursor:default;-webkit-user-select:none;user-select:none}.el-check[data-v-b9e67b24]{vertical-align:middle;margin:0 2px}.doc-tab[data-v-b9e67b24]{display:inline-block}.doc-table-row-wrap[data-v-b9e67b24]{overflow-x:auto}.doc-table-row-wrap:not(.is-first):not(.is-page-break) .doc-table tr:first-child td[data-v-b9e67b24]{border-top:none}.doc-table[data-v-b9e67b24]{border-collapse:collapse;table-layout:fixed}.doc-table td[data-v-b9e67b24]{border:1px solid #000;padding:4px 6px;font-size:12px;color:#000;word-break:break-word;overflow-wrap:break-word}.doc-table.doc-table--header-footer td[data-v-b9e67b24]{padding:4px}.cell-para[data-v-b9e67b24]{margin:0;line-height:1.5;min-height:1em}.doc-table--no-border td[data-v-b9e67b24]{border:none}.doc-table--header-footer td[data-v-b9e67b24]{word-break:normal;overflow-wrap:normal}.doc-list[data-v-b9e67b24]{margin:0;padding-left:24px;font-size:12px;color:#000}.doc-list-item[data-v-b9e67b24]{line-height:1.5;word-break:break-word;min-height:1.5em}.empty-line[data-v-b9e67b24]{display:inline-block;width:1px}.editor-layout[data-v-9ff2db2b]{display:flex;height:100%;overflow:hidden}.editor-container[data-v-9ff2db2b]{flex:1;min-width:0;height:100%;overflow:hidden}.editor-loading[data-v-9ff2db2b]{display:flex;align-items:center;justify-content:center;height:100%;font-size:14px;color:#666}.doc-header[data-v-9ff2db2b]{display:flex;flex-direction:column;align-items:center;width:100%;overflow:hidden;border-bottom:1px solid #e5e7eb;padding-bottom:4px;margin-bottom:8px}.doc-footer[data-v-9ff2db2b]{display:flex;flex-direction:column;align-items:center;width:100%;overflow:hidden;border-top:1px solid #e5e7eb;padding-top:4px;margin-top:8px}.doc-page-number[data-v-9ff2db2b]{text-align:center;font-size:12px;color:#666;margin-top:4px}.word-editor-scope{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,PingFang SC,Hiragino Sans GB,Microsoft YaHei,sans-serif;font-size:14px;line-height:1.43;color:#1f2937;text-align:left;-webkit-font-smoothing:antialiased}.word-editor-scope *,.word-editor-scope *:before,.word-editor-scope *:after{box-sizing:border-box}:where(.word-editor-scope) :where(p,h1,h2,h3,h4,h5,h6,ul,ol,li,figure,blockquote,dl,dd){margin:0;padding:0}.word-editor-scope table{margin:0;border-collapse:collapse;border-spacing:0}.word-editor-scope img{max-width:none}.word-editor-scope .virtual-table-cell{padding:0}
|
|
1
|
+
.vue-recycle-scroller__resize-observer[data-v-08cc04ab]{position:absolute;top:0;right:0;bottom:0;left:0;opacity:0;pointer-events:none;z-index:-1}.vue-recycle-scroller{position:relative}.vue-recycle-scroller.direction-vertical:not(.page-mode){overflow-y:auto}.vue-recycle-scroller.direction-horizontal:not(.page-mode){overflow-x:auto}.vue-recycle-scroller.grid-mode:not(.page-mode){overflow:auto}.vue-recycle-scroller.direction-horizontal{display:flex}.vue-recycle-scroller__slot{flex:auto 0 0}.vue-recycle-scroller__item-wrapper{flex:1;box-sizing:border-box;overflow:hidden;position:relative}.vue-recycle-scroller.ready .vue-recycle-scroller__item-view{position:absolute;top:0;left:0;will-change:transform}.vue-recycle-scroller.direction-vertical .vue-recycle-scroller__item-wrapper{width:100%}.vue-recycle-scroller.direction-horizontal .vue-recycle-scroller__item-wrapper{height:100%}.vue-recycle-scroller.ready.direction-vertical .vue-recycle-scroller__item-view{width:100%}.vue-recycle-scroller.ready.direction-horizontal .vue-recycle-scroller__item-view{height:100%}.we-vt-table--context-menu-clild-wrapper,.we-vt-table--context-menu-wrapper{box-shadow:0 4px 12px #00000014,0 0 0 1px #0000000a!important;border:none!important;border-radius:var(--modern-menu-radius)!important}.we-vt-context-menu--option-wrapper li.link--active,.we-vt-table--context-menu-clild-wrapper li.link--active{background-color:transparent!important;border-color:transparent!important}.we-vt-table--context-menu-wrapper .we-vt-context-menu--option-wrapper .modern-menu-item:first-child .modern-menu-link:hover{background:var(--modern-menu-item-hover-bg)!important;color:var(--modern-menu-item-hover-color)!important}.virtual-table-menu.modern-virtual-menu{z-index:9999;position:fixed}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper{background:var(--modern-menu-bg);border:1px solid var(--modern-menu-border);border-radius:var(--modern-menu-radius);box-shadow:var(--modern-menu-shadow);padding:4px;min-width:160px;list-style:none;margin:0;transition:all var(--modern-menu-animation-duration) var(--modern-menu-animation-easing);animation:menuFadeIn .15s ease-out}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item{position:relative;padding:0;margin-bottom:0}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item:last-child{margin-bottom:0}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item .modern-menu-link{display:flex;align-items:center;gap:8px;padding:6px 10px;border-radius:var(--modern-menu-item-radius);color:var(--modern-menu-item-color);text-decoration:none;font-size:13px;font-weight:400;cursor:pointer;line-height:1.4;transition:all var(--modern-menu-animation-duration) var(--modern-menu-animation-easing)}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item .modern-menu-link .menu-icon{flex-shrink:0;color:var(--modern-menu-icon-color);transition:color var(--modern-menu-animation-duration) var(--modern-menu-animation-easing)}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item .modern-menu-link .menu-label{flex:1;white-space:nowrap}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item .modern-menu-link .submenu-arrow{flex-shrink:0;color:var(--modern-menu-icon-color);transition:color var(--modern-menu-animation-duration) var(--modern-menu-animation-easing)}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item .modern-menu-link:hover{background:var(--modern-menu-item-hover-bg);color:var(--modern-menu-item-hover-color)}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item .modern-menu-link:hover .menu-icon,.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item .modern-menu-link:hover .submenu-arrow{color:var(--modern-menu-icon-hover-color)}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item.link--disabled .modern-menu-link{color:var(--modern-menu-item-disabled-color);cursor:not-allowed}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item.link--disabled .modern-menu-link:hover{background:transparent;color:var(--modern-menu-item-disabled-color)}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item.link--disabled .modern-menu-link:hover .menu-icon,.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item.link--disabled .modern-menu-link:hover .submenu-arrow{color:var(--modern-menu-icon-disabled-color)}.virtual-table-menu.modern-virtual-menu .modern-menu-wrapper .modern-menu-item.has-children{position:relative}.virtual-table-menu.modern-virtual-menu .modern-submenu{position:absolute;left:calc(100% + 4px);top:0;min-width:140px;background:var(--modern-submenu-bg);border:1px solid var(--modern-menu-border);border-radius:var(--modern-submenu-radius);box-shadow:var(--modern-submenu-shadow);padding:4px;list-style:none;z-index:10000;margin:0;animation:submenuFadeIn .12s ease-out}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item{padding:0;margin-bottom:0}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item:last-child{margin-bottom:0}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item .modern-submenu-link{display:flex;align-items:center;gap:6px;padding:5px 8px;border-radius:var(--modern-submenu-item-radius);color:var(--modern-menu-item-color);text-decoration:none;font-size:12px;font-weight:400;cursor:pointer;line-height:1.4;transition:all var(--modern-menu-animation-duration) var(--modern-menu-animation-easing)}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item .modern-submenu-link .submenu-icon{flex-shrink:0;color:var(--modern-menu-icon-color);transition:color var(--modern-menu-animation-duration) var(--modern-menu-animation-easing)}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item .modern-submenu-link .submenu-label{flex:1;white-space:nowrap}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item .modern-submenu-link:hover{background:var(--modern-menu-item-hover-bg);color:var(--modern-menu-item-hover-color)}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item .modern-submenu-link:hover .submenu-icon{color:var(--modern-menu-icon-hover-color)}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item.link--disabled .modern-submenu-link{color:var(--modern-menu-item-disabled-color);cursor:not-allowed}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item.link--disabled .modern-submenu-link:hover{background:transparent;color:var(--modern-menu-item-disabled-color)}.virtual-table-menu.modern-virtual-menu .modern-submenu .modern-submenu-item.link--disabled .modern-submenu-link:hover .submenu-icon{color:var(--modern-menu-icon-disabled-color)}@keyframes menuFadeIn{0%{opacity:0;transform:scale(.98) translateY(-4px)}to{opacity:1;transform:scale(1) translateY(0)}}@keyframes submenuFadeIn{0%{opacity:0;transform:scale(.98) translate(-4px)}to{opacity:1;transform:scale(1) translate(0)}}.virtual-table[data-v-885af7f2]{width:100%;height:100%;background-color:var(--we-vt-table-body-background-color, #fff);display:flex;flex-direction:column}.virtual-table .virtual-table-header[data-v-885af7f2]{display:flex}.virtual-table .virtual-table-wrapper[data-v-885af7f2]{flex:1;font-family:"FangSong"}.virtual-table .virtual-table-row[data-v-885af7f2]{display:flex;min-height:20px}.virtual-table .virtual-table-row.current-row[data-v-885af7f2]{background-color:var(--el-table-row-hover-bg-color);color:var(--el-color-primary)}.virtual-table .virtual-table-cell[data-v-885af7f2]{position:relative}.virtual-table .content-wrapper[data-v-885af7f2]{flex:1;min-height:20px;color:#606266;font-size:14px;font-weight:400}.virtual-table .virtual-table-inline-editing-trigger[data-v-885af7f2]{white-space:pre-line;word-break:break-all;border:1px transparent dotted}.virtual-table .virtual-table-inline-editing-trigger[data-v-885af7f2]:hover{border-color:var(--el-color-primary)}.a4-pages-container[data-v-885af7f2]{width:100%;height:100%;overflow:auto;background-color:#f0f0f0;padding:20px;display:flex;flex-direction:column;align-items:center;font-family:"FangSong"}.a4-page[data-v-885af7f2]{background:#fff;box-shadow:0 2px 8px #00000026;position:relative;margin:0 auto;box-sizing:border-box;display:flex;flex-direction:column;flex-shrink:0}.a4-table-header[data-v-885af7f2]{background:#fff;z-index:10;border-bottom:1px solid #e8e8e8;margin-bottom:10px;padding-bottom:10px;overflow-x:auto;min-width:0;margin-top:10px}.a4-table-header[data-v-885af7f2]::-webkit-scrollbar{height:4px}.a4-table-header[data-v-885af7f2]::-webkit-scrollbar-track{background:transparent}.a4-table-header[data-v-885af7f2]::-webkit-scrollbar-thumb{background:#ddd;border-radius:2px}.a4-page-content[data-v-885af7f2]{min-width:0;min-height:0;position:relative;flex:1 1 auto}.a4-page-content[data-v-885af7f2]::-webkit-scrollbar{height:6px}.a4-page-content[data-v-885af7f2]::-webkit-scrollbar-track{background:#f1f1f1;border-radius:3px}.a4-page-content[data-v-885af7f2]::-webkit-scrollbar-thumb{background:#888;border-radius:3px}.a4-page-content[data-v-885af7f2]::-webkit-scrollbar-thumb:hover{background:#555}.a4-page-header[data-v-885af7f2]{flex-shrink:0;width:100%;overflow:hidden}.a4-page-footer[data-v-885af7f2]{flex-shrink:0;width:100%;text-align:center;color:#666;font-size:12px;background:#fff;min-height:20px;padding:4px 0 8px}.page-number[data-v-885af7f2]{display:inline-block}.a4-page .virtual-table-row[data-v-885af7f2]{display:flex;transition:background-color .2s;width:100%}.a4-page .virtual-table-cell[data-v-885af7f2]{overflow:hidden;text-overflow:ellipsis;box-sizing:border-box}.a4-page .virtual-table-header[data-v-885af7f2]{min-width:fit-content}.a4-page .we-vt-header--column[data-v-885af7f2]{flex-shrink:0;padding:8px;box-sizing:border-box}.a4-page .virtual-table-row[data-v-885af7f2]:hover{background-color:#fafafa}.a4-page .virtual-table-row.row--current[data-v-885af7f2]{background-color:var(--el-table-row-hover-bg-color);color:var(--el-color-primary)}.virtual-table-row.row--highlight[data-v-885af7f2]{animation:rowHighlight-885af7f2 1.5s ease-in-out}@keyframes rowHighlight-885af7f2{0%{background-color:transparent}25%{background-color:gold;transform:scale(1.01)}50%{background-color:#ffeb3b}to{background-color:transparent;transform:scale(1)}}.a4-page-placeholder[data-v-885af7f2]{background:#fff;box-shadow:0 2px 8px #00000026;position:relative;margin:0 auto;box-sizing:border-box;display:flex;align-items:center;justify-content:center;flex-shrink:0}.a4-page-loading[data-v-885af7f2]{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:400px;width:100%}.loading-spinner[data-v-885af7f2]{width:40px;height:40px;border:3px solid #f3f3f3;border-top:3px solid var(--el-color-primary);border-radius:50%;animation:spin-885af7f2 1s linear infinite}@keyframes spin-885af7f2{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.loading-text[data-v-885af7f2]{margin-top:20px;color:#666;font-size:14px}@media print{.a4-pages-container[data-v-885af7f2]{background:none;padding:0}.a4-page[data-v-885af7f2]{box-shadow:none;margin:0;page-break-after:always}.a4-page[data-v-885af7f2]:last-child{page-break-after:auto}.a4-page-footer[data-v-885af7f2]{position:fixed;bottom:0}}.catalog-node__label[data-v-ac882917]{display:flex;align-items:center;gap:4px;height:30px;padding-right:10px;border-radius:6px;cursor:pointer;color:#3f4654;font-size:13px;transition:background-color .15s ease,color .15s ease}.catalog-node__label[data-v-ac882917]:hover{background-color:#f1f3f6;color:#1f2937}.catalog-node__label.is-active[data-v-ac882917]{background-color:#e8f0fe;color:#2563eb;font-weight:500}.catalog-node__toggle[data-v-ac882917]{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;flex-shrink:0;color:#9aa3b2}.catalog-node__toggle[data-v-ac882917]:hover{color:#2563eb}.catalog-node__text[data-v-ac882917]{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.catalog[data-v-8becafa1]{display:flex;flex-direction:column;width:268px;height:100%;flex-shrink:0;background-color:#fafbfc;border-right:1px solid #e7e9ee}.catalog--collapsed[data-v-8becafa1]{width:44px;align-items:center;padding-top:10px}.catalog__header[data-v-8becafa1]{display:flex;align-items:center;justify-content:space-between;height:48px;padding:0 12px 0 14px;border-bottom:1px solid #e7e9ee}.catalog__title[data-v-8becafa1]{display:inline-flex;align-items:center;gap:6px;font-size:14px;font-weight:600;color:#1f2937}.catalog__icon-btn[data-v-8becafa1]{display:inline-flex;align-items:center;justify-content:center;width:30px;height:30px;padding:0;border:none;border-radius:6px;background:transparent;color:#6b7280;cursor:pointer;transition:background-color .15s ease,color .15s ease}.catalog__icon-btn[data-v-8becafa1]:hover{background-color:#eef0f4;color:#2563eb}.catalog__body[data-v-8becafa1]{flex:1;overflow-y:auto;padding:8px}.catalog__empty[data-v-8becafa1]{padding:24px 12px;text-align:center;font-size:13px;color:#9aa3b2}.doc-para[data-v-b43bda01]{margin:0;min-height:20px;line-height:1.5;font-size:14px;color:#000;word-break:break-word}.doc-title[data-v-b43bda01]{margin:0;line-height:1.4;font-size:14px;color:#000;word-break:break-word}.doc-link[data-v-b43bda01]{color:#00f;text-decoration:underline}.doc-image[data-v-b43bda01]{max-width:100%;vertical-align:middle}.ctrl-input[data-v-b43bda01]{display:inline-block;border-bottom:1px solid #000;min-width:60px;vertical-align:bottom;padding:0 2px;line-height:1.4}.ctrl-options[data-v-b43bda01]{display:inline-flex;flex-wrap:wrap;gap:8px;align-items:center;vertical-align:middle}.ctrl-options--vertical[data-v-b43bda01]{display:flex;flex-direction:column;align-items:flex-start;gap:2px}.ctrl-option[data-v-b43bda01]{display:inline-flex;align-items:center;gap:3px;padding-left:6px;cursor:default;-webkit-user-select:none;user-select:none}.el-check[data-v-b43bda01]{vertical-align:middle;margin:0 2px}.doc-tab[data-v-b43bda01]{display:inline-block}.doc-table-row-wrap[data-v-b43bda01]{overflow-x:auto}.doc-table-row-wrap:not(.is-first):not(.is-page-break) .doc-table tr:first-child td[data-v-b43bda01]{border-top:none}.doc-table[data-v-b43bda01]{border-collapse:collapse;table-layout:fixed}.doc-table td[data-v-b43bda01]{border:1px solid #000;padding:4px 6px;font-size:12px;color:#000;word-break:break-word;overflow-wrap:break-word}.doc-table.doc-table--header-footer td[data-v-b43bda01]{padding:4px}.cell-para[data-v-b43bda01]{margin:0;line-height:1.5;min-height:1em}.doc-table--no-border td[data-v-b43bda01]{border:none}.doc-table--header-footer td[data-v-b43bda01]{word-break:normal;overflow-wrap:normal}.doc-list[data-v-b43bda01]{margin:0;padding-left:24px;font-size:12px;color:#000}.doc-list-item[data-v-b43bda01]{line-height:1.5;word-break:break-word;min-height:1.5em}.empty-line[data-v-b43bda01]{display:inline-block;width:1px}.editor-layout[data-v-18dd3aa4]{display:flex;height:100%;overflow:hidden}.editor-container[data-v-18dd3aa4]{flex:1;min-width:0;height:100%;overflow:hidden}.editor-loading[data-v-18dd3aa4]{display:flex;align-items:center;justify-content:center;height:100%;font-size:14px;color:#666}.doc-header[data-v-18dd3aa4]{display:flex;flex-direction:column;align-items:center;width:100%;overflow:hidden;border-bottom:1px solid #e5e7eb;padding-bottom:4px;margin-bottom:8px}.doc-footer[data-v-18dd3aa4]{display:flex;flex-direction:column;align-items:center;width:100%;overflow:hidden;border-top:1px solid #e5e7eb;padding-top:4px;margin-top:8px}.doc-page-number[data-v-18dd3aa4]{text-align:center;font-size:12px;color:#666;margin-top:4px}.word-editor-scope{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,PingFang SC,Hiragino Sans GB,Microsoft YaHei,sans-serif;font-size:14px;line-height:1.43;color:#1f2937;text-align:left;-webkit-font-smoothing:antialiased}.word-editor-scope *,.word-editor-scope *:before,.word-editor-scope *:after{box-sizing:border-box}:where(.word-editor-scope) :where(p,h1,h2,h3,h4,h5,h6,ul,ol,li,figure,blockquote,dl,dd){margin:0;padding:0}.word-editor-scope table{margin:0;border-collapse:collapse;border-spacing:0}.word-editor-scope img{max-width:none}.word-editor-scope .virtual-table-cell{padding:0}
|
package/lib/word-editor.es.js
CHANGED
|
@@ -2021,7 +2021,7 @@ const Ni = {
|
|
|
2021
2021
|
], 6)) : ve("", !0);
|
|
2022
2022
|
};
|
|
2023
2023
|
}
|
|
2024
|
-
}, pt = /* @__PURE__ */ Ve(il, [["__scopeId", "data-v-
|
|
2024
|
+
}, pt = /* @__PURE__ */ Ve(il, [["__scopeId", "data-v-b43bda01"]]), ll = { class: "editor-layout word-editor-scope" }, ol = { class: "editor-container" }, al = {
|
|
2025
2025
|
key: 0,
|
|
2026
2026
|
class: "editor-loading"
|
|
2027
2027
|
}, sl = {
|
|
@@ -2032,7 +2032,7 @@ const Ni = {
|
|
|
2032
2032
|
props: {
|
|
2033
2033
|
// 文档结构数据(IElement[]),来源由使用方决定
|
|
2034
2034
|
data: {
|
|
2035
|
-
type: Array,
|
|
2035
|
+
type: [Array, Object],
|
|
2036
2036
|
default: () => []
|
|
2037
2037
|
},
|
|
2038
2038
|
// 外部数据加载态,用于展示加载占位
|
|
@@ -2350,7 +2350,7 @@ const Ni = {
|
|
|
2350
2350
|
])
|
|
2351
2351
|
]));
|
|
2352
2352
|
}
|
|
2353
|
-
}, gl = /* @__PURE__ */ Ve(fl, [["__scopeId", "data-v-
|
|
2353
|
+
}, gl = /* @__PURE__ */ Ve(fl, [["__scopeId", "data-v-18dd3aa4"]]), Vt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
2354
2354
|
function ot(t = 10) {
|
|
2355
2355
|
const e = crypto.getRandomValues(new Uint8Array(t));
|
|
2356
2356
|
return Array.from(e).map((n) => Vt[n % Vt.length]).join("");
|
package/lib/word-editor.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
(function(X,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("vue-virtual-scroller"),require("lucide-vue-next")):typeof define=="function"&&define.amd?define(["exports","vue","vue-virtual-scroller","lucide-vue-next"],e):(X=typeof globalThis<"u"?globalThis:X||self,e(X.WordEditor={},X.Vue,X.VueVirtualScroller,X.LucideVueNext))})(this,function(X,e,xe,E){"use strict";var ro=Object.defineProperty;var so=(X,e,xe)=>e in X?ro(X,e,{enumerable:!0,configurable:!0,writable:!0,value:xe}):X[e]=xe;var v=(X,e,xe)=>so(X,typeof e!="symbol"?e+"":e,xe);const _t={class:"we-vt-context-menu--option-wrapper modern-menu-wrapper"},wt=["onMouseenter","onMouseleave"],xt=["onClick"],Ct={class:"we-vt-context-menu--link-content menu-label"},Et={key:0,class:"we-vt-context-menu--submenu modern-submenu"},Bt=["onClick"],Mt={class:"we-vt-context-menu--link-content submenu-label"},St={__name:"ContextMenu",props:{e:{type:Object,default:()=>({})},row:{type:Object,default:()=>({})},menuConfig:{type:Object,default:()=>({body:{}})}},emits:["close","menuClick"],setup(n,{emit:t}){const o=t,a=n,i=e.computed(()=>{var O,A;return{left:`${(O=a.e)==null?void 0:O.pageX}px`,top:`${(A=a.e)==null?void 0:A.pageY}px`}}),s=e.ref([]),p=e.ref(null);let m=null;const y=e.ref(),c=(O,A,f)=>{if(O.children&&O.children.length>0){A&&A.preventDefault()&&A.stopPropagation();return}O.disabled||(f?o("menuClick",{...O,parent:f.code},a.row):o("menuClick",O,a.row)),A&&A.preventDefault()&&A.stopPropagation()},S=O=>{let A=O.target;for(;A&&A!=y.value;)A=A.parentNode;A!=y.value&&o("close")},k=(O,A)=>{O.currentTarget.classList.add("link--active"),m&&(clearTimeout(m),m=null),A.children&&A.children.length>0?p.value=A.code:m=setTimeout(()=>{p.value=null},100)},T=(O,A)=>{O.currentTarget.classList.remove("link--active"),A.children&&A.children.length>0&&(m=setTimeout(()=>{p.value===A.code&&(p.value=null)},300))},H=O=>{m&&(clearTimeout(m),m=null),O.currentTarget.classList.add("link--active")},K=O=>{O.currentTarget.classList.remove("link--active")},B=O=>{const A=O.code||"",f=(O.name||"").toLowerCase(),I={"add-current":E.Navigation,"add-next":E.ArrowDown,"add-child":E.PlusCircle,paste:E.Clipboard,delete:E.Trash2,copy:E.Copy,cut:E.Move,edit:E.Edit,export_part_section:E.Layers,export_part_chapter:E.FileDown,export_full:E.Download,pdf:E.FileText,word:E.Type,excel:E.Grid,txt:E.FileText,view:E.Eye,preview:E.Eye,expand:E.Plus,collapse:E.Minus,"sort-asc":E.SortAsc,"sort-desc":E.SortDesc,filter:E.Filter,search:E.Search,permission:E.ShieldCheck,share:E.Share,lock:E.Lock,unlock:E.Globe,info:E.Info,settings:E.Settings,history:E.History,refresh:E.RotateCcw,save:E.Save,upload:E.Upload,download:E.Download,more:E.MoreHorizontal};return I[A]?I[A]:f.includes("添加")||f.includes("add")?f.includes("当前")||f.includes("current")?E.Navigation:f.includes("下")||f.includes("next")?E.ArrowDown:f.includes("子")||f.includes("child")?E.PlusCircle:E.Plus:f.includes("导出")||f.includes("export")?f.includes("节")||f.includes("section")?E.Layers:f.includes("章")||f.includes("chapter")?E.FileDown:E.Download:f.includes("粘贴")||f.includes("paste")?E.Clipboard:f.includes("删除")||f.includes("delete")?E.Trash2:f.includes("pdf")?E.FileText:f.includes("word")?E.Type:E.MoreHorizontal};return e.onMounted(()=>{var O,A,f,I,L,M,W;(O=a.menuConfig)!=null&&O.visibleMethod&&typeof((A=a.menuConfig)==null?void 0:A.visibleMethod)=="function"&&((L=a.menuConfig)==null||L.visibleMethod({options:(I=(f=a.menuConfig)==null?void 0:f.body)==null?void 0:I.options,row:a.row})),s.value=(((W=(M=a.menuConfig)==null?void 0:M.body)==null?void 0:W.options)||[]).flat(),document.addEventListener("click",S,!0)}),e.onUnmounted(()=>{document.removeEventListener("click",S,!0)}),(O,A)=>(e.openBlock(),e.createElementBlock("div",{class:"we-vt-table--context-menu-wrapper virtual-table-menu modern-virtual-menu",ref_key:"contextMenuRef",ref:y,style:e.normalizeStyle([{display:"inline-block"},i.value])},[e.createElementVNode("ul",_t,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,f=>(e.openBlock(),e.createElementBlock("li",{class:e.normalizeClass({"link--disabled":f.disabled,"has-children":f.children&&f.children.length>0,"modern-menu-item":!0}),key:f.code,onMouseenter:I=>k(I,f),onMouseleave:I=>T(I,f)},[e.createElementVNode("a",{class:"we-vt-context-menu--link modern-menu-link",onClick:I=>c(f,I)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(B(f)),{size:16,class:"menu-icon"})),e.createElementVNode("span",Ct,e.toDisplayString(f.name),1),f.children&&f.children.length>0?(e.openBlock(),e.createBlock(e.unref(E.ChevronRight),{key:0,size:14,class:"submenu-arrow"})):e.createCommentVNode("",!0)],8,xt),f.children&&f.children.length>0&&p.value===f.code?(e.openBlock(),e.createElementBlock("ul",Et,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.children,I=>(e.openBlock(),e.createElementBlock("li",{key:I.code,class:e.normalizeClass({"link--disabled":I.disabled,"modern-submenu-item":!0}),onMouseenter:H,onMouseleave:K},[e.createElementVNode("a",{class:"we-vt-context-menu--link modern-submenu-link",onClick:L=>c(I,L,f)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(B(I)),{size:14,class:"submenu-icon"})),e.createElementVNode("span",Mt,e.toDisplayString(I.name),1)],8,Bt)],34))),128))])):e.createCommentVNode("",!0)],42,wt))),128))])],4))}},tt=Symbol("component_container");function Ft(n,t,o){const a=e.h(n,{...t},o),i=document.createElement("div");return document.body.appendChild(i),a[tt]=i,e.render(a,i),a.component}function It(n){var o;const t=n.vnode[tt];e.render(null,t),t!=null&&t.checkVisibility&&(t!=null&&t.checkVisibility())&&((o=document.body)==null||o.removeChild(t))}let nt;const Tt=n=>{nt=Ft(St,n,null)},At=function(n){const t=n.onClose;return n.onClose=()=>{t&&t.call(),It(nt)},Tt(n),n};function Pt(n,t,o){const a=(o==null?void 0:o.keyField)||(o==null?void 0:o.rowField)||"node_id",i=(o==null?void 0:o.parentField)||"parent_id",s=(o==null?void 0:o.parentField)||"order";if(!(n!=null&&n.length))return n;const p={};n.forEach(S=>{const k=S[i];p[k]||(p[k]=[]),p[k].push(S)});function m(S){const k=p[S]||[];k.sort((H,K)=>H[s]&&K[s]?H[s]-K[s]:0);const T=[];return k.forEach(H=>{T.push(H),T.push(...m(H[a]))}),T}let y=[];if(Array.isArray(t))y=t;else{const S=new Set(n.map(H=>H[a])),k=n.filter(H=>!S.has(H[i]));if(k.length===0)throw new Error("无法确定根节点:可能存在循环引用或数据不完整");const T={};k.forEach(H=>{const K=H[i];T[K]=(T[K]||0)+1}),y=Object.entries(T).map(([H])=>H)}let c=[];return y.forEach(S=>{c=c.concat(m(S))}),c}function ot(n,t,o){let a;for(;n&&n.nodeType&&n!==document;){if(n.className&&n.className.split&&n.className.split(" ").indexOf(t)>-1)return a=n,a;if(n===o)return null;n=n.parentNode}return a}function Lt(n){return typeof n=="function"||Object.prototype.toString.call(n)==="[object Object]"&&!e.isVNode(n)}const $t=e.defineComponent({name:"VirtualTable",props:{data:{type:Array,required:!0,default:()=>[]},rowConfig:{type:Object,default:()=>({keyField:"node_id"})},editConfig:{type:Object,default:null},treeConfig:{type:Object,default:null},menuConfig:{type:Object,default:()=>({body:{}})},showHeader:{type:Boolean,default:!0},rowClassName:{type:Function,default:null},pageConfig:{type:Object,default:()=>({enabled:!1,pageHeight:842,pageWidth:595,margin:40,gap:10,showPageHeader:!0,showPageBorder:!1,pageBorderPadding:5,pageBorderStyle:"1px solid #000",headerHeight:0,footerHeight:0,showPageNumber:!0})},pageData:{type:Object,default:null}},emits:["current-change","menu-click","edit-activated","edit-closed","scroll-end","selection-change"],setup(n,{emit:t,slots:o,expose:a}){var bt;const i=e.getCurrentInstance(),s=e.ref(),p=e.ref(!1),m=e.ref(null),y=e.ref(null),c=e.ref([]);let S=new Map;const k=new Map;e.ref(0);const T=e.ref([]);e.ref([]);const H=e.ref(new Set),K=e.ref(new Set),B=e.ref(null),O=2,A=new WeakMap,f=e.ref(null),I=e.ref(""),L=new Set,M=e.computed(()=>{try{return Array.isArray(c.value)?c.value:[]}catch{return[]}}),W=l=>{var g,h,u;if(!l)return 30;if(l.height)return l.height;const r=`${l.content_type}_${((g=l.content)==null?void 0:g.length)||0}_${((h=l.title)==null?void 0:h.length)||0}_${l._editing?1:0}`;if(A.has(l)){const w=A.get(l);if(w.key===r)return w.height}let d=30;switch(l.content_type){case"image":d=150;break;case"table-row":d=l.rowHeight||35;break;case"table":const x=((l.content||"").match(/<tr/g)||[]).length;d=Math.max(100,x*35+30);break;case"flowchart":d=200;break;default:{const b=(l.content||"").length,_=(l.title||"").length,C=b+_,P=((u=(l.content||"").match(/[一-龥]/g))==null?void 0:u.length)||0,$=((l.content||"").match(/[A-Za-z0-9]/g)||[]).length,F=C-P-$,z=P*12+$*7+F*4,q=Math.max(1,Math.ceil(z/760));d=Math.max(20,q*18),l._editing&&(d+=20);break}}return A.set(l,{key:r,height:d}),d},oe=e.computed(()=>{if(M.value.length===0)return 30;const l=M.value.slice(0,Math.min(100,M.value.length));if(l.length===0)return 30;const r=l.reduce((g,h)=>g+W(h),0)/l.length,d=Math.max(20,Math.floor(r*.6));return Math.min(d,60)});let N;const J=(l,r)=>{t("menu-click",{menu:l,row:r}),N==null||N.onClose(),N=null},pe=l=>{var d,g,h,u,w;if(!((h=(g=(d=n.menuConfig)==null?void 0:d.body)==null?void 0:g.options)!=null&&h.length))return;N==null||N.onClose(),N=null;let r=l.target;for(;r&&(r!=null&&r.getAttribute)&&!(r!=null&&r.getAttribute("data-id"))&&r!==((u=s.value)==null?void 0:u.$el);)r=r.parentNode;if((w=r==null?void 0:r.getAttribute)!=null&&w.call(r,"data-id")){const x=r.getAttribute("data-id"),b=_e(x);b&&(N=At({e:l,row:b,menuConfig:n.menuConfig,onMenuClick:J}),l.preventDefault(),l.stopPropagation())}},He=l=>{var d,g,h;if(!m.value)return;let r=l.target;for(;r&&(r!=null&&r.getAttribute)&&!(r!=null&&r.getAttribute("data-id"))&&r!==((d=s.value)==null?void 0:d.$el);)if(r=r.parentNode,r!=null&&r.classList&&["el-popper","ck-body-wrapper"].some(u=>r.classList.contains(u)))return;((g=r==null?void 0:r.getAttribute)==null?void 0:g.call(r,"data-id"))!=((h=m.value)==null?void 0:h.node_id)&&(m.value._editing=!1,t("edit-closed",{row:m.value,column:{},$table:i==null?void 0:i.exposed}),m.value=null)};((bt=n.editConfig)==null?void 0:bt.trigger)==="dblclick"&&e.watch(()=>m.value,l=>{document.removeEventListener("click",He,!0),l&&setTimeout(()=>{document.addEventListener("click",He,!0)},200)});const R=l=>JSON.stringify(l.map(r=>{var d;return{id:r[n.rowConfig.keyField],content:((d=r.content)==null?void 0:d.length)||0,type:r.content_type,editing:r._editing}})),le=()=>{if(!n.pageConfig.enabled){T.value=[{items:c.value,startIndex:0,endIndex:c.value.length}];return}if(n.pageData&&Object.keys(n.pageData).length){const l=[],r=n.rowConfig.keyField||"node_id",d=new Map;c.value.forEach(h=>{d.set(String(h[r]),h)}),Object.keys(n.pageData).sort((h,u)=>parseInt(h)-parseInt(u)).forEach(h=>{const u=n.pageData[h],w=[];u.forEach(x=>{const b=d.get(String(x));b&&w.push(b)}),w.length>0&&l.push({items:w,pageNumber:parseInt(h),height:w.reduce((x,b)=>x+W(b),0)})}),T.value=l}else{const{pageHeight:l,margin:r,headerHeight:d=0}=n.pageConfig,h=Math.max(100,l-r*2-d-20),u=[];let w=[],x=0,b=0,_=1;c.value.forEach((C,P)=>{const $=W(C);(C.layer||0)<=2&&w.length>0?(u.push({items:[...w],startIndex:b,endIndex:P,height:x,pageNumber:_++}),w=[C],x=$,b=P):x+$>h&&w.length>0?(u.push({items:[...w],startIndex:b,endIndex:P,height:x,pageNumber:_++}),w=[C],x=Math.min($,h),b=P):(w.push(C),x+=$)}),w.length>0&&u.push({items:w,startIndex:b,endIndex:c.value.length,height:x,pageNumber:_}),T.value=u}},ce=()=>{try{const l=Array.isArray(n.data)?n.data:[],r=R(l);if(!(r!==I.value)&&c.value.length>0)return;I.value=r;const g=(n.treeConfig?Pt(l,void 0,n.treeConfig):l).map((u,w)=>{const x=u[n.rowConfig.keyField],b=k.get(x);if(!b||b.content!==u.content||b.content_type!==u.content_type){L.add(x);const _={...u,index:w,_editing:u._editing||!1,_original:(b==null?void 0:b._original)||{...u}};return k.set(x,_),_}return b.index=w,b});c.value=g,le();const h=new Set(g.map(u=>u[n.rowConfig.keyField]));for(const[u]of k)h.has(u)||(k.delete(u),L.delete(u))}catch{c.value=[],T.value=[],k.clear(),L.clear()}};e.watch(()=>n.data,(l,r)=>{try{if(!Array.isArray(l))return;e.nextTick(()=>{if(ce(),n.pageConfig.enabled){K.value.clear(),H.value.clear();for(let d=0;d<Math.min(3,T.value.length);d++)K.value.add(d);e.nextTick(()=>{ae()})}})}catch{}},{deep:!1,immediate:!1}),e.watch(()=>n.pageData,()=>{if(n.pageConfig.enabled){le(),K.value.clear(),H.value.clear();for(let l=0;l<Math.min(3,T.value.length);l++)K.value.add(l);e.nextTick(()=>{ae()})}},{deep:!0}),e.watch(()=>n.pageConfig,()=>{if(n.pageConfig.enabled){le(),K.value.clear(),H.value.clear();for(let l=0;l<Math.min(3,T.value.length);l++)K.value.add(l);e.nextTick(()=>{ae()})}},{deep:!0}),e.watch(y,()=>t("current-change",{row:y.value}));let me=null;const Oe=()=>{window.ResizeObserver&&(me=new ResizeObserver(l=>{var r,d;for(const g of l){const h=(r=g.target.dataset)==null?void 0:r.id;if(!h)continue;const u=_e(h);if(!u)continue;const w=g.contentRect.height,x=((d=A.get(u))==null?void 0:d.height)||0;if(Math.abs(x-w)>5){const b=A.get(u)||{};A.set(u,{...b,height:w}),requestAnimationFrame(()=>{var C;const _=g.target.__vueParentComponent;(C=_==null?void 0:_.proxy)!=null&&C.updateSize&&_.proxy.updateSize()})}}}),e.nextTick(()=>{var d;const l=(d=s.value)==null?void 0:d.$el;if(!l)return;l.querySelectorAll("[data-id]").forEach(g=>{g.dataset.id&&me.observe(g)})}))},Ne=()=>{f.value&&(f.value.disconnect(),f.value=null),me&&(me.disconnect(),me=null)},ae=()=>{n.pageConfig.enabled&&(B.value&&B.value.disconnect(),B.value=new IntersectionObserver(l=>{l.forEach(r=>{const d=parseInt(r.target.dataset.pageIndex);if(r.isIntersecting){H.value.add(d);for(let g=Math.max(0,d-O);g<=Math.min(T.value.length-1,d+O);g++)K.value.add(g)}else H.value.delete(d),setTimeout(()=>{H.value.has(d)||Array.from(H.value).some(h=>Math.abs(h-d)<=O*2)||K.value.delete(d)},3e3)})},{root:null,rootMargin:"100px",threshold:.01}),e.nextTick(()=>{const l=document.querySelector(".a4-pages-container");l&&l.querySelectorAll(".a4-page-placeholder").forEach(d=>{B.value.observe(d)})}))};e.onMounted(()=>{ce(),e.nextTick(()=>{var l;if(Oe(),ee.setup(),ae(),((l=n.editConfig)==null?void 0:l.trigger)==="contenteditable"&&(document.addEventListener("selectionchange",te),document.addEventListener("mouseup",be)),n.pageConfig.enabled)for(let r=0;r<Math.min(3,T.value.length);r++)K.value.add(r)}),p.value=!0}),e.onUnmounted(()=>{var l;Ne(),ee.cleanup(),B.value&&(B.value.disconnect(),B.value=null),((l=n.editConfig)==null?void 0:l.trigger)==="contenteditable"&&(document.removeEventListener("selectionchange",te),document.removeEventListener("mouseup",be)),ke&&clearTimeout(ke),S=new Map,k.clear(),K.value.clear(),H.value.clear()});const ee={handlers:new Map,setup(){e.nextTick(()=>{var r;const l=(r=s.value)==null?void 0:r.$el;l&&(l.addEventListener("click",this.handleClick.bind(this),{passive:!0}),l.addEventListener("dblclick",this.handleDblClick.bind(this),{passive:!0}))})},handleClick(l){const r=l.target.closest("[data-id]");if(!r)return;const d=r.dataset.id,g=_e(d);g&&Ve(g)},handleDblClick(l){var h;if(!((h=n.editConfig)!=null&&h.trigger)==="dblclick")return;const r=l.target.closest("[data-id]");if(!r)return;const d=r.dataset.id,g=_e(d);g&&Le(g)},cleanup(){var r,d;const l=(d=(r=s.value)==null?void 0:r.$el)==null?void 0:d.querySelector(".virtual-table-wrapper");l&&(l.removeEventListener("click",this.handleClick),l.removeEventListener("dblclick",this.handleDblClick))}},ue=l=>{Ve(l)},ye=l=>Le(l);let ge=null,Y;const ie=({row:l,column:r},d,g)=>{var w,x;const h=g||d.target,u=ot(h,"virtual-table-cell",(w=s.value)==null?void 0:w.$el);ge===u&&Y&&(clearTimeout(Y),ge=null),((x=m.value)==null?void 0:x[n.rowConfig.keyField])!=(l==null?void 0:l[n.rowConfig.keyField])&&setTimeout(()=>{var _,C;m.value=l;let b=(_=h==null?void 0:h.getAttribute)==null?void 0:_.call(h,"field");if(!b){try{const P=document.getSelection();let $=P==null?void 0:P.anchorNode;$&&$.nodeType===3&&($=$.parentElement);const F=(C=$==null?void 0:$.closest)==null?void 0:C.call($,"[field]");F&&(b=F.getAttribute("field"))}catch{}if(!b&&(d!=null&&d.composedPath)){for(const P of d.composedPath())if(P!=null&&P.getAttribute&&P.getAttribute("field")){b=P.getAttribute("field");break}}}t("edit-activated",{row:l,column:{...r,field:b},$table:i==null?void 0:i.exposed})},200)},de=({row:l,column:r},d,g)=>{var u;const h=g||d.target;ge=ot(h,"virtual-table-cell",(u=s.value)==null?void 0:u.$el),Y&&clearTimeout(Y),Y=setTimeout(()=>{var b,_,C,P,$;const w=l.content_type;let x=(b=h==null?void 0:h.getAttribute)==null?void 0:b.call(h,"field");if(!x){try{const F=document.getSelection();let z=F==null?void 0:F.anchorNode;z&&z.nodeType===3&&(z=z.parentElement);const q=(_=z==null?void 0:z.closest)==null?void 0:_.call(z,"[field]");q&&(x=q.getAttribute("field"))}catch{}if(!x&&(d!=null&&d.composedPath)){for(const F of d.composedPath())if(F!=null&&F.getAttribute&&F.getAttribute("field")){x=F.getAttribute("field");break}}}if(w!=="table"){if(w==="text"){let F=null,z=null;if((C=h==null?void 0:h.getAttribute)!=null&&C.call(h,"field")?F=h:(P=h==null?void 0:h.closest)!=null&&P.call(h,"[field]")&&(F=h.closest("[field]")),F&&(z=F.textContent),x&&z!==void 0&&z!==null){z=z.trim();const q=(($=l[x])==null?void 0:$.trim())||"";z!==q&&(l[x]=z)}}}t("edit-closed",{row:l,column:{...r,field:x},$table:i==null?void 0:i.exposed})},50)};let D=null,ke=null;const he=l=>{var r;((r=n.editConfig)==null?void 0:r.trigger)==="contenteditable"&&G("focusin",l)},Z=l=>{var r,d,g,h,u;if(((r=n.editConfig)==null?void 0:r.trigger)==="contenteditable")if(D!=null&&D.cellEl){let w=D.fieldEl;!w&&D.field&&(w=(g=(d=D.cellEl)==null?void 0:d.querySelector)==null?void 0:g.call(d,`[field="${D.field}"]`)),w||(w=((u=(h=D.cellEl).querySelector)==null?void 0:u.call(h,"[field]"))||D.cellEl),de(D,{target:w},w),D=null}else G("focusout",l)},G=(l,r)=>{var d,g,h,u,w,x;try{const b=document.getSelection();let _=b==null?void 0:b.anchorNode;_&&_.nodeType===3&&(_=_.parentElement);const C=(d=_==null?void 0:_.closest)==null?void 0:d.call(_,".virtual-table-cell"),P=(g=_==null?void 0:_.closest)==null?void 0:g.call(_,".virtual-table-row");if(!C||!P)return;const $=P.getAttribute("data-id"),F=C.getAttribute("data-prop"),z=_e($),q=Fe.value.find(ne=>`${ne.prop}`==`${F}`)||{},V=((h=_==null?void 0:_.closest)==null?void 0:h.call(_,"[field]"))||null,j=((u=V==null?void 0:V.getAttribute)==null?void 0:u.call(V,"field"))||void 0;l==="focusin"?(D={row:z,column:q,cellEl:C,rowEl:P,fieldEl:V,field:j},ie({row:z,column:q},r,V||((w=_==null?void 0:_.closest)==null?void 0:w.call(_,"[field]")))):de({row:z,column:q},r,V||((x=_==null?void 0:_.closest)==null?void 0:x.call(_,"[field]")))}catch{}},te=()=>{var l;((l=n.editConfig)==null?void 0:l.trigger)==="contenteditable"&&(ke&&clearTimeout(ke),ke=setTimeout(()=>{var r,d,g,h,u,w,x,b,_,C,P,$,F,z;try{const q=document.getSelection();if(q.rangeCount===0)return;const V=q.getRangeAt(0);let j=V.startContainer;j.nodeType===3&&(j=j.parentElement);const ne=(r=j==null?void 0:j.closest)==null?void 0:r.call(j,".virtual-table-cell"),Q=(d=j==null?void 0:j.closest)==null?void 0:d.call(j,".virtual-table-row");if(!ne||!Q)return;const Ie=Q.getAttribute("data-id"),Te=ne.getAttribute("data-prop"),fe=_e(Ie),re=Fe.value.find(U=>`${U.prop}`==`${Te}`)||{};if(!D||((g=D.row)==null?void 0:g[n.rowConfig.keyField])!==(fe==null?void 0:fe[n.rowConfig.keyField])||((h=D.column)==null?void 0:h.prop)!==(re==null?void 0:re.prop)){if(D){let U=D.fieldEl;!U&&D.field&&(U=(w=(u=D.cellEl)==null?void 0:u.querySelector)==null?void 0:w.call(u,`[field="${D.field}"]`)),U||(U=((b=(x=D.cellEl)==null?void 0:x.querySelector)==null?void 0:b.call(x,"[field]"))||D.cellEl),de(D,{target:U},U)}D={row:fe,column:re,cellEl:ne,rowEl:Q,fieldEl:((_=j==null?void 0:j.closest)==null?void 0:_.call(j,"[field]"))||null,field:(($=(P=((C=j==null?void 0:j.closest)==null?void 0:C.call(j,"[field]"))||null)==null?void 0:P.getAttribute)==null?void 0:$.call(P,"field"))||void 0},ie({row:fe,column:re},{target:ne},ne)}if(q.toString()){const U=V.endContainer.nodeType===3?V.endContainer.parentElement:V.endContainer,Ee=(F=U==null?void 0:U.closest)==null?void 0:F.call(U,".virtual-table-cell"),qe=(z=U==null?void 0:U.closest)==null?void 0:z.call(U,".virtual-table-row")}}catch{}},50))},be=()=>{var l;((l=n.editConfig)==null?void 0:l.trigger)==="contenteditable"&&setTimeout(()=>{var g,h,u,w;const r=document.getSelection();if(!r)return;const d=r.toString();if(d){const x=r.rangeCount>0?r.getRangeAt(0):null;let b=null,_=null;try{if(x){let C=x.startContainer;(C==null?void 0:C.nodeType)===3&&(C=C.parentElement);const P=(g=C==null?void 0:C.closest)==null?void 0:g.call(C,".virtual-table-cell"),$=(h=C==null?void 0:C.closest)==null?void 0:h.call(C,".virtual-table-row");b=P&&$?{rowId:$.getAttribute("data-id"),prop:P.getAttribute("data-prop")}:null;let F=x.endContainer;(F==null?void 0:F.nodeType)===3&&(F=F.parentElement);const z=(u=F==null?void 0:F.closest)==null?void 0:u.call(F,".virtual-table-cell"),q=(w=F==null?void 0:F.closest)==null?void 0:w.call(F,".virtual-table-row");_=z&&q?{rowId:q.getAttribute("data-id"),prop:z.getAttribute("data-prop")}:null}}catch{}t("selection-change",{text:d,selection:r,range:x,start:b,end:_})}},10)},Ce=l=>(l==null?void 0:l._editing)===!0,Qe=l=>l!=null&&l.parent_id?S.get(l.parent_id):null,Kn=l=>{var d;const r=c.value.findIndex(g=>g[n.rowConfig.keyField]==l[n.rowConfig.keyField]);return r<1?null:((d=c.value[r-1])==null?void 0:d.layer)===l.layer?c.value[r-1]:null},Un=l=>{const r=c.value.findIndex(d=>d[n.rowConfig.keyField]==l[n.rowConfig.keyField]);return r>=c.value.length-1?null:c.value[r+1]},_e=l=>{if(!l)return null;let r=k.get(l);return r||(typeof l=="number"?k.get(`${l}`):typeof l=="string"&&/^\d+$/.test(l)?k.get(Number(l)):null)};let ve=null;const qn=l=>{ve&&cancelAnimationFrame(ve),ve=requestAnimationFrame(()=>{var g;const r=n.rowConfig.keyField,d=l[r];if(n.pageConfig.enabled){let h=-1;for(let u=0;u<T.value.length;u++)if(T.value[u].items.some(b=>b[r]===d)){h=u;break}if(h!==-1){for(let u=Math.max(0,h-1);u<=Math.min(T.value.length-1,h+1);u++)K.value.has(u)||K.value.add(u);e.nextTick(()=>{const u=document.querySelector(".a4-pages-container");if(!u)return;const w=(x=0)=>{const b=u.querySelector(`[data-id="${d}"]`);if(b){let _=0,C=b;for(;C&&C!==u;)_+=C.offsetTop,C=C.offsetParent;const P=u.clientHeight;let $=_-P*.3;$=Math.max(0,$);const F=u.scrollTop,z=Math.abs($-F),q=V=>{const j=u.scrollTop,ne=V-j,Q=Math.min(800,Math.max(300,z*.5)),Ie=performance.now(),Te=re=>re<.5?4*re*re*re:1-Math.pow(-2*re+2,3)/2,fe=re=>{const $e=re-Ie,U=Math.min($e/Q,1),Ee=Te(U),qe=j+ne*Ee;u.scrollTop=qe,U<1?requestAnimationFrame(fe):setTimeout(()=>{u.scrollTop=V},50)};requestAnimationFrame(fe)};z>3e3?u.scrollTo({top:$,behavior:"instant"}):q($),b.classList.add("row--highlight"),setTimeout(()=>{b.classList.remove("row--highlight")},1500)}else x<10&&setTimeout(()=>w(x+1),150)};setTimeout(w,200)})}}else{const h=c.value.findIndex(u=>u[r]===d);h!==-1&&((g=s.value)!=null&&g.scrollToItem)&&s.value.scrollToItem(h)}ve=null})},Ve=l=>{if(l){if(!p.value){setTimeout(()=>Ve(l),200);return}y.value=l,y.value!==m.value&&m.value&&(m.value._editing=!1,setTimeout(()=>{m.value=null},200))}},Le=(l,r)=>new Promise(d=>{var g,h;if(!((g=n==null?void 0:n.editConfig)!=null&&g.beforeEditMethod&&typeof((h=n==null?void 0:n.editConfig)==null?void 0:h.beforeEditMethod)=="function"&&!n.editConfig.beforeEditMethod({row:l}))){if(!l||!p.value){setTimeout(()=>Le(l),200);return}l!==m.value&&(c.value.forEach(u=>{u._editing&&t("edit-closed",{row:u,column:{field:r},$table:i==null?void 0:i.exposed}),u._editing=!1}),l._editing=!0,setTimeout(()=>{m.value=l,t("edit-activated",{row:l,column:{field:r},$table:i==null?void 0:i.exposed}),d(!0)}))}}),Wn=l=>Le(l),et=()=>{if(le(),n.pageConfig.enabled){const l=Array.from(H.value);if(l.length>0){const r=Math.min(...l);for(let d=Math.max(0,r-1);d<=Math.min(T.value.length-1,r+2);d++)K.value.add(d)}else for(let r=0;r<Math.min(3,T.value.length);r++)K.value.add(r);e.nextTick(()=>{ae()})}e.nextTick(()=>{!n.pageConfig.enabled&&s.value&&s.value.$forceUpdate&&s.value.$forceUpdate()})},Gn=(l,r)=>new Promise(d=>{let g=-1;if(r==-1){const h=_e(l.parent_id);for(g=c.value.findIndex(u=>u[n.rowConfig.keyField]==h[n.rowConfig.keyField])+1;c.value[g].parent_id==h[n.rowConfig.keyField];)g+=1}else g=c.value.findIndex(h=>h[n.rowConfig.keyField]==r[n.rowConfig.keyField]);S.set(l.node_id,l),k.set(l[n.rowConfig.keyField],l),c.value.splice(g,0,l),et(),d({row:l})}),Jn=(l,r)=>new Promise(d=>{const g=c.value.findIndex(h=>h[n.rowConfig.keyField]==r[n.rowConfig.keyField])+1;S.set(l.node_id,l),k.set(l[n.rowConfig.keyField],l),c.value.splice(g,0,l),et(),d({row:l})}),pt=l=>{const r=c.value.findIndex(d=>d[n.rowConfig.keyField]==l[n.rowConfig.keyField]||d===l);if(r>-1){const d=l[n.rowConfig.keyField];S.delete(l.node_id),k.delete(d),c.value.splice(r,1),et()}},Xn=(l,r)=>{if(!l||!l[n.rowConfig.keyField])return!1;const d=l._original;return d?r?l[r]!==d[r]:Object.keys(d).some(g=>d[g]!==l[g]):!1},Yn=l=>l&&l[n.rowConfig.keyField]&&!l._original,Zn=(l,r)=>{l&&l[n.rowConfig.keyField]&&(r&&Object.assign(l,r),l._original={...l,_editing:void 0,_X_ROW_CHILD:void 0,_original:void 0})},Qn=l=>{if(l&&l[n.rowConfig.keyField]){const r=_e(l[n.rowConfig.keyField]);r._original?Object.assign(r,r._original):pt(r)}},eo=()=>{},to=()=>{y.value={}},mt=l=>{var d,g,h;let r=c.value.findIndex(u=>u[n.rowConfig.keyField]==l[n.rowConfig.keyField]);if(r>-1&&n.treeConfig){const u=((d=n.treeConfig)==null?void 0:d.keyField)||((g=n.treeConfig)==null?void 0:g.rowField)||"node_id",w=((h=n.treeConfig)==null?void 0:h.parentField)||"parent_id",x=[],b=new Map;b.set(l[u],!0);for(let _=r+1;_<c.value.length;_++){const C=c.value[_];if(C&&b.has(C[w]))x.push(C),b.set(C[u]);else break}return x}return[]};a({isEditByRow:Ce,getParentRow:Qe,getSiblingRow:Kn,getNextRow:Un,getRowById:_e,scrollToRow:qn,setCurrentRow:Ve,setEditRow:Le,setEditCell:Wn,insertAt:Gn,insertNextAt:Jn,isUpdateByRow:Xn,isInsertByRow:Yn,reloadRow:Zn,revertData:Qn,remove:pt,setAllTreeExpand:eo,clearCurrentRow:to,getAllChilds:mt});const Fe=e.computed(()=>o.default().filter(l=>{var r;return((r=l.type)==null?void 0:r.name)==="VirtualTableColumn"}).map(l=>{var r,d,g;return{prop:(r=l.props)==null?void 0:r.prop,title:(d=l.props)==null?void 0:d.title,width:(g=l.props)==null?void 0:g.width,slots:l.children}})),je=l=>{try{return l===0?{width:"0px"}:l?{flex:/^\d+$/.test(l)?`0 0 ${l}px`:`0 0 ${l}`}:{flex:"1 1 100%"}}catch(r){return console.warn("[VirtualTable] computeColumnWidth error:",r),{flex:"1 1 100%"}}},yt=e.computed(()=>{var l;return(l=n.treeConfig)!=null&&l.childCurrent&&y.value?mt(y.value).map(r=>r[n.rowConfig.keyField]):[]}),kt=e.ref({viewStartIndex:0,viewEndIndex:0,visibleStartIndex:0,visibleEndIndex:0});let Ke=null,Ue=null;const no=(l,r)=>{Ke&&cancelAnimationFrame(Ke),Ke=requestAnimationFrame(()=>{t("scroll-end",{...kt.value}),Ke=null})},oo=(l,r,d,g)=>{Ue&&cancelAnimationFrame(Ue),Ue=requestAnimationFrame(()=>{kt.value={viewStartIndex:l,viewEndIndex:r,visibleStartIndex:d,visibleEndIndex:g},Ue=null})},lo=(l,r)=>{var F,z,q;const{pageHeight:d,margin:g,showPageBorder:h,pageBorderPadding:u,pageBorderStyle:w,showPageHeader:x,headerHeight:b=0,footerHeight:_=0,showPageNumber:C}=n.pageConfig,P=l.pageNumber||r+1,$=(F=l.items)==null?void 0:F.some(V=>V._isCover);return K.value.has(r)?e.createVNode(e.Fragment,null,[x!==!1&&(o["page-header"]||b>0)&&!$?e.createVNode("div",{class:"a4-page-header",style:{minHeight:`${Math.max(b,1)}px`}},[(z=o["page-header"])==null?void 0:z.call(o,{pageNumber:P,pageIndex:r,totalPages:T.value.length,isCoverPage:$})]):null,r===0&&n.showHeader?e.createVNode("div",{class:"a4-table-header"},[e.createVNode("div",{class:"virtual-table-header we-vt-table--header we-vt-table--header-wrapper"},[Fe.value.map(V=>{var j,ne,Q;return e.createVNode("div",{class:"we-vt-header--column",key:V.prop,style:je(V.width)},[e.createVNode("div",{class:"we-vt-cell"},[(j=V.slots)!=null&&j.header?(Q=(ne=V.slots)==null?void 0:ne.header)==null?void 0:Q.call(ne,{column:V}):V.title])])})])]):null,e.createVNode("div",{class:"a4-page-content",style:{...h?{border:w,padding:`${u}px`}:{}}},[l.items.map(V=>{var j,ne;return e.createVNode("div",{key:V[n.rowConfig.keyField],"data-id":V[n.rowConfig.keyField],class:{"virtual-table-row":!0,"we-vt-body--row":!0,"row--current":V[n.rowConfig.keyField]===((j=y.value)==null?void 0:j[n.rowConfig.keyField])||((ne=n.treeConfig)==null?void 0:ne.childCurrent)&&yt.value.includes(V[n.rowConfig.keyField])},style:{width:"100%"},onClick:()=>ue(V),onDblclick:()=>ye(V)},[Fe.value.map(Q=>{var Ie,Te,fe,re,$e,U,Ee;return e.createVNode("div",{key:Q.prop,class:"virtual-table-cell we-vt-cell",style:je(Q.width),"data-prop":Q.prop},[V._editing&&((Ie=n.editConfig)==null?void 0:Ie.trigger)==="dblclick"?((Te=Q.slots)==null?void 0:Te.edit)&&((re=(fe=Q.slots)==null?void 0:fe.edit)==null?void 0:re.call(fe,{row:V,column:Q})):(($e=Q.slots)==null?void 0:$e.default)&&((Ee=(U=Q.slots)==null?void 0:U.default)==null?void 0:Ee.call(U,{row:V,column:Q}))])})])})]),o["page-footer"]?e.createVNode("div",{class:"a4-page-footer"},[(q=o["page-footer"])==null?void 0:q.call(o,{pageNumber:P,pageIndex:r,totalPages:T.value.length})]):e.createVNode("div",{class:"a4-page-footer",contenteditable:"false"},[C!==!1?e.createVNode("span",{class:"page-number",contenteditable:"false"},[e.createTextVNode("第"),P,e.createTextVNode("页 / 共"),T.value.length,e.createTextVNode("页")]):null])]):e.createVNode("div",{class:"a4-page-loading"},[e.createVNode("div",{class:"loading-spinner"},null),e.createVNode("div",{class:"loading-text"},[e.createTextVNode("加载中...")])])},ao=()=>{var w;const{pageHeight:l,pageWidth:r,margin:d,gap:g,showPageBorder:h,pageBorderPadding:u}=n.pageConfig;return e.createVNode("div",{class:"virtual-table we-vt-table we-vt-table--render-default border--none"},[e.createVNode("div",{class:"a4-pages-container",contenteditable:((w=n.editConfig)==null?void 0:w.trigger)==="contenteditable"?"true":void 0,onContextmenu:pe,onFocusin:he,onFocusout:Z},[T.value.map((x,b)=>{const _=K.value.has(b);return e.createVNode("div",{key:`page-${b}`,class:_?"a4-page":"a4-page-placeholder","data-page-index":b,style:{width:`${r}px`,minHeight:`${l}px`,marginBottom:`${g}px`,padding:_?`${h?d-u:d}px`:"0",paddingBottom:_?"12px":"0",boxSizing:"border-box",position:"relative"}},[lo(x,b)])})])])},io=()=>{var l;return e.createVNode("div",{class:"virtual-table we-vt-table we-vt-table--render-default border--none"},[n.showHeader?e.createVNode("div",{class:"virtual-table-header we-vt-table--header we-vt-table--header-wrapper"},[Fe.value.map(r=>{var d,g,h;return e.createVNode("div",{class:"we-vt-header--column",key:r.prop,style:je(r.width)},[e.createVNode("div",{class:"we-vt-cell"},[(d=r.slots)!=null&&d.header?(h=(g=r.slots)==null?void 0:g.header)==null?void 0:h.call(g,{column:r}):r.title]),e.createVNode("div",{class:"we-vt-resizable is--line"},null)])})]):void 0,e.createVNode(xe.DynamicScroller,{ref:s,items:M.value,minItemSize:oe.value,keyField:n.rowConfig.keyField,emitUpdate:!1,buffer:300,class:"virtual-table-wrapper",contenteditable:((l=n.editConfig)==null?void 0:l.trigger)==="contenteditable"?"true":void 0,onContextmenu:pe,onScrollend:no,onUpdate:oo,onFocusin:he,onFocusout:Z},{default:({item:r,index:d,active:g})=>{var u,w,x;let h;return e.createVNode(xe.DynamicScrollerItem,{key:r[n.rowConfig.keyField],item:r,active:g,sizeDependencies:[(u=r.content)==null?void 0:u.length,r._editing,r.content_type],"data-id":r[n.rowConfig.keyField],"data-index":d,"data-active":g,class:{"virtual-table-row":!0,"we-vt-body--row":!0,"row--current":r[n.rowConfig.keyField]===((w=y.value)==null?void 0:w[n.rowConfig.keyField])||((x=n.treeConfig)==null?void 0:x.childCurrent)&&yt.value.includes(r[n.rowConfig.keyField])}},Lt(h=Fe.value.map(b=>{var _,C,P,$,F,z,q;return e.createVNode("div",{key:b.prop,class:"virtual-table-cell we-vt-cell",style:je(b.width),"data-prop":b.prop},[r._editing&&((_=n.editConfig)==null?void 0:_.trigger)==="dblclick"?((C=b.slots)==null?void 0:C.edit)&&(($=(P=b.slots)==null?void 0:P.edit)==null?void 0:$.call(P,{row:r,column:b})):((F=b.slots)==null?void 0:F.default)&&((q=(z=b.slots)==null?void 0:z.default)==null?void 0:q.call(z,{row:r,column:b}))])}))?h:{default:()=>[h]})}})])};return()=>n.pageConfig.enabled?ao():io()}}),Be=(n,t)=>{const o=n.__vccOpts||n;for(const[a,i]of t)o[a]=i;return o},zt=Be($t,[["__scopeId","data-v-885af7f2"]]),Rt={name:"VirtualTableColumn",props:{prop:String,label:String,width:[String,Number]}};function Dt(n,t,o,a,i,s){return e.renderSlot(n.$slots,"default")}const Ht=Be(Rt,[["render",Dt]]),Ot={class:"catalog-node"},Nt=["title"],vt={class:"catalog-node__text"},Vt={key:0,class:"catalog-node__children"},jt=Be({__name:"CatalogNode",props:{item:{type:Object,required:!0},depth:{type:Number,default:0},activeId:{type:String,default:""}},emits:["navigate"],setup(n,{emit:t}){const o=n,a=t,i=e.ref(!0),s=e.computed(()=>o.item.children&&o.item.children.length>0);function p(m){m.stopPropagation(),i.value=!i.value}return(m,y)=>{const c=e.resolveComponent("CatalogNode",!0);return e.openBlock(),e.createElementBlock("div",Ot,[e.createElementVNode("div",{class:e.normalizeClass(["catalog-node__label",{"is-active":n.activeId===n.item.nodeId}]),style:e.normalizeStyle({paddingLeft:10+n.depth*14+"px"}),title:n.item.name,onClick:y[0]||(y[0]=S=>a("navigate",n.item))},[e.createElementVNode("span",{class:"catalog-node__toggle",onClick:p},[s.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.value?e.unref(E.ChevronDown):e.unref(E.ChevronRight)),{key:0,size:14})):e.createCommentVNode("",!0)]),e.createElementVNode("span",vt,e.toDisplayString(n.item.name||"(无标题)"),1)],14,Nt),s.value&&i.value?(e.openBlock(),e.createElementBlock("div",Vt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.item.children,S=>(e.openBlock(),e.createBlock(c,{key:S.nodeId,item:S,depth:n.depth+1,"active-id":n.activeId,onNavigate:y[1]||(y[1]=k=>a("navigate",k))},null,8,["item","depth","active-id"]))),128))])):e.createCommentVNode("",!0)])}}},[["__scopeId","data-v-ac882917"]]),Kt={key:0,class:"catalog catalog--collapsed"},Ut={key:1,class:"catalog"},qt={class:"catalog__header"},Wt={class:"catalog__title"},Gt={class:"catalog__body"},Jt={key:0,class:"catalog__empty"},Xt=Be({__name:"index",props:{items:{type:Array,default:()=>[]}},emits:["navigate"],setup(n,{emit:t}){const o=t,a=e.ref(!1),i=e.ref("");function s(p){i.value=p.nodeId,o("navigate",p)}return(p,m)=>a.value?(e.openBlock(),e.createElementBlock("div",Kt,[e.createElementVNode("button",{class:"catalog__icon-btn",title:"展开目录",onClick:m[0]||(m[0]=y=>a.value=!1)},[e.createVNode(e.unref(E.PanelLeftOpen),{size:18})])])):(e.openBlock(),e.createElementBlock("div",Ut,[e.createElementVNode("div",qt,[e.createElementVNode("span",Wt,[e.createVNode(e.unref(E.ListTree),{size:16}),m[2]||(m[2]=e.createTextVNode(" 目录 ",-1))]),e.createElementVNode("button",{class:"catalog__icon-btn",title:"收起目录",onClick:m[1]||(m[1]=y=>a.value=!0)},[e.createVNode(e.unref(E.PanelLeftClose),{size:18})])]),e.createElementVNode("div",Gt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.items,y=>(e.openBlock(),e.createBlock(jt,{key:y.nodeId,item:y,"active-id":i.value,onNavigate:s},null,8,["item","active-id"]))),128)),n.items.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Jt," 暂无目录 "))])]))}},[["__scopeId","data-v-8becafa1"]]),Yt={first:1,second:2,third:3,fourth:4,fifth:5,sixth:6};function Zt(n){return n.blockType!=="title"||!n.level?0:Yt[n.level]||1}function Qt(n){const t=[];for(const i of n||[]){const s=Zt(i);s&&t.push({id:i.node_id,nodeId:i.node_id,name:(i.content||"").trim(),level:s,children:[]})}if(!t.length)return[];const o=(i,s)=>{const p=s.children[s.children.length-1];p&&i.level>p.level?o(i,p):s.children.push(i)},a=[];for(const i of t){const s=a[a.length-1];s&&i.level>s.level?o(i,s):a.push(i)}return a}const en={first:0,second:1,third:2,fourth:3,fifth:4,sixth:5,seventh:6,eighth:7};function ze(n,t){let o="",a=n;const i=t?65:97;for(;a>0;){const s=(a-1)%26;o=String.fromCharCode(i+s)+o,a=Math.floor((a-1)/26)}return o}const lt=[n=>n.toString(),n=>ze(n,!0),n=>`(${n})`,n=>`(${ze(n,!1)})`,n=>`${n})`,n=>`${ze(n,!1)})`,n=>`<${n}>`,n=>`<${ze(n,!1)}>`];function tn(){const n=new Array(8).fill(0);return{next(t,o){const a=en[t];if(a==null)return"";n[a]++;for(let s=a+1;s<n.length;s++)n[s]=0;if(o!=null&&o!=="")return`${o} `;const i=lt[Math.min(a,lt.length-1)];return`${i(n[a])}. `}}}const Me=14,at=760,nn=756,on={left:"left",center:"center",right:"right",alignment:"justify",justify:"justify"};function it(n){const t=[];let o=!1;const a=i=>{if(o){if(i&&i.value!=null&&/^[\n200B]+$/.test(i.value)){t.push(i);return}o=!1,t.push({...i,_coverBreakBefore:!0})}else t.push(i)};for(const i of n||[]){if(i&&i.type==="pageBreak"){o=!0;continue}if(i&&i.type==="area"){const s=it(i.valueList||[]);if((i.areaId||"").includes("cover")){for(const m of s)a({...m,_isCover:!0});o=!0}else for(const m of s)a(m)}else a(i)}return t}const ln=n=>n==null?void 0:n.some(t=>t._isCover);function Ae(n){const t=it(n),o=[];let a=[],i=0,s=null;const p=y=>{a.length&&(o.push({type:"paragraph",elements:[...a],rowFlex:y,_isCover:ln(a)}),a=[])},m=()=>{if(i===0)return;const y=s;p(y);for(let c=1;c<i;c++)o.push({type:"paragraph",elements:[],rowFlex:y});i=0,s=null};for(const y of t||[])if(y.type==="table")m(),p(),o.push({type:"table",el:y,_isCover:!!y._isCover});else if(y.type==="title")m(),p(),o.push({type:"title",el:y,_isCover:!!y._isCover});else if(y.type==="list"){m(),p();const c=[];let S=[];for(const k of y.valueList||[])k.value===`
|
|
2
|
-
`||k.value===""?(c.push([...S]),S=[]):S.push(k);(S.length||c.length===0)&&c.push([...S]),o.push({type:"list",listType:y.listType||"ul",listStyle:y.listStyle||"disc",items:c})}else if(y.listId){m(),p();const c=y.value===""||y.value===""?[]:[y];o.push({type:"list",listType:y.listType||"ul",listStyle:y.listStyle||"disc",items:[c]})}else y.value!=null&&/^[\n]+$/.test(y.value)?(i+=y.value.length,y.rowFlex&&(s=y.rowFlex)):(m(),a.push(y));return m(),p(),o}function Se(n){const t=n.filter(k=>k.type==="image").reduce((k,T)=>k+(T.height||T.width||0),0),o=n.filter(k=>k.type!=="image").map(k=>k.value||"").join("");if(!o)return t||20;const a=n.reduce((k,T)=>Math.max(k,T.size||0),0)||14,i=a+6,s=n.filter(k=>k.type==="tab").reduce((k,T)=>k+(T.size||Me),0),p=(o.match(/[一-龥]/g)||[]).length,m=(o.match(/[A-Za-z0-9]/g)||[]).length,y=o.length-p-m,c=p*a+m*(a*.55)+y*(a*.35)+s,S=Math.max(1,Math.ceil(c/at));return t+Math.max(i,S*i)}function an(n){if(!n||!n.length)return[[]];const t=[];let o=[];for(const a of n)a.type==="image"&&(a.width||0)>=at?(o.length&&(t.push(o),o=[]),t.push([a])):o.push(a);return o.length&&t.push(o),t.length?t:[[]]}function rt(n){if(n.length===0)return[];const t=new Array(n.length).fill(0);n.forEach((s,p)=>{(s.tdList||[]).forEach(m=>{const y=m.rowspan||1;if(y>1){const c=Math.min(p+y-1,n.length-1);t[p]=Math.max(t[p],c);for(let S=1;S<y&&p+S<n.length;S++)t[p+S]=Math.max(t[p+S],c)}})});const o=[];let a=0,i=0;for(let s=0;s<n.length;s++)i=Math.max(i,t[s]),i<=s&&(o.push(n.slice(a,s+1)),a=s+1,i=0);return a<n.length&&o.push(n.slice(a)),o}function We(n,t=0){const o=(n==null?void 0:n.width)||0,a=Math.max(nn-t,1);return!o||o<=a?1:a/o}function st(n){var s,p;const t=n.elements||[],o=((s=t.find(m=>m.rowFlex))==null?void 0:s.rowFlex)||n.rowFlex,a={textAlign:on[o]||"left"},i=(p=t.find(m=>m.rowMargin))==null?void 0:p.rowMargin;return i&&(a.lineHeight=i),a}function rn(n){var s;const t=Ae(n.value);let o=0,a=0,i=!1;for(const p of t)if(p.type==="paragraph"){if(!p.elements.length)continue;o++;for(const m of p.elements)(m.type==="image"||m.type==="table")&&(i=!0),a+=(m.value||"").length}else p.type==="list"?(o+=((s=p.items)==null?void 0:s.length)||1,i=!0):(o++,i=!0);return o>1||a>30||i?"top":n.verticalAlign||"middle"}function se(n){const t={};n.font&&(t.fontFamily=n.font),t.fontSize=(n.size||Me)+"px",n.bold!=null&&(t.fontWeight=n.bold?"bold":"normal"),n.italic!=null&&(t.fontStyle=n.italic?"italic":"normal"),n.color&&(t.color=n.color),n.highlight&&n.highlight!=="rgb(255, 255, 255)"&&n.highlight!=="#ffffff"&&(t.backgroundColor=n.highlight);const o=[n.underline&&"underline",n.strikeout&&"line-through"].filter(Boolean).join(" ");return o&&(t.textDecoration=o),n.letterSpacing&&(t.letterSpacing=n.letterSpacing+"px"),t}const sn=5;function ct(n,t=!1){var a,i;let o=0;for(const s of n)if(s.type==="table"){const p=((a=s.el)==null?void 0:a.trList)||[];o+=p.reduce((m,y)=>m+(y.height||y.minHeight||35),0)}else if(s.type==="title")o+=Se(s.titleValueList||((i=s.el)==null?void 0:i.valueList)||[]);else if(s.type==="paragraph")o+=Se(s.elements||[]);else if(s.type==="list"){const p=Math.round(18),m=(s.items||[]).reduce((y,c)=>y+(c.length?Se(c):p),0);o+=Math.max(m,p)}return o+(t&&o>0?sn:0)}const cn={key:0,class:"empty-line"},dn=["href"],hn=["src"],fn=["checked"],un=["checked"],gn={key:4,class:"ctrl-input"},pn=["checked"],mn=["checked"],yn={key:0},kn=["colspan","rowspan"],bn={key:0},_n=["src"],wn=["href"],xn=["checked"],Cn=["checked"],En=["checked"],Ge=Be({__name:"DocBlock",props:{block:{type:Object,required:!0},isHeaderFooter:{type:Boolean,default:!1}},setup(n){const t=n,o=e.inject("bindTableObserver",null),a=e.inject("resolveImageUrl",null);function i(p){if(!p)return"";const m=(a==null?void 0:a.value)||a;return typeof m=="function"?m(p):p}const s=e.computed(()=>t.isHeaderFooter?0:t.block.indentPx??0);return(p,m)=>{var y;return n.block.blockType==="title"?(e.openBlock(),e.createElementBlock("p",{key:0,class:e.normalizeClass(["doc-title",`doc-title--${n.block.level}`]),style:e.normalizeStyle({paddingLeft:s.value?s.value+"px":void 0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.titleValueList||[],(c,S)=>(e.openBlock(),e.createElementBlock("span",{key:S,style:e.normalizeStyle(e.unref(se)(c))},e.toDisplayString(c.value),5))),128))],6)):n.block.blockType==="paragraph"?(e.openBlock(),e.createElementBlock("p",{key:1,class:"doc-para",style:e.normalizeStyle({...e.unref(st)(n.block),paddingLeft:s.value?s.value+"px":void 0})},[n.block.elements.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",cn," ")),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.elements,(c,S)=>{var k,T,H,K,B,O,A,f,I,L,M,W,oe;return e.openBlock(),e.createElementBlock(e.Fragment,{key:S},[!c.type||c.type==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle(e.unref(se)(c))},e.toDisplayString(c.value),5)):c.type==="hyperlink"?(e.openBlock(),e.createElementBlock("a",{key:1,href:c.url,class:"doc-link",target:"_blank",rel:"noopener"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.valueList||[],(N,J)=>(e.openBlock(),e.createElementBlock("span",{key:J,style:e.normalizeStyle(e.unref(se)(N))},e.toDisplayString(N.value),5))),128))],8,dn)):c.type==="image"?(e.openBlock(),e.createElementBlock("img",{key:2,src:i(c.value),class:"doc-image",style:e.normalizeStyle({width:c.width?c.width+"px":"auto",height:c.height?c.height+"px":"auto"})},null,12,hn)):c.type==="control"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[((k=c.control)==null?void 0:k.type)==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle({fontSize:(c.control.size||12)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.control.value||[],(N,J)=>(e.openBlock(),e.createElementBlock("span",{key:J,style:e.normalizeStyle(e.unref(se)(N))},e.toDisplayString(N.value),5))),128))],4)):((T=c.control)==null?void 0:T.type)==="input"?(e.openBlock(),e.createElementBlock("span",{key:1,class:"ctrl-input",style:e.normalizeStyle({minWidth:(c.control.minWidth||60)+"px",fontSize:(c.control.size||12)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.control.value||[],(N,J)=>(e.openBlock(),e.createElementBlock("span",{key:J},e.toDisplayString(N.value),1))),128))],4)):((H=c.control)==null?void 0:H.type)==="radio"?(e.openBlock(),e.createElementBlock("span",{key:2,class:e.normalizeClass(["ctrl-options",{"ctrl-options--vertical":((B=(K=c.control.extension)==null?void 0:K.elementAttributes)==null?void 0:B.layout)==="vertical"}]),style:e.normalizeStyle({fontSize:(c.control.size||e.unref(Me))+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.control.valueSets||[],(N,J)=>(e.openBlock(),e.createElementBlock("label",{key:J,class:"ctrl-option"},[e.createElementVNode("input",{type:"radio",disabled:"",checked:c.control.code===N.code},null,8,fn),e.createTextVNode(" "+e.toDisplayString(N.value),1)]))),128))],6)):((O=c.control)==null?void 0:O.type)==="checkbox"?(e.openBlock(),e.createElementBlock("span",{key:3,class:e.normalizeClass(["ctrl-options",{"ctrl-options--vertical":((f=(A=c.control.extension)==null?void 0:A.elementAttributes)==null?void 0:f.layout)==="vertical"}]),style:e.normalizeStyle({fontSize:(c.control.size||e.unref(Me))+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.control.valueSets||[],(N,J)=>(e.openBlock(),e.createElementBlock("label",{key:J,class:"ctrl-option"},[e.createElementVNode("input",{type:"checkbox",disabled:"",checked:(c.control.code||"").split(",").includes(N.code)},null,8,un),e.createTextVNode(" "+e.toDisplayString(N.value),1)]))),128))],6)):((I=c.control)==null?void 0:I.type)==="select"?(e.openBlock(),e.createElementBlock("span",gn,e.toDisplayString(((M=(L=c.control.value)==null?void 0:L[0])==null?void 0:M.value)||c.control.placeholder||""),1)):e.createCommentVNode("",!0)],64)):c.type==="checkbox"?(e.openBlock(),e.createElementBlock("input",{key:4,type:"checkbox",checked:!!((W=c.checkbox)!=null&&W.value),disabled:"",class:"el-check"},null,8,pn)):c.type==="radio"?(e.openBlock(),e.createElementBlock("input",{key:5,type:"radio",checked:!!((oe=c.radio)!=null&&oe.value),disabled:"",class:"el-check"},null,8,mn)):c.type==="superscript"?(e.openBlock(),e.createElementBlock("sup",{key:6,style:e.normalizeStyle(e.unref(se)(c))},e.toDisplayString(c.value),5)):c.type==="subscript"?(e.openBlock(),e.createElementBlock("sub",{key:7,style:e.normalizeStyle(e.unref(se)(c))},e.toDisplayString(c.value),5)):c.type==="tab"?(e.openBlock(),e.createElementBlock("span",{key:8,class:"doc-tab",style:e.normalizeStyle({width:(c.size||e.unref(Me))+"px"})},null,4)):e.createCommentVNode("",!0)],64)}),128))],4)):n.block.blockType==="list"?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.block.listType==="ol"?"ol":"ul"),{key:2,class:"doc-list",style:e.normalizeStyle({listStyleType:n.block.listStyle==="decimal"?"decimal":n.block.listStyle==="lower-alpha"?"lower-alpha":"disc",paddingLeft:s.value?s.value+24+"px":void 0})},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.items,(c,S)=>(e.openBlock(),e.createElementBlock("li",{key:S,class:"doc-list-item"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c,(k,T)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:T},[!k.type||k.type==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle(e.unref(se)(k))},e.toDisplayString(k.value),5)):k.type==="superscript"?(e.openBlock(),e.createElementBlock("sup",{key:1,style:e.normalizeStyle(e.unref(se)(k))},e.toDisplayString(k.value),5)):k.type==="subscript"?(e.openBlock(),e.createElementBlock("sub",{key:2,style:e.normalizeStyle(e.unref(se)(k))},e.toDisplayString(k.value),5)):e.createCommentVNode("",!0)],64))),128))]))),128))]),_:1},8,["style"])):n.block.blockType==="table-row-group"?(e.openBlock(),e.createElementBlock("div",{key:3,class:e.normalizeClass(["doc-table-row-wrap",{"is-first":n.block.isFirst,"is-last":n.block.isLast,"is-page-break":n.block.isPageBreak}]),style:e.normalizeStyle({display:n.block.tableRowFlex?"flex":void 0,justifyContent:n.block.tableRowFlex==="right"?"flex-end":n.block.tableRowFlex==="center"?"center":n.block.tableRowFlex==="left"?"flex-start":void 0,paddingLeft:s.value?s.value+"px":void 0})},[e.createElementVNode("div",{style:e.normalizeStyle({overflow:n.block.sliceHeight!=null?"hidden":void 0,height:n.block.sliceHeight!=null?(n.block.isLast?n.block.sliceHeight+1:n.block.sliceHeight)+"px":void 0,width:n.block.tableEl.width?"max-content":"100%"})},[e.createElementVNode("table",{ref:n.block._baseKey&&e.unref(o)?c=>e.unref(o)(c,n.block._baseKey):void 0,class:e.normalizeClass(["doc-table",{"doc-table--no-border":n.block.tableEl.borderType==="empty","doc-table--header-footer":n.isHeaderFooter}]),style:e.normalizeStyle({width:n.block.tableEl.width?(n.isHeaderFooter?n.block.tableEl.width:n.block.tableEl.width*e.unref(We)(n.block.tableEl,s.value))+"px":"100%",transform:n.block.sliceOffset?`translateY(-${n.block.sliceOffset}px)`:void 0})},[(y=n.block.tableEl.colgroup)!=null&&y.length?(e.openBlock(),e.createElementBlock("colgroup",yn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.tableEl.colgroup,(c,S)=>(e.openBlock(),e.createElementBlock("col",{key:S,style:e.normalizeStyle({width:(n.isHeaderFooter?c.width:c.width*e.unref(We)(n.block.tableEl,s.value))+"px"})},null,4))),128))])):e.createCommentVNode("",!0),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.trGroup,(c,S)=>(e.openBlock(),e.createElementBlock("tr",{key:S,style:e.normalizeStyle({height:(c.height||c.minHeight||30)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.tdList||[],(k,T)=>(e.openBlock(),e.createElementBlock("td",{key:T,colspan:k.colspan||1,rowspan:k.rowspan||1,style:e.normalizeStyle({backgroundColor:k.backgroundColor||void 0,verticalAlign:e.unref(rn)(k),width:k.width?k.width*e.unref(We)(n.block.tableEl,s.value)+"px":void 0,height:k.height?k.height+"px":void 0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(Ae)(k.value),(H,K)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:K},[H.type==="paragraph"?(e.openBlock(),e.createElementBlock("p",{key:0,class:"cell-para",style:e.normalizeStyle(e.unref(st)(H))},[H.elements.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",bn," ")),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(H.elements,(B,O)=>{var A,f,I,L,M,W,oe;return e.openBlock(),e.createElementBlock(e.Fragment,{key:O},[!B.type||B.type==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle(e.unref(se)(B))},e.toDisplayString(B.value),5)):B.type==="image"?(e.openBlock(),e.createElementBlock("img",{key:1,src:i(B.value),class:"doc-image",style:e.normalizeStyle({width:B.width?B.width+"px":"auto",height:B.height?B.height+"px":"auto"})},null,12,_n)):B.type==="hyperlink"?(e.openBlock(),e.createElementBlock("a",{key:2,href:B.url,class:"doc-link",target:"_blank"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B.valueList||[],(N,J)=>(e.openBlock(),e.createElementBlock("span",{key:J,style:e.normalizeStyle(e.unref(se)(N))},e.toDisplayString(N.value),5))),128))],8,wn)):B.type==="control"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[((A=B.control)==null?void 0:A.type)==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle({fontSize:(B.control.size||12)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B.control.value||[],(N,J)=>(e.openBlock(),e.createElementBlock("span",{key:J,style:e.normalizeStyle(e.unref(se)(N))},e.toDisplayString(N.value),5))),128))],4)):((f=B.control)==null?void 0:f.type)==="input"?(e.openBlock(),e.createElementBlock("span",{key:1,class:"ctrl-input",style:e.normalizeStyle({fontSize:(B.control.size||12)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B.control.value||[],(N,J)=>(e.openBlock(),e.createElementBlock("span",{key:J},e.toDisplayString(N.value),1))),128))],4)):((I=B.control)==null?void 0:I.type)==="radio"?(e.openBlock(),e.createElementBlock("span",{key:2,class:e.normalizeClass(["ctrl-options",{"ctrl-options--vertical":((M=(L=B.control.extension)==null?void 0:L.elementAttributes)==null?void 0:M.layout)==="vertical"}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B.control.valueSets||[],(N,J)=>(e.openBlock(),e.createElementBlock("label",{key:J,class:"ctrl-option"},[e.createElementVNode("input",{type:"radio",disabled:"",checked:B.control.code===N.code},null,8,xn),e.createTextVNode(e.toDisplayString(N.value),1)]))),128))],2)):e.createCommentVNode("",!0)],64)):B.type==="checkbox"?(e.openBlock(),e.createElementBlock("input",{key:4,type:"checkbox",checked:!!((W=B.checkbox)!=null&&W.value),disabled:"",class:"el-check"},null,8,Cn)):B.type==="radio"?(e.openBlock(),e.createElementBlock("input",{key:5,type:"radio",checked:!!((oe=B.radio)!=null&&oe.value),disabled:"",class:"el-check"},null,8,En)):B.type==="superscript"?(e.openBlock(),e.createElementBlock("sup",{key:6,style:e.normalizeStyle(e.unref(se)(B))},e.toDisplayString(B.value),5)):B.type==="subscript"?(e.openBlock(),e.createElementBlock("sub",{key:7,style:e.normalizeStyle(e.unref(se)(B))},e.toDisplayString(B.value),5)):B.type==="tab"?(e.openBlock(),e.createElementBlock("span",{key:8,class:"doc-tab",style:e.normalizeStyle({width:(B.size||e.unref(Me))+"px"})},null,4)):e.createCommentVNode("",!0)],64)}),128))],4)):e.createCommentVNode("",!0)],64))),128))],12,kn))),128))],4))),128))])],6)],4)],6)):e.createCommentVNode("",!0)}}},[["__scopeId","data-v-b9e67b24"]]),Bn={class:"editor-layout word-editor-scope"},Mn={class:"editor-container"},Sn={key:0,class:"editor-loading"},Fn={key:0,class:"doc-header"},In={class:"doc-footer"},Tn={class:"doc-page-number"},An=1123,Pn=50,Ln=20,$n=Be({__name:"index",props:{data:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1},resolveImageUrl:{type:Function,default:null}},setup(n){const t=n,o=e.computed(()=>{const f=t.data;return f?!Array.isArray(f)&&f.main?f.main:Array.isArray(f)?f:[]:[]}),a=e.ref(null),i=e.ref({});let s=null;e.onMounted(()=>{s=new ResizeObserver(f=>{const I={};for(const L of f){const M=L.target._rowKey;if(!M)continue;const W=Math.round(L.contentRect.height);W>(i.value[M]||0)&&(I[M]=W)}Object.keys(I).length&&(i.value={...i.value,...I})})}),e.onUnmounted(()=>{s==null||s.disconnect(),s=null});function p(f,I){!f||!s||(f._rowKey=I,s.observe(f))}e.provide("bindTableObserver",p),e.provide("resolveImageUrl",t.resolveImageUrl);const m=e.computed(()=>Math.max(100,An-Pn*2-k.value-Ln)),y=e.computed(()=>{const f=Ae(o.value),I=[],L=m.value;let M=0,W=!1;const oe=R=>{I.push({...R,_isCover:W})},N=tn(),J={first:0,second:1,third:2,fourth:3,fifth:4,sixth:5,seventh:6,eighth:7};let pe=-1;const He=R=>{var le,ce,me;return!!((le=R.el)!=null&&le._coverBreakBefore||(me=(ce=R.elements)==null?void 0:ce[0])!=null&&me._coverBreakBefore)};return f.forEach((R,le)=>{var me,Ze,Oe,Ne;const ce=He(R);if(ce&&(M=0),W=!!R._isCover,R.type==="title"){const ae=R.el.valueList||[],ee=N.next(R.el.level,(me=R.el.extension)==null?void 0:me.startIndex),ue=ae.some(ie=>{var de;return(de=ie.extension)==null?void 0:de.isIndex});let ye=ae;if(!ue&&ee){const ie=ae[0]||{};ye=[{value:ee,size:ie.size,bold:ie.bold,italic:ie.italic,color:ie.color,font:ie.font,extension:{isIndex:!0}},...ae]}const ge=ye.map(ie=>ie.value||"").join(""),Y=Se(ye);M=M+Y>L&&M>0?Y:M+Y,pe=J[R.el.level]??0,oe({node_id:`blk_${le}_0`,layer:ce?1:100,blockType:"title",level:R.el.level,titleEl:R.el,titleValueList:ye,content_type:"text",content:ge,height:Y,indentPx:pe*20})}else if(R.type==="paragraph"){const ae=an(R.elements),ee=pe>=0?(pe+1)*20:0;ae.forEach((ue,ye)=>{const ge=ue.map(ie=>ie.value||"").join(""),Y=Se(ue);M=M+Y>L&&M>0?Y:M+Y,oe({node_id:`blk_${le}_${ye}`,layer:ce&&ye===0?1:100,blockType:"paragraph",elements:ue,rowFlex:R.rowFlex,content_type:"text",content:ge,height:Y,indentPx:ee})})}else if(R.type==="table"){const ae=!!((Ze=R.el.extension)!=null&&Ze.isTitleTable),ee=((Oe=R.el.extension)==null?void 0:Oe.elementType)==="signOff",ue=((Ne=R.el.extension)==null?void 0:Ne.elementType)==="stepTable",ye=ee||ue,ge=ae||ee?0:pe>=0?(pe+1)*20:0,Y=rt(R.el.trList||[]),ie=Y.length;if(ye){const de=Y.flat(),D=de.reduce((Z,G)=>Z+(G.height||G.minHeight||35),0),ke=`blk_${le}_0`,he=Math.max(D,i.value[ke]||0);if(M>0&&M+he>L&&(M=0),he>L){const Z=Math.ceil(he/L);for(let G=0;G<Z;G++){const te=G*L,be=Math.min(L,he-te),Ce=G>0||M>0;M=be,oe({node_id:`blk_${le}_0_s${G}`,layer:ce&&G===0?1:100,blockType:"table-row-group",content_type:"table-row",rowHeight:he,trGroup:de,tableEl:R.el,tableRowFlex:R.el.rowFlex||null,isFirst:G===0,isLast:G===Z-1,isPageBreak:Ce,sliceOffset:te,sliceHeight:be,_baseKey:G===0?ke:void 0,height:be,indentPx:ge})}}else{const Z=M>0;M=M+he>L?he:M+he,oe({node_id:`blk_${le}_0`,layer:ce?1:100,blockType:"table-row-group",content_type:"table-row",rowHeight:he,trGroup:de,tableEl:R.el,tableRowFlex:R.el.rowFlex||null,isFirst:!0,isLast:!0,isPageBreak:Z,indentPx:ge})}}else Y.forEach((de,D)=>{const ke=`blk_${le}_${D}`,he=de.reduce((G,te)=>G+(te.height||te.minHeight||35),0),Z=Math.max(he,i.value[ke]||0);if(Z>L){const G=Math.ceil(Z/L);for(let te=0;te<G;te++){const be=te*L,Ce=Math.min(L,Z-be),Qe=te>0||M>0;M=Ce,oe({node_id:`blk_${le}_${D}_s${te}`,layer:ce&&D===0&&te===0?1:100,blockType:"table-row-group",content_type:"table-row",rowHeight:Z,trGroup:de,tableEl:R.el,tableRowFlex:R.el.rowFlex||null,isFirst:D===0&&te===0,isLast:D===ie-1&&te===G-1,isPageBreak:Qe,sliceOffset:be,sliceHeight:Ce,_baseKey:te===0?ke:void 0,height:Ce,indentPx:ge})}}else{const G=D>0&&M+Z>L;M=M+Z>L?Z:M+Z,oe({node_id:`blk_${le}_${D}`,layer:ce&&D===0?1:100,blockType:"table-row-group",content_type:"table-row",rowHeight:Z,trGroup:de,tableEl:R.el,tableRowFlex:R.el.rowFlex||null,isFirst:D===0,isLast:D===ie-1,isPageBreak:G,indentPx:ge})}})}else if(R.type==="list"){const ae=Math.round(18);let ee=0;for(const ue of R.items)ee+=ue.length?Se(ue):ae;ee=Math.max(ee,ae),M=M+ee>L&&M>0?ee:M+ee,oe({node_id:`blk_${le}_0`,layer:ce?1:100,blockType:"list",listType:R.listType,listStyle:R.listStyle,items:R.items,height:ee,indentPx:pe>=0?(pe+1)*20:0})}}),I}),c=e.computed(()=>{var I;const f=(I=t.data)==null?void 0:I.header;return f!=null&&f.length?Ae(f):[]}),S=e.computed(()=>{var I;const f=(I=t.data)==null?void 0:I.footer;return f!=null&&f.length?Ae(f):[]}),k=e.computed(()=>ct(c.value,!0)),T=e.computed(()=>ct(S.value,!0)),H=e.computed(()=>c.value.length>0),K=e.computed(()=>S.value.length>0);function B(f){var L,M,W;const I=f.type==="table";return{blockType:I?"table-row-group":f.type,elements:f.elements,rowFlex:f.rowFlex,level:(L=f.el)==null?void 0:L.level,titleValueList:((M=f.el)==null?void 0:M.valueList)||f.titleValueList,listType:f.listType,listStyle:f.listStyle,items:f.items,indentPx:0,trGroup:I?rt(f.el.trList).flat():void 0,tableEl:I?f.el:void 0,isFirst:!0,isLast:!0,tableRowFlex:((W=f.el)==null?void 0:W.rowFlex)||null}}const O=e.computed(()=>Qt(y.value));function A(f){var I;(I=a.value)==null||I.scrollToRow({node_id:f.nodeId})}return(f,I)=>(e.openBlock(),e.createElementBlock("div",Bn,[e.createVNode(Xt,{items:O.value,onNavigate:A},null,8,["items"]),e.createElementVNode("div",Mn,[n.loading?(e.openBlock(),e.createElementBlock("div",Sn," 加载中… ")):(e.openBlock(),e.createBlock(e.unref(zt),{key:1,ref_key:"virtualTableRef",ref:a,"show-header":!1,"row-config":{keyField:"node_id"},"page-config":{enabled:!0,pageHeight:1123,pageWidth:860,margin:50,gap:16,showPageHeader:H.value,showPageBorder:!0,pageBorderPadding:5,pageBorderStyle:"1px solid #333",headerHeight:k.value,footerHeight:T.value,showPageNumber:!0},data:y.value},e.createSlots({default:e.withCtx(()=>[e.createVNode(e.unref(Ht),null,{default:e.withCtx(({row:L})=>[e.createVNode(Ge,{block:L},null,8,["block"])]),_:1})]),_:2},[H.value?{name:"page-header",fn:e.withCtx(({isCoverPage:L})=>[L?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Fn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,(M,W)=>(e.openBlock(),e.createBlock(Ge,{key:W,block:B(M),"is-header-footer":!0},null,8,["block"]))),128))]))]),key:"0"}:void 0,K.value?{name:"page-footer",fn:e.withCtx(({pageNumber:L,totalPages:M})=>[e.createElementVNode("div",In,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(S.value,(W,oe)=>(e.openBlock(),e.createBlock(Ge,{key:oe,block:B(W),"is-header-footer":!0},null,8,["block"]))),128)),e.createElementVNode("div",Tn," 第"+e.toDisplayString(L)+"页 / 共"+e.toDisplayString(M)+"页 ",1)])]),key:"1"}:void 0]),1032,["page-config","data"]))])]))}},[["__scopeId","data-v-9ff2db2b"]]),dt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function Re(n=10){const t=crypto.getRandomValues(new Uint8Array(n));return Array.from(t).map(o=>dt[o%dt.length]).join("")}class De{constructor(t){v(this,"data");this.data=e.reactive({id:Re(),version:1,sections:[this.createEmptySection()],pageWidth:595,pageHeight:842,marginTop:72,marginBottom:72,marginLeft:90,marginRight:90,...t})}createEmptySection(){return{id:Re(),paragraphs:[this.createEmptyParagraph()]}}createEmptyParagraph(t){return{id:Re(),type:"paragraph",format:t??{},children:[]}}createTextElement(t,o){return{id:Re(),type:"text",value:t,format:o??{}}}getSectionCount(){return this.data.sections.length}getParagraphCount(t=0){var o;return((o=this.data.sections[t])==null?void 0:o.paragraphs.length)??0}getAllParagraphs(){const t=[];return this.data.sections.forEach((o,a)=>{o.paragraphs.forEach((i,s)=>{t.push({paragraph:i,sectionIndex:a,paragraphIndex:s})})}),t}getParagraphAt(t,o){var a;return((a=this.data.sections[t])==null?void 0:a.paragraphs[o])??null}getElementAt(t){const o=this.getParagraphAt(t.sectionIndex,t.paragraphIndex);return(o==null?void 0:o.children[t.elementIndex])??null}insertText(t,o,a){const i=this.getParagraphAt(t.sectionIndex,t.paragraphIndex);if(!i)return;const s=i.children[t.elementIndex];if(s&&s.type==="text")s.value=s.value.slice(0,t.offset)+o+s.value.slice(t.offset);else{const p=this.createTextElement(o,a);i.children.splice(t.elementIndex,0,p)}this.bumpVersion()}deleteAt(t,o){const a=this.getParagraphAt(t.sectionIndex,t.paragraphIndex);if(!a)return;const i=a.children[t.elementIndex];!i||i.type!=="text"||(i.value=i.value.slice(0,t.offset)+i.value.slice(t.offset+o),i.value===""&&a.children.splice(t.elementIndex,1),this.bumpVersion())}insertParagraph(t,o,a){const i=this.data.sections[t];if(!i)throw new Error(`Section ${t} not found`);const s=this.createEmptyParagraph(a);return i.paragraphs.splice(o+1,0,s),this.bumpVersion(),s}mergeParagraphs(t,o){const a=this.data.sections[t];if(!a)return;const i=a.paragraphs[o],s=a.paragraphs[o+1];!i||!s||(i.children.push(...s.children),a.paragraphs.splice(o+1,1),this.bumpVersion())}updateParagraphFormat(t,o,a){const i=this.getParagraphAt(t,o);i&&(i.format={...i.format,...a},this.bumpVersion())}updateElementFormat(t,o){const a=this.getElementAt(t);a&&(a.format={...a.format,...o},this.bumpVersion())}updateRangeFormat(t,o,a){const i=this.getAllParagraphs();let s=!1;for(const{paragraph:p,sectionIndex:m,paragraphIndex:y}of i){const c=m===t.sectionIndex&&y===t.paragraphIndex,S=m===o.sectionIndex&&y===o.paragraphIndex;if(c&&(s=!0),s)for(let k=0;k<p.children.length;k++){const T=p.children[k];if(!(c&&k<t.elementIndex)){if(S&&k>o.elementIndex)break;T.format={...T.format,...a}}}if(S)break}this.bumpVersion()}bumpVersion(){this.data.version++}toJSON(){return JSON.stringify(this.data,null,2)}static fromJSON(t){const o=JSON.parse(t),a=new De;return Object.assign(a.data,o),a}}function we(n=0,t=0,o=0,a=0){return{sectionIndex:n,paragraphIndex:t,elementIndex:o,offset:a}}function ht(n,t){return n.sectionIndex===t.sectionIndex&&n.paragraphIndex===t.paragraphIndex&&n.elementIndex===t.elementIndex&&n.offset===t.offset}class Je{constructor(t){v(this,"_selection",e.reactive({anchor:we(),focus:we(),isCollapsed:!0}));v(this,"_docModel");v(this,"hasSelection",e.computed(()=>!this._selection.isCollapsed));this._docModel=t}get selection(){return this._selection}setCursor(t){this._selection.anchor={...t},this._selection.focus={...t},this._selection.isCollapsed=!0}setSelection(t,o){this._selection.anchor={...t},this._selection.focus={...o},this._selection.isCollapsed=ht(t,o)}collapse(t=!0){t?this._selection.anchor={...this._selection.focus}:this._selection.focus={...this._selection.anchor},this._selection.isCollapsed=!0}selectAll(){const t=this._docModel.data.sections,o=t[t.length-1],a=o==null?void 0:o.paragraphs[o.paragraphs.length-1],i=a==null?void 0:a.children[a.children.length-1],s=(i==null?void 0:i.type)==="text"?i.value.length:0;this._selection.anchor=we(0,0,0,0),this._selection.focus=we(t.length-1,((o==null?void 0:o.paragraphs.length)??1)-1,((a==null?void 0:a.children.length)??0)===0?0:((a==null?void 0:a.children.length)??1)-1,s),this._selection.isCollapsed=!1}moveForward(t=!1){const o=this._selection.focus,a=this._docModel.getParagraphAt(o.sectionIndex,o.paragraphIndex);if(!a)return;const i=a.children[o.elementIndex];if((i==null?void 0:i.type)==="text"&&o.offset<i.value.length){const p={...o,offset:o.offset+1};this._applyMove(p,t);return}if(o.elementIndex<a.children.length-1){const p={...o,elementIndex:o.elementIndex+1,offset:0};this._applyMove(p,t);return}const s=this._getNextParagraphPoint(o);s&&this._applyMove(s,t)}moveBackward(t=!1){const o=this._selection.focus;if(o.offset>0){const i={...o,offset:o.offset-1};this._applyMove(i,t);return}if(o.elementIndex>0){const i=this._docModel.getParagraphAt(o.sectionIndex,o.paragraphIndex),s=i==null?void 0:i.children[o.elementIndex-1],p=(s==null?void 0:s.type)==="text"?s.value.length:0,m={...o,elementIndex:o.elementIndex-1,offset:p};this._applyMove(m,t);return}const a=this._getPrevParagraphPoint(o);a&&this._applyMove(a,t)}_applyMove(t,o){o?(this._selection.focus=t,this._selection.isCollapsed=ht(this._selection.anchor,t)):(this._selection.anchor={...t},this._selection.focus={...t},this._selection.isCollapsed=!0)}_getNextParagraphPoint(t){const o=this._docModel.data.sections[t.sectionIndex];return o?t.paragraphIndex<o.paragraphs.length-1?we(t.sectionIndex,t.paragraphIndex+1,0,0):t.sectionIndex<this._docModel.data.sections.length-1?we(t.sectionIndex+1,0,0,0):null:null}_getPrevParagraphPoint(t){if(t.paragraphIndex>0){const o=this._docModel.getParagraphAt(t.sectionIndex,t.paragraphIndex-1);if(!o)return null;const a=o.children.length-1,i=o.children[a],s=(i==null?void 0:i.type)==="text"?i.value.length:0;return we(t.sectionIndex,t.paragraphIndex-1,Math.max(a,0),s)}if(t.sectionIndex>0){const o=this._docModel.data.sections[t.sectionIndex-1];if(!o)return null;const a=o.paragraphs.length-1,i=o.paragraphs[a],s=((i==null?void 0:i.children.length)??0)-1,p=i==null?void 0:i.children[s],m=(p==null?void 0:p.type)==="text"?p.value.length:0;return we(t.sectionIndex-1,a,Math.max(s,0),m)}return null}static domToModelPoint(t,o){let a=t instanceof Element?t:t.parentElement;for(;a;){const i=a.getAttribute("data-si"),s=a.getAttribute("data-pi"),p=a.getAttribute("data-ei");if(i!==null&&s!==null&&p!==null)return{sectionIndex:parseInt(i),paragraphIndex:parseInt(s),elementIndex:parseInt(p),offset:o};a=a.parentElement}return null}}const zn=200;class Rn{constructor(){v(this,"_undoStack",[]);v(this,"_redoStack",[])}get canUndo(){return this._undoStack.length>0}get canRedo(){return this._redoStack.length>0}push(t){var a,i;this._redoStack=[];const o=this._undoStack[this._undoStack.length-1];if(o&&((a=t.canMergeWith)!=null&&a.call(t,o))){(i=o.merge)==null||i.call(o,t);return}this._undoStack.push(t),this._undoStack.length>zn&&this._undoStack.shift()}undo(){const t=this._undoStack.pop();return t?(t.undo(),this._redoStack.push(t),!0):!1}redo(){const t=this._redoStack.pop();return t?(t.execute(),this._undoStack.push(t),!0):!1}clear(){this._undoStack=[],this._redoStack=[]}}class Dn{constructor(t,o,a,i,s){v(this,"name","insertText");v(this,"_point");v(this,"_text");v(this,"_format");this.docModel=t,this.selectionManager=o,this._point={...a},this._text=i,this._format=s}execute(){this.docModel.insertText(this._point,this._text,this._format),this.selectionManager.setCursor({...this._point,offset:this._point.offset+this._text.length})}undo(){this.docModel.deleteAt(this._point,this._text.length),this.selectionManager.setCursor(this._point)}canMergeWith(t){if(t.name!=="insertText")return!1;const o=t;return o._point.sectionIndex===this._point.sectionIndex&&o._point.paragraphIndex===this._point.paragraphIndex&&o._point.elementIndex===this._point.elementIndex&&o._point.offset===this._point.offset+this._text.length}merge(t){const o=t;this._text+=o._text}}class Hn{constructor(t,o){v(this,"name","insertParagraph");v(this,"_insertedParagraphId",null);this.docModel=t,this.selectionManager=o}execute(){var y,c;const{focus:t}=this.selectionManager.selection,{sectionIndex:o,paragraphIndex:a}=t,i=this.docModel.getParagraphAt(o,a);if(!i)return;const s=t.elementIndex,p=i.children.splice(s),m=this.docModel.createEmptyParagraph(i.format);m.children.push(...p),this._insertedParagraphId=m.id,this.docModel.data.sections[o].paragraphs.splice(a+1,0,m),(c=(y=this.docModel).bumpVersion)==null||c.call(y),this.selectionManager.setCursor({sectionIndex:o,paragraphIndex:a+1,elementIndex:0,offset:0})}undo(){const{focus:t}=this.selectionManager.selection,{sectionIndex:o,paragraphIndex:a}=t;a!==0&&(this.docModel.mergeParagraphs(o,a-1),this.selectionManager.setCursor({sectionIndex:o,paragraphIndex:a-1,elementIndex:0,offset:0}))}}class ft{constructor(t,o,a){v(this,"name");v(this,"_deletedText","");this.docModel=t,this.selectionManager=o,this.name=a==="backward"?"deleteBackward":"deleteForward"}execute(){const{focus:t,isCollapsed:o}=this.selectionManager.selection;if(o)if(this.name==="deleteBackward")if(t.offset>0){const a={...t,offset:t.offset-1},i=this.docModel.getElementAt(t);(i==null?void 0:i.type)==="text"&&(this._deletedText=i.value[t.offset-1]??""),this.docModel.deleteAt(a,1),this.selectionManager.setCursor(a)}else(t.paragraphIndex>0||t.elementIndex>0)&&(this.docModel.mergeParagraphs(t.sectionIndex,t.paragraphIndex-1),this.selectionManager.setCursor({...t,paragraphIndex:t.paragraphIndex-1}));else{const a=this.docModel.getElementAt(t);if((a==null?void 0:a.type)==="text"&&t.offset<a.value.length)this._deletedText=a.value[t.offset],this.docModel.deleteAt(t,1);else{const i=this.docModel.data.sections[t.sectionIndex];i&&t.paragraphIndex<i.paragraphs.length-1&&this.docModel.mergeParagraphs(t.sectionIndex,t.paragraphIndex)}}}undo(){if(this._deletedText){const{focus:t}=this.selectionManager.selection;this.docModel.insertText(t,this._deletedText)}}}class Pe{constructor(t,o,a,i){v(this,"name");v(this,"_prevFormat",{});this.docModel=t,this.selectionManager=o,this._value=i,this.name=a}execute(){const{anchor:t,focus:o}=this.selectionManager.selection,a=this._getFormatKey();if(!a)return;const i={};if(this._isToggle()){const s=this._getCurrentValue(a);i[a]=!s}else i[a]=this._value;this.docModel.updateRangeFormat(t,o,i)}undo(){const{anchor:t,focus:o}=this.selectionManager.selection;this.docModel.updateRangeFormat(t,o,this._prevFormat)}_isToggle(){return["bold","italic","underline","strikethrough","superscript","subscript"].includes(this.name)}_getFormatKey(){return{bold:"bold",italic:"italic",underline:"underline",strikethrough:"strikethrough",fontSize:"fontSize",fontFamily:"fontFamily",color:"color",backgroundColor:"backgroundColor"}[this.name]??null}_getCurrentValue(t){var i;const{focus:o}=this.selectionManager.selection,a=this.docModel.getElementAt(o);return(i=a==null?void 0:a.format)==null?void 0:i[t]}}class Xe{constructor(t,o,a,i){v(this,"name","textAlign");this.docModel=t,this.selectionManager=o,this._formatKey=a,this._value=i}execute(){const{focus:t}=this.selectionManager.selection,o={};o[this._formatKey]=this._value,this.docModel.updateParagraphFormat(t.sectionIndex,t.paragraphIndex,o)}undo(){}}class On{constructor(t,o,a){v(this,"_factories",new Map);this.docModel=t,this.selectionManager=o,this.historyManager=a,this._registerBuiltinCommands()}_registerBuiltinCommands(){this.register("insertText",o=>{const{focus:a}=this.selectionManager.selection;return new Dn(this.docModel,this.selectionManager,a,o)}),this.register("insertParagraph",()=>new Hn(this.docModel,this.selectionManager)),this.register("deleteBackward",()=>new ft(this.docModel,this.selectionManager,"backward")),this.register("deleteForward",()=>new ft(this.docModel,this.selectionManager,"forward")),this.register("undo",()=>null),this.register("redo",()=>null),["bold","italic","underline","strikethrough","superscript","subscript"].forEach(o=>{this.register(o,()=>new Pe(this.docModel,this.selectionManager,o))}),this.register("fontSize",o=>new Pe(this.docModel,this.selectionManager,"fontSize",o)),this.register("fontFamily",o=>new Pe(this.docModel,this.selectionManager,"fontFamily",o)),this.register("color",o=>new Pe(this.docModel,this.selectionManager,"color",o)),this.register("backgroundColor",o=>new Pe(this.docModel,this.selectionManager,"backgroundColor",o)),this.register("textAlign",o=>new Xe(this.docModel,this.selectionManager,"textAlign",o)),this.register("lineHeight",o=>new Xe(this.docModel,this.selectionManager,"lineHeight",o)),this.register("heading",o=>new Xe(this.docModel,this.selectionManager,"heading",o)),this.register("selectAll",()=>(this.selectionManager.selectAll(),null)),this.register("setSelection",o=>{if(o){const a=o;this.selectionManager.setSelection(a.anchor,a.focus)}return null})}register(t,o){this._factories.set(t,o)}exec(t,o){if(t==="undo"){this.historyManager.undo();return}if(t==="redo"){this.historyManager.redo();return}const a=this._factories.get(t);if(!a){console.warn(`[CommandManager] 未注册命令: ${t}`);return}const i=a(o);i&&(i.execute(),this.historyManager.push(i))}}class Nn{constructor(t,o){v(this,"_el",null);v(this,"_commandManager");v(this,"_selectionManager");v(this,"_composing",!1);v(this,"_boundKeydown");v(this,"_boundBeforeInput");v(this,"_boundCompositionStart");v(this,"_boundCompositionEnd");v(this,"_boundSelectionChange");this._commandManager=t,this._selectionManager=o,this._boundKeydown=this._onKeydown.bind(this),this._boundBeforeInput=this._onBeforeInput.bind(this),this._boundCompositionStart=()=>{this._composing=!0},this._boundCompositionEnd=this._onCompositionEnd.bind(this),this._boundSelectionChange=this._onSelectionChange.bind(this)}attach(t){this._el=t,t.addEventListener("keydown",this._boundKeydown),t.addEventListener("beforeinput",this._boundBeforeInput),t.addEventListener("compositionstart",this._boundCompositionStart),t.addEventListener("compositionend",this._boundCompositionEnd),document.addEventListener("selectionchange",this._boundSelectionChange)}detach(){this._el&&(this._el.removeEventListener("keydown",this._boundKeydown),this._el.removeEventListener("beforeinput",this._boundBeforeInput),this._el.removeEventListener("compositionstart",this._boundCompositionStart),this._el.removeEventListener("compositionend",this._boundCompositionEnd),document.removeEventListener("selectionchange",this._boundSelectionChange),this._el=null)}_onKeydown(t){const o=t.key,a=t.ctrlKey||t.metaKey,i=t.shiftKey;if(a)switch(o){case"z":t.preventDefault(),i?this._commandManager.exec("redo"):this._commandManager.exec("undo");return;case"b":t.preventDefault(),this._commandManager.exec("bold");return;case"i":t.preventDefault(),this._commandManager.exec("italic");return;case"u":t.preventDefault(),this._commandManager.exec("underline");return;case"a":t.preventDefault(),this._commandManager.exec("selectAll");return}switch(o){case"Enter":t.preventDefault(),this._composing||this._commandManager.exec("insertParagraph");break;case"Backspace":t.preventDefault(),this._composing||this._commandManager.exec("deleteBackward");break;case"Delete":t.preventDefault(),this._composing||this._commandManager.exec("deleteForward");break;case"ArrowLeft":t.preventDefault(),this._selectionManager.moveBackward(i);break;case"ArrowRight":t.preventDefault(),this._selectionManager.moveForward(i);break;case"Tab":t.preventDefault(),this._commandManager.exec("insertText"," ");break}}_onBeforeInput(t){t.preventDefault(),!this._composing&&t.data&&this._commandManager.exec("insertText",t.data)}_onCompositionEnd(t){this._composing=!1,t.data&&this._commandManager.exec("insertText",t.data)}_onSelectionChange(){const t=window.getSelection();if(!t||!this._el)return;const o=t.anchorNode,a=t.focusNode;if(!o||!a||!this._el.contains(o)&&!this._el.contains(a))return;const i=Je.domToModelPoint(o,t.anchorOffset),s=Je.domToModelPoint(a,t.focusOffset);i&&s&&this._selectionManager.setSelection(i,s)}}class ut{constructor(t={}){v(this,"docModel");v(this,"selection");v(this,"history");v(this,"commands");v(this,"input");v(this,"_readonly");v(this,"_plugins",[]);v(this,"_inputEl",null);var o;this._readonly=t.readonly??!1,this.docModel=new De(t.initialDocument),this.selection=new Je(this.docModel),this.history=new Rn,this.commands=new On(this.docModel,this.selection,this.history),this.input=new Nn(this.commands,this.selection),(o=t.plugins)==null||o.forEach(a=>this.use(a))}exec(t,o){if(this._readonly&&!this._isReadCommand(t)){console.warn("[Editor] 只读模式,忽略写操作");return}this.commands.exec(t,o)}mount(t){this._inputEl=t,this._readonly||this.input.attach(t)}unmount(){this.input.detach(),this._inputEl=null}use(t){return this._plugins.find(o=>o.name===t.name)?(console.warn(`[Editor] 插件 ${t.name} 已安装`),this):(t.install(this),this._plugins.push(t),this)}getJSON(){return this.docModel.toJSON()}loadJSON(t){const o=De.fromJSON(t);Object.assign(this.docModel.data,o.data),this.history.clear()}get isReadonly(){return this._readonly}_isReadCommand(t){return["undo","redo","selectAll","setSelection"].includes(t)}}const Ye=Symbol("editor");function vn(n){const t=new ut(n);return e.provide(Ye,t),e.onUnmounted(()=>{t.unmount()}),t}function Vn(){const n=e.inject(Ye);if(!n)throw new Error("[useEditor] 必须在 EditorContainer 组件内使用");return n}const gt=$n,jn={install(n){n.component("EditorContainer",gt)}};X.Editor=ut,X.EditorContainer=gt,X.EditorKey=Ye,X.createEditor=vn,X.default=jn,X.useEditor=Vn,Object.defineProperties(X,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
2
|
+
`||k.value===""?(c.push([...S]),S=[]):S.push(k);(S.length||c.length===0)&&c.push([...S]),o.push({type:"list",listType:y.listType||"ul",listStyle:y.listStyle||"disc",items:c})}else if(y.listId){m(),p();const c=y.value===""||y.value===""?[]:[y];o.push({type:"list",listType:y.listType||"ul",listStyle:y.listStyle||"disc",items:[c]})}else y.value!=null&&/^[\n]+$/.test(y.value)?(i+=y.value.length,y.rowFlex&&(s=y.rowFlex)):(m(),a.push(y));return m(),p(),o}function Se(n){const t=n.filter(k=>k.type==="image").reduce((k,T)=>k+(T.height||T.width||0),0),o=n.filter(k=>k.type!=="image").map(k=>k.value||"").join("");if(!o)return t||20;const a=n.reduce((k,T)=>Math.max(k,T.size||0),0)||14,i=a+6,s=n.filter(k=>k.type==="tab").reduce((k,T)=>k+(T.size||Me),0),p=(o.match(/[一-龥]/g)||[]).length,m=(o.match(/[A-Za-z0-9]/g)||[]).length,y=o.length-p-m,c=p*a+m*(a*.55)+y*(a*.35)+s,S=Math.max(1,Math.ceil(c/at));return t+Math.max(i,S*i)}function an(n){if(!n||!n.length)return[[]];const t=[];let o=[];for(const a of n)a.type==="image"&&(a.width||0)>=at?(o.length&&(t.push(o),o=[]),t.push([a])):o.push(a);return o.length&&t.push(o),t.length?t:[[]]}function rt(n){if(n.length===0)return[];const t=new Array(n.length).fill(0);n.forEach((s,p)=>{(s.tdList||[]).forEach(m=>{const y=m.rowspan||1;if(y>1){const c=Math.min(p+y-1,n.length-1);t[p]=Math.max(t[p],c);for(let S=1;S<y&&p+S<n.length;S++)t[p+S]=Math.max(t[p+S],c)}})});const o=[];let a=0,i=0;for(let s=0;s<n.length;s++)i=Math.max(i,t[s]),i<=s&&(o.push(n.slice(a,s+1)),a=s+1,i=0);return a<n.length&&o.push(n.slice(a)),o}function We(n,t=0){const o=(n==null?void 0:n.width)||0,a=Math.max(nn-t,1);return!o||o<=a?1:a/o}function st(n){var s,p;const t=n.elements||[],o=((s=t.find(m=>m.rowFlex))==null?void 0:s.rowFlex)||n.rowFlex,a={textAlign:on[o]||"left"},i=(p=t.find(m=>m.rowMargin))==null?void 0:p.rowMargin;return i&&(a.lineHeight=i),a}function rn(n){var s;const t=Ae(n.value);let o=0,a=0,i=!1;for(const p of t)if(p.type==="paragraph"){if(!p.elements.length)continue;o++;for(const m of p.elements)(m.type==="image"||m.type==="table")&&(i=!0),a+=(m.value||"").length}else p.type==="list"?(o+=((s=p.items)==null?void 0:s.length)||1,i=!0):(o++,i=!0);return o>1||a>30||i?"top":n.verticalAlign||"middle"}function se(n){const t={};n.font&&(t.fontFamily=n.font),t.fontSize=(n.size||Me)+"px",n.bold!=null&&(t.fontWeight=n.bold?"bold":"normal"),n.italic!=null&&(t.fontStyle=n.italic?"italic":"normal"),n.color&&(t.color=n.color),n.highlight&&n.highlight!=="rgb(255, 255, 255)"&&n.highlight!=="#ffffff"&&(t.backgroundColor=n.highlight);const o=[n.underline&&"underline",n.strikeout&&"line-through"].filter(Boolean).join(" ");return o&&(t.textDecoration=o),n.letterSpacing&&(t.letterSpacing=n.letterSpacing+"px"),t}const sn=5;function ct(n,t=!1){var a,i;let o=0;for(const s of n)if(s.type==="table"){const p=((a=s.el)==null?void 0:a.trList)||[];o+=p.reduce((m,y)=>m+(y.height||y.minHeight||35),0)}else if(s.type==="title")o+=Se(s.titleValueList||((i=s.el)==null?void 0:i.valueList)||[]);else if(s.type==="paragraph")o+=Se(s.elements||[]);else if(s.type==="list"){const p=Math.round(18),m=(s.items||[]).reduce((y,c)=>y+(c.length?Se(c):p),0);o+=Math.max(m,p)}return o+(t&&o>0?sn:0)}const cn={key:0,class:"empty-line"},dn=["href"],hn=["src"],fn=["checked"],un=["checked"],gn={key:4,class:"ctrl-input"},pn=["checked"],mn=["checked"],yn={key:0},kn=["colspan","rowspan"],bn={key:0},_n=["src"],wn=["href"],xn=["checked"],Cn=["checked"],En=["checked"],Ge=Be({__name:"DocBlock",props:{block:{type:Object,required:!0},isHeaderFooter:{type:Boolean,default:!1}},setup(n){const t=n,o=e.inject("bindTableObserver",null),a=e.inject("resolveImageUrl",null);function i(p){if(!p)return"";const m=(a==null?void 0:a.value)||a;return typeof m=="function"?m(p):p}const s=e.computed(()=>t.isHeaderFooter?0:t.block.indentPx??0);return(p,m)=>{var y;return n.block.blockType==="title"?(e.openBlock(),e.createElementBlock("p",{key:0,class:e.normalizeClass(["doc-title",`doc-title--${n.block.level}`]),style:e.normalizeStyle({paddingLeft:s.value?s.value+"px":void 0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.titleValueList||[],(c,S)=>(e.openBlock(),e.createElementBlock("span",{key:S,style:e.normalizeStyle(e.unref(se)(c))},e.toDisplayString(c.value),5))),128))],6)):n.block.blockType==="paragraph"?(e.openBlock(),e.createElementBlock("p",{key:1,class:"doc-para",style:e.normalizeStyle({...e.unref(st)(n.block),paddingLeft:s.value?s.value+"px":void 0})},[n.block.elements.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",cn," ")),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.elements,(c,S)=>{var k,T,H,K,B,O,A,f,I,L,M,W,oe;return e.openBlock(),e.createElementBlock(e.Fragment,{key:S},[!c.type||c.type==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle(e.unref(se)(c))},e.toDisplayString(c.value),5)):c.type==="hyperlink"?(e.openBlock(),e.createElementBlock("a",{key:1,href:c.url,class:"doc-link",target:"_blank",rel:"noopener"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.valueList||[],(N,J)=>(e.openBlock(),e.createElementBlock("span",{key:J,style:e.normalizeStyle(e.unref(se)(N))},e.toDisplayString(N.value),5))),128))],8,dn)):c.type==="image"?(e.openBlock(),e.createElementBlock("img",{key:2,src:i(c.value),class:"doc-image",style:e.normalizeStyle({width:c.width?c.width+"px":"auto",height:c.height?c.height+"px":"auto"})},null,12,hn)):c.type==="control"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[((k=c.control)==null?void 0:k.type)==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle({fontSize:(c.control.size||12)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.control.value||[],(N,J)=>(e.openBlock(),e.createElementBlock("span",{key:J,style:e.normalizeStyle(e.unref(se)(N))},e.toDisplayString(N.value),5))),128))],4)):((T=c.control)==null?void 0:T.type)==="input"?(e.openBlock(),e.createElementBlock("span",{key:1,class:"ctrl-input",style:e.normalizeStyle({minWidth:(c.control.minWidth||60)+"px",fontSize:(c.control.size||12)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.control.value||[],(N,J)=>(e.openBlock(),e.createElementBlock("span",{key:J},e.toDisplayString(N.value),1))),128))],4)):((H=c.control)==null?void 0:H.type)==="radio"?(e.openBlock(),e.createElementBlock("span",{key:2,class:e.normalizeClass(["ctrl-options",{"ctrl-options--vertical":((B=(K=c.control.extension)==null?void 0:K.elementAttributes)==null?void 0:B.layout)==="vertical"}]),style:e.normalizeStyle({fontSize:(c.control.size||e.unref(Me))+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.control.valueSets||[],(N,J)=>(e.openBlock(),e.createElementBlock("label",{key:J,class:"ctrl-option"},[e.createElementVNode("input",{type:"radio",disabled:"",checked:c.control.code===N.code},null,8,fn),e.createTextVNode(" "+e.toDisplayString(N.value),1)]))),128))],6)):((O=c.control)==null?void 0:O.type)==="checkbox"?(e.openBlock(),e.createElementBlock("span",{key:3,class:e.normalizeClass(["ctrl-options",{"ctrl-options--vertical":((f=(A=c.control.extension)==null?void 0:A.elementAttributes)==null?void 0:f.layout)==="vertical"}]),style:e.normalizeStyle({fontSize:(c.control.size||e.unref(Me))+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.control.valueSets||[],(N,J)=>(e.openBlock(),e.createElementBlock("label",{key:J,class:"ctrl-option"},[e.createElementVNode("input",{type:"checkbox",disabled:"",checked:(c.control.code||"").split(",").includes(N.code)},null,8,un),e.createTextVNode(" "+e.toDisplayString(N.value),1)]))),128))],6)):((I=c.control)==null?void 0:I.type)==="select"?(e.openBlock(),e.createElementBlock("span",gn,e.toDisplayString(((M=(L=c.control.value)==null?void 0:L[0])==null?void 0:M.value)||c.control.placeholder||""),1)):e.createCommentVNode("",!0)],64)):c.type==="checkbox"?(e.openBlock(),e.createElementBlock("input",{key:4,type:"checkbox",checked:!!((W=c.checkbox)!=null&&W.value),disabled:"",class:"el-check"},null,8,pn)):c.type==="radio"?(e.openBlock(),e.createElementBlock("input",{key:5,type:"radio",checked:!!((oe=c.radio)!=null&&oe.value),disabled:"",class:"el-check"},null,8,mn)):c.type==="superscript"?(e.openBlock(),e.createElementBlock("sup",{key:6,style:e.normalizeStyle(e.unref(se)(c))},e.toDisplayString(c.value),5)):c.type==="subscript"?(e.openBlock(),e.createElementBlock("sub",{key:7,style:e.normalizeStyle(e.unref(se)(c))},e.toDisplayString(c.value),5)):c.type==="tab"?(e.openBlock(),e.createElementBlock("span",{key:8,class:"doc-tab",style:e.normalizeStyle({width:(c.size||e.unref(Me))+"px"})},null,4)):e.createCommentVNode("",!0)],64)}),128))],4)):n.block.blockType==="list"?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.block.listType==="ol"?"ol":"ul"),{key:2,class:"doc-list",style:e.normalizeStyle({listStyleType:n.block.listStyle==="decimal"?"decimal":n.block.listStyle==="lower-alpha"?"lower-alpha":"disc",paddingLeft:s.value?s.value+24+"px":void 0})},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.items,(c,S)=>(e.openBlock(),e.createElementBlock("li",{key:S,class:"doc-list-item"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c,(k,T)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:T},[!k.type||k.type==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle(e.unref(se)(k))},e.toDisplayString(k.value),5)):k.type==="superscript"?(e.openBlock(),e.createElementBlock("sup",{key:1,style:e.normalizeStyle(e.unref(se)(k))},e.toDisplayString(k.value),5)):k.type==="subscript"?(e.openBlock(),e.createElementBlock("sub",{key:2,style:e.normalizeStyle(e.unref(se)(k))},e.toDisplayString(k.value),5)):e.createCommentVNode("",!0)],64))),128))]))),128))]),_:1},8,["style"])):n.block.blockType==="table-row-group"?(e.openBlock(),e.createElementBlock("div",{key:3,class:e.normalizeClass(["doc-table-row-wrap",{"is-first":n.block.isFirst,"is-last":n.block.isLast,"is-page-break":n.block.isPageBreak}]),style:e.normalizeStyle({display:n.block.tableRowFlex?"flex":void 0,justifyContent:n.block.tableRowFlex==="right"?"flex-end":n.block.tableRowFlex==="center"?"center":n.block.tableRowFlex==="left"?"flex-start":void 0,paddingLeft:s.value?s.value+"px":void 0})},[e.createElementVNode("div",{style:e.normalizeStyle({overflow:n.block.sliceHeight!=null?"hidden":void 0,height:n.block.sliceHeight!=null?(n.block.isLast?n.block.sliceHeight+1:n.block.sliceHeight)+"px":void 0,width:n.block.tableEl.width?"max-content":"100%"})},[e.createElementVNode("table",{ref:n.block._baseKey&&e.unref(o)?c=>e.unref(o)(c,n.block._baseKey):void 0,class:e.normalizeClass(["doc-table",{"doc-table--no-border":n.block.tableEl.borderType==="empty","doc-table--header-footer":n.isHeaderFooter}]),style:e.normalizeStyle({width:n.block.tableEl.width?(n.isHeaderFooter?n.block.tableEl.width:n.block.tableEl.width*e.unref(We)(n.block.tableEl,s.value))+"px":"100%",transform:n.block.sliceOffset?`translateY(-${n.block.sliceOffset}px)`:void 0})},[(y=n.block.tableEl.colgroup)!=null&&y.length?(e.openBlock(),e.createElementBlock("colgroup",yn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.tableEl.colgroup,(c,S)=>(e.openBlock(),e.createElementBlock("col",{key:S,style:e.normalizeStyle({width:(n.isHeaderFooter?c.width:c.width*e.unref(We)(n.block.tableEl,s.value))+"px"})},null,4))),128))])):e.createCommentVNode("",!0),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.trGroup,(c,S)=>(e.openBlock(),e.createElementBlock("tr",{key:S,style:e.normalizeStyle({height:(c.height||c.minHeight||30)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.tdList||[],(k,T)=>(e.openBlock(),e.createElementBlock("td",{key:T,colspan:k.colspan||1,rowspan:k.rowspan||1,style:e.normalizeStyle({backgroundColor:k.backgroundColor||void 0,verticalAlign:e.unref(rn)(k),width:k.width?k.width*e.unref(We)(n.block.tableEl,s.value)+"px":void 0,height:k.height?k.height+"px":void 0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(Ae)(k.value),(H,K)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:K},[H.type==="paragraph"?(e.openBlock(),e.createElementBlock("p",{key:0,class:"cell-para",style:e.normalizeStyle(e.unref(st)(H))},[H.elements.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",bn," ")),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(H.elements,(B,O)=>{var A,f,I,L,M,W,oe;return e.openBlock(),e.createElementBlock(e.Fragment,{key:O},[!B.type||B.type==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle(e.unref(se)(B))},e.toDisplayString(B.value),5)):B.type==="image"?(e.openBlock(),e.createElementBlock("img",{key:1,src:i(B.value),class:"doc-image",style:e.normalizeStyle({width:B.width?B.width+"px":"auto",height:B.height?B.height+"px":"auto"})},null,12,_n)):B.type==="hyperlink"?(e.openBlock(),e.createElementBlock("a",{key:2,href:B.url,class:"doc-link",target:"_blank"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B.valueList||[],(N,J)=>(e.openBlock(),e.createElementBlock("span",{key:J,style:e.normalizeStyle(e.unref(se)(N))},e.toDisplayString(N.value),5))),128))],8,wn)):B.type==="control"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[((A=B.control)==null?void 0:A.type)==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle({fontSize:(B.control.size||12)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B.control.value||[],(N,J)=>(e.openBlock(),e.createElementBlock("span",{key:J,style:e.normalizeStyle(e.unref(se)(N))},e.toDisplayString(N.value),5))),128))],4)):((f=B.control)==null?void 0:f.type)==="input"?(e.openBlock(),e.createElementBlock("span",{key:1,class:"ctrl-input",style:e.normalizeStyle({fontSize:(B.control.size||12)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B.control.value||[],(N,J)=>(e.openBlock(),e.createElementBlock("span",{key:J},e.toDisplayString(N.value),1))),128))],4)):((I=B.control)==null?void 0:I.type)==="radio"?(e.openBlock(),e.createElementBlock("span",{key:2,class:e.normalizeClass(["ctrl-options",{"ctrl-options--vertical":((M=(L=B.control.extension)==null?void 0:L.elementAttributes)==null?void 0:M.layout)==="vertical"}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B.control.valueSets||[],(N,J)=>(e.openBlock(),e.createElementBlock("label",{key:J,class:"ctrl-option"},[e.createElementVNode("input",{type:"radio",disabled:"",checked:B.control.code===N.code},null,8,xn),e.createTextVNode(e.toDisplayString(N.value),1)]))),128))],2)):e.createCommentVNode("",!0)],64)):B.type==="checkbox"?(e.openBlock(),e.createElementBlock("input",{key:4,type:"checkbox",checked:!!((W=B.checkbox)!=null&&W.value),disabled:"",class:"el-check"},null,8,Cn)):B.type==="radio"?(e.openBlock(),e.createElementBlock("input",{key:5,type:"radio",checked:!!((oe=B.radio)!=null&&oe.value),disabled:"",class:"el-check"},null,8,En)):B.type==="superscript"?(e.openBlock(),e.createElementBlock("sup",{key:6,style:e.normalizeStyle(e.unref(se)(B))},e.toDisplayString(B.value),5)):B.type==="subscript"?(e.openBlock(),e.createElementBlock("sub",{key:7,style:e.normalizeStyle(e.unref(se)(B))},e.toDisplayString(B.value),5)):B.type==="tab"?(e.openBlock(),e.createElementBlock("span",{key:8,class:"doc-tab",style:e.normalizeStyle({width:(B.size||e.unref(Me))+"px"})},null,4)):e.createCommentVNode("",!0)],64)}),128))],4)):e.createCommentVNode("",!0)],64))),128))],12,kn))),128))],4))),128))])],6)],4)],6)):e.createCommentVNode("",!0)}}},[["__scopeId","data-v-b43bda01"]]),Bn={class:"editor-layout word-editor-scope"},Mn={class:"editor-container"},Sn={key:0,class:"editor-loading"},Fn={key:0,class:"doc-header"},In={class:"doc-footer"},Tn={class:"doc-page-number"},An=1123,Pn=50,Ln=20,$n=Be({__name:"index",props:{data:{type:[Array,Object],default:()=>[]},loading:{type:Boolean,default:!1},resolveImageUrl:{type:Function,default:null}},setup(n){const t=n,o=e.computed(()=>{const f=t.data;return f?!Array.isArray(f)&&f.main?f.main:Array.isArray(f)?f:[]:[]}),a=e.ref(null),i=e.ref({});let s=null;e.onMounted(()=>{s=new ResizeObserver(f=>{const I={};for(const L of f){const M=L.target._rowKey;if(!M)continue;const W=Math.round(L.contentRect.height);W>(i.value[M]||0)&&(I[M]=W)}Object.keys(I).length&&(i.value={...i.value,...I})})}),e.onUnmounted(()=>{s==null||s.disconnect(),s=null});function p(f,I){!f||!s||(f._rowKey=I,s.observe(f))}e.provide("bindTableObserver",p),e.provide("resolveImageUrl",t.resolveImageUrl);const m=e.computed(()=>Math.max(100,An-Pn*2-k.value-Ln)),y=e.computed(()=>{const f=Ae(o.value),I=[],L=m.value;let M=0,W=!1;const oe=R=>{I.push({...R,_isCover:W})},N=tn(),J={first:0,second:1,third:2,fourth:3,fifth:4,sixth:5,seventh:6,eighth:7};let pe=-1;const He=R=>{var le,ce,me;return!!((le=R.el)!=null&&le._coverBreakBefore||(me=(ce=R.elements)==null?void 0:ce[0])!=null&&me._coverBreakBefore)};return f.forEach((R,le)=>{var me,Ze,Oe,Ne;const ce=He(R);if(ce&&(M=0),W=!!R._isCover,R.type==="title"){const ae=R.el.valueList||[],ee=N.next(R.el.level,(me=R.el.extension)==null?void 0:me.startIndex),ue=ae.some(ie=>{var de;return(de=ie.extension)==null?void 0:de.isIndex});let ye=ae;if(!ue&&ee){const ie=ae[0]||{};ye=[{value:ee,size:ie.size,bold:ie.bold,italic:ie.italic,color:ie.color,font:ie.font,extension:{isIndex:!0}},...ae]}const ge=ye.map(ie=>ie.value||"").join(""),Y=Se(ye);M=M+Y>L&&M>0?Y:M+Y,pe=J[R.el.level]??0,oe({node_id:`blk_${le}_0`,layer:ce?1:100,blockType:"title",level:R.el.level,titleEl:R.el,titleValueList:ye,content_type:"text",content:ge,height:Y,indentPx:pe*20})}else if(R.type==="paragraph"){const ae=an(R.elements),ee=pe>=0?(pe+1)*20:0;ae.forEach((ue,ye)=>{const ge=ue.map(ie=>ie.value||"").join(""),Y=Se(ue);M=M+Y>L&&M>0?Y:M+Y,oe({node_id:`blk_${le}_${ye}`,layer:ce&&ye===0?1:100,blockType:"paragraph",elements:ue,rowFlex:R.rowFlex,content_type:"text",content:ge,height:Y,indentPx:ee})})}else if(R.type==="table"){const ae=!!((Ze=R.el.extension)!=null&&Ze.isTitleTable),ee=((Oe=R.el.extension)==null?void 0:Oe.elementType)==="signOff",ue=((Ne=R.el.extension)==null?void 0:Ne.elementType)==="stepTable",ye=ee||ue,ge=ae||ee?0:pe>=0?(pe+1)*20:0,Y=rt(R.el.trList||[]),ie=Y.length;if(ye){const de=Y.flat(),D=de.reduce((Z,G)=>Z+(G.height||G.minHeight||35),0),ke=`blk_${le}_0`,he=Math.max(D,i.value[ke]||0);if(M>0&&M+he>L&&(M=0),he>L){const Z=Math.ceil(he/L);for(let G=0;G<Z;G++){const te=G*L,be=Math.min(L,he-te),Ce=G>0||M>0;M=be,oe({node_id:`blk_${le}_0_s${G}`,layer:ce&&G===0?1:100,blockType:"table-row-group",content_type:"table-row",rowHeight:he,trGroup:de,tableEl:R.el,tableRowFlex:R.el.rowFlex||null,isFirst:G===0,isLast:G===Z-1,isPageBreak:Ce,sliceOffset:te,sliceHeight:be,_baseKey:G===0?ke:void 0,height:be,indentPx:ge})}}else{const Z=M>0;M=M+he>L?he:M+he,oe({node_id:`blk_${le}_0`,layer:ce?1:100,blockType:"table-row-group",content_type:"table-row",rowHeight:he,trGroup:de,tableEl:R.el,tableRowFlex:R.el.rowFlex||null,isFirst:!0,isLast:!0,isPageBreak:Z,indentPx:ge})}}else Y.forEach((de,D)=>{const ke=`blk_${le}_${D}`,he=de.reduce((G,te)=>G+(te.height||te.minHeight||35),0),Z=Math.max(he,i.value[ke]||0);if(Z>L){const G=Math.ceil(Z/L);for(let te=0;te<G;te++){const be=te*L,Ce=Math.min(L,Z-be),Qe=te>0||M>0;M=Ce,oe({node_id:`blk_${le}_${D}_s${te}`,layer:ce&&D===0&&te===0?1:100,blockType:"table-row-group",content_type:"table-row",rowHeight:Z,trGroup:de,tableEl:R.el,tableRowFlex:R.el.rowFlex||null,isFirst:D===0&&te===0,isLast:D===ie-1&&te===G-1,isPageBreak:Qe,sliceOffset:be,sliceHeight:Ce,_baseKey:te===0?ke:void 0,height:Ce,indentPx:ge})}}else{const G=D>0&&M+Z>L;M=M+Z>L?Z:M+Z,oe({node_id:`blk_${le}_${D}`,layer:ce&&D===0?1:100,blockType:"table-row-group",content_type:"table-row",rowHeight:Z,trGroup:de,tableEl:R.el,tableRowFlex:R.el.rowFlex||null,isFirst:D===0,isLast:D===ie-1,isPageBreak:G,indentPx:ge})}})}else if(R.type==="list"){const ae=Math.round(18);let ee=0;for(const ue of R.items)ee+=ue.length?Se(ue):ae;ee=Math.max(ee,ae),M=M+ee>L&&M>0?ee:M+ee,oe({node_id:`blk_${le}_0`,layer:ce?1:100,blockType:"list",listType:R.listType,listStyle:R.listStyle,items:R.items,height:ee,indentPx:pe>=0?(pe+1)*20:0})}}),I}),c=e.computed(()=>{var I;const f=(I=t.data)==null?void 0:I.header;return f!=null&&f.length?Ae(f):[]}),S=e.computed(()=>{var I;const f=(I=t.data)==null?void 0:I.footer;return f!=null&&f.length?Ae(f):[]}),k=e.computed(()=>ct(c.value,!0)),T=e.computed(()=>ct(S.value,!0)),H=e.computed(()=>c.value.length>0),K=e.computed(()=>S.value.length>0);function B(f){var L,M,W;const I=f.type==="table";return{blockType:I?"table-row-group":f.type,elements:f.elements,rowFlex:f.rowFlex,level:(L=f.el)==null?void 0:L.level,titleValueList:((M=f.el)==null?void 0:M.valueList)||f.titleValueList,listType:f.listType,listStyle:f.listStyle,items:f.items,indentPx:0,trGroup:I?rt(f.el.trList).flat():void 0,tableEl:I?f.el:void 0,isFirst:!0,isLast:!0,tableRowFlex:((W=f.el)==null?void 0:W.rowFlex)||null}}const O=e.computed(()=>Qt(y.value));function A(f){var I;(I=a.value)==null||I.scrollToRow({node_id:f.nodeId})}return(f,I)=>(e.openBlock(),e.createElementBlock("div",Bn,[e.createVNode(Xt,{items:O.value,onNavigate:A},null,8,["items"]),e.createElementVNode("div",Mn,[n.loading?(e.openBlock(),e.createElementBlock("div",Sn," 加载中… ")):(e.openBlock(),e.createBlock(e.unref(zt),{key:1,ref_key:"virtualTableRef",ref:a,"show-header":!1,"row-config":{keyField:"node_id"},"page-config":{enabled:!0,pageHeight:1123,pageWidth:860,margin:50,gap:16,showPageHeader:H.value,showPageBorder:!0,pageBorderPadding:5,pageBorderStyle:"1px solid #333",headerHeight:k.value,footerHeight:T.value,showPageNumber:!0},data:y.value},e.createSlots({default:e.withCtx(()=>[e.createVNode(e.unref(Ht),null,{default:e.withCtx(({row:L})=>[e.createVNode(Ge,{block:L},null,8,["block"])]),_:1})]),_:2},[H.value?{name:"page-header",fn:e.withCtx(({isCoverPage:L})=>[L?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Fn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,(M,W)=>(e.openBlock(),e.createBlock(Ge,{key:W,block:B(M),"is-header-footer":!0},null,8,["block"]))),128))]))]),key:"0"}:void 0,K.value?{name:"page-footer",fn:e.withCtx(({pageNumber:L,totalPages:M})=>[e.createElementVNode("div",In,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(S.value,(W,oe)=>(e.openBlock(),e.createBlock(Ge,{key:oe,block:B(W),"is-header-footer":!0},null,8,["block"]))),128)),e.createElementVNode("div",Tn," 第"+e.toDisplayString(L)+"页 / 共"+e.toDisplayString(M)+"页 ",1)])]),key:"1"}:void 0]),1032,["page-config","data"]))])]))}},[["__scopeId","data-v-18dd3aa4"]]),dt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function Re(n=10){const t=crypto.getRandomValues(new Uint8Array(n));return Array.from(t).map(o=>dt[o%dt.length]).join("")}class De{constructor(t){v(this,"data");this.data=e.reactive({id:Re(),version:1,sections:[this.createEmptySection()],pageWidth:595,pageHeight:842,marginTop:72,marginBottom:72,marginLeft:90,marginRight:90,...t})}createEmptySection(){return{id:Re(),paragraphs:[this.createEmptyParagraph()]}}createEmptyParagraph(t){return{id:Re(),type:"paragraph",format:t??{},children:[]}}createTextElement(t,o){return{id:Re(),type:"text",value:t,format:o??{}}}getSectionCount(){return this.data.sections.length}getParagraphCount(t=0){var o;return((o=this.data.sections[t])==null?void 0:o.paragraphs.length)??0}getAllParagraphs(){const t=[];return this.data.sections.forEach((o,a)=>{o.paragraphs.forEach((i,s)=>{t.push({paragraph:i,sectionIndex:a,paragraphIndex:s})})}),t}getParagraphAt(t,o){var a;return((a=this.data.sections[t])==null?void 0:a.paragraphs[o])??null}getElementAt(t){const o=this.getParagraphAt(t.sectionIndex,t.paragraphIndex);return(o==null?void 0:o.children[t.elementIndex])??null}insertText(t,o,a){const i=this.getParagraphAt(t.sectionIndex,t.paragraphIndex);if(!i)return;const s=i.children[t.elementIndex];if(s&&s.type==="text")s.value=s.value.slice(0,t.offset)+o+s.value.slice(t.offset);else{const p=this.createTextElement(o,a);i.children.splice(t.elementIndex,0,p)}this.bumpVersion()}deleteAt(t,o){const a=this.getParagraphAt(t.sectionIndex,t.paragraphIndex);if(!a)return;const i=a.children[t.elementIndex];!i||i.type!=="text"||(i.value=i.value.slice(0,t.offset)+i.value.slice(t.offset+o),i.value===""&&a.children.splice(t.elementIndex,1),this.bumpVersion())}insertParagraph(t,o,a){const i=this.data.sections[t];if(!i)throw new Error(`Section ${t} not found`);const s=this.createEmptyParagraph(a);return i.paragraphs.splice(o+1,0,s),this.bumpVersion(),s}mergeParagraphs(t,o){const a=this.data.sections[t];if(!a)return;const i=a.paragraphs[o],s=a.paragraphs[o+1];!i||!s||(i.children.push(...s.children),a.paragraphs.splice(o+1,1),this.bumpVersion())}updateParagraphFormat(t,o,a){const i=this.getParagraphAt(t,o);i&&(i.format={...i.format,...a},this.bumpVersion())}updateElementFormat(t,o){const a=this.getElementAt(t);a&&(a.format={...a.format,...o},this.bumpVersion())}updateRangeFormat(t,o,a){const i=this.getAllParagraphs();let s=!1;for(const{paragraph:p,sectionIndex:m,paragraphIndex:y}of i){const c=m===t.sectionIndex&&y===t.paragraphIndex,S=m===o.sectionIndex&&y===o.paragraphIndex;if(c&&(s=!0),s)for(let k=0;k<p.children.length;k++){const T=p.children[k];if(!(c&&k<t.elementIndex)){if(S&&k>o.elementIndex)break;T.format={...T.format,...a}}}if(S)break}this.bumpVersion()}bumpVersion(){this.data.version++}toJSON(){return JSON.stringify(this.data,null,2)}static fromJSON(t){const o=JSON.parse(t),a=new De;return Object.assign(a.data,o),a}}function we(n=0,t=0,o=0,a=0){return{sectionIndex:n,paragraphIndex:t,elementIndex:o,offset:a}}function ht(n,t){return n.sectionIndex===t.sectionIndex&&n.paragraphIndex===t.paragraphIndex&&n.elementIndex===t.elementIndex&&n.offset===t.offset}class Je{constructor(t){v(this,"_selection",e.reactive({anchor:we(),focus:we(),isCollapsed:!0}));v(this,"_docModel");v(this,"hasSelection",e.computed(()=>!this._selection.isCollapsed));this._docModel=t}get selection(){return this._selection}setCursor(t){this._selection.anchor={...t},this._selection.focus={...t},this._selection.isCollapsed=!0}setSelection(t,o){this._selection.anchor={...t},this._selection.focus={...o},this._selection.isCollapsed=ht(t,o)}collapse(t=!0){t?this._selection.anchor={...this._selection.focus}:this._selection.focus={...this._selection.anchor},this._selection.isCollapsed=!0}selectAll(){const t=this._docModel.data.sections,o=t[t.length-1],a=o==null?void 0:o.paragraphs[o.paragraphs.length-1],i=a==null?void 0:a.children[a.children.length-1],s=(i==null?void 0:i.type)==="text"?i.value.length:0;this._selection.anchor=we(0,0,0,0),this._selection.focus=we(t.length-1,((o==null?void 0:o.paragraphs.length)??1)-1,((a==null?void 0:a.children.length)??0)===0?0:((a==null?void 0:a.children.length)??1)-1,s),this._selection.isCollapsed=!1}moveForward(t=!1){const o=this._selection.focus,a=this._docModel.getParagraphAt(o.sectionIndex,o.paragraphIndex);if(!a)return;const i=a.children[o.elementIndex];if((i==null?void 0:i.type)==="text"&&o.offset<i.value.length){const p={...o,offset:o.offset+1};this._applyMove(p,t);return}if(o.elementIndex<a.children.length-1){const p={...o,elementIndex:o.elementIndex+1,offset:0};this._applyMove(p,t);return}const s=this._getNextParagraphPoint(o);s&&this._applyMove(s,t)}moveBackward(t=!1){const o=this._selection.focus;if(o.offset>0){const i={...o,offset:o.offset-1};this._applyMove(i,t);return}if(o.elementIndex>0){const i=this._docModel.getParagraphAt(o.sectionIndex,o.paragraphIndex),s=i==null?void 0:i.children[o.elementIndex-1],p=(s==null?void 0:s.type)==="text"?s.value.length:0,m={...o,elementIndex:o.elementIndex-1,offset:p};this._applyMove(m,t);return}const a=this._getPrevParagraphPoint(o);a&&this._applyMove(a,t)}_applyMove(t,o){o?(this._selection.focus=t,this._selection.isCollapsed=ht(this._selection.anchor,t)):(this._selection.anchor={...t},this._selection.focus={...t},this._selection.isCollapsed=!0)}_getNextParagraphPoint(t){const o=this._docModel.data.sections[t.sectionIndex];return o?t.paragraphIndex<o.paragraphs.length-1?we(t.sectionIndex,t.paragraphIndex+1,0,0):t.sectionIndex<this._docModel.data.sections.length-1?we(t.sectionIndex+1,0,0,0):null:null}_getPrevParagraphPoint(t){if(t.paragraphIndex>0){const o=this._docModel.getParagraphAt(t.sectionIndex,t.paragraphIndex-1);if(!o)return null;const a=o.children.length-1,i=o.children[a],s=(i==null?void 0:i.type)==="text"?i.value.length:0;return we(t.sectionIndex,t.paragraphIndex-1,Math.max(a,0),s)}if(t.sectionIndex>0){const o=this._docModel.data.sections[t.sectionIndex-1];if(!o)return null;const a=o.paragraphs.length-1,i=o.paragraphs[a],s=((i==null?void 0:i.children.length)??0)-1,p=i==null?void 0:i.children[s],m=(p==null?void 0:p.type)==="text"?p.value.length:0;return we(t.sectionIndex-1,a,Math.max(s,0),m)}return null}static domToModelPoint(t,o){let a=t instanceof Element?t:t.parentElement;for(;a;){const i=a.getAttribute("data-si"),s=a.getAttribute("data-pi"),p=a.getAttribute("data-ei");if(i!==null&&s!==null&&p!==null)return{sectionIndex:parseInt(i),paragraphIndex:parseInt(s),elementIndex:parseInt(p),offset:o};a=a.parentElement}return null}}const zn=200;class Rn{constructor(){v(this,"_undoStack",[]);v(this,"_redoStack",[])}get canUndo(){return this._undoStack.length>0}get canRedo(){return this._redoStack.length>0}push(t){var a,i;this._redoStack=[];const o=this._undoStack[this._undoStack.length-1];if(o&&((a=t.canMergeWith)!=null&&a.call(t,o))){(i=o.merge)==null||i.call(o,t);return}this._undoStack.push(t),this._undoStack.length>zn&&this._undoStack.shift()}undo(){const t=this._undoStack.pop();return t?(t.undo(),this._redoStack.push(t),!0):!1}redo(){const t=this._redoStack.pop();return t?(t.execute(),this._undoStack.push(t),!0):!1}clear(){this._undoStack=[],this._redoStack=[]}}class Dn{constructor(t,o,a,i,s){v(this,"name","insertText");v(this,"_point");v(this,"_text");v(this,"_format");this.docModel=t,this.selectionManager=o,this._point={...a},this._text=i,this._format=s}execute(){this.docModel.insertText(this._point,this._text,this._format),this.selectionManager.setCursor({...this._point,offset:this._point.offset+this._text.length})}undo(){this.docModel.deleteAt(this._point,this._text.length),this.selectionManager.setCursor(this._point)}canMergeWith(t){if(t.name!=="insertText")return!1;const o=t;return o._point.sectionIndex===this._point.sectionIndex&&o._point.paragraphIndex===this._point.paragraphIndex&&o._point.elementIndex===this._point.elementIndex&&o._point.offset===this._point.offset+this._text.length}merge(t){const o=t;this._text+=o._text}}class Hn{constructor(t,o){v(this,"name","insertParagraph");v(this,"_insertedParagraphId",null);this.docModel=t,this.selectionManager=o}execute(){var y,c;const{focus:t}=this.selectionManager.selection,{sectionIndex:o,paragraphIndex:a}=t,i=this.docModel.getParagraphAt(o,a);if(!i)return;const s=t.elementIndex,p=i.children.splice(s),m=this.docModel.createEmptyParagraph(i.format);m.children.push(...p),this._insertedParagraphId=m.id,this.docModel.data.sections[o].paragraphs.splice(a+1,0,m),(c=(y=this.docModel).bumpVersion)==null||c.call(y),this.selectionManager.setCursor({sectionIndex:o,paragraphIndex:a+1,elementIndex:0,offset:0})}undo(){const{focus:t}=this.selectionManager.selection,{sectionIndex:o,paragraphIndex:a}=t;a!==0&&(this.docModel.mergeParagraphs(o,a-1),this.selectionManager.setCursor({sectionIndex:o,paragraphIndex:a-1,elementIndex:0,offset:0}))}}class ft{constructor(t,o,a){v(this,"name");v(this,"_deletedText","");this.docModel=t,this.selectionManager=o,this.name=a==="backward"?"deleteBackward":"deleteForward"}execute(){const{focus:t,isCollapsed:o}=this.selectionManager.selection;if(o)if(this.name==="deleteBackward")if(t.offset>0){const a={...t,offset:t.offset-1},i=this.docModel.getElementAt(t);(i==null?void 0:i.type)==="text"&&(this._deletedText=i.value[t.offset-1]??""),this.docModel.deleteAt(a,1),this.selectionManager.setCursor(a)}else(t.paragraphIndex>0||t.elementIndex>0)&&(this.docModel.mergeParagraphs(t.sectionIndex,t.paragraphIndex-1),this.selectionManager.setCursor({...t,paragraphIndex:t.paragraphIndex-1}));else{const a=this.docModel.getElementAt(t);if((a==null?void 0:a.type)==="text"&&t.offset<a.value.length)this._deletedText=a.value[t.offset],this.docModel.deleteAt(t,1);else{const i=this.docModel.data.sections[t.sectionIndex];i&&t.paragraphIndex<i.paragraphs.length-1&&this.docModel.mergeParagraphs(t.sectionIndex,t.paragraphIndex)}}}undo(){if(this._deletedText){const{focus:t}=this.selectionManager.selection;this.docModel.insertText(t,this._deletedText)}}}class Pe{constructor(t,o,a,i){v(this,"name");v(this,"_prevFormat",{});this.docModel=t,this.selectionManager=o,this._value=i,this.name=a}execute(){const{anchor:t,focus:o}=this.selectionManager.selection,a=this._getFormatKey();if(!a)return;const i={};if(this._isToggle()){const s=this._getCurrentValue(a);i[a]=!s}else i[a]=this._value;this.docModel.updateRangeFormat(t,o,i)}undo(){const{anchor:t,focus:o}=this.selectionManager.selection;this.docModel.updateRangeFormat(t,o,this._prevFormat)}_isToggle(){return["bold","italic","underline","strikethrough","superscript","subscript"].includes(this.name)}_getFormatKey(){return{bold:"bold",italic:"italic",underline:"underline",strikethrough:"strikethrough",fontSize:"fontSize",fontFamily:"fontFamily",color:"color",backgroundColor:"backgroundColor"}[this.name]??null}_getCurrentValue(t){var i;const{focus:o}=this.selectionManager.selection,a=this.docModel.getElementAt(o);return(i=a==null?void 0:a.format)==null?void 0:i[t]}}class Xe{constructor(t,o,a,i){v(this,"name","textAlign");this.docModel=t,this.selectionManager=o,this._formatKey=a,this._value=i}execute(){const{focus:t}=this.selectionManager.selection,o={};o[this._formatKey]=this._value,this.docModel.updateParagraphFormat(t.sectionIndex,t.paragraphIndex,o)}undo(){}}class On{constructor(t,o,a){v(this,"_factories",new Map);this.docModel=t,this.selectionManager=o,this.historyManager=a,this._registerBuiltinCommands()}_registerBuiltinCommands(){this.register("insertText",o=>{const{focus:a}=this.selectionManager.selection;return new Dn(this.docModel,this.selectionManager,a,o)}),this.register("insertParagraph",()=>new Hn(this.docModel,this.selectionManager)),this.register("deleteBackward",()=>new ft(this.docModel,this.selectionManager,"backward")),this.register("deleteForward",()=>new ft(this.docModel,this.selectionManager,"forward")),this.register("undo",()=>null),this.register("redo",()=>null),["bold","italic","underline","strikethrough","superscript","subscript"].forEach(o=>{this.register(o,()=>new Pe(this.docModel,this.selectionManager,o))}),this.register("fontSize",o=>new Pe(this.docModel,this.selectionManager,"fontSize",o)),this.register("fontFamily",o=>new Pe(this.docModel,this.selectionManager,"fontFamily",o)),this.register("color",o=>new Pe(this.docModel,this.selectionManager,"color",o)),this.register("backgroundColor",o=>new Pe(this.docModel,this.selectionManager,"backgroundColor",o)),this.register("textAlign",o=>new Xe(this.docModel,this.selectionManager,"textAlign",o)),this.register("lineHeight",o=>new Xe(this.docModel,this.selectionManager,"lineHeight",o)),this.register("heading",o=>new Xe(this.docModel,this.selectionManager,"heading",o)),this.register("selectAll",()=>(this.selectionManager.selectAll(),null)),this.register("setSelection",o=>{if(o){const a=o;this.selectionManager.setSelection(a.anchor,a.focus)}return null})}register(t,o){this._factories.set(t,o)}exec(t,o){if(t==="undo"){this.historyManager.undo();return}if(t==="redo"){this.historyManager.redo();return}const a=this._factories.get(t);if(!a){console.warn(`[CommandManager] 未注册命令: ${t}`);return}const i=a(o);i&&(i.execute(),this.historyManager.push(i))}}class Nn{constructor(t,o){v(this,"_el",null);v(this,"_commandManager");v(this,"_selectionManager");v(this,"_composing",!1);v(this,"_boundKeydown");v(this,"_boundBeforeInput");v(this,"_boundCompositionStart");v(this,"_boundCompositionEnd");v(this,"_boundSelectionChange");this._commandManager=t,this._selectionManager=o,this._boundKeydown=this._onKeydown.bind(this),this._boundBeforeInput=this._onBeforeInput.bind(this),this._boundCompositionStart=()=>{this._composing=!0},this._boundCompositionEnd=this._onCompositionEnd.bind(this),this._boundSelectionChange=this._onSelectionChange.bind(this)}attach(t){this._el=t,t.addEventListener("keydown",this._boundKeydown),t.addEventListener("beforeinput",this._boundBeforeInput),t.addEventListener("compositionstart",this._boundCompositionStart),t.addEventListener("compositionend",this._boundCompositionEnd),document.addEventListener("selectionchange",this._boundSelectionChange)}detach(){this._el&&(this._el.removeEventListener("keydown",this._boundKeydown),this._el.removeEventListener("beforeinput",this._boundBeforeInput),this._el.removeEventListener("compositionstart",this._boundCompositionStart),this._el.removeEventListener("compositionend",this._boundCompositionEnd),document.removeEventListener("selectionchange",this._boundSelectionChange),this._el=null)}_onKeydown(t){const o=t.key,a=t.ctrlKey||t.metaKey,i=t.shiftKey;if(a)switch(o){case"z":t.preventDefault(),i?this._commandManager.exec("redo"):this._commandManager.exec("undo");return;case"b":t.preventDefault(),this._commandManager.exec("bold");return;case"i":t.preventDefault(),this._commandManager.exec("italic");return;case"u":t.preventDefault(),this._commandManager.exec("underline");return;case"a":t.preventDefault(),this._commandManager.exec("selectAll");return}switch(o){case"Enter":t.preventDefault(),this._composing||this._commandManager.exec("insertParagraph");break;case"Backspace":t.preventDefault(),this._composing||this._commandManager.exec("deleteBackward");break;case"Delete":t.preventDefault(),this._composing||this._commandManager.exec("deleteForward");break;case"ArrowLeft":t.preventDefault(),this._selectionManager.moveBackward(i);break;case"ArrowRight":t.preventDefault(),this._selectionManager.moveForward(i);break;case"Tab":t.preventDefault(),this._commandManager.exec("insertText"," ");break}}_onBeforeInput(t){t.preventDefault(),!this._composing&&t.data&&this._commandManager.exec("insertText",t.data)}_onCompositionEnd(t){this._composing=!1,t.data&&this._commandManager.exec("insertText",t.data)}_onSelectionChange(){const t=window.getSelection();if(!t||!this._el)return;const o=t.anchorNode,a=t.focusNode;if(!o||!a||!this._el.contains(o)&&!this._el.contains(a))return;const i=Je.domToModelPoint(o,t.anchorOffset),s=Je.domToModelPoint(a,t.focusOffset);i&&s&&this._selectionManager.setSelection(i,s)}}class ut{constructor(t={}){v(this,"docModel");v(this,"selection");v(this,"history");v(this,"commands");v(this,"input");v(this,"_readonly");v(this,"_plugins",[]);v(this,"_inputEl",null);var o;this._readonly=t.readonly??!1,this.docModel=new De(t.initialDocument),this.selection=new Je(this.docModel),this.history=new Rn,this.commands=new On(this.docModel,this.selection,this.history),this.input=new Nn(this.commands,this.selection),(o=t.plugins)==null||o.forEach(a=>this.use(a))}exec(t,o){if(this._readonly&&!this._isReadCommand(t)){console.warn("[Editor] 只读模式,忽略写操作");return}this.commands.exec(t,o)}mount(t){this._inputEl=t,this._readonly||this.input.attach(t)}unmount(){this.input.detach(),this._inputEl=null}use(t){return this._plugins.find(o=>o.name===t.name)?(console.warn(`[Editor] 插件 ${t.name} 已安装`),this):(t.install(this),this._plugins.push(t),this)}getJSON(){return this.docModel.toJSON()}loadJSON(t){const o=De.fromJSON(t);Object.assign(this.docModel.data,o.data),this.history.clear()}get isReadonly(){return this._readonly}_isReadCommand(t){return["undo","redo","selectAll","setSelection"].includes(t)}}const Ye=Symbol("editor");function vn(n){const t=new ut(n);return e.provide(Ye,t),e.onUnmounted(()=>{t.unmount()}),t}function Vn(){const n=e.inject(Ye);if(!n)throw new Error("[useEditor] 必须在 EditorContainer 组件内使用");return n}const gt=$n,jn={install(n){n.component("EditorContainer",gt)}};X.Editor=ut,X.EditorContainer=gt,X.EditorKey=Ye,X.createEditor=vn,X.default=jn,X.useEditor=Vn,Object.defineProperties(X,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|