@paroicms/quill-editor-plugin 1.4.0 → 1.6.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,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.plugin = void 0;
4
+ const data_formatters_lib_1 = require("@paroi/data-formatters-lib");
5
+ const node_path_1 = require("node:path");
6
+ const quill_delta_1 = require("./quill-delta");
7
+ const projectDir = (0, node_path_1.dirname)(__dirname);
8
+ const packageDir = (0, node_path_1.dirname)(projectDir);
9
+ const version = (0, data_formatters_lib_1.strVal)(require((0, node_path_1.join)(packageDir, "package.json")).version);
10
+ exports.plugin = {
11
+ version,
12
+ siteInit(api) {
13
+ api.registerSiteSchemaLibrary((0, node_path_1.join)(packageDir, "site-schema-lib"));
14
+ api.setBoAssetsDirectory((0, node_path_1.join)(packageDir, "bo-front", "dist"));
15
+ api.registerFieldPreprocessor("quillDelta", (ctx, value, options) => {
16
+ if (value !== undefined &&
17
+ value !== null &&
18
+ typeof value === "object" &&
19
+ "delta" in value &&
20
+ value.delta) {
21
+ const delta = value.delta;
22
+ if (options.outputType === "plainText")
23
+ return (0, quill_delta_1.convertQuillDeltaToPlainText)(ctx, delta);
24
+ return (0, quill_delta_1.convertQuillDeltaToHtml)(ctx, delta, options);
25
+ }
26
+ });
27
+ },
28
+ };
@@ -6,7 +6,6 @@ const data_formatters_lib_1 = require("@paroi/data-formatters-lib");
6
6
  const quill_delta_to_html_1 = require("@paroi/quill-delta-to-html");
7
7
  const public_server_lib_1 = require("@paroicms/public-server-lib");
