@qxs-bns/components-wc 0.0.2

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.
Files changed (141) hide show
  1. package/es/base/define.mjs +2 -0
  2. package/es/base/define.mjs.map +1 -0
  3. package/es/base/uid.mjs +2 -0
  4. package/es/base/uid.mjs.map +1 -0
  5. package/es/editor/blocksuite-editor.mjs +931 -0
  6. package/es/editor/blocksuite-editor.mjs.map +1 -0
  7. package/es/editor/index.mjs +2 -0
  8. package/es/editor/index.mjs.map +1 -0
  9. package/es/index.mjs +2 -0
  10. package/es/index.mjs.map +1 -0
  11. package/es/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/css-tag.mjs +7 -0
  12. package/es/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/css-tag.mjs.map +1 -0
  13. package/es/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.mjs +7 -0
  14. package/es/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.mjs.map +1 -0
  15. package/es/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.mjs +7 -0
  16. package/es/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.mjs.map +1 -0
  17. package/es/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/reactive-element.mjs +7 -0
  18. package/es/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/reactive-element.mjs.map +1 -0
  19. package/es/node_modules/.pnpm/@tiptap_extension-placeholder@3.20.5_@tiptap_extensions@3.20.5_@tiptap_core@3.20.5_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.mjs +2 -0
  20. package/es/node_modules/.pnpm/@tiptap_extension-placeholder@3.20.5_@tiptap_extensions@3.20.5_@tiptap_core@3.20.5_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.mjs.map +1 -0
  21. package/es/node_modules/.pnpm/@tiptap_extensions@3.20.5_@tiptap_core@3.20.5_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.mjs +2 -0
  22. package/es/node_modules/.pnpm/@tiptap_extensions@3.20.5_@tiptap_core@3.20.5_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.mjs.map +1 -0
  23. package/es/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directive-helpers.mjs +7 -0
  24. package/es/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directive-helpers.mjs.map +1 -0
  25. package/es/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directive.mjs +7 -0
  26. package/es/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directive.mjs.map +1 -0
  27. package/es/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directives/repeat.mjs +7 -0
  28. package/es/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directives/repeat.mjs.map +1 -0
  29. package/es/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/lit-html.mjs +7 -0
  30. package/es/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/lit-html.mjs.map +1 -0
  31. package/es/node_modules/.pnpm/prosemirror-dropcursor@1.8.2/node_modules/prosemirror-dropcursor/dist/index.mjs +2 -0
  32. package/es/node_modules/.pnpm/prosemirror-dropcursor@1.8.2/node_modules/prosemirror-dropcursor/dist/index.mjs.map +1 -0
  33. package/es/node_modules/.pnpm/prosemirror-gapcursor@1.4.1/node_modules/prosemirror-gapcursor/dist/index.mjs +2 -0
  34. package/es/node_modules/.pnpm/prosemirror-gapcursor@1.4.1/node_modules/prosemirror-gapcursor/dist/index.mjs.map +1 -0
  35. package/es/node_modules/.pnpm/prosemirror-history@1.5.0/node_modules/prosemirror-history/dist/index.mjs +2 -0
  36. package/es/node_modules/.pnpm/prosemirror-history@1.5.0/node_modules/prosemirror-history/dist/index.mjs.map +1 -0
  37. package/es/node_modules/.pnpm/prosemirror-keymap@1.2.3/node_modules/prosemirror-keymap/dist/index.mjs +2 -0
  38. package/es/node_modules/.pnpm/prosemirror-keymap@1.2.3/node_modules/prosemirror-keymap/dist/index.mjs.map +1 -0
  39. package/es/node_modules/.pnpm/prosemirror-model@1.25.4/node_modules/prosemirror-model/dist/index.mjs +2 -0
  40. package/es/node_modules/.pnpm/prosemirror-model@1.25.4/node_modules/prosemirror-model/dist/index.mjs.map +1 -0
  41. package/es/node_modules/.pnpm/prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.mjs +2 -0
  42. package/es/node_modules/.pnpm/prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.mjs.map +1 -0
  43. package/es/node_modules/.pnpm/prosemirror-transform@1.11.0/node_modules/prosemirror-transform/dist/index.mjs +2 -0
  44. package/es/node_modules/.pnpm/prosemirror-transform@1.11.0/node_modules/prosemirror-transform/dist/index.mjs.map +1 -0
  45. package/es/node_modules/.pnpm/prosemirror-view@1.41.7/node_modules/prosemirror-view/dist/index.mjs +2 -0
  46. package/es/node_modules/.pnpm/prosemirror-view@1.41.7/node_modules/prosemirror-view/dist/index.mjs.map +1 -0
  47. package/es/node_modules/.pnpm/rope-sequence@1.3.4/node_modules/rope-sequence/dist/index.mjs +2 -0
  48. package/es/node_modules/.pnpm/rope-sequence@1.3.4/node_modules/rope-sequence/dist/index.mjs.map +1 -0
  49. package/es/node_modules/.pnpm/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.mjs +2 -0
  50. package/es/node_modules/.pnpm/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.mjs.map +1 -0
  51. package/es/subject/action.mjs +118 -0
  52. package/es/subject/action.mjs.map +1 -0
  53. package/es/subject/blank-fill.mjs +204 -0
  54. package/es/subject/blank-fill.mjs.map +1 -0
  55. package/es/subject/layout.mjs +18 -0
  56. package/es/subject/layout.mjs.map +1 -0
  57. package/es/subject/list.mjs +128 -0
  58. package/es/subject/list.mjs.map +1 -0
  59. package/es/subject/page-end.mjs +25 -0
  60. package/es/subject/page-end.mjs.map +1 -0
  61. package/es/subject/rich-text.mjs +27 -0
  62. package/es/subject/rich-text.mjs.map +1 -0
  63. package/es/subject/scale.mjs +162 -0
  64. package/es/subject/scale.mjs.map +1 -0
  65. package/es/subject/single.mjs +318 -0
  66. package/es/subject/single.mjs.map +1 -0
  67. package/es/subject/text-fill.mjs +229 -0
  68. package/es/subject/text-fill.mjs.map +1 -0
  69. package/es/subject/type.mjs +42 -0
  70. package/es/subject/type.mjs.map +1 -0
  71. package/lib/base/define.cjs +2 -0
  72. package/lib/base/define.cjs.map +1 -0
  73. package/lib/base/uid.cjs +2 -0
  74. package/lib/base/uid.cjs.map +1 -0
  75. package/lib/editor/blocksuite-editor.cjs +931 -0
  76. package/lib/editor/blocksuite-editor.cjs.map +1 -0
  77. package/lib/editor/index.cjs +2 -0
  78. package/lib/editor/index.cjs.map +1 -0
  79. package/lib/index.cjs +2 -0
  80. package/lib/index.cjs.map +1 -0
  81. package/lib/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/css-tag.cjs +7 -0
  82. package/lib/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/css-tag.cjs.map +1 -0
  83. package/lib/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.cjs +7 -0
  84. package/lib/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.cjs.map +1 -0
  85. package/lib/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.cjs +7 -0
  86. package/lib/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.cjs.map +1 -0
  87. package/lib/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/reactive-element.cjs +7 -0
  88. package/lib/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/reactive-element.cjs.map +1 -0
  89. package/lib/node_modules/.pnpm/@tiptap_extension-placeholder@3.20.5_@tiptap_extensions@3.20.5_@tiptap_core@3.20.5_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.cjs +2 -0
  90. package/lib/node_modules/.pnpm/@tiptap_extension-placeholder@3.20.5_@tiptap_extensions@3.20.5_@tiptap_core@3.20.5_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.cjs.map +1 -0
  91. package/lib/node_modules/.pnpm/@tiptap_extensions@3.20.5_@tiptap_core@3.20.5_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.cjs +2 -0
  92. package/lib/node_modules/.pnpm/@tiptap_extensions@3.20.5_@tiptap_core@3.20.5_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.cjs.map +1 -0
  93. package/lib/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directive-helpers.cjs +7 -0
  94. package/lib/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directive-helpers.cjs.map +1 -0
  95. package/lib/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directive.cjs +7 -0
  96. package/lib/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directive.cjs.map +1 -0
  97. package/lib/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directives/repeat.cjs +8 -0
  98. package/lib/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directives/repeat.cjs.map +1 -0
  99. package/lib/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/lit-html.cjs +7 -0
  100. package/lib/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/lit-html.cjs.map +1 -0
  101. package/lib/node_modules/.pnpm/prosemirror-dropcursor@1.8.2/node_modules/prosemirror-dropcursor/dist/index.cjs +2 -0
  102. package/lib/node_modules/.pnpm/prosemirror-dropcursor@1.8.2/node_modules/prosemirror-dropcursor/dist/index.cjs.map +1 -0
  103. package/lib/node_modules/.pnpm/prosemirror-gapcursor@1.4.1/node_modules/prosemirror-gapcursor/dist/index.cjs +2 -0
  104. package/lib/node_modules/.pnpm/prosemirror-gapcursor@1.4.1/node_modules/prosemirror-gapcursor/dist/index.cjs.map +1 -0
  105. package/lib/node_modules/.pnpm/prosemirror-history@1.5.0/node_modules/prosemirror-history/dist/index.cjs +2 -0
  106. package/lib/node_modules/.pnpm/prosemirror-history@1.5.0/node_modules/prosemirror-history/dist/index.cjs.map +1 -0
  107. package/lib/node_modules/.pnpm/prosemirror-keymap@1.2.3/node_modules/prosemirror-keymap/dist/index.cjs +2 -0
  108. package/lib/node_modules/.pnpm/prosemirror-keymap@1.2.3/node_modules/prosemirror-keymap/dist/index.cjs.map +1 -0
  109. package/lib/node_modules/.pnpm/prosemirror-model@1.25.4/node_modules/prosemirror-model/dist/index.cjs +2 -0
  110. package/lib/node_modules/.pnpm/prosemirror-model@1.25.4/node_modules/prosemirror-model/dist/index.cjs.map +1 -0
  111. package/lib/node_modules/.pnpm/prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.cjs +2 -0
  112. package/lib/node_modules/.pnpm/prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.cjs.map +1 -0
  113. package/lib/node_modules/.pnpm/prosemirror-transform@1.11.0/node_modules/prosemirror-transform/dist/index.cjs +2 -0
  114. package/lib/node_modules/.pnpm/prosemirror-transform@1.11.0/node_modules/prosemirror-transform/dist/index.cjs.map +1 -0
  115. package/lib/node_modules/.pnpm/prosemirror-view@1.41.7/node_modules/prosemirror-view/dist/index.cjs +2 -0
  116. package/lib/node_modules/.pnpm/prosemirror-view@1.41.7/node_modules/prosemirror-view/dist/index.cjs.map +1 -0
  117. package/lib/node_modules/.pnpm/rope-sequence@1.3.4/node_modules/rope-sequence/dist/index.cjs +2 -0
  118. package/lib/node_modules/.pnpm/rope-sequence@1.3.4/node_modules/rope-sequence/dist/index.cjs.map +1 -0
  119. package/lib/node_modules/.pnpm/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.cjs +2 -0
  120. package/lib/node_modules/.pnpm/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.cjs.map +1 -0
  121. package/lib/subject/action.cjs +118 -0
  122. package/lib/subject/action.cjs.map +1 -0
  123. package/lib/subject/blank-fill.cjs +204 -0
  124. package/lib/subject/blank-fill.cjs.map +1 -0
  125. package/lib/subject/layout.cjs +18 -0
  126. package/lib/subject/layout.cjs.map +1 -0
  127. package/lib/subject/list.cjs +128 -0
  128. package/lib/subject/list.cjs.map +1 -0
  129. package/lib/subject/page-end.cjs +25 -0
  130. package/lib/subject/page-end.cjs.map +1 -0
  131. package/lib/subject/rich-text.cjs +27 -0
  132. package/lib/subject/rich-text.cjs.map +1 -0
  133. package/lib/subject/scale.cjs +162 -0
  134. package/lib/subject/scale.cjs.map +1 -0
  135. package/lib/subject/single.cjs +318 -0
  136. package/lib/subject/single.cjs.map +1 -0
  137. package/lib/subject/text-fill.cjs +229 -0
  138. package/lib/subject/text-fill.cjs.map +1 -0
  139. package/lib/subject/type.cjs +42 -0
  140. package/lib/subject/type.cjs.map +1 -0
  141. package/package.json +77 -0
