@frontify/guideline-blocks-settings 2.0.0 → 2.0.2
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/Attachments/AttachmentItem.es.js +83 -83
- package/dist/components/Attachments/AttachmentItem.es.js.map +1 -1
- package/dist/components/Attachments/Attachments.es.js +51 -54
- package/dist/components/Attachments/Attachments.es.js.map +1 -1
- package/dist/components/BlockInjectButton/BlockInjectButton.es.js +56 -57
- package/dist/components/BlockInjectButton/BlockInjectButton.es.js.map +1 -1
- package/dist/components/BlockItemWrapper/BlockItemWrapper.es.js +25 -25
- package/dist/components/BlockItemWrapper/BlockItemWrapper.es.js.map +1 -1
- package/dist/components/BlockItemWrapper/Toolbar/context/MultiFlyoutContext.es.js +3 -3
- package/dist/components/Link/LinkInput.es.js +35 -35
- package/dist/components/Link/LinkInput.es.js.map +1 -1
- package/dist/components/Link/LinkSelector/LinkSelector.es.js +31 -31
- package/dist/components/Link/LinkSelector/LinkSelector.es.js.map +1 -1
- package/dist/components/Link/helpers/filterDocumentSectionsWithUnreadableTitles.es.js +2 -5
- package/dist/components/Link/helpers/filterDocumentSectionsWithUnreadableTitles.es.js.map +1 -1
- package/dist/components/Link/utils/getUrl.es.js +9 -15
- package/dist/components/Link/utils/getUrl.es.js.map +1 -1
- package/dist/components/RichTextEditor/RichTextEditor.es.js +39 -39
- package/dist/components/RichTextEditor/RichTextEditor.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/ButtonMarkupElement/ButtonMarkupElementNode.es.js +24 -25
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/ButtonMarkupElement/ButtonMarkupElementNode.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/ButtonButton.es.js +6 -6
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/ButtonButton.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/InsertButtonModal/useInsertModal.es.js +25 -25
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/InsertButtonModal/useInsertModal.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/createButtonPlugin.es.js +29 -33
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/createButtonPlugin.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/submitFloatingButton.es.js +6 -6
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/submitFloatingButton.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/unwrapButton.es.js +22 -23
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/unwrapButton.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButton.es.js +61 -63
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButton.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButtonText.es.js +6 -6
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButtonText.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/getButtonStyle.es.js +6 -7
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/getButtonStyle.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/withButton.es.js +21 -21
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/withButton.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ColumnBreakPlugin/ColumnBreakPlugin.es.js +15 -19
- package/dist/components/RichTextEditor/plugins/ColumnBreakPlugin/ColumnBreakPlugin.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/CustomFloatingLink.es.js +5 -5
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/InsertModal.es.js +13 -13
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/InsertModal.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useInsertModal.es.js +23 -23
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useInsertModal.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/LinkPlugin/LinkMarkupElement/LinkMarkupElementNode.es.js +7 -8
- package/dist/components/RichTextEditor/plugins/LinkPlugin/LinkMarkupElement/LinkMarkupElementNode.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/LinkPlugin/index.es.js +23 -27
- package/dist/components/RichTextEditor/plugins/LinkPlugin/index.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/LinkPlugin/utils/getUrl.es.js +6 -9
- package/dist/components/RichTextEditor/plugins/LinkPlugin/utils/getUrl.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom1Plugin.es.js +24 -28
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom1Plugin.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom2Plugin.es.js +24 -28
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom2Plugin.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom3Plugin.es.js +24 -28
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom3Plugin.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading1Plugin.es.js +24 -28
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading1Plugin.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading2Plugin.es.js +24 -28
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading2Plugin.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading3Plugin.es.js +24 -28
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading3Plugin.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading4Plugin.es.js +24 -28
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading4Plugin.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/imageCaptionPlugin.es.js +25 -29
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/imageCaptionPlugin.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/imageTitlePlugin.es.js +25 -29
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/imageTitlePlugin.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/paragraphPlugin.es.js +26 -30
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/paragraphPlugin.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/quotePlugin.es.js +26 -30
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/quotePlugin.es.js.map +1 -1
- package/dist/helpers/customCoordinatesGetterFactory.es.js +18 -18
- package/dist/helpers/customCoordinatesGetterFactory.es.js.map +1 -1
- package/dist/hooks/useAttachments.es.js +6 -6
- package/dist/hooks/useAttachments.es.js.map +1 -1
- package/dist/index.cjs.js +7 -7
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +0 -15
- package/dist/index.es.js +208 -208
- package/dist/index.umd.js +7 -7
- package/dist/index.umd.js.map +1 -1
- package/dist/settings/background.es.js +4 -4
- package/dist/settings/background.es.js.map +1 -1
- package/dist/settings/border.es.js +17 -17
- package/dist/settings/border.es.js.map +1 -1
- package/dist/settings/borderRadius.es.js +12 -15
- package/dist/settings/borderRadius.es.js.map +1 -1
- package/dist/settings/borderRadiusExtended.es.js +25 -28
- package/dist/settings/borderRadiusExtended.es.js.map +1 -1
- package/dist/settings/gutter.es.js +17 -20
- package/dist/settings/gutter.es.js.map +1 -1
- package/dist/settings/margin.es.js +14 -14
- package/dist/settings/margin.es.js.map +1 -1
- package/dist/settings/marginExtended.es.js +29 -29
- package/dist/settings/marginExtended.es.js.map +1 -1
- package/dist/settings/padding.es.js +14 -14
- package/dist/settings/padding.es.js.map +1 -1
- package/dist/settings/paddingExtended.es.js +28 -28
- package/dist/settings/paddingExtended.es.js.map +1 -1
- package/dist/settings/securityDownloadable.es.js +8 -11
- package/dist/settings/securityDownloadable.es.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/color/getReadableColor.es.js +6 -6
- package/dist/utilities/color/getReadableColor.es.js.map +1 -1
- package/dist/utilities/color/isDark.es.js +4 -4
- package/dist/utilities/color/isDark.es.js.map +1 -1
- package/package.json +16 -16
|
@@ -1,51 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
constructor({ styles: l = x.imageTitle, ...s } = {}) {
|
|
10
|
-
super(a.imageTitle, {
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { Plugin as r, MarkupElement as o, createPluginFactory as g, merge as u, alignmentClassnames as c, getColumnBreakClasses as p } from "@frontify/fondue/rte";
|
|
3
|
+
import { TextStyles as s, BlockStyles as T } from "../styles.es.js";
|
|
4
|
+
const y = "textstyle-imageTitle-plugin";
|
|
5
|
+
class C extends r {
|
|
6
|
+
styles = {};
|
|
7
|
+
constructor({ styles: e = T.imageTitle, ...l } = {}) {
|
|
8
|
+
super(s.imageTitle, {
|
|
11
9
|
label: "Image Title",
|
|
12
|
-
markupElement: new
|
|
13
|
-
...
|
|
14
|
-
});
|
|
15
|
-
m(this, "styles", {});
|
|
16
|
-
this.styles = l;
|
|
10
|
+
markupElement: new k(),
|
|
11
|
+
...l
|
|
12
|
+
}), this.styles = e;
|
|
17
13
|
}
|
|
18
14
|
plugins() {
|
|
19
|
-
return [
|
|
15
|
+
return [x(this.styles)];
|
|
20
16
|
}
|
|
21
17
|
}
|
|
22
|
-
class
|
|
23
|
-
constructor(e =
|
|
18
|
+
class k extends o {
|
|
19
|
+
constructor(e = y, l = a) {
|
|
24
20
|
super(e, l);
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
return /* @__PURE__ */
|
|
23
|
+
const a = ({ element: t, attributes: e, children: l, styles: m }) => {
|
|
24
|
+
const i = t.align;
|
|
25
|
+
return /* @__PURE__ */ n(
|
|
30
26
|
"p",
|
|
31
27
|
{
|
|
32
28
|
...e,
|
|
33
|
-
className:
|
|
34
|
-
style:
|
|
29
|
+
className: u([i && c[i], p(t)]),
|
|
30
|
+
style: m,
|
|
35
31
|
children: l
|
|
36
32
|
}
|
|
37
33
|
);
|
|
38
|
-
},
|
|
39
|
-
key:
|
|
34
|
+
}, x = (t) => g({
|
|
35
|
+
key: s.imageTitle,
|
|
40
36
|
isElement: !0,
|
|
41
|
-
component:
|
|
37
|
+
component: a,
|
|
42
38
|
deserializeHtml: {
|
|
43
|
-
rules: [{ validClassName:
|
|
39
|
+
rules: [{ validClassName: s.imageTitle }]
|
|
44
40
|
}
|
|
45
41
|
})({
|
|
46
|
-
component: (e) => /* @__PURE__ */
|
|
42
|
+
component: (e) => /* @__PURE__ */ n(a, { ...e, styles: t })
|
|
47
43
|
});
|
|
48
44
|
export {
|
|
49
|
-
|
|
45
|
+
C as ImageTitlePlugin
|
|
50
46
|
};
|
|
51
47
|
//# sourceMappingURL=imageTitlePlugin.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageTitlePlugin.es.js","sources":["../../../../../src/components/RichTextEditor/plugins/TextStylePlugins/imageTitlePlugin.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n MarkupElement,\n type PlatePlugin,\n Plugin,\n type PluginProps,\n type TextStyleRenderElementProps,\n alignmentClassnames,\n createPluginFactory,\n getColumnBreakClasses,\n merge,\n} from '@frontify/fondue/rte';\nimport { type CSSProperties } from 'react';\n\nimport { BlockStyles, TextStyles } from '../styles';\n\nconst ID = 'textstyle-imageTitle-plugin';\n\nexport class ImageTitlePlugin extends Plugin {\n public styles: CSSProperties = {};\n constructor({ styles = BlockStyles.imageTitle, ...props }: PluginProps = {}) {\n super(TextStyles.imageTitle, {\n label: 'Image Title',\n markupElement: new ImageTitleMarkupElement(),\n ...props,\n });\n this.styles = styles;\n }\n\n plugins(): PlatePlugin[] {\n return [createImageTitlePlugin(this.styles)];\n }\n}\n\nclass ImageTitleMarkupElement extends MarkupElement {\n constructor(id = ID, node = ImageTitleMarkupElementNode) {\n super(id, node);\n }\n}\nconst ImageTitleMarkupElementNode = ({ element, attributes, children, styles }: TextStyleRenderElementProps) => {\n const align = element.align as string;\n return (\n <p\n {...attributes}\n className={merge([align && alignmentClassnames[align], getColumnBreakClasses(element)])}\n style={styles}\n >\n {children}\n </p>\n );\n};\n\nconst createImageTitlePlugin = (styles: CSSProperties) =>\n createPluginFactory({\n key: TextStyles.imageTitle,\n isElement: true,\n component: ImageTitleMarkupElementNode,\n deserializeHtml: {\n rules: [{ validClassName: TextStyles.imageTitle }],\n },\n })({\n component: (props: TextStyleRenderElementProps) => <ImageTitleMarkupElementNode {...props} styles={styles} />,\n });\n"],"names":["ID","ImageTitlePlugin","Plugin","styles","BlockStyles","props","TextStyles","ImageTitleMarkupElement","
|
|
1
|
+
{"version":3,"file":"imageTitlePlugin.es.js","sources":["../../../../../src/components/RichTextEditor/plugins/TextStylePlugins/imageTitlePlugin.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n MarkupElement,\n type PlatePlugin,\n Plugin,\n type PluginProps,\n type TextStyleRenderElementProps,\n alignmentClassnames,\n createPluginFactory,\n getColumnBreakClasses,\n merge,\n} from '@frontify/fondue/rte';\nimport { type CSSProperties } from 'react';\n\nimport { BlockStyles, TextStyles } from '../styles';\n\nconst ID = 'textstyle-imageTitle-plugin';\n\nexport class ImageTitlePlugin extends Plugin {\n public styles: CSSProperties = {};\n constructor({ styles = BlockStyles.imageTitle, ...props }: PluginProps = {}) {\n super(TextStyles.imageTitle, {\n label: 'Image Title',\n markupElement: new ImageTitleMarkupElement(),\n ...props,\n });\n this.styles = styles;\n }\n\n plugins(): PlatePlugin[] {\n return [createImageTitlePlugin(this.styles)];\n }\n}\n\nclass ImageTitleMarkupElement extends MarkupElement {\n constructor(id = ID, node = ImageTitleMarkupElementNode) {\n super(id, node);\n }\n}\nconst ImageTitleMarkupElementNode = ({ element, attributes, children, styles }: TextStyleRenderElementProps) => {\n const align = element.align as string;\n return (\n <p\n {...attributes}\n className={merge([align && alignmentClassnames[align], getColumnBreakClasses(element)])}\n style={styles}\n >\n {children}\n </p>\n );\n};\n\nconst createImageTitlePlugin = (styles: CSSProperties) =>\n createPluginFactory({\n key: TextStyles.imageTitle,\n isElement: true,\n component: ImageTitleMarkupElementNode,\n deserializeHtml: {\n rules: [{ validClassName: TextStyles.imageTitle }],\n },\n })({\n component: (props: TextStyleRenderElementProps) => <ImageTitleMarkupElementNode {...props} styles={styles} />,\n });\n"],"names":["ID","ImageTitlePlugin","Plugin","styles","BlockStyles","props","TextStyles","ImageTitleMarkupElement","createImageTitlePlugin","MarkupElement","id","node","ImageTitleMarkupElementNode","element","attributes","children","align","jsx","merge","alignmentClassnames","getColumnBreakClasses","createPluginFactory"],"mappings":";;;AAiBA,MAAMA,IAAK;AAEJ,MAAMC,UAAyBC,EAAO;AAAA,EAClC,SAAwB,CAAA;AAAA,EAC/B,YAAY,EAAE,QAAAC,IAASC,EAAY,YAAY,GAAGC,EAAA,IAAuB,IAAI;AACzE,UAAMC,EAAW,YAAY;AAAA,MACzB,OAAO;AAAA,MACP,eAAe,IAAIC,EAAA;AAAA,MACnB,GAAGF;AAAA,IAAA,CACN,GACD,KAAK,SAASF;AAAA,EAClB;AAAA,EAEA,UAAyB;AACrB,WAAO,CAACK,EAAuB,KAAK,MAAM,CAAC;AAAA,EAC/C;AACJ;AAEA,MAAMD,UAAgCE,EAAc;AAAA,EAChD,YAAYC,IAAKV,GAAIW,IAAOC,GAA6B;AACrD,UAAMF,GAAIC,CAAI;AAAA,EAClB;AACJ;AACA,MAAMC,IAA8B,CAAC,EAAE,SAAAC,GAAS,YAAAC,GAAY,UAAAC,GAAU,QAAAZ,QAA0C;AAC5G,QAAMa,IAAQH,EAAQ;AACtB,SACI,gBAAAI;AAAA,IAAC;AAAA,IAAA;AAAA,MACI,GAAGH;AAAA,MACJ,WAAWI,EAAM,CAACF,KAASG,EAAoBH,CAAK,GAAGI,EAAsBP,CAAO,CAAC,CAAC;AAAA,MACtF,OAAOV;AAAA,MAEN,UAAAY;AAAA,IAAA;AAAA,EAAA;AAGb,GAEMP,IAAyB,CAACL,MAC5BkB,EAAoB;AAAA,EAChB,KAAKf,EAAW;AAAA,EAChB,WAAW;AAAA,EACX,WAAWM;AAAA,EACX,iBAAiB;AAAA,IACb,OAAO,CAAC,EAAE,gBAAgBN,EAAW,YAAY;AAAA,EAAA;AAEzD,CAAC,EAAE;AAAA,EACC,WAAW,CAACD,wBAAwCO,GAAA,EAA6B,GAAGP,GAAO,QAAAF,EAAA,CAAgB;AAC/G,CAAC;"}
|
|
@@ -1,45 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
super(n.p, {
|
|
10
|
-
markupElement: new d(),
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { Plugin as c, MarkupElement as m, merge as u, alignmentClassnames as g, getColumnBreakClasses as i, createPluginFactory as P, createParagraphPlugin as y } from "@frontify/fondue/rte";
|
|
3
|
+
import { TextStyles as s, BlockStyles as h } from "../styles.es.js";
|
|
4
|
+
class A extends c {
|
|
5
|
+
styles = {};
|
|
6
|
+
constructor({ styles: e = h.p, ...r } = {}) {
|
|
7
|
+
super(s.p, {
|
|
8
|
+
markupElement: new x(),
|
|
11
9
|
label: "Body Text",
|
|
12
|
-
...
|
|
13
|
-
});
|
|
14
|
-
p(this, "styles", {});
|
|
15
|
-
this.styles = r;
|
|
10
|
+
...r
|
|
11
|
+
}), this.styles = e;
|
|
16
12
|
}
|
|
17
13
|
plugins() {
|
|
18
|
-
return [
|
|
14
|
+
return [E(this.styles)];
|
|
19
15
|
}
|
|
20
16
|
}
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
return /* @__PURE__ */
|
|
17
|
+
const k = "tw-m-0 tw-px-0 tw-py-0", a = ({ element: t, attributes: e, children: r, styles: p }) => {
|
|
18
|
+
const n = t.align, o = u([n && g[n], k, i(t)]);
|
|
19
|
+
return /* @__PURE__ */ l("p", { ...e, className: o, style: p, children: r });
|
|
24
20
|
};
|
|
25
|
-
class
|
|
26
|
-
constructor(e =
|
|
21
|
+
class x extends m {
|
|
22
|
+
constructor(e = s.p, r = a) {
|
|
27
23
|
super(e, r);
|
|
28
24
|
}
|
|
29
25
|
}
|
|
30
|
-
const
|
|
31
|
-
...
|
|
32
|
-
key:
|
|
26
|
+
const E = (t) => P({
|
|
27
|
+
...y(),
|
|
28
|
+
key: s.p,
|
|
33
29
|
isElement: !0,
|
|
34
|
-
component:
|
|
30
|
+
component: a
|
|
35
31
|
})({
|
|
36
|
-
component: (e) => /* @__PURE__ */
|
|
32
|
+
component: (e) => /* @__PURE__ */ l(a, { ...e, styles: t })
|
|
37
33
|
});
|
|
38
34
|
export {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
k as PARAGRAPH_CLASSES,
|
|
36
|
+
x as ParagraphMarkupElement,
|
|
37
|
+
a as ParagraphMarkupElementNode,
|
|
38
|
+
A as ParagraphPlugin,
|
|
39
|
+
E as createParagraphPlugin
|
|
44
40
|
};
|
|
45
41
|
//# sourceMappingURL=paragraphPlugin.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paragraphPlugin.es.js","sources":["../../../../../src/components/RichTextEditor/plugins/TextStylePlugins/paragraphPlugin.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n MarkupElement,\n type PlatePlugin,\n Plugin,\n type PluginProps,\n type TextStyleRenderElementProps,\n alignmentClassnames,\n createParagraphPlugin as createPlateParagraphPlugin,\n createPluginFactory,\n getColumnBreakClasses,\n merge,\n} from '@frontify/fondue/rte';\nimport { type CSSProperties } from 'react';\n\nimport { BlockStyles, TextStyles } from '../styles';\n\nexport class ParagraphPlugin extends Plugin {\n public styles = {};\n constructor({ styles = BlockStyles.p, ...props }: PluginProps = {}) {\n super(TextStyles.p, {\n markupElement: new ParagraphMarkupElement(),\n label: 'Body Text',\n ...props,\n });\n this.styles = styles;\n }\n\n plugins(): PlatePlugin[] {\n return [createParagraphPlugin(this.styles)];\n }\n}\n\nexport const PARAGRAPH_CLASSES = 'tw-m-0 tw-px-0 tw-py-0';\n\nexport const ParagraphMarkupElementNode = ({ element, attributes, children, styles }: TextStyleRenderElementProps) => {\n const align = element.align as string;\n const className = merge([align && alignmentClassnames[align], PARAGRAPH_CLASSES, getColumnBreakClasses(element)]);\n return (\n <p {...attributes} className={className} style={styles}>\n {children}\n </p>\n );\n};\n\nexport class ParagraphMarkupElement extends MarkupElement {\n constructor(id = TextStyles.p, node = ParagraphMarkupElementNode) {\n super(id, node);\n }\n}\n\nexport const createParagraphPlugin = (styles: CSSProperties): PlatePlugin =>\n createPluginFactory({\n ...createPlateParagraphPlugin(),\n key: TextStyles.p,\n isElement: true,\n component: ParagraphMarkupElementNode,\n })({\n component: (props: TextStyleRenderElementProps) => <ParagraphMarkupElementNode {...props} styles={styles} />,\n });\n"],"names":["ParagraphPlugin","Plugin","styles","BlockStyles","props","TextStyles","ParagraphMarkupElement","
|
|
1
|
+
{"version":3,"file":"paragraphPlugin.es.js","sources":["../../../../../src/components/RichTextEditor/plugins/TextStylePlugins/paragraphPlugin.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n MarkupElement,\n type PlatePlugin,\n Plugin,\n type PluginProps,\n type TextStyleRenderElementProps,\n alignmentClassnames,\n createParagraphPlugin as createPlateParagraphPlugin,\n createPluginFactory,\n getColumnBreakClasses,\n merge,\n} from '@frontify/fondue/rte';\nimport { type CSSProperties } from 'react';\n\nimport { BlockStyles, TextStyles } from '../styles';\n\nexport class ParagraphPlugin extends Plugin {\n public styles = {};\n constructor({ styles = BlockStyles.p, ...props }: PluginProps = {}) {\n super(TextStyles.p, {\n markupElement: new ParagraphMarkupElement(),\n label: 'Body Text',\n ...props,\n });\n this.styles = styles;\n }\n\n plugins(): PlatePlugin[] {\n return [createParagraphPlugin(this.styles)];\n }\n}\n\nexport const PARAGRAPH_CLASSES = 'tw-m-0 tw-px-0 tw-py-0';\n\nexport const ParagraphMarkupElementNode = ({ element, attributes, children, styles }: TextStyleRenderElementProps) => {\n const align = element.align as string;\n const className = merge([align && alignmentClassnames[align], PARAGRAPH_CLASSES, getColumnBreakClasses(element)]);\n return (\n <p {...attributes} className={className} style={styles}>\n {children}\n </p>\n );\n};\n\nexport class ParagraphMarkupElement extends MarkupElement {\n constructor(id = TextStyles.p, node = ParagraphMarkupElementNode) {\n super(id, node);\n }\n}\n\nexport const createParagraphPlugin = (styles: CSSProperties): PlatePlugin =>\n createPluginFactory({\n ...createPlateParagraphPlugin(),\n key: TextStyles.p,\n isElement: true,\n component: ParagraphMarkupElementNode,\n })({\n component: (props: TextStyleRenderElementProps) => <ParagraphMarkupElementNode {...props} styles={styles} />,\n });\n"],"names":["ParagraphPlugin","Plugin","styles","BlockStyles","props","TextStyles","ParagraphMarkupElement","createParagraphPlugin","PARAGRAPH_CLASSES","ParagraphMarkupElementNode","element","attributes","children","align","className","merge","alignmentClassnames","getColumnBreakClasses","MarkupElement","id","node","createPluginFactory","createPlateParagraphPlugin"],"mappings":";;;AAkBO,MAAMA,UAAwBC,EAAO;AAAA,EACjC,SAAS,CAAA;AAAA,EAChB,YAAY,EAAE,QAAAC,IAASC,EAAY,GAAG,GAAGC,EAAA,IAAuB,IAAI;AAChE,UAAMC,EAAW,GAAG;AAAA,MAChB,eAAe,IAAIC,EAAA;AAAA,MACnB,OAAO;AAAA,MACP,GAAGF;AAAA,IAAA,CACN,GACD,KAAK,SAASF;AAAA,EAClB;AAAA,EAEA,UAAyB;AACrB,WAAO,CAACK,EAAsB,KAAK,MAAM,CAAC;AAAA,EAC9C;AACJ;AAEO,MAAMC,IAAoB,0BAEpBC,IAA6B,CAAC,EAAE,SAAAC,GAAS,YAAAC,GAAY,UAAAC,GAAU,QAAAV,QAA0C;AAClH,QAAMW,IAAQH,EAAQ,OAChBI,IAAYC,EAAM,CAACF,KAASG,EAAoBH,CAAK,GAAGL,GAAmBS,EAAsBP,CAAO,CAAC,CAAC;AAChH,2BACK,KAAA,EAAG,GAAGC,GAAY,WAAAG,GAAsB,OAAOZ,GAC3C,UAAAU,GACL;AAER;AAEO,MAAMN,UAA+BY,EAAc;AAAA,EACtD,YAAYC,IAAKd,EAAW,GAAGe,IAAOX,GAA4B;AAC9D,UAAMU,GAAIC,CAAI;AAAA,EAClB;AACJ;AAEO,MAAMb,IAAwB,CAACL,MAClCmB,EAAoB;AAAA,EAChB,GAAGC,EAAA;AAAA,EACH,KAAKjB,EAAW;AAAA,EAChB,WAAW;AAAA,EACX,WAAWI;AACf,CAAC,EAAE;AAAA,EACC,WAAW,CAACL,wBAAwCK,GAAA,EAA4B,GAAGL,GAAO,QAAAF,EAAA,CAAgB;AAC9G,CAAC;"}
|
|
@@ -1,53 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
constructor({ styles: s = q.quote, ...o } = {}) {
|
|
10
|
-
super(a.quote, {
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { Plugin as a, merge as m, alignmentClassnames as c, getColumnBreakClasses as i, createPluginFactory as p, MarkupElement as g } from "@frontify/fondue/rte";
|
|
3
|
+
import { TextStyles as u, BlockStyles as k } from "../styles.es.js";
|
|
4
|
+
const y = "textstyle-quote-plugin";
|
|
5
|
+
class C extends a {
|
|
6
|
+
styles = {};
|
|
7
|
+
constructor({ styles: e = k.quote, ...s } = {}) {
|
|
8
|
+
super(u.quote, {
|
|
11
9
|
label: "Quote",
|
|
12
|
-
markupElement: new
|
|
13
|
-
...
|
|
14
|
-
});
|
|
15
|
-
u(this, "styles", {});
|
|
16
|
-
this.styles = s;
|
|
10
|
+
markupElement: new d(),
|
|
11
|
+
...s
|
|
12
|
+
}), this.styles = e;
|
|
17
13
|
}
|
|
18
14
|
plugins() {
|
|
19
|
-
return [
|
|
15
|
+
return [q(this.styles)];
|
|
20
16
|
}
|
|
21
17
|
}
|
|
22
|
-
class
|
|
23
|
-
constructor(e =
|
|
18
|
+
class d extends g {
|
|
19
|
+
constructor(e = y, s = o) {
|
|
24
20
|
super(e, s);
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
return /* @__PURE__ */
|
|
23
|
+
const o = ({ element: t, attributes: e, children: s, styles: r }) => {
|
|
24
|
+
const l = t.align;
|
|
25
|
+
return /* @__PURE__ */ n(
|
|
30
26
|
"blockquote",
|
|
31
27
|
{
|
|
32
28
|
...e,
|
|
33
|
-
className:
|
|
34
|
-
style:
|
|
29
|
+
className: m([l && c[l], i(t)]),
|
|
30
|
+
style: r,
|
|
35
31
|
children: s
|
|
36
32
|
}
|
|
37
33
|
);
|
|
38
|
-
},
|
|
39
|
-
key:
|
|
34
|
+
}, q = (t) => p({
|
|
35
|
+
key: u.quote,
|
|
40
36
|
isElement: !0,
|
|
41
|
-
component:
|
|
37
|
+
component: o,
|
|
42
38
|
deserializeHtml: {
|
|
43
39
|
rules: [{ validNodeName: ["blockquote", "BLOCKQUOTE"] }]
|
|
44
40
|
}
|
|
45
41
|
})({
|
|
46
|
-
component: (e) => /* @__PURE__ */
|
|
42
|
+
component: (e) => /* @__PURE__ */ n(o, { ...e, styles: t })
|
|
47
43
|
});
|
|
48
44
|
export {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
o as QuoteMarkupElementNode,
|
|
46
|
+
C as QuotePlugin,
|
|
47
|
+
q as createQuotePlugin
|
|
52
48
|
};
|
|
53
49
|
//# sourceMappingURL=quotePlugin.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quotePlugin.es.js","sources":["../../../../../src/components/RichTextEditor/plugins/TextStylePlugins/quotePlugin.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n MarkupElement,\n type PlatePlugin,\n Plugin,\n type PluginProps,\n type TextStyleRenderElementProps,\n alignmentClassnames,\n createPluginFactory,\n getColumnBreakClasses,\n merge,\n} from '@frontify/fondue/rte';\nimport { type CSSProperties } from 'react';\n\nimport { BlockStyles, TextStyles } from '../styles';\n\nconst ID = 'textstyle-quote-plugin';\n\nexport class QuotePlugin extends Plugin {\n public styles: CSSProperties = {};\n constructor({ styles = BlockStyles.quote, ...props }: PluginProps = {}) {\n super(TextStyles.quote, {\n label: 'Quote',\n markupElement: new QuoteMarkupElement(),\n ...props,\n });\n this.styles = styles;\n }\n\n plugins(): PlatePlugin[] {\n return [createQuotePlugin(this.styles)];\n }\n}\n\nclass QuoteMarkupElement extends MarkupElement {\n constructor(id = ID, node = QuoteMarkupElementNode) {\n super(id, node);\n }\n}\n\nexport const QuoteMarkupElementNode = ({ element, attributes, children, styles }: TextStyleRenderElementProps) => {\n const align = element.align as string;\n return (\n <blockquote\n {...attributes}\n className={merge([align && alignmentClassnames[align], getColumnBreakClasses(element)])}\n style={styles}\n >\n {children}\n </blockquote>\n );\n};\n\nexport const createQuotePlugin = (styles: CSSProperties): PlatePlugin =>\n createPluginFactory({\n key: TextStyles.quote,\n isElement: true,\n component: QuoteMarkupElementNode,\n deserializeHtml: {\n rules: [{ validNodeName: ['blockquote', 'BLOCKQUOTE'] }],\n },\n })({\n component: (props: TextStyleRenderElementProps) => <QuoteMarkupElementNode {...props} styles={styles} />,\n });\n"],"names":["ID","QuotePlugin","Plugin","styles","BlockStyles","props","TextStyles","QuoteMarkupElement","
|
|
1
|
+
{"version":3,"file":"quotePlugin.es.js","sources":["../../../../../src/components/RichTextEditor/plugins/TextStylePlugins/quotePlugin.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n MarkupElement,\n type PlatePlugin,\n Plugin,\n type PluginProps,\n type TextStyleRenderElementProps,\n alignmentClassnames,\n createPluginFactory,\n getColumnBreakClasses,\n merge,\n} from '@frontify/fondue/rte';\nimport { type CSSProperties } from 'react';\n\nimport { BlockStyles, TextStyles } from '../styles';\n\nconst ID = 'textstyle-quote-plugin';\n\nexport class QuotePlugin extends Plugin {\n public styles: CSSProperties = {};\n constructor({ styles = BlockStyles.quote, ...props }: PluginProps = {}) {\n super(TextStyles.quote, {\n label: 'Quote',\n markupElement: new QuoteMarkupElement(),\n ...props,\n });\n this.styles = styles;\n }\n\n plugins(): PlatePlugin[] {\n return [createQuotePlugin(this.styles)];\n }\n}\n\nclass QuoteMarkupElement extends MarkupElement {\n constructor(id = ID, node = QuoteMarkupElementNode) {\n super(id, node);\n }\n}\n\nexport const QuoteMarkupElementNode = ({ element, attributes, children, styles }: TextStyleRenderElementProps) => {\n const align = element.align as string;\n return (\n <blockquote\n {...attributes}\n className={merge([align && alignmentClassnames[align], getColumnBreakClasses(element)])}\n style={styles}\n >\n {children}\n </blockquote>\n );\n};\n\nexport const createQuotePlugin = (styles: CSSProperties): PlatePlugin =>\n createPluginFactory({\n key: TextStyles.quote,\n isElement: true,\n component: QuoteMarkupElementNode,\n deserializeHtml: {\n rules: [{ validNodeName: ['blockquote', 'BLOCKQUOTE'] }],\n },\n })({\n component: (props: TextStyleRenderElementProps) => <QuoteMarkupElementNode {...props} styles={styles} />,\n });\n"],"names":["ID","QuotePlugin","Plugin","styles","BlockStyles","props","TextStyles","QuoteMarkupElement","createQuotePlugin","MarkupElement","id","node","QuoteMarkupElementNode","element","attributes","children","align","jsx","merge","alignmentClassnames","getColumnBreakClasses","createPluginFactory"],"mappings":";;;AAiBA,MAAMA,IAAK;AAEJ,MAAMC,UAAoBC,EAAO;AAAA,EAC7B,SAAwB,CAAA;AAAA,EAC/B,YAAY,EAAE,QAAAC,IAASC,EAAY,OAAO,GAAGC,EAAA,IAAuB,IAAI;AACpE,UAAMC,EAAW,OAAO;AAAA,MACpB,OAAO;AAAA,MACP,eAAe,IAAIC,EAAA;AAAA,MACnB,GAAGF;AAAA,IAAA,CACN,GACD,KAAK,SAASF;AAAA,EAClB;AAAA,EAEA,UAAyB;AACrB,WAAO,CAACK,EAAkB,KAAK,MAAM,CAAC;AAAA,EAC1C;AACJ;AAEA,MAAMD,UAA2BE,EAAc;AAAA,EAC3C,YAAYC,IAAKV,GAAIW,IAAOC,GAAwB;AAChD,UAAMF,GAAIC,CAAI;AAAA,EAClB;AACJ;AAEO,MAAMC,IAAyB,CAAC,EAAE,SAAAC,GAAS,YAAAC,GAAY,UAAAC,GAAU,QAAAZ,QAA0C;AAC9G,QAAMa,IAAQH,EAAQ;AACtB,SACI,gBAAAI;AAAA,IAAC;AAAA,IAAA;AAAA,MACI,GAAGH;AAAA,MACJ,WAAWI,EAAM,CAACF,KAASG,EAAoBH,CAAK,GAAGI,EAAsBP,CAAO,CAAC,CAAC;AAAA,MACtF,OAAOV;AAAA,MAEN,UAAAY;AAAA,IAAA;AAAA,EAAA;AAGb,GAEaP,IAAoB,CAACL,MAC9BkB,EAAoB;AAAA,EAChB,KAAKf,EAAW;AAAA,EAChB,WAAW;AAAA,EACX,WAAWM;AAAA,EACX,iBAAiB;AAAA,IACb,OAAO,CAAC,EAAE,eAAe,CAAC,cAAc,YAAY,GAAG;AAAA,EAAA;AAE/D,CAAC,EAAE;AAAA,EACC,WAAW,CAACP,wBAAwCO,GAAA,EAAwB,GAAGP,GAAO,QAAAF,EAAA,CAAgB;AAC1G,CAAC;"}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { KeyboardCode as
|
|
2
|
-
const
|
|
3
|
-
if (
|
|
4
|
-
const
|
|
5
|
-
switch (
|
|
6
|
-
case
|
|
1
|
+
import { KeyboardCode as e } from "@dnd-kit/core";
|
|
2
|
+
const y = [e.Down, e.Right, e.Up, e.Left], g = (h, s) => (f, { currentCoordinates: t, context: { activeNode: c } }) => {
|
|
3
|
+
if (f.preventDefault(), y.includes(f.code)) {
|
|
4
|
+
const i = c?.offsetWidth ?? 0, x = c?.offsetHeight ?? 0;
|
|
5
|
+
switch (f.code) {
|
|
6
|
+
case e.Right:
|
|
7
7
|
return {
|
|
8
|
-
...
|
|
9
|
-
x:
|
|
8
|
+
...t,
|
|
9
|
+
x: t.x + i + h
|
|
10
10
|
};
|
|
11
|
-
case
|
|
11
|
+
case e.Left:
|
|
12
12
|
return {
|
|
13
|
-
...
|
|
14
|
-
x:
|
|
13
|
+
...t,
|
|
14
|
+
x: t.x - i - h
|
|
15
15
|
};
|
|
16
|
-
case
|
|
16
|
+
case e.Down:
|
|
17
17
|
return {
|
|
18
|
-
...
|
|
19
|
-
y:
|
|
18
|
+
...t,
|
|
19
|
+
y: t.y + x + s
|
|
20
20
|
};
|
|
21
|
-
case
|
|
21
|
+
case e.Up:
|
|
22
22
|
return {
|
|
23
|
-
...
|
|
24
|
-
y:
|
|
23
|
+
...t,
|
|
24
|
+
y: t.y - x - s
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
export {
|
|
30
|
-
|
|
30
|
+
g as customCoordinatesGetterFactory
|
|
31
31
|
};
|
|
32
32
|
//# sourceMappingURL=customCoordinatesGetterFactory.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customCoordinatesGetterFactory.es.js","sources":["../../src/helpers/customCoordinatesGetterFactory.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { KeyboardCode, type KeyboardCoordinateGetter } from '@dnd-kit/core';\n\nconst directions: string[] = [KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, KeyboardCode.Left];\n\nexport const customCoordinatesGetterFactory =\n (columnGap: number, rowGap: number): KeyboardCoordinateGetter =>\n (event, { currentCoordinates, context: { activeNode } }) => {\n event.preventDefault();\n if (directions.includes(event.code)) {\n const width = activeNode?.offsetWidth ?? 0;\n const height = activeNode?.offsetHeight ?? 0;\n\n switch (event.code) {\n case KeyboardCode.Right:\n return {\n ...currentCoordinates,\n x: currentCoordinates.x + width + columnGap,\n };\n case KeyboardCode.Left:\n return {\n ...currentCoordinates,\n x: currentCoordinates.x - width - columnGap,\n };\n case KeyboardCode.Down:\n return {\n ...currentCoordinates,\n y: currentCoordinates.y + height + rowGap,\n };\n case KeyboardCode.Up:\n return {\n ...currentCoordinates,\n y: currentCoordinates.y - height - rowGap,\n };\n }\n }\n return undefined;\n };\n"],"names":["directions","KeyboardCode","customCoordinatesGetterFactory","columnGap","rowGap","event","currentCoordinates","activeNode","width","height"],"mappings":";AAIA,MAAMA,IAAuB,CAACC,EAAa,MAAMA,EAAa,OAAOA,EAAa,IAAIA,EAAa,IAAI,GAE1FC,IACT,CAACC,GAAmBC,MACpB,CAACC,GAAO,EAAE,oBAAAC,GAAoB,SAAS,EAAE,YAAAC,EAAA,QAAmB;AAExD,MADAF,EAAM,eAAA,GACFL,EAAW,SAASK,EAAM,IAAI,GAAG;AACjC,UAAMG,
|
|
1
|
+
{"version":3,"file":"customCoordinatesGetterFactory.es.js","sources":["../../src/helpers/customCoordinatesGetterFactory.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { KeyboardCode, type KeyboardCoordinateGetter } from '@dnd-kit/core';\n\nconst directions: string[] = [KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, KeyboardCode.Left];\n\nexport const customCoordinatesGetterFactory =\n (columnGap: number, rowGap: number): KeyboardCoordinateGetter =>\n (event, { currentCoordinates, context: { activeNode } }) => {\n event.preventDefault();\n if (directions.includes(event.code)) {\n const width = activeNode?.offsetWidth ?? 0;\n const height = activeNode?.offsetHeight ?? 0;\n\n switch (event.code) {\n case KeyboardCode.Right:\n return {\n ...currentCoordinates,\n x: currentCoordinates.x + width + columnGap,\n };\n case KeyboardCode.Left:\n return {\n ...currentCoordinates,\n x: currentCoordinates.x - width - columnGap,\n };\n case KeyboardCode.Down:\n return {\n ...currentCoordinates,\n y: currentCoordinates.y + height + rowGap,\n };\n case KeyboardCode.Up:\n return {\n ...currentCoordinates,\n y: currentCoordinates.y - height - rowGap,\n };\n }\n }\n return undefined;\n };\n"],"names":["directions","KeyboardCode","customCoordinatesGetterFactory","columnGap","rowGap","event","currentCoordinates","activeNode","width","height"],"mappings":";AAIA,MAAMA,IAAuB,CAACC,EAAa,MAAMA,EAAa,OAAOA,EAAa,IAAIA,EAAa,IAAI,GAE1FC,IACT,CAACC,GAAmBC,MACpB,CAACC,GAAO,EAAE,oBAAAC,GAAoB,SAAS,EAAE,YAAAC,EAAA,QAAmB;AAExD,MADAF,EAAM,eAAA,GACFL,EAAW,SAASK,EAAM,IAAI,GAAG;AACjC,UAAMG,IAAQD,GAAY,eAAe,GACnCE,IAASF,GAAY,gBAAgB;AAE3C,YAAQF,EAAM,MAAA;AAAA,MACV,KAAKJ,EAAa;AACd,eAAO;AAAA,UACH,GAAGK;AAAA,UACH,GAAGA,EAAmB,IAAIE,IAAQL;AAAA,QAAA;AAAA,MAE1C,KAAKF,EAAa;AACd,eAAO;AAAA,UACH,GAAGK;AAAA,UACH,GAAGA,EAAmB,IAAIE,IAAQL;AAAA,QAAA;AAAA,MAE1C,KAAKF,EAAa;AACd,eAAO;AAAA,UACH,GAAGK;AAAA,UACH,GAAGA,EAAmB,IAAIG,IAASL;AAAA,QAAA;AAAA,MAE3C,KAAKH,EAAa;AACd,eAAO;AAAA,UACH,GAAGK;AAAA,UACH,GAAGA,EAAmB,IAAIG,IAASL;AAAA,QAAA;AAAA,IACvC;AAAA,EAEZ;AAEJ;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
-
import { useBlockAssets as
|
|
3
|
-
import {
|
|
2
|
+
import { useBlockAssets as l } from "@frontify/app-bridge";
|
|
3
|
+
import { useContext as u, createContext as w } from "react";
|
|
4
4
|
const p = (t, o) => {
|
|
5
|
-
const { blockAssets: e, addAssetIdsToKey: n, deleteAssetIdsFromKey: a, updateAssetIdsFromKey: r } = o, d =
|
|
5
|
+
const { blockAssets: e, addAssetIdsToKey: n, deleteAssetIdsFromKey: a, updateAssetIdsFromKey: r } = o, d = e?.[t] || [];
|
|
6
6
|
return {
|
|
7
7
|
onAttachmentsAdd: async (s) => {
|
|
8
8
|
await n(
|
|
@@ -26,7 +26,7 @@ const p = (t, o) => {
|
|
|
26
26
|
attachments: d
|
|
27
27
|
};
|
|
28
28
|
}, v = (t, o) => {
|
|
29
|
-
const { onAttachmentsAdd: e, onAttachmentDelete: n, onAttachmentReplace: a, onAttachmentsSorted: r, attachments: d } = p(o,
|
|
29
|
+
const { onAttachmentsAdd: e, onAttachmentDelete: n, onAttachmentReplace: a, onAttachmentsSorted: r, attachments: d } = p(o, l(t));
|
|
30
30
|
return {
|
|
31
31
|
onAttachmentsAdd: e,
|
|
32
32
|
onAttachmentDelete: n,
|
|
@@ -35,7 +35,7 @@ const p = (t, o) => {
|
|
|
35
35
|
attachments: d,
|
|
36
36
|
appBridge: t
|
|
37
37
|
};
|
|
38
|
-
}, i =
|
|
38
|
+
}, i = w(null);
|
|
39
39
|
i.displayName = "AttachmentsContext";
|
|
40
40
|
const x = ({
|
|
41
41
|
appBridge: t,
|
|
@@ -53,7 +53,7 @@ const x = ({
|
|
|
53
53
|
const a = p(n, t);
|
|
54
54
|
return /* @__PURE__ */ m(i.Provider, { value: { ...a, appBridge: o }, children: e });
|
|
55
55
|
}, R = () => {
|
|
56
|
-
const t =
|
|
56
|
+
const t = u(i);
|
|
57
57
|
if (!t)
|
|
58
58
|
throw new Error(
|
|
59
59
|
"No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAttachments.es.js","sources":["../../src/hooks/useAttachments.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type AppBridgeBlock, type Asset, useBlockAssets } from '@frontify/app-bridge';\nimport { type ReactNode, createContext, useContext } from 'react';\n\nimport { type BlockProps } from '../index';\n\nexport const useAttachmentOperations = (attachmentKey: string, blockAssetBundle: ReturnType<typeof useBlockAssets>) => {\n const { blockAssets, addAssetIdsToKey, deleteAssetIdsFromKey, updateAssetIdsFromKey } = blockAssetBundle;\n const attachments = blockAssets?.[attachmentKey] || [];\n\n const onAttachmentsAdd = async (newAssets: Asset[]) => {\n await addAssetIdsToKey(\n attachmentKey,\n newAssets.map((asset) => asset.id),\n );\n };\n\n const onAttachmentDelete = async (assetToDelete: Asset) => {\n await deleteAssetIdsFromKey(attachmentKey, [assetToDelete.id]);\n };\n\n const onAttachmentReplace = async (attachmentToReplace: Asset, newAsset: Asset) => {\n const newAssetIds = attachments.map((attachment) =>\n attachment.id === attachmentToReplace.id ? newAsset.id : attachment.id,\n );\n\n await updateAssetIdsFromKey(attachmentKey, newAssetIds);\n };\n\n const onAttachmentsSorted = async (assets: Asset[]) => {\n const newAssetIds = assets.map((asset) => asset.id);\n\n await updateAssetIdsFromKey(attachmentKey, newAssetIds);\n };\n\n return {\n onAttachmentsAdd,\n onAttachmentDelete,\n onAttachmentReplace,\n onAttachmentsSorted,\n attachments,\n };\n};\n\nexport const useAttachments = (appBridge: AppBridgeBlock, attachmentKey: string) => {\n const { onAttachmentsAdd, onAttachmentDelete, onAttachmentReplace, onAttachmentsSorted, attachments } =\n useAttachmentOperations(attachmentKey, useBlockAssets(appBridge));\n\n return {\n onAttachmentsAdd,\n onAttachmentDelete,\n onAttachmentReplace,\n onAttachmentsSorted,\n attachments,\n appBridge,\n };\n};\n\nconst AttachmentsContext = createContext<ReturnType<typeof useAttachments> | null>(null);\nAttachmentsContext.displayName = 'AttachmentsContext';\n\nexport const AttachmentsProvider = ({\n appBridge,\n children,\n assetId,\n}: {\n appBridge: AppBridgeBlock;\n children: ReactNode;\n assetId: string;\n}) => {\n const attachmentContext = useAttachments(appBridge, assetId);\n\n return <AttachmentsContext.Provider value={attachmentContext}>{children}</AttachmentsContext.Provider>;\n};\n\nexport const AttachmentOperationsProvider = ({\n blockAssetBundle,\n appBridge,\n children,\n assetId,\n}: {\n blockAssetBundle: ReturnType<typeof useBlockAssets>;\n children: ReactNode;\n assetId: string;\n appBridge: AppBridgeBlock;\n}) => {\n const attachmentContext = useAttachmentOperations(assetId, blockAssetBundle);\n\n return (\n <AttachmentsContext.Provider value={{ ...attachmentContext, appBridge }}>\n {children}\n </AttachmentsContext.Provider>\n );\n};\n\nexport const useAttachmentsContext = () => {\n const context = useContext(AttachmentsContext);\n\n if (!context) {\n throw new Error(\n \"No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC\",\n );\n }\n\n return context;\n};\n\n/**\n * Block-level HOC for cases when there is only one attachment asset field related to the block.\n * Recommended for most cases.\n * If finer control is required over attachments, use {@link AttachmentsProvider} component.\n */\nexport const withAttachmentsProvider = <T extends BlockProps>(Component: (props: T) => ReactNode, assetId: string) => {\n const wrappedComponent = (props: T) => (\n <AttachmentsProvider appBridge={props.appBridge} assetId={assetId}>\n <Component {...props} />\n </AttachmentsProvider>\n );\n\n wrappedComponent.displayName = 'withAttachmentsProvider';\n\n return wrappedComponent;\n};\n"],"names":["useAttachmentOperations","attachmentKey","blockAssetBundle","blockAssets","addAssetIdsToKey","deleteAssetIdsFromKey","updateAssetIdsFromKey","attachments","newAssets","asset","assetToDelete","attachmentToReplace","newAsset","newAssetIds","attachment","assets","useAttachments","appBridge","onAttachmentsAdd","onAttachmentDelete","onAttachmentReplace","onAttachmentsSorted","useBlockAssets","AttachmentsContext","createContext","AttachmentsProvider","children","assetId","attachmentContext","AttachmentOperationsProvider","jsx","useAttachmentsContext","context","useContext","withAttachmentsProvider","Component","wrappedComponent","props"],"mappings":";;;AAOO,MAAMA,IAA0B,CAACC,GAAuBC,MAAwD;AACnH,QAAM,EAAE,aAAAC,GAAa,kBAAAC,GAAkB,uBAAAC,GAAuB,uBAAAC,MAA0BJ,GAClFK,
|
|
1
|
+
{"version":3,"file":"useAttachments.es.js","sources":["../../src/hooks/useAttachments.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type AppBridgeBlock, type Asset, useBlockAssets } from '@frontify/app-bridge';\nimport { type ReactNode, createContext, useContext } from 'react';\n\nimport { type BlockProps } from '../index';\n\nexport const useAttachmentOperations = (attachmentKey: string, blockAssetBundle: ReturnType<typeof useBlockAssets>) => {\n const { blockAssets, addAssetIdsToKey, deleteAssetIdsFromKey, updateAssetIdsFromKey } = blockAssetBundle;\n const attachments = blockAssets?.[attachmentKey] || [];\n\n const onAttachmentsAdd = async (newAssets: Asset[]) => {\n await addAssetIdsToKey(\n attachmentKey,\n newAssets.map((asset) => asset.id),\n );\n };\n\n const onAttachmentDelete = async (assetToDelete: Asset) => {\n await deleteAssetIdsFromKey(attachmentKey, [assetToDelete.id]);\n };\n\n const onAttachmentReplace = async (attachmentToReplace: Asset, newAsset: Asset) => {\n const newAssetIds = attachments.map((attachment) =>\n attachment.id === attachmentToReplace.id ? newAsset.id : attachment.id,\n );\n\n await updateAssetIdsFromKey(attachmentKey, newAssetIds);\n };\n\n const onAttachmentsSorted = async (assets: Asset[]) => {\n const newAssetIds = assets.map((asset) => asset.id);\n\n await updateAssetIdsFromKey(attachmentKey, newAssetIds);\n };\n\n return {\n onAttachmentsAdd,\n onAttachmentDelete,\n onAttachmentReplace,\n onAttachmentsSorted,\n attachments,\n };\n};\n\nexport const useAttachments = (appBridge: AppBridgeBlock, attachmentKey: string) => {\n const { onAttachmentsAdd, onAttachmentDelete, onAttachmentReplace, onAttachmentsSorted, attachments } =\n useAttachmentOperations(attachmentKey, useBlockAssets(appBridge));\n\n return {\n onAttachmentsAdd,\n onAttachmentDelete,\n onAttachmentReplace,\n onAttachmentsSorted,\n attachments,\n appBridge,\n };\n};\n\nconst AttachmentsContext = createContext<ReturnType<typeof useAttachments> | null>(null);\nAttachmentsContext.displayName = 'AttachmentsContext';\n\nexport const AttachmentsProvider = ({\n appBridge,\n children,\n assetId,\n}: {\n appBridge: AppBridgeBlock;\n children: ReactNode;\n assetId: string;\n}) => {\n const attachmentContext = useAttachments(appBridge, assetId);\n\n return <AttachmentsContext.Provider value={attachmentContext}>{children}</AttachmentsContext.Provider>;\n};\n\nexport const AttachmentOperationsProvider = ({\n blockAssetBundle,\n appBridge,\n children,\n assetId,\n}: {\n blockAssetBundle: ReturnType<typeof useBlockAssets>;\n children: ReactNode;\n assetId: string;\n appBridge: AppBridgeBlock;\n}) => {\n const attachmentContext = useAttachmentOperations(assetId, blockAssetBundle);\n\n return (\n <AttachmentsContext.Provider value={{ ...attachmentContext, appBridge }}>\n {children}\n </AttachmentsContext.Provider>\n );\n};\n\nexport const useAttachmentsContext = () => {\n const context = useContext(AttachmentsContext);\n\n if (!context) {\n throw new Error(\n \"No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC\",\n );\n }\n\n return context;\n};\n\n/**\n * Block-level HOC for cases when there is only one attachment asset field related to the block.\n * Recommended for most cases.\n * If finer control is required over attachments, use {@link AttachmentsProvider} component.\n */\nexport const withAttachmentsProvider = <T extends BlockProps>(Component: (props: T) => ReactNode, assetId: string) => {\n const wrappedComponent = (props: T) => (\n <AttachmentsProvider appBridge={props.appBridge} assetId={assetId}>\n <Component {...props} />\n </AttachmentsProvider>\n );\n\n wrappedComponent.displayName = 'withAttachmentsProvider';\n\n return wrappedComponent;\n};\n"],"names":["useAttachmentOperations","attachmentKey","blockAssetBundle","blockAssets","addAssetIdsToKey","deleteAssetIdsFromKey","updateAssetIdsFromKey","attachments","newAssets","asset","assetToDelete","attachmentToReplace","newAsset","newAssetIds","attachment","assets","useAttachments","appBridge","onAttachmentsAdd","onAttachmentDelete","onAttachmentReplace","onAttachmentsSorted","useBlockAssets","AttachmentsContext","createContext","AttachmentsProvider","children","assetId","attachmentContext","AttachmentOperationsProvider","jsx","useAttachmentsContext","context","useContext","withAttachmentsProvider","Component","wrappedComponent","props"],"mappings":";;;AAOO,MAAMA,IAA0B,CAACC,GAAuBC,MAAwD;AACnH,QAAM,EAAE,aAAAC,GAAa,kBAAAC,GAAkB,uBAAAC,GAAuB,uBAAAC,MAA0BJ,GAClFK,IAAcJ,IAAcF,CAAa,KAAK,CAAA;AA2BpD,SAAO;AAAA,IACH,kBA1BqB,OAAOO,MAAuB;AACnD,YAAMJ;AAAA,QACFH;AAAA,QACAO,EAAU,IAAI,CAACC,MAAUA,EAAM,EAAE;AAAA,MAAA;AAAA,IAEzC;AAAA,IAsBI,oBApBuB,OAAOC,MAAyB;AACvD,YAAML,EAAsBJ,GAAe,CAACS,EAAc,EAAE,CAAC;AAAA,IACjE;AAAA,IAmBI,qBAjBwB,OAAOC,GAA4BC,MAAoB;AAC/E,YAAMC,IAAcN,EAAY;AAAA,QAAI,CAACO,MACjCA,EAAW,OAAOH,EAAoB,KAAKC,EAAS,KAAKE,EAAW;AAAA,MAAA;AAGxE,YAAMR,EAAsBL,GAAeY,CAAW;AAAA,IAC1D;AAAA,IAYI,qBAVwB,OAAOE,MAAoB;AACnD,YAAMF,IAAcE,EAAO,IAAI,CAACN,MAAUA,EAAM,EAAE;AAElD,YAAMH,EAAsBL,GAAeY,CAAW;AAAA,IAC1D;AAAA,IAOI,aAAAN;AAAA,EAAA;AAER,GAEaS,IAAiB,CAACC,GAA2BhB,MAA0B;AAChF,QAAM,EAAE,kBAAAiB,GAAkB,oBAAAC,GAAoB,qBAAAC,GAAqB,qBAAAC,GAAqB,aAAAd,EAAA,IACpFP,EAAwBC,GAAeqB,EAAeL,CAAS,CAAC;AAEpE,SAAO;AAAA,IACH,kBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,aAAAd;AAAA,IACA,WAAAU;AAAA,EAAA;AAER,GAEMM,IAAqBC,EAAwD,IAAI;AACvFD,EAAmB,cAAc;AAE1B,MAAME,IAAsB,CAAC;AAAA,EAChC,WAAAR;AAAA,EACA,UAAAS;AAAA,EACA,SAAAC;AACJ,MAIM;AACF,QAAMC,IAAoBZ,EAAeC,GAAWU,CAAO;AAE3D,2BAAQJ,EAAmB,UAAnB,EAA4B,OAAOK,GAAoB,UAAAF,GAAS;AAC5E,GAEaG,IAA+B,CAAC;AAAA,EACzC,kBAAA3B;AAAA,EACA,WAAAe;AAAA,EACA,UAAAS;AAAA,EACA,SAAAC;AACJ,MAKM;AACF,QAAMC,IAAoB5B,EAAwB2B,GAASzB,CAAgB;AAE3E,SACI,gBAAA4B,EAACP,EAAmB,UAAnB,EAA4B,OAAO,EAAE,GAAGK,GAAmB,WAAAX,KACvD,UAAAS,GACL;AAER,GAEaK,IAAwB,MAAM;AACvC,QAAMC,IAAUC,EAAWV,CAAkB;AAE7C,MAAI,CAACS;AACD,UAAM,IAAI;AAAA,MACN;AAAA,IAAA;AAIR,SAAOA;AACX,GAOaE,IAA0B,CAAuBC,GAAoCR,MAAoB;AAClH,QAAMS,IAAmB,CAACC,MACtB,gBAAAP,EAACL,GAAA,EAAoB,WAAWY,EAAM,WAAW,SAAAV,GAC7C,UAAA,gBAAAG,EAACK,GAAA,EAAW,GAAGE,GAAO,GAC1B;AAGJ,SAAAD,EAAiB,cAAc,2BAExBA;AACX;"}
|