@qxs-bns/components-wc 0.0.30 → 0.0.31

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 (49) hide show
  1. package/es/editor/blocksuite-editor.mjs +166 -357
  2. package/es/editor/blocksuite-editor.mjs.map +1 -1
  3. package/es/editor/toolbar.mjs +2 -0
  4. package/es/editor/toolbar.mjs.map +1 -0
  5. package/es/subject/action.mjs +7 -8
  6. package/es/subject/action.mjs.map +1 -1
  7. package/es/subject/blank-fill.mjs +243 -132
  8. package/es/subject/blank-fill.mjs.map +1 -1
  9. package/es/subject/layout.mjs +4 -4
  10. package/es/subject/layout.mjs.map +1 -1
  11. package/es/subject/page-end.mjs +1 -1
  12. package/es/subject/page-end.mjs.map +1 -1
  13. package/es/subject/scale.mjs +165 -126
  14. package/es/subject/scale.mjs.map +1 -1
  15. package/es/subject/shared-methods.mjs +2 -0
  16. package/es/subject/shared-methods.mjs.map +1 -0
  17. package/es/subject/shared-styles.mjs +75 -0
  18. package/es/subject/shared-styles.mjs.map +1 -0
  19. package/es/subject/single.mjs +243 -187
  20. package/es/subject/single.mjs.map +1 -1
  21. package/es/subject/sortable.mjs +7 -7
  22. package/es/subject/sortable.mjs.map +1 -1
  23. package/es/subject/text-fill.mjs +273 -138
  24. package/es/subject/text-fill.mjs.map +1 -1
  25. package/lib/editor/blocksuite-editor.cjs +166 -357
  26. package/lib/editor/blocksuite-editor.cjs.map +1 -1
  27. package/lib/editor/toolbar.cjs +2 -0
  28. package/lib/editor/toolbar.cjs.map +1 -0
  29. package/lib/subject/action.cjs +33 -34
  30. package/lib/subject/action.cjs.map +1 -1
  31. package/lib/subject/blank-fill.cjs +247 -136
  32. package/lib/subject/blank-fill.cjs.map +1 -1
  33. package/lib/subject/layout.cjs +2 -2
  34. package/lib/subject/layout.cjs.map +1 -1
  35. package/lib/subject/page-end.cjs +2 -2
  36. package/lib/subject/page-end.cjs.map +1 -1
  37. package/lib/subject/scale.cjs +165 -126
  38. package/lib/subject/scale.cjs.map +1 -1
  39. package/lib/subject/shared-methods.cjs +2 -0
  40. package/lib/subject/shared-methods.cjs.map +1 -0
  41. package/lib/subject/shared-styles.cjs +75 -0
  42. package/lib/subject/shared-styles.cjs.map +1 -0
  43. package/lib/subject/single.cjs +243 -187
  44. package/lib/subject/single.cjs.map +1 -1
  45. package/lib/subject/sortable.cjs +1 -1
  46. package/lib/subject/sortable.cjs.map +1 -1
  47. package/lib/subject/text-fill.cjs +273 -138
  48. package/lib/subject/text-fill.cjs.map +1 -1
  49. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import{Node as e,mergeAttributes as t,Editor as i}from"@tiptap/core";import o from"@tiptap/extension-blockquote";import r from"@tiptap/extension-bold";import l from"@tiptap/extension-bullet-list";import s from"@tiptap/extension-code";import n from"@tiptap/extension-document";import a from"@tiptap/extension-heading";import d from"@tiptap/extension-history";import c from"@tiptap/extension-horizontal-rule";import h from"@tiptap/extension-image";import b from"@tiptap/extension-italic";import p from"@tiptap/extension-link";import u from"@tiptap/extension-list-item";import g from"@tiptap/extension-ordered-list";import m from"@tiptap/extension-paragraph";import x from"@tiptap/extension-placeholder";import v from"@tiptap/extension-strike";import{Table as _}from"@tiptap/extension-table";import{TableCell as y}from"@tiptap/extension-table-cell";import{TableHeader as f}from"@tiptap/extension-table-header";import{TableRow as k}from"@tiptap/extension-table-row";import w from"@tiptap/extension-text";import C from"@tiptap/extension-text-align";import T from"@tiptap/extension-underline";import{css as $,LitElement as M,html as L}from"lit";import{property as I,state as A}from"lit/decorators.js";import{safeCustomElement as S}from"../base/define.mjs";var B=Object.defineProperty,R=Object.getOwnPropertyDescriptor,E=(e,t,i,o)=>{for(var r,l=o>1?void 0:o?R(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};const P="输入内容",z="输入 / 唤出快捷命令",q=e.create({name:"taskList",group:"block list",content:"taskItem+",defining:!0,parseHTML:()=>[{tag:'ul[data-type="taskList"]'}],renderHTML(e){let{HTMLAttributes:i}=e;return["ul",t(i,{"data-type":"taskList"}),0]},addCommands(){return{toggleTaskList:()=>e=>{let{commands:t}=e;return t.toggleList(this.name,"taskItem")}}}}),V=e.create({name:"taskItem",defining:!0,content:"paragraph block*",addAttributes:()=>({checked:{default:!1,parseHTML:e=>"true"===e.getAttribute("data-checked"),renderHTML:e=>({"data-checked":String(Boolean(e.checked))})}}),parseHTML:()=>[{tag:'li[data-type="taskItem"]'}],renderHTML(e){let{HTMLAttributes:i}=e;const o=Boolean(i.checked);return["li",t(i,{"data-type":"taskItem"}),["label",{contenteditable:"false"},["input",{type:"checkbox",checked:o?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),H=h.extend({addAttributes(){return{...this.parent?.(),width:{default:null,parseHTML:e=>{const t=e.getAttribute("width"),i=Number(t);return Number.isFinite(i)&&i>0?i:null},renderHTML:e=>e.width?{width:String(e.width)}:{}},align:{default:"center",parseHTML:e=>e.getAttribute("data-align")||"center",renderHTML:e=>e.align?{"data-align":String(e.align)}:{}}}},renderHTML(e){let{HTMLAttributes:i}=e;const o=Number(i.width),r=["max-width:100%","height:auto",Number.isFinite(o)&&o>0?`width:${o}px`:"",i.style||""].filter(Boolean).join(";");return["img",t(this.options.HTMLAttributes,i,{style:r})]}});let F=class extends M{constructor(){super(...arguments),this.content="",this["model-value"]="",this.placeholder=P,this["toolbar-mode"]="header",this["header-always-visible"]="false",this["use-model"]="false",this.readonly="false",this.preview="false",this["custom-styles"]="",this._injectedStyleEl=null,this["upload-image"]=async e=>new Promise((t,i)=>{const o=new FileReader;o.onload=e=>t(e.target?.result),o.onerror=i,o.readAsDataURL(e)}),this._editor=null,this._pendingContent=null,this._tableRows=3,this._tableCols=3,this._hoverRow=0,this._hoverCol=0,this._tableDropdownOpen=!1,this._tableCellToolbar={x:0,y:0,visible:!1,cellRow:0,cellCol:0},this._imageToolbar={x:0,y:0,visible:!1},this._linkEditor={x:0,y:0,visible:!1,url:"",label:""},this._isEditorFocused=!1,this._selectedImage=null,this._hasSlashCommand=!1,this._slashCommandRange=null,this._isUpdating=!1,this._pendingImageInsertPos=null,this._linkSelection=null,this._preserveFocusOnInternalClick=!1,this._tableEdgeDetectionSetup=!1}_injectCustomStyles(){const e=this.shadowRoot;if(!e)return;if(this._injectedStyleEl&&(this._injectedStyleEl.remove(),this._injectedStyleEl=null),!this["custom-styles"])return;const t=document.createElement("style");t.textContent=this["custom-styles"],e.appendChild(t),this._injectedStyleEl=t}get _useModelValue(){return!0===this["use-model"]||"true"===this["use-model"]||""===this["use-model"]||this.hasAttribute("use-model")}get _readonlyValue(){return!1!==this.readonly&&"false"!==this.readonly}get _previewValue(){return!1!==this.preview&&"false"!==this.preview}get _isEditable(){return!this._readonlyValue&&!this._previewValue}get _toolbarModeValue(){return"header"===this["toolbar-mode"]?"header":"slash"}get _headerAlwaysVisibleValue(){return!0===this["header-always-visible"]||"true"===this["header-always-visible"]||""===this["header-always-visible"]||this.hasAttribute("header-always-visible")}get _resolvedPlaceholder(){return this.placeholder&&this.placeholder!==P&&this.placeholder!==z?this.placeholder:"header"===this._toolbarModeValue?P:z}_initEditor(){if(this._editor)return;const e=this.shadowRoot?.querySelector(".editor-content");if(!e)return void requestAnimationFrame(()=>this._initEditor());for(;e.firstChild;)e.removeChild(e.firstChild);const t=this._useModelValue,h=this.getAttribute("model-value")??this["model-value"],$=this.content,M=t?(this._pendingContent??h)||"<p></p>":(this._pendingContent??$)||"<p></p>",L=[n,m,w,r,b,T,v,s,a.configure({levels:[1,2,3]}),l,g,q,V,u,o,c,d,H.configure({inline:!1,allowBase64:!0}),p.extend({inclusive:!1}).configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer"}}),C.configure({types:["heading","paragraph"]}),_.configure({resizable:!0}),k,y,f,x.configure({placeholder:this._resolvedPlaceholder})];this._editor=new i({element:e,extensions:L,editable:this._isEditable,content:M}),this._pendingContent=null,this._editor.on("selectionUpdate",()=>{"slash"===this._toolbarModeValue&&this._updateBubbleMenuPosition(),this._editor?.isActive("table")?this._showTableCellToolbar():this._hideTableCellToolbar(),this._syncImageSelectionState()}),this._editor.on("transaction",()=>{this._editor?.isActive("table")?this._showTableCellToolbar():this._hideTableCellToolbar(),this._checkSlashCommand(),this._setupTableEdgeDetection(),this._syncImageSelectionState()}),this._editor.on("update",()=>{this._emitContentChange()})}_toggleTaskItemChecked(e){const t=e.target,i=this._editor;if(!(t instanceof HTMLInputElement&&"checkbox"===t.type&&i))return;const o=t.closest('li[data-type="taskItem"]');if(!o)return;e.preventDefault(),e.stopPropagation();const r=i.view.posAtDOM(o,0),l=Math.max(0,r-2),s=Math.min(i.state.doc.content.size,r+2);let n=null;if(i.state.doc.nodesBetween(l,s,(e,t)=>{if("taskItem"===e.type.name)return n=t,!1}),null===n)return;const a=i.state.doc.nodeAt(n);a&&"taskItem"===a.type.name&&i.view.dispatch(i.state.tr.setNodeMarkup(n,void 0,{...a.attrs,checked:!a.attrs.checked}))}_emitContentChange(){if(!this._editor)return;const e=this._editor.getHTML();this.dispatchEvent(new CustomEvent("content-change",{detail:e,bubbles:!0,composed:!0}))}_setupTableEdgeDetection(){const e=this.shadowRoot?.querySelector(".editor-content"),t=this.shadowRoot?.querySelector(".editor-wrapper");if(!e||this._tableEdgeDetectionSetup)return;this._tableEdgeDetectionSetup=!0;const i=e=>{this._toggleTaskItemChecked(e);const t=e.target;t instanceof Element&&t.closest(".editor-header, .bubble-menu, .table-cell-toolbar, .image-toolbar, .link-editor")||this._isEditable&&this._editor?.chain().focus().run()};e.addEventListener("click",i),t?.addEventListener("click",i)}_handleWrapperFocusIn(){this._preserveFocusOnInternalClick=!1,this._isEditorFocused=!0}_handleWrapperMouseDown(e){const t=e.target;this._isEditable&&t instanceof Element&&!t.closest(".editor-header, .bubble-menu, .table-cell-toolbar, .image-toolbar, .link-editor")&&(this._preserveFocusOnInternalClick=!0,requestAnimationFrame(()=>{this._preserveFocusOnInternalClick=!1}))}_handleWrapperFocusOut(e){const t=e.relatedTarget,i=this.shadowRoot?.querySelector(".editor-wrapper");this._preserveFocusOnInternalClick||t&&i?.contains(t)||(this._isEditorFocused=!1,this._tableDropdownOpen=!1,this._closeLinkEditor())}_isHeaderVisible(){return"header"===this._toolbarModeValue&&!this._previewValue&&(this._headerAlwaysVisibleValue||this._isEditorFocused||this._tableDropdownOpen||Boolean(this._selectedImage))}_getImageSelection(){const e=this._editor,t=e?.state.selection;return e&&t?.node&&"image"===t.node.type?.name?{pos:t.from,attrs:t.node.attrs??{}}:null}_getImageMaxWidth(){const e=this.shadowRoot?.querySelector(".editor-content"),t=(e?.clientWidth??560)-32;return Math.max(24,Math.min(560,t))}async _getImageNaturalWidth(e){return await new Promise(t=>{const i=URL.createObjectURL(e),o=new window.Image;o.onload=()=>{const e=o.naturalWidth;URL.revokeObjectURL(i),t(Number.isFinite(e)&&e>0?e:null)},o.onerror=()=>{URL.revokeObjectURL(i),t(null)},o.src=i})}_syncImageSelectionState(){const e=this._getImageSelection();if(!e)return this._selectedImage=null,void("slash"===this._toolbarModeValue&&this._hideImageToolbar());const t=Number(e.attrs.width),i=String(e.attrs.align||"center");if(this._selectedImage={pos:e.pos,width:Number.isFinite(t)&&t>0?t:this._getImageMaxWidth(),align:i},"slash"!==this._toolbarModeValue)return void this._hideImageToolbar();const o=this._editor,r=this.shadowRoot?.querySelector(".editor-wrapper")?.getBoundingClientRect();if(!o||!r)return;const l=o.view.coordsAtPos(e.pos),s=l.left-r.left+(l.right-l.left)/2,n=l.top-r.top-40;this._showImageToolbar({x:s,y:n})}_clearSlashCommandText(){if(!this._editor||!this._slashCommandRange)return;const{from:e,to:t}=this._slashCommandRange;this._editor.chain().focus().deleteRange({from:e,to:t}).run(),this._hasSlashCommand=!1,this._slashCommandRange=null}_checkSlashCommand(){if(!this._editor)return;const{selection:e}=this._editor.state;if(!e.empty)return this._hasSlashCommand=!1,void(this._slashCommandRange=null);const{$from:t}=e,i=t.parent.textBetween(0,t.parentOffset," "," "),o=/(?:^|\s)(\/\S*)$/.exec(i);if(!o)return this._hasSlashCommand=!1,void(this._slashCommandRange=null);const r=o[1];this._hasSlashCommand=!0,this._slashCommandRange={from:e.from-r.length,to:e.from}}firstUpdated(){this._injectCustomStyles(),this._initEditor()}updated(e){if(e.has("custom-styles")&&this._injectCustomStyles(),this._editor){if(e.has("content")||e.has("model-value")&&this._useModelValue){const e=this._useModelValue?this["model-value"]:this.content;e!==this._editor.getHTML()&&this._editor.commands.setContent(e||"<p></p>")}(e.has("readonly")||e.has("preview"))&&this._editor.setEditable(this._isEditable)}else e.has("content")&&(this._pendingContent=this.content),e.has("model-value")&&this._useModelValue&&(this._pendingContent=this["model-value"])}disconnectedCallback(){super.disconnectedCallback(),this._editor?.destroy(),this._editor=null}getContent(){return this._editor?.getHTML()??""}forceUpdate(){if(this.requestUpdate(),this._editor){const e=this._useModelValue?this["model-value"]:this.content;e!==this._editor.getHTML()&&this._editor.commands.setContent(e||"<p></p>")}}_applyFormat(e){this._clearSlashCommandText(),e()}_getSlashCommandContext(){const e=this._editor,t=this._slashCommandRange;if(!e||!t)return null;return{lineFrom:e.state.doc.resolve(t.from).start(),lineTo:t.from}}_applySlashLineMark(e,t){const i=this._editor,o=this._getSlashCommandContext();return!(!i||!o)&&(this._clearSlashCommandText(),o.lineFrom<o.lineTo&&e(i.chain().focus().setTextSelection({from:o.lineFrom,to:o.lineTo})).run(),t(i.chain().focus().setTextSelection({from:o.lineTo,to:o.lineTo})).run(),!0)}_applyToolbarLineMark(e,t){const i=this._editor;if(!i)return!1;const{selection:o}=i.state,r=o.empty?(()=>{const e=i.state.doc.resolve(o.from);return{from:e.start(),to:e.end()}})():{from:o.from,to:o.to};return!(r.from>=r.to)&&(e(i.chain().focus().setTextSelection(r)).run(),t(i.chain().focus().setTextSelection({from:r.to,to:r.to})).run(),!0)}_applySlashLineBlock(e){const t=this._editor,i=this._getSlashCommandContext();return!(!t||!i)&&(this._clearSlashCommandText(),e(t.chain().focus().setTextSelection({from:i.lineFrom,to:i.lineTo})).run(),!0)}_toggleBold(){this._applySlashLineMark(e=>e.setBold(),e=>e.unsetBold())||this._applyToolbarLineMark(e=>e.toggleBold(),e=>e.unsetBold())}_toggleItalic(){this._applySlashLineMark(e=>e.setItalic(),e=>e.unsetItalic())||this._applyToolbarLineMark(e=>e.toggleItalic(),e=>e.unsetItalic())}_toggleUnderline(){this._applySlashLineMark(e=>e.setUnderline(),e=>e.unsetUnderline())||this._applyToolbarLineMark(e=>e.toggleUnderline(),e=>e.unsetUnderline())}_toggleStrike(){this._applySlashLineMark(e=>e.setStrike(),e=>e.unsetStrike())||this._applyToolbarLineMark(e=>e.toggleStrike(),e=>e.unsetStrike())}_toggleCode(){this._applySlashLineMark(e=>e.setCode(),e=>e.unsetCode())||this._applyToolbarLineMark(e=>e.toggleCode(),e=>e.unsetCode())}_setHeading(e){this._applySlashLineBlock(t=>t.setHeading({level:e}))||this._applyFormat(()=>this._editor?.chain().focus().toggleHeading({level:e}).run())}_setParagraph(){this._applySlashLineBlock(e=>e.setParagraph())||this._applyFormat(()=>this._editor?.chain().focus().setParagraph().run())}_toggleBulletList(){this._applySlashLineBlock(e=>e.toggleBulletList())||this._applyFormat(()=>this._editor?.chain().focus().toggleBulletList().run())}_toggleOrderedList(){this._applySlashLineBlock(e=>e.toggleOrderedList())||this._applyFormat(()=>this._editor?.chain().focus().toggleOrderedList().run())}_toggleTaskList(){this._applySlashLineBlock(e=>e.toggleTaskList())||this._applyFormat(()=>this._editor?.chain().focus().toggleTaskList().run())}_toggleBlockquote(){this._applySlashLineBlock(e=>e.toggleBlockquote())||this._applyFormat(()=>this._editor?.chain().focus().toggleBlockquote().run())}_setTextAlign(e){this._applySlashLineBlock(t=>t.setTextAlign(e))||this._applyFormat(()=>this._editor?.chain().focus().setTextAlign(e).run())}_normalizeLinkUrl(e){const t=e.trim();return t?/^(https?:\/\/|mailto:|tel:|#|\/)/i.test(t)?t:`https://${t}`:""}_getLinkLabelFromRange(e){const t=this._editor;return!t||!e||e.from>=e.to?"":t.state.doc.textBetween(e.from,e.to,"")}_getLinkTargetRange(){const e=this._editor;if(!e)return null;const{selection:t}=e.state;if(!t.empty)return{from:t.from,to:t.to};if(e.isActive("link"))return e.chain().focus().extendMarkRange("link").run(),{from:e.state.selection.from,to:e.state.selection.to};const i=e.state.doc.resolve(t.from);return{from:i.start(),to:i.end()}}_setLink(e){const t=this._editor,i=this.shadowRoot?.querySelector(".editor-wrapper"),o=e.currentTarget instanceof HTMLElement?e.currentTarget:null;if(!t||!i||!o)return;const r=this._getLinkTargetRange();this._linkSelection=r;const l=i.getBoundingClientRect(),s=o.getBoundingClientRect(),n=Math.max(12,l.width-332),a=Math.min(Math.max(12,s.left-l.left),n),d=s.bottom-l.top+8,c=String(t.getAttributes("link").href||""),h=this._getLinkLabelFromRange(r);this._linkEditor={x:a,y:d,visible:!0,url:c,label:h},this.updateComplete.then(()=>{const e=this.shadowRoot?.querySelector('.link-editor__input[data-field="url"]');e?.focus(),e?.select()})}_closeLinkEditor(){this._linkEditor={...this._linkEditor,visible:!1}}_handleLinkEditorInput(e){const t=e.target,i="label"===t.dataset.field?"label":"url";this._linkEditor={...this._linkEditor,[i]:t.value}}_applyLink(){const e=this._editor,t=this._normalizeLinkUrl(this._linkEditor.url),i=this._linkEditor.label.trim()||t;if(!e||!t)return;this._clearSlashCommandText();const o=this._linkSelection??this._getLinkTargetRange()??e.state.selection,r=o.from+i.length;e.chain().focus().insertContentAt({from:o.from,to:o.to},{type:"text",text:i,marks:[{type:"link",attrs:{href:t}}]}).setTextSelection({from:r,to:r}).run(),this._closeLinkEditor()}_removeLink(){const e=this._editor;if(!e)return;const t=this._linkSelection??e.state.selection;let i=e.chain().focus();t.from!==t.to&&(i=i.setTextSelection(t)),i.extendMarkRange("link").unsetLink().run(),this._closeLinkEditor()}_handleLinkEditorKeydown(e){if("Enter"===e.key)return e.preventDefault(),void this._applyLink();"Escape"===e.key&&(e.preventDefault(),this._closeLinkEditor())}_insertTable(e,t){this._editor?.chain().focus().insertTable({rows:e??this._tableRows,cols:t??this._tableCols,withHeaderRow:!0}).run()}async _handleImageUpload(e){const t=e.target,i=t.files?.[0];if(i)try{const e=await this._getImageNaturalWidth(i),t=await this["upload-image"](i),o=e?Math.min(e,this._getImageMaxWidth()):this._getImageMaxWidth();this._clearSlashCommandText();const r=this._pendingImageInsertPos;this._pendingImageInsertPos=null,null!==r?this._insertImageAt(r,{src:t,width:o,align:"center"}):this._editor?.chain().focus().setImage({src:t,width:o,align:"center"}).run()}catch(e){}t.value=""}_triggerImageUpload(){this._clearSlashCommandText();const e=this.shadowRoot?.querySelector(".image-input");e?.click()}_insertTableByClick(e,t){this._clearSlashCommandText(),this._tableRows=e,this._tableCols=t,this._insertTable(e,t)}_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)&&requestAnimationFrame(()=>{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(){requestAnimationFrame(()=>{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){requestAnimationFrame(()=>{this._imageToolbar={x:e.x,y:e.y,visible:!0}})}_hideImageToolbar(){requestAnimationFrame(()=>{this._imageToolbar={...this._imageToolbar,visible:!1}})}_deleteImage(){const e=this._getSelectedImageNode();if(!e)return;const{editor:t,pos:i,node:o}=e;t.view.dispatch(t.state.tr.delete(i,i+o.nodeSize)),this._selectedImage=null,this._pendingImageInsertPos=null,this._hideImageToolbar()}_insertImageAfter(){const e=this._getSelectedImageNode();e?(this._pendingImageInsertPos=e.pos+e.node.nodeSize,this._triggerImageUpload()):this._triggerImageUpload()}_getSelectedImageNode(){const e=this._editor,t=this._selectedImage?.pos;if(!e||void 0===t)return null;const i=e.state.doc.nodeAt(t);return i&&"image"===i.type.name?{editor:e,pos:t,node:i}:null}_insertImageAt(e,t){const i=this._editor;if(!i)return;const o=Math.max(0,Math.min(e,i.state.doc.content.size));i.chain().insertContentAt(o,{type:"image",attrs:t}).setNodeSelection(o).run()}_updateSelectedImageAttributes(e){const t=this._getSelectedImageNode();if(!t)return;const{editor:i,pos:o,node:r}=t;i.view.dispatch(i.state.tr.setNodeMarkup(o,void 0,{...r.attrs,...e}))}_setImageWidth(e){const t=Math.max(24,Math.min(this._getImageMaxWidth(),Math.round(e)));this._updateSelectedImageAttributes({width:t})}_handleImageWidthInput(e){const t=e.target.value.trim();if(!t)return;const i=Number(t);Number.isFinite(i)&&this._setImageWidth(i)}_setImageAlignLeft(){this._updateSelectedImageAttributes({align:"left"})}_setImageAlignCenter(){this._updateSelectedImageAttributes({align:"center"})}_setImageAlignRight(){this._updateSelectedImageAttributes({align:"right"})}_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"})?"右对齐":"左对齐":"对齐"}_renderImageControls(){const e=this._selectedImage;return e?L`
1
+ import{Node as e,mergeAttributes as t,Editor as i}from"@tiptap/core";import o from"@tiptap/extension-blockquote";import r from"@tiptap/extension-bold";import l from"@tiptap/extension-bullet-list";import s from"@tiptap/extension-code";import n from"@tiptap/extension-document";import a from"@tiptap/extension-heading";import d from"@tiptap/extension-history";import h from"@tiptap/extension-horizontal-rule";import c from"@tiptap/extension-image";import p from"@tiptap/extension-italic";import b from"@tiptap/extension-link";import u from"@tiptap/extension-list-item";import g from"@tiptap/extension-ordered-list";import m from"@tiptap/extension-paragraph";import _ from"@tiptap/extension-placeholder";import x from"@tiptap/extension-strike";import{Table as f}from"@tiptap/extension-table";import{TableCell as v}from"@tiptap/extension-table-cell";import{TableHeader as y}from"@tiptap/extension-table-header";import{TableRow as k}from"@tiptap/extension-table-row";import w from"@tiptap/extension-text";import T from"@tiptap/extension-text-align";import C from"@tiptap/extension-underline";import{css as M,LitElement as I,html as $}from"lit";import{property as L,state as S}from"lit/decorators.js";import{DEFAULT_EDITOR_TOOLBAR as A,parseEditorToolbarItems as R}from"./toolbar.mjs";import{safeCustomElement as E}from"../base/define.mjs";var B=Object.defineProperty,P=Object.getOwnPropertyDescriptor,q=(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};const F="输入内容",z="输入 / 唤出快捷命令",V=e.create({name:"taskList",group:"block list",content:"taskItem+",defining:!0,parseHTML:()=>[{tag:'ul[data-type="taskList"]'}],renderHTML(e){let{HTMLAttributes:i}=e;return["ul",t(i,{"data-type":"taskList"}),0]},addCommands(){return{toggleTaskList:()=>e=>{let{commands:t}=e;return t.toggleList(this.name,"taskItem")}}}}),D=e.create({name:"taskItem",defining:!0,content:"paragraph block*",addAttributes:()=>({checked:{default:!1,parseHTML:e=>"true"===e.getAttribute("data-checked"),renderHTML:e=>({"data-checked":String(Boolean(e.checked))})}}),parseHTML:()=>[{tag:'li[data-type="taskItem"]'}],renderHTML(e){let{HTMLAttributes:i}=e;const o=Boolean(i.checked);return["li",t(i,{"data-type":"taskItem"}),["label",{contenteditable:"false"},["input",{type:"checkbox",checked:o?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),H=c.extend({addAttributes(){return{...this.parent?.(),width:{default:null,parseHTML:e=>{const t=e.getAttribute("width"),i=Number(t);return Number.isFinite(i)&&i>0?i:null},renderHTML:e=>e.width?{width:String(e.width)}:{}},align:{default:"left",parseHTML:e=>e.getAttribute("data-align")||"left",renderHTML:e=>e.align?{"data-align":String(e.align)}:{}}}},renderHTML(e){let{HTMLAttributes:i}=e;const o=Number(i.width),r=["max-width:100%","height:auto",Number.isFinite(o)&&o>0?`width:${o}px`:"",i.style||""].filter(Boolean).join(";");return["img",t(this.options.HTMLAttributes,i,{style:r})]}});let j=class extends I{constructor(){super(...arguments),this.content="",this["model-value"]="",this.placeholder=F,this["toolbar-mode"]="header",this.toolbar=A.join(" "),this["header-always-visible"]="false",this["use-model"]="false",this.readonly="false",this.preview="false",this["custom-styles"]="",this._injectedStyleEl=null,this["upload-image"]=async e=>new Promise((t,i)=>{const o=new FileReader;o.onload=e=>t(e.target?.result),o.onerror=i,o.readAsDataURL(e)}),this._editor=null,this._pendingContent=null,this._tableRows=3,this._tableCols=3,this._hoverRow=0,this._hoverCol=0,this._tableDropdownOpen=!1,this._tableCellToolbar={x:0,y:0,visible:!1,cellRow:0,cellCol:0},this._imageToolbar={x:0,y:0,visible:!1},this._linkEditor={x:0,y:0,visible:!1,url:"",label:""},this._isEditorFocused=!1,this._selectedImage=null,this._hasSlashCommand=!1,this._slashCommandRange=null,this._isUpdating=!1,this._pendingImageInsertPos=null,this._linkSelection=null,this._preserveFocusOnInternalClick=!1,this._tableEdgeDetectionSetup=!1}_injectCustomStyles(){const e=this.shadowRoot;if(!e)return;if(this._injectedStyleEl&&(this._injectedStyleEl.remove(),this._injectedStyleEl=null),!this["custom-styles"])return;const t=document.createElement("style");t.textContent=this["custom-styles"],e.appendChild(t),this._injectedStyleEl=t}get _useModelValue(){return!0===this["use-model"]||"true"===this["use-model"]||""===this["use-model"]||this.hasAttribute("use-model")}get _readonlyValue(){return!1!==this.readonly&&"false"!==this.readonly}get _previewValue(){return!1!==this.preview&&"false"!==this.preview}get _isEditable(){return!this._readonlyValue&&!this._previewValue}get _toolbarModeValue(){return"header"===this["toolbar-mode"]?"header":"slash"}get _headerAlwaysVisibleValue(){return!0===this["header-always-visible"]||"true"===this["header-always-visible"]||""===this["header-always-visible"]||this.hasAttribute("header-always-visible")}get _resolvedPlaceholder(){return this.placeholder&&this.placeholder!==F&&this.placeholder!==z?this.placeholder:"header"===this._toolbarModeValue?F:z}get _toolbarItemsValue(){return R(this.toolbar)}_hasToolbarItem(e){return this._toolbarItemsValue.includes(e)}_initEditor(){if(this._editor)return;const e=this.shadowRoot?.querySelector(".editor-content");if(!e)return void requestAnimationFrame(()=>this._initEditor());for(;e.firstChild;)e.removeChild(e.firstChild);const t=this._useModelValue,c=this.getAttribute("model-value")??this["model-value"],M=this.content,I=t?(this._pendingContent??c)||"<p></p>":(this._pendingContent??M)||"<p></p>",$=[n,m,w,r,p,C,x,s,a.configure({levels:[1,2,3]}),l,g,V,D,u,o,h,d,H.configure({inline:!1,allowBase64:!0}),b.extend({inclusive:!1}).configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer"}}),T.configure({types:["heading","paragraph"]}),f.configure({resizable:!0}),k,v,y,_.configure({placeholder:this._resolvedPlaceholder})];this._editor=new i({element:e,extensions:$,editable:this._isEditable,content:I}),this._pendingContent=null,this._editor.on("selectionUpdate",()=>{"slash"===this._toolbarModeValue&&this._updateBubbleMenuPosition(),this._editor?.isActive("table")?this._showTableCellToolbar():this._hideTableCellToolbar(),this._syncImageSelectionState()}),this._editor.on("transaction",()=>{this._editor?.isActive("table")?this._showTableCellToolbar():this._hideTableCellToolbar(),this._checkSlashCommand(),this._setupTableEdgeDetection(),this._syncImageSelectionState()}),this._editor.on("update",()=>{this._emitContentChange()})}_toggleTaskItemChecked(e){const t=e.target,i=this._editor;if(!(t instanceof HTMLInputElement&&"checkbox"===t.type&&i))return;const o=t.closest('li[data-type="taskItem"]');if(!o)return;e.preventDefault(),e.stopPropagation();const r=i.view.posAtDOM(o,0),l=Math.max(0,r-2),s=Math.min(i.state.doc.content.size,r+2);let n=null;if(i.state.doc.nodesBetween(l,s,(e,t)=>{if("taskItem"===e.type.name)return n=t,!1}),null===n)return;const a=i.state.doc.nodeAt(n);a&&"taskItem"===a.type.name&&i.view.dispatch(i.state.tr.setNodeMarkup(n,void 0,{...a.attrs,checked:!a.attrs.checked}))}_emitContentChange(){if(!this._editor)return;const e=this._editor.getHTML();this.dispatchEvent(new CustomEvent("content-change",{detail:e,bubbles:!0,composed:!0}))}_setupTableEdgeDetection(){const e=this.shadowRoot?.querySelector(".editor-content"),t=this.shadowRoot?.querySelector(".editor-wrapper");if(!e||this._tableEdgeDetectionSetup)return;this._tableEdgeDetectionSetup=!0;const i=e=>{this._toggleTaskItemChecked(e);const t=e.target;t instanceof Element&&t.closest(".editor-header, .bubble-menu, .table-cell-toolbar, .image-toolbar, .link-editor")||this._isEditable&&this._editor?.chain().focus().run()};e.addEventListener("click",i),t?.addEventListener("click",i)}_handleWrapperFocusIn(){this._preserveFocusOnInternalClick=!1,this._isEditorFocused=!0}_handleWrapperMouseDown(e){const t=e.target;this._isEditable&&t instanceof Element&&!t.closest(".editor-header, .bubble-menu, .table-cell-toolbar, .image-toolbar, .link-editor")&&(this._preserveFocusOnInternalClick=!0,requestAnimationFrame(()=>{this._preserveFocusOnInternalClick=!1}))}_handleWrapperFocusOut(e){const t=e.relatedTarget,i=this.shadowRoot?.querySelector(".editor-wrapper");this._preserveFocusOnInternalClick||t&&i?.contains(t)||(this._isEditorFocused=!1,this._tableDropdownOpen=!1,this._closeLinkEditor())}_isHeaderVisible(){return"header"===this._toolbarModeValue&&!this._previewValue&&(this._headerAlwaysVisibleValue||this._isEditorFocused||this._tableDropdownOpen||Boolean(this._selectedImage))}_getImageSelection(){const e=this._editor,t=e?.state.selection;return e&&t?.node&&"image"===t.node.type?.name?{pos:t.from,attrs:t.node.attrs??{}}:null}_getImageMaxWidth(){const e=this.shadowRoot?.querySelector(".editor-content"),t=(e?.clientWidth??560)-32;return Math.max(24,Math.min(560,t))}async _getImageNaturalWidth(e){return await new Promise(t=>{const i=URL.createObjectURL(e),o=new window.Image;o.onload=()=>{const e=o.naturalWidth;URL.revokeObjectURL(i),t(Number.isFinite(e)&&e>0?e:null)},o.onerror=()=>{URL.revokeObjectURL(i),t(null)},o.src=i})}_syncImageSelectionState(){const e=this._getImageSelection();if(!e)return this._selectedImage=null,void("slash"===this._toolbarModeValue&&this._hideImageToolbar());const t=Number(e.attrs.width),i=String(e.attrs.align||"left");if(this._selectedImage={pos:e.pos,width:Number.isFinite(t)&&t>0?t:this._getImageMaxWidth(),align:i},"slash"!==this._toolbarModeValue)return void this._hideImageToolbar();const o=this._editor,r=this.shadowRoot?.querySelector(".editor-wrapper")?.getBoundingClientRect();if(!o||!r)return;const l=o.view.coordsAtPos(e.pos),s=l.left-r.left+(l.right-l.left)/2,n=l.top-r.top-40;this._showImageToolbar({x:s,y:n})}_clearSlashCommandText(){if(!this._editor||!this._slashCommandRange)return;const{from:e,to:t}=this._slashCommandRange;this._editor.chain().focus().deleteRange({from:e,to:t}).run(),this._hasSlashCommand=!1,this._slashCommandRange=null}_checkSlashCommand(){if(!this._editor)return;const{selection:e}=this._editor.state;if(!e.empty)return this._hasSlashCommand=!1,void(this._slashCommandRange=null);const{$from:t}=e,i=t.parent.textBetween(0,t.parentOffset," "," "),o=/(?:^|\s)(\/\S*)$/.exec(i);if(!o)return this._hasSlashCommand=!1,void(this._slashCommandRange=null);const r=o[1];this._hasSlashCommand=!0,this._slashCommandRange={from:e.from-r.length,to:e.from}}firstUpdated(){this._injectCustomStyles(),queueMicrotask(()=>{this.isConnected&&this._initEditor()})}updated(e){if(e.has("custom-styles")&&this._injectCustomStyles(),this._editor){if(e.has("content")||e.has("model-value")&&this._useModelValue){const e=this._useModelValue?this["model-value"]:this.content;e!==this._editor.getHTML()&&this._editor.commands.setContent(e||"<p></p>")}(e.has("readonly")||e.has("preview"))&&this._editor.setEditable(this._isEditable)}else e.has("content")&&(this._pendingContent=this.content),e.has("model-value")&&this._useModelValue&&(this._pendingContent=this["model-value"])}disconnectedCallback(){super.disconnectedCallback(),this._editor?.destroy(),this._editor=null}getContent(){return this._editor?.getHTML()??""}forceUpdate(){if(this.requestUpdate(),this._editor){const e=this._useModelValue?this["model-value"]:this.content;e!==this._editor.getHTML()&&this._editor.commands.setContent(e||"<p></p>")}}_applyFormat(e){this._clearSlashCommandText(),e()}_getSlashCommandContext(){const e=this._editor,t=this._slashCommandRange;if(!e||!t)return null;return{lineFrom:e.state.doc.resolve(t.from).start(),lineTo:t.from}}_applySlashLineMark(e,t){const i=this._editor,o=this._getSlashCommandContext();return!(!i||!o)&&(this._clearSlashCommandText(),o.lineFrom<o.lineTo&&e(i.chain().focus().setTextSelection({from:o.lineFrom,to:o.lineTo})).run(),t(i.chain().focus().setTextSelection({from:o.lineTo,to:o.lineTo})).run(),!0)}_applyToolbarLineMark(e,t){const i=this._editor;if(!i)return!1;const{selection:o}=i.state,r=o.empty?(()=>{const e=i.state.doc.resolve(o.from);return{from:e.start(),to:e.end()}})():{from:o.from,to:o.to};return!(r.from>=r.to)&&(e(i.chain().focus().setTextSelection(r)).run(),t(i.chain().focus().setTextSelection({from:r.to,to:r.to})).run(),!0)}_applySlashLineBlock(e){const t=this._editor,i=this._getSlashCommandContext();return!(!t||!i)&&(this._clearSlashCommandText(),e(t.chain().focus().setTextSelection({from:i.lineFrom,to:i.lineTo})).run(),!0)}_toggleBold(){this._applySlashLineMark(e=>e.setBold(),e=>e.unsetBold())||this._applyToolbarLineMark(e=>e.toggleBold(),e=>e.unsetBold())}_toggleItalic(){this._applySlashLineMark(e=>e.setItalic(),e=>e.unsetItalic())||this._applyToolbarLineMark(e=>e.toggleItalic(),e=>e.unsetItalic())}_toggleUnderline(){this._applySlashLineMark(e=>e.setUnderline(),e=>e.unsetUnderline())||this._applyToolbarLineMark(e=>e.toggleUnderline(),e=>e.unsetUnderline())}_toggleStrike(){this._applySlashLineMark(e=>e.setStrike(),e=>e.unsetStrike())||this._applyToolbarLineMark(e=>e.toggleStrike(),e=>e.unsetStrike())}_toggleCode(){this._applySlashLineMark(e=>e.setCode(),e=>e.unsetCode())||this._applyToolbarLineMark(e=>e.toggleCode(),e=>e.unsetCode())}_setHeading(e){this._applySlashLineBlock(t=>t.setHeading({level:e}))||this._applyFormat(()=>this._editor?.chain().focus().toggleHeading({level:e}).run())}_setParagraph(){this._applySlashLineBlock(e=>e.setParagraph())||this._applyFormat(()=>this._editor?.chain().focus().setParagraph().run())}_toggleBulletList(){this._applySlashLineBlock(e=>e.toggleBulletList())||this._applyFormat(()=>this._editor?.chain().focus().toggleBulletList().run())}_toggleOrderedList(){this._applySlashLineBlock(e=>e.toggleOrderedList())||this._applyFormat(()=>this._editor?.chain().focus().toggleOrderedList().run())}_toggleTaskList(){this._applySlashLineBlock(e=>e.toggleTaskList())||this._applyFormat(()=>this._editor?.chain().focus().toggleTaskList().run())}_toggleBlockquote(){this._applySlashLineBlock(e=>e.toggleBlockquote())||this._applyFormat(()=>this._editor?.chain().focus().toggleBlockquote().run())}_setTextAlign(e){this._applySlashLineBlock(t=>t.setTextAlign(e))||this._applyFormat(()=>this._editor?.chain().focus().setTextAlign(e).run())}_normalizeLinkUrl(e){const t=e.trim();return t?/^(https?:\/\/|mailto:|tel:|#|\/)/i.test(t)?t:`https://${t}`:""}_getLinkLabelFromRange(e){const t=this._editor;return!t||!e||e.from>=e.to?"":t.state.doc.textBetween(e.from,e.to,"")}_getLinkTargetRange(){const e=this._editor;if(!e)return null;const{selection:t}=e.state;if(!t.empty)return{from:t.from,to:t.to};if(e.isActive("link"))return e.chain().focus().extendMarkRange("link").run(),{from:e.state.selection.from,to:e.state.selection.to};const i=e.state.doc.resolve(t.from);return{from:i.start(),to:i.end()}}_setLink(e){const t=this._editor,i=this.shadowRoot?.querySelector(".editor-wrapper"),o=e.currentTarget instanceof HTMLElement?e.currentTarget:null;if(!t||!i||!o)return;const r=this._getLinkTargetRange();this._linkSelection=r;const l=i.getBoundingClientRect(),s=o.getBoundingClientRect(),n=Math.max(12,l.width-332),a=Math.min(Math.max(12,s.left-l.left),n),d=s.bottom-l.top+8,h=String(t.getAttributes("link").href||""),c=this._getLinkLabelFromRange(r);this._linkEditor={x:a,y:d,visible:!0,url:h,label:c},this.updateComplete.then(()=>{const e=this.shadowRoot?.querySelector('.link-editor__input[data-field="url"]');e?.focus(),e?.select()})}_closeLinkEditor(){this._linkEditor={...this._linkEditor,visible:!1}}_handleLinkEditorInput(e){const t=e.target,i="label"===t.dataset.field?"label":"url";this._linkEditor={...this._linkEditor,[i]:t.value}}_applyLink(){const e=this._editor,t=this._normalizeLinkUrl(this._linkEditor.url),i=this._linkEditor.label.trim()||t;if(!e||!t)return;this._clearSlashCommandText();const o=this._linkSelection??this._getLinkTargetRange()??e.state.selection,r=o.from+i.length;e.chain().focus().insertContentAt({from:o.from,to:o.to},{type:"text",text:i,marks:[{type:"link",attrs:{href:t}}]}).setTextSelection({from:r,to:r}).run(),this._closeLinkEditor()}_removeLink(){const e=this._editor;if(!e)return;const t=this._linkSelection??e.state.selection;let i=e.chain().focus();t.from!==t.to&&(i=i.setTextSelection(t)),i.extendMarkRange("link").unsetLink().run(),this._closeLinkEditor()}_handleLinkEditorKeydown(e){if("Enter"===e.key)return e.preventDefault(),void this._applyLink();"Escape"===e.key&&(e.preventDefault(),this._closeLinkEditor())}_insertTable(e,t){this._editor?.chain().focus().insertTable({rows:e??this._tableRows,cols:t??this._tableCols,withHeaderRow:!0}).run()}async _handleImageUpload(e){const t=e.target,i=t.files?.[0];if(i)try{const e=await this._getImageNaturalWidth(i),t=await this["upload-image"](i),o=e?Math.min(e,this._getImageMaxWidth()):this._getImageMaxWidth();this._clearSlashCommandText();const r=this._pendingImageInsertPos;this._pendingImageInsertPos=null,null!==r?this._insertImageAt(r,{src:t,width:o,align:"left"}):this._editor?.chain().focus().setImage({src:t,width:o,align:"left"}).run()}catch(e){}t.value=""}_triggerImageUpload(){this._clearSlashCommandText();const e=this.shadowRoot?.querySelector(".image-input");e?.click()}_insertTableByClick(e,t){this._clearSlashCommandText(),this._tableRows=e,this._tableCols=t,this._insertTable(e,t)}_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)&&requestAnimationFrame(()=>{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(){requestAnimationFrame(()=>{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){requestAnimationFrame(()=>{this._imageToolbar={x:e.x,y:e.y,visible:!0}})}_hideImageToolbar(){requestAnimationFrame(()=>{this._imageToolbar={...this._imageToolbar,visible:!1}})}_deleteImage(){const e=this._getSelectedImageNode();if(!e)return;const{editor:t,pos:i,node:o}=e;t.view.dispatch(t.state.tr.delete(i,i+o.nodeSize)),this._selectedImage=null,this._pendingImageInsertPos=null,this._hideImageToolbar()}_insertImageAfter(){const e=this._getSelectedImageNode();e?(this._pendingImageInsertPos=e.pos+e.node.nodeSize,this._triggerImageUpload()):this._triggerImageUpload()}_getSelectedImageNode(){const e=this._editor,t=this._selectedImage?.pos;if(!e||void 0===t)return null;const i=e.state.doc.nodeAt(t);return i&&"image"===i.type.name?{editor:e,pos:t,node:i}:null}_insertImageAt(e,t){const i=this._editor;if(!i)return;const o=Math.max(0,Math.min(e,i.state.doc.content.size));i.chain().insertContentAt(o,{type:"image",attrs:t}).setNodeSelection(o).run()}_updateSelectedImageAttributes(e){const t=this._getSelectedImageNode();if(!t)return;const{editor:i,pos:o,node:r}=t;i.view.dispatch(i.state.tr.setNodeMarkup(o,void 0,{...r.attrs,...e}))}_setImageWidth(e){const t=Math.max(24,Math.min(this._getImageMaxWidth(),Math.round(e)));this._updateSelectedImageAttributes({width:t})}_handleImageWidthInput(e){const t=e.target.value.trim();if(!t)return;const i=Number(t);Number.isFinite(i)&&this._setImageWidth(i)}_setImageAlignLeft(){this._updateSelectedImageAttributes({align:"left"})}_setImageAlignCenter(){this._updateSelectedImageAttributes({align:"center"})}_setImageAlignRight(){this._updateSelectedImageAttributes({align:"right"})}_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"})?"右对齐":"左对齐":"对齐"}_renderImageControls(){const e=this._selectedImage;return e?$`
2
2
  <button class="bubble-btn danger" title="删除图片" @click=${this._deleteImage}>
3
3
  <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>
4
4
  </button>
@@ -6,6 +6,7 @@ import{Node as e,mergeAttributes as t,Editor as i}from"@tiptap/core";import o fr
6
6
  <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>
7
7
  </button>
8
8
  <div class="bubble-divider"></div>
9
+ <span class="image-control-label">对齐</span>
9
10
  <button class="bubble-btn ${"left"===e.align?"is-active":""}" title="左对齐" @click=${this._setImageAlignLeft}>
10
11
  <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>
11
12
  </button>
@@ -26,14 +27,145 @@ import{Node as e,mergeAttributes as t,Editor as i}from"@tiptap/core";import o fr
26
27
  @input=${this._handleImageWidthInput}
27
28
  />
28
29
  </div>
29
- `:""}_updateBubbleMenuPosition(){"slash"===this._toolbarModeValue&&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,h=d.top-s.top-40;c+n.width>s.width&&(c=s.width-n.width-8),c<0&&(c=8),h<0&&(h=d.bottom-s.top+8),e.style.left=`${c}px`,e.style.top=`${h}px`,e.style.opacity="1",e.style.visibility="visible"})}render(){const e=this._editor;return L`
30
+ `:""}_joinToolbarGroups(e){return e.flatMap((e,t)=>0===t?[e]:[$`<div class="bubble-divider"></div>`,e])}_renderFormatToolbarGroup(e){return $`
31
+ <button
32
+ class="bubble-btn ${e?.isActive("bold")?"is-active":""}"
33
+ @click=${this._toggleBold}
34
+ title="加粗"
35
+ >
36
+ <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>
37
+ </button>
38
+ <button
39
+ class="bubble-btn ${e?.isActive("italic")?"is-active":""}"
40
+ @click=${this._toggleItalic}
41
+ title="斜体"
42
+ >
43
+ <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>
44
+ </button>
45
+ <button
46
+ class="bubble-btn ${e?.isActive("underline")?"is-active":""}"
47
+ @click=${this._toggleUnderline}
48
+ title="下划线"
49
+ >
50
+ <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>
51
+ </button>
52
+ <button
53
+ class="bubble-btn ${e?.isActive("strike")?"is-active":""}"
54
+ @click=${this._toggleStrike}
55
+ title="删除线"
56
+ >
57
+ <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>
58
+ </button>
59
+ `}_renderHeadingToolbarGroup(e){return $`
60
+ <div class="bubble-dropdown">
61
+ <button class="bubble-dropdown-btn">
62
+ ${this._getTextLabel()}
63
+ <svg viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"/></svg>
64
+ </button>
65
+ <div class="bubble-dropdown-menu">
66
+ <button class="bubble-dropdown-item ${e?.isActive("heading")?"":"is-active"}" @click=${this._setParagraph}>正文</button>
67
+ <button class="bubble-dropdown-item ${e?.isActive("heading",{level:1})?"is-active":""}" @click=${()=>this._setHeading(1)}>标题 1</button>
68
+ <button class="bubble-dropdown-item ${e?.isActive("heading",{level:2})?"is-active":""}" @click=${()=>this._setHeading(2)}>标题 2</button>
69
+ <button class="bubble-dropdown-item ${e?.isActive("heading",{level:3})?"is-active":""}" @click=${()=>this._setHeading(3)}>标题 3</button>
70
+ </div>
71
+ </div>
72
+ `}_renderAlignToolbarGroup(e){return $`
73
+ <div class="bubble-dropdown">
74
+ <button class="bubble-dropdown-btn">
75
+ ${this._getAlignLabel()}
76
+ <svg viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"/></svg>
77
+ </button>
78
+ <div class="bubble-dropdown-menu">
79
+ <button class="bubble-dropdown-item ${e?.isActive({textAlign:"left"})?"is-active":""}" @click=${()=>this._setTextAlign("left")}>
80
+ <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>
81
+ 左对齐
82
+ </button>
83
+ <button class="bubble-dropdown-item ${e?.isActive({textAlign:"center"})?"is-active":""}" @click=${()=>this._setTextAlign("center")}>
84
+ <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>
85
+ 居中
86
+ </button>
87
+ <button class="bubble-dropdown-item ${e?.isActive({textAlign:"right"})?"is-active":""}" @click=${()=>this._setTextAlign("right")}>
88
+ <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>
89
+ 右对齐
90
+ </button>
91
+ </div>
92
+ </div>
93
+ `}_renderCodeLinkImageToolbarGroup(e){return $`
94
+ ${this._hasToolbarItem("code")?$`
95
+ <button class="bubble-btn ${e?.isActive("code")?"is-active":""}" @click=${this._toggleCode} title="行内代码">
96
+ <svg viewBox="0 0 24 24"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
97
+ </button>
98
+ `:""}
99
+ ${this._hasToolbarItem("link")?$`
100
+ <button class="bubble-btn ${e?.isActive("link")?"is-active":""}" @click=${this._setLink} title="链接">
101
+ <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>
102
+ </button>
103
+ `:""}
104
+ ${this._hasToolbarItem("image")?$`
105
+ <button class="bubble-btn" @click=${this._triggerImageUpload} title="图片">
106
+ <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>
107
+ </button>
108
+ `:""}
109
+ `}_renderListToolbarGroup(e){return $`
110
+ <button class="bubble-btn ${e?.isActive("bulletList")?"is-active":""}" @click=${this._toggleBulletList} title="无序列表">
111
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
112
+ <line x1="9" y1="6" x2="20" y2="6"/>
113
+ <line x1="9" y1="12" x2="20" y2="12"/>
114
+ <line x1="9" y1="18" x2="20" y2="18"/>
115
+ <circle cx="4" cy="6" r="0.5" fill="currentColor" stroke="none"/>
116
+ <circle cx="4" cy="12" r="0.5" fill="currentColor" stroke="none"/>
117
+ <circle cx="4" cy="18" r="0.5" fill="currentColor" stroke="none"/>
118
+ </svg>
119
+ </button>
120
+ <button class="bubble-btn ${e?.isActive("orderedList")?"is-active":""}" @click=${this._toggleOrderedList} title="有序列表">
121
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
122
+ <line x1="10" y1="6" x2="21" y2="6"/>
123
+ <line x1="10" y1="12" x2="21" y2="12"/>
124
+ <line x1="10" y1="18" x2="21" y2="18"/>
125
+ <path d="M4 6h1v4"/>
126
+ <path d="M4 10h2"/>
127
+ <path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1.5"/>
128
+ </svg>
129
+ </button>
130
+ <button class="bubble-btn ${e?.isActive("taskList")?"is-active":""}" @click=${this._toggleTaskList} title="待办列表">
131
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
132
+ <rect x="3" y="5" width="4" height="4" rx="1"/>
133
+ <polyline points="4 7 5 8 6.5 6.5"/>
134
+ <line x1="10" y1="7" x2="21" y2="7"/>
135
+ <rect x="3" y="15" width="4" height="4" rx="1"/>
136
+ <line x1="10" y1="17" x2="21" y2="17"/>
137
+ </svg>
138
+ </button>
139
+ `}_renderBlockquoteToolbarGroup(e){return $`
140
+ <button class="bubble-btn ${e?.isActive("blockquote")?"is-active":""}" @click=${this._toggleBlockquote} title="引用">
141
+ <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>
142
+ </button>
143
+ `}_renderTableToolbarGroup(){return $`
144
+ <div
145
+ class="bubble-dropdown ${this._tableDropdownOpen?"is-open":""}"
146
+ @mouseenter=${()=>{this._tableDropdownOpen=!0,this._hoverRow=0,this._hoverCol=0}}
147
+ @mouseleave=${()=>this._tableDropdownOpen=!1}
148
+ >
149
+ <button class="bubble-dropdown-btn" title="表格">
150
+ <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>
151
+ </button>
152
+ <div class="bubble-dropdown-menu">
153
+ <div class="table-grid-preview">
154
+ ${this._renderTableGrid()}
155
+ </div>
156
+ <div class="table-size-hint">
157
+ <span>${this._hoverRow>0?`${this._hoverRow} × ${this._hoverCol}`:`${this._tableRows} × ${this._tableCols}`}</span>
158
+ </div>
159
+ </div>
160
+ </div>
161
+ `}_renderTextToolbar(e){const t=[];return this._hasToolbarItem("format")&&t.push(this._renderFormatToolbarGroup(e)),this._hasToolbarItem("heading")&&t.push(this._renderHeadingToolbarGroup(e)),this._hasToolbarItem("align")&&t.push(this._renderAlignToolbarGroup(e)),(this._hasToolbarItem("code")||this._hasToolbarItem("link")||this._hasToolbarItem("image"))&&t.push(this._renderCodeLinkImageToolbarGroup(e)),this._hasToolbarItem("list")&&t.push(this._renderListToolbarGroup(e)),this._hasToolbarItem("blockquote")&&t.push(this._renderBlockquoteToolbarGroup(e)),this._hasToolbarItem("table")&&t.push(this._renderTableToolbarGroup()),this._joinToolbarGroups(t)}_updateBubbleMenuPosition(){"slash"===this._toolbarModeValue&&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 h=d.left-s.left,c=d.top-s.top-40;h+n.width>s.width&&(h=s.width-n.width-8),h<0&&(h=8),c<0&&(c=d.bottom-s.top+8),e.style.left=`${h}px`,e.style.top=`${c}px`,e.style.opacity="1",e.style.visibility="visible"})}render(){const e=this._editor;return $`
30
162
  <div
31
163
  class="editor-wrapper ${e?"":"loading"} ${this._previewValue?"preview":""}"
32
164
  @mousedown=${this._handleWrapperMouseDown}
33
165
  @focusin=${this._handleWrapperFocusIn}
34
166
  @focusout=${this._handleWrapperFocusOut}
35
167
  >
36
- ${e?"":L`
168
+ ${e?"":$`
37
169
  <div class="loading-placeholder">
38
170
  <div class="loading-spinner"></div>
39
171
  <span>编辑器加载中...</span>
@@ -46,359 +178,24 @@ import{Node as e,mergeAttributes as t,Editor as i}from"@tiptap/core";import o fr
46
178
  @change=${this._handleImageUpload}
47
179
  />
48
180
 
49
- ${this._previewValue||"header"!==this._toolbarModeValue?"":L`
181
+ ${this._previewValue||"header"!==this._toolbarModeValue?"":$`
50
182
  <div class="editor-header ${this._isHeaderVisible()?"is-visible":""}">
51
183
  <div class="editor-header__inner">
52
- ${this._selectedImage?this._renderImageControls():L`
53
- <button
54
- class="bubble-btn ${e?.isActive("bold")?"is-active":""}"
55
- @click=${this._toggleBold}
56
- title="加粗"
57
- >
58
- <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>
59
- </button>
60
- <button
61
- class="bubble-btn ${e?.isActive("italic")?"is-active":""}"
62
- @click=${this._toggleItalic}
63
- title="斜体"
64
- >
65
- <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>
66
- </button>
67
- <button
68
- class="bubble-btn ${e?.isActive("underline")?"is-active":""}"
69
- @click=${this._toggleUnderline}
70
- title="下划线"
71
- >
72
- <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>
73
- </button>
74
- <button
75
- class="bubble-btn ${e?.isActive("strike")?"is-active":""}"
76
- @click=${this._toggleStrike}
77
- title="删除线"
78
- >
79
- <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>
80
- </button>
81
-
82
- <div class="bubble-divider"></div>
83
-
84
- <div class="bubble-dropdown">
85
- <button class="bubble-dropdown-btn">
86
- ${this._getTextLabel()}
87
- <svg viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"/></svg>
88
- </button>
89
- <div class="bubble-dropdown-menu">
90
- <button class="bubble-dropdown-item ${e?.isActive("heading")?"":"is-active"}" @click=${this._setParagraph}>正文</button>
91
- <button class="bubble-dropdown-item ${e?.isActive("heading",{level:1})?"is-active":""}" @click=${()=>this._setHeading(1)}>标题 1</button>
92
- <button class="bubble-dropdown-item ${e?.isActive("heading",{level:2})?"is-active":""}" @click=${()=>this._setHeading(2)}>标题 2</button>
93
- <button class="bubble-dropdown-item ${e?.isActive("heading",{level:3})?"is-active":""}" @click=${()=>this._setHeading(3)}>标题 3</button>
94
- </div>
95
- </div>
96
-
97
- <div class="bubble-divider"></div>
98
-
99
- <div class="bubble-dropdown">
100
- <button class="bubble-dropdown-btn">
101
- ${this._getAlignLabel()}
102
- <svg viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"/></svg>
103
- </button>
104
- <div class="bubble-dropdown-menu">
105
- <button class="bubble-dropdown-item ${e?.isActive({textAlign:"left"})?"is-active":""}" @click=${()=>this._setTextAlign("left")}>
106
- <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>
107
- 左对齐
108
- </button>
109
- <button class="bubble-dropdown-item ${e?.isActive({textAlign:"center"})?"is-active":""}" @click=${()=>this._setTextAlign("center")}>
110
- <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>
111
- 居中
112
- </button>
113
- <button class="bubble-dropdown-item ${e?.isActive({textAlign:"right"})?"is-active":""}" @click=${()=>this._setTextAlign("right")}>
114
- <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>
115
- 右对齐
116
- </button>
117
- </div>
118
- </div>
119
-
120
- <div class="bubble-divider"></div>
121
-
122
- <button class="bubble-btn ${e?.isActive("code")?"is-active":""}" @click=${this._toggleCode} title="行内代码">
123
- <svg viewBox="0 0 24 24"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
124
- </button>
125
- <button class="bubble-btn ${e?.isActive("link")?"is-active":""}" @click=${this._setLink} title="链接">
126
- <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>
127
- </button>
128
- <button class="bubble-btn" @click=${this._triggerImageUpload} title="图片">
129
- <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>
130
- </button>
131
-
132
- <div class="bubble-divider"></div>
133
-
134
- <button class="bubble-btn ${e?.isActive("bulletList")?"is-active":""}" @click=${this._toggleBulletList} title="无序列表">
135
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
136
- <line x1="9" y1="6" x2="20" y2="6"/>
137
- <line x1="9" y1="12" x2="20" y2="12"/>
138
- <line x1="9" y1="18" x2="20" y2="18"/>
139
- <circle cx="4" cy="6" r="0.5" fill="currentColor" stroke="none"/>
140
- <circle cx="4" cy="12" r="0.5" fill="currentColor" stroke="none"/>
141
- <circle cx="4" cy="18" r="0.5" fill="currentColor" stroke="none"/>
142
- </svg>
143
- </button>
144
- <button class="bubble-btn ${e?.isActive("orderedList")?"is-active":""}" @click=${this._toggleOrderedList} title="有序列表">
145
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
146
- <line x1="10" y1="6" x2="21" y2="6"/>
147
- <line x1="10" y1="12" x2="21" y2="12"/>
148
- <line x1="10" y1="18" x2="21" y2="18"/>
149
- <path d="M4 6h1v4"/>
150
- <path d="M4 10h2"/>
151
- <path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1.5"/>
152
- </svg>
153
- </button>
154
- <button class="bubble-btn ${e?.isActive("taskList")?"is-active":""}" @click=${this._toggleTaskList} title="待办列表">
155
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
156
- <rect x="3" y="5" width="4" height="4" rx="1"/>
157
- <polyline points="4 7 5 8 6.5 6.5"/>
158
- <line x1="10" y1="7" x2="21" y2="7"/>
159
- <rect x="3" y="15" width="4" height="4" rx="1"/>
160
- <line x1="10" y1="17" x2="21" y2="17"/>
161
- </svg>
162
- </button>
163
- <button class="bubble-btn ${e?.isActive("blockquote")?"is-active":""}" @click=${this._toggleBlockquote} title="引用">
164
- <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>
165
- </button>
166
-
167
- <div class="bubble-divider"></div>
168
-
169
- <div
170
- class="bubble-dropdown ${this._tableDropdownOpen?"is-open":""}"
171
- @mouseenter=${()=>{this._tableDropdownOpen=!0,this._hoverRow=0,this._hoverCol=0}}
172
- @mouseleave=${()=>this._tableDropdownOpen=!1}
173
- >
174
- <button class="bubble-dropdown-btn" title="表格">
175
- <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>
176
- </button>
177
- <div class="bubble-dropdown-menu">
178
- <div class="table-grid-preview">
179
- ${this._renderTableGrid()}
180
- </div>
181
- <div class="table-size-hint">
182
- <span>${this._hoverRow>0?`${this._hoverRow} × ${this._hoverCol}`:`${this._tableRows} × ${this._tableCols}`}</span>
183
- </div>
184
- </div>
185
- </div>
186
- `}
184
+ ${this._selectedImage?this._renderImageControls():this._renderTextToolbar(e)}
187
185
  </div>
188
186
  </div>
189
187
  `}
190
188
 
191
189
  <!-- Bubble Menu (悬浮操作栏) -->
192
- ${this._previewValue||"slash"!==this._toolbarModeValue?"":L`
190
+ ${this._previewValue||"slash"!==this._toolbarModeValue?"":$`
193
191
  <div class="bubble-menu">
194
- <!-- 文本格式 -->
195
- <button
196
- class="bubble-btn ${e?.isActive("bold")?"is-active":""}"
197
- @click=${this._toggleBold}
198
- title="加粗"
199
- >
200
- <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>
201
- </button>
202
- <button
203
- class="bubble-btn ${e?.isActive("italic")?"is-active":""}"
204
- @click=${this._toggleItalic}
205
- title="斜体"
206
- >
207
- <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>
208
- </button>
209
- <button
210
- class="bubble-btn ${e?.isActive("underline")?"is-active":""}"
211
- @click=${this._toggleUnderline}
212
- title="下划线"
213
- >
214
- <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>
215
- </button>
216
- <button
217
- class="bubble-btn ${e?.isActive("strike")?"is-active":""}"
218
- @click=${this._toggleStrike}
219
- title="删除线"
220
- >
221
- <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>
222
- </button>
223
-
224
- <div class="bubble-divider"></div>
225
-
226
- <!-- 文本类型下拉 -->
227
- <div class="bubble-dropdown">
228
- <button class="bubble-dropdown-btn">
229
- ${this._getTextLabel()}
230
- <svg viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"/></svg>
231
- </button>
232
- <div class="bubble-dropdown-menu">
233
- <button
234
- class="bubble-dropdown-item ${e?.isActive("heading")?"":"is-active"}"
235
- @click=${this._setParagraph}
236
- >
237
- 正文
238
- </button>
239
- <button
240
- class="bubble-dropdown-item ${e?.isActive("heading",{level:1})?"is-active":""}"
241
- @click=${()=>this._setHeading(1)}
242
- >
243
- 标题 1
244
- </button>
245
- <button
246
- class="bubble-dropdown-item ${e?.isActive("heading",{level:2})?"is-active":""}"
247
- @click=${()=>this._setHeading(2)}
248
- >
249
- 标题 2
250
- </button>
251
- <button
252
- class="bubble-dropdown-item ${e?.isActive("heading",{level:3})?"is-active":""}"
253
- @click=${()=>this._setHeading(3)}
254
- >
255
- 标题 3
256
- </button>
257
- </div>
258
- </div>
259
-
260
- <div class="bubble-divider"></div>
261
-
262
- <!-- 对齐下拉 -->
263
- <div class="bubble-dropdown">
264
- <button class="bubble-dropdown-btn">
265
- ${this._getAlignLabel()}
266
- <svg viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"/></svg>
267
- </button>
268
- <div class="bubble-dropdown-menu">
269
- <button
270
- class="bubble-dropdown-item ${e?.isActive({textAlign:"left"})?"is-active":""}"
271
- @click=${()=>this._setTextAlign("left")}
272
- >
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
277
- class="bubble-dropdown-item ${e?.isActive({textAlign:"center"})?"is-active":""}"
278
- @click=${()=>this._setTextAlign("center")}
279
- >
280
- <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>
281
- 居中
282
- </button>
283
- <button
284
- class="bubble-dropdown-item ${e?.isActive({textAlign:"right"})?"is-active":""}"
285
- @click=${()=>this._setTextAlign("right")}
286
- >
287
- <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>
288
- 右对齐
289
- </button>
290
- </div>
291
- </div>
292
-
293
- <div class="bubble-divider"></div>
294
-
295
- <!-- 行内代码 -->
296
- <button
297
- class="bubble-btn ${e?.isActive("code")?"is-active":""}"
298
- @click=${this._toggleCode}
299
- title="行内代码"
300
- >
301
- <svg viewBox="0 0 24 24"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
302
- </button>
303
-
304
- <!-- 链接 -->
305
- <button
306
- class="bubble-btn ${e?.isActive("link")?"is-active":""}"
307
- @click=${this._setLink}
308
- title="链接"
309
- >
310
- <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>
311
- </button>
312
-
313
- <!-- 图片 -->
314
- <button
315
- class="bubble-btn"
316
- @click=${this._triggerImageUpload}
317
- title="图片"
318
- >
319
- <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>
320
- </button>
321
-
322
- <div class="bubble-divider"></div>
323
-
324
- <!-- 列表 -->
325
- <button
326
- class="bubble-btn ${e?.isActive("bulletList")?"is-active":""}"
327
- @click=${this._toggleBulletList}
328
- title="无序列表"
329
- >
330
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
331
- <line x1="9" y1="6" x2="20" y2="6"/>
332
- <line x1="9" y1="12" x2="20" y2="12"/>
333
- <line x1="9" y1="18" x2="20" y2="18"/>
334
- <circle cx="4" cy="6" r="0.5" fill="currentColor" stroke="none"/>
335
- <circle cx="4" cy="12" r="0.5" fill="currentColor" stroke="none"/>
336
- <circle cx="4" cy="18" r="0.5" fill="currentColor" stroke="none"/>
337
- </svg>
338
- </button>
339
- <button
340
- class="bubble-btn ${e?.isActive("orderedList")?"is-active":""}"
341
- @click=${this._toggleOrderedList}
342
- title="有序列表"
343
- >
344
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
345
- <line x1="10" y1="6" x2="21" y2="6"/>
346
- <line x1="10" y1="12" x2="21" y2="12"/>
347
- <line x1="10" y1="18" x2="21" y2="18"/>
348
- <path d="M4 6h1v4"/>
349
- <path d="M4 10h2"/>
350
- <path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1.5"/>
351
- </svg>
352
- </button>
353
- <button
354
- class="bubble-btn ${e?.isActive("taskList")?"is-active":""}"
355
- @click=${this._toggleTaskList}
356
- title="待办列表"
357
- >
358
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
359
- <rect x="3" y="5" width="4" height="4" rx="1"/>
360
- <polyline points="4 7 5 8 6.5 6.5"/>
361
- <line x1="10" y1="7" x2="21" y2="7"/>
362
- <rect x="3" y="15" width="4" height="4" rx="1"/>
363
- <line x1="10" y1="17" x2="21" y2="17"/>
364
- </svg>
365
- </button>
366
-
367
- <!-- 引用 -->
368
- <button
369
- class="bubble-btn ${e?.isActive("blockquote")?"is-active":""}"
370
- @click=${this._toggleBlockquote}
371
- title="引用"
372
- >
373
- <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>
374
- </button>
375
-
376
- <div class="bubble-divider"></div>
377
-
378
- <!-- 表格下拉 -->
379
- <div
380
- class="bubble-dropdown ${this._tableDropdownOpen?"is-open":""}"
381
- @mouseenter=${()=>{this._tableDropdownOpen=!0,this._hoverRow=0,this._hoverCol=0}}
382
- @mouseleave=${()=>this._tableDropdownOpen=!1}
383
- >
384
- <button class="bubble-dropdown-btn" title="表格">
385
- <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>
386
- </button>
387
- <div class="bubble-dropdown-menu">
388
- <div class="table-grid-preview">
389
- ${this._renderTableGrid()}
390
- </div>
391
- <div class="table-size-hint">
392
- <span>${this._hoverRow>0?`${this._hoverRow} × ${this._hoverCol}`:`${this._tableRows} × ${this._tableCols}`}</span>
393
- </div>
394
- </div>
395
- </div>
192
+ ${this._renderTextToolbar(e)}
396
193
  </div>
397
194
  `}
398
195
 
399
196
  <div class="editor-content" data-empty-hint=${this._resolvedPlaceholder}></div>
400
197
 
401
- ${this._linkEditor.visible?L`
198
+ ${this._linkEditor.visible?$`
402
199
  <div
403
200
  class="link-editor"
404
201
  style="left: ${this._linkEditor.x}px; top: ${this._linkEditor.y}px;"
@@ -432,19 +229,19 @@ import{Node as e,mergeAttributes as t,Editor as i}from"@tiptap/core";import o fr
432
229
  <div class="link-editor__actions">
433
230
  <button class="link-editor__action primary" title="应用链接" @click=${this._applyLink}>应用</button>
434
231
  <button class="link-editor__action" title="取消链接编辑" @click=${this._closeLinkEditor}>取消</button>
435
- ${e?.isActive("link")||this._linkEditor.url?L`<button class="link-editor__action danger" title="移除链接" @click=${this._removeLink}>移除</button>`:""}
232
+ ${e?.isActive("link")||this._linkEditor.url?$`<button class="link-editor__action danger" title="移除链接" @click=${this._removeLink}>移除</button>`:""}
436
233
  </div>
437
234
  </div>
438
235
  `:""}
439
236
 
440
237
  <!-- Table Cell Toolbar -->
441
- ${this._tableCellToolbar.visible&&e?.isActive("table")?L`
238
+ ${this._tableCellToolbar.visible&&e?.isActive("table")?$`
442
239
  <div
443
240
  class="table-cell-toolbar"
444
241
  style="left: ${this._tableCellToolbar.x}px; top: ${this._tableCellToolbar.y}px;"
445
242
  @mousedown=${e=>e.preventDefault()}
446
243
  >
447
- ${0===this._tableCellToolbar.cellRow?L`
244
+ ${0===this._tableCellToolbar.cellRow?$`
448
245
  <button class="table-cell-toolbar-btn" title="上方添加行" @click=${this._addTableRowAbove}>
449
246
  <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>
450
247
  </button>
@@ -455,8 +252,8 @@ import{Node as e,mergeAttributes as t,Editor as i}from"@tiptap/core";import o fr
455
252
  <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>
456
253
  </button>
457
254
  `:""}
458
- ${0===this._tableCellToolbar.cellCol?L`
459
- ${0!==this._tableCellToolbar.cellRow?L`<div style="width:1px;height:20px;background:#e3e3e3;margin:0 4px;"></div>`:""}
255
+ ${0===this._tableCellToolbar.cellCol?$`
256
+ ${0!==this._tableCellToolbar.cellRow?$`<div style="width:1px;height:20px;background:#e3e3e3;margin:0 4px;"></div>`:""}
460
257
  <button class="table-cell-toolbar-btn" title="左侧添加列" @click=${this._addTableColumnLeft}>
461
258
  <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>
462
259
  </button>
@@ -467,7 +264,7 @@ import{Node as e,mergeAttributes as t,Editor as i}from"@tiptap/core";import o fr
467
264
  <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>
468
265
  </button>
469
266
  `:""}
470
- ${0===this._tableCellToolbar.cellRow&&0===this._tableCellToolbar.cellCol?L`
267
+ ${0===this._tableCellToolbar.cellRow&&0===this._tableCellToolbar.cellCol?$`
471
268
  <div style="width:1px;height:20px;background:#e3e3e3;margin:0 4px;"></div>
472
269
  <button class="table-cell-toolbar-btn danger" title="删除表格" @click=${this._deleteTable}>
473
270
  <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>
@@ -477,7 +274,7 @@ import{Node as e,mergeAttributes as t,Editor as i}from"@tiptap/core";import o fr
477
274
  `:""}
478
275
 
479
276
  <!-- Image Toolbar -->
480
- ${"slash"===this._toolbarModeValue&&this._imageToolbar.visible?L`
277
+ ${"slash"===this._toolbarModeValue&&this._imageToolbar.visible?$`
481
278
  <div
482
279
  class="image-toolbar"
483
280
  style="left: ${this._imageToolbar.x}px; top: ${this._imageToolbar.y}px;"
@@ -487,17 +284,17 @@ import{Node as e,mergeAttributes as t,Editor as i}from"@tiptap/core";import o fr
487
284
  </div>
488
285
  `:""}
489
286
  </div>
490
- `}_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(L`
287
+ `}_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($`
491
288
  <div
492
289
  class="table-cell ${r?"selected":""}"
493
290
  @click=${()=>{this._insertTableByClick(i,o),this._tableDropdownOpen=!1}}
494
291
  @mouseenter=${()=>{this._hoverRow=i,this._hoverCol=o}}
495
292
  @mouseleave=${()=>{this._hoverRow=0,this._hoverCol=0}}
496
293
  ></div>
497
- `)}return e}};F.styles=$`
294
+ `)}return e}};j.styles=M`
498
295
  :host {
499
296
  display: block;
500
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, sans-serif;
297
+ font-family: inherit;
501
298
  }
502
299
 
503
300
  .editor-wrapper {
@@ -789,17 +586,17 @@ import{Node as e,mergeAttributes as t,Editor as i}from"@tiptap/core";import o fr
789
586
 
790
587
  .ProseMirror img[data-align="left"] {
791
588
  display: block !important;
792
- margin: 0 auto 0 0 !important;
589
+ margin: 16px auto 16px 0 !important;
793
590
  }
794
591
 
795
592
  .ProseMirror img[data-align="center"] {
796
593
  display: block !important;
797
- margin: 0 auto !important;
594
+ margin: 16px auto !important;
798
595
  }
799
596
 
800
597
  .ProseMirror img[data-align="right"] {
801
598
  display: block !important;
802
- margin: 0 0 0 auto !important;
599
+ margin: 16px 0 16px auto !important;
803
600
  }
804
601
 
805
602
  .ProseMirror a {
@@ -810,6 +607,8 @@ import{Node as e,mergeAttributes as t,Editor as i}from"@tiptap/core";import o fr
810
607
 
811
608
  .ProseMirror img.ProseMirror-selectednode {
812
609
  outline: 2px solid var(--qxs-color-primary, #3D61E3);
610
+ outline-offset: 2px;
611
+ box-shadow: 0 0 0 4px rgba(61, 97, 227, 0.12);
813
612
  }
814
613
 
815
614
  /* Table styles */
@@ -1238,6 +1037,16 @@ import{Node as e,mergeAttributes as t,Editor as i}from"@tiptap/core";import o fr
1238
1037
  margin: 0 4px;
1239
1038
  }
1240
1039
 
1040
+ .image-control-label {
1041
+ display: inline-flex;
1042
+ align-items: center;
1043
+ padding: 0 4px;
1044
+ font-size: 12px;
1045
+ color: #909399;
1046
+ user-select: none;
1047
+ white-space: nowrap;
1048
+ }
1049
+
1241
1050
  /* Image More Menu */
1242
1051
  .image-more-menu {
1243
1052
  position: absolute;
@@ -1287,5 +1096,5 @@ import{Node as e,mergeAttributes as t,Editor as i}from"@tiptap/core";import o fr
1287
1096
  outline: 2px solid var(--qxs-color-primary, #3D61E3);
1288
1097
  outline-offset: 2px;
1289
1098
  }
1290
- `,E([I({type:String,attribute:"content"})],F.prototype,"content",2),E([I({type:String,attribute:"model-value"})],F.prototype,"model-value",2),E([I({type:String,attribute:"placeholder"})],F.prototype,"placeholder",2),E([I({type:String,attribute:"toolbar-mode"})],F.prototype,"toolbar-mode",2),E([I({type:String,attribute:"header-always-visible"})],F.prototype,"header-always-visible",2),E([I({type:String,attribute:"use-model"})],F.prototype,"use-model",2),E([I({type:String,attribute:"readonly"})],F.prototype,"readonly",2),E([I({type:String,attribute:"preview"})],F.prototype,"preview",2),E([I({type:String,attribute:"custom-styles"})],F.prototype,"custom-styles",2),E([I({type:Object,attribute:"upload-image"})],F.prototype,"upload-image",2),E([A()],F.prototype,"_editor",2),E([A()],F.prototype,"_pendingContent",2),E([A()],F.prototype,"_hoverRow",2),E([A()],F.prototype,"_hoverCol",2),E([A()],F.prototype,"_tableDropdownOpen",2),E([A()],F.prototype,"_tableCellToolbar",2),E([A()],F.prototype,"_imageToolbar",2),E([A()],F.prototype,"_linkEditor",2),E([A()],F.prototype,"_isEditorFocused",2),E([A()],F.prototype,"_selectedImage",2),F=E([S("qxs-blocksuite-editor")],F);export{F as QxsBlocksuiteEditor};
1099
+ `,q([L({type:String,attribute:"content"})],j.prototype,"content",2),q([L({type:String,attribute:"model-value"})],j.prototype,"model-value",2),q([L({type:String,attribute:"placeholder"})],j.prototype,"placeholder",2),q([L({type:String,attribute:"toolbar-mode"})],j.prototype,"toolbar-mode",2),q([L({attribute:"toolbar"})],j.prototype,"toolbar",2),q([L({type:String,attribute:"header-always-visible"})],j.prototype,"header-always-visible",2),q([L({type:String,attribute:"use-model"})],j.prototype,"use-model",2),q([L({type:String,attribute:"readonly"})],j.prototype,"readonly",2),q([L({type:String,attribute:"preview"})],j.prototype,"preview",2),q([L({type:String,attribute:"custom-styles"})],j.prototype,"custom-styles",2),q([L({type:Object,attribute:"upload-image"})],j.prototype,"upload-image",2),q([S()],j.prototype,"_editor",2),q([S()],j.prototype,"_hoverRow",2),q([S()],j.prototype,"_hoverCol",2),q([S()],j.prototype,"_tableDropdownOpen",2),q([S()],j.prototype,"_tableCellToolbar",2),q([S()],j.prototype,"_imageToolbar",2),q([S()],j.prototype,"_linkEditor",2),q([S()],j.prototype,"_isEditorFocused",2),q([S()],j.prototype,"_selectedImage",2),j=q([E("qxs-blocksuite-editor")],j);export{j as QxsBlocksuiteEditor};
1291
1100
  //# sourceMappingURL=blocksuite-editor.mjs.map