@@ -0,0 +1,931 @@
1
+ import{Editor as e}from"@tiptap/core";import t from"@tiptap/extension-blockquote";import i from"@tiptap/extension-bold";import o from"@tiptap/extension-bullet-list";import r from"@tiptap/extension-code";import l from"@tiptap/extension-document";import s from"@tiptap/extension-heading";import n from"@tiptap/extension-history";import a from"@tiptap/extension-horizontal-rule";import d from"@tiptap/extension-image";import c from"@tiptap/extension-italic";import b from"@tiptap/extension-link";import p from"@tiptap/extension-list-item";import h from"@tiptap/extension-ordered-list";import g from"@tiptap/extension-paragraph";import u from"@tiptap/extension-strike";import{Table as x}from"@tiptap/extension-table";import{TableCell as m}from"@tiptap/extension-table-cell";import{TableHeader as v}from"@tiptap/extension-table-header";import{TableRow as f}from"@tiptap/extension-table-row";import _ from"@tiptap/extension-text";import y from"@tiptap/extension-text-align";import w from"@tiptap/extension-underline";import k from"../node_modules/.pnpm/@tiptap_extension-placeholder@3.20.5_@tiptap_extensions@3.20.5_@tiptap_core@3.20.5_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.mjs";import{css as C,LitElement as T,html as M}from"lit";import{property as $}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.mjs";import{state as A}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.mjs";import{safeCustomElement as R}from"../base/define.mjs";var B=Object.defineProperty,P=Object.getOwnPropertyDescriptor,S=(e,t,i,o)=>{for(var r,l=o>1?void 0:o?P(t,i):t,s=e.length-1;s>=0;s--)(r=e[s])&&(l=(o?r(t,i,l):r(l))||l);return o&&l&&B(t,i,l),l};let I=class extends T{constructor(){super(...arguments),this.content="",this.readonly=!1,this.preview=!1,this._editor=null,this._pendingContent=null,this._tableRows=3,this._tableCols=3,this._hoverRow=0,this._hoverCol=0,this._tableDropdownOpen=!1,this._isLoading=!0,this._tableCellToolbar={x:0,y:0,visible:!1,cellRow:0,cellCol:0},this._tableEdgeHover={type:null,index:0,position:{x:0,y:0}},this._imageToolbar={x:0,y:0,visible:!1},this._imageMoreMenuVisible=!1,this._hasSlashCommand=!1,this._tableEdgeDetectionSetup=!1}_initEditor(){if(this._editor)return;const C=this.shadowRoot?.querySelector(".editor-content");if(!C)return void requestAnimationFrame(()=>this._initEditor());this._isLoading=!1;const T=[l,g,_,i,c,w,u,r,s.configure({levels:[1,2,3]}),o,h,p,t,a,n,d.configure({inline:!1,allowBase64:!0}),b.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer"}}),y.configure({types:["heading","paragraph"]}),x.configure({resizable:!0}),f,m,v,k.configure({placeholder:"输入 / 唤出快捷命令"})];this._editor=new e({element:C,extensions:T,content:(this._pendingContent??this.content)||"<p></p>",editable:!this.readonly}),this._pendingContent=null,this._editor.on("selectionUpdate",()=>{this.requestUpdate(),this._updateBubbleMenuPosition(),this._editor?.isActive("table")?this._showTableCellToolbar():this._hideTableCellToolbar();const e=this._editor;if(e){const{selection:t}=e.state,{$from:i}=t;if("image"===i.node(i.depth).type.name){const t=e.view.coordsAtPos(i.start()),o=this.shadowRoot?.querySelector(".editor-wrapper")?.getBoundingClientRect();if(o){const e=t.left-o.left+(t.right-t.left)/2,i=t.top-o.top-40;this._showImageToolbar({x:e,y:i})}}else this._hideImageToolbar()}}),this._editor.on("transaction",()=>{this.requestUpdate(),this._editor?.isActive("table")?this._showTableCellToolbar():this._hideTableCellToolbar(),this._checkSlashCommand(),this._setupTableEdgeDetection()})}_setupTableEdgeDetection(){const e=this.shadowRoot?.querySelector(".editor-content");e&&!this._tableEdgeDetectionSetup&&(this._tableEdgeDetectionSetup=!0,e.addEventListener("mousemove",e=>{this._handleTableEdgeMouseMove(e)}),e.addEventListener("mouseleave",()=>{this._tableEdgeHover={type:null,index:0,position:{x:0,y:0}}}),e.addEventListener("click",e=>{const t=e.target;if("IMG"===t.tagName){const e=this._editor?.view.posAtDOM(t,0);void 0!==e&&this._editor?.chain().focus().setNodeSelection(e).run()}}))}_handleTableEdgeMouseMove(e){if(!this._editor?.isActive("table"))return this._tableEdgeHover={type:null,index:0,position:{x:0,y:0}},void this.requestUpdate();const t=e.target.closest("table");if(!t)return this._tableEdgeHover={type:null,index:0,position:{x:0,y:0}},void this.requestUpdate();const i=t.getBoundingClientRect(),o=this.shadowRoot?.querySelector(".editor-wrapper");if(!o)return;const r=o.getBoundingClientRect(),l=e.clientX-r.left,s=e.clientY-r.top,n=10,a=i.height/t.rows.length;for(let o=0;o<t.rows.length;o++){const t=i.top+o*a,s=t+a;if(e.clientY>=t-n&&e.clientY<=t+n)return this._tableEdgeHover={type:"row",index:o,position:{x:l,y:t-r.top}},void this.requestUpdate();if(e.clientY>=s-n&&e.clientY<=s+n)return this._tableEdgeHover={type:"row",index:o+1,position:{x:l,y:s-r.top}},void this.requestUpdate()}const d=i.width/t.rows[0]?.cells.length||1;for(let o=0;o<(t.rows[0]?.cells.length||0);o++){const t=i.left+o*d,l=t+d;if(e.clientX>=t-n&&e.clientX<=t+n)return this._tableEdgeHover={type:"col",index:o,position:{x:t-r.left,y:s}},void this.requestUpdate();if(e.clientX>=l-n&&e.clientX<=l+n)return this._tableEdgeHover={type:"col",index:o+1,position:{x:l-r.left,y:s}},void this.requestUpdate()}this._tableEdgeHover={type:null,index:0,position:{x:0,y:0}},this.requestUpdate()}_checkSlashCommand(){if(!this._editor)return;const{selection:e}=this._editor.state,t=this._editor.state.doc.textBetween(Math.max(0,e.from-10),e.from," ");this._hasSlashCommand=t.endsWith("/")}firstUpdated(){this._initEditor()}updated(e){if(this._editor)return e.has("content")&&this._editor.commands.setContent(this.content||"<p></p>"),void(e.has("readonly")&&this._editor.setEditable(!this.readonly));e.has("content")&&(this._pendingContent=this.content);const t=this.shadowRoot?.querySelector(".editor-content");t&&!this._editor&&this._initEditor()}disconnectedCallback(){super.disconnectedCallback(),this._editor?.destroy(),this._editor=null}getContent(){return this._editor?.getHTML()??""}_applyFormat(e){if(this._hasSlashCommand&&this._editor){const{selection:e}=this._editor.state;this._editor.chain().focus().deleteRange({from:e.from-1,to:e.from}).run(),this._hasSlashCommand=!1}e()}_toggleBold(){this._applyFormat(()=>this._editor?.chain().focus().toggleBold().run())}_toggleItalic(){this._applyFormat(()=>this._editor?.chain().focus().toggleItalic().run())}_toggleUnderline(){this._applyFormat(()=>this._editor?.chain().focus().toggleUnderline().run())}_toggleStrike(){this._applyFormat(()=>this._editor?.chain().focus().toggleStrike().run())}_toggleCode(){this._applyFormat(()=>this._editor?.chain().focus().toggleCode().run())}_setHeading(e){this._applyFormat(()=>this._editor?.chain().focus().toggleHeading({level:e}).run())}_setParagraph(){this._applyFormat(()=>this._editor?.chain().focus().setParagraph().run())}_toggleBulletList(){this._applyFormat(()=>this._editor?.chain().focus().toggleBulletList().run())}_toggleOrderedList(){this._applyFormat(()=>this._editor?.chain().focus().toggleOrderedList().run())}_toggleBlockquote(){this._applyFormat(()=>this._editor?.chain().focus().toggleBlockquote().run())}_setTextAlign(e){this._applyFormat(()=>this._editor?.chain().focus().setTextAlign(e).run())}_setLink(){const e=window.prompt("请输入链接地址:");e&&this._applyFormat(()=>this._editor?.chain().focus().setLink({href:e}).run())}_unsetLink(){this._applyFormat(()=>this._editor?.chain().focus().unsetLink().run())}_insertTable(e,t){this._editor?.chain().focus().insertTable({rows:e??this._tableRows,cols:t??this._tableCols,withHeaderRow:!0}).run()}_handleImageUpload(e){const t=e.target,i=t.files?.[0];if(i){const e=new FileReader;e.onload=e=>{const t=e.target?.result;this._editor?.chain().focus().setImage({src:t}).run()},e.readAsDataURL(i)}t.value=""}_triggerImageUpload(){const e=this.shadowRoot?.querySelector(".image-input");e?.click()}_insertTableByClick(e,t){if(this._hasSlashCommand&&this._editor){const{selection:e}=this._editor.state;this._editor.chain().focus().deleteRange({from:e.from-1,to:e.from}).run(),this._hasSlashCommand=!1}this._tableRows=e,this._tableCols=t,this._insertTable(e,t)}_insertHorizontalRule(){this._editor?.chain().focus().setHorizontalRule().run()}_showTableCellToolbar(){if(!this._editor?.isActive("table"))return;const{state:e}=this._editor,{selection:t}=e,i=this._editor.view.coordsAtPos(t.from),o=this.shadowRoot?.querySelector(".editor-wrapper");if(!o)return;const r=o.getBoundingClientRect(),l=this._getTableCellRow(),s=this._getTableCellCol();(0===l||0===s)&&(this._tableCellToolbar={x:i.left-r.left,y:i.bottom-r.top+8,visible:!0,cellRow:l,cellCol:s})}_getTableCellRow(){if(!this._editor)return 0;const{selection:e}=this._editor.state,t=this._editor.state.doc.resolve(e.from);for(let e=t.depth;e>0;e--){if("tableCell"===t.node(e).type.name)return t.index(e-1)}return 0}_getTableCellCol(){if(!this._editor)return 0;const{selection:e}=this._editor.state,t=this._editor.state.doc.resolve(e.from);for(let e=t.depth;e>0;e--){if("tableCell"===t.node(e).type.name)return t.index(e)}return 0}_hideTableCellToolbar(){this._tableCellToolbar={...this._tableCellToolbar,visible:!1}}_addTableRowAbove(){this._editor?.chain().focus().addRowBefore().run(),this._hideTableCellToolbar()}_addTableRowBelow(){this._editor?.chain().focus().addRowAfter().run(),this._hideTableCellToolbar()}_addTableColumnLeft(){this._editor?.chain().focus().addColumnBefore().run(),this._hideTableCellToolbar()}_addTableColumnRight(){this._editor?.chain().focus().addColumnAfter().run(),this._hideTableCellToolbar()}_deleteTableRow(){this._editor?.chain().focus().deleteRow().run(),this._hideTableCellToolbar()}_deleteTableColumn(){this._editor?.chain().focus().deleteColumn().run(),this._hideTableCellToolbar()}_deleteTable(){this._editor?.chain().focus().deleteTable().run(),this._hideTableCellToolbar()}_showImageToolbar(e){this._imageToolbar={x:e.x,y:e.y,visible:!0},this._imageMoreMenuVisible=!1}_hideImageToolbar(){this._imageToolbar={...this._imageToolbar,visible:!1},this._imageMoreMenuVisible=!1}_toggleImageMoreMenu(){this._imageMoreMenuVisible=!this._imageMoreMenuVisible}_deleteImage(){this._editor?.chain().focus().deleteNode("image").run(),this._hideImageToolbar()}_insertImageAfter(){this._triggerImageUpload(),this._imageMoreMenuVisible=!1}_setImageAlignLeft(){const e=this._editor;if(e){const{selection:t}=e.state,i=t.from;e.chain().focus().setNodeSelection(i).run();const o=this.shadowRoot?.querySelector(".ProseMirror img.ProseMirror-selectednode");o&&(o.style.display="block",o.style.margin="0 auto 0 0")}this._imageMoreMenuVisible=!1}_setImageAlignCenter(){const e=this._editor;if(e){const{selection:t}=e.state,i=t.from;e.chain().focus().setNodeSelection(i).run();const o=this.shadowRoot?.querySelector(".ProseMirror img.ProseMirror-selectednode");o&&(o.style.display="block",o.style.margin="0 auto")}this._imageMoreMenuVisible=!1}_setImageAlignRight(){const e=this._editor;if(e){const{selection:t}=e.state,i=t.from;e.chain().focus().setNodeSelection(i).run();const o=this.shadowRoot?.querySelector(".ProseMirror img.ProseMirror-selectednode");o&&(o.style.display="block",o.style.margin="0 0 0 auto")}this._imageMoreMenuVisible=!1}_updateImageToolbarPosition(){requestAnimationFrame(()=>{const e=this._editor;if(!e)return;const{selection:t}=e.state,{$from:i}=t;if("image"===i.node(i.depth).type.name?i.node(i.depth):null){const t=e.view.coordsAtPos(i.start()),o=this.shadowRoot?.querySelector(".editor-wrapper")?.getBoundingClientRect();if(o){const e=t.left-o.left+(t.right-t.left)/2,i=t.top-o.top-40;this._showImageToolbar({x:e,y:i})}}else this._hideImageToolbar()})}_getTextLabel(){const e=this._editor;return e?e.isActive("heading",{level:1})?"标题 1":e.isActive("heading",{level:2})?"标题 2":e.isActive("heading",{level:3})?"标题 3":"正文":"正文"}_getAlignLabel(){const e=this._editor;return e?e.isActive({textAlign:"center"})?"居中":e.isActive({textAlign:"right"})?"右对齐":"左对齐":"对齐"}_updateBubbleMenuPosition(){requestAnimationFrame(()=>{const e=this.shadowRoot?.querySelector(".bubble-menu"),t=this.shadowRoot?.querySelector(".ProseMirror"),i=this.shadowRoot?.querySelector(".editor-wrapper");if(!e||!t||!i)return;const o=this._editor,r=o?.isActive("table")??!1,{selection:l}=o?.state??{selection:null};if(r&&l&&!l.empty&&o){const{from:t,to:i}=l,r=o.state.doc.resolve(t),s=o.state.doc.resolve(i);let n=!1;for(let e=r.depth;e>=0;e--)if("table"===r.node(e).type.name){n=!0;break}const a=r.node(r.depth),d=s.node(s.depth);if("table"!==a.type.name&&"table"!==d.type.name||(n=!0),n)return e.style.opacity="0",void(e.style.visibility="hidden")}if(l&&!l.empty);else if(!l||l.empty&&!this._hasSlashCommand)return e.style.opacity="0",void(e.style.visibility="hidden");const s=i.getBoundingClientRect(),n=e.getBoundingClientRect(),{from:a}=l,d=this._editor?.view.coordsAtPos(a);if(!d)return;let c=d.left-s.left,b=d.top-s.top-40;c+n.width>s.width&&(c=s.width-n.width-8),c<0&&(c=8),b<0&&(b=d.bottom-s.top+8),e.style.left=`${c}px`,e.style.top=`${b}px`,e.style.opacity="1",e.style.visibility="visible"})}render(){const e=this._editor;return M`
2
+ <div class="editor-wrapper ${this._isLoading?"loading":""} ${this.preview?"preview":""}">
3
+ ${this._isLoading?M`
4
+ <div class="loading-placeholder">
5
+ <div class="loading-spinner"></div>
6
+ <span>编辑器加载中...</span>
7
+ </div>
8
+ `:""}
9
+ <input
10
+ type="file"
11
+ accept="image/*"
12
+ class="image-input"
13
+ @change=${this._handleImageUpload}
14
+ />
15
+
16
+ <!-- Bubble Menu (悬浮操作栏) -->
17
+ ${this.preview?"":M`
18
+ <div class="bubble-menu">
19
+ <!-- 文本格式 -->
20
+ <button
21
+ class="bubble-btn ${e?.isActive("bold")?"is-active":""}"
22
+ @click=${this._toggleBold}
23
+ title="加粗"
24
+ >
25
+ <svg viewBox="0 0 24 24"><path d="M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/><path d="M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/></svg>
26
+ </button>
27
+ <button
28
+ class="bubble-btn ${e?.isActive("italic")?"is-active":""}"
29
+ @click=${this._toggleItalic}
30
+ title="斜体"
31
+ >
32
+ <svg viewBox="0 0 24 24"><line x1="19" y1="4" x2="10" y2="4"/><line x1="14" y1="20" x2="5" y2="20"/><line x1="15" y1="4" x2="9" y2="20"/></svg>
33
+ </button>
34
+ <button
35
+ class="bubble-btn ${e?.isActive("underline")?"is-active":""}"
36
+ @click=${this._toggleUnderline}
37
+ title="下划线"
38
+ >
39
+ <svg viewBox="0 0 24 24"><path d="M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3"/><line x1="4" y1="21" x2="20" y2="21"/></svg>
40
+ </button>
41
+ <button
42
+ class="bubble-btn ${e?.isActive("strike")?"is-active":""}"
43
+ @click=${this._toggleStrike}
44
+ title="删除线"
45
+ >
46
+ <svg viewBox="0 0 24 24"><path d="M17.3 4.9c-2.3-.6-4.4-1-6.2-.9-2.7 0-5.3.7-5.3 3.6 0 1.5 1.8 3.3 5.3 3.9h.2m8.2 3.2c.3.4.4.8.4 1.3 0 2.9-2.7 3.6-6.2 3.6-2.3 0-4.4-.3-6.2-.9M4 12h16"/></svg>
47
+ </button>
48
+
49
+ <div class="bubble-divider"></div>
50
+
51
+ <!-- 文本类型下拉 -->
52
+ <div class="bubble-dropdown">
53
+ <button class="bubble-dropdown-btn">
54
+ ${this._getTextLabel()}
55
+ <svg viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"/></svg>
56
+ </button>
57
+ <div class="bubble-dropdown-menu">
58
+ <button
59
+ class="bubble-dropdown-item ${e?.isActive("heading")?"":"is-active"}"
60
+ @click=${this._setParagraph}
61
+ >
62
+ 正文
63
+ </button>
64
+ <button
65
+ class="bubble-dropdown-item ${e?.isActive("heading",{level:1})?"is-active":""}"
66
+ @click=${()=>this._setHeading(1)}
67
+ >
68
+ 标题 1
69
+ </button>
70
+ <button
71
+ class="bubble-dropdown-item ${e?.isActive("heading",{level:2})?"is-active":""}"
72
+ @click=${()=>this._setHeading(2)}
73
+ >
74
+ 标题 2
75
+ </button>
76
+ <button
77
+ class="bubble-dropdown-item ${e?.isActive("heading",{level:3})?"is-active":""}"
78
+ @click=${()=>this._setHeading(3)}
79
+ >
80
+ 标题 3
81
+ </button>
82
+ </div>
83
+ </div>
84
+
85
+ <div class="bubble-divider"></div>
86
+
87
+ <!-- 对齐下拉 -->
88
+ <div class="bubble-dropdown">
89
+ <button class="bubble-dropdown-btn">
90
+ ${this._getAlignLabel()}
91
+ <svg viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"/></svg>
92
+ </button>
93
+ <div class="bubble-dropdown-menu">
94
+ <button
95
+ class="bubble-dropdown-item ${e?.isActive({textAlign:"left"})?"is-active":""}"
96
+ @click=${()=>this._setTextAlign("left")}
97
+ >
98
+ <svg viewBox="0 0 24 24"><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="15" y2="12"/><line x1="3" y1="18" x2="18" y2="18"/></svg>
99
+ 左对齐
100
+ </button>
101
+ <button
102
+ class="bubble-dropdown-item ${e?.isActive({textAlign:"center"})?"is-active":""}"
103
+ @click=${()=>this._setTextAlign("center")}
104
+ >
105
+ <svg viewBox="0 0 24 24"><line x1="3" y1="6" x2="21" y2="6"/><line x1="6" y1="12" x2="18" y2="12"/><line x1="4" y1="18" x2="20" y2="18"/></svg>
106
+ 居中
107
+ </button>
108
+ <button
109
+ class="bubble-dropdown-item ${e?.isActive({textAlign:"right"})?"is-active":""}"
110
+ @click=${()=>this._setTextAlign("right")}
111
+ >
112
+ <svg viewBox="0 0 24 24"><line x1="3" y1="6" x2="21" y2="6"/><line x1="9" y1="12" x2="21" y2="12"/><line x1="6" y1="18" x2="21" y2="18"/></svg>
113
+ 右对齐
114
+ </button>
115
+ </div>
116
+ </div>
117
+
118
+ <div class="bubble-divider"></div>
119
+
120
+ <!-- 行内代码 -->
121
+ <button
122
+ class="bubble-btn ${e?.isActive("code")?"is-active":""}"
123
+ @click=${this._toggleCode}
124
+ title="行内代码"
125
+ >
126
+ <svg viewBox="0 0 24 24"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
127
+ </button>
128
+
129
+ <!-- 链接 -->
130
+ <button
131
+ class="bubble-btn ${e?.isActive("link")?"is-active":""}"
132
+ @click=${this._setLink}
133
+ title="链接"
134
+ >
135
+ <svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>
136
+ </button>
137
+
138
+ <!-- 图片 -->
139
+ <button
140
+ class="bubble-btn"
141
+ @click=${this._triggerImageUpload}
142
+ title="图片"
143
+ >
144
+ <svg viewBox="0 0 24 24"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>
145
+ </button>
146
+
147
+ <div class="bubble-divider"></div>
148
+
149
+ <!-- 列表 -->
150
+ <button
151
+ class="bubble-btn ${e?.isActive("bulletList")?"is-active":""}"
152
+ @click=${this._toggleBulletList}
153
+ title="无序列表"
154
+ >
155
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
156
+ <line x1="9" y1="6" x2="20" y2="6"/>
157
+ <line x1="9" y1="12" x2="20" y2="12"/>
158
+ <line x1="9" y1="18" x2="20" y2="18"/>
159
+ <circle cx="4" cy="6" r="0.5" fill="currentColor" stroke="none"/>
160
+ <circle cx="4" cy="12" r="0.5" fill="currentColor" stroke="none"/>
161
+ <circle cx="4" cy="18" r="0.5" fill="currentColor" stroke="none"/>
162
+ </svg>
163
+ </button>
164
+ <button
165
+ class="bubble-btn ${e?.isActive("orderedList")?"is-active":""}"
166
+ @click=${this._toggleOrderedList}
167
+ title="有序列表"
168
+ >
169
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
170
+ <line x1="10" y1="6" x2="21" y2="6"/>
171
+ <line x1="10" y1="12" x2="21" y2="12"/>
172
+ <line x1="10" y1="18" x2="21" y2="18"/>
173
+ <path d="M4 6h1v4"/>
174
+ <path d="M4 10h2"/>
175
+ <path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1.5"/>
176
+ </svg>
177
+ </button>
178
+
179
+ <!-- 引用 -->
180
+ <button
181
+ class="bubble-btn ${e?.isActive("blockquote")?"is-active":""}"
182
+ @click=${this._toggleBlockquote}
183
+ title="引用"
184
+ >
185
+ <svg viewBox="0 0 24 24"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z"/><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z"/></svg>
186
+ </button>
187
+
188
+ <div class="bubble-divider"></div>
189
+
190
+ <!-- 表格下拉 -->
191
+ <div
192
+ class="bubble-dropdown ${this._tableDropdownOpen?"is-open":""}"
193
+ @mouseenter=${()=>{this._tableDropdownOpen=!0,this._hoverRow=0,this._hoverCol=0}}
194
+ @mouseleave=${()=>this._tableDropdownOpen=!1}
195
+ >
196
+ <button class="bubble-dropdown-btn" title="表格">
197
+ <svg viewBox="0 0 24 24" style="width:18px;height:18px;stroke:currentColor;stroke-width:2;fill:none;"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>
198
+ </button>
199
+ <div class="bubble-dropdown-menu">
200
+ <div class="table-grid-preview">
201
+ ${this._renderTableGrid()}
202
+ </div>
203
+ <div class="table-size-hint">
204
+ <span>${this._hoverRow>0?`${this._hoverRow} × ${this._hoverCol}`:`${this._tableRows} × ${this._tableCols}`}</span>
205
+ </div>
206
+ </div>
207
+ </div>
208
+ </div>
209
+ `}
210
+
211
+ <div class="editor-content"></div>
212
+
213
+ <!-- Table Cell Toolbar -->
214
+ ${this._tableCellToolbar.visible&&e?.isActive("table")?M`
215
+ <div
216
+ class="table-cell-toolbar"
217
+ style="left: ${this._tableCellToolbar.x}px; top: ${this._tableCellToolbar.y}px;"
218
+ @mousedown=${e=>e.preventDefault()}
219
+ >
220
+ ${0===this._tableCellToolbar.cellRow?M`
221
+ <button class="table-cell-toolbar-btn" title="上方添加行" @click=${this._addTableRowAbove}>
222
+ <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none"><rect x="4" y="8" width="16" height="8" rx="1"/><line x1="12" y1="3" x2="12" y2="7"/><line x1="10" y1="5" x2="14" y2="5"/></svg>
223
+ </button>
224
+ <button class="table-cell-toolbar-btn" title="下方添加行" @click=${this._addTableRowBelow}>
225
+ <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none"><rect x="4" y="8" width="16" height="8" rx="1"/><line x1="12" y1="21" x2="12" y2="17"/><line x1="10" y1="19" x2="14" y2="19"/></svg>
226
+ </button>
227
+ <button class="table-cell-toolbar-btn danger" title="删除行" @click=${this._deleteTableRow}>
228
+ <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none"><rect x="4" y="8" width="16" height="8" rx="1"/><line x1="9" y1="10" x2="9" y2="14"/><line x1="15" y1="10" x2="15" y2="14"/></svg>
229
+ </button>
230
+ `:""}
231
+ ${0===this._tableCellToolbar.cellCol?M`
232
+ ${0!==this._tableCellToolbar.cellRow?M`<div style="width:1px;height:20px;background:#e3e3e3;margin:0 4px;"></div>`:""}
233
+ <button class="table-cell-toolbar-btn" title="左侧添加列" @click=${this._addTableColumnLeft}>
234
+ <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none"><rect x="8" y="4" width="8" height="16" rx="1"/><line x1="3" y1="12" x2="7" y2="12"/><line x1="5" y1="10" x2="5" y2="14"/></svg>
235
+ </button>
236
+ <button class="table-cell-toolbar-btn" title="右侧添加列" @click=${this._addTableColumnRight}>
237
+ <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none"><rect x="8" y="4" width="8" height="16" rx="1"/><line x1="21" y1="12" x2="17" y2="12"/><line x1="19" y1="10" x2="19" y2="14"/></svg>
238
+ </button>
239
+ <button class="table-cell-toolbar-btn danger" title="删除列" @click=${this._deleteTableColumn}>
240
+ <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none"><rect x="8" y="4" width="8" height="16" rx="1"/><line x1="10" y1="9" x2="14" y2="9"/><line x1="10" y1="15" x2="14" y2="15"/></svg>
241
+ </button>
242
+ `:""}
243
+ ${0===this._tableCellToolbar.cellRow&&0===this._tableCellToolbar.cellCol?M`
244
+ <div style="width:1px;height:20px;background:#e3e3e3;margin:0 4px;"></div>
245
+ <button class="table-cell-toolbar-btn danger" title="删除表格" @click=${this._deleteTable}>
246
+ <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
247
+ </button>
248
+ `:""}
249
+ </div>
250
+ `:""}
251
+
252
+ <!-- Image Toolbar -->
253
+ ${this._imageToolbar.visible?M`
254
+ <div
255
+ class="image-toolbar"
256
+ style="left: ${this._imageToolbar.x}px; top: ${this._imageToolbar.y}px;"
257
+ @mousedown=${e=>e.preventDefault()}
258
+ >
259
+ <button class="image-toolbar-btn danger" title="删除图片" @click=${this._deleteImage}>
260
+ <svg viewBox="0 0 24 24"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
261
+ </button>
262
+ <button class="image-toolbar-btn" title="添加图片" @click=${this._insertImageAfter}>
263
+ <svg viewBox="0 0 24 24"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
264
+ </button>
265
+ <div class="image-toolbar-divider"></div>
266
+ <div style="position: relative;">
267
+ <button class="image-toolbar-btn" title="更多" @click=${this._toggleImageMoreMenu}>
268
+ <svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/></svg>
269
+ </button>
270
+ ${this._imageMoreMenuVisible?M`
271
+ <div class="image-more-menu">
272
+ <button class="image-more-menu-item" @click=${this._setImageAlignLeft}>
273
+ <svg viewBox="0 0 24 24"><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="15" y2="12"/><line x1="3" y1="18" x2="18" y2="18"/></svg>
274
+ 左对齐
275
+ </button>
276
+ <button class="image-more-menu-item" @click=${this._setImageAlignCenter}>
277
+ <svg viewBox="0 0 24 24"><line x1="3" y1="6" x2="21" y2="6"/><line x1="6" y1="12" x2="18" y2="12"/><line x1="4" y1="18" x2="20" y2="18"/></svg>
278
+ 居中
279
+ </button>
280
+ <button class="image-more-menu-item" @click=${this._setImageAlignRight}>
281
+ <svg viewBox="0 0 24 24"><line x1="3" y1="6" x2="21" y2="6"/><line x1="9" y1="12" x2="21" y2="12"/><line x1="6" y1="18" x2="21" y2="18"/></svg>
282
+ 右对齐
283
+ </button>
284
+ </div>
285
+ `:""}
286
+ </div>
287
+ </div>
288
+ `:""}
289
+ </div>
290
+ `}_renderTableGrid(){const e=[];for(let t=0;t<100;t++){const i=Math.floor(t/10)+1,o=t%10+1,r=this._hoverRow>0&&i<=this._hoverRow&&o<=this._hoverCol;e.push(M`
291
+ <div
292
+ class="table-cell ${r?"selected":""}"
293
+ @click=${()=>{this._insertTableByClick(i,o),this._tableDropdownOpen=!1}}
294
+ @mouseenter=${()=>{this._hoverRow=i,this._hoverCol=o}}
295
+ @mouseleave=${()=>{this._hoverRow=0,this._hoverCol=0}}
296
+ ></div>
297
+ `)}return e}};I.styles=C`
298
+ :host {
299
+ display: block;
300
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, sans-serif;
301
+ }
302
+
303
+ .editor-wrapper {
304
+ border: 1px solid #e3e3e3;
305
+ border-radius: 12px;
306
+ background: transparent;
307
+ overflow: visible;
308
+ position: relative;
309
+ }
310
+
311
+ .editor-wrapper:focus-within {
312
+ border-color: #1e96fc;
313
+ box-shadow: 0 0 0 2px rgba(30, 150, 252, 0.1);
314
+ }
315
+
316
+ .editor-wrapper.preview {
317
+ border: none;
318
+ border-radius: 0;
319
+ background: transparent;
320
+ }
321
+
322
+ .editor-wrapper.preview .editor-content {
323
+ padding: 8px 12px;
324
+ min-height: unset;
325
+ }
326
+
327
+ .editor-content {
328
+ padding: 16px 20px;
329
+ min-height: 200px;
330
+ cursor: text;
331
+ }
332
+
333
+ .editor-content:empty::before {
334
+ content: '输入 / 唤出快捷命令';
335
+ color: #c0c0c0;
336
+ pointer-events: none;
337
+ display: block;
338
+ margin-top: 80px;
339
+ text-align: center;
340
+ }
341
+
342
+ .editor-content .ProseMirror:empty {
343
+ min-height: 200px;
344
+ }
345
+
346
+ .ProseMirror p.is-editor-empty:first-child::before {
347
+ content: attr(data-placeholder);
348
+ color: #c0c0c0;
349
+ pointer-events: none;
350
+ float: left;
351
+ height: 0;
352
+ }
353
+
354
+ .editor-wrapper.loading {
355
+ display: flex;
356
+ align-items: center;
357
+ justify-content: center;
358
+ min-height: 200px;
359
+ background: #fafafa;
360
+ }
361
+
362
+ .loading-placeholder {
363
+ display: flex;
364
+ flex-direction: column;
365
+ align-items: center;
366
+ gap: 12px;
367
+ color: #909399;
368
+ font-size: 14px;
369
+ }
370
+
371
+ .loading-spinner {
372
+ width: 24px;
373
+ height: 24px;
374
+ border: 2px solid #e3e3e3;
375
+ border-top-color: #1e96fc;
376
+ border-radius: 50%;
377
+ animation: spin 0.8s linear infinite;
378
+ }
379
+
380
+ @keyframes spin {
381
+ to { transform: rotate(360deg); }
382
+ }
383
+
384
+ .ProseMirror {
385
+ outline: none;
386
+ line-height: 1.7;
387
+ color: #37352f;
388
+ font-size: 15px;
389
+ }
390
+
391
+ .ProseMirror > * + * {
392
+ margin-top: 0.5em;
393
+ }
394
+
395
+ .ProseMirror > *:first-child {
396
+ margin-top: 0 !important;
397
+ }
398
+
399
+ .ProseMirror p {
400
+ margin: 0;
401
+ }
402
+
403
+ .ProseMirror h1 {
404
+ font-size: 1.875em;
405
+ font-weight: 700;
406
+ margin: 0 0 0.25em;
407
+ line-height: 1.3;
408
+ }
409
+
410
+ .ProseMirror > h1:first-child {
411
+ margin-top: 0 !important;
412
+ line-height: 1.15;
413
+ }
414
+
415
+ .ProseMirror > p:first-child {
416
+ margin-top: 0 !important;
417
+ }
418
+
419
+ .ProseMirror h2 {
420
+ font-size: 1.5em;
421
+ font-weight: 600;
422
+ margin: 0.5em 0 0.25em;
423
+ line-height: 1.3;
424
+ }
425
+
426
+ .ProseMirror h3 {
427
+ font-size: 1.25em;
428
+ font-weight: 600;
429
+ margin: 0.5em 0 0.25em;
430
+ line-height: 1.3;
431
+ }
432
+
433
+ .ProseMirror ul,
434
+ .ProseMirror ol {
435
+ padding-left: 1.5em;
436
+ margin: 0;
437
+ }
438
+
439
+ .ProseMirror li {
440
+ margin: 0.1em 0;
441
+ }
442
+
443
+ .ProseMirror li::marker {
444
+ color: #37352f;
445
+ }
446
+
447
+ .ProseMirror strong {
448
+ font-weight: 700;
449
+ }
450
+
451
+ .ProseMirror em {
452
+ font-style: italic;
453
+ font-synthesis: none;
454
+ transform: skewX(-12deg);
455
+ display: inline-block;
456
+ }
457
+
458
+ .ProseMirror u {
459
+ text-decoration: underline;
460
+ }
461
+
462
+ .ProseMirror s {
463
+ text-decoration: line-through;
464
+ color: #787774;
465
+ }
466
+
467
+ .ProseMirror code {
468
+ background: rgba(135, 131, 120, 0.14);
469
+ color: #eb5757;
470
+ padding: 2px 4px;
471
+ border-radius: 4px;
472
+ font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
473
+ font-size: 85%;
474
+ }
475
+
476
+ .ProseMirror pre {
477
+ background: #f6f6f7;
478
+ border-radius: 8px;
479
+ padding: 12px 16px;
480
+ overflow-x: auto;
481
+ }
482
+
483
+ .ProseMirror pre code {
484
+ background: none;
485
+ padding: 0;
486
+ color: #37352f;
487
+ }
488
+
489
+ .ProseMirror blockquote {
490
+ border-left: 3px solid #e3e3e3;
491
+ padding-left: 1em;
492
+ margin: 0.75em 0;
493
+ color: #787774;
494
+ }
495
+
496
+ .ProseMirror hr {
497
+ border: none;
498
+ border-top: 1px solid #e3e3e3;
499
+ margin: 1.5em 0;
500
+ }
501
+
502
+ .ProseMirror img {
503
+ max-width: 100%;
504
+ height: auto;
505
+ border-radius: 8px;
506
+ }
507
+
508
+ .ProseMirror a {
509
+ color: #1e96fc;
510
+ text-decoration: underline;
511
+ cursor: pointer;
512
+ }
513
+
514
+ .ProseMirror img.ProseMirror-selectednode {
515
+ outline: 2px solid #1e96fc;
516
+ }
517
+
518
+ /* Table styles */
519
+ .ProseMirror table {
520
+ border-collapse: collapse;
521
+ width: 100%;
522
+ margin: 1em 0;
523
+ border: 1px solid #e3e3e3;
524
+ border-radius: 8px;
525
+ overflow: hidden;
526
+ }
527
+
528
+ .ProseMirror th,
529
+ .ProseMirror td {
530
+ border: 1px solid #e3e3e3;
531
+ padding: 8px 12px;
532
+ text-align: left;
533
+ vertical-align: top;
534
+ }
535
+
536
+ .ProseMirror th {
537
+ background: #fafafa;
538
+ font-weight: 600;
539
+ }
540
+
541
+ .ProseMirror .selectedCell {
542
+ background: rgba(30, 150, 252, 0.1);
543
+ }
544
+
545
+ /* Table Cell Toolbar */
546
+ .table-cell-toolbar {
547
+ position: absolute;
548
+ z-index: 50;
549
+ display: flex;
550
+ gap: 2px;
551
+ padding: 4px;
552
+ background: #fff;
553
+ border: 1px solid #e3e3e3;
554
+ border-radius: 6px;
555
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
556
+ }
557
+
558
+ .table-cell-toolbar-btn {
559
+ display: flex;
560
+ align-items: center;
561
+ justify-content: center;
562
+ width: 28px;
563
+ height: 28px;
564
+ border: none;
565
+ background: transparent;
566
+ border-radius: 4px;
567
+ cursor: pointer;
568
+ color: #606266;
569
+ transition: all 0.15s;
570
+ }
571
+
572
+ .table-cell-toolbar-btn:hover {
573
+ background: #ecf5ff;
574
+ color: #1e96fc;
575
+ }
576
+
577
+ .table-cell-toolbar-btn.danger:hover {
578
+ background: #fef0f0;
579
+ color: #f56c6c;
580
+ }
581
+
582
+ /* Table Edge Add Button */
583
+ .table-edge-add {
584
+ position: absolute;
585
+ z-index: 40;
586
+ display: none;
587
+ width: 20px;
588
+ height: 20px;
589
+ align-items: center;
590
+ justify-content: center;
591
+ background: #fff;
592
+ border: 1px solid #e3e3e3;
593
+ border-radius: 4px;
594
+ cursor: pointer;
595
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
596
+ color: #606266;
597
+ transition: all 0.15s;
598
+ }
599
+
600
+ .table-edge-add:hover {
601
+ background: #ecf5ff;
602
+ border-color: #1e96fc;
603
+ color: #1e96fc;
604
+ }
605
+
606
+ .table-edge-add.visible {
607
+ display: flex;
608
+ }
609
+
610
+ .table-edge-add-row {
611
+ width: 100%;
612
+ height: 8px;
613
+ left: 0;
614
+ border-radius: 0 0 4px 4px;
615
+ }
616
+
617
+ .table-edge-add-col {
618
+ height: 100%;
619
+ width: 8px;
620
+ top: 0;
621
+ border-radius: 0 4px 4px 0;
622
+ }
623
+
624
+ /* Bubble Menu - 企业级风格 */
625
+ .bubble-menu {
626
+ position: absolute;
627
+ display: flex;
628
+ align-items: center;
629
+ gap: 2px;
630
+ padding: 4px 6px;
631
+ background: #fff;
632
+ border: 1px solid #e3e3e3;
633
+ border-radius: 8px;
634
+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
635
+ z-index: 100;
636
+ opacity: 0;
637
+ visibility: hidden;
638
+ transition: opacity 0.15s, visibility 0.15s, transform 0.15s;
639
+ transform: translateY(4px);
640
+ max-width: calc(100vw - 40px);
641
+ }
642
+
643
+ .bubble-menu.is-visible {
644
+ opacity: 1;
645
+ visibility: visible;
646
+ transform: translateY(0);
647
+ }
648
+
649
+ .bubble-menu.is-visible {
650
+ opacity: 1;
651
+ visibility: visible;
652
+ transform: translateY(0);
653
+ }
654
+
655
+ .bubble-btn {
656
+ display: flex;
657
+ align-items: center;
658
+ justify-content: center;
659
+ width: 28px;
660
+ height: 28px;
661
+ border: none;
662
+ background: transparent;
663
+ color: #37352f;
664
+ border-radius: 4px;
665
+ cursor: pointer;
666
+ transition: all 0.15s;
667
+ position: relative;
668
+ }
669
+
670
+ .bubble-btn:hover {
671
+ background: rgba(55, 53, 47, 0.08);
672
+ }
673
+
674
+ .bubble-btn.is-active {
675
+ background: #1e96fc;
676
+ color: #fff;
677
+ }
678
+
679
+ .bubble-btn svg {
680
+ width: 16px;
681
+ height: 16px;
682
+ stroke: currentColor;
683
+ stroke-width: 2;
684
+ fill: none;
685
+ }
686
+
687
+ .bubble-divider {
688
+ width: 1px;
689
+ height: 16px;
690
+ background: #e3e3e3;
691
+ margin: 0 3px;
692
+ }
693
+
694
+ /* Dropdown */
695
+ .bubble-dropdown {
696
+ position: relative;
697
+ }
698
+
699
+ .bubble-dropdown-btn {
700
+ display: flex;
701
+ align-items: center;
702
+ gap: 4px;
703
+ padding: 0 6px;
704
+ height: 28px;
705
+ border: none;
706
+ background: transparent;
707
+ color: #37352f;
708
+ border-radius: 4px;
709
+ cursor: pointer;
710
+ font-size: 12px;
711
+ font-weight: 500;
712
+ font-family: inherit;
713
+ transition: all 0.15s;
714
+ white-space: nowrap;
715
+ }
716
+
717
+ .bubble-dropdown-btn:hover {
718
+ background: rgba(55, 53, 47, 0.08);
719
+ }
720
+
721
+ .bubble-dropdown-btn svg {
722
+ width: 12px;
723
+ height: 12px;
724
+ stroke: currentColor;
725
+ stroke-width: 2;
726
+ fill: none;
727
+ }
728
+
729
+ .bubble-dropdown-menu {
730
+ position: absolute;
731
+ top: 100%;
732
+ left: 0;
733
+ margin-top: 4px;
734
+ min-width: 120px;
735
+ background: #fff;
736
+ border: 1px solid #e3e3e3;
737
+ border-radius: 6px;
738
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
739
+ padding: 4px;
740
+ opacity: 0;
741
+ visibility: hidden;
742
+ transform: translateY(-4px);
743
+ transition: all 0.15s;
744
+ z-index: 101;
745
+ }
746
+
747
+ .bubble-dropdown:hover .bubble-dropdown-menu,
748
+ .bubble-dropdown.is-open .bubble-dropdown-menu {
749
+ opacity: 1;
750
+ visibility: visible;
751
+ transform: translateY(0);
752
+ }
753
+
754
+ .bubble-dropdown-item {
755
+ display: flex;
756
+ align-items: center;
757
+ gap: 6px;
758
+ width: 100%;
759
+ padding: 6px 8px;
760
+ border: none;
761
+ background: transparent;
762
+ color: #37352f;
763
+ border-radius: 4px;
764
+ cursor: pointer;
765
+ font-size: 12px;
766
+ font-weight: 500;
767
+ font-family: inherit;
768
+ text-align: left;
769
+ transition: all 0.15s;
770
+ }
771
+
772
+ .bubble-dropdown-item:hover {
773
+ background: rgba(55, 53, 47, 0.08);
774
+ }
775
+
776
+ .bubble-dropdown-item.is-active {
777
+ background: #1e96fc;
778
+ color: #fff;
779
+ }
780
+
781
+ .bubble-dropdown-item svg {
782
+ width: 16px;
783
+ height: 16px;
784
+ stroke: currentColor;
785
+ stroke-width: 2;
786
+ fill: none;
787
+ }
788
+
789
+ .image-input {
790
+ display: none;
791
+ }
792
+
793
+ .table-grid-preview {
794
+ display: grid;
795
+ grid-template-columns: repeat(10, 18px);
796
+ gap: 2px;
797
+ padding: 8px;
798
+ }
799
+
800
+ .table-grid-preview .table-cell {
801
+ width: 18px;
802
+ height: 18px;
803
+ border: 1px solid #e3e3e3;
804
+ border-radius: 2px;
805
+ background: #fff;
806
+ cursor: pointer;
807
+ transition: all 0.1s;
808
+ }
809
+
810
+ .table-grid-preview .table-cell:hover {
811
+ background: rgba(30, 150, 252, 0.3);
812
+ border-color: #1e96fc;
813
+ }
814
+
815
+ .table-grid-preview .table-cell.selected {
816
+ background: rgba(30, 150, 252, 0.15);
817
+ border-color: rgba(30, 150, 252, 0.5);
818
+ }
819
+
820
+ .table-size-hint {
821
+ text-align: center;
822
+ padding: 4px 8px 6px;
823
+ font-size: 10px;
824
+ color: #8c8c8c;
825
+ }
826
+
827
+ /* Image Toolbar */
828
+ .image-toolbar {
829
+ position: absolute;
830
+ display: flex;
831
+ align-items: center;
832
+ gap: 2px;
833
+ padding: 4px 6px;
834
+ background: #fff;
835
+ border: 1px solid #e3e3e3;
836
+ border-radius: 6px;
837
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
838
+ z-index: 100;
839
+ transform: translateX(-50%);
840
+ }
841
+
842
+ .image-toolbar-btn {
843
+ display: flex;
844
+ align-items: center;
845
+ justify-content: center;
846
+ width: 28px;
847
+ height: 28px;
848
+ border: none;
849
+ background: transparent;
850
+ border-radius: 4px;
851
+ cursor: pointer;
852
+ color: #595959;
853
+ transition: all 0.15s;
854
+ }
855
+
856
+ .image-toolbar-btn:hover {
857
+ background: #f5f5f5;
858
+ color: #1e96fc;
859
+ }
860
+
861
+ .image-toolbar-btn.danger:hover {
862
+ background: #fff1f0;
863
+ color: #ff4d4f;
864
+ }
865
+
866
+ .image-toolbar-btn svg {
867
+ width: 16px;
868
+ height: 16px;
869
+ stroke: currentColor;
870
+ stroke-width: 2;
871
+ fill: none;
872
+ }
873
+
874
+ .image-toolbar-divider {
875
+ width: 1px;
876
+ height: 20px;
877
+ background: #e3e3e3;
878
+ margin: 0 4px;
879
+ }
880
+
881
+ /* Image More Menu */
882
+ .image-more-menu {
883
+ position: absolute;
884
+ top: 100%;
885
+ right: 0;
886
+ margin-top: 4px;
887
+ padding: 4px;
888
+ background: #fff;
889
+ border: 1px solid #e3e3e3;
890
+ border-radius: 6px;
891
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
892
+ z-index: 101;
893
+ min-width: 120px;
894
+ }
895
+
896
+ .image-more-menu-item {
897
+ display: flex;
898
+ align-items: center;
899
+ gap: 8px;
900
+ padding: 8px 12px;
901
+ border: none;
902
+ background: transparent;
903
+ width: 100%;
904
+ text-align: left;
905
+ font-size: 13px;
906
+ color: #595959;
907
+ border-radius: 4px;
908
+ cursor: pointer;
909
+ transition: all 0.15s;
910
+ }
911
+
912
+ .image-more-menu-item:hover {
913
+ background: #f5f5f5;
914
+ color: #1e96fc;
915
+ }
916
+
917
+ .image-more-menu-item svg {
918
+ width: 14px;
919
+ height: 14px;
920
+ stroke: currentColor;
921
+ stroke-width: 2;
922
+ fill: none;
923
+ }
924
+
925
+ /* Selected Image */
926
+ .ProseMirror img.selected {
927
+ outline: 2px solid #1e96fc;
928
+ outline-offset: 2px;
929
+ }
930
+ `,S([$({type:String,attribute:"content"})],I.prototype,"content",2),S([$({type:Boolean,attribute:"readonly"})],I.prototype,"readonly",2),S([$({type:Boolean,attribute:"preview"})],I.prototype,"preview",2),S([A()],I.prototype,"_pendingContent",2),S([A()],I.prototype,"_hoverRow",2),S([A()],I.prototype,"_hoverCol",2),S([A()],I.prototype,"_tableDropdownOpen",2),S([A()],I.prototype,"_isLoading",2),S([A()],I.prototype,"_tableCellToolbar",2),S([A()],I.prototype,"_tableEdgeHover",2),S([A()],I.prototype,"_imageToolbar",2),S([A()],I.prototype,"_imageMoreMenuVisible",2),S([A()],I.prototype,"_hasSlashCommand",2),I=S([R("qxs-blocksuite-editor")],I);export{I as QxsBlocksuiteEditor};
931
+ //# sourceMappingURL=blocksuite-editor.mjs.map