@paroicms/quill-editor-plugin 1.39.0 → 1.40.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.
@@ -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
+ }
@@ -3,7 +3,7 @@ import { escapeHtml, makeStylesheetLinkAsyncTag, resolveModuleDirectory, } from
3
3
  import { type } from "arktype";
4
4
  import { readFileSync } from "node:fs";
5
5
  import { dirname, join } from "node:path";
6
- import { formatTextsInQuillDelta } from "./format-texts-in-delta.js";
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",
@@ -41,9 +41,11 @@ const plugin = {
41
41
  const { fieldType, language } = options;
42
42
  if (fieldType.pluginName !== pluginName)
43
43
  return value;
44
+ if (fieldType.dataType !== "json" || !fieldType.normalizeTypography)
45
+ return value;
44
46
  if (!isJsonFieldValue(value) || !isObj(value.j) || !Array.isArray(value.j.ops))
45
47
  return value;
46
- const newDelta = await formatTextsInQuillDelta(service, value.j, language);
48
+ const newDelta = await normalizeTypographyInQuillDelta(service, value.j, language);
47
49
  return {
48
50
  j: newDelta,
49
51
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paroicms/quill-editor-plugin",
3
- "version": "1.39.0",
3
+ "version": "1.40.0",
4
4
  "description": "Quill Editor plugin for ParoiCMS",
5
5
  "keywords": [
6
6
  "paroicms",
@@ -17,16 +17,13 @@
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:public",
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: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)",
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": {
@@ -38,22 +35,11 @@
38
35
  "@paroicms/public-server-lib": "0"
39
36
  },
40
37
  "devDependencies": {
41
- "@paroicms/public-admin-ui-lib": "0.27.2",
42
- "@paroicms/public-anywhere-lib": "0.32.0",
43
- "@paroicms/public-server-lib": "0.41.0",
44
- "@solid-primitives/i18n": "~2.2.1",
38
+ "@paroicms/public-anywhere-lib": "0.33.0",
39
+ "@paroicms/public-server-lib": "0.42.0",
45
40
  "@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
41
  "rimraf": "~6.0.1",
50
- "sass": "~1.89.2",
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"
42
+ "typescript": "~5.8.3"
57
43
  },
58
44
  "type": "module",
59
45
  "main": "backend/dist/plugin.js",
@@ -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
- }