@nocobase/plugin-field-markdown-vditor 1.4.7 → 1.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +4 -4
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -265,4 +265,4 @@ window.addEventListener("message", (e) => {
|
|
|
265
265
|
`);v--)if(o.textContent.charAt(v)!==" "&&o.textContent.charAt(v)!==" "){c=!1;break}a===0&&(c=!1);var g=!0;for(v=a-1;v<o.textContent.length;v++)if(o.textContent.charAt(v)!==" "&&o.textContent.charAt(v)!==`
|
|
266
266
|
`){g=!1;break}var h=(0,_.W)(getSelection().getRangeAt(0).startContainer);h&&h.textContent===""&&(Fe(t),h.remove()),c&&o.getAttribute("data-type")!=="code-block"||g||Yt(o.innerHTML)||Xt(o.innerHTML)&&o.previousElementSibling?typeof t.options.input=="function"&&t.options.input(m(t)):(i.inputType==="insertParagraph"&&n.element.innerHTML==="<p><br></p><p><br></p>"&&o.previousElementSibling.remove(),Mt(t,r,i))}}}}),this.element.addEventListener("click",function(i){if(i.target.tagName==="INPUT"){var r=i.target;return r.checked?r.setAttribute("checked","checked"):r.removeAttribute("checked"),n.preventInput=!0,void Se(t)}if(i.target.tagName!=="IMG"||i.target.parentElement.classList.contains("vditor-wysiwyg__preview")){var o=(0,p.lG)(i.target,"A");if(o)return t.options.link.click?t.options.link.click(o):t.options.link.isOpen&&window.open(o.getAttribute("href")),void i.preventDefault();var a=(0,x.zh)(t);if(i.target.isEqualNode(n.element)&&n.element.lastElementChild&&a.collapsed){var c=n.element.lastElementChild.getBoundingClientRect();i.y>c.top+c.height&&(n.element.lastElementChild.tagName==="P"&&n.element.lastElementChild.textContent.trim().replace(b.g.ZWSP,"")===""?(a.selectNodeContents(n.element.lastElementChild),a.collapse(!1)):(n.element.insertAdjacentHTML("beforeend",'<p data-block="0">'+b.g.ZWSP+"<wbr></p>"),(0,x.ib)(n.element,a)))}nt(t);var v=(0,p.fb)(i.target,"vditor-wysiwyg__preview");v||(v=(0,p.fb)((0,x.zh)(t).startContainer,"vditor-wysiwyg__preview")),v&&vt(v,t),Lt(i,t)}else i.target.getAttribute("data-type")==="link-ref"?pn(t,i.target):function(g,h){var A=g.target;h.wysiwyg.popover.innerHTML="";var I=function(){A.setAttribute("src",T.value),A.setAttribute("alt",B.value),A.setAttribute("title",V.value),typeof h.options.input=="function"&&h.options.input(m(h))},W=document.createElement("span");W.setAttribute("aria-label",window.VditorI18n.imageURL),W.className="vditor-tooltipped vditor-tooltipped__n";var T=document.createElement("input");W.appendChild(T),T.className="vditor-input",T.setAttribute("placeholder",window.VditorI18n.imageURL),T.value=A.getAttribute("src")||"",T.oninput=function(){I()},T.onkeydown=function(P){Re(h,P)};var R=document.createElement("span");R.setAttribute("aria-label",window.VditorI18n.alternateText),R.className="vditor-tooltipped vditor-tooltipped__n";var B=document.createElement("input");R.appendChild(B),B.className="vditor-input",B.setAttribute("placeholder",window.VditorI18n.alternateText),B.style.width="52px",B.value=A.getAttribute("alt")||"",B.oninput=function(){I()},B.onkeydown=function(P){Re(h,P)};var O=document.createElement("span");O.setAttribute("aria-label",window.VditorI18n.title),O.className="vditor-tooltipped vditor-tooltipped__n";var V=document.createElement("input");O.appendChild(V),V.className="vditor-input",V.setAttribute("placeholder",window.VditorI18n.title),V.value=A.getAttribute("title")||"",V.oninput=function(){I()},V.onkeydown=function(P){Re(h,P)},Ve(A,h),h.wysiwyg.popover.insertAdjacentElement("beforeend",W),h.wysiwyg.popover.insertAdjacentElement("beforeend",R),h.wysiwyg.popover.insertAdjacentElement("beforeend",O),Be(h,A)}(i,t)}),this.element.addEventListener("keyup",function(i){if(!i.isComposing&&!(0,l.yl)(i)){i.key==="Enter"&&He(t),i.key!=="Backspace"&&i.key!=="Delete"||t.wysiwyg.element.innerHTML===""||t.wysiwyg.element.childNodes.length!==1||!t.wysiwyg.element.firstElementChild||t.wysiwyg.element.firstElementChild.tagName!=="P"||t.wysiwyg.element.firstElementChild.childElementCount!==0||t.wysiwyg.element.textContent!==""&&t.wysiwyg.element.textContent!==`
|
|
267
267
|
`||(t.wysiwyg.element.innerHTML="");var r=(0,x.zh)(t);if(i.key==="Backspace"&&(0,l.vU)()&&r.startContainer.textContent===`
|
|
268
|
-
`&&r.startOffset===1&&(r.startContainer.textContent=""),un(t,r),nt(t),i.key==="ArrowDown"||i.key==="ArrowRight"||i.key==="Backspace"||i.key==="ArrowLeft"||i.key==="ArrowUp"){i.key!=="ArrowLeft"&&i.key!=="ArrowRight"||t.hint.render(t);var o=(0,p.fb)(r.startContainer,"vditor-wysiwyg__preview");if(!o&&r.startContainer.nodeType!==3&&r.startOffset>0&&(c=r.startContainer).classList.contains("vditor-wysiwyg__block")&&(o=c.lastElementChild),o)if(o.previousElementSibling.style.display!=="none"){var a=o.previousElementSibling;if(a.tagName==="PRE"&&(a=a.firstElementChild),i.key==="ArrowDown"||i.key==="ArrowRight"){var c,v=function(h){for(var A=h;A&&!A.nextSibling;)A=A.parentElement;return A.nextSibling}(c=o.parentElement);if(v&&v.nodeType!==3){var g=v.querySelector(".vditor-wysiwyg__preview");if(g)return void vt(g,t)}if(v.nodeType===3){for(;v.textContent.length===0&&v.nextSibling;)v=v.nextSibling;r.setStart(v,1)}else r.setStart(v.firstChild,0)}else r.selectNodeContents(a),r.collapse(!1)}else i.key==="ArrowDown"||i.key==="ArrowRight"?vt(o,t):vt(o,t,!1)}}})},e}(),Hi=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var o in r)r.hasOwnProperty(o)&&(i[o]=r[o])},e(t,n)};return function(t,n){function i(){this.constructor=t}e(t,n),t.prototype=n===null?Object.create(n):(i.prototype=n.prototype,new i)}}();const Ni=function(e){function t(n,i){var r=e.call(this)||this;if(r.version=b.H,typeof n=="string"){if(i?i.cache?i.cache.id||(i.cache.id="vditor"+n):i.cache={id:"vditor"+n}:i={cache:{id:"vditor"+n}},!document.getElementById(n))return r.showErrorTip("Failed to get element by id: "+n),r;n=document.getElementById(n)}var o=new Ai(i).merge();if(o.i18n)window.VditorI18n=o.i18n,r.init(n,o);else{if(!["en_US","fr_FR","pt_BR","ja_JP","ko_KR","ru_RU","sv_SE","zh_CN","zh_TW"].includes(o.lang))throw new Error("options.lang error, see https://ld246.com/article/1549638745630#options");var a="vditorI18nScript",c=a+o.lang;document.querySelectorAll('head script[id^="vditorI18nScript"]').forEach(function(v){v.id!==c&&document.head.removeChild(v)}),(0,s.G)(o.cdn+"/dist/js/i18n/"+o.lang+".js",c).then(function(){r.init(n,o)}).catch(function(v){r.showErrorTip("GET "+o.cdn+"/dist/js/i18n/"+o.lang+".js net::ERR_ABORTED 404 (Not Found)")})}return r}return Hi(t,e),t.prototype.showErrorTip=function(n){var i=new Vn;document.body.appendChild(i.element),i.show(n,0)},t.prototype.setTheme=function(n,i,r,o){this.vditor.options.theme=n,ve(this.vditor),i&&(this.vditor.options.preview.theme.current=i,(0,Ie.Z)(i,o||this.vditor.options.preview.theme.path)),r&&(this.vditor.options.preview.hljs.style=r,(0,Un.Y)(r,this.vditor.options.cdn))},t.prototype.getValue=function(){return m(this.vditor)},t.prototype.getCurrentMode=function(){return this.vditor.currentMode},t.prototype.focus=function(){this.vditor.currentMode==="sv"?this.vditor.sv.element.focus():this.vditor.currentMode==="wysiwyg"?this.vditor.wysiwyg.element.focus():this.vditor.currentMode==="ir"&&this.vditor.ir.element.focus()},t.prototype.blur=function(){this.vditor.currentMode==="sv"?this.vditor.sv.element.blur():this.vditor.currentMode==="wysiwyg"?this.vditor.wysiwyg.element.blur():this.vditor.currentMode==="ir"&&this.vditor.ir.element.blur()},t.prototype.disabled=function(){y(this.vditor,["subToolbar","hint","popover"]),L(this.vditor.toolbar.elements,b.g.EDIT_TOOLBARS.concat(["undo","redo","fullscreen","edit-mode"])),this.vditor[this.vditor.currentMode].element.setAttribute("contenteditable","false")},t.prototype.enable=function(){E(this.vditor.toolbar.elements,b.g.EDIT_TOOLBARS.concat(["undo","redo","fullscreen","edit-mode"])),this.vditor.undo.resetIcon(this.vditor),this.vditor[this.vditor.currentMode].element.setAttribute("contenteditable","true")},t.prototype.getSelection=function(){return this.vditor.currentMode==="wysiwyg"?yt(this.vditor.wysiwyg.element):this.vditor.currentMode==="sv"?yt(this.vditor.sv.element):this.vditor.currentMode==="ir"?yt(this.vditor.ir.element):void 0},t.prototype.renderPreview=function(n){this.vditor.preview.render(this.vditor,n)},t.prototype.getCursorPosition=function(){return(0,x.Ny)(this.vditor[this.vditor.currentMode].element)},t.prototype.isUploading=function(){return this.vditor.upload.isUploading},t.prototype.clearCache=function(){localStorage.removeItem(this.vditor.options.cache.id)},t.prototype.disabledCache=function(){this.vditor.options.cache.enable=!1},t.prototype.enableCache=function(){if(!this.vditor.options.cache.id)throw new Error("need options.cache.id, see https://ld246.com/article/1549638745630#options");this.vditor.options.cache.enable=!0},t.prototype.html2md=function(n){return this.vditor.lute.HTML2Md(n)},t.prototype.exportJSON=function(n){return this.vditor.lute.RenderJSON(n)},t.prototype.getHTML=function(){return qn(this.vditor)},t.prototype.tip=function(n,i){this.vditor.tip.show(n,i)},t.prototype.setPreviewMode=function(n){$t(n,this.vditor)},t.prototype.deleteValue=function(){window.getSelection().isCollapsed||document.execCommand("delete",!1)},t.prototype.updateValue=function(n){document.execCommand("insertHTML",!1,n)},t.prototype.insertValue=function(n,i){i===void 0&&(i=!0);var r=(0,x.zh)(this.vditor);r.collapse(!0);var o=document.createElement("template");o.innerHTML=n,r.insertNode(o.content.cloneNode(!0)),r.collapse(!1),this.vditor.currentMode==="sv"?(this.vditor.sv.preventInput=!0,i&&oe(this.vditor)):this.vditor.currentMode==="wysiwyg"?i&&Mt(this.vditor,getSelection().getRangeAt(0)):this.vditor.currentMode==="ir"&&(this.vditor.ir.preventInput=!0,i&&Ee(this.vditor,getSelection().getRangeAt(0),!0))},t.prototype.setValue=function(n,i){var r=this;i===void 0&&(i=!1),this.vditor.currentMode==="sv"?(this.vditor.sv.element.innerHTML="<div data-block='0'>"+this.vditor.lute.SpinVditorSVDOM(n)+"</div>",Oe(this.vditor,{enableAddUndoStack:!0,enableHint:!1,enableInput:!1})):this.vditor.currentMode==="wysiwyg"?mn(this.vditor,n,{enableAddUndoStack:!0,enableHint:!1,enableInput:!1}):(this.vditor.ir.element.innerHTML=this.vditor.lute.Md2VditorIRDOM(n),this.vditor.ir.element.querySelectorAll(".vditor-ir__preview[data-render='2']").forEach(function(o){xe(o,r.vditor)}),Xe(this.vditor,{enableAddUndoStack:!0,enableHint:!1,enableInput:!1})),this.vditor.outline.render(this.vditor),n||(y(this.vditor,["emoji","headings","submenu","hint"]),this.vditor.wysiwyg.popover&&(this.vditor.wysiwyg.popover.style.display="none"),this.clearCache()),i&&this.clearStack()},t.prototype.clearStack=function(){this.vditor.undo.clearStack(this.vditor),this.vditor.undo.addToUndoStack(this.vditor)},t.prototype.destroy=function(){this.vditor.element.innerHTML=this.vditor.originalInnerHTML,this.vditor.element.classList.remove("vditor"),this.vditor.element.removeAttribute("style");var n=document.getElementById("vditorIconScript");n&&n.remove(),this.clearCache(),Je(),this.vditor.wysiwyg.unbindListener()},t.prototype.getCommentIds=function(){return this.vditor.currentMode!=="wysiwyg"?[]:this.vditor.wysiwyg.getComments(this.vditor,!0)},t.prototype.hlCommentIds=function(n){if(this.vditor.currentMode==="wysiwyg"){var i=function(r){r.classList.remove("vditor-comment--hover"),n.forEach(function(o){r.getAttribute("data-cmtids").indexOf(o)>-1&&r.classList.add("vditor-comment--hover")})};this.vditor.wysiwyg.element.querySelectorAll(".vditor-comment").forEach(function(r){i(r)}),this.vditor.preview.element.style.display!=="none"&&this.vditor.preview.element.querySelectorAll(".vditor-comment").forEach(function(r){i(r)})}},t.prototype.unHlCommentIds=function(n){if(this.vditor.currentMode==="wysiwyg"){var i=function(r){n.forEach(function(o){r.getAttribute("data-cmtids").indexOf(o)>-1&&r.classList.remove("vditor-comment--hover")})};this.vditor.wysiwyg.element.querySelectorAll(".vditor-comment").forEach(function(r){i(r)}),this.vditor.preview.element.style.display!=="none"&&this.vditor.preview.element.querySelectorAll(".vditor-comment").forEach(function(r){i(r)})}},t.prototype.removeCommentIds=function(n){var i=this;if(this.vditor.currentMode==="wysiwyg"){var r=function(o,a){var c=o.getAttribute("data-cmtids").split(" ");c.find(function(v,g){if(v===a)return c.splice(g,1),!0}),c.length===0?(o.outerHTML=o.innerHTML,(0,x.zh)(i.vditor).collapse(!0)):o.setAttribute("data-cmtids",c.join(" "))};n.forEach(function(o){i.vditor.wysiwyg.element.querySelectorAll(".vditor-comment").forEach(function(a){r(a,o)}),i.vditor.preview.element.style.display!=="none"&&i.vditor.preview.element.querySelectorAll(".vditor-comment").forEach(function(a){r(a,o)})}),Se(this.vditor,{enableAddUndoStack:!0,enableHint:!1,enableInput:!1})}},t.prototype.init=function(n,i){var r=this;this.vditor={currentMode:i.mode,element:n,hint:new Tr(i.hint.extend),lute:void 0,options:i,originalInnerHTML:n.innerHTML,outline:new xr(window.VditorI18n.outline),tip:new Vn},this.vditor.sv=new Nr(this.vditor),this.vditor.undo=new Mi,this.vditor.wysiwyg=new _i(this.vditor),this.vditor.ir=new Cr(this.vditor),this.vditor.toolbar=new Ti(this.vditor),i.resize.enable&&(this.vditor.resize=new Hr(this.vditor)),this.vditor.toolbar.elements.devtools&&(this.vditor.devtools=new w),(i.upload.url||i.upload.handler)&&(this.vditor.upload=new vr),(0,s.G)(i._lutePath||i.cdn+"/dist/js/lute/lute.min.js","vditorLuteScript").then(function(){r.vditor.lute=(0,Mr.X)({autoSpace:r.vditor.options.preview.markdown.autoSpace,gfmAutoLink:r.vditor.options.preview.markdown.gfmAutoLink,codeBlockPreview:r.vditor.options.preview.markdown.codeBlockPreview,emojiSite:r.vditor.options.hint.emojiPath,emojis:r.vditor.options.hint.emoji,fixTermTypo:r.vditor.options.preview.markdown.fixTermTypo,footnotes:r.vditor.options.preview.markdown.footnotes,headingAnchor:!1,inlineMathDigit:r.vditor.options.preview.math.inlineDigit,linkBase:r.vditor.options.preview.markdown.linkBase,linkPrefix:r.vditor.options.preview.markdown.linkPrefix,listStyle:r.vditor.options.preview.markdown.listStyle,mark:r.vditor.options.preview.markdown.mark,mathBlockPreview:r.vditor.options.preview.markdown.mathBlockPreview,paragraphBeginningSpace:r.vditor.options.preview.markdown.paragraphBeginningSpace,sanitize:r.vditor.options.preview.markdown.sanitize,toc:r.vditor.options.preview.markdown.toc}),r.vditor.preview=new _r(r.vditor),function(o){o.element.innerHTML="",o.element.classList.add("vditor"),o.options.rtl&&o.element.setAttribute("dir","rtl"),ve(o),(0,Ie.Z)(o.options.preview.theme.current,o.options.preview.theme.path),typeof o.options.height=="number"?o.element.style.height=o.options.height+"px":o.element.style.height=o.options.height,typeof o.options.minHeight=="number"&&(o.element.style.minHeight=o.options.minHeight+"px"),typeof o.options.width=="number"?o.element.style.width=o.options.width+"px":o.element.style.width=o.options.width,o.element.appendChild(o.toolbar.element);var a=document.createElement("div");if(a.className="vditor-content",o.options.outline.position==="left"&&a.appendChild(o.outline.element),a.appendChild(o.wysiwyg.element.parentElement),a.appendChild(o.sv.element),a.appendChild(o.ir.element.parentElement),a.appendChild(o.preview.element),o.toolbar.elements.devtools&&a.appendChild(o.devtools.element),o.options.outline.position==="right"&&(o.outline.element.classList.add("vditor-outline--right"),a.appendChild(o.outline.element)),o.upload&&a.appendChild(o.upload.element),o.options.resize.enable&&a.appendChild(o.resize.element),a.appendChild(o.hint.element),a.appendChild(o.tip.element),o.element.appendChild(a),a.addEventListener("click",function(){y(o,["subToolbar"])}),o.toolbar.elements.export&&o.element.insertAdjacentHTML("beforeend",'<iframe id="vditorExportIframe" style="width: 100%;height: 0;border: 0"></iframe>'),rt(o,o.options.mode,sr(o)),document.execCommand("DefaultParagraphSeparator",!1,"p"),navigator.userAgent.indexOf("iPhone")>-1&&window.visualViewport!==void 0){var c=!1,v=function(g){c||(c=!0,requestAnimationFrame(function(){c=!1;var h=o.toolbar.element;h.style.transform="none",h.getBoundingClientRect().top<0&&(h.style.transform="translate(0, "+-h.getBoundingClientRect().top+"px)")}))};window.visualViewport.addEventListener("scroll",v),window.visualViewport.addEventListener("resize",v)}}(r.vditor),i.after&&i.after(),i.icon&&(0,s.J)(i.cdn+"/dist/js/icons/"+i.icon+".js","vditorIconScript")})},t}(M.default)})(),je=je.default})())})(ot);var Yn=ot.exports;const St=Ze(Yn),Rt=()=>de.usePlugin(Pt).getCDN(),on=de.genStyleHook("nb-field-markdown-vditor",ae=>{const{componentCls:ye}=ae;return{[ye]:{".vditor-reset":{fontSize:`${ae.fontSize}px !important`},".vditor":{borderRadius:8},".vditor .vditor-content":{borderRadius:"0 0 8px 8px",overflow:"hidden"},".vditor .vditor-toolbar":{paddingLeft:" 16px !important",borderRadius:"8px 8px 0 0"},".vditor .vditor-content .vditor-ir .vditor-reset":{paddingLeft:" 16px !important"}}}});function Qn(ae){const ye=ae;let pe=document.createElement("div");pe.innerHTML=ye;const ce=pe.innerText;return pe=null,(ce==null?void 0:ce.replace(/[\n\r]/g,""))||""}const $n=ae=>{if(ae){const ye=document.createRange();return ye.selectNodeContents(ae),ye.getBoundingClientRect().width}};function an(ae){var J;const ye=Ae.useRef(null),{wrapSSR:pe,componentCls:ce,hashId:ne}=on(),je=Rt();return Ae.useEffect(()=>{var M;St.preview(ye.current,(M=ae.value)!=null?M:"",{mode:"light",cdn:je})},[ae.value]),pe(Ke.jsx("div",{className:`${ne} ${ce}`,children:Ke.jsx("div",{ref:ye,style:rn({border:"none"},(J=ae==null?void 0:ae.style)!=null?J:{})})}))}const er=de.withDynamicSchemaProps(ae=>{var l;const ye=Me.useField(),pe=(l=ae.value)!=null?l:ye.value,ce=Rt(),ne=Ae.useRef(),[je,J]=Ae.useState(!1),[M,b]=Ae.useState(!1),[d,m]=Ae.useState(""),s=Ae.useRef();Ae.useEffect(()=>{var u;!ae.value||!ye.value||(ae.ellipsis?St.md2html(ae.value,{mode:"light",cdn:ce}).then(f=>{m(Qn(f))}).catch(()=>m("")):St.preview(ne.current,(u=ae.value)!=null?u:ye.value,{mode:"light",cdn:ce}))},[ae.value,ae.ellipsis,ye.value]);const w=Ae.useCallback(()=>{var E;if(!s.current)return!1;const u=$n(s.current),f=(E=s.current)==null?void 0:E.offsetWidth;return u>f},[s]);return ae.ellipsis?Ke.jsx(kt.Popover,{open:je,onOpenChange:u=>{J(M&&u)},content:Ke.jsx(an,{value:pe,style:{maxWidth:500,maxHeight:400,overflowY:"auto"}}),children:Ke.jsx("div",{ref:s,style:{overflow:"hidden",overflowWrap:"break-word",textOverflow:"ellipsis",whiteSpace:"nowrap",wordBreak:"break-all"},onMouseEnter:u=>{const f=u.target;w()&&b(f.scrollWidth>=f.clientWidth)},children:d})}):Ke.jsx(an,{value:pe})}),tr="field-markdown-vditor";function me(ae){return jt.tval(ae,{ns:tr})}const{defaultProps:nr,operators:rr}=de.interfacesProperties,ln=["headings","bold","italic","strike","link","list","ordered-list","check","quote","line","code","inline-code","upload","fullscreen"];class ir extends de.CollectionFieldInterface{constructor(){super(...arguments);We(this,"name","vditor");We(this,"type","object");We(this,"group","media");We(this,"order",1);We(this,"title",me("Vditor"));We(this,"sortable",!0);We(this,"default",{type:"text",length:"long",uiSchema:{type:"string","x-component":"MarkdownVditor"}});We(this,"availableTypes",["text","json","string"]);We(this,"properties",Xn(rn({},nr),{"uiSchema.x-component-props.fileCollection":{type:"string",title:me("File collection"),"x-component":"CollectionSelect","x-component-props":{filter:pe=>{var ce;return((ce=pe==null?void 0:pe.options)==null?void 0:ce.template)==="file"}},"x-decorator":"FormItem",default:"","x-reactions":{fulfill:{schema:{description:me("Used to store files uploaded in the Markdown editor")}}}},"uiSchema.x-component-props.toolbar":{type:"array",title:me("Toolbar"),"x-component":"Select","x-component-props":{mode:"multiple"},"x-decorator":"FormItem",default:ln,enum:[{value:"emoji",label:me("Emoji")},{value:"headings",label:me("Headings")},{value:"bold",label:me("Bold")},{value:"italic",label:me("Italic")},{value:"strike",label:me("Strike")},{value:"line",label:me("Line")},{value:"quote",label:me("Quote")},{value:"list",label:me("List")},{value:"ordered-list",label:me("OrderedList")},{value:"check",label:me("Check")},{value:"outdent",label:me("Outdent")},{value:"indent",label:me("Indent")},{value:"code",label:me("Code")},{value:"inline-code",label:me("InlineCode")},{value:"insert-after",label:me("InsertAfter")},{value:"insert-before",label:me("InsertBefore")},{value:"undo",label:me("Undo")},{value:"redo",label:me("Redo")},{value:"upload",label:me("Upload")},{value:"link",label:me("Link")},{value:"record",label:me("Record")},{value:"table",label:me("Table")},{value:"edit-mode",label:me("EditMode")},{value:"both",label:me("Both")},{value:"preview",label:me("Preview")},{value:"fullscreen",label:me("Fullscreen")},{value:"outline",label:me("Outline")}]}}));We(this,"filterable",{operators:rr.bigField});We(this,"titleUsable",!0)}schemaInitialize(pe,{block:ce}){["Table","Kanban"].includes(ce)&&(pe["x-component-props"]=pe["x-component-props"]||{},pe["x-component-props"].ellipsis=!0)}}const or=["en_US","fr_FR","pt_BR","ja_JP","ko_KR","ru_RU","sv_SE","zh_CN","zh_TW"],ar=de.withDynamicSchemaProps(ae=>{const{disabled:ye,onChange:pe,value:ce,fileCollection:ne,toolbar:je}=ae,[J,M]=Ae.useState(!1),b=Ae.useRef(),d=Ae.useRef(!1),m=Ae.useRef(null),s=Ae.useRef(null),w=de.useApp(),l=de.useAPIClient(),u=Rt(),{wrapSSR:f,hashId:E,componentCls:L}=on(),S=l.auth.locale,C=Ae.useMemo(()=>{const y=S.replace(/-/g,"_");return or.includes(y)?y:"en_US"},[S]);return Ae.useEffect(()=>{if(!m.current)return;const y=ne||"attachments",k=je!=null?je:ln,p=new St(m.current,{value:ce!=null?ce:"",lang:C,cache:{enable:!1},undoDelay:0,preview:{math:{engine:"KaTeX"}},toolbar:k,fullscreen:{index:1200},cdn:u,minHeight:200,after:()=>{b.current=p,M(!0),p.setValue(ce!=null?ce:""),ye?p.disabled():p.enable()},input(_){pe(_)},upload:{url:w.getApiUrl(`${y}:create`),headers:l.getHeaders(),multiple:!1,fieldName:"file",max:1024*1024*1024,format(_,N){const q=JSON.parse(N),D={msg:"",code:0,data:{errFiles:[],succMap:{[q.data.filename]:q.data.url}}};return JSON.stringify(D)}}});return()=>{var _;(_=b.current)==null||_.destroy(),b.current=void 0}},[ne,je==null?void 0:je.join(",")]),Ae.useEffect(()=>{var y;if(J&&b.current){const k=b.current;if(ce!==k.getValue()){k.setValue(ce!=null?ce:"");const p=(y=m.current)==null?void 0:y.querySelector("div.vditor-content > div.vditor-ir > pre");if(p){const _=document.createRange(),N=window.getSelection();N&&(_.selectNodeContents(p),_.collapse(!1),N.removeAllRanges(),N.addRange(_))}}}},[ce,J]),Ae.useEffect(()=>{J&&b.current&&(ye?b.current.disabled():b.current.enable())},[ye,J]),Ae.useLayoutEffect(()=>{if(!m.current)return;const y=new ResizeObserver(k=>{var p;for(const _ of k){const N=_.target;N.className.includes("vditor--fullscreen")?(document.body.appendChild(N),d.current=!0):d.current&&((p=s.current)==null||p.appendChild(N),d.current=!1)}});return y.observe(m.current),()=>{y.unobserve(m.current)}},[]),f(Ke.jsx("div",{ref:s,className:`${E} ${L}`,children:Ke.jsx("div",{id:E,ref:m})}))}),lr=de.withDynamicSchemaProps(Me.connect(ar,Me.mapReadPretty(er)));class Pt extends de.Plugin{afterAdd(){return It(this,null,function*(){})}beforeLoad(){return It(this,null,function*(){})}load(){return It(this,null,function*(){this.app.addComponents({MarkdownVditor:lr}),this.initVditorDependency(),this.app.dataSourceManager.addFieldInterfaces([ir])})}getCDN(){return this.app.getPublicPath()+"static/plugins/@nocobase/plugin-field-markdown-vditor/dist/client/vditor"}initVditorDependency(){const ye=this.getCDN();try{const pe="plugin-field-markdown-vditor-dep",ce={[`${pe}.katex`]:`${ye}/dist/js/katex/katex.min.js?v=0.16.9`,[`${pe}.ABCJS`]:`${ye}/dist/js/abcjs/abcjs_basic.min`,[`${pe}.plantumlEncoder`]:`${ye}/dist/js/plantuml/plantuml-encoder.min`,[`${pe}.echarts`]:`${ye}/dist/js/echarts/echarts.min`,[`${pe}.flowchart`]:`${ye}/dist/js/flowchart.js/flowchart.min`,[`${pe}.Viz`]:`${ye}/dist/js/graphviz/viz`,[`${pe}.mermaid`]:`${ye}/dist/js/mermaid/mermaid.min`};this.app.requirejs.require.config({waitSeconds:120,paths:ce}),Object.keys(ce).forEach(ne=>{this.app.requirejs.require([ne],je=>{window[ne.split(".")[1]]=je})})}catch(pe){console.log("initVditorDependency failed",pe)}}}be.PluginFieldMarkdownVditorClient=Pt,be.default=Pt,Object.defineProperties(be,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
268
|
+
`&&r.startOffset===1&&(r.startContainer.textContent=""),un(t,r),nt(t),i.key==="ArrowDown"||i.key==="ArrowRight"||i.key==="Backspace"||i.key==="ArrowLeft"||i.key==="ArrowUp"){i.key!=="ArrowLeft"&&i.key!=="ArrowRight"||t.hint.render(t);var o=(0,p.fb)(r.startContainer,"vditor-wysiwyg__preview");if(!o&&r.startContainer.nodeType!==3&&r.startOffset>0&&(c=r.startContainer).classList.contains("vditor-wysiwyg__block")&&(o=c.lastElementChild),o)if(o.previousElementSibling.style.display!=="none"){var a=o.previousElementSibling;if(a.tagName==="PRE"&&(a=a.firstElementChild),i.key==="ArrowDown"||i.key==="ArrowRight"){var c,v=function(h){for(var A=h;A&&!A.nextSibling;)A=A.parentElement;return A.nextSibling}(c=o.parentElement);if(v&&v.nodeType!==3){var g=v.querySelector(".vditor-wysiwyg__preview");if(g)return void vt(g,t)}if(v.nodeType===3){for(;v.textContent.length===0&&v.nextSibling;)v=v.nextSibling;r.setStart(v,1)}else r.setStart(v.firstChild,0)}else r.selectNodeContents(a),r.collapse(!1)}else i.key==="ArrowDown"||i.key==="ArrowRight"?vt(o,t):vt(o,t,!1)}}})},e}(),Hi=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var o in r)r.hasOwnProperty(o)&&(i[o]=r[o])},e(t,n)};return function(t,n){function i(){this.constructor=t}e(t,n),t.prototype=n===null?Object.create(n):(i.prototype=n.prototype,new i)}}();const Ni=function(e){function t(n,i){var r=e.call(this)||this;if(r.version=b.H,typeof n=="string"){if(i?i.cache?i.cache.id||(i.cache.id="vditor"+n):i.cache={id:"vditor"+n}:i={cache:{id:"vditor"+n}},!document.getElementById(n))return r.showErrorTip("Failed to get element by id: "+n),r;n=document.getElementById(n)}var o=new Ai(i).merge();if(o.i18n)window.VditorI18n=o.i18n,r.init(n,o);else{if(!["en_US","fr_FR","pt_BR","ja_JP","ko_KR","ru_RU","sv_SE","zh_CN","zh_TW"].includes(o.lang))throw new Error("options.lang error, see https://ld246.com/article/1549638745630#options");var a="vditorI18nScript",c=a+o.lang;document.querySelectorAll('head script[id^="vditorI18nScript"]').forEach(function(v){v.id!==c&&document.head.removeChild(v)}),(0,s.G)(o.cdn+"/dist/js/i18n/"+o.lang+".js",c).then(function(){r.init(n,o)}).catch(function(v){r.showErrorTip("GET "+o.cdn+"/dist/js/i18n/"+o.lang+".js net::ERR_ABORTED 404 (Not Found)")})}return r}return Hi(t,e),t.prototype.showErrorTip=function(n){var i=new Vn;document.body.appendChild(i.element),i.show(n,0)},t.prototype.setTheme=function(n,i,r,o){this.vditor.options.theme=n,ve(this.vditor),i&&(this.vditor.options.preview.theme.current=i,(0,Ie.Z)(i,o||this.vditor.options.preview.theme.path)),r&&(this.vditor.options.preview.hljs.style=r,(0,Un.Y)(r,this.vditor.options.cdn))},t.prototype.getValue=function(){return m(this.vditor)},t.prototype.getCurrentMode=function(){return this.vditor.currentMode},t.prototype.focus=function(){this.vditor.currentMode==="sv"?this.vditor.sv.element.focus():this.vditor.currentMode==="wysiwyg"?this.vditor.wysiwyg.element.focus():this.vditor.currentMode==="ir"&&this.vditor.ir.element.focus()},t.prototype.blur=function(){this.vditor.currentMode==="sv"?this.vditor.sv.element.blur():this.vditor.currentMode==="wysiwyg"?this.vditor.wysiwyg.element.blur():this.vditor.currentMode==="ir"&&this.vditor.ir.element.blur()},t.prototype.disabled=function(){y(this.vditor,["subToolbar","hint","popover"]),L(this.vditor.toolbar.elements,b.g.EDIT_TOOLBARS.concat(["undo","redo","fullscreen","edit-mode"])),this.vditor[this.vditor.currentMode].element.setAttribute("contenteditable","false")},t.prototype.enable=function(){E(this.vditor.toolbar.elements,b.g.EDIT_TOOLBARS.concat(["undo","redo","fullscreen","edit-mode"])),this.vditor.undo.resetIcon(this.vditor),this.vditor[this.vditor.currentMode].element.setAttribute("contenteditable","true")},t.prototype.getSelection=function(){return this.vditor.currentMode==="wysiwyg"?yt(this.vditor.wysiwyg.element):this.vditor.currentMode==="sv"?yt(this.vditor.sv.element):this.vditor.currentMode==="ir"?yt(this.vditor.ir.element):void 0},t.prototype.renderPreview=function(n){this.vditor.preview.render(this.vditor,n)},t.prototype.getCursorPosition=function(){return(0,x.Ny)(this.vditor[this.vditor.currentMode].element)},t.prototype.isUploading=function(){return this.vditor.upload.isUploading},t.prototype.clearCache=function(){localStorage.removeItem(this.vditor.options.cache.id)},t.prototype.disabledCache=function(){this.vditor.options.cache.enable=!1},t.prototype.enableCache=function(){if(!this.vditor.options.cache.id)throw new Error("need options.cache.id, see https://ld246.com/article/1549638745630#options");this.vditor.options.cache.enable=!0},t.prototype.html2md=function(n){return this.vditor.lute.HTML2Md(n)},t.prototype.exportJSON=function(n){return this.vditor.lute.RenderJSON(n)},t.prototype.getHTML=function(){return qn(this.vditor)},t.prototype.tip=function(n,i){this.vditor.tip.show(n,i)},t.prototype.setPreviewMode=function(n){$t(n,this.vditor)},t.prototype.deleteValue=function(){window.getSelection().isCollapsed||document.execCommand("delete",!1)},t.prototype.updateValue=function(n){document.execCommand("insertHTML",!1,n)},t.prototype.insertValue=function(n,i){i===void 0&&(i=!0);var r=(0,x.zh)(this.vditor);r.collapse(!0);var o=document.createElement("template");o.innerHTML=n,r.insertNode(o.content.cloneNode(!0)),r.collapse(!1),this.vditor.currentMode==="sv"?(this.vditor.sv.preventInput=!0,i&&oe(this.vditor)):this.vditor.currentMode==="wysiwyg"?i&&Mt(this.vditor,getSelection().getRangeAt(0)):this.vditor.currentMode==="ir"&&(this.vditor.ir.preventInput=!0,i&&Ee(this.vditor,getSelection().getRangeAt(0),!0))},t.prototype.setValue=function(n,i){var r=this;i===void 0&&(i=!1),this.vditor.currentMode==="sv"?(this.vditor.sv.element.innerHTML="<div data-block='0'>"+this.vditor.lute.SpinVditorSVDOM(n)+"</div>",Oe(this.vditor,{enableAddUndoStack:!0,enableHint:!1,enableInput:!1})):this.vditor.currentMode==="wysiwyg"?mn(this.vditor,n,{enableAddUndoStack:!0,enableHint:!1,enableInput:!1}):(this.vditor.ir.element.innerHTML=this.vditor.lute.Md2VditorIRDOM(n),this.vditor.ir.element.querySelectorAll(".vditor-ir__preview[data-render='2']").forEach(function(o){xe(o,r.vditor)}),Xe(this.vditor,{enableAddUndoStack:!0,enableHint:!1,enableInput:!1})),this.vditor.outline.render(this.vditor),n||(y(this.vditor,["emoji","headings","submenu","hint"]),this.vditor.wysiwyg.popover&&(this.vditor.wysiwyg.popover.style.display="none"),this.clearCache()),i&&this.clearStack()},t.prototype.clearStack=function(){this.vditor.undo.clearStack(this.vditor),this.vditor.undo.addToUndoStack(this.vditor)},t.prototype.destroy=function(){this.vditor.element.innerHTML=this.vditor.originalInnerHTML,this.vditor.element.classList.remove("vditor"),this.vditor.element.removeAttribute("style");var n=document.getElementById("vditorIconScript");n&&n.remove(),this.clearCache(),Je(),this.vditor.wysiwyg.unbindListener()},t.prototype.getCommentIds=function(){return this.vditor.currentMode!=="wysiwyg"?[]:this.vditor.wysiwyg.getComments(this.vditor,!0)},t.prototype.hlCommentIds=function(n){if(this.vditor.currentMode==="wysiwyg"){var i=function(r){r.classList.remove("vditor-comment--hover"),n.forEach(function(o){r.getAttribute("data-cmtids").indexOf(o)>-1&&r.classList.add("vditor-comment--hover")})};this.vditor.wysiwyg.element.querySelectorAll(".vditor-comment").forEach(function(r){i(r)}),this.vditor.preview.element.style.display!=="none"&&this.vditor.preview.element.querySelectorAll(".vditor-comment").forEach(function(r){i(r)})}},t.prototype.unHlCommentIds=function(n){if(this.vditor.currentMode==="wysiwyg"){var i=function(r){n.forEach(function(o){r.getAttribute("data-cmtids").indexOf(o)>-1&&r.classList.remove("vditor-comment--hover")})};this.vditor.wysiwyg.element.querySelectorAll(".vditor-comment").forEach(function(r){i(r)}),this.vditor.preview.element.style.display!=="none"&&this.vditor.preview.element.querySelectorAll(".vditor-comment").forEach(function(r){i(r)})}},t.prototype.removeCommentIds=function(n){var i=this;if(this.vditor.currentMode==="wysiwyg"){var r=function(o,a){var c=o.getAttribute("data-cmtids").split(" ");c.find(function(v,g){if(v===a)return c.splice(g,1),!0}),c.length===0?(o.outerHTML=o.innerHTML,(0,x.zh)(i.vditor).collapse(!0)):o.setAttribute("data-cmtids",c.join(" "))};n.forEach(function(o){i.vditor.wysiwyg.element.querySelectorAll(".vditor-comment").forEach(function(a){r(a,o)}),i.vditor.preview.element.style.display!=="none"&&i.vditor.preview.element.querySelectorAll(".vditor-comment").forEach(function(a){r(a,o)})}),Se(this.vditor,{enableAddUndoStack:!0,enableHint:!1,enableInput:!1})}},t.prototype.init=function(n,i){var r=this;this.vditor={currentMode:i.mode,element:n,hint:new Tr(i.hint.extend),lute:void 0,options:i,originalInnerHTML:n.innerHTML,outline:new xr(window.VditorI18n.outline),tip:new Vn},this.vditor.sv=new Nr(this.vditor),this.vditor.undo=new Mi,this.vditor.wysiwyg=new _i(this.vditor),this.vditor.ir=new Cr(this.vditor),this.vditor.toolbar=new Ti(this.vditor),i.resize.enable&&(this.vditor.resize=new Hr(this.vditor)),this.vditor.toolbar.elements.devtools&&(this.vditor.devtools=new w),(i.upload.url||i.upload.handler)&&(this.vditor.upload=new vr),(0,s.G)(i._lutePath||i.cdn+"/dist/js/lute/lute.min.js","vditorLuteScript").then(function(){r.vditor.lute=(0,Mr.X)({autoSpace:r.vditor.options.preview.markdown.autoSpace,gfmAutoLink:r.vditor.options.preview.markdown.gfmAutoLink,codeBlockPreview:r.vditor.options.preview.markdown.codeBlockPreview,emojiSite:r.vditor.options.hint.emojiPath,emojis:r.vditor.options.hint.emoji,fixTermTypo:r.vditor.options.preview.markdown.fixTermTypo,footnotes:r.vditor.options.preview.markdown.footnotes,headingAnchor:!1,inlineMathDigit:r.vditor.options.preview.math.inlineDigit,linkBase:r.vditor.options.preview.markdown.linkBase,linkPrefix:r.vditor.options.preview.markdown.linkPrefix,listStyle:r.vditor.options.preview.markdown.listStyle,mark:r.vditor.options.preview.markdown.mark,mathBlockPreview:r.vditor.options.preview.markdown.mathBlockPreview,paragraphBeginningSpace:r.vditor.options.preview.markdown.paragraphBeginningSpace,sanitize:r.vditor.options.preview.markdown.sanitize,toc:r.vditor.options.preview.markdown.toc}),r.vditor.preview=new _r(r.vditor),function(o){o.element.innerHTML="",o.element.classList.add("vditor"),o.options.rtl&&o.element.setAttribute("dir","rtl"),ve(o),(0,Ie.Z)(o.options.preview.theme.current,o.options.preview.theme.path),typeof o.options.height=="number"?o.element.style.height=o.options.height+"px":o.element.style.height=o.options.height,typeof o.options.minHeight=="number"&&(o.element.style.minHeight=o.options.minHeight+"px"),typeof o.options.width=="number"?o.element.style.width=o.options.width+"px":o.element.style.width=o.options.width,o.element.appendChild(o.toolbar.element);var a=document.createElement("div");if(a.className="vditor-content",o.options.outline.position==="left"&&a.appendChild(o.outline.element),a.appendChild(o.wysiwyg.element.parentElement),a.appendChild(o.sv.element),a.appendChild(o.ir.element.parentElement),a.appendChild(o.preview.element),o.toolbar.elements.devtools&&a.appendChild(o.devtools.element),o.options.outline.position==="right"&&(o.outline.element.classList.add("vditor-outline--right"),a.appendChild(o.outline.element)),o.upload&&a.appendChild(o.upload.element),o.options.resize.enable&&a.appendChild(o.resize.element),a.appendChild(o.hint.element),a.appendChild(o.tip.element),o.element.appendChild(a),a.addEventListener("click",function(){y(o,["subToolbar"])}),o.toolbar.elements.export&&o.element.insertAdjacentHTML("beforeend",'<iframe id="vditorExportIframe" style="width: 100%;height: 0;border: 0"></iframe>'),rt(o,o.options.mode,sr(o)),document.execCommand("DefaultParagraphSeparator",!1,"p"),navigator.userAgent.indexOf("iPhone")>-1&&window.visualViewport!==void 0){var c=!1,v=function(g){c||(c=!0,requestAnimationFrame(function(){c=!1;var h=o.toolbar.element;h.style.transform="none",h.getBoundingClientRect().top<0&&(h.style.transform="translate(0, "+-h.getBoundingClientRect().top+"px)")}))};window.visualViewport.addEventListener("scroll",v),window.visualViewport.addEventListener("resize",v)}}(r.vditor),i.after&&i.after(),i.icon&&(0,s.J)(i.cdn+"/dist/js/icons/"+i.icon+".js","vditorIconScript")})},t}(M.default)})(),je=je.default})())})(ot);var Yn=ot.exports;const St=Ze(Yn),Rt=()=>de.usePlugin(Pt).getCDN(),on=de.genStyleHook("nb-field-markdown-vditor",ae=>{const{componentCls:ye}=ae;return{[ye]:{".vditor-reset":{fontSize:`${ae.fontSize}px !important`},".vditor":{borderRadius:8},".vditor .vditor-content":{borderRadius:"0 0 8px 8px",overflow:"hidden"},".vditor .vditor-toolbar":{paddingLeft:" 16px !important",borderRadius:"8px 8px 0 0"},".vditor .vditor-content .vditor-ir .vditor-reset":{paddingLeft:" 16px !important"}}}});function Qn(ae){const ye=ae;let pe=document.createElement("div");pe.innerHTML=ye;const ce=pe.innerText;return pe=null,(ce==null?void 0:ce.replace(/[\n\r]/g,""))||""}const $n=ae=>{if(ae){const ye=document.createRange();return ye.selectNodeContents(ae),ye.getBoundingClientRect().width}};function an(ae){var J;const ye=Ae.useRef(null),{wrapSSR:pe,componentCls:ce,hashId:ne}=on(),je=Rt();return Ae.useEffect(()=>{var M;St.preview(ye.current,(M=ae.value)!=null?M:"",{mode:"light",cdn:je})},[ae.value]),pe(Ke.jsx("div",{className:`${ne} ${ce}`,children:Ke.jsx("div",{ref:ye,style:rn({border:"none"},(J=ae==null?void 0:ae.style)!=null?J:{})})}))}const er=de.withDynamicSchemaProps(ae=>{var l;const ye=Me.useField(),pe=(l=ae.value)!=null?l:ye.value,ce=Rt(),ne=Ae.useRef(),[je,J]=Ae.useState(!1),[M,b]=Ae.useState(!1),[d,m]=Ae.useState(""),s=Ae.useRef();Ae.useEffect(()=>{var u;!ae.value||!ye.value||(ae.ellipsis?St.md2html(ae.value,{mode:"light",cdn:ce}).then(f=>{m(Qn(f))}).catch(()=>m("")):St.preview(ne.current,(u=ae.value)!=null?u:ye.value,{mode:"light",cdn:ce}))},[ae.value,ae.ellipsis,ye.value]);const w=Ae.useCallback(()=>{var E;if(!s.current)return!1;const u=$n(s.current),f=(E=s.current)==null?void 0:E.offsetWidth;return u>f},[s]);return ae.ellipsis?Ke.jsx(kt.Popover,{open:je,onOpenChange:u=>{J(M&&u)},content:Ke.jsx(an,{value:pe,style:{maxWidth:500,maxHeight:400,overflowY:"auto"}}),children:Ke.jsx("div",{ref:s,style:{overflow:"hidden",overflowWrap:"break-word",textOverflow:"ellipsis",whiteSpace:"nowrap",wordBreak:"break-all"},onMouseEnter:u=>{const f=u.target;w()&&b(f.scrollWidth>=f.clientWidth)},children:d})}):Ke.jsx(an,{value:pe})}),tr="field-markdown-vditor";function me(ae){return jt.tval(ae,{ns:tr})}const{defaultProps:nr,operators:rr}=de.interfacesProperties,ln=["headings","bold","italic","strike","link","list","ordered-list","check","quote","line","code","inline-code","upload","fullscreen"];class ir extends de.CollectionFieldInterface{constructor(){super(...arguments);We(this,"name","vditor");We(this,"type","object");We(this,"group","media");We(this,"order",1);We(this,"title",me("Vditor"));We(this,"sortable",!0);We(this,"default",{type:"text",length:"long",uiSchema:{type:"string","x-component":"MarkdownVditor"}});We(this,"availableTypes",["text","json","string"]);We(this,"properties",Xn(rn({},nr),{"uiSchema.x-component-props.fileCollection":{type:"string",title:me("File collection"),"x-component":"CollectionSelect","x-component-props":{filter:pe=>{var ce;return((ce=pe==null?void 0:pe.options)==null?void 0:ce.template)==="file"}},"x-decorator":"FormItem",default:"","x-reactions":{fulfill:{schema:{description:me("Used to store files uploaded in the Markdown editor")}}}},"uiSchema.x-component-props.toolbar":{type:"array",title:me("Toolbar"),"x-component":"Select","x-component-props":{mode:"multiple"},"x-decorator":"FormItem",default:ln,enum:[{value:"emoji",label:me("Emoji")},{value:"headings",label:me("Headings")},{value:"bold",label:me("Bold")},{value:"italic",label:me("Italic")},{value:"strike",label:me("Strike")},{value:"line",label:me("Line")},{value:"quote",label:me("Quote")},{value:"list",label:me("List")},{value:"ordered-list",label:me("OrderedList")},{value:"check",label:me("Check")},{value:"outdent",label:me("Outdent")},{value:"indent",label:me("Indent")},{value:"code",label:me("Code")},{value:"inline-code",label:me("InlineCode")},{value:"insert-after",label:me("InsertAfter")},{value:"insert-before",label:me("InsertBefore")},{value:"undo",label:me("Undo")},{value:"redo",label:me("Redo")},{value:"upload",label:me("Upload")},{value:"link",label:me("Link")},{value:"record",label:me("Record")},{value:"table",label:me("Table")},{value:"edit-mode",label:me("EditMode")},{value:"both",label:me("Both")},{value:"preview",label:me("Preview")},{value:"fullscreen",label:me("Fullscreen")},{value:"outline",label:me("Outline")}]}}));We(this,"filterable",{operators:rr.bigField});We(this,"titleUsable",!0)}schemaInitialize(pe,{block:ce}){["Table","Kanban"].includes(ce)&&(pe["x-component-props"]=pe["x-component-props"]||{},pe["x-component-props"].ellipsis=!0)}}const or=["en_US","fr_FR","pt_BR","ja_JP","ko_KR","ru_RU","sv_SE","zh_CN","zh_TW"],ar=de.withDynamicSchemaProps(ae=>{const{disabled:ye,onChange:pe,value:ce,fileCollection:ne,toolbar:je}=ae,[J,M]=Ae.useState(!1),b=Ae.useRef(),d=Ae.useRef(!1),m=Ae.useRef(null),s=Ae.useRef(null),w=de.useApp(),l=de.useAPIClient(),u=Rt(),{wrapSSR:f,hashId:E,componentCls:L}=on(),S=l.auth.locale||"en-US",C=Ae.useMemo(()=>{const y=S.replace(/-/g,"_");return or.includes(y)?y:"en_US"},[S]);return Ae.useEffect(()=>{if(!m.current)return;const y=ne||"attachments",k=je!=null?je:ln,p=new St(m.current,{value:ce!=null?ce:"",lang:C,cache:{enable:!1},undoDelay:0,preview:{math:{engine:"KaTeX"}},toolbar:k,fullscreen:{index:1200},cdn:u,minHeight:200,after:()=>{b.current=p,M(!0),p.setValue(ce!=null?ce:""),ye?p.disabled():p.enable()},input(_){pe(_)},upload:{url:w.getApiUrl(`${y}:create`),headers:l.getHeaders(),multiple:!1,fieldName:"file",max:1024*1024*1024,format(_,N){const q=JSON.parse(N),D={msg:"",code:0,data:{errFiles:[],succMap:{[q.data.filename]:q.data.url}}};return JSON.stringify(D)}}});return()=>{var _;(_=b.current)==null||_.destroy(),b.current=void 0}},[ne,je==null?void 0:je.join(",")]),Ae.useEffect(()=>{var y;if(J&&b.current){const k=b.current;if(ce!==k.getValue()){k.setValue(ce!=null?ce:"");const p=(y=m.current)==null?void 0:y.querySelector("div.vditor-content > div.vditor-ir > pre");if(p){const _=document.createRange(),N=window.getSelection();N&&(_.selectNodeContents(p),_.collapse(!1),N.removeAllRanges(),N.addRange(_))}}}},[ce,J]),Ae.useEffect(()=>{J&&b.current&&(ye?b.current.disabled():b.current.enable())},[ye,J]),Ae.useLayoutEffect(()=>{if(!m.current)return;const y=new ResizeObserver(k=>{var p;for(const _ of k){const N=_.target;N.className.includes("vditor--fullscreen")?(document.body.appendChild(N),d.current=!0):d.current&&((p=s.current)==null||p.appendChild(N),d.current=!1)}});return y.observe(m.current),()=>{y.unobserve(m.current)}},[]),f(Ke.jsx("div",{ref:s,className:`${E} ${L}`,children:Ke.jsx("div",{id:E,ref:m})}))}),lr=de.withDynamicSchemaProps(Me.connect(ar,Me.mapReadPretty(er)));class Pt extends de.Plugin{afterAdd(){return It(this,null,function*(){})}beforeLoad(){return It(this,null,function*(){})}load(){return It(this,null,function*(){this.app.addComponents({MarkdownVditor:lr}),this.initVditorDependency(),this.app.dataSourceManager.addFieldInterfaces([ir])})}getCDN(){return this.app.getPublicPath()+"static/plugins/@nocobase/plugin-field-markdown-vditor/dist/client/vditor"}initVditorDependency(){const ye=this.getCDN();try{const pe="plugin-field-markdown-vditor-dep",ce={[`${pe}.katex`]:`${ye}/dist/js/katex/katex.min.js?v=0.16.9`,[`${pe}.ABCJS`]:`${ye}/dist/js/abcjs/abcjs_basic.min`,[`${pe}.plantumlEncoder`]:`${ye}/dist/js/plantuml/plantuml-encoder.min`,[`${pe}.echarts`]:`${ye}/dist/js/echarts/echarts.min`,[`${pe}.flowchart`]:`${ye}/dist/js/flowchart.js/flowchart.min`,[`${pe}.Viz`]:`${ye}/dist/js/graphviz/viz`,[`${pe}.mermaid`]:`${ye}/dist/js/mermaid/mermaid.min`};this.app.requirejs.require.config({waitSeconds:120,paths:ce}),Object.keys(ce).forEach(ne=>{this.app.requirejs.require([ne],je=>{window[ne.split(".")[1]]=je})})}catch(pe){console.log("initVditorDependency failed",pe)}}}be.PluginFieldMarkdownVditorClient=Pt,be.default=Pt,Object.defineProperties(be,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.4.
|
|
12
|
-
"@nocobase/database": "1.4.
|
|
13
|
-
"@nocobase/server": "1.4.
|
|
11
|
+
"@nocobase/client": "1.4.9",
|
|
12
|
+
"@nocobase/database": "1.4.9",
|
|
13
|
+
"@nocobase/server": "1.4.9",
|
|
14
14
|
"@formily/core": "2.3.0",
|
|
15
15
|
"@formily/react": "2.3.0",
|
|
16
16
|
"antd": "5.12.8",
|
|
17
17
|
"react": "18.2.0",
|
|
18
|
-
"@nocobase/utils": "1.4.
|
|
18
|
+
"@nocobase/utils": "1.4.9"
|
|
19
19
|
};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "数据表字段:Markdown(Vditor)",
|
|
5
5
|
"description": "Used to store Markdown and render it using Vditor editor, supports common Markdown syntax such as list, code, quote, etc., and supports uploading images, recordings, etc.It also allows for instant rendering, where what you see is what you get.",
|
|
6
6
|
"description.zh-CN": "用于存储 Markdown,并使用 Vditor 编辑器渲染,支持常见 Markdown 语法,如列表,代码,引用等,并支持上传图片,录音等。同时可以做到即时渲染,所见即所得。",
|
|
7
|
-
"version": "1.4.
|
|
7
|
+
"version": "1.4.9",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "dist/server/index.js",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/field-markdown-vditor",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"keywords": [
|
|
28
28
|
"Collection fields"
|
|
29
29
|
],
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "87b52358d8f6fdd2974aca9b41dda15edd4a0e69"
|
|
31
31
|
}
|