@paroicms/quill-editor-plugin 1.34.0 → 1.36.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.
- package/{bo-front/dist/bo-plugin.mjs → admin-ui-plugin/dist/admin-ui-plugin.mjs} +1 -1
- package/backend/dist/formatters.js +17 -16
- package/backend/dist/plugin.js +13 -9
- package/backend/dist/quill-delta.js +17 -11
- package/package.json +19 -19
- package/site-schema-lib/field-lib.site-schema.json +4 -4
- /package/{bo-front/dist/bo-plugin.css → admin-ui-plugin/dist/admin-ui-plugin.css} +0 -0
- /package/{public-front → frontend}/dist/cross.svg +0 -0
- /package/{public-front/dist/public-front-plugin.css → frontend/dist/quill-editor-plugin.css} +0 -0
- /package/{public-front/dist/public-front-plugin.mjs → frontend/dist/quill-editor-plugin.mjs} +0 -0
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { boolValOrUndef, objVal, strVal, strValOrUndef } from "@paroi/data-formatters-lib";
|
|
2
1
|
import { isResizeRule } from "@paroicms/public-anywhere-lib";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
import { type } from "arktype";
|
|
3
|
+
export const MediaBlotInputAT = type({
|
|
4
|
+
mediaId: "string",
|
|
5
|
+
resizeRule: "string",
|
|
6
|
+
"align?": '"center"|"left"|"right"|undefined|null',
|
|
7
|
+
"href?": "string|undefined|null",
|
|
8
|
+
"zoomable?": "boolean|undefined|null",
|
|
9
|
+
"+": "reject",
|
|
10
|
+
}).pipe((data) => {
|
|
11
|
+
if (!isResizeRule(data.resizeRule))
|
|
12
|
+
throw new Error(`Invalid resizeRule: ${data.resizeRule}`);
|
|
12
13
|
return {
|
|
13
|
-
mediaId:
|
|
14
|
-
resizeRule,
|
|
15
|
-
align: align,
|
|
16
|
-
href:
|
|
17
|
-
zoomable:
|
|
14
|
+
mediaId: data.mediaId,
|
|
15
|
+
resizeRule: data.resizeRule,
|
|
16
|
+
align: data.align ?? undefined,
|
|
17
|
+
href: data.href ?? undefined,
|
|
18
|
+
zoomable: data.zoomable ?? undefined,
|
|
18
19
|
};
|
|
19
|
-
}
|
|
20
|
+
});
|
package/backend/dist/plugin.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isJsonFieldValue } from "@paroicms/public-anywhere-lib";
|
|
1
|
+
import { isJsonFieldValue, isObj } from "@paroicms/public-anywhere-lib";
|
|
3
2
|
import { escapeHtml, makeStylesheetLinkAsyncTag, resolveModuleDirectory, } from "@paroicms/public-server-lib";
|
|
3
|
+
import { type } from "arktype";
|
|
4
4
|
import { readFileSync } from "node:fs";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
import { convertQuillDeltaToHtml, convertQuillDeltaToPlainText } from "./quill-delta.js";
|
|
7
|
+
const MediaIdQueryAT = type({
|
|
8
|
+
"mediaId?": "string|undefined",
|
|
9
|
+
"+": "reject",
|
|
10
|
+
});
|
|
7
11
|
const projectDir = resolveModuleDirectory(import.meta.url, { parent: true });
|
|
8
12
|
const packageDir = dirname(projectDir);
|
|
9
|
-
const version =
|
|
13
|
+
const version = type({ version: "string", "+": "ignore" }).assert(JSON.parse(readFileSync(join(packageDir, "package.json"), "utf-8"))).version;
|
|
10
14
|
const plugin = {
|
|
11
15
|
version,
|
|
12
16
|
slug: "quill-editor",
|
|
13
17
|
siteInit(service) {
|
|
14
|
-
service.setPublicAssetsDirectory(join(packageDir, "
|
|
15
|
-
service.
|
|
18
|
+
service.setPublicAssetsDirectory(join(packageDir, "frontend", "dist"));
|
|
19
|
+
service.setAdminUiAssetsDirectory(join(packageDir, "admin-ui-plugin", "dist"));
|
|
16
20
|
service.registerSiteSchemaLibrary(join(packageDir, "site-schema-lib"));
|
|
17
21
|
service.registerFieldPreprocessor((service, value, options) => {
|
|
18
22
|
if (!isJsonFieldValue(value))
|
|
@@ -29,14 +33,14 @@ const plugin = {
|
|
|
29
33
|
if (!state.get("paQuillEditor:html"))
|
|
30
34
|
return;
|
|
31
35
|
const tags = [
|
|
32
|
-
makeStylesheetLinkAsyncTag(`${service.pluginAssetsUrl}/
|
|
36
|
+
makeStylesheetLinkAsyncTag(`${service.pluginAssetsUrl}/quill-editor-plugin.css`),
|
|
33
37
|
];
|
|
34
38
|
if (state.get("paQuillEditor:zoomable")) {
|
|
35
|
-
tags.push(`<script type="module" src="${escapeHtml(`${service.pluginAssetsUrl}/
|
|
39
|
+
tags.push(`<script type="module" src="${escapeHtml(`${service.pluginAssetsUrl}/quill-editor-plugin.mjs`)}" async></script>`);
|
|
36
40
|
}
|
|
37
41
|
return tags;
|
|
38
42
|
});
|
|
39
|
-
if (service.configuration.
|
|
43
|
+
if (service.configuration.adminUi?.code) {
|
|
40
44
|
service.registerHeadTags(({ state }) => {
|
|
41
45
|
if (!state.get("paQuillEditor:html"))
|
|
42
46
|
return;
|
|
@@ -80,7 +84,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
80
84
|
service.setPublicApiHandler(async (service, httpContext, relativePath) => {
|
|
81
85
|
const { req, res } = httpContext;
|
|
82
86
|
if (relativePath === "/zoom-image") {
|
|
83
|
-
const mediaId =
|
|
87
|
+
const { mediaId } = MediaIdQueryAT.assert(req.query);
|
|
84
88
|
if (!mediaId) {
|
|
85
89
|
res.append("Content-Type", "application/json; charset=utf-8");
|
|
86
90
|
res.status(400).send({ error: "mediaId parameter is required" });
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { strVal, strValOrUndef } from "@paroi/data-formatters-lib";
|
|
2
1
|
import { QuillDeltaToHtmlAsyncConverter, QuillDeltaToHtmlConverter, } from "@paroi/quill-delta-to-html";
|
|
3
2
|
import { escapeHtml, generateObfuscatedHtml, obfuscateAsHtmlLink, stripHtmlTags, } from "@paroicms/public-server-lib";
|
|
4
|
-
import {
|
|
3
|
+
import { type } from "arktype";
|
|
4
|
+
import { MediaBlotInputAT } from "./formatters.js";
|
|
5
5
|
import { shouldOpenInBlankTab } from "./url-blank-tab.js";
|
|
6
|
+
const ObfuscateAttributesAT = type({
|
|
7
|
+
obfuscate: "string",
|
|
8
|
+
"+": "reject",
|
|
9
|
+
});
|
|
10
|
+
const StringOrUndefinedAT = type("string|undefined|null").pipe((data) => data ?? undefined);
|
|
6
11
|
export async function convertQuillDeltaToHtml(service, delta, options) {
|
|
7
12
|
const { pluginService } = service;
|
|
8
13
|
const ops = delta.ops;
|
|
@@ -51,7 +56,7 @@ export function convertQuillDeltaToPlainText(service, delta) {
|
|
|
51
56
|
}
|
|
52
57
|
async function mediaBlotProcessing(service, obj, options) {
|
|
53
58
|
const { useImage, pluginService } = service;
|
|
54
|
-
const value =
|
|
59
|
+
const value = MediaBlotInputAT.assert(obj);
|
|
55
60
|
const media = await pluginService.getMedia({ mediaId: value.mediaId }, { withAttachedData: { language: service.language } });
|
|
56
61
|
if (media?.kind !== "image") {
|
|
57
62
|
pluginService.logger.warn(`media '${value.mediaId}' is not an image`);
|
|
@@ -102,16 +107,17 @@ export function preprocessDelta(ops) {
|
|
|
102
107
|
}
|
|
103
108
|
}
|
|
104
109
|
function obfuscateBlotProcessing(value, inlineAttributes) {
|
|
105
|
-
const
|
|
106
|
-
if (!
|
|
110
|
+
const textValue = StringOrUndefinedAT.assert(value);
|
|
111
|
+
if (!textValue)
|
|
107
112
|
return "";
|
|
108
|
-
const
|
|
113
|
+
const { obfuscate } = ObfuscateAttributesAT.assert(inlineAttributes);
|
|
114
|
+
const asALink = formatObfuscateAsALink(obfuscate);
|
|
109
115
|
let obfuscatedVal;
|
|
110
116
|
if (asALink === "mailto" || asALink === "tel") {
|
|
111
|
-
obfuscatedVal = obfuscateAsHtmlLink(
|
|
117
|
+
obfuscatedVal = obfuscateAsHtmlLink(textValue);
|
|
112
118
|
}
|
|
113
119
|
else {
|
|
114
|
-
obfuscatedVal = generateObfuscatedHtml(
|
|
120
|
+
obfuscatedVal = generateObfuscatedHtml(textValue);
|
|
115
121
|
}
|
|
116
122
|
let result = obfuscatedVal;
|
|
117
123
|
if (inlineAttributes.strike) {
|
|
@@ -135,7 +141,7 @@ function formatObfuscateAsALink(val) {
|
|
|
135
141
|
throw new Error(`invalid link-type '${val}'`);
|
|
136
142
|
}
|
|
137
143
|
function videoPluginBlotProcessing(_service, value, _options) {
|
|
138
|
-
const videoId =
|
|
144
|
+
const videoId = StringOrUndefinedAT.assert(value);
|
|
139
145
|
if (!videoId)
|
|
140
146
|
return "";
|
|
141
147
|
return `
|
|
@@ -147,12 +153,12 @@ function videoPluginBlotProcessing(_service, value, _options) {
|
|
|
147
153
|
`;
|
|
148
154
|
}
|
|
149
155
|
async function internalLinkPluginBlotProcessing(service, value, options) {
|
|
150
|
-
const documentId =
|
|
156
|
+
const documentId = StringOrUndefinedAT.assert(value);
|
|
151
157
|
if (!documentId)
|
|
152
158
|
return "";
|
|
153
159
|
const doc = await service.getDocument(documentId);
|
|
154
160
|
if (!doc)
|
|
155
161
|
return "";
|
|
156
162
|
const url = await doc.getUrl({ absoluteUrl: !!options?.absoluteUrls });
|
|
157
|
-
return `<a class="InternalLink" href="${url}">${
|
|
163
|
+
return `<a class="InternalLink" href="${url}">${StringOrUndefinedAT.assert(doc.title) ?? ""}</a>`;
|
|
158
164
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paroicms/quill-editor-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.36.0",
|
|
4
4
|
"description": "Quill Editor plugin for ParoiCMS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"paroicms",
|
|
@@ -16,31 +16,31 @@
|
|
|
16
16
|
"author": "Paroi Team",
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"scripts": {
|
|
19
|
-
"dev:
|
|
20
|
-
"build": "npm run build:backend && npm run build:
|
|
19
|
+
"dev:admin-ui": "(cd admin-ui-plugin && vite)",
|
|
20
|
+
"build": "npm run build:backend && npm run build:admin-ui && npm run build:public",
|
|
21
21
|
"build:backend": "(cd backend && tsc)",
|
|
22
22
|
"build:backend:watch": "(cd backend && tsc --watch --preserveWatchOutput)",
|
|
23
|
-
"build:
|
|
24
|
-
"minify:
|
|
25
|
-
"build:public": "(cd
|
|
26
|
-
"minify:public": "terser
|
|
27
|
-
"build:public:watch": "(cd
|
|
28
|
-
"build:
|
|
29
|
-
"bo:tsc": "(cd
|
|
30
|
-
"clear": "rimraf backend/dist/*
|
|
23
|
+
"build:admin-ui": "(cd admin-ui-plugin && tsc && vite build && npm run minify:admin-ui)",
|
|
24
|
+
"minify:admin-ui": "terser admin-ui-plugin/dist/admin-ui-plugin.mjs --output admin-ui-plugin/dist/admin-ui-plugin.mjs",
|
|
25
|
+
"build:public": "(cd frontend && tsc && vite build && npm run minify:public)",
|
|
26
|
+
"minify:public": "terser frontend/dist/quill-editor-plugin.mjs --output frontend/dist/quill-editor-plugin.mjs",
|
|
27
|
+
"build:public:watch": "(cd frontend && tsc && vite build --watch)",
|
|
28
|
+
"build:admin-ui:watch": "(cd admin-ui-plugin && vite build --watch)",
|
|
29
|
+
"bo:tsc": "(cd admin-ui-plugin && tsc)",
|
|
30
|
+
"clear": "rimraf backend/dist/* frontend/dist/* admin-ui-plugin/dist/*"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@paroi/quill-delta-to-html": "~0.12.3",
|
|
34
|
-
"
|
|
34
|
+
"arktype": "~2.1.20"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@paroicms/public-anywhere-lib": "0",
|
|
38
38
|
"@paroicms/public-server-lib": "0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@paroicms/public-
|
|
42
|
-
"@paroicms/public-
|
|
43
|
-
"@paroicms/public-server-lib": "0.
|
|
41
|
+
"@paroicms/public-admin-ui-lib": "0.26.0",
|
|
42
|
+
"@paroicms/public-anywhere-lib": "0.25.0",
|
|
43
|
+
"@paroicms/public-server-lib": "0.37.0",
|
|
44
44
|
"@solid-primitives/i18n": "~2.2.1",
|
|
45
45
|
"@types/node": "~24.0.1",
|
|
46
46
|
"highlight.js": "~11.11.1",
|
|
@@ -50,18 +50,18 @@
|
|
|
50
50
|
"sass": "~1.89.2",
|
|
51
51
|
"solid-devtools": "~0.34.0",
|
|
52
52
|
"solid-js": "1.9.7",
|
|
53
|
+
"terser": "~5.42.0",
|
|
53
54
|
"typescript": "~5.8.3",
|
|
54
55
|
"vite": "~6.3.5",
|
|
55
|
-
"vite-plugin-solid": "~2.11.6"
|
|
56
|
-
"terser": "~5.42.0"
|
|
56
|
+
"vite-plugin-solid": "~2.11.6"
|
|
57
57
|
},
|
|
58
58
|
"type": "module",
|
|
59
59
|
"main": "backend/dist/plugin.js",
|
|
60
60
|
"types": "types/html-editor-public-types.d.ts",
|
|
61
61
|
"files": [
|
|
62
62
|
"backend/dist",
|
|
63
|
-
"
|
|
64
|
-
"
|
|
63
|
+
"frontend/dist",
|
|
64
|
+
"admin-ui-plugin/dist",
|
|
65
65
|
"site-schema-lib",
|
|
66
66
|
"types"
|
|
67
67
|
]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
2
|
+
"ParoiCMSSiteSchemaFormatVersion": "9",
|
|
3
3
|
"languages": ["en", "fr"],
|
|
4
4
|
"fieldTypes": [
|
|
5
5
|
{
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"dataType": "json",
|
|
10
10
|
"renderAs": "html",
|
|
11
11
|
"useAsExcerpt": 1,
|
|
12
|
-
"
|
|
12
|
+
"adminUi": {
|
|
13
13
|
"editorRows": 4
|
|
14
14
|
},
|
|
15
15
|
"plugin": "@paroicms/quill-editor-plugin"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dataType": "json",
|
|
33
33
|
"renderAs": "html",
|
|
34
34
|
"useAsExcerpt": 1,
|
|
35
|
-
"
|
|
35
|
+
"adminUi": {
|
|
36
36
|
"editorRows": 8
|
|
37
37
|
},
|
|
38
38
|
"plugin": "@paroicms/quill-editor-plugin"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"storedAs": "text",
|
|
44
44
|
"dataType": "json",
|
|
45
45
|
"renderAs": "html",
|
|
46
|
-
"
|
|
46
|
+
"adminUi": {
|
|
47
47
|
"editorRows": 4
|
|
48
48
|
},
|
|
49
49
|
"plugin": "@paroicms/quill-editor-plugin"
|
|
File without changes
|
|
File without changes
|
/package/{public-front/dist/public-front-plugin.css → frontend/dist/quill-editor-plugin.css}
RENAMED
|
File without changes
|
/package/{public-front/dist/public-front-plugin.mjs → frontend/dist/quill-editor-plugin.mjs}
RENAMED
|
File without changes
|