@frontify/fondue 12.0.0-beta.267 → 12.0.0-beta.268
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/utils/parseRawValue.es.js +19 -15
- package/dist/components/RichTextEditor/utils/parseRawValue.es.js.map +1 -1
- package/dist/index.cjs.js +11 -11
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.umd.js +13 -13
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
import { ELEMENT_PARAGRAPH as
|
|
2
|
-
import { InitPlateEditor as
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { ELEMENT_PARAGRAPH as i, deserializeHtml as l, normalizeEditor as s } from "@udecode/plate";
|
|
2
|
+
import { InitPlateEditor as c } from "./InitPlateEditor.es.js";
|
|
3
|
+
const m = (e) => e[0].hasOwnProperty("type") ? e : [
|
|
4
|
+
{
|
|
5
|
+
type: "p",
|
|
6
|
+
children: e
|
|
7
|
+
}
|
|
8
|
+
], d = [{ type: i, children: [{ text: "" }] }], h = ({ editorId: e = "parseRawValue", raw: a, plugins: n }) => {
|
|
9
|
+
const t = c.init(`${e}_parseRawValue`, n).getInstance();
|
|
10
|
+
let r = d;
|
|
11
|
+
if (!a)
|
|
12
|
+
return r;
|
|
8
13
|
try {
|
|
9
|
-
|
|
14
|
+
r = JSON.parse(a);
|
|
10
15
|
} catch {
|
|
11
|
-
const
|
|
12
|
-
element:
|
|
13
|
-
stripWhitespace: !0
|
|
16
|
+
const o = a.trim().replaceAll(/>\s+</g, "><"), p = l(t, {
|
|
17
|
+
element: o
|
|
14
18
|
});
|
|
15
|
-
|
|
19
|
+
r = m(p);
|
|
16
20
|
}
|
|
17
|
-
return
|
|
21
|
+
return t.children = r, s(t, { force: !0 }), t.children;
|
|
18
22
|
};
|
|
19
23
|
export {
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
d as EMPTY_RICH_TEXT_VALUE,
|
|
25
|
+
h as parseRawValue
|
|
22
26
|
};
|
|
23
27
|
//# sourceMappingURL=parseRawValue.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseRawValue.es.js","sources":["../../../../src/components/RichTextEditor/utils/parseRawValue.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { ELEMENT_PARAGRAPH, Value, deserializeHtml, normalizeEditor } from '@udecode/plate';\nimport { PluginComposer } from '../Plugins';\nimport { InitPlateEditor } from './InitPlateEditor';\n\nconst
|
|
1
|
+
{"version":3,"file":"parseRawValue.es.js","sources":["../../../../src/components/RichTextEditor/utils/parseRawValue.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { ELEMENT_PARAGRAPH, Value, deserializeHtml, normalizeEditor } from '@udecode/plate';\nimport { PluginComposer } from '../Plugins';\nimport { InitPlateEditor } from './InitPlateEditor';\n\nconst wrapChildrenWithoutTypeInParagraph = (children: Value): Value =>\n children[0].hasOwnProperty('type')\n ? children\n : [\n {\n type: 'p',\n children,\n },\n ];\n\nexport const EMPTY_RICH_TEXT_VALUE: Value = [{ type: ELEMENT_PARAGRAPH, children: [{ text: '' }] }];\n\ntype ParseRawValueOptions = {\n editorId?: string;\n raw?: string;\n plugins?: PluginComposer;\n};\n\nexport const parseRawValue = ({ editorId = 'parseRawValue', raw, plugins }: ParseRawValueOptions): Value => {\n const editor = InitPlateEditor.init(`${editorId}_parseRawValue`, plugins).getInstance();\n let parsedValue = EMPTY_RICH_TEXT_VALUE;\n\n if (!raw) {\n return parsedValue;\n }\n\n try {\n parsedValue = JSON.parse(raw);\n } catch {\n const trimmedText = raw.trim().replaceAll(/>\\s+</g, '><');\n const parsedHtml = deserializeHtml(editor, {\n element: trimmedText,\n }) as Value;\n parsedValue = wrapChildrenWithoutTypeInParagraph(parsedHtml);\n }\n\n editor.children = parsedValue;\n normalizeEditor(editor, { force: true });\n\n return editor.children;\n};\n"],"names":["wrapChildrenWithoutTypeInParagraph","children","EMPTY_RICH_TEXT_VALUE","ELEMENT_PARAGRAPH","parseRawValue","editorId","raw","plugins","editor","InitPlateEditor","parsedValue","trimmedText","parsedHtml","deserializeHtml","normalizeEditor"],"mappings":";;AAMA,MAAMA,IAAqC,CAACC,MACxCA,EAAS,CAAC,EAAE,eAAe,MAAM,IAC3BA,IACA;AAAA,EACI;AAAA,IACI,MAAM;AAAA,IACN,UAAAA;AAAA,EACJ;AACJ,GAEGC,IAA+B,CAAC,EAAE,MAAMC,GAAmB,UAAU,CAAC,EAAE,MAAM,GAAI,CAAA,GAAG,GAQrFC,IAAgB,CAAC,EAAE,UAAAC,IAAW,iBAAiB,KAAAC,GAAK,SAAAC,QAA2C;AACxG,QAAMC,IAASC,EAAgB,KAAK,GAAGJ,mBAA0BE,CAAO,EAAE;AAC1E,MAAIG,IAAcR;AAElB,MAAI,CAACI;AACM,WAAAI;AAGP,MAAA;AACc,IAAAA,IAAA,KAAK,MAAMJ,CAAG;AAAA,EAAA,QAC9B;AACE,UAAMK,IAAcL,EAAI,KAAA,EAAO,WAAW,UAAU,IAAI,GAClDM,IAAaC,EAAgBL,GAAQ;AAAA,MACvC,SAASG;AAAA,IAAA,CACZ;AACD,IAAAD,IAAcV,EAAmCY,CAAU;AAAA,EAC/D;AAEA,SAAAJ,EAAO,WAAWE,GAClBI,EAAgBN,GAAQ,EAAE,OAAO,GAAM,CAAA,GAEhCA,EAAO;AAClB;"}
|