* update zeneditor, fixing ime issues.

This commit is contained in:
liwenrui
2024-05-16 12:15:49 +08:00
parent bf5f8bfd67
commit 92f29ae05c
4 changed files with 4 additions and 4 deletions
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
import{r as t,h as i}from"./p-7900c24a.js";import{P as e,a as s,E as n,t as o,p as h}from"./p-017438c7.js";class l{constructor({editor:t,element:i,view:e,tippyOptions:s={},shouldShow:n}){this.preventHide=!1,this.shouldShow=({view:t,state:i})=>{const{selection:e}=i,{$anchor:s,empty:n}=e,o=1===s.depth,h=s.parent.isTextblock&&!s.parent.type.spec.code&&!s.parent.textContent;return!!(t.hasFocus()&&n&&o&&h&&this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout((()=>this.update(this.editor.view)))},this.blurHandler=({event:t})=>{var i;this.preventHide?this.preventHide=!1:(null==t?void 0:t.relatedTarget)&&(null===(i=this.element.parentNode)||void 0===i?void 0:i.contains(t.relatedTarget))||this.hide()},this.tippyBlurHandler=t=>{this.blurHandler({event:t})},this.editor=t,this.element=i,this.view=e,n&&(this.shouldShow=n),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.tippyOptions=s,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:t}=this.editor.options;!this.tippy&&t.parentElement&&(this.tippy=o(t,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"right",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",this.tippyBlurHandler))}update(t,i){var e,s,n;const{state:o}=t,{doc:l,selection:r}=o,{from:c,to:d}=r;i&&i.doc.eq(l)&&i.selection.eq(r)||(this.createTooltip(),(null===(e=this.shouldShow)||void 0===e?void 0:e.call(this,{editor:this.editor,view:t,state:o,oldState:i}))?(null===(s=this.tippy)||void 0===s||s.setProps({getReferenceClientRect:(null===(n=this.tippyOptions)||void 0===n?void 0:n.getReferenceClientRect)||(()=>h(t,c,d))}),this.show()):this.hide())}show(){var t;null===(t=this.tippy)||void 0===t||t.show()}hide(){var t;null===(t=this.tippy)||void 0===t||t.hide()}destroy(){var t,i;(null===(t=this.tippy)||void 0===t?void 0:t.popper.firstChild)&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),null===(i=this.tippy)||void 0===i||i.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}const r=t=>new e({key:"string"==typeof t.pluginKey?new s(t.pluginKey):t.pluginKey,view:i=>new l({view:i,...t})});n.create({name:"floatingMenu",addOptions:()=>({element:null,tippyOptions:{},pluginKey:"floatingMenu",shouldShow:null}),addProseMirrorPlugins(){return this.options.element?[r({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,shouldShow:this.options.shouldShow})]:[]}});const c=class{constructor(i){t(this,i),this.menuProps=void 0,this.editor=void 0,this.element=void 0}componentDidLoad(){if(!Boolean(this.element)||this.editor.isDestroyed)return;const{pluginKey:t="floatingMenu",tippyOptions:i={},shouldShow:e=null}=this.menuProps,s=r({pluginKey:t,editor:this.editor,element:this.element,tippyOptions:Object.assign({placement:"left",getReferenceClientRect:()=>{const t=this.editor.view.state.selection.$anchor,i=t.pos-t.parentOffset;return h(this.editor.view,i,i)}},i),shouldShow:null!=e?e:({view:t,state:i})=>{const{selection:e}=i,{$anchor:s,empty:n}=e,o=1===s.depth;return!(!t.hasFocus()||!n||!o)}});this.editor.registerPlugin(s)}render(){return i("div",{key:"5f8300d192f4bca4595802d1e07096a62f415247",ref:t=>this.element=t,class:"floating-menu",style:{visibility:"hidden"}},[{icon:"ci-plus",title:"Add",action:()=>{}},{icon:"ci-more_vertical",title:"Click to tune",action:()=>{}}].map(((t,e)=>{const s=t,{isHidden:n,type:o}=s,h=function(t,i){var e={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&i.indexOf(s)<0&&(e[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(t);n<s.length;n++)i.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(e[s[n]]=t[s[n]])}return e}(s,["isHidden","type"]);if(!n||!n())return"divider"===o?i("div",{class:"divider",key:e}):i("zen-editor-menu-item",{itemProps:Object.assign({},h),key:e})})))}};export{c as zen_editor_floating_menu}
import{r as t,h as i}from"./p-7900c24a.js";import{P as e,a as s,E as n,t as o,p as h}from"./p-c7bbeb98.js";class l{constructor({editor:t,element:i,view:e,tippyOptions:s={},shouldShow:n}){this.preventHide=!1,this.shouldShow=({view:t,state:i})=>{const{selection:e}=i,{$anchor:s,empty:n}=e,o=1===s.depth,h=s.parent.isTextblock&&!s.parent.type.spec.code&&!s.parent.textContent;return!!(t.hasFocus()&&n&&o&&h&&this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout((()=>this.update(this.editor.view)))},this.blurHandler=({event:t})=>{var i;this.preventHide?this.preventHide=!1:(null==t?void 0:t.relatedTarget)&&(null===(i=this.element.parentNode)||void 0===i?void 0:i.contains(t.relatedTarget))||this.hide()},this.tippyBlurHandler=t=>{this.blurHandler({event:t})},this.editor=t,this.element=i,this.view=e,n&&(this.shouldShow=n),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.tippyOptions=s,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:t}=this.editor.options;!this.tippy&&t.parentElement&&(this.tippy=o(t,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"right",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",this.tippyBlurHandler))}update(t,i){var e,s,n;const{state:o}=t,{doc:l,selection:r}=o,{from:c,to:d}=r;i&&i.doc.eq(l)&&i.selection.eq(r)||(this.createTooltip(),(null===(e=this.shouldShow)||void 0===e?void 0:e.call(this,{editor:this.editor,view:t,state:o,oldState:i}))?(null===(s=this.tippy)||void 0===s||s.setProps({getReferenceClientRect:(null===(n=this.tippyOptions)||void 0===n?void 0:n.getReferenceClientRect)||(()=>h(t,c,d))}),this.show()):this.hide())}show(){var t;null===(t=this.tippy)||void 0===t||t.show()}hide(){var t;null===(t=this.tippy)||void 0===t||t.hide()}destroy(){var t,i;(null===(t=this.tippy)||void 0===t?void 0:t.popper.firstChild)&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),null===(i=this.tippy)||void 0===i||i.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}const r=t=>new e({key:"string"==typeof t.pluginKey?new s(t.pluginKey):t.pluginKey,view:i=>new l({view:i,...t})});n.create({name:"floatingMenu",addOptions:()=>({element:null,tippyOptions:{},pluginKey:"floatingMenu",shouldShow:null}),addProseMirrorPlugins(){return this.options.element?[r({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,shouldShow:this.options.shouldShow})]:[]}});const c=class{constructor(i){t(this,i),this.menuProps=void 0,this.editor=void 0,this.element=void 0}componentDidLoad(){if(!Boolean(this.element)||this.editor.isDestroyed)return;const{pluginKey:t="floatingMenu",tippyOptions:i={},shouldShow:e=null}=this.menuProps,s=r({pluginKey:t,editor:this.editor,element:this.element,tippyOptions:Object.assign({placement:"left",getReferenceClientRect:()=>{const t=this.editor.view.state.selection.$anchor,i=t.pos-t.parentOffset;return h(this.editor.view,i,i)}},i),shouldShow:null!=e?e:({view:t,state:i})=>{const{selection:e}=i,{$anchor:s,empty:n}=e,o=1===s.depth;return!(!t.hasFocus()||!n||!o)}});this.editor.registerPlugin(s)}render(){return i("div",{key:"5f8300d192f4bca4595802d1e07096a62f415247",ref:t=>this.element=t,class:"floating-menu",style:{visibility:"hidden"}},[{icon:"ci-plus",title:"Add",action:()=>{}},{icon:"ci-more_vertical",title:"Click to tune",action:()=>{}}].map(((t,e)=>{const s=t,{isHidden:n,type:o}=s,h=function(t,i){var e={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&i.indexOf(s)<0&&(e[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(t);n<s.length;n++)i.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(e[s[n]]=t[s[n]])}return e}(s,["isHidden","type"]);if(!n||!n())return"divider"===o?i("div",{class:"divider",key:e}):i("zen-editor-menu-item",{itemProps:Object.assign({},h),key:e})})))}};export{c as zen_editor_floating_menu}
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
import{p as e,b as o}from"./p-7900c24a.js";export{s as setNonce}from"./p-7900c24a.js";import{g as r}from"./p-90d6b5f8.js";(()=>{const o=import.meta.url,r={};return""!==o&&(r.resourcesUrl=new URL(".",o).href),e(r)})().then((async e=>(await r(),o([["p-6ff48369",[[65,"zen-editor",{name:[1],readonly:[1028],uploadUrl:[1,"upload-url"],placeholder:[1],fullscreenable:[4],resizable:[4],exposeEditor:[4,"expose-editor"],size:[1],hideUI:[4,"hide-ui"],hideMenubar:[4,"hide-menubar"],menubarMode:[1,"menubar-mode"],slashMenu:[4,"slash-menu"],bubbleMenu:[4,"bubble-menu"],preferHardBreak:[4,"prefer-hard-break"],neglectDefaultTextStyle:[4,"neglect-default-text-style"],locale:[1],css:[1],collaborative:[4],hocuspocus:[1],docName:[1,"doc-name"],username:[1],userColor:[1,"user-color"],value:[1025],editor:[32],isFullscreen:[32],rendered:[32],setHTML:[64],insertHTML:[64],getHTML:[64],getText:[64],focusEditor:[64],blurEditor:[64],setReadonly:[64]},null,{css:["onCSSChange"]}],[1,"zen-editor-core",{name:[1],readonly:[4],uploadUrl:[1,"upload-url"],placeholder:[1],initialContent:[1,"initial-content"],resizable:[4],exposeEditor:[4,"expose-editor"],size:[1],hideUI:[4,"hide-ui"],hideMenubar:[4,"hide-menubar"],menubarMode:[1,"menubar-mode"],extraMenubarItems:[1,"extra-menubar-items"],slashMenu:[4,"slash-menu"],bubbleMenu:[4,"bubble-menu"],preferHardBreak:[4,"prefer-hard-break"],neglectDefaultTextStyle:[4,"neglect-default-text-style"],locale:[1],styles:[16],collaborative:[4],hocuspocus:[1],docName:[1,"doc-name"],username:[1],userColor:[1,"user-color"],updateInputValue:[16],fullscreenable:[4],toggleFullscreen:[16],isFullscreen:[4,"is-fullscreen"],value:[1],editor:[32],forceUpdateCounter:[32],isMonaco:[32]},null,{locale:["onLocaleChanage"]}],[2,"zen-editor-bubble-menu",{menuProps:[16],editor:[16],disabled:[4],element:[32]}],[1,"zen-editor-menubar",{editor:[16],menubarMode:[2,"menubar-mode"],extraMenubarItems:[1,"extra-menubar-items"],forceUpdateCounter:[2,"force-update-counter"],states:[8],toggleMonaco:[16],toggleFullscreen:[16],styles:[16]}],[1,"zen-editor-slash-menu",{editor:[16],items:[1040],props:[16],currentSelectionIndex:[32]},null,{editor:["onEditorChange"],items:["onItemsChange"],props:["onPropsChange"]}],[0,"monaco-editor",{options:[8],initialValue:[1,"initial-value"],tiptapEditor:[16],updateInputValue:[16],setFocus:[64],getValue:[64]},null,{options:["onOptionsChange"]}],[1,"zen-editor-content",{editor:[16],styles:[16]},[[2,"click","handleClick"]]],[0,"zen-editor-menu-item",{itemProps:[8,"item-props"],menubarMode:[2,"menubar-mode"],styles:[16]}]]],["p-2cebaee6",[[0,"zen-editor-floating-menu",{menuProps:[16],editor:[16],element:[32]}]]],["p-45e30bc7",[[0,"zen-editor-footer",{editor:[16],forceUpdateCounter:[2,"force-update-counter"],toggleFullscreen:[16],showCharCount:[4,"show-char-count"]}]]]],e))));
import{p as e,b as o}from"./p-7900c24a.js";export{s as setNonce}from"./p-7900c24a.js";import{g as r}from"./p-90d6b5f8.js";(()=>{const o=import.meta.url,r={};return""!==o&&(r.resourcesUrl=new URL(".",o).href),e(r)})().then((async e=>(await r(),o([["p-1a9a7624",[[65,"zen-editor",{name:[1],readonly:[1028],uploadUrl:[1,"upload-url"],placeholder:[1],fullscreenable:[4],resizable:[4],exposeEditor:[4,"expose-editor"],size:[1],hideUI:[4,"hide-ui"],hideMenubar:[4,"hide-menubar"],menubarMode:[1,"menubar-mode"],slashMenu:[4,"slash-menu"],bubbleMenu:[4,"bubble-menu"],preferHardBreak:[4,"prefer-hard-break"],neglectDefaultTextStyle:[4,"neglect-default-text-style"],locale:[1],css:[1],collaborative:[4],hocuspocus:[1],docName:[1,"doc-name"],username:[1],userColor:[1,"user-color"],value:[1025],editor:[32],isFullscreen:[32],rendered:[32],setHTML:[64],insertHTML:[64],getHTML:[64],getText:[64],focusEditor:[64],blurEditor:[64],setReadonly:[64]},null,{css:["onCSSChange"]}],[1,"zen-editor-core",{name:[1],readonly:[4],uploadUrl:[1,"upload-url"],placeholder:[1],initialContent:[1,"initial-content"],resizable:[4],exposeEditor:[4,"expose-editor"],size:[1],hideUI:[4,"hide-ui"],hideMenubar:[4,"hide-menubar"],menubarMode:[1,"menubar-mode"],extraMenubarItems:[1,"extra-menubar-items"],slashMenu:[4,"slash-menu"],bubbleMenu:[4,"bubble-menu"],preferHardBreak:[4,"prefer-hard-break"],neglectDefaultTextStyle:[4,"neglect-default-text-style"],locale:[1],styles:[16],collaborative:[4],hocuspocus:[1],docName:[1,"doc-name"],username:[1],userColor:[1,"user-color"],updateInputValue:[16],fullscreenable:[4],toggleFullscreen:[16],isFullscreen:[4,"is-fullscreen"],value:[1],editor:[32],forceUpdateCounter:[32],isMonaco:[32]},null,{locale:["onLocaleChanage"]}],[2,"zen-editor-bubble-menu",{menuProps:[16],editor:[16],disabled:[4],element:[32]}],[1,"zen-editor-menubar",{editor:[16],menubarMode:[2,"menubar-mode"],extraMenubarItems:[1,"extra-menubar-items"],forceUpdateCounter:[2,"force-update-counter"],states:[8],toggleMonaco:[16],toggleFullscreen:[16],styles:[16]}],[1,"zen-editor-slash-menu",{editor:[16],items:[1040],props:[16],currentSelectionIndex:[32]},null,{editor:["onEditorChange"],items:["onItemsChange"],props:["onPropsChange"]}],[0,"monaco-editor",{options:[8],initialValue:[1,"initial-value"],tiptapEditor:[16],updateInputValue:[16],setFocus:[64],getValue:[64]},null,{options:["onOptionsChange"]}],[1,"zen-editor-content",{editor:[16],styles:[16]},[[2,"click","handleClick"]]],[0,"zen-editor-menu-item",{itemProps:[8,"item-props"],menubarMode:[2,"menubar-mode"],styles:[16]}]]],["p-8daea7c4",[[0,"zen-editor-floating-menu",{menuProps:[16],editor:[16],element:[32]}]]],["p-45e30bc7",[[0,"zen-editor-footer",{editor:[16],forceUpdateCounter:[2,"force-update-counter"],toggleFullscreen:[16],showCharCount:[4,"show-char-count"]}]]]],e))));