@paroicms/quill-editor-plugin 1.39.0 → 1.41.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/backend/dist/{plugin.js → index.js} +8 -11
- package/backend/dist/normalize-typography-in-delta.js +24 -0
- package/frontend/dist/quill-editor-plugin.mjs +1 -1
- package/package.json +11 -24
- package/site-schema-lib/field-lib.site-schema.json +4 -0
- package/backend/dist/format-texts-in-delta.js +0 -15
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
import { isJsonFieldValue, isObj } from "@paroicms/public-anywhere-lib";
|
|
2
|
-
import { escapeHtml, makeStylesheetLinkAsyncTag,
|
|
2
|
+
import { escapeHtml, makeStylesheetLinkAsyncTag, } from "@paroicms/public-server-lib";
|
|
3
|
+
import { esmDirName, extractPackageNameAndVersionSync } from "@paroicms/script-lib";
|
|
3
4
|
import { type } from "arktype";
|
|
4
|
-
import { readFileSync } from "node:fs";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
|
-
import {
|
|
6
|
+
import { normalizeTypographyInQuillDelta } from "./normalize-typography-in-delta.js";
|
|
7
7
|
import { convertQuillDeltaToHtml, convertQuillDeltaToPlainText } from "./quill-delta.js";
|
|
8
8
|
const MediaIdQueryAT = type({
|
|
9
9
|
"mediaId?": "string|undefined",
|
|
10
10
|
"+": "reject",
|
|
11
11
|
});
|
|
12
|
-
const projectDir =
|
|
12
|
+
const projectDir = dirname(esmDirName(import.meta.url));
|
|
13
13
|
const packageDir = dirname(projectDir);
|
|
14
|
-
const { name: pluginName, version } =
|
|
15
|
-
name: "string",
|
|
16
|
-
version: "string",
|
|
17
|
-
"+": "ignore",
|
|
18
|
-
}).assert(JSON.parse(readFileSync(join(packageDir, "package.json"), "utf-8")));
|
|
14
|
+
const { name: pluginName, version } = extractPackageNameAndVersionSync(packageDir);
|
|
19
15
|
const plugin = {
|
|
20
16
|
version,
|
|
21
|
-
slug: "quill-editor",
|
|
22
17
|
siteInit(service) {
|
|
23
18
|
service.setPublicAssetsDirectory(join(packageDir, "frontend", "dist"));
|
|
24
19
|
service.setAdminUiAssetsDirectory(join(packageDir, "admin-ui-plugin", "dist"));
|
|
@@ -41,9 +36,11 @@ const plugin = {
|
|
|
41
36
|
const { fieldType, language } = options;
|
|
42
37
|
if (fieldType.pluginName !== pluginName)
|
|
43
38
|
return value;
|
|
39
|
+
if (fieldType.dataType !== "json" || !fieldType.normalizeTypography)
|
|
40
|
+
return value;
|
|
44
41
|
if (!isJsonFieldValue(value) || !isObj(value.j) || !Array.isArray(value.j.ops))
|
|
45
42
|
return value;
|
|
46
|
-
const newDelta = await
|
|
43
|
+
const newDelta = await normalizeTypographyInQuillDelta(service, value.j, language);
|
|
47
44
|
return {
|
|
48
45
|
j: newDelta,
|
|
49
46
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isPromise } from "node:util/types";
|
|
2
|
+
export async function normalizeTypographyInQuillDelta(service, delta, language) {
|
|
3
|
+
const processedOps = await normalizeOpsSequentially(service, delta.ops, language);
|
|
4
|
+
return { ops: processedOps };
|
|
5
|
+
}
|
|
6
|
+
async function normalizeOpsSequentially(service, ops, language) {
|
|
7
|
+
const processedOps = [];
|
|
8
|
+
for (const op of ops) {
|
|
9
|
+
if (typeof op.insert !== "string") {
|
|
10
|
+
processedOps.push(op);
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
const result = service.executeHook("normalizeTypography", {
|
|
14
|
+
value: op.insert,
|
|
15
|
+
options: { language },
|
|
16
|
+
});
|
|
17
|
+
const formattedText = isPromise(result) ? await result : result;
|
|
18
|
+
processedOps.push({
|
|
19
|
+
...op,
|
|
20
|
+
insert: formattedText ?? op.insert,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return processedOps;
|
|
24
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{delegateEvents as $,template as w,setAttribute as c,effect as Z}from"https://esm.sh/solid-js@1.9.7/web";function k(o){let e=o;const t=e.indexOf("?");t!==-1&&(e=e.substring(0,t));const r=e.indexOf("#");r!==-1&&(e=e.substring(0,r));const n=e.lastIndexOf("/");return n===-1?void 0:e.slice(0,n)}const
|
|
1
|
+
import{delegateEvents as $,template as w,setAttribute as c,effect as Z}from"https://esm.sh/solid-js@1.9.7/web";function k(o){let e=o;const t=e.indexOf("?");t!==-1&&(e=e.substring(0,t));const r=e.indexOf("#");r!==-1&&(e=e.substring(0,r));const n=e.lastIndexOf("/");return n===-1?void 0:e.slice(0,n)}const b=k(import.meta.url),E="/api/plugin/quill-editor-plugin",P=E;var V=w('<div class=PaZoomableViewer><button type=button class="PaZoomableViewer-closeButton PaButton"><img alt=⨯ width=30 height=30></button><div class=PaZoomableViewer-spinner>'),x=w('<div class=PaZoomableViewer><button type=button class="PaZoomableViewer-closeButton PaButton"><img alt=⨯ width=30 height=30></button><img class=PaZoomableViewer-img alt>');function L(){const o=document.querySelectorAll("[data-zoomable]");for(const e of o){if(!(e instanceof HTMLElement))continue;const t=e.dataset.zoomable?.trim();t&&C(e,{mediaId:t})}}function C(o,{mediaId:e}){o.classList.add("PaZoomable"),o.setAttribute("tabindex","0"),o.addEventListener("click",(async t=>{t.preventDefault(),await _(e)}))}async function _(o){const e=document.body,t=(()=>{var i=V(),s=i.firstChild,l=s.firstChild;return s.$$click=n,c(l,"src",`${b}/cross.svg`),i})();function r(i){i.key==="Escape"&&n()}function n(){t.remove(),e.removeEventListener("keyup",r)}e.addEventListener("keyup",r),e.appendChild(t);try{let i=function(d){d.key==="Escape"&&s()},s=function(){p.remove(),e.removeEventListener("keyup",i)};const l=await fetch(`${P}/zoom-image?mediaId=${encodeURIComponent(o)}`);if(!l.ok){console.error("Failed to fetch zoom image:",l.statusText),n();return}const m=await l.json();n();const p=(()=>{var d=x(),u=d.firstChild,y=u.firstChild,f=u.nextSibling;return u.$$click=s,c(y,"src",`${b}/cross.svg`),Z((a=>{var h=m.url,v=m.width,g=m.height;return h!==a.e&&c(f,"src",a.e=h),v!==a.t&&c(f,"width",a.t=v),g!==a.a&&c(f,"height",a.a=g),a}),{e:void 0,t:void 0,a:void 0}),d})();e.addEventListener("keyup",i),e.appendChild(p)}catch(i){console.error("Error fetching zoom image:",i),n()}}$(["click"]);L();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paroicms/quill-editor-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.41.0",
|
|
4
4
|
"description": "Quill Editor plugin for ParoiCMS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"paroicms",
|
|
@@ -17,20 +17,18 @@
|
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"scripts": {
|
|
19
19
|
"dev:admin-ui": "(cd admin-ui-plugin && vite)",
|
|
20
|
-
"build": "npm run build:backend && npm run build:admin-ui && npm run build:
|
|
20
|
+
"build": "npm run build:backend && npm run build:admin-ui && npm run build:frontend",
|
|
21
21
|
"build:backend": "(cd backend && tsc)",
|
|
22
|
+
"build:admin-ui": "(cd admin-ui-plugin && npm run build)",
|
|
22
23
|
"build:backend:watch": "(cd backend && tsc --watch --preserveWatchOutput)",
|
|
23
|
-
"build:
|
|
24
|
-
"
|
|
25
|
-
"build:
|
|
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)",
|
|
24
|
+
"build:frontend": "(cd frontend && npm run build)",
|
|
25
|
+
"build:frontend:watch": "(cd frontend && npm run build:watch)",
|
|
26
|
+
"build:admin-ui:watch": "(cd admin-ui-plugin && npm run build:watch)",
|
|
30
27
|
"clear": "rimraf backend/dist/* frontend/dist/* admin-ui-plugin/dist/*"
|
|
31
28
|
},
|
|
32
29
|
"dependencies": {
|
|
33
30
|
"@paroi/quill-delta-to-html": "~0.12.3",
|
|
31
|
+
"@paroicms/script-lib": "0.2.0",
|
|
34
32
|
"arktype": "~2.1.20"
|
|
35
33
|
},
|
|
36
34
|
"peerDependencies": {
|
|
@@ -38,25 +36,14 @@
|
|
|
38
36
|
"@paroicms/public-server-lib": "0"
|
|
39
37
|
},
|
|
40
38
|
"devDependencies": {
|
|
41
|
-
"@paroicms/public-
|
|
42
|
-
"@paroicms/public-
|
|
43
|
-
"@paroicms/public-server-lib": "0.41.0",
|
|
44
|
-
"@solid-primitives/i18n": "~2.2.1",
|
|
39
|
+
"@paroicms/public-anywhere-lib": "0.34.0",
|
|
40
|
+
"@paroicms/public-server-lib": "0.43.0",
|
|
45
41
|
"@types/node": "~24.0.1",
|
|
46
|
-
"highlight.js": "~11.11.1",
|
|
47
|
-
"quill": "~2.0.3",
|
|
48
|
-
"quill-image-drop-and-paste": "~2.0.1",
|
|
49
42
|
"rimraf": "~6.0.1",
|
|
50
|
-
"
|
|
51
|
-
"solid-devtools": "~0.34.0",
|
|
52
|
-
"solid-js": "1.9.7",
|
|
53
|
-
"terser": "~5.42.0",
|
|
54
|
-
"typescript": "~5.8.3",
|
|
55
|
-
"vite": "~6.3.5",
|
|
56
|
-
"vite-plugin-solid": "~2.11.6"
|
|
43
|
+
"typescript": "~5.8.3"
|
|
57
44
|
},
|
|
58
45
|
"type": "module",
|
|
59
|
-
"main": "backend/dist/
|
|
46
|
+
"main": "backend/dist/index.js",
|
|
60
47
|
"types": "types/html-editor-public-types.d.ts",
|
|
61
48
|
"files": [
|
|
62
49
|
"backend/dist",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"storedAs": "text",
|
|
9
9
|
"dataType": "json",
|
|
10
10
|
"renderAs": "html",
|
|
11
|
+
"normalizeTypography": true,
|
|
11
12
|
"useAsExcerpt": 1,
|
|
12
13
|
"adminUi": {
|
|
13
14
|
"editorRows": 4
|
|
@@ -20,6 +21,7 @@
|
|
|
20
21
|
"storedAs": "text",
|
|
21
22
|
"dataType": "json",
|
|
22
23
|
"renderAs": "html",
|
|
24
|
+
"normalizeTypography": true,
|
|
23
25
|
"withGallery": true,
|
|
24
26
|
"useAsExcerpt": 2,
|
|
25
27
|
"useAsDefaultImage": 2,
|
|
@@ -31,6 +33,7 @@
|
|
|
31
33
|
"storedAs": "text",
|
|
32
34
|
"dataType": "json",
|
|
33
35
|
"renderAs": "html",
|
|
36
|
+
"normalizeTypography": true,
|
|
34
37
|
"useAsExcerpt": 1,
|
|
35
38
|
"adminUi": {
|
|
36
39
|
"editorRows": 8
|
|
@@ -43,6 +46,7 @@
|
|
|
43
46
|
"storedAs": "text",
|
|
44
47
|
"dataType": "json",
|
|
45
48
|
"renderAs": "html",
|
|
49
|
+
"normalizeTypography": true,
|
|
46
50
|
"adminUi": {
|
|
47
51
|
"editorRows": 4
|
|
48
52
|
},
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export async function formatTextsInQuillDelta(service, delta, language) {
|
|
2
|
-
const processedOps = await Promise.all(delta.ops.map(async (op) => {
|
|
3
|
-
if (typeof op.insert !== "string")
|
|
4
|
-
return op;
|
|
5
|
-
const formattedText = await service.executeHook("textFormatting", {
|
|
6
|
-
value: op.insert,
|
|
7
|
-
options: { language },
|
|
8
|
-
});
|
|
9
|
-
return {
|
|
10
|
-
...op,
|
|
11
|
-
insert: formattedText ?? op.insert,
|
|
12
|
-
};
|
|
13
|
-
}));
|
|
14
|
-
return { ops: processedOps };
|
|
15
|
-
}
|