@paroicms/quill-editor-plugin 1.14.0 → 1.16.0
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.
|
@@ -11,14 +11,19 @@ async function convertQuillDeltaToHtml(service, delta, options) {
|
|
|
11
11
|
const converter = new quill_delta_to_html_1.QuillDeltaToHtmlAsyncConverter(ops, {
|
|
12
12
|
multiLineParagraph: false,
|
|
13
13
|
});
|
|
14
|
-
converter.renderCustomWith((customOp) => {
|
|
14
|
+
converter.renderCustomWith(async (customOp) => {
|
|
15
15
|
const { type, value } = customOp.insert;
|
|
16
16
|
if (type === "html-snippet")
|
|
17
17
|
return value.html;
|
|
18
18
|
if (type === "obfuscate")
|
|
19
19
|
return obfuscateBlotProcessing(value, customOp.attributes);
|
|
20
20
|
if (type === "img")
|
|
21
|
-
return imgBlotProcessing(service, value, options);
|
|
21
|
+
return await imgBlotProcessing(service, value, options);
|
|
22
|
+
if (type === "video-plugin")
|
|
23
|
+
return videoPluginBlotProcessing(service, value, options);
|
|
24
|
+
if (type === "internal-link-plugin") {
|
|
25
|
+
return await internalLinkPluginBlotProcessing(service, value, options);
|
|
26
|
+
}
|
|
22
27
|
service.logger.warn(`Invalid blot '${type}'`);
|
|
23
28
|
return "";
|
|
24
29
|
});
|
|
@@ -32,6 +37,10 @@ function convertQuillDeltaToPlainText(service, delta) {
|
|
|
32
37
|
return value.html;
|
|
33
38
|
if (type === "img")
|
|
34
39
|
return "";
|
|
40
|
+
if (type === "video-plugin")
|
|
41
|
+
return "";
|
|
42
|
+
if (type === "internal-link-plugin")
|
|
43
|
+
return "";
|
|
35
44
|
service.logger.warn(`Invalid blot '${type}'`);
|
|
36
45
|
return "";
|
|
37
46
|
});
|
|
@@ -92,11 +101,18 @@ async function imgBlotProcessing(service, value, options) {
|
|
|
92
101
|
}
|
|
93
102
|
function preprocessDelta(ops) {
|
|
94
103
|
for (const op of ops) {
|
|
95
|
-
if (!op.insert || !op.attributes
|
|
104
|
+
if (!op.insert || !op.attributes)
|
|
96
105
|
continue;
|
|
97
|
-
op.
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
if (op.attributes?.obfuscate) {
|
|
107
|
+
op.insert = {
|
|
108
|
+
obfuscate: op.insert,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
else if (op.attributes?.["internal-link-plugin"]) {
|
|
112
|
+
op.insert = {
|
|
113
|
+
"internal-link-plugin": op.attributes?.["internal-link-plugin"],
|
|
114
|
+
};
|
|
115
|
+
}
|
|
100
116
|
}
|
|
101
117
|
}
|
|
102
118
|
function obfuscateBlotProcessing(value, inlineAttributes) {
|
|
@@ -132,3 +148,25 @@ function formatObfuscateAsALink(val) {
|
|
|
132
148
|
return "tel";
|
|
133
149
|
throw new Error(`invalid link-type '${val}'`);
|
|
134
150
|
}
|
|
151
|
+
function videoPluginBlotProcessing(_service, value, _options) {
|
|
152
|
+
const videoId = (0, data_formatters_lib_1.strValOrUndef)(value);
|
|
153
|
+
if (!videoId)
|
|
154
|
+
return "";
|
|
155
|
+
return `
|
|
156
|
+
<iframe
|
|
157
|
+
width="420"
|
|
158
|
+
height="315"
|
|
159
|
+
src="https://www.youtube.com/embed/${encodeURIComponent(videoId)}"
|
|
160
|
+
></iframe>
|
|
161
|
+
`;
|
|
162
|
+
}
|
|
163
|
+
async function internalLinkPluginBlotProcessing(service, value, options) {
|
|
164
|
+
const documentId = (0, data_formatters_lib_1.strValOrUndef)(value);
|
|
165
|
+
if (!documentId)
|
|
166
|
+
return "";
|
|
167
|
+
const doc = await service.getDocument(documentId);
|
|
168
|
+
if (!doc)
|
|
169
|
+
return "";
|
|
170
|
+
const url = await doc.getUrl({ absoluteUrl: !!options?.absoluteUrls });
|
|
171
|
+
return `<a class="InternalLink" href="${url}">${(0, data_formatters_lib_1.strValOrUndef)(doc.title)}</a>`;
|
|
172
|
+
}
|