@frontify/fondue 12.0.0-beta.315 → 12.0.0-beta.316

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.
@@ -1,14 +1,14 @@
1
- import s from "react";
1
+ import n from "react";
2
2
  import { useElementProps as i } from "@udecode/plate";
3
3
  import { LINK_PLUGIN as m } from "../id.es.js";
4
- import { getUrlFromLinkOrLegacyLink as a } from "../utils/getUrl.es.js";
5
- import { useRichTextEditorContext as p } from "../../../context/RichTextEditorContext.es.js";
4
+ import { getUrlFromLinkOrLegacyLink as p } from "../utils/getUrl.es.js";
5
+ import { useRichTextEditorContext as a } from "../../../context/RichTextEditorContext.es.js";
6
6
  const c = (r) => ({
7
7
  ...i({
8
8
  ...r,
9
9
  elementToAttributes: (t) => ({
10
- href: a(t),
11
- target: t.target || "_blank"
10
+ href: p(t),
11
+ target: t.target || "_self"
12
12
  })
13
13
  }),
14
14
  // quick fix: hovering <a> with href loses the editor focus
@@ -16,8 +16,8 @@ const c = (r) => ({
16
16
  t.stopPropagation();
17
17
  }
18
18
  }), h = (r) => {
19
- const e = c(r), { attributes: t, children: o } = r, { styles: n } = p();
20
- return /* @__PURE__ */ s.createElement("a", { ...t, href: e.href, target: e.target, style: n[m] }, o);
19
+ const e = c(r), { attributes: t, children: o } = r, { styles: s } = a();
20
+ return /* @__PURE__ */ n.createElement("a", { ...t, href: e.href, target: e.target, style: s[m] }, o);
21
21
  };
22
22
  export {
23
23
  h as LinkMarkupElementNode
@@ -1 +1 @@
1
- {"version":3,"file":"LinkMarkupElementNode.es.js","sources":["../../../../../../src/components/RichTextEditor/Plugins/LinkPlugin/LinkMarkupElement/LinkMarkupElementNode.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React, { MouseEvent } from 'react';\nimport { HTMLPropsAs, LinkRootProps, useElementProps } from '@udecode/plate';\nimport { getUrlFromLinkOrLegacyLink } from '../utils';\nimport { TLinkElement } from '../types';\nimport { useRichTextEditorContext } from '@components/RichTextEditor/context';\nimport { LINK_PLUGIN } from '../id';\n\nconst useLink = (props: LinkRootProps): HTMLPropsAs<'a'> => {\n const _props = useElementProps<TLinkElement, 'a'>({\n ...props,\n elementToAttributes: (element) => ({\n href: getUrlFromLinkOrLegacyLink(element),\n target: element.target || '_blank',\n }),\n });\n\n return {\n ..._props,\n // quick fix: hovering <a> with href loses the editor focus\n onMouseOver: (e: MouseEvent) => {\n e.stopPropagation();\n },\n };\n};\n\nexport const LinkMarkupElementNode = (props: LinkRootProps) => {\n const htmlProps = useLink(props);\n const { attributes, children } = props;\n const { styles } = useRichTextEditorContext();\n\n return (\n <a {...attributes} href={htmlProps.href} target={htmlProps.target} style={styles[LINK_PLUGIN]}>\n {children}\n </a>\n );\n};\n"],"names":["useLink","props","useElementProps","element","getUrlFromLinkOrLegacyLink","e","LinkMarkupElementNode","htmlProps","attributes","children","styles","useRichTextEditorContext","React","LINK_PLUGIN"],"mappings":";;;;;AASA,MAAMA,IAAU,CAACC,OASN;AAAA,EACH,GATWC,EAAmC;AAAA,IAC9C,GAAGD;AAAA,IACH,qBAAqB,CAACE,OAAa;AAAA,MAC/B,MAAMC,EAA2BD,CAAO;AAAA,MACxC,QAAQA,EAAQ,UAAU;AAAA,IAAA;AAAA,EAC9B,CACH;AAAA;AAAA,EAKG,aAAa,CAACE,MAAkB;AAC5B,IAAAA,EAAE,gBAAgB;AAAA,EACtB;AAAA,IAIKC,IAAwB,CAACL,MAAyB;AACrD,QAAAM,IAAYP,EAAQC,CAAK,GACzB,EAAE,YAAAO,GAAY,UAAAC,EAAa,IAAAR,GAC3B,EAAE,QAAAS,MAAWC;AAEnB,SACK,gBAAAC,EAAA,cAAA,KAAA,EAAG,GAAGJ,GAAY,MAAMD,EAAU,MAAM,QAAQA,EAAU,QAAQ,OAAOG,EAAOG,CAAW,KACvFJ,CACL;AAER;"}
1
+ {"version":3,"file":"LinkMarkupElementNode.es.js","sources":["../../../../../../src/components/RichTextEditor/Plugins/LinkPlugin/LinkMarkupElement/LinkMarkupElementNode.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React, { MouseEvent } from 'react';\nimport { HTMLPropsAs, LinkRootProps, useElementProps } from '@udecode/plate';\nimport { getUrlFromLinkOrLegacyLink } from '../utils';\nimport { TLinkElement } from '../types';\nimport { useRichTextEditorContext } from '@components/RichTextEditor/context';\nimport { LINK_PLUGIN } from '../id';\n\nconst useLink = (props: LinkRootProps): HTMLPropsAs<'a'> => {\n const _props = useElementProps<TLinkElement, 'a'>({\n ...props,\n elementToAttributes: (element) => ({\n href: getUrlFromLinkOrLegacyLink(element),\n target: element.target || '_self',\n }),\n });\n\n return {\n ..._props,\n // quick fix: hovering <a> with href loses the editor focus\n onMouseOver: (e: MouseEvent) => {\n e.stopPropagation();\n },\n };\n};\n\nexport const LinkMarkupElementNode = (props: LinkRootProps) => {\n const htmlProps = useLink(props);\n const { attributes, children } = props;\n const { styles } = useRichTextEditorContext();\n\n return (\n <a {...attributes} href={htmlProps.href} target={htmlProps.target} style={styles[LINK_PLUGIN]}>\n {children}\n </a>\n );\n};\n"],"names":["useLink","props","useElementProps","element","getUrlFromLinkOrLegacyLink","e","LinkMarkupElementNode","htmlProps","attributes","children","styles","useRichTextEditorContext","React","LINK_PLUGIN"],"mappings":";;;;;AASA,MAAMA,IAAU,CAACC,OASN;AAAA,EACH,GATWC,EAAmC;AAAA,IAC9C,GAAGD;AAAA,IACH,qBAAqB,CAACE,OAAa;AAAA,MAC/B,MAAMC,EAA2BD,CAAO;AAAA,MACxC,QAAQA,EAAQ,UAAU;AAAA,IAAA;AAAA,EAC9B,CACH;AAAA;AAAA,EAKG,aAAa,CAACE,MAAkB;AAC5B,IAAAA,EAAE,gBAAgB;AAAA,EACtB;AAAA,IAIKC,IAAwB,CAACL,MAAyB;AACrD,QAAAM,IAAYP,EAAQC,CAAK,GACzB,EAAE,YAAAO,GAAY,UAAAC,EAAa,IAAAR,GAC3B,EAAE,QAAAS,MAAWC;AAEnB,SACK,gBAAAC,EAAA,cAAA,KAAA,EAAG,GAAGJ,GAAY,MAAMD,EAAU,MAAM,QAAQA,EAAU,QAAQ,OAAOG,EAAOG,CAAW,KACvFJ,CACL;AAER;"}
@@ -2,7 +2,7 @@ import { reactCssPropsToCss as s } from "../utils/reactCssPropsToCss.es.js";
2
2
  const i = (t, n, u, l) => {
3
3
  const a = l["button-plugin"], o = t.buttonStyle ?? "primary", b = `button${o.charAt(0).toUpperCase()}${o.slice(1)}`, e = a[b], r = s(e);
4
4
  return `<a href="${t.url}"
5
- target="${t.target ?? "_blank"}"
5
+ target="${t.target ?? "_self"}"
6
6
  dir="auto"
7
7
  style="${r}"
8
8
  class="${u}"
@@ -1 +1 @@
1
- {"version":3,"file":"button.es.js","sources":["../../../../../src/components/RichTextEditor/serializer/nodes/button.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { TElement } from '@udecode/plate';\nimport { reactCssPropsToCss } from '../utils/reactCssPropsToCss';\nimport { CSSPropertiesHover } from '../types';\n\nexport type ButtonStylesType = Record<string, Record<string, CSSPropertiesHover>>;\n\nexport const buttonNode = (node: TElement, children: string, defaultClassNames: string, styles: ButtonStylesType) => {\n const buttonStyles = styles['button-plugin'];\n const buttonTypeString = (node.buttonStyle as string) ?? 'primary';\n const buttonType = `button${buttonTypeString.charAt(0).toUpperCase()}${buttonTypeString.slice(1)}`;\n const buttonStyle = buttonStyles[buttonType];\n\n const defaultStyles = reactCssPropsToCss(buttonStyle);\n return `<a href=\"${node.url}\"\n target=\"${node.target ?? '_blank'}\"\n dir=\"auto\"\n style=\"${defaultStyles}\"\n class=\"${defaultClassNames}\"\n onmouseenter=\"this.setAttribute('style', '${defaultStyles} ${reactCssPropsToCss(buttonStyle.hover)}');\"\n onmouseleave=\"this.setAttribute('style', '${reactCssPropsToCss(buttonStyle)}');\"\n >${children}</a>`;\n};\n"],"names":["buttonNode","node","children","defaultClassNames","styles","buttonStyles","buttonTypeString","buttonType","buttonStyle","defaultStyles","reactCssPropsToCss"],"mappings":";AAQO,MAAMA,IAAa,CAACC,GAAgBC,GAAkBC,GAA2BC,MAA6B;AAC3G,QAAAC,IAAeD,EAAO,eAAe,GACrCE,IAAoBL,EAAK,eAA0B,WACnDM,IAAa,SAASD,EAAiB,OAAO,CAAC,EAAE,YAAY,IAAIA,EAAiB,MAAM,CAAC,KACzFE,IAAcH,EAAaE,CAAU,GAErCE,IAAgBC,EAAmBF,CAAW;AACpD,SAAO,YAAYP,EAAK;AAAA,0BACFA,EAAK,UAAU;AAAA;AAAA,yBAEhBQ;AAAA,yBACAN;AAAA,4DACmCM,KAAiBC,EAAmBF,EAAY,KAAK;AAAA,4DACrDE,EAAmBF,CAAW;AAAA,mBACvEN;AACnB;"}
1
+ {"version":3,"file":"button.es.js","sources":["../../../../../src/components/RichTextEditor/serializer/nodes/button.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { TElement } from '@udecode/plate';\nimport { reactCssPropsToCss } from '../utils/reactCssPropsToCss';\nimport { CSSPropertiesHover } from '../types';\n\nexport type ButtonStylesType = Record<string, Record<string, CSSPropertiesHover>>;\n\nexport const buttonNode = (node: TElement, children: string, defaultClassNames: string, styles: ButtonStylesType) => {\n const buttonStyles = styles['button-plugin'];\n const buttonTypeString = (node.buttonStyle as string) ?? 'primary';\n const buttonType = `button${buttonTypeString.charAt(0).toUpperCase()}${buttonTypeString.slice(1)}`;\n const buttonStyle = buttonStyles[buttonType];\n\n const defaultStyles = reactCssPropsToCss(buttonStyle);\n return `<a href=\"${node.url}\"\n target=\"${node.target ?? '_self'}\"\n dir=\"auto\"\n style=\"${defaultStyles}\"\n class=\"${defaultClassNames}\"\n onmouseenter=\"this.setAttribute('style', '${defaultStyles} ${reactCssPropsToCss(buttonStyle.hover)}');\"\n onmouseleave=\"this.setAttribute('style', '${reactCssPropsToCss(buttonStyle)}');\"\n >${children}</a>`;\n};\n"],"names":["buttonNode","node","children","defaultClassNames","styles","buttonStyles","buttonTypeString","buttonType","buttonStyle","defaultStyles","reactCssPropsToCss"],"mappings":";AAQO,MAAMA,IAAa,CAACC,GAAgBC,GAAkBC,GAA2BC,MAA6B;AAC3G,QAAAC,IAAeD,EAAO,eAAe,GACrCE,IAAoBL,EAAK,eAA0B,WACnDM,IAAa,SAASD,EAAiB,OAAO,CAAC,EAAE,YAAY,IAAIA,EAAiB,MAAM,CAAC,KACzFE,IAAcH,EAAaE,CAAU,GAErCE,IAAgBC,EAAmBF,CAAW;AACpD,SAAO,YAAYP,EAAK;AAAA,0BACFA,EAAK,UAAU;AAAA;AAAA,yBAEhBQ;AAAA,yBACAN;AAAA,4DACmCM,KAAiBC,EAAmBF,EAAY,KAAK;AAAA,4DACrDE,EAAmBF,CAAW;AAAA,mBACvEN;AACnB;"}
@@ -1,13 +1,13 @@
1
- import p from "escape-html";
2
- import { reactCssPropsToCss as e } from "../utils/reactCssPropsToCss.es.js";
3
- import { LINK_PLUGIN as f } from "../../Plugins/LinkPlugin/id.es.js";
1
+ import e from "escape-html";
2
+ import { reactCssPropsToCss as f } from "../utils/reactCssPropsToCss.es.js";
3
+ import { LINK_PLUGIN as p } from "../../Plugins/LinkPlugin/id.es.js";
4
4
  const u = (r, a, s, $) => {
5
5
  var l;
6
6
  if (r.chosenLink) {
7
7
  const { chosenLink: t } = r;
8
- return `<a dir="auto" class="${s}" style="${e($[f])}" target=${t != null && t.openInNewTab ? "_blank" : "_self"} href="${p((l = t == null ? void 0 : t.searchResult) == null ? void 0 : l.link)}">${a}</a>`;
8
+ return `<a dir="auto" class="${s}" style="${f($[p])}" target=${t != null && t.openInNewTab ? "_blank" : "_self"} href="${e((l = t == null ? void 0 : t.searchResult) == null ? void 0 : l.link)}">${a}</a>`;
9
9
  }
10
- return `<a dir="auto" class="${s}" style="${e($[f])}" target="${(r == null ? void 0 : r.target) ?? "_blank"}" href="${p(r.url)}">${a}</a>`;
10
+ return `<a dir="auto" class="${s}" style="${f($[p])}" target="${(r == null ? void 0 : r.target) ?? "_self"}" href="${e(r.url)}">${a}</a>`;
11
11
  };
12
12
  export {
13
13
  u as linkNode
@@ -1 +1 @@
1
- {"version":3,"file":"link.es.js","sources":["../../../../../src/components/RichTextEditor/serializer/nodes/link.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { TLinkElement } from '@components/RichTextEditor/Plugins/LinkPlugin/types';\nimport { TElement } from '@udecode/plate';\nimport escapeHtml from 'escape-html';\nimport { reactCssPropsToCss } from '../utils/reactCssPropsToCss';\nimport { CSSPropertiesHover } from '../types';\nimport { LINK_PLUGIN } from '@components/RichTextEditor/Plugins/LinkPlugin/id';\n\nexport const linkNode = (\n node: TElement,\n children: string,\n defaultClassNames: string,\n styles: Record<string, CSSPropertiesHover>,\n) => {\n if (node.chosenLink) {\n const { chosenLink } = node as TLinkElement;\n return `<a dir=\"auto\" class=\"${defaultClassNames}\" style=\"${reactCssPropsToCss(styles[LINK_PLUGIN])}\" target=${\n chosenLink?.openInNewTab ? '_blank' : '_self'\n } href=\"${escapeHtml(chosenLink?.searchResult?.link)}\">${children}</a>`;\n }\n return `<a dir=\"auto\" class=\"${defaultClassNames}\" style=\"${reactCssPropsToCss(styles[LINK_PLUGIN])}\" target=\"${\n node?.target ?? '_blank'\n }\" href=\"${escapeHtml(node.url as string)}\">${children}</a>`;\n};\n"],"names":["linkNode","node","children","defaultClassNames","styles","chosenLink","reactCssPropsToCss","LINK_PLUGIN","escapeHtml","_a"],"mappings":";;;AASO,MAAMA,IAAW,CACpBC,GACAC,GACAC,GACAC,MACC;;AACD,MAAIH,EAAK,YAAY;AACX,UAAA,EAAE,YAAAI,EAAe,IAAAJ;AACvB,WAAO,wBAAwBE,aAA6BG,EAAmBF,EAAOG,CAAW,CAAC,aAC9FF,KAAA,QAAAA,EAAY,eAAe,WAAW,iBAChCG,GAAWC,IAAAJ,KAAA,gBAAAA,EAAY,iBAAZ,gBAAAI,EAA0B,IAAI,MAAMP;AAAA,EAC7D;AACA,SAAO,wBAAwBC,aAA6BG,EAAmBF,EAAOG,CAAW,CAAC,eAC9FN,KAAA,gBAAAA,EAAM,WAAU,mBACTO,EAAWP,EAAK,GAAa,MAAMC;AAClD;"}
1
+ {"version":3,"file":"link.es.js","sources":["../../../../../src/components/RichTextEditor/serializer/nodes/link.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { TLinkElement } from '@components/RichTextEditor/Plugins/LinkPlugin/types';\nimport { TElement } from '@udecode/plate';\nimport escapeHtml from 'escape-html';\nimport { reactCssPropsToCss } from '../utils/reactCssPropsToCss';\nimport { CSSPropertiesHover } from '../types';\nimport { LINK_PLUGIN } from '@components/RichTextEditor/Plugins/LinkPlugin/id';\n\nexport const linkNode = (\n node: TElement,\n children: string,\n defaultClassNames: string,\n styles: Record<string, CSSPropertiesHover>,\n) => {\n if (node.chosenLink) {\n const { chosenLink } = node as TLinkElement;\n return `<a dir=\"auto\" class=\"${defaultClassNames}\" style=\"${reactCssPropsToCss(styles[LINK_PLUGIN])}\" target=${\n chosenLink?.openInNewTab ? '_blank' : '_self'\n } href=\"${escapeHtml(chosenLink?.searchResult?.link)}\">${children}</a>`;\n }\n return `<a dir=\"auto\" class=\"${defaultClassNames}\" style=\"${reactCssPropsToCss(styles[LINK_PLUGIN])}\" target=\"${\n node?.target ?? '_self'\n }\" href=\"${escapeHtml(node.url as string)}\">${children}</a>`;\n};\n"],"names":["linkNode","node","children","defaultClassNames","styles","chosenLink","reactCssPropsToCss","LINK_PLUGIN","escapeHtml","_a"],"mappings":";;;AASO,MAAMA,IAAW,CACpBC,GACAC,GACAC,GACAC,MACC;;AACD,MAAIH,EAAK,YAAY;AACX,UAAA,EAAE,YAAAI,EAAe,IAAAJ;AACvB,WAAO,wBAAwBE,aAA6BG,EAAmBF,EAAOG,CAAW,CAAC,aAC9FF,KAAA,QAAAA,EAAY,eAAe,WAAW,iBAChCG,GAAWC,IAAAJ,KAAA,gBAAAA,EAAY,iBAAZ,gBAAAI,EAA0B,IAAI,MAAMP;AAAA,EAC7D;AACA,SAAO,wBAAwBC,aAA6BG,EAAmBF,EAAOG,CAAW,CAAC,eAC9FN,KAAA,gBAAAA,EAAM,WAAU,kBACTO,EAAWP,EAAK,GAAa,MAAMC;AAClD;"}