@frontify/fondue 12.0.0-beta.308 → 12.0.0-beta.309
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/dist/components/RichTextEditor/serializer/serializeToHtml.es.js +21 -26
- package/dist/components/RichTextEditor/serializer/serializeToHtml.es.js.map +1 -1
- package/dist/components/RichTextEditor/serializer/utils/serializeLeafToHtml.es.js +4 -4
- package/dist/components/RichTextEditor/serializer/utils/serializeLeafToHtml.es.js.map +1 -1
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.umd.js +4 -4
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,31 +1,26 @@
|
|
|
1
|
-
import { parseRawValue as
|
|
2
|
-
import { serializeNodeToHtmlRecursive as
|
|
3
|
-
import { defaultPlugins as
|
|
4
|
-
import { mapMentionable as
|
|
5
|
-
import { defaultStyles as
|
|
6
|
-
const
|
|
7
|
-
const l =
|
|
8
|
-
return
|
|
9
|
-
},
|
|
10
|
-
const l =
|
|
11
|
-
return Promise.resolve(
|
|
12
|
-
},
|
|
13
|
-
const
|
|
14
|
-
let
|
|
15
|
-
for (let
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
mappedMentionable: o
|
|
1
|
+
import { parseRawValue as a } from "../utils/parseRawValue.es.js";
|
|
2
|
+
import { serializeNodeToHtmlRecursive as f } from "./utils/serializeNodeToHtmlRecursive.es.js";
|
|
3
|
+
import { defaultPlugins as i } from "../Plugins/index.es.js";
|
|
4
|
+
import { mapMentionable as d } from "../Plugins/MentionPlugin/helpers/mapMentionable.es.js";
|
|
5
|
+
import { defaultStyles as u } from "../utils/defaultStyles.es.js";
|
|
6
|
+
const R = (t, e = i, o = 1, r = "normal") => {
|
|
7
|
+
const l = a({ raw: t, plugins: e }), s = e.getStyles;
|
|
8
|
+
return c(l, { columns: o, columnGap: r, styles: s });
|
|
9
|
+
}, T = async (t, e = i, o = 1, r = "normal") => {
|
|
10
|
+
const l = a({ raw: t, plugins: e }), s = e.getStyles;
|
|
11
|
+
return Promise.resolve(c(l, { columns: o, columnGap: r, styles: s }));
|
|
12
|
+
}, c = (t, { mentionable: e, columns: o = 1, columnGap: r = "normal", styles: l = u } = {}) => {
|
|
13
|
+
const s = e ? d(e) : /* @__PURE__ */ new Map();
|
|
14
|
+
let n = "";
|
|
15
|
+
for (let m = 0, p = t.length; m < p; m++)
|
|
16
|
+
n += f(t[m], l, {
|
|
17
|
+
mappedMentionable: s
|
|
19
18
|
});
|
|
20
|
-
}
|
|
21
|
-
return r > 1 ? `<div style="columns:${r}; column-gap:${s};">${i}</div>` : i;
|
|
22
|
-
}, h = (e) => {
|
|
23
|
-
var t;
|
|
24
|
-
return Array.isArray(e == null ? void 0 : e.children) ? (t = e == null ? void 0 : e.children) == null ? void 0 : t.every((r) => r.text === "") : !1;
|
|
19
|
+
return o > 1 ? `<div style="columns:${o}; column-gap:${r};">${n}</div>` : n;
|
|
25
20
|
};
|
|
26
21
|
export {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
c as serializeNodesToHtml,
|
|
23
|
+
R as serializeRawToHtml,
|
|
24
|
+
T as serializeRawToHtmlAsync
|
|
30
25
|
};
|
|
31
26
|
//# sourceMappingURL=serializeToHtml.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializeToHtml.es.js","sources":["../../../../src/components/RichTextEditor/serializer/serializeToHtml.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { TDescendant } from '@udecode/plate';\nimport { CSSProperties } from 'react';\nimport { mapMentionable } from '../Plugins/MentionPlugin/helpers';\nimport { parseRawValue } from '../utils/parseRawValue';\nimport { serializeNodeToHtmlRecursive } from './utils/serializeNodeToHtmlRecursive';\nimport type { MentionableItems } from '../Plugins/MentionPlugin';\nimport { defaultStyles } from '../utils';\nimport { PluginComposer, defaultPlugins } from '../Plugins';\nimport { CSSPropertiesHover } from './types';\n\nexport const serializeRawToHtml = (\n raw: string,\n plugins: PluginComposer = defaultPlugins,\n columns: SerializeNodesToHtmlOptions['columns'] = 1,\n columnGap: SerializeNodesToHtmlOptions['columnGap'] = 'normal',\n): string => {\n const nodes = parseRawValue({ raw, plugins });\n const styles = plugins.getStyles;\n return serializeNodesToHtml(nodes, { columns, columnGap, styles });\n};\nexport const serializeRawToHtmlAsync = async (\n raw: string,\n plugins: PluginComposer = defaultPlugins,\n columns: SerializeNodesToHtmlOptions['columns'] = 1,\n columnGap: SerializeNodesToHtmlOptions['columnGap'] = 'normal',\n): Promise<string> => {\n const nodes = parseRawValue({ raw, plugins });\n const styles = plugins.getStyles;\n return Promise.resolve(serializeNodesToHtml(nodes, { columns, columnGap, styles }));\n};\n\nexport type SerializeNodesToHtmlOptions = {\n styles?: Record<string, CSSPropertiesHover>;\n mentionable?: MentionableItems;\n columns?: number;\n columnGap?: CSSProperties['columnGap'];\n};\n\nexport const serializeNodesToHtml = (\n nodes: TDescendant[],\n { mentionable, columns = 1, columnGap = 'normal', styles = defaultStyles }: SerializeNodesToHtmlOptions = {},\n): string => {\n const mappedMentionable = mentionable ? mapMentionable(mentionable) : new Map();\n\n let html = '';\n for (let i = 0, len = nodes.length; i < len; i++) {\n
|
|
1
|
+
{"version":3,"file":"serializeToHtml.es.js","sources":["../../../../src/components/RichTextEditor/serializer/serializeToHtml.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { TDescendant } from '@udecode/plate';\nimport { CSSProperties } from 'react';\nimport { mapMentionable } from '../Plugins/MentionPlugin/helpers';\nimport { parseRawValue } from '../utils/parseRawValue';\nimport { serializeNodeToHtmlRecursive } from './utils/serializeNodeToHtmlRecursive';\nimport type { MentionableItems } from '../Plugins/MentionPlugin';\nimport { defaultStyles } from '../utils';\nimport { PluginComposer, defaultPlugins } from '../Plugins';\nimport { CSSPropertiesHover } from './types';\n\nexport const serializeRawToHtml = (\n raw: string,\n plugins: PluginComposer = defaultPlugins,\n columns: SerializeNodesToHtmlOptions['columns'] = 1,\n columnGap: SerializeNodesToHtmlOptions['columnGap'] = 'normal',\n): string => {\n const nodes = parseRawValue({ raw, plugins });\n const styles = plugins.getStyles;\n return serializeNodesToHtml(nodes, { columns, columnGap, styles });\n};\nexport const serializeRawToHtmlAsync = async (\n raw: string,\n plugins: PluginComposer = defaultPlugins,\n columns: SerializeNodesToHtmlOptions['columns'] = 1,\n columnGap: SerializeNodesToHtmlOptions['columnGap'] = 'normal',\n): Promise<string> => {\n const nodes = parseRawValue({ raw, plugins });\n const styles = plugins.getStyles;\n return Promise.resolve(serializeNodesToHtml(nodes, { columns, columnGap, styles }));\n};\n\nexport type SerializeNodesToHtmlOptions = {\n styles?: Record<string, CSSPropertiesHover>;\n mentionable?: MentionableItems;\n columns?: number;\n columnGap?: CSSProperties['columnGap'];\n};\n\nexport const serializeNodesToHtml = (\n nodes: TDescendant[],\n { mentionable, columns = 1, columnGap = 'normal', styles = defaultStyles }: SerializeNodesToHtmlOptions = {},\n): string => {\n const mappedMentionable = mentionable ? mapMentionable(mentionable) : new Map();\n\n let html = '';\n for (let i = 0, len = nodes.length; i < len; i++) {\n html += serializeNodeToHtmlRecursive(nodes[i], styles, {\n mappedMentionable,\n });\n }\n\n if (columns > 1) {\n return `<div style=\"columns:${columns}; column-gap:${columnGap};\">${html}</div>`;\n }\n\n return html;\n};\n"],"names":["serializeRawToHtml","raw","plugins","defaultPlugins","columns","columnGap","nodes","parseRawValue","styles","serializeNodesToHtml","serializeRawToHtmlAsync","mentionable","defaultStyles","mappedMentionable","mapMentionable","html","i","len","serializeNodeToHtmlRecursive"],"mappings":";;;;;AAYa,MAAAA,IAAqB,CAC9BC,GACAC,IAA0BC,GAC1BC,IAAkD,GAClDC,IAAsD,aAC7C;AACT,QAAMC,IAAQC,EAAc,EAAE,KAAAN,GAAK,SAAAC,EAAS,CAAA,GACtCM,IAASN,EAAQ;AACvB,SAAOO,EAAqBH,GAAO,EAAE,SAAAF,GAAS,WAAAC,GAAW,QAAAG,GAAQ;AACrE,GACaE,IAA0B,OACnCT,GACAC,IAA0BC,GAC1BC,IAAkD,GAClDC,IAAsD,aACpC;AAClB,QAAMC,IAAQC,EAAc,EAAE,KAAAN,GAAK,SAAAC,EAAS,CAAA,GACtCM,IAASN,EAAQ;AAChB,SAAA,QAAQ,QAAQO,EAAqBH,GAAO,EAAE,SAAAF,GAAS,WAAAC,GAAW,QAAAG,EAAQ,CAAA,CAAC;AACtF,GASaC,IAAuB,CAChCH,GACA,EAAE,aAAAK,GAAa,SAAAP,IAAU,GAAG,WAAAC,IAAY,UAAU,QAAAG,IAASI,EAAc,IAAiC,CAAA,MACjG;AACT,QAAMC,IAAoBF,IAAcG,EAAeH,CAAW,wBAAQ;AAE1E,MAAII,IAAO;AACX,WAASC,IAAI,GAAGC,IAAMX,EAAM,QAAQU,IAAIC,GAAKD;AACzC,IAAAD,KAAQG,EAA6BZ,EAAMU,CAAC,GAAGR,GAAQ;AAAA,MACnD,mBAAAK;AAAA,IAAA,CACH;AAGL,SAAIT,IAAU,IACH,uBAAuBA,iBAAuBC,OAAeU,YAGjEA;AACX;"}
|
|
@@ -4,14 +4,14 @@ import { ITALIC_CLASSES as f } from "../../Plugins/ItalicPlugin/ItalicMarkupElem
|
|
|
4
4
|
import { UNDERLINE_CLASSES as m } from "../../Plugins/UnderlinePlugin/UnderlineMarkupElement.es.js";
|
|
5
5
|
import { STRIKETHROUGH_CLASSES as c } from "../../Plugins/StrikethroughPlugin/StrikethroughMarkupElement.es.js";
|
|
6
6
|
import { CODE_CLASSES as $ } from "../../Plugins/CodePlugin/CodeMarkupElement.es.js";
|
|
7
|
-
const
|
|
7
|
+
const b = (r) => {
|
|
8
8
|
let s = n(r.text);
|
|
9
|
-
s = s.replaceAll(`
|
|
10
|
-
`, "<br
|
|
9
|
+
s === "" && (s = ""), s = s.replaceAll(`
|
|
10
|
+
`, "<br />");
|
|
11
11
|
const { bold: p, italic: i, underline: t, strikethrough: a, code: o, subscript: e, superscript: l } = r;
|
|
12
12
|
return p && (s = `<span class="${S}">${s}</span>`), i && (s = `<span class="${f}">${s}</span>`), t && (s = `<span class="${m}">${s}</span>`), a && (s = `<span class="${c}">${s}</span>`), o && (s = `<span class="${$}">${s}</span>`), e ? s = `<sub>${s}</sub>` : l && (s = `<sup>${s}</sup>`), s;
|
|
13
13
|
};
|
|
14
14
|
export {
|
|
15
|
-
|
|
15
|
+
b as serializeLeafToHtml
|
|
16
16
|
};
|
|
17
17
|
//# sourceMappingURL=serializeLeafToHtml.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializeLeafToHtml.es.js","sources":["../../../../../src/components/RichTextEditor/serializer/utils/serializeLeafToHtml.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n BOLD_CLASSES,\n CODE_CLASSES,\n ITALIC_CLASSES,\n STRIKETHROUGH_CLASSES,\n UNDERLINE_CLASSES,\n} from '@components/RichTextEditor/Plugins';\nimport { TText } from '@udecode/plate';\nimport escapeHtml from 'escape-html';\n\nexport const serializeLeafToHtml = (node: TText): string => {\n let string = escapeHtml(node.text);\n string = string.replaceAll('\\n', '<br
|
|
1
|
+
{"version":3,"file":"serializeLeafToHtml.es.js","sources":["../../../../../src/components/RichTextEditor/serializer/utils/serializeLeafToHtml.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n BOLD_CLASSES,\n CODE_CLASSES,\n ITALIC_CLASSES,\n STRIKETHROUGH_CLASSES,\n UNDERLINE_CLASSES,\n} from '@components/RichTextEditor/Plugins';\nimport { TText } from '@udecode/plate';\nimport escapeHtml from 'escape-html';\n\nexport const serializeLeafToHtml = (node: TText): string => {\n let string = escapeHtml(node.text);\n if (string === '') {\n string = '';\n }\n string = string.replaceAll('\\n', '<br />');\n const { bold, italic, underline, strikethrough, code, subscript, superscript } = node;\n if (bold) {\n string = `<span class=\"${BOLD_CLASSES}\">${string}</span>`;\n }\n if (italic) {\n string = `<span class=\"${ITALIC_CLASSES}\">${string}</span>`;\n }\n if (underline) {\n string = `<span class=\"${UNDERLINE_CLASSES}\">${string}</span>`;\n }\n if (strikethrough) {\n string = `<span class=\"${STRIKETHROUGH_CLASSES}\">${string}</span>`;\n }\n if (code) {\n string = `<span class=\"${CODE_CLASSES}\">${string}</span>`;\n }\n if (subscript) {\n string = `<sub>${string}</sub>`;\n } else if (superscript) {\n string = `<sup>${string}</sup>`;\n }\n return string;\n};\n"],"names":["serializeLeafToHtml","node","string","escapeHtml","bold","italic","underline","strikethrough","code","subscript","superscript","BOLD_CLASSES","ITALIC_CLASSES","UNDERLINE_CLASSES","STRIKETHROUGH_CLASSES","CODE_CLASSES"],"mappings":";;;;;;AAYa,MAAAA,IAAsB,CAACC,MAAwB;AACpD,MAAAC,IAASC,EAAWF,EAAK,IAAI;AACjC,EAAIC,MAAW,OACFA,IAAA,aAEJA,IAAAA,EAAO,WAAW;AAAA,GAAM,gBAAgB;AAC3C,QAAA,EAAE,MAAAE,GAAM,QAAAC,GAAQ,WAAAC,GAAW,eAAAC,GAAe,MAAAC,GAAM,WAAAC,GAAW,aAAAC,EAAgB,IAAAT;AACjF,SAAIG,MACAF,IAAS,gBAAgBS,MAAiBT,aAE1CG,MACAH,IAAS,gBAAgBU,MAAmBV,aAE5CI,MACAJ,IAAS,gBAAgBW,MAAsBX,aAE/CK,MACAL,IAAS,gBAAgBY,MAA0BZ,aAEnDM,MACAN,IAAS,gBAAgBa,MAAiBb,aAE1CO,IACAP,IAAS,QAAQA,YACVQ,MACPR,IAAS,QAAQA,YAEdA;AACX;"}
|