@makeswift/runtime 0.0.0-20230711141354 → 0.0.0-20230711144946

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.
@@ -19,18 +19,19 @@ var React = require("react");
19
19
  var reactPage = require("./react-page.cjs.js");
20
20
  require("./actions.cjs.js");
21
21
  require("slate");
22
- require("./state/breakpoints.cjs.js");
23
- require("is-hotkey");
24
- var jsxRuntime = require("react/jsx-runtime");
25
22
  require("slate-react");
26
- var next = require("./index.cjs.js");
27
- require("@emotion/css");
23
+ var index = require("./index.cjs5.js");
28
24
  require("uuid");
25
+ var next = require("./index.cjs.js");
26
+ var jsxRuntime = require("react/jsx-runtime");
29
27
  require("redux");
30
28
  require("redux-thunk");
29
+ require("./state/breakpoints.cjs.js");
30
+ require("zod");
31
+ require("@emotion/css");
31
32
  require("@emotion/serialize");
32
33
  require("@emotion/utils");
33
- require("zod");
34
+ require("is-hotkey");
34
35
  require("use-sync-external-store/shim/with-selector");
35
36
  require("next/dynamic");
36
37
  require("./text-input.cjs.js");
@@ -65,7 +66,7 @@ const ReadOnlyTextV2 = React.forwardRef(function ReadOnlyText({
65
66
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
66
67
  ref,
67
68
  children: descendantsAsString === "" ? /* @__PURE__ */ jsxRuntime.jsx(Placeholder, {}) : /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
68
- plugins: (_b = definition == null ? void 0 : definition.config.plugins) != null ? _b : [],
69
+ plugins: ((_b = definition == null ? void 0 : definition.config) == null ? void 0 : _b.mode) === reactPage.RichTextV2Mode.Inline ? [reactPage.InlineModePlugin()] : [reactPage.BlockPlugin(), reactPage.TypographyPlugin(), reactPage.TextAlignPlugin(), reactPage.InlinePlugin(), index.LinkPlugin()],
69
70
  descendants
70
71
  })
71
72
  });
@@ -164,17 +165,17 @@ function Descendants({
164
165
  plugins
165
166
  }) {
166
167
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
167
- children: descendants.map((descendant, index) => {
168
+ children: descendants.map((descendant, index2) => {
168
169
  if (isText(descendant)) {
169
170
  return /* @__PURE__ */ jsxRuntime.jsx(LeafComponent, {
170
171
  plugins,
171
172
  leaf: descendant
172
- }, index);
173
+ }, index2);
173
174
  }
174
175
  return /* @__PURE__ */ jsxRuntime.jsx(ElementComponent, {
175
176
  descendant,
176
177
  plugins
177
- }, index);
178
+ }, index2);
178
179
  })
179
180
  });
