qzhuli-markdown-wysiwyg 0.1.13 → 0.1.14
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/editor/markdown-editor-wysiwyg.html +15 -14
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +73 -70
- package/package.json +1 -1
|
@@ -11479,11 +11479,11 @@
|
|
|
11479
11479
|
return headings
|
|
11480
11480
|
}
|
|
11481
11481
|
|
|
11482
|
-
function getCurrentTocEntries() {
|
|
11483
|
-
if (sourceMode) {
|
|
11484
|
-
const textarea = document.getElementById('markdown-source-editor')
|
|
11485
|
-
return collectSourceModeHeadings(textarea ? textarea.value : '')
|
|
11486
|
-
}
|
|
11482
|
+
function getCurrentTocEntries() {
|
|
11483
|
+
if (sourceMode) {
|
|
11484
|
+
const textarea = document.getElementById('markdown-source-editor')
|
|
11485
|
+
return collectSourceModeHeadings(textarea ? textarea.value : '')
|
|
11486
|
+
}
|
|
11487
11487
|
|
|
11488
11488
|
const content = document.getElementById('doc-content')
|
|
11489
11489
|
if (!content) return []
|
|
@@ -11495,15 +11495,16 @@
|
|
|
11495
11495
|
text: heading.textContent || '',
|
|
11496
11496
|
element: heading,
|
|
11497
11497
|
lineIndex: index,
|
|
11498
|
-
}
|
|
11499
|
-
})
|
|
11500
|
-
}
|
|
11501
|
-
|
|
11502
|
-
|
|
11503
|
-
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
hideToolbarTimer
|
|
11498
|
+
}
|
|
11499
|
+
})
|
|
11500
|
+
}
|
|
11501
|
+
|
|
11502
|
+
const sourceTextarea = document.getElementById('markdown-source-editor')
|
|
11503
|
+
if (sourceTextarea) {
|
|
11504
|
+
const revealToolbar = () => {
|
|
11505
|
+
if (editorReadOnly || !toolbarWrapper) return
|
|
11506
|
+
clearTimeout(hideToolbarTimer)
|
|
11507
|
+
hideToolbarTimer = setTimeout(() => {
|
|
11507
11508
|
toolbarWrapper.classList.remove('toolbar-hidden')
|
|
11508
11509
|
toolbarHidden = false
|
|
11509
11510
|
}, 100)
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("vue");var p=typeof document<"u"?document.currentScript:null;const D="qzhuli-markdown-wysiwyg",G="./editor/markdown-editor-wysiwyg.html",W=/\/node_modules\/\.vite\/deps\/[^/?#]*qzhuli-markdown-wysiwyg[^/?#]*\.js(?:[?#].*)?$/i,U=(o,i)=>{const s=String(i||"").trim();!s||o.includes(s)||o.push(s)},F=()=>new URL(G,typeof document>"u"?require("url").pathToFileURL(__filename).href:p&&p.tagName.toUpperCase()==="SCRIPT"&&p.src||new URL("index.cjs",document.baseURI).href).href,K=()=>{const o=String((typeof document>"u"?require("url").pathToFileURL(__filename).href:p&&p.tagName.toUpperCase()==="SCRIPT"&&p.src||new URL("index.cjs",document.baseURI).href)||"").trim();return!o||!W.test(o)?"":o.replace(W,`/node_modules/${D}/dist/editor/markdown-editor-wysiwyg.html`)},b=o=>{const i=[];if(U(i,o),i.length>0)return i;const s=K();return s?(U(i,s),U(i,F()),i):(U(i,F()),i)},Y=o=>b(o)[0]||"",$=["src","title"],_=r.defineComponent({name:"MarkdownEditorWysiwyg",__name:"MarkdownEditorWysiwyg",props:{modelValue:{default:""},readOnly:{type:Boolean,default:!1},viewMode:{},theme:{default:"system"},filename:{default:""},path:{default:""},runtimeUrl:{default:""},iframeTitle:{default:"Markdown WYSIWYG editor"},atUserList:{default:()=>[]}},emits:["update:modelValue","change","ready","scroll","get-at-list","at-who","mention-click","file-save"],setup(o,{expose:i,emit:s}){const a=o,u=s,w=r.ref(null),k=r.getCurrentInstance(),I=()=>{var e;const t=(e=k==null?void 0:k.subTree)==null?void 0:e.el;w.value=t instanceof HTMLIFrameElement?t:null},l=r.ref(!1),P=r.ref(0),c=r.ref(0),m=r.ref(0),E=r.ref(a.modelValue??""),q=r.ref(a.filename??""),A=r.ref(a.path??""),C=r.computed(()=>O(a.atUserList)),L=r.computed(()=>a.viewMode?a.viewMode:a.readOnly?"readonly":"default"),h=r.computed(()=>b(a.runtimeUrl)),R=r.computed(()=>h.value[c.value]||"");let g=null;const f=()=>{g===null||typeof window>"u"||(window.clearTimeout(g),g=null)},T=()=>{f(),!(typeof window>"u")&&(l.value||c.value>=h.value.length-1||(g=window.setTimeout(()=>{l.value||c.value>=h.value.length-1||(l.value=!1,m.value=0,c.value+=1)},1200)))},v=t=>{var e,n;(n=(e=w.value)==null?void 0:e.contentWindow)==null||n.postMessage(t,"*")},M=(t,e)=>{if(typeof t=="string"){const y=t.trim();return{id:y||e,name:y,displayName:y,label:y,subtitle:"",keywords:[],searchTerms:[]}}const n=String(t.name||t.displayName||t.label||"").trim(),d=String(t.displayName||t.label||t.name||"").trim(),S=String(t.subtitle||"").trim();return{id:t.id??n??d??e,name:n||d,displayName:d||n,label:d||n,avatar:String(t.avatar||"").trim(),subtitle:S,keywords:Array.isArray(t.keywords)?[...t.keywords]:[],searchTerms:Array.isArray(t.searchTerms)?[...t.searchTerms]:[]}},O=(t=[])=>t.map((e,n)=>M(e,n)),N=()=>{const t=a.modelValue??"",e=a.filename??"",n=a.path??"";v({type:"load-content",content:t,filename:e,path:n}),E.value=t,q.value=e,A.value=n},V=()=>{v({type:"apply-settings",theme:a.theme,readOnly:L.value==="readonly",viewMode:L.value})},j=()=>{v({type:"set-host-mode",mode:"external"})},x=(t=m.value)=>{v({type:"set-at-list",requestId:t,users:C.value})},B=()=>{l.value&&(j(),N(),V(),x())},H=()=>{f(),l.value=!1,m.value=0,c.value=0,P.value+=1},z=t=>{if(w.value&&t.source!==w.value.contentWindow||!t.data||typeof t.data!="object")return;const e=t.data;if(e.type==="editor-ready"){f(),l.value=!0,u("ready"),B();return}if(e.type==="get-at-list"){const n=Number(e.requestId)||Date.now();m.value=n;const d={requestId:n,query:String(e.query||"")};u("get-at-list",d);return}if(e.type==="at-who"){if(!e.user)return;const n={requestId:Number(e.requestId)||m.value||Date.now(),value:String(e.value||""),user:M(e.user,0)};u("at-who",n);return}if(e.type==="mention-click"){if(!e.user)return;const n={value:String(e.value||""),user:M(e.user,0)};u("mention-click",n);return}if(e.type==="file-save"){const n={content:String(e.content??""),filename:String(e.filename??a.filename??""),path:String(e.path??a.path??"")};u("file-save",n);return}if(e.type==="content-change"){const n=e.content??"";E.value=n,u("update:modelValue",n),u("change",n);return}e.type==="scroll-position"&&u("scroll",Number(e.position)||0)};return r.watch(h,()=>{f(),c.value=0,l.value||T()},{deep:!0}),r.watch(R,()=>{R.value&&(f(),l.value=!1,m.value=0,T())}),r.watch(()=>[a.modelValue,a.filename,a.path],([t,e,n])=>{if(!l.value)return;const d=t??"",S=e??"",y=n??"";d===E.value&&S===q.value&&y===A.value||N()}),r.watch(()=>[a.readOnly,a.viewMode,a.theme],()=>{l.value&&V()}),r.watch(C,()=>{l.value&&x()},{deep:!0}),i({reload:H,postMessage:v}),r.onMounted(()=>{I(),window.addEventListener("message",z),T()}),r.onUpdated(()=>{I()}),r.onBeforeUnmount(()=>{f(),window.removeEventListener("message",z)}),(t,e)=>(r.openBlock(),r.createElementBlock("iframe",{key:P.value,src:R.value,title:o.iframeTitle,class:"markdown-editor-wysiwyg-frame",style:{display:"block",width:"100%",height:"100%",border:"0"}},null,8,$))}}),J={install(o){o.component("MarkdownEditorWysiwyg",_)}};exports.MarkdownEditorWysiwyg=_;exports.MarkdownEditorWysiwygPlugin=J;exports.default=_;exports.resolveEditorRuntimeUrl=Y;exports.resolveEditorRuntimeUrls=b;
|
package/dist/index.mjs
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
!
|
|
5
|
-
},
|
|
1
|
+
import { defineComponent as j, ref as d, getCurrentInstance as G, computed as k, watch as p, onMounted as K, onUpdated as Y, onBeforeUnmount as $, openBlock as J, createElementBlock as Q } from "vue";
|
|
2
|
+
const X = "qzhuli-markdown-wysiwyg", Z = "./editor/markdown-editor-wysiwyg.html", x = /\/node_modules\/\.vite\/deps\/[^/?#]*qzhuli-markdown-wysiwyg[^/?#]*\.js(?:[?#].*)?$/i, E = (r, l) => {
|
|
3
|
+
const i = String(l || "").trim();
|
|
4
|
+
!i || r.includes(i) || r.push(i);
|
|
5
|
+
}, W = () => new URL(
|
|
6
6
|
/* @vite-ignore */
|
|
7
|
-
|
|
7
|
+
Z,
|
|
8
8
|
import.meta.url
|
|
9
9
|
).href, ee = () => {
|
|
10
10
|
const r = String(import.meta.url || "").trim();
|
|
11
|
-
return !r || !
|
|
12
|
-
|
|
13
|
-
`/node_modules/${
|
|
11
|
+
return !r || !x.test(r) ? "" : r.replace(
|
|
12
|
+
x,
|
|
13
|
+
`/node_modules/${X}/dist/editor/markdown-editor-wysiwyg.html`
|
|
14
14
|
);
|
|
15
|
-
},
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
}, F = (r) => {
|
|
16
|
+
const l = [];
|
|
17
|
+
if (E(l, r), l.length > 0)
|
|
18
|
+
return l;
|
|
19
|
+
const i = ee();
|
|
20
|
+
return i ? (E(l, i), E(l, W()), l) : (E(l, W()), l);
|
|
21
|
+
}, re = (r) => F(r)[0] || "", te = ["src", "title"], ne = /* @__PURE__ */ j({
|
|
19
22
|
name: "MarkdownEditorWysiwyg",
|
|
20
23
|
__name: "MarkdownEditorWysiwyg",
|
|
21
24
|
props: {
|
|
@@ -30,54 +33,54 @@ const Q = "qzhuli-markdown-wysiwyg", X = "./editor/markdown-editor-wysiwyg.html"
|
|
|
30
33
|
atUserList: { default: () => [] }
|
|
31
34
|
},
|
|
32
35
|
emits: ["update:modelValue", "change", "ready", "scroll", "get-at-list", "at-who", "mention-click", "file-save"],
|
|
33
|
-
setup(r, { expose:
|
|
34
|
-
const a = r,
|
|
36
|
+
setup(r, { expose: l, emit: i }) {
|
|
37
|
+
const a = r, s = i, w = d(null), M = G(), R = () => {
|
|
35
38
|
var e;
|
|
36
|
-
const t = (e =
|
|
39
|
+
const t = (e = M == null ? void 0 : M.subTree) == null ? void 0 : e.el;
|
|
37
40
|
w.value = t instanceof HTMLIFrameElement ? t : null;
|
|
38
|
-
},
|
|
41
|
+
}, o = d(!1), _ = d(0), m = d(0), c = d(0), T = d(a.modelValue ?? ""), q = d(a.filename ?? ""), I = d(a.path ?? ""), P = k(() => O(a.atUserList)), N = k(() => a.viewMode ? a.viewMode : a.readOnly ? "readonly" : "default"), g = k(() => F(a.runtimeUrl)), b = k(() => g.value[m.value] || "");
|
|
39
42
|
let h = null;
|
|
40
|
-
const
|
|
43
|
+
const f = () => {
|
|
41
44
|
h === null || typeof window > "u" || (window.clearTimeout(h), h = null);
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
}, U = () => {
|
|
46
|
+
f(), !(typeof window > "u") && (o.value || m.value >= g.value.length - 1 || (h = window.setTimeout(() => {
|
|
47
|
+
o.value || m.value >= g.value.length - 1 || (o.value = !1, c.value = 0, m.value += 1);
|
|
45
48
|
}, 1200)));
|
|
46
49
|
}, v = (t) => {
|
|
47
50
|
var e, n;
|
|
48
51
|
(n = (e = w.value) == null ? void 0 : e.contentWindow) == null || n.postMessage(t, "*");
|
|
49
52
|
}, S = (t, e) => {
|
|
50
53
|
if (typeof t == "string") {
|
|
51
|
-
const
|
|
54
|
+
const y = t.trim();
|
|
52
55
|
return {
|
|
53
|
-
id:
|
|
54
|
-
name:
|
|
55
|
-
displayName:
|
|
56
|
-
label:
|
|
56
|
+
id: y || e,
|
|
57
|
+
name: y,
|
|
58
|
+
displayName: y,
|
|
59
|
+
label: y,
|
|
57
60
|
subtitle: "",
|
|
58
61
|
keywords: [],
|
|
59
62
|
searchTerms: []
|
|
60
63
|
};
|
|
61
64
|
}
|
|
62
|
-
const n = String(t.name || t.displayName || t.label || "").trim(),
|
|
65
|
+
const n = String(t.name || t.displayName || t.label || "").trim(), u = String(t.displayName || t.label || t.name || "").trim(), A = String(t.subtitle || "").trim();
|
|
63
66
|
return {
|
|
64
|
-
id: t.id ?? n ??
|
|
65
|
-
name: n ||
|
|
66
|
-
displayName:
|
|
67
|
-
label:
|
|
67
|
+
id: t.id ?? n ?? u ?? e,
|
|
68
|
+
name: n || u,
|
|
69
|
+
displayName: u || n,
|
|
70
|
+
label: u || n,
|
|
68
71
|
avatar: String(t.avatar || "").trim(),
|
|
69
|
-
subtitle:
|
|
72
|
+
subtitle: A,
|
|
70
73
|
keywords: Array.isArray(t.keywords) ? [...t.keywords] : [],
|
|
71
74
|
searchTerms: Array.isArray(t.searchTerms) ? [...t.searchTerms] : []
|
|
72
75
|
};
|
|
73
|
-
},
|
|
76
|
+
}, O = (t = []) => t.map((e, n) => S(e, n)), C = () => {
|
|
74
77
|
const t = a.modelValue ?? "", e = a.filename ?? "", n = a.path ?? "";
|
|
75
78
|
v({
|
|
76
79
|
type: "load-content",
|
|
77
80
|
content: t,
|
|
78
81
|
filename: e,
|
|
79
82
|
path: n
|
|
80
|
-
}),
|
|
83
|
+
}), T.value = t, q.value = e, I.value = n;
|
|
81
84
|
}, L = () => {
|
|
82
85
|
v({
|
|
83
86
|
type: "apply-settings",
|
|
@@ -85,46 +88,46 @@ const Q = "qzhuli-markdown-wysiwyg", X = "./editor/markdown-editor-wysiwyg.html"
|
|
|
85
88
|
readOnly: N.value === "readonly",
|
|
86
89
|
viewMode: N.value
|
|
87
90
|
});
|
|
88
|
-
},
|
|
91
|
+
}, B = () => {
|
|
89
92
|
v({
|
|
90
93
|
type: "set-host-mode",
|
|
91
94
|
mode: "external"
|
|
92
95
|
});
|
|
93
|
-
}, V = (t =
|
|
96
|
+
}, V = (t = c.value) => {
|
|
94
97
|
v({
|
|
95
98
|
type: "set-at-list",
|
|
96
99
|
requestId: t,
|
|
97
|
-
users:
|
|
100
|
+
users: P.value
|
|
98
101
|
});
|
|
99
|
-
}, B = () => {
|
|
100
|
-
l.value && (O(), C(), L(), V());
|
|
101
102
|
}, H = () => {
|
|
102
|
-
|
|
103
|
-
},
|
|
103
|
+
o.value && (B(), C(), L(), V());
|
|
104
|
+
}, D = () => {
|
|
105
|
+
f(), o.value = !1, c.value = 0, m.value = 0, _.value += 1;
|
|
106
|
+
}, z = (t) => {
|
|
104
107
|
if (w.value && t.source !== w.value.contentWindow || !t.data || typeof t.data != "object") return;
|
|
105
108
|
const e = t.data;
|
|
106
109
|
if (e.type === "editor-ready") {
|
|
107
|
-
|
|
110
|
+
f(), o.value = !0, s("ready"), H();
|
|
108
111
|
return;
|
|
109
112
|
}
|
|
110
113
|
if (e.type === "get-at-list") {
|
|
111
114
|
const n = Number(e.requestId) || Date.now();
|
|
112
|
-
|
|
113
|
-
const
|
|
115
|
+
c.value = n;
|
|
116
|
+
const u = {
|
|
114
117
|
requestId: n,
|
|
115
118
|
query: String(e.query || "")
|
|
116
119
|
};
|
|
117
|
-
|
|
120
|
+
s("get-at-list", u);
|
|
118
121
|
return;
|
|
119
122
|
}
|
|
120
123
|
if (e.type === "at-who") {
|
|
121
124
|
if (!e.user) return;
|
|
122
125
|
const n = {
|
|
123
|
-
requestId: Number(e.requestId) ||
|
|
126
|
+
requestId: Number(e.requestId) || c.value || Date.now(),
|
|
124
127
|
value: String(e.value || ""),
|
|
125
128
|
user: S(e.user, 0)
|
|
126
129
|
};
|
|
127
|
-
|
|
130
|
+
s("at-who", n);
|
|
128
131
|
return;
|
|
129
132
|
}
|
|
130
133
|
if (e.type === "mention-click") {
|
|
@@ -133,7 +136,7 @@ const Q = "qzhuli-markdown-wysiwyg", X = "./editor/markdown-editor-wysiwyg.html"
|
|
|
133
136
|
value: String(e.value || ""),
|
|
134
137
|
user: S(e.user, 0)
|
|
135
138
|
};
|
|
136
|
-
|
|
139
|
+
s("mention-click", n);
|
|
137
140
|
return;
|
|
138
141
|
}
|
|
139
142
|
if (e.type === "file-save") {
|
|
@@ -142,57 +145,57 @@ const Q = "qzhuli-markdown-wysiwyg", X = "./editor/markdown-editor-wysiwyg.html"
|
|
|
142
145
|
filename: String(e.filename ?? a.filename ?? ""),
|
|
143
146
|
path: String(e.path ?? a.path ?? "")
|
|
144
147
|
};
|
|
145
|
-
|
|
148
|
+
s("file-save", n);
|
|
146
149
|
return;
|
|
147
150
|
}
|
|
148
151
|
if (e.type === "content-change") {
|
|
149
152
|
const n = e.content ?? "";
|
|
150
|
-
|
|
153
|
+
T.value = n, s("update:modelValue", n), s("change", n);
|
|
151
154
|
return;
|
|
152
155
|
}
|
|
153
|
-
e.type === "scroll-position" &&
|
|
156
|
+
e.type === "scroll-position" && s("scroll", Number(e.position) || 0);
|
|
154
157
|
};
|
|
155
158
|
return p(
|
|
156
159
|
g,
|
|
157
160
|
() => {
|
|
158
|
-
|
|
161
|
+
f(), m.value = 0, o.value || U();
|
|
159
162
|
},
|
|
160
163
|
{ deep: !0 }
|
|
161
164
|
), p(
|
|
162
|
-
|
|
165
|
+
b,
|
|
163
166
|
() => {
|
|
164
|
-
|
|
167
|
+
b.value && (f(), o.value = !1, c.value = 0, U());
|
|
165
168
|
}
|
|
166
169
|
), p(
|
|
167
170
|
() => [a.modelValue, a.filename, a.path],
|
|
168
171
|
([t, e, n]) => {
|
|
169
|
-
if (!
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
+
if (!o.value) return;
|
|
173
|
+
const u = t ?? "", A = e ?? "", y = n ?? "";
|
|
174
|
+
u === T.value && A === q.value && y === I.value || C();
|
|
172
175
|
}
|
|
173
176
|
), p(
|
|
174
177
|
() => [a.readOnly, a.viewMode, a.theme],
|
|
175
178
|
() => {
|
|
176
|
-
|
|
179
|
+
o.value && L();
|
|
177
180
|
}
|
|
178
181
|
), p(
|
|
179
|
-
|
|
182
|
+
P,
|
|
180
183
|
() => {
|
|
181
|
-
|
|
184
|
+
o.value && V();
|
|
182
185
|
},
|
|
183
186
|
{ deep: !0 }
|
|
184
|
-
),
|
|
185
|
-
reload:
|
|
187
|
+
), l({
|
|
188
|
+
reload: D,
|
|
186
189
|
postMessage: v
|
|
187
|
-
}), G(() => {
|
|
188
|
-
_(), window.addEventListener("message", x), b();
|
|
189
190
|
}), K(() => {
|
|
190
|
-
|
|
191
|
+
R(), window.addEventListener("message", z), U();
|
|
191
192
|
}), Y(() => {
|
|
192
|
-
|
|
193
|
-
}), (
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
R();
|
|
194
|
+
}), $(() => {
|
|
195
|
+
f(), window.removeEventListener("message", z);
|
|
196
|
+
}), (t, e) => (J(), Q("iframe", {
|
|
197
|
+
key: _.value,
|
|
198
|
+
src: b.value,
|
|
196
199
|
title: r.iframeTitle,
|
|
197
200
|
class: "markdown-editor-wysiwyg-frame",
|
|
198
201
|
style: { display: "block", width: "100%", height: "100%", border: "0" }
|
|
@@ -208,5 +211,5 @@ export {
|
|
|
208
211
|
le as MarkdownEditorWysiwygPlugin,
|
|
209
212
|
ne as default,
|
|
210
213
|
re as resolveEditorRuntimeUrl,
|
|
211
|
-
|
|
214
|
+
F as resolveEditorRuntimeUrls
|
|
212
215
|
};
|