@paroicms/quill-editor-plugin 1.10.0 → 1.12.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,12 +11,12 @@ const plugin = {
11
11
  siteInit(service) {
12
12
  service.setBoAssetsDirectory((0, node_path_1.join)(packageDir, "bo-front", "dist"));
13
13
  service.registerSiteSchemaLibrary((0, node_path_1.join)(packageDir, "site-schema-lib"));
14
- service.registerFieldPreprocessor("quillDelta", (ctx, value, options) => {
14
+ service.registerFieldPreprocessor("quillDelta", (service, value, options) => {
15
15
  if ((0, data_formatters_lib_1.isObj)(value) && (0, data_formatters_lib_1.isObj)(value.delta)) {
16
16
  const delta = value.delta;
17
17
  if (options.outputType === "plainText")
18
- return (0, quill_delta_1.convertQuillDeltaToPlainText)(ctx, delta);
19
- return (0, quill_delta_1.convertQuillDeltaToHtml)(ctx, delta, options);
18
+ return (0, quill_delta_1.convertQuillDeltaToPlainText)(service, delta);
19
+ return (0, quill_delta_1.convertQuillDeltaToHtml)(service, delta, options);
20
20
  }
21
21
  });
22
22
  if (service.pluginConf.bo?.code) {
@@ -5,7 +5,7 @@ exports.convertQuillDeltaToPlainText = convertQuillDeltaToPlainText;
5
5
  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
- async function convertQuillDeltaToHtml(ctx, delta, options) {
8
+ async function convertQuillDeltaToHtml(service, delta, options) {
9
9
  const ops = delta.ops;
10
10
  preprocessDelta(ops);
11
11
  const converter = new quill_delta_to_html_1.QuillDeltaToHtmlAsyncConverter(ops, {
@@ -18,13 +18,13 @@ async function convertQuillDeltaToHtml(ctx, delta, options) {
18
18
  if (type === "obfuscate")
19
19
  return obfuscateBlotProcessing(value, customOp.attributes);
20
20
  if (type === "img")
21
- return imgBlotProcessing(ctx, value, options);
22
- ctx.siteContext.siteLog.warn(`Invalid blot '${type}'`);
21
+ return imgBlotProcessing(service, value, options);
22
+ service.logger.warn(`Invalid blot '${type}'`);
23
23
  return "";
24
24
  });
25
25
  return await converter.convert();
26
26
  }
27
- function convertQuillDeltaToPlainText(ctx, delta) {
27
+ function convertQuillDeltaToPlainText(service, delta) {
28
28
  const converter = new quill_delta_to_html_1.QuillDeltaToHtmlConverter(delta.ops);
29
29
  converter.renderCustomWith((customOp) => {
30
30
  const { type, value } = customOp.insert;
@@ -32,14 +32,14 @@ function convertQuillDeltaToPlainText(ctx, delta) {
32
32
  return value.html;
33
33
  if (type === "img")
34
34
  return "";
35
- ctx.siteContext.siteLog.warn(`Invalid blot '${type}'`);
35
+ service.logger.warn(`Invalid blot '${type}'`);
36
36
  return "";
37
37
  });
38
38
  const html = converter.convert();
39
39
  return (0, public_server_lib_1.stripHtmlTags)(html, { blockSeparator: " – " });
40
40
  }
41
- async function imgBlotProcessing(ctx, value, options) {
42
- const { siteContext, useImage } = ctx;
41
+ async function imgBlotProcessing(service, value, options) {
42
+ const { themeConf, useImage, logger } = service;
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);
@@ -47,29 +47,27 @@ async function imgBlotProcessing(ctx, value, options) {
47
47
  const hasZoom = zoom !== "none";
48
48
  let imgAttributes;
49
49
  if (uid && variant && (0, public_server_lib_1.isImageSize)(variant)) {
50
- const realSize = (0, public_server_lib_1.applyRatioToImageSize)(variant, siteContext.themeConf.pixelRatio);
50
+ const realSize = (0, public_server_lib_1.applyRatioToImageSize)(variant, themeConf.pixelRatio);
51
51
  const image = await useImage({ size: realSize, imageUid: uid });
52
52
  let dataZoomSrc;
53
53
  if (hasZoom) {
54
54
  const zoomImage = await useImage({
55
55
  imageUid: uid,
56
- size: (0, public_server_lib_1.applyRatioToImageSize)("x1900x", siteContext.themeConf.pixelRatio),
56
+ size: (0, public_server_lib_1.applyRatioToImageSize)("x1900x", themeConf.pixelRatio),
57
57
  });
58
- dataZoomSrc = options?.absoluteUrls
59
- ? (0, public_server_lib_1.toAbsoluteUrl)(siteContext, zoomImage.url)
60
- : zoomImage.url;
58
+ dataZoomSrc = options?.absoluteUrls ? (0, public_server_lib_1.toAbsoluteUrl)(service, zoomImage.url) : zoomImage.url;
61
59
  }
62
60
  imgAttributes = {
63
61
  dataZoomSrc,
64
- src: options?.absoluteUrls ? (0, public_server_lib_1.toAbsoluteUrl)(siteContext, image.url) : image.url,
65
- width: Math.round(image.width / siteContext.themeConf.pixelRatio),
66
- height: Math.round(image.height / siteContext.themeConf.pixelRatio),
62
+ src: options?.absoluteUrls ? (0, public_server_lib_1.toAbsoluteUrl)(service, image.url) : image.url,
63
+ width: Math.round(image.width / themeConf.pixelRatio),
64
+ height: Math.round(image.height / themeConf.pixelRatio),
67
65
  };
68
66
  }
69
67
  else {
70
68
  const src = (0, data_formatters_lib_1.strValOrUndef)(value.src, { varName: "src" });
71
69
  if (!src) {
72
- siteContext.siteLog.warn("missing 'uid' and 'src' in 'img' blot");
70
+ logger.warn("missing 'uid' and 'src' in 'img' blot");
73
71
  return "";
74
72
  }
75
73
  imgAttributes = {