8
8
  async function convertQuillDeltaToHtml(ctx, delta, options) {
9
- const { siteContext, useImage } = ctx;
10
9
  const ops = delta.ops;
11
10
  preprocessDelta(ops);
12
11
  const converter = new quill_delta_to_html_1.QuillDeltaToHtmlAsyncConverter(ops, {
@@ -19,13 +18,13 @@ async function convertQuillDeltaToHtml(ctx, delta, options) {
19
18
  if (type === "obfuscate")
20
19
  return obfuscateBlotProcessing(value, customOp.attributes);
21
20
  if (type === "img")
22
- return imgBlotProcessing(siteContext, useImage, value, options);
23
- siteContext.siteLog.warn(`Invalid blot '${type}'`);
21
+ return imgBlotProcessing(ctx, value, options);
22
+ ctx.siteContext.siteLog.warn(`Invalid blot '${type}'`);
24
23
  return "";
25
24
  });
26
25
  return await converter.convert();
27
26
  }
28
- function convertQuillDeltaToPlainText(delta, siteContext) {
27
+ function convertQuillDeltaToPlainText(ctx, delta) {
29
28
  const converter = new quill_delta_to_html_1.QuillDeltaToHtmlConverter(delta.ops);
30
29
  converter.renderCustomWith((customOp) => {
31
30
  const { type, value } = customOp.insert;
@@ -33,13 +32,14 @@ function convertQuillDeltaToPlainText(delta, siteContext) {
33
32
  return value.html;
34
33
  if (type === "img")
35
34
  return "";
36
- siteContext.siteLog.warn(`Invalid blot '${type}'`);
35
+ ctx.siteContext.siteLog.warn(`Invalid blot '${type}'`);
37
36
  return "";
38
37
  });
39
38
  const html = converter.convert();
40
39
  return (0, public_server_lib_1.stripHtmlTags)(html, { blockSeparator: " – " });
41
40
  }
42
- async function imgBlotProcessing(siteContext, useImage, value, options) {
41
+ async function imgBlotProcessing(ctx, value, options) {
42
+ const { siteContext, useImage } = ctx;
43
43
  const uid = (0, data_formatters_lib_1.strValOrUndef)(value.uid, { varName: "uid" });
44
44
  const variant = (0, data_formatters_lib_1.strValOrUndef)(value.variant, { varName: "variant" });
45
45
  const align = (0, data_formatters_lib_1.strValOrUndef)(value.align);
@@ -55,13 +55,13 @@ async function imgBlotProcessing(siteContext, useImage, value, options) {
55
55
  imageUid: uid,
56
56
  size: (0, public_server_lib_1.applyRatioToImageSize)("x1900x", siteContext.themeConf.pixelRatio),
57
57
  });
58
- dataZoomSrc = options?.absoluteImageUrls
58
+ dataZoomSrc = options?.absoluteUrls
59
59
  ? (0, public_server_lib_1.toAbsoluteUrl)(siteContext, zoomImage.url)
60
60
  : zoomImage.url;
61
61
  }
62
62
  imgAttributes = {
63
63
  dataZoomSrc,
64
- src: options?.absoluteImageUrls ? (0, public_server_lib_1.toAbsoluteUrl)(siteContext, image.url) : image.url,
64
+ src: options?.absoluteUrls ? (0, public_server_lib_1.toAbsoluteUrl)(siteContext, image.url) : image.url,
65
65
  width: Math.round(image.width / siteContext.themeConf.pixelRatio),
66
66
  height: Math.round(image.height / siteContext.themeConf.pixelRatio),
67
67
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@paroicms/quill-editor-plugin",
3
- "version": "1.4.0",
4
- "description": "Quill Editor for ParoiCMS",
3
+ "version": "1.6.0",
4
+ "description": "Quill Editor plugin for ParoiCMS",
5
5
  "keywords": [
6
6
  "paroicms",
7
7
  "quill",
@@ -16,12 +16,11 @@
16
16
  "author": "Paroi Team",
17
17
  "license": "MIT",
18
18
  "scripts": {
19
- "dev": "vite",
20
- "clear": "rimraf bo-dist/*",
21
- "preview": "vite preview",
22
- "build": "npm run build:backend && npm run build:frontend",
23
- "build:backend": "tsc --project tsconfig.backend.json",
24
- "build:frontend": "tsc && vite build"
19
+ "dev:bo": "(cd bo-front && vite)",
20
+ "build": "npm run build:backend && npm run build:bo",
21
+ "build:backend": "(cd backend && tsc)",
22
+ "build:bo": "(cd bo-front && tsc && vite build)",
23
+ "clear": "rimraf backend/dist/* bo-front/dist/*"
25
24
  },
26
25
  "dependencies": {
27
26
  "@paroi/quill-delta-to-html": "~0.12.2",
@@ -33,9 +32,9 @@
33
32
  "@paroicms/public-server-lib": "0"
34
33
  },
35
34
  "devDependencies": {
36
- "@paroicms/public-anywhere-lib": "0.3.0",
37
- "@paroicms/public-front-lib": "0.8.0",
38
- "@paroicms/public-server-lib": "0.8.0",
35
+ "@paroicms/public-anywhere-lib": "0.4.0",
36
+ "@paroicms/public-front-lib": "0.8.1",
37
+ "@paroicms/public-server-lib": "0.10.0",
39
38
  "@solid-primitives/i18n": "~2.1.1",
40
39
  "quill": "~2.0.2",
41
40
  "rimraf": "~6.0.1",
@@ -46,10 +45,10 @@
46
45
  "vite": "~5.2.11",
47
46
  "vite-plugin-solid": "~2.10.2"
48
47
  },
49
- "main": "plugin.cjs",
48
+ "main": "backend/dist/plugin.js",
50
49
  "files": [
51
- "bo-dist",
52
- "dist-backend",
53
- "plugin.cjs"
50
+ "backend/dist",
51
+ "bo-front/dist",
52
+ "site-schema-lib"
54
53
  ]
55
54
  }
@@ -0,0 +1,36 @@
1
+ {
2
+ "version": "3.1",
3
+ "languages": ["en", "fr"],
4
+ "fieldTypes": [
5
+ {
6
+ "name": "leadParagraph",
7
+ "storedOn": "section",
8
+ "storedAs": "text",
9
+ "dataType": "quillDelta",
10
+ "useAsExcerpt": 1,
11
+ "backOffice": {
12
+ "editorRows": 4
13
+ },
14
+ "visibility": ["overview", "feed"],
15
+ "plugin": "@paroicms/quill-editor-plugin"
16
+ },
17
+ {
18
+ "name": "htmlContent",
19
+ "storedOn": "section",
20
+ "storedAs": "text",
21
+ "dataType": "quillDelta",
22
+ "withGallery": true,
23
+ "useAsExcerpt": 2,
24
+ "useAsDefaultImage": 2,
25
+ "visibility": ["overview", "feed"],
26
+ "plugin": "@paroicms/quill-editor-plugin"
27
+ },
28
+ {
29
+ "name": "footerMention",
30
+ "storedOn": "section",
31
+ "storedAs": "text",
32
+ "dataType": "quillDelta",
33
+ "plugin": "@paroicms/quill-editor-plugin"
34
+ }
35
+ ]
36
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "fieldTypes": {
3
+ "leadParagraph": {
4
+ "label": "Lead paragraph"
5
+ },
6
+ "htmlContent": {
7
+ "label": "Content"
8
+ },
9
+ "footerMention": {
10
+ "label": "Footer mention"
11
+ }
12
+ }
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "fieldTypes": {
3
+ "leadParagraph": {
4
+ "label": "Chapeau"
5
+ },
6
+ "htmlContent": {
7
+ "label": "Contenu"
8
+ },
9
+ "footerMention": {
10
+ "label": "Mention de bas de page"
11
+ }
12
+ }
13
+ }
package/plugin.cjs DELETED
@@ -1,19 +0,0 @@
1
- const { join } = require("path");
2
- const { version } = require("./package.json");
3
- const { convertQuillDeltaToHtml, convertQuillDeltaToPlainText } = require("./dist-backend/quill-delta")
4
-
5
- const plugin = {
6
- version,
7
- siteInit(api) {
8
- api.setBoAssetsDirectory(join(__dirname, "bo-dist"));
9
- api.registerFieldProcessor("quillDelta", (ctx, value, options) => {
10
- if (value !== undefined && value !== null && typeof value === "object" && "delta" in value && value.delta) {
11
- const delta = value.delta;
12
- if (options.outputType === "plainText") return convertQuillDeltaToPlainText(delta, ctx.siteContext)
13
- else return convertQuillDeltaToHtml(ctx, delta, options)
14
- } else return undefined
15
- })
16
- }
17
- };
18
-
19
- module.exports = { plugin };
File without changes
File without changes