180
181
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ReadOnlyTextV2.cjs.js","sources":["../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef } from 'react'\nimport {\n RichTextV2ControlData,\n RichTextV2ControlDefinition,\n RichTextV2Mode,\n RichTextV2Plugin,\n} from '../../../../controls'\nimport { useStyle } from '../../use-style'\nimport { Descendant, Element, Text } from 'slate'\nimport { InlineType, Block, BlockType } from '../../../../slate'\nimport { ControlValue } from '../control'\nimport { RenderElementProps, RenderLeafProps } from 'slate-react'\n\ntype Props = {\n text: RichTextV2ControlData\n definition: RichTextV2ControlDefinition | null\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text: { descendants }, definition }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = getText(descendants, definition?.config.mode ?? RichTextV2Mode.Block)\n\n return (\n <div ref={ref}>\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants plugins={definition?.config.plugins ?? []} descendants={descendants} />\n )}\n </div>\n )\n})\n\nexport default ReadOnlyTextV2\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\ntype LeafProps = {\n leaf: Text\n plugins: RichTextV2Plugin[]\n}\n\nexport function LeafComponent({ plugins, ...props }: LeafProps) {\n function initialRenderLeaf({ leaf }: RenderLeafProps) {\n return <span className={leaf.className}>{leaf.text === '' ? '\\uFEFF' : leaf.text}</span>\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf({ attributes: {} as any, leaf: props.leaf, children: null, text: props.leaf })\n}\n\ntype ElementProps = {\n descendant: Element\n plugins: RichTextV2Plugin[]\n}\n\nfunction ElementComponent({ plugins, ...props }: ElementProps) {\n function initialRenderElement(props: RenderElementProps) {\n return <Descendants descendants={props.element.children} plugins={plugins} />\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (control?.definition == null || renderElement == null) return renderFn(props)\n\n if (control.getElementValue == null) return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement({ attributes: {} as any, children: null, element: props.descendant })\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: Descendant): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({\n descendants,\n plugins,\n}: {\n plugins: RichTextV2Plugin[]\n descendants: Descendant[]\n}) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <LeafComponent key={index} plugins={plugins} leaf={descendant} />\n }\n\n return <ElementComponent key={index} descendant={descendant} plugins={plugins} />\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Block {\n if (isText(descendant)) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant, mode: RichTextV2Mode): string {\n if (isText(descendant)) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case BlockType.Default:\n return mode === RichTextV2Mode.Inline\n ? descendant.children.map(descendant => getTextByDescendant(descendant, mode)).join('') ??\n ''\n : descendant.children\n .map(descendant => getTextByDescendant(descendant, mode))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return (\n descendant.children.map(descendant => getTextByDescendant(descendant, mode)).join('') ?? ''\n )\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant, mode))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[], mode: RichTextV2Mode): string {\n return descendant.map(node => getTextByDescendant(node, mode)).join('\\n')\n}\n"],"names":["ReadOnlyTextV2","forwardRef","text","descendants","definition","ref","descendantsAsString","getText","config","mode","RichTextV2Mode","Block","_jsx","plugins","useStyle","display","width","maxWidth","whiteSpace","opacity","verticalAlign","props","leaf","className","renderLeaf","reduce","renderFn","plugin","control","getLeafValue","undefined","ControlValue","value","initialRenderLeaf","attributes","children","element","renderElement","getElementValue","initialRenderElement","descendant","node","_Fragment","map","index","isText","type","BlockType","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","Paragraph","Default","OrderedList","UnorderedList","ListItem","ListItemChild","Inline","getTextByDescendant","join","every","isBlock","InlineType","Link","Code","SubScript","SuperScript"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBMA,MAAAA,iBAAiBC,MAAAA,WAAW,sBAChC;AAAA,EAAEC,MAAM;AAAA,IAAEC;AAAAA;AAAAA,EAAeC;AAAAA,GACzBC,KACA;;AACA,QAAMC,sBAAsBC,QAAQJ,aAAaC,+CAAYI,OAAOC,SAAnBL,YAA2BM,yBAAeC,KAAxD;AAGjC,wCAAA,OAAA;AAAA,IAAK;AAAA,IACFL,UAAAA,wBAAwB,KACvBM,2BAAA,IAAC,aAAD,EAAA,IAEAA,2BAAA,IAAC,aAAD;AAAA,MAAa,SAASR,+CAAYI,OAAOK,YAAnBT,YAA8B,CAApD;AAAA,MAAwD;AAAA,IAAA,CAAxD;AAAA,EAAA,CALN;AASD,CAfgC;AAmBjC,qBAAqB;AAAA,EAAEF,OAAO;AAAA,GAA2C;AAErE,wCAAA,QAAA;AAAA,IACE,WAAWY,UAAAA,SAAS;AAAA,MAClBC,SAAS;AAAA,MACTC,OAAO;AAAA,MACPC,UAAU;AAAA,MACVC,YAAY;AAAA,MACZC,SAAS;AAAA,MACTC,eAAe;AAAA,IAAA,CANE;AAAA,IASlBlB,UAAAA;AAAAA,EAAAA,CAXL;AAcD;AAO6B,uBAAA,IAAkC;AAAlC,eAAEW;AAAAA;AAAAA,MAAF,IAAcQ,kBAAd,IAAcA;AAAAA,IAAZR;AAAAA;AACH,6BAAA;AAAA,IAAES;AAAAA,KAAyB;AAC7C,0CAAA,QAAA;AAAA,MAAM,WAAWA,KAAKC;AAAAA,MAAYD,UAAAA,KAAKpB,SAAS,KAAK,WAAWoB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D,MAAAzB,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAA0B/B,MAA8B;AAChE+B,SAAAA,WAAWG,IAAIF,CAAQqB,SAAAA,oBAAoBrB,MAAMhC,IAAP,CAA1C,EAAwDsD,KAAK,IAA7D;AACR;;;"}
1
+ {"version":3,"file":"ReadOnlyTextV2.cjs.js","sources":["../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef } from 'react'\nimport {\n RichTextV2ControlData,\n RichTextV2ControlDefinition,\n RichTextV2Mode,\n RichTextV2Plugin,\n} from '../../../../controls'\nimport { useStyle } from '../../use-style'\nimport { Descendant, Element, Text } from 'slate'\nimport {\n InlineType,\n Block,\n BlockType,\n BlockPlugin,\n InlineModePlugin,\n InlinePlugin,\n LinkPlugin,\n TextAlignPlugin,\n TypographyPlugin,\n} from '../../../../slate'\nimport { ControlValue } from '../control'\nimport { RenderElementProps, RenderLeafProps } from 'slate-react'\n\ntype Props = {\n text: RichTextV2ControlData\n definition: RichTextV2ControlDefinition | null\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text: { descendants }, definition }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = getText(descendants, definition?.config.mode ?? RichTextV2Mode.Block)\n\n return (\n <div ref={ref}>\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants\n plugins={\n /**\n * TODO: we are manually referencing our default plugins for each mode here because\n * Referencing the real LinkPlugin causes a circular dependency.\n * When circular dependencies calm down we should update the plugin definition to use real plugins,\n * and just use the plugins that are defined by our config.\n */\n // definition?.config?.plugins ,\n definition?.config?.mode === RichTextV2Mode.Inline\n ? [InlineModePlugin()]\n : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]\n }\n descendants={descendants}\n />\n )}\n </div>\n )\n})\n\nexport default ReadOnlyTextV2\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\ntype LeafProps = {\n leaf: Text\n plugins: RichTextV2Plugin[]\n}\n\nexport function LeafComponent({ plugins, ...props }: LeafProps) {\n function initialRenderLeaf({ leaf }: RenderLeafProps) {\n return <span className={leaf.className}>{leaf.text === '' ? '\\uFEFF' : leaf.text}</span>\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf({ attributes: {} as any, leaf: props.leaf, children: null, text: props.leaf })\n}\n\ntype ElementProps = {\n descendant: Element\n plugins: RichTextV2Plugin[]\n}\n\nfunction ElementComponent({ plugins, ...props }: ElementProps) {\n function initialRenderElement(props: RenderElementProps) {\n return <Descendants descendants={props.element.children} plugins={plugins} />\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (control?.definition == null || renderElement == null) return renderFn(props)\n\n if (control.getElementValue == null) return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement({ attributes: {} as any, children: null, element: props.descendant })\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: Descendant): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({\n descendants,\n plugins,\n}: {\n plugins: RichTextV2Plugin[]\n descendants: Descendant[]\n}) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <LeafComponent key={index} plugins={plugins} leaf={descendant} />\n }\n\n return <ElementComponent key={index} descendant={descendant} plugins={plugins} />\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Block {\n if (isText(descendant)) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant, mode: RichTextV2Mode): string {\n if (isText(descendant)) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case BlockType.Default:\n return mode === RichTextV2Mode.Inline\n ? descendant.children.map(descendant => getTextByDescendant(descendant, mode)).join('') ??\n ''\n : descendant.children\n .map(descendant => getTextByDescendant(descendant, mode))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return (\n descendant.children.map(descendant => getTextByDescendant(descendant, mode)).join('') ?? ''\n )\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant, mode))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[], mode: RichTextV2Mode): string {\n return descendant.map(node => getTextByDescendant(node, mode)).join('\\n')\n}\n"],"names":["ReadOnlyTextV2","forwardRef","text","descendants","definition","ref","descendantsAsString","getText","config","mode","RichTextV2Mode","Block","_jsx","Inline","InlineModePlugin","BlockPlugin","TypographyPlugin","TextAlignPlugin","InlinePlugin","LinkPlugin","useStyle","display","width","maxWidth","whiteSpace","opacity","verticalAlign","plugins","props","leaf","className","renderLeaf","reduce","renderFn","plugin","control","getLeafValue","undefined","ControlValue","value","initialRenderLeaf","attributes","children","element","renderElement","getElementValue","initialRenderElement","descendant","node","_Fragment","map","index","isText","type","BlockType","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","Paragraph","Default","OrderedList","UnorderedList","ListItem","ListItemChild","getTextByDescendant","join","every","isBlock","InlineType","Link","Code","SubScript","SuperScript"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BMA,MAAAA,iBAAiBC,MAAAA,WAAW,sBAChC;AAAA,EAAEC,MAAM;AAAA,IAAEC;AAAAA;AAAAA,EAAeC;AAAAA,GACzBC,KACA;;AACA,QAAMC,sBAAsBC,QAAQJ,aAAaC,+CAAYI,OAAOC,SAAnBL,YAA2BM,yBAAeC,KAAxD;AAGjC,wCAAA,OAAA;AAAA,IAAK;AAAA,IACFL,UAAAA,wBAAwB,KACvBM,2BAAA,IAAC,aAAD,EAAA,IAEAA,2BAAA,IAAC,aAAD;AAAA,MACE,SAQER,gDAAYI,WAAZJ,mBAAoBK,UAASC,UAAAA,eAAeG,SACxC,CAACC,2BAAD,CAAA,IACA,CAACC,UAAD,YAAA,GAAgBC,UAAAA,oBAAoBC,UAAAA,mBAAmBC,UAAY,aAAA,GAAIC,MAAAA,YAAvE;AAAA,MAEN;AAAA,IAAA,CAbF;AAAA,EAAA,CALN;AAuBD,CA7BgC;AAiCjC,qBAAqB;AAAA,EAAEjB,OAAO;AAAA,GAA2C;AAErE,wCAAA,QAAA;AAAA,IACE,WAAWkB,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UE;AAAAA,SACVF,UAAAA,UAAUG;AAAAA,SACVH,UAAAA,UAAUI;AAAAA,SACVJ,UAAAA,UAAUK;AAAAA,SACVL,UAAAA,UAAUM;AAAAA,SACVN,UAAAA,UAAUO;AAAAA,SACVP,UAAAA,UAAUQ;AAAAA,SACVR,UAAAA,UAAUU;AAAAA,SACVV,UAAAA,UAAUW;AAAAA,SACVX,UAAAA,UAAUY;AAAAA,SACVZ,UAAUa,UAAAA;AACb,aACEpB,iBAAWL,SACRQ,IAAIH,CAAcqB,gBAAAA,oBAAoBrB,aAAYtC,IAAb,CADxC,EAEG4D,KAAKtB,WAAWL,SAAS4B,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAAxB,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAA0BtC,MAA8B;AAChEsC,SAAAA,WAAWG,IAAIF,CAAQoB,SAAAA,oBAAoBpB,MAAMvC,IAAP,CAA1C,EAAwD4D,KAAK,IAA7D;AACR;;;"}
@@ -14,21 +14,22 @@ var __objRest = (source, exclude) => {
14
14
  return target;
15
15
  };
16
16
  import { forwardRef } from "react";
17
- import { bp as RichTextV2Mode, Y as useStyle, V as BlockType, bM as InlineType } from "./react-page.es.js";
17
+ import { bp as RichTextV2Mode, bI as InlineModePlugin, bG as BlockPlugin, bB as TypographyPlugin, bK as TextAlignPlugin, bP as InlinePlugin, Y as useStyle, V as BlockType, bM as InlineType } from "./react-page.es.js";
18
18
  import "./actions.es.js";
19
19
  import "slate";
20
- import "./state/breakpoints.es.js";
21
- import "is-hotkey";
22
- import { jsx, Fragment } from "react/jsx-runtime";
23
20
  import "slate-react";
24
- import { N as ControlValue } from "./index.es.js";
25
- import "@emotion/css";
21
+ import { L as LinkPlugin } from "./index.es5.js";
26
22
  import "uuid";
23
+ import { N as ControlValue } from "./index.es.js";
24
+ import { jsx, Fragment } from "react/jsx-runtime";
27
25
  import "redux";
28
26
  import "redux-thunk";
27
+ import "./state/breakpoints.es.js";
28
+ import "zod";
29
+ import "@emotion/css";
29
30
  import "@emotion/serialize";
30
31
  import "@emotion/utils";
31
- import "zod";
32
+ import "is-hotkey";
32
33
  import "use-sync-external-store/shim/with-selector";
33
34
  import "next/dynamic";
34
35
  import "./text-input.es.js";
@@ -63,7 +64,7 @@ const ReadOnlyTextV2 = forwardRef(function ReadOnlyText({
63
64
  return /* @__PURE__ */ jsx("div", {
64
65
  ref,
65
66
  children: descendantsAsString === "" ? /* @__PURE__ */ jsx(Placeholder, {}) : /* @__PURE__ */ jsx(Descendants, {
66
- plugins: (_b = definition == null ? void 0 : definition.config.plugins) != null ? _b : [],
67
+ plugins: ((_b = definition == null ? void 0 : definition.config) == null ? void 0 : _b.mode) === RichTextV2Mode.Inline ? [InlineModePlugin()] : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()],
67
68
  descendants
68
69
  })
69
70
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ReadOnlyTextV2.es.js","sources":["../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef } from 'react'\nimport {\n RichTextV2ControlData,\n RichTextV2ControlDefinition,\n RichTextV2Mode,\n RichTextV2Plugin,\n} from '../../../../controls'\nimport { useStyle } from '../../use-style'\nimport { Descendant, Element, Text } from 'slate'\nimport { InlineType, Block, BlockType } from '../../../../slate'\nimport { ControlValue } from '../control'\nimport { RenderElementProps, RenderLeafProps } from 'slate-react'\n\ntype Props = {\n text: RichTextV2ControlData\n definition: RichTextV2ControlDefinition | null\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text: { descendants }, definition }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = getText(descendants, definition?.config.mode ?? RichTextV2Mode.Block)\n\n return (\n <div ref={ref}>\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants plugins={definition?.config.plugins ?? []} descendants={descendants} />\n )}\n </div>\n )\n})\n\nexport default ReadOnlyTextV2\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\ntype LeafProps = {\n leaf: Text\n plugins: RichTextV2Plugin[]\n}\n\nexport function LeafComponent({ plugins, ...props }: LeafProps) {\n function initialRenderLeaf({ leaf }: RenderLeafProps) {\n return <span className={leaf.className}>{leaf.text === '' ? '\\uFEFF' : leaf.text}</span>\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf({ attributes: {} as any, leaf: props.leaf, children: null, text: props.leaf })\n}\n\ntype ElementProps = {\n descendant: Element\n plugins: RichTextV2Plugin[]\n}\n\nfunction ElementComponent({ plugins, ...props }: ElementProps) {\n function initialRenderElement(props: RenderElementProps) {\n return <Descendants descendants={props.element.children} plugins={plugins} />\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (control?.definition == null || renderElement == null) return renderFn(props)\n\n if (control.getElementValue == null) return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement({ attributes: {} as any, children: null, element: props.descendant })\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: Descendant): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({\n descendants,\n plugins,\n}: {\n plugins: RichTextV2Plugin[]\n descendants: Descendant[]\n}) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <LeafComponent key={index} plugins={plugins} leaf={descendant} />\n }\n\n return <ElementComponent key={index} descendant={descendant} plugins={plugins} />\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Block {\n if (isText(descendant)) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant, mode: RichTextV2Mode): string {\n if (isText(descendant)) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case BlockType.Default:\n return mode === RichTextV2Mode.Inline\n ? descendant.children.map(descendant => getTextByDescendant(descendant, mode)).join('') ??\n ''\n : descendant.children\n .map(descendant => getTextByDescendant(descendant, mode))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return (\n descendant.children.map(descendant => getTextByDescendant(descendant, mode)).join('') ?? ''\n )\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant, mode))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[], mode: RichTextV2Mode): string {\n return descendant.map(node => getTextByDescendant(node, mode)).join('\\n')\n}\n"],"names":["ReadOnlyTextV2","forwardRef","text","descendants","definition","ref","descendantsAsString","getText","config","mode","RichTextV2Mode","Block","_jsx","plugins","useStyle","display","width","maxWidth","whiteSpace","opacity","verticalAlign","props","leaf","className","renderLeaf","reduce","renderFn","plugin","control","getLeafValue","undefined","value","initialRenderLeaf","attributes","children","element","renderElement","getElementValue","initialRenderElement","descendant","node","_Fragment","map","index","isText","type","BlockType","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","Paragraph","Default","OrderedList","UnorderedList","ListItem","ListItemChild","Inline","getTextByDescendant","join","every","isBlock","InlineType","Link","Code","SubScript","SuperScript"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBMA,MAAAA,iBAAiBC,WAAW,sBAChC;AAAA,EAAEC,MAAM;AAAA,IAAEC;AAAAA;AAAAA,EAAeC;AAAAA,GACzBC,KACA;;AACA,QAAMC,sBAAsBC,QAAQJ,aAAaC,+CAAYI,OAAOC,SAAnBL,YAA2BM,eAAeC,KAAxD;AAGjC,6BAAA,OAAA;AAAA,IAAK;AAAA,IACFL,UAAAA,wBAAwB,KACvBM,oBAAC,aAAD,EAAA,IAEAA,oBAAC,aAAD;AAAA,MAAa,SAASR,+CAAYI,OAAOK,YAAnBT,YAA8B,CAApD;AAAA,MAAwD;AAAA,IAAA,CAAxD;AAAA,EAAA,CALN;AASD,CAfgC;AAmBjC,qBAAqB;AAAA,EAAEF,OAAO;AAAA,GAA2C;AAErE,6BAAA,QAAA;AAAA,IACE,WAAWY,SAAS;AAAA,MAClBC,SAAS;AAAA,MACTC,OAAO;AAAA,MACPC,UAAU;AAAA,MACVC,YAAY;AAAA,MACZC,SAAS;AAAA,MACTC,eAAe;AAAA,IAAA,CANE;AAAA,IASlBlB,UAAAA;AAAAA,EAAAA,CAXL;AAcD;AA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D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAA0B9B,MAA8B;AAChE8B,SAAAA,WAAWG,IAAIF,CAAQqB,SAAAA,oBAAoBrB,MAAM/B,IAAP,CAA1C,EAAwDqD,KAAK,IAA7D;AACR;;"}
1
+ {"version":3,"file":"ReadOnlyTextV2.es.js","sources":["../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef } from 'react'\nimport {\n RichTextV2ControlData,\n RichTextV2ControlDefinition,\n RichTextV2Mode,\n RichTextV2Plugin,\n} from '../../../../controls'\nimport { useStyle } from '../../use-style'\nimport { Descendant, Element, Text } from 'slate'\nimport {\n InlineType,\n Block,\n BlockType,\n BlockPlugin,\n InlineModePlugin,\n InlinePlugin,\n LinkPlugin,\n TextAlignPlugin,\n TypographyPlugin,\n} from '../../../../slate'\nimport { ControlValue } from '../control'\nimport { RenderElementProps, RenderLeafProps } from 'slate-react'\n\ntype Props = {\n text: RichTextV2ControlData\n definition: RichTextV2ControlDefinition | null\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text: { descendants }, definition }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = getText(descendants, definition?.config.mode ?? RichTextV2Mode.Block)\n\n return (\n <div ref={ref}>\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants\n plugins={\n /**\n * TODO: we are manually referencing our default plugins for each mode here because\n * Referencing the real LinkPlugin causes a circular dependency.\n * When circular dependencies calm down we should update the plugin definition to use real plugins,\n * and just use the plugins that are defined by our config.\n */\n // definition?.config?.plugins ,\n definition?.config?.mode === RichTextV2Mode.Inline\n ? [InlineModePlugin()]\n : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]\n }\n descendants={descendants}\n />\n )}\n </div>\n )\n})\n\nexport default ReadOnlyTextV2\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\ntype LeafProps = {\n leaf: Text\n plugins: RichTextV2Plugin[]\n}\n\nexport function LeafComponent({ plugins, ...props }: LeafProps) {\n function initialRenderLeaf({ leaf }: RenderLeafProps) {\n return <span className={leaf.className}>{leaf.text === '' ? '\\uFEFF' : leaf.text}</span>\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf({ attributes: {} as any, leaf: props.leaf, children: null, text: props.leaf })\n}\n\ntype ElementProps = {\n descendant: Element\n plugins: RichTextV2Plugin[]\n}\n\nfunction ElementComponent({ plugins, ...props }: ElementProps) {\n function initialRenderElement(props: RenderElementProps) {\n return <Descendants descendants={props.element.children} plugins={plugins} />\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (control?.definition == null || renderElement == null) return renderFn(props)\n\n if (control.getElementValue == null) return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement({ attributes: {} as any, children: null, element: props.descendant })\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: Descendant): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({\n descendants,\n plugins,\n}: {\n plugins: RichTextV2Plugin[]\n descendants: Descendant[]\n}) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <LeafComponent key={index} plugins={plugins} leaf={descendant} />\n }\n\n return <ElementComponent key={index} descendant={descendant} plugins={plugins} />\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Block {\n if (isText(descendant)) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant, mode: RichTextV2Mode): string {\n if (isText(descendant)) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case BlockType.Default:\n return mode === RichTextV2Mode.Inline\n ? descendant.children.map(descendant => getTextByDescendant(descendant, mode)).join('') ??\n ''\n : descendant.children\n .map(descendant => getTextByDescendant(descendant, mode))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return (\n descendant.children.map(descendant => getTextByDescendant(descendant, mode)).join('') ?? ''\n )\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant, mode))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[], mode: RichTextV2Mode): string {\n return descendant.map(node => getTextByDescendant(node, mode)).join('\\n')\n}\n"],"names":["ReadOnlyTextV2","forwardRef","text","descendants","definition","ref","descendantsAsString","getText","config","mode","RichTextV2Mode","Block","_jsx","Inline","InlineModePlugin","BlockPlugin","TypographyPlugin","TextAlignPlugin","InlinePlugin","LinkPlugin","useStyle","display","width","maxWidth","whiteSpace","opacity","verticalAlign","plugins","props","leaf","className","renderLeaf","reduce","renderFn","plugin","control","getLeafValue","undefined","value","initialRenderLeaf","attributes","children","element","renderElement","getElementValue","initialRenderElement","descendant","node","_Fragment","map","index","isText","type","BlockType","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","Paragraph","Default","OrderedList","UnorderedList","ListItem","ListItemChild","getTextByDescendant","join","every","isBlock","InlineType","Link","Code","SubScript","SuperScript"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BMA,MAAAA,iBAAiBC,WAAW,sBAChC;AAAA,EAAEC,MAAM;AAAA,IAAEC;AAAAA;AAAAA,EAAeC;AAAAA,GACzBC,KACA;;AACA,QAAMC,sBAAsBC,QAAQJ,aAAaC,+CAAYI,OAAOC,SAAnBL,YAA2BM,eAAeC,KAAxD;AAGjC,6BAAA,OAAA;AAAA,IAAK;AAAA,IACFL,UAAAA,wBAAwB,KACvBM,oBAAC,aAAD,EAAA,IAEAA,oBAAC,aAAD;AAAA,MACE,SAQER,gDAAYI,WAAZJ,mBAAoBK,UAASC,eAAeG,SACxC,CAACC,iBAAD,CAAA,IACA,CAACC,YAAD,GAAgBC,oBAAoBC,mBAAmBC,aAAY,GAAIC,YAAvE;AAAA,MAEN;AAAA,IAAA,CAbF;AAAA,EAAA,CALN;AAuBD,CA7BgC;AAiCjC,qBAAqB;AAAA,EAAEjB,OAAO;AAAA,GAA2C;AAErE,6BAAA,QAAA;AAAA,IACE,WAAWkB,SAAS;AAAA,MAClBC,SAAS;AAAA,MACTC,OAAO;AAAA,MACPC,UAAU;AAAA,MACVC,YAAY;AAAA,MACZC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aAAYrC,IAAb,CADxC,EAEG2D,KAAKtB,WAAWL,SAAS4B,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAAxB,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAA0BrC,MAA8B;AAChEqC,SAAAA,WAAWG,IAAIF,CAAQoB,SAAAA,oBAAoBpB,MAAMtC,IAAP,CAA1C,EAAwD2D,KAAK,IAA7D;AACR;;"}
package/dist/Text.cjs.js CHANGED
@@ -27,7 +27,7 @@ function _interopDefaultLegacy(e) {
27
27
  }
28
28
  var dynamic__default = /* @__PURE__ */ _interopDefaultLegacy(dynamic);
29
29
  const EditableText = next.forwardNextDynamicRef((patch) => dynamic__default["default"](() => patch(Promise.resolve().then(function() {
30
- return require("./index.cjs8.js");
30
+ return require("./index.cjs9.js");
31
31
  }))));
32
32
  const ReadOnlyText = next.forwardNextDynamicRef((patch) => dynamic__default["default"](() => patch(Promise.resolve().then(function() {
33
33
  return require("./ReadOnlyText.cjs.js");
package/dist/Text.es.js CHANGED
@@ -21,7 +21,7 @@ import dynamic from "next/dynamic";
21
21
  import { forwardRef } from "react";
22
22
  import { B as forwardNextDynamicRef, F as useIsPreview } from "./index.es.js";
23
23
  import { jsx } from "react/jsx-runtime";
24
- const EditableText = forwardNextDynamicRef((patch) => dynamic(() => patch(import("./index.es8.js"))));
24
+ const EditableText = forwardNextDynamicRef((patch) => dynamic(() => patch(import("./index.es9.js"))));
25
25
  const ReadOnlyText = forwardNextDynamicRef((patch) => dynamic(() => patch(import("./ReadOnlyText.es.js"))));
26
26
  const Text = forwardRef(function Text2(props, ref) {
27
27
  const isPreview = useIsPreview();
package/dist/index.cjs.js CHANGED
@@ -1207,7 +1207,7 @@ async function fonts(_req, res, { getFonts } = {}) {
1207
1207
  const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
1208
1208
  return res.json(fonts2);
1209
1209
  }
1210
- const version = "0.0.0-20230711141354";
1210
+ const version = "0.0.0-20230711144946";
1211
1211
  async function handler(req, res, { apiKey, unstable_siteVersions }) {
1212
1212
  if (req.query.secret !== apiKey) {
1213
1213
  return res.status(401).json({ message: "Unauthorized" });
@@ -3296,7 +3296,7 @@ function useNumber(numberControlData, controlDefinition) {
3296
3296
  return numberControlData != null ? numberControlData : controlDefinition.config.defaultValue;
3297
3297
  }
3298
3298
  const Text = forwardNextDynamicRef((patch) => dynamic__default["default"](() => patch(Promise.resolve().then(function() {
3299
- return require("./index.cjs6.js");
3299
+ return require("./index.cjs7.js");
3300
3300
  }))));
3301
3301
  function useRichText(data, control) {
3302
3302
  const textCallbackRef = React.useCallback((handle) => {
@@ -3312,7 +3312,7 @@ function useRichText(data, control) {
3312
3312
  });
3313
3313
  }
3314
3314
  const EditableText = forwardNextDynamicRef((patch) => dynamic__default["default"](() => patch(Promise.resolve().then(function() {
3315
- return require("./index.cjs7.js");
3315
+ return require("./index.cjs8.js");
3316
3316
  }))));
3317
3317
  const ReadOnlyText = forwardNextDynamicRef((patch) => dynamic__default["default"](() => patch(Promise.resolve().then(function() {
3318
3318
  return require("./ReadOnlyTextV2.cjs.js");
@@ -22,7 +22,6 @@ var reactPage = require("./react-page.cjs.js");
22
22
  var next = require("./index.cjs.js");
23
23
  var css = require("@emotion/css");
24
24
  var jsxRuntime = require("react/jsx-runtime");
25
- var uuid = require("uuid");
26
25
  const withLink = (editor) => {
27
26
  const {
28
27
  isInline
@@ -83,25 +82,6 @@ function LinkPlugin() {
83
82
  }
84
83
  });
85
84
  }
86
- function withLocalChanges(editor) {
87
- editor.localChanges = /* @__PURE__ */ new Map();
88
- editor.recentLocalChanges = [];
89
- editor.currentKey = "";
90
- const _onChange = editor.onChange;
91
- editor.onChange = (options) => {
92
- _onChange(options);
93
- if (editor == null || (options == null ? void 0 : options.operation) == null)
94
- return;
95
- const key = uuid.v4();
96
- editor.localChanges.set(key, {
97
- selection: editor.selection,
98
- time: performance.now()
99
- });
100
- editor.currentKey = key;
101
- };
102
- return editor;
103
- }
104
85
  exports.LinkPlugin = LinkPlugin;
105
86
  exports.withLink = withLink;
106
- exports.withLocalChanges = withLocalChanges;
107
87
  //# sourceMappingURL=index.cjs5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs5.js","sources":["../src/slate/LinkPlugin/index.tsx","../src/slate/LocalChangesPlugin/index.tsx"],"sourcesContent":["import { Editor, Element } from 'slate'\nimport { RenderElement, createRichTextV2Plugin } from '../../controls/rich-text-v2'\nimport { Link } from '../../controls/link'\nimport { ElementUtils } from '../utils/element'\nimport { InlineType } from '../types'\nimport { RenderElementProps } from 'slate-react'\nimport { useStyle } from '../../runtimes/react/use-style'\nimport { Link as LinkComponent } from '../../components/shared/Link'\nimport { cx } from '@emotion/css'\nimport { isLinkElement } from './types'\nimport { onChange } from './onChange'\nimport { getValue } from './getValue'\n\nexport const withLink = (editor: Editor) => {\n const { isInline } = editor\n\n editor.isInline = entry => {\n return ElementUtils.isInline(entry) && isInline(entry)\n }\n\n return editor\n}\n\nfunction InlinePluginComponent({\n element,\n attributes,\n children,\n renderElement,\n}: RenderElementProps & { renderElement: RenderElement }) {\n const linkStyle = useStyle({ textDecoration: 'none' })\n switch (element.type) {\n case InlineType.Link:\n return (\n <LinkComponent\n {...attributes}\n link={element.link ?? undefined}\n className={cx(linkStyle, element.className)}\n >\n {renderElement({\n element,\n attributes,\n children,\n })}\n </LinkComponent>\n )\n\n default:\n return (\n <>\n {renderElement({\n element,\n attributes,\n children,\n })}\n </>\n )\n }\n}\n\nexport function LinkPlugin() {\n return createRichTextV2Plugin({\n control: {\n definition: Link({\n label: 'On Click',\n }),\n onChange,\n getValue,\n getElementValue: (element: Element) => {\n return ElementUtils.isInline(element) && isLinkElement(element) ? element.link : undefined\n },\n },\n withPlugin: withLink,\n renderElement: renderElement => props => {\n return <InlinePluginComponent {...props} renderElement={renderElement} />\n },\n })\n}\n","import { BaseEditor, Editor, Selection } from 'slate'\nimport { v4 as uuid } from 'uuid'\n\nexport type LocalChange = { selection: Selection; time: number }\n\nexport interface LocalChangesEditor extends BaseEditor {\n localChanges: Map<string, LocalChange>\n recentKeys: Map<string, number>\n recentLocalChanges: { time: number; key: string }[]\n currentKey: string\n}\n\nexport function withLocalChanges(editor: Editor): Editor {\n editor.localChanges = new Map<string, LocalChange>()\n editor.recentLocalChanges = []\n editor.currentKey = ''\n\n const _onChange = editor.onChange\n editor.onChange = options => {\n _onChange(options)\n if (editor == null || options?.operation == null) return\n\n const key = uuid()\n editor.localChanges.set(key, { selection: editor.selection, time: performance.now() })\n editor.currentKey = key\n }\n\n return editor\n}\n"],"names":["withLink","editor","isInline","entry","ElementUtils","element","attributes","children","renderElement","linkStyle","useStyle","textDecoration","type","InlineType","Link","LinkComponent","link","undefined","cx","className","_Fragment","createRichTextV2Plugin","control","definition","label","onChange","getValue","getElementValue","isLinkElement","withPlugin","props","localChanges","Map","recentLocalChanges","currentKey","_onChange","options","operation","key","uuid","set","selection","time","performance","now"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAaaA,MAAAA,WAAW,CAACC,WAAmB;AACpC,QAAA;AAAA,IAAEC;AAAAA,MAAaD;AAErBA,SAAOC,WAAWC,CAAS,UAAA;AAClBC,WAAAA,UAAAA,aAAaF,SAASC,KAAtB,KAAgCD,SAASC,KAAD;AAAA,EAAA;AAG1CF,SAAAA;AACR;AAED,+BAA+B;AAAA,EAC7BI;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,GACwD;;AAClDC,QAAAA,YAAYC,UAAAA,SAAS;AAAA,IAAEC,gBAAgB;AAAA,EAAA,CAAnB;AAClBN,UAAAA,QAAQO;AAAAA,SACTC,UAAWC,WAAAA;AAEZ,4CAACC,KAAAA,MAAD,iCACMT,aADN;AAAA,QAEE,MAAMD,cAAQW,SAARX,YAAgBY;AAAAA,QACtB,WAAWC,IAAAA,GAAGT,WAAWJ,QAAQc,SAApB;AAAA,QAHf,UAKGX,cAAc;AAAA,UACbH;AAAAA,UACAC;AAAAA,U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or, Element } from 'slate'\nimport { RenderElement, createRichTextV2Plugin } from '../../controls/rich-text-v2'\nimport { Link } from '../../controls/link'\nimport { ElementUtils } from '../utils/element'\nimport { InlineType } from '../types'\nimport { RenderElementProps } from 'slate-react'\nimport { useStyle } from '../../runtimes/react/use-style'\nimport { Link as LinkComponent } from '../../components/shared/Link'\nimport { cx } from '@emotion/css'\nimport { isLinkElement } from './types'\nimport { onChange } from './onChange'\nimport { getValue } from './getValue'\n\nexport const withLink = (editor: Editor) => {\n const { isInline } = editor\n\n editor.isInline = entry => {\n return ElementUtils.isInline(entry) && isInline(entry)\n }\n\n return editor\n}\n\nfunction InlinePluginComponent({\n element,\n attributes,\n children,\n renderElement,\n}: RenderElementProps & { renderElement: RenderElement }) {\n const linkStyle = useStyle({ textDecoration: 'none' })\n switch (element.type) {\n case InlineType.Link:\n return (\n <LinkComponent\n {...attributes}\n link={element.link ?? undefined}\n className={cx(linkStyle, element.className)}\n >\n {renderElement({\n element,\n attributes,\n children,\n })}\n </LinkComponent>\n )\n\n default:\n return (\n <>\n {renderElement({\n element,\n attributes,\n children,\n })}\n </>\n )\n }\n}\n\nexport function LinkPlugin() {\n return createRichTextV2Plugin({\n control: {\n definition: Link({\n label: 'On Click',\n }),\n onChange,\n getValue,\n getElementValue: (element: Element) => {\n return ElementUtils.isInline(element) && isLinkElement(element) ? element.link : undefined\n },\n },\n withPlugin: withLink,\n renderElement: renderElement => props => {\n return <InlinePluginComponent {...props} renderElement={renderElement} />\n },\n })\n}\n"],"names":["withLink","editor","isInline","entry","ElementUtils","element","attributes","children","renderElement","linkStyle","useStyle","textDecoration","type","InlineType","Link","LinkComponent","link","undefined","cx","className","_Fragment","createRichTextV2Plugin","control","definition","label","onChange","getValue","getElementValue","isLinkElement","withPlugin","props"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAaaA,MAAAA,WAAW,CAACC,WAAmB;AACpC,QAAA;AAAA,IAAEC;AAAAA,MAAaD;AAErBA,SAAOC,WAAWC,CA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1,22 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var Text = require("./Text.cjs.js");
4
- require("next/dynamic");
5
- require("react");
6
- require("./index.cjs.js");
7
- require("use-sync-external-store/shim/with-selector");
8
- require("./react-page.cjs.js");
9
- require("redux");
10
- require("redux-thunk");
11
- require("./actions.cjs.js");
12
- require("zod");
13
- require("./state/breakpoints.cjs.js");
14
- require("@emotion/css");
15
- require("@emotion/serialize");
16
- require("@emotion/utils");
17
- require("slate");
18
- require("react/jsx-runtime");
19
- require("is-hotkey");
20
- require("./text-input.cjs.js");
21
- require("./combobox.cjs.js");
22
- require("use-sync-external-store/shim");
23
- require("./types.cjs.js");
24
- require("./box-models.cjs.js");
25
- require("css-box-model");
26
- require("color");
27
- require("scroll-into-view-if-needed");
28
- require("react-dom");
29
- require("html-react-parser");
30
- require("next/head");
31
- require("@emotion/server/create-instance");
32
- require("next/document");
33
- require("cors");
34
- require("path-to-regexp");
35
- require("cookie");
36
- require("http-proxy");
37
- require("set-cookie-parser");
38
- require("./constants.cjs.js");
39
- require("uuid");
40
- require("corporate-ipsum");
41
- require("slate-react");
42
- require("next/link");
43
- exports["default"] = Text.Text;
2
+ var uuid = require("uuid");
3
+ function withLocalChanges(editor) {
4
+ editor.localChanges = /* @__PURE__ */ new Map();
5
+ editor.recentLocalChanges = [];
6
+ editor.currentKey = "";
7
+ const _onChange = editor.onChange;
8
+ editor.onChange = (options) => {
9
+ _onChange(options);
10
+ if (editor == null || (options == null ? void 0 : options.operation) == null)
11
+ return;
12
+ const key = uuid.v4();
13
+ editor.localChanges.set(key, {
14
+ selection: editor.selection,
15
+ time: performance.now()
16
+ });
17
+ editor.currentKey = key;
18
+ };
19
+ return editor;
20
+ }
21
+ exports.withLocalChanges = withLocalChanges;
44
22
  //# sourceMappingURL=index.cjs6.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs6.js","sources":["../src/slate/LocalChangesPlugin/index.tsx"],"sourcesContent":["import { BaseEditor, Editor, Selection } from 'slate'\nimport { v4 as uuid } from 'uuid'\n\nexport type LocalChange = { selection: Selection; time: number }\n\nexport interface LocalChangesEditor extends BaseEditor {\n localChanges: Map<string, LocalChange>\n recentKeys: Map<string, number>\n recentLocalChanges: { time: number; key: string }[]\n currentKey: string\n}\n\nexport function withLocalChanges(editor: Editor): Editor {\n editor.localChanges = new Map<string, LocalChange>()\n editor.recentLocalChanges = []\n editor.currentKey = ''\n\n const _onChange = editor.onChange\n editor.onChange = options => {\n _onChange(options)\n if (editor == null || options?.operation == null) return\n\n const key = uuid()\n editor.localChanges.set(key, { selection: editor.selection, time: performance.now() })\n editor.currentKey = key\n }\n\n return editor\n}\n"],"names":["editor","localChanges","Map","recentLocalChanges","currentKey","_onChange","onChange","options","operation","key","uuid","set","selection","time","performance","now"],"mappings":";;AAYO,0BAA0BA,QAAwB;AAChDC,SAAAA,mCAAmBC;AAC1BF,SAAOG,qBAAqB;AAC5BH,SAAOI,aAAa;AAEpB,QAAMC,YAAYL,OAAOM;AACzBN,SAAOM,WAAWC,CAAW,YAAA;AAC3BF,cAAUE,OAAD;AACLP,QAAAA,UAAU,QAAQO,oCAASC,cAAa;AAAM;AAE5CC,UAAAA,MAAMC,KAAAA;AACLT,WAAAA,aAAaU,IAAIF,KAAK;AAAA,MAAEG,WAAWZ,OAAOY;AAAAA,MAAWC,MAAMC,YAAYC,IAAZ;AAAA,IAAA,CAAlE;AACAf,WAAOI,aAAaK;AAAAA,EAAAA;AAGfT,SAAAA;AACR;;"}