@nocobase/plugin-field-markdown-vditor 1.2.22-alpha → 1.2.23-alpha
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/LICENSE.txt
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
Updated Date:
|
|
1
|
+
Updated Date: July 22, 2024
|
|
2
2
|
|
|
3
3
|
NocoBase License Agreement
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
NOCOBASE PTE. LTD. ("The Company") https://www.nocobase.com/ issues this License Agreement ("Agreement") to you. You, as an individual or a company ("User"), will be deemed to voluntarily accept all terms of this Agreement by using NocoBase (including but not limited to obtaining NocoBase source code or installation package in any form, installing and using NocoBase, purchasing NocoBase commercial license and services, purchasing NocoBase commercial plugins). If the User does not agree to any term of this Agreement, or cannot accurately understand our interpretation of the relevant terms, please stop using it immediately.
|
|
6
6
|
|
|
7
7
|
This Agreement applies to any use, quotation, contract, invoice, and all software delivered by the Company. The User and the Company or NocoBase's agents can no longer sign a separate license agreement for the sale and delivery of the software.
|
|
8
8
|
|
|
@@ -11,25 +11,24 @@ The Company reserves the right to formulate and modify this Agreement from time
|
|
|
11
11
|
==============
|
|
12
12
|
1. Definitions
|
|
13
13
|
==============
|
|
14
|
-
1.1 "Software" refers to the NocoBase kernel and plugins placed in the same code repository as the kernel, including their source code, installation packages, images, and all their modifications, updates, and upgrades.
|
|
15
14
|
|
|
16
|
-
1.
|
|
15
|
+
1.1 "Software" refers to the NocoBase kernel and plugins placed in the same code repository as the kernel, including their source code, installation packages, images, and all their modifications, updates, and upgrades.
|
|
17
16
|
|
|
18
|
-
1.
|
|
17
|
+
1.2 "Marketplace" refers to the marketplace provided by the Company for selling Software plugins and solutions.
|
|
19
18
|
|
|
20
|
-
1.
|
|
19
|
+
1.3 "Commercial Plugin" refers to the paid plugins sold in the Marketplace.
|
|
21
20
|
|
|
22
|
-
1.
|
|
21
|
+
1.4 "Upper Layer Application" refers to a specific business use case application serving internal or external customers of the User, developed based on Software and Commercial Plugins, such as ERP/CRM.
|
|
23
22
|
|
|
24
|
-
1.
|
|
23
|
+
1.5 "Customer" refers to the clients who purchase the User's Upper Layer Application.
|
|
25
24
|
|
|
26
|
-
1.
|
|
25
|
+
1.6 "Third-Party Open Source Software" refers to open source software provided with Software and Commercial Plugins. They are licensed through various published open source software licenses or copyright notices accompanying such software.
|
|
27
26
|
|
|
28
27
|
===================================
|
|
29
28
|
2. Intellectual Property Protection
|
|
30
29
|
===================================
|
|
31
30
|
|
|
32
|
-
Except for Third-Party Open Source Software, the Company owns all copyrights, trademark rights, patent rights, trade secrets, and other intellectual property rights of the Software
|
|
31
|
+
Except for Third-Party Open Source Software, the Company owns all copyrights, trademark rights, patent rights, trade secrets, and other intellectual property rights of the Software, and has registered and protected them in relevant countries and regions according to the "Paris Convention" or "TRIPS Agreement", ensuring that the intellectual property rights of the Software and Commercial Plugins are internationally recognized and protected.
|
|
33
32
|
|
|
34
33
|
=============
|
|
35
34
|
3. Disclaimer
|
|
@@ -51,11 +50,11 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
|
|
|
51
50
|
5. Rights and Obligations of Open Source License
|
|
52
51
|
================================================
|
|
53
52
|
|
|
54
|
-
5.1 The Software can be used for commercial purposes
|
|
53
|
+
5.1 The Software can be used for commercial purposes.
|
|
55
54
|
|
|
56
|
-
5.2 User can sell plugins developed for the Software in the
|
|
55
|
+
5.2 User can sell plugins developed for the Software in the Marketplace.
|
|
57
56
|
|
|
58
|
-
5.3 Outside the
|
|
57
|
+
5.3 Outside the Marketplace, changes and plugins to the Software developed by User or third parties, and third-party applications developed based on the Software must all be open-sourced under the AGPL-3.0 license.
|
|
59
58
|
|
|
60
59
|
5.4 It is not allowed to remove or change the brand, name, link, version number, license, and other information about NocoBase on the Software interface, except for the main LOGO in the upper left corner of the page.
|
|
61
60
|
|
|
@@ -69,25 +68,23 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
|
|
|
69
68
|
6. Rights of Commercial License
|
|
70
69
|
===============================
|
|
71
70
|
|
|
72
|
-
6.1 Obtain a permanent commercial license
|
|
73
|
-
|
|
74
|
-
6.2 Get 6 months of exclusive technical support.
|
|
71
|
+
6.1 Obtain a permanent commercial license of the Software or Commercial Plugin.
|
|
75
72
|
|
|
76
|
-
6.
|
|
73
|
+
6.2 Get 12 months of upgrade and exclusive technical support.
|
|
77
74
|
|
|
78
|
-
6.
|
|
75
|
+
6.3 The licensed Software and Commercial Plugins can be used for commercial purposes with no restrictions on the number of applications and users.
|
|
79
76
|
|
|
80
|
-
6.
|
|
77
|
+
6.4 Changes and plugins to the Software, and applications integrated with the Software do not need to be open sourced.
|
|
81
78
|
|
|
82
|
-
6.
|
|
79
|
+
6.5 Can remove or change the brand, name, link, version number, license, and other information about NocoBase on the Software interface.
|
|
83
80
|
|
|
84
|
-
6.
|
|
81
|
+
6.6 Can sell plugins developed for Software in the Marketplace.
|
|
85
82
|
|
|
86
|
-
6.
|
|
83
|
+
6.7 Can sell or provide Upper Layer Applications developed based on Software in the form of SaaS to the public.
|
|
87
84
|
|
|
88
|
-
6.
|
|
85
|
+
6.8 Not restricted by the AGPL-3.0 agreement.
|
|
89
86
|
|
|
90
|
-
6.
|
|
87
|
+
6.9 If there are other agreements in the contract for the above rights, the contract agreement shall prevail.
|
|
91
88
|
|
|
92
89
|
====================================
|
|
93
90
|
7. Obligations of Commercial License
|
|
@@ -97,15 +94,15 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
|
|
|
97
94
|
|
|
98
95
|
7.2 It is not allowed to sell, transfer, lease, share, or give away the Commercial License.
|
|
99
96
|
|
|
100
|
-
7.3 It is not allowed to
|
|
97
|
+
7.3 It is not allowed to provide any form of no-code, zero-code, low-code platform SaaS products to the public using the original or modified Software.
|
|
101
98
|
|
|
102
|
-
7.4 It is not allowed to
|
|
99
|
+
7.4 It is not allowed to sell Upper Layer Application to Customer who have not obtained a Commercial License.
|
|
103
100
|
|
|
104
101
|
7.5 It is not allowed to use reverse engineering, decompilation, and other means to try to discover the source code of Commercial Plugins that have not obtained source code license.
|
|
105
102
|
|
|
106
103
|
7.6 It is not allowed to disclose the source code of Commercial Plugins to any third party.
|
|
107
104
|
|
|
108
|
-
7.7 It is not allowed to publicly sell plugins developed for Software outside of the
|
|
105
|
+
7.7 It is not allowed to publicly sell plugins developed for Software outside of the Marketplace.
|
|
109
106
|
|
|
110
107
|
7.8 If there is a violation of the above obligations or the terms of this Agreement, the rights owned by the User will be immediately terminated, the paid fees will not be refunded, and the Company reserves the right to pursue the User's legal responsibility.
|
|
111
108
|
|
|
@@ -121,4 +118,4 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
|
|
|
121
118
|
|
|
122
119
|
8.3 All terms and conditions of this Agreement shall be deemed enforceable to the maximum extent permitted by applicable law. If any term of this Agreement is deemed invalid by any applicable law, the invalidity of that term does not affect the validity of any other term of this Agreement, and it should be deemed that the invalid term has been modified as much as possible to make it valid and enforceable, or if the term cannot be modified, it should be deemed to have been deleted from this Agreement.
|
|
123
120
|
|
|
124
|
-
8.4 The arbitration award is final, binding on both parties, and can be enforced in any court with jurisdiction.
|
|
121
|
+
8.4 The arbitration award is final, binding on both parties, and can be enforced in any court with jurisdiction.
|
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(E.g.ZWSP,"")===""?(a.selectNodeContents(n.element.lastElementChild),a.collapse(!1)):(n.element.insertAdjacentHTML("beforeend",'<p data-block="0">'+E.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 O=function(){A.setAttribute("src",T.value),A.setAttribute("alt",q.value),A.setAttribute("title",B.value),typeof h.options.input=="function"&&h.options.input(m(h))},U=document.createElement("span");U.setAttribute("aria-label",window.VditorI18n.imageURL),U.className="vditor-tooltipped vditor-tooltipped__n";var T=document.createElement("input");U.appendChild(T),T.className="vditor-input",T.setAttribute("placeholder",window.VditorI18n.imageURL),T.value=A.getAttribute("src")||"",T.oninput=function(){O()},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 q=document.createElement("input");R.appendChild(q),q.className="vditor-input",q.setAttribute("placeholder",window.VditorI18n.alternateText),q.style.width="52px",q.value=A.getAttribute("alt")||"",q.oninput=function(){O()},q.onkeydown=function(P){Re(h,P)};var D=document.createElement("span");D.setAttribute("aria-label",window.VditorI18n.title),D.className="vditor-tooltipped vditor-tooltipped__n";var B=document.createElement("input");D.appendChild(B),B.className="vditor-input",B.setAttribute("placeholder",window.VditorI18n.title),B.value=A.getAttribute("title")||"",B.oninput=function(){O()},B.onkeydown=function(P){Re(h,P)},Ve(A,h),h.wysiwyg.popover.insertAdjacentElement("beforeend",U),h.wysiwyg.popover.insertAdjacentElement("beforeend",R),h.wysiwyg.popover.insertAdjacentElement("beforeend",D),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=E.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,E.g.EDIT_TOOLBARS.concat(["undo","redo","fullscreen","edit-mode"])),this.vditor[this.vditor.currentMode].element.setAttribute("contenteditable","false")},t.prototype.enable=function(){w(this.vditor.toolbar.elements,E.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&&ae(this.vditor)):this.vditor.currentMode==="wysiwyg"?i&&Mt(this.vditor,getSelection().getRangeAt(0)):this.vditor.currentMode==="ir"&&(this.vditor.ir.preventInput=!0,i&&be(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 Cr(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 Tr(this.vditor),this.vditor.toolbar=new Ci(this.vditor),i.resize.enable&&(this.vditor.resize=new Hr(this.vditor)),this.vditor.toolbar.elements.devtools&&(this.vditor.devtools=new b),(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",oe=>{const{componentCls:ye}=oe;return{[ye]:{".vditor-reset":{fontSize:`${oe.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(oe){const ye=oe;let ue=document.createElement("div");ue.innerHTML=ye;const me=ue.innerText;return ue=null,(me==null?void 0:me.replace(/[\n\r]/g,""))||""}const $n=oe=>{if(oe){const ye=document.createRange();return ye.selectNodeContents(oe),ye.getBoundingClientRect().width}};function an(oe){var Z;const ye=Ae.useRef(),{wrapSSR:ue,componentCls:me,hashId:ne}=on(),je=Rt();return Ae.useEffect(()=>{oe.value&&St.preview(ye.current,oe.value,{mode:"light",cdn:je})},[oe.value]),ue(Ke.jsx("div",{className:`${ne} ${me}`,children:Ke.jsx("div",{ref:ye,style:rn({border:"none"},(Z=oe==null?void 0:oe.style)!=null?Z:{})})}))}const er=de.withDynamicSchemaProps(oe=>{var l;const ye=Me.useField(),ue=(l=oe.value)!=null?l:ye.value,me=Rt(),ne=Ae.useRef(),[je,Z]=Ae.useState(!1),[M,E]=Ae.useState(!1),[d,m]=Ae.useState(""),s=Ae.useRef();Ae.useEffect(()=>{var u;!oe.value||!ye.value||(oe.ellipsis?St.md2html(oe.value,{mode:"light",cdn:me}).then(f=>{m(Qn(f))}).catch(()=>m("")):St.preview(ne.current,(u=oe.value)!=null?u:ye.value,{mode:"light",cdn:me}))},[oe.value,oe.ellipsis,ye.value]);const b=Ae.useCallback(()=>{var w;if(!s.current)return!1;const u=$n(s.current),f=(w=s.current)==null?void 0:w.offsetWidth;return u>f},[s]);return oe.ellipsis?Ke.jsx(kt.Popover,{open:je,onOpenChange:u=>{Z(M&&u)},content:Ke.jsx(an,{value:ue,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;b()&&E(f.scrollWidth>=f.clientWidth)},children:d})}):Ke.jsx(an,{value:ue})}),tr="field-markdown-vditor";function pe(oe){return jt.tval(oe,{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);ze(this,"name","vditor");ze(this,"type","object");ze(this,"group","media");ze(this,"order",1);ze(this,"title",pe("Vditor"));ze(this,"sortable",!0);ze(this,"default",{type:"text",length:"long",uiSchema:{type:"string","x-component":"MarkdownVditor"}});ze(this,"properties",Xn(rn({},nr),{"uiSchema.x-component-props.fileCollection":{type:"string",title:pe("File collection"),"x-component":"CollectionSelect","x-component-props":{filter:ue=>{var me;return((me=ue==null?void 0:ue.options)==null?void 0:me.template)==="file"}},"x-decorator":"FormItem",default:"","x-reactions":{fulfill:{schema:{description:pe("Used to store files uploaded in the Markdown editor")}}}},"uiSchema.x-component-props.toolbar":{type:"array",title:pe("Toolbar"),"x-component":"Select","x-component-props":{mode:"multiple"},"x-decorator":"FormItem",default:ln,enum:[{value:"emoji",label:pe("Emoji")},{value:"headings",label:pe("Headings")},{value:"bold",label:pe("Bold")},{value:"italic",label:pe("Italic")},{value:"strike",label:pe("Strike")},{value:"line",label:pe("Line")},{value:"quote",label:pe("Quote")},{value:"list",label:pe("List")},{value:"ordered-list",label:pe("OrderedList")},{value:"check",label:pe("Check")},{value:"outdent",label:pe("Outdent")},{value:"indent",label:pe("Indent")},{value:"code",label:pe("Code")},{value:"inline-code",label:pe("InlineCode")},{value:"insert-after",label:pe("InsertAfter")},{value:"insert-before",label:pe("InsertBefore")},{value:"undo",label:pe("Undo")},{value:"redo",label:pe("Redo")},{value:"upload",label:pe("Upload")},{value:"link",label:pe("Link")},{value:"record",label:pe("Record")},{value:"table",label:pe("Table")},{value:"edit-mode",label:pe("EditMode")},{value:"both",label:pe("Both")},{value:"preview",label:pe("Preview")},{value:"fullscreen",label:pe("Fullscreen")},{value:"outline",label:pe("Outline")}]}}));ze(this,"filterable",{operators:rr.number});ze(this,"titleUsable",!0)}schemaInitialize(ue,{block:me}){["Table","Kanban"].includes(me)&&(ue["x-component-props"]=ue["x-component-props"]||{},ue["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(oe=>{const{disabled:ye,onChange:ue,value:me,fileCollection:ne,toolbar:je}=oe,Z=Ae.useRef(),M=Ae.useRef(!1),E=Ae.useRef(),d=Ae.useRef(),m=de.useApp(),s=de.useAPIClient(),b=Rt(),{wrapSSR:l,hashId:u,componentCls:f}=on(),w=s.auth.locale,L=Ae.useMemo(()=>{const S=w.replace(/-/g,"_");return or.includes(S)?S:"en_US"},[w]);return Ae.useEffect(()=>{const S=ne||"attachments",C=je!=null?je:ln,y=new St(E.current,{value:me!=null?me:"",lang:L,cache:{enable:!1},undoDelay:0,preview:{math:{engine:"KaTeX"}},toolbar:C,fullscreen:{index:1200},cdn:b,minHeight:200,after:()=>{Z.current=y,y.setValue(me!=null?me:""),ye?y.disabled():y.enable()},input(k){ue(k)},upload:{url:m.getApiUrl(`${S}:create`),headers:s.getHeaders(),multiple:!1,fieldName:"file",format(k,p){const _=JSON.parse(p),I={msg:"",code:0,data:{errFiles:[],succMap:{[_.data.filename]:_.data.url}}};return JSON.stringify(I)}}});return()=>{var k;(k=Z.current)==null||k.destroy(),Z.current=void 0}},[ne,je==null?void 0:je.join(",")]),Ae.useEffect(()=>{var C,y,k;if(me===((C=Z==null?void 0:Z.current)==null?void 0:C.getValue()))return;(y=Z.current)==null||y.setValue(me),(k=Z.current)==null||k.focus();const S=E.current.querySelector("div.vditor-content > div.vditor-ir > pre");if(S){const p=document.createRange(),_=window.getSelection();_&&(p.selectNodeContents(S),p.collapse(!1),_.removeAllRanges(),_.addRange(p))}},[me]),Ae.useEffect(()=>{var S,C;ye?(S=Z.current)==null||S.disabled():(C=Z.current)==null||C.enable()},[ye]),Ae.useLayoutEffect(()=>{const S=new ResizeObserver(C=>{var y;for(const k of C){const p=k.target;p.className.includes("vditor--fullscreen")?(document.body.appendChild(p),M.current=!0):M.current&&((y=d.current)==null||y.appendChild(p),M.current=!1)}});return S.observe(E.current),()=>{S.unobserve(E.current)}},[]),l(Ke.jsx("div",{ref:d,className:`${u} ${f}`,children:Ke.jsx("div",{id:u,ref:E})}))}),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 ue="plugin-field-markdown-vditor-dep",me={[`${ue}.katex`]:`${ye}/dist/js/katex/katex.min.js?v=0.16.9`,[`${ue}.ABCJS`]:`${ye}/dist/js/abcjs/abcjs_basic.min`,[`${ue}.plantumlEncoder`]:`${ye}/dist/js/plantuml/plantuml-encoder.min`,[`${ue}.echarts`]:`${ye}/dist/js/echarts/echarts.min`,[`${ue}.flowchart`]:`${ye}/dist/js/flowchart.js/flowchart.min`,[`${ue}.Viz`]:`${ye}/dist/js/graphviz/viz`,[`${ue}.mermaid`]:`${ye}/dist/js/mermaid/mermaid.min`};this.app.requirejs.require.config({waitSeconds:120,paths:me}),Object.keys(me).forEach(ne=>{this.app.requirejs.require([ne],je=>{window[ne.split(".")[1]]=je})})}catch(ue){console.log("initVditorDependency failed",ue)}}}we.PluginFieldMarkdownVditorClient=Pt,we.default=Pt,Object.defineProperties(we,{__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=E.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,E.g.EDIT_TOOLBARS.concat(["undo","redo","fullscreen","edit-mode"])),this.vditor[this.vditor.currentMode].element.setAttribute("contenteditable","false")},t.prototype.enable=function(){w(this.vditor.toolbar.elements,E.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&&ae(this.vditor)):this.vditor.currentMode==="wysiwyg"?i&&Mt(this.vditor,getSelection().getRangeAt(0)):this.vditor.currentMode==="ir"&&(this.vditor.ir.preventInput=!0,i&&be(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 Cr(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 Tr(this.vditor),this.vditor.toolbar=new Ci(this.vditor),i.resize.enable&&(this.vditor.resize=new Hr(this.vditor)),this.vditor.toolbar.elements.devtools&&(this.vditor.devtools=new b),(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",oe=>{const{componentCls:ye}=oe;return{[ye]:{".vditor-reset":{fontSize:`${oe.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(oe){const ye=oe;let ue=document.createElement("div");ue.innerHTML=ye;const me=ue.innerText;return ue=null,(me==null?void 0:me.replace(/[\n\r]/g,""))||""}const $n=oe=>{if(oe){const ye=document.createRange();return ye.selectNodeContents(oe),ye.getBoundingClientRect().width}};function an(oe){var Z;const ye=Ae.useRef(),{wrapSSR:ue,componentCls:me,hashId:ne}=on(),je=Rt();return Ae.useEffect(()=>{oe.value&&St.preview(ye.current,oe.value,{mode:"light",cdn:je})},[oe.value]),ue(Ke.jsx("div",{className:`${ne} ${me}`,children:Ke.jsx("div",{ref:ye,style:rn({border:"none"},(Z=oe==null?void 0:oe.style)!=null?Z:{})})}))}const er=de.withDynamicSchemaProps(oe=>{var l;const ye=Me.useField(),ue=(l=oe.value)!=null?l:ye.value,me=Rt(),ne=Ae.useRef(),[je,Z]=Ae.useState(!1),[M,E]=Ae.useState(!1),[d,m]=Ae.useState(""),s=Ae.useRef();Ae.useEffect(()=>{var u;!oe.value||!ye.value||(oe.ellipsis?St.md2html(oe.value,{mode:"light",cdn:me}).then(f=>{m(Qn(f))}).catch(()=>m("")):St.preview(ne.current,(u=oe.value)!=null?u:ye.value,{mode:"light",cdn:me}))},[oe.value,oe.ellipsis,ye.value]);const b=Ae.useCallback(()=>{var w;if(!s.current)return!1;const u=$n(s.current),f=(w=s.current)==null?void 0:w.offsetWidth;return u>f},[s]);return oe.ellipsis?Ke.jsx(kt.Popover,{open:je,onOpenChange:u=>{Z(M&&u)},content:Ke.jsx(an,{value:ue,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;b()&&E(f.scrollWidth>=f.clientWidth)},children:d})}):Ke.jsx(an,{value:ue})}),tr="field-markdown-vditor";function pe(oe){return jt.tval(oe,{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);ze(this,"name","vditor");ze(this,"type","object");ze(this,"group","media");ze(this,"order",1);ze(this,"title",pe("Vditor"));ze(this,"sortable",!0);ze(this,"default",{type:"text",length:"long",uiSchema:{type:"string","x-component":"MarkdownVditor"}});ze(this,"properties",Xn(rn({},nr),{"uiSchema.x-component-props.fileCollection":{type:"string",title:pe("File collection"),"x-component":"CollectionSelect","x-component-props":{filter:ue=>{var me;return((me=ue==null?void 0:ue.options)==null?void 0:me.template)==="file"}},"x-decorator":"FormItem",default:"","x-reactions":{fulfill:{schema:{description:pe("Used to store files uploaded in the Markdown editor")}}}},"uiSchema.x-component-props.toolbar":{type:"array",title:pe("Toolbar"),"x-component":"Select","x-component-props":{mode:"multiple"},"x-decorator":"FormItem",default:ln,enum:[{value:"emoji",label:pe("Emoji")},{value:"headings",label:pe("Headings")},{value:"bold",label:pe("Bold")},{value:"italic",label:pe("Italic")},{value:"strike",label:pe("Strike")},{value:"line",label:pe("Line")},{value:"quote",label:pe("Quote")},{value:"list",label:pe("List")},{value:"ordered-list",label:pe("OrderedList")},{value:"check",label:pe("Check")},{value:"outdent",label:pe("Outdent")},{value:"indent",label:pe("Indent")},{value:"code",label:pe("Code")},{value:"inline-code",label:pe("InlineCode")},{value:"insert-after",label:pe("InsertAfter")},{value:"insert-before",label:pe("InsertBefore")},{value:"undo",label:pe("Undo")},{value:"redo",label:pe("Redo")},{value:"upload",label:pe("Upload")},{value:"link",label:pe("Link")},{value:"record",label:pe("Record")},{value:"table",label:pe("Table")},{value:"edit-mode",label:pe("EditMode")},{value:"both",label:pe("Both")},{value:"preview",label:pe("Preview")},{value:"fullscreen",label:pe("Fullscreen")},{value:"outline",label:pe("Outline")}]}}));ze(this,"filterable",{operators:rr.bigField});ze(this,"titleUsable",!0)}schemaInitialize(ue,{block:me}){["Table","Kanban"].includes(me)&&(ue["x-component-props"]=ue["x-component-props"]||{},ue["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(oe=>{const{disabled:ye,onChange:ue,value:me,fileCollection:ne,toolbar:je}=oe,Z=Ae.useRef(),M=Ae.useRef(!1),E=Ae.useRef(),d=Ae.useRef(),m=de.useApp(),s=de.useAPIClient(),b=Rt(),{wrapSSR:l,hashId:u,componentCls:f}=on(),w=s.auth.locale,L=Ae.useMemo(()=>{const S=w.replace(/-/g,"_");return or.includes(S)?S:"en_US"},[w]);return Ae.useEffect(()=>{const S=ne||"attachments",C=je!=null?je:ln,y=new St(E.current,{value:me!=null?me:"",lang:L,cache:{enable:!1},undoDelay:0,preview:{math:{engine:"KaTeX"}},toolbar:C,fullscreen:{index:1200},cdn:b,minHeight:200,after:()=>{Z.current=y,y.setValue(me!=null?me:""),ye?y.disabled():y.enable()},input(k){ue(k)},upload:{url:m.getApiUrl(`${S}:create`),headers:s.getHeaders(),multiple:!1,fieldName:"file",format(k,p){const _=JSON.parse(p),I={msg:"",code:0,data:{errFiles:[],succMap:{[_.data.filename]:_.data.url}}};return JSON.stringify(I)}}});return()=>{var k;(k=Z.current)==null||k.destroy(),Z.current=void 0}},[ne,je==null?void 0:je.join(",")]),Ae.useEffect(()=>{var C,y,k;if(me===((C=Z==null?void 0:Z.current)==null?void 0:C.getValue()))return;(y=Z.current)==null||y.setValue(me),(k=Z.current)==null||k.focus();const S=E.current.querySelector("div.vditor-content > div.vditor-ir > pre");if(S){const p=document.createRange(),_=window.getSelection();_&&(p.selectNodeContents(S),p.collapse(!1),_.removeAllRanges(),_.addRange(p))}},[me]),Ae.useEffect(()=>{var S,C;ye?(S=Z.current)==null||S.disabled():(C=Z.current)==null||C.enable()},[ye]),Ae.useLayoutEffect(()=>{const S=new ResizeObserver(C=>{var y;for(const k of C){const p=k.target;p.className.includes("vditor--fullscreen")?(document.body.appendChild(p),M.current=!0):M.current&&((y=d.current)==null||y.appendChild(p),M.current=!1)}});return S.observe(E.current),()=>{S.unobserve(E.current)}},[]),l(Ke.jsx("div",{ref:d,className:`${u} ${f}`,children:Ke.jsx("div",{id:u,ref:E})}))}),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 ue="plugin-field-markdown-vditor-dep",me={[`${ue}.katex`]:`${ye}/dist/js/katex/katex.min.js?v=0.16.9`,[`${ue}.ABCJS`]:`${ye}/dist/js/abcjs/abcjs_basic.min`,[`${ue}.plantumlEncoder`]:`${ye}/dist/js/plantuml/plantuml-encoder.min`,[`${ue}.echarts`]:`${ye}/dist/js/echarts/echarts.min`,[`${ue}.flowchart`]:`${ye}/dist/js/flowchart.js/flowchart.min`,[`${ue}.Viz`]:`${ye}/dist/js/graphviz/viz`,[`${ue}.mermaid`]:`${ye}/dist/js/mermaid/mermaid.min`};this.app.requirejs.require.config({waitSeconds:120,paths:me}),Object.keys(me).forEach(ne=>{this.app.requirejs.require([ne],je=>{window[ne.split(".")[1]]=je})})}catch(ue){console.log("initVditorDependency failed",ue)}}}we.PluginFieldMarkdownVditorClient=Pt,we.default=Pt,Object.defineProperties(we,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -82,16 +82,28 @@ export declare class MarkdownVditorFieldInterface extends CollectionFieldInterfa
|
|
|
82
82
|
label: string;
|
|
83
83
|
value: string;
|
|
84
84
|
selected: boolean;
|
|
85
|
+
schema: {
|
|
86
|
+
type: string;
|
|
87
|
+
'x-component': string;
|
|
88
|
+
};
|
|
85
89
|
noValue?: undefined;
|
|
86
90
|
} | {
|
|
87
91
|
label: string;
|
|
88
92
|
value: string;
|
|
93
|
+
schema: {
|
|
94
|
+
type: string;
|
|
95
|
+
'x-component': string;
|
|
96
|
+
};
|
|
89
97
|
selected?: undefined;
|
|
90
98
|
noValue?: undefined;
|
|
91
99
|
} | {
|
|
92
100
|
label: string;
|
|
93
101
|
value: string;
|
|
94
102
|
noValue: boolean;
|
|
103
|
+
schema: {
|
|
104
|
+
type: string;
|
|
105
|
+
'x-component': string;
|
|
106
|
+
};
|
|
95
107
|
selected?: undefined;
|
|
96
108
|
})[];
|
|
97
109
|
};
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.2.
|
|
12
|
-
"@nocobase/database": "1.2.
|
|
13
|
-
"@nocobase/server": "1.2.
|
|
11
|
+
"@nocobase/client": "1.2.23-alpha",
|
|
12
|
+
"@nocobase/database": "1.2.23-alpha",
|
|
13
|
+
"@nocobase/server": "1.2.23-alpha",
|
|
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.2.
|
|
18
|
+
"@nocobase/utils": "1.2.23-alpha"
|
|
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.2.
|
|
7
|
+
"version": "1.2.23-alpha",
|
|
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": "e2ee9d3c39d123cfdb0b50bfb6d381eaa4a96f77"
|
|
31
31
|
}
|