@makeswift/runtime 0.9.1 → 0.9.3

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.
Files changed (206) hide show
  1. package/dist/Box.cjs.js +1 -4
  2. package/dist/Box.cjs.js.map +1 -1
  3. package/dist/Box.es.js +1 -4
  4. package/dist/Box.es.js.map +1 -1
  5. package/dist/Button.cjs.js +1 -4
  6. package/dist/Button.cjs.js.map +1 -1
  7. package/dist/Button.es.js +1 -4
  8. package/dist/Button.es.js.map +1 -1
  9. package/dist/Carousel.cjs.js +1 -4
  10. package/dist/Carousel.cjs.js.map +1 -1
  11. package/dist/Carousel.es.js +1 -4
  12. package/dist/Carousel.es.js.map +1 -1
  13. package/dist/Countdown.cjs.js +0 -3
  14. package/dist/Countdown.cjs.js.map +1 -1
  15. package/dist/Countdown.es.js +0 -3
  16. package/dist/Countdown.es.js.map +1 -1
  17. package/dist/Divider.cjs.js +1 -4
  18. package/dist/Divider.cjs.js.map +1 -1
  19. package/dist/Divider.es.js +1 -4
  20. package/dist/Divider.es.js.map +1 -1
  21. package/dist/Embed.cjs.js +0 -2
  22. package/dist/Embed.cjs.js.map +1 -1
  23. package/dist/Embed.es.js +0 -2
  24. package/dist/Embed.es.js.map +1 -1
  25. package/dist/Form.cjs.js +0 -3
  26. package/dist/Form.cjs.js.map +1 -1
  27. package/dist/Form.es.js +0 -3
  28. package/dist/Form.es.js.map +1 -1
  29. package/dist/Image.cjs.js +0 -3
  30. package/dist/Image.cjs.js.map +1 -1
  31. package/dist/Image.es.js +0 -3
  32. package/dist/Image.es.js.map +1 -1
  33. package/dist/LiveProvider.cjs.js +1 -4
  34. package/dist/LiveProvider.cjs.js.map +1 -1
  35. package/dist/LiveProvider.es.js +3 -6
  36. package/dist/LiveProvider.es.js.map +1 -1
  37. package/dist/Navigation.cjs.js +0 -3
  38. package/dist/Navigation.cjs.js.map +1 -1
  39. package/dist/Navigation.es.js +0 -3
  40. package/dist/Navigation.es.js.map +1 -1
  41. package/dist/PreviewProvider.cjs.js +2 -5
  42. package/dist/PreviewProvider.cjs.js.map +1 -1
  43. package/dist/PreviewProvider.es.js +2 -5
  44. package/dist/PreviewProvider.es.js.map +1 -1
  45. package/dist/ReadOnlyText.cjs.js +1 -1
  46. package/dist/ReadOnlyText.es.js +2 -2
  47. package/dist/ReadOnlyTextV2.cjs.js +1 -1
  48. package/dist/ReadOnlyTextV2.es.js +2 -2
  49. package/dist/Root.cjs.js +0 -3
  50. package/dist/Root.cjs.js.map +1 -1
  51. package/dist/Root.es.js +0 -3
  52. package/dist/Root.es.js.map +1 -1
  53. package/dist/SocialLinks.cjs.js +1 -4
  54. package/dist/SocialLinks.cjs.js.map +1 -1
  55. package/dist/SocialLinks.es.js +1 -4
  56. package/dist/SocialLinks.es.js.map +1 -1
  57. package/dist/Text.cjs.js +0 -3
  58. package/dist/Text.cjs.js.map +1 -1
  59. package/dist/Text.es.js +0 -3
  60. package/dist/Text.es.js.map +1 -1
  61. package/dist/Video.cjs.js +0 -2
  62. package/dist/Video.cjs.js.map +1 -1
  63. package/dist/Video.es.js +0 -2
  64. package/dist/Video.es.js.map +1 -1
  65. package/dist/builder.cjs.js +0 -3
  66. package/dist/builder.cjs.js.map +1 -1
  67. package/dist/builder.es.js +0 -3
  68. package/dist/builder.es.js.map +1 -1
  69. package/dist/components.cjs.js +0 -3
  70. package/dist/components.cjs.js.map +1 -1
  71. package/dist/components.es.js +0 -3
  72. package/dist/components.es.js.map +1 -1
  73. package/dist/control-serialization.cjs.js +0 -3
  74. package/dist/control-serialization.cjs.js.map +1 -1
  75. package/dist/control-serialization.es.js +1 -4
  76. package/dist/control-serialization.es.js.map +1 -1
  77. package/dist/controls.cjs.js +5 -5
  78. package/dist/controls.es.js +2 -5
  79. package/dist/controls.es.js.map +1 -1
  80. package/dist/index.cjs.js +86 -17
  81. package/dist/index.cjs.js.map +1 -1
  82. package/dist/index.cjs10.js +4 -4
  83. package/dist/index.cjs10.js.map +1 -1
  84. package/dist/index.cjs2.js +1 -3
  85. package/dist/index.cjs2.js.map +1 -1
  86. package/dist/index.cjs6.js +2 -1
  87. package/dist/index.cjs6.js.map +1 -1
  88. package/dist/index.cjs8.js +0 -3
  89. package/dist/index.cjs8.js.map +1 -1
  90. package/dist/index.cjs9.js +49 -13
  91. package/dist/index.cjs9.js.map +1 -1
  92. package/dist/index.es.js +82 -14
  93. package/dist/index.es.js.map +1 -1
  94. package/dist/index.es10.js +3 -3
  95. package/dist/index.es2.js +2 -4
  96. package/dist/index.es2.js.map +1 -1
  97. package/dist/index.es6.js +2 -1
  98. package/dist/index.es6.js.map +1 -1
  99. package/dist/index.es8.js +0 -3
  100. package/dist/index.es8.js.map +1 -1
  101. package/dist/index.es9.js +50 -14
  102. package/dist/index.es9.js.map +1 -1
  103. package/dist/leaf.es.js +1 -1
  104. package/dist/main.cjs.js +0 -3
  105. package/dist/main.cjs.js.map +1 -1
  106. package/dist/main.es.js +0 -3
  107. package/dist/main.es.js.map +1 -1
  108. package/dist/next.cjs.js +0 -3
  109. package/dist/next.cjs.js.map +1 -1
  110. package/dist/next.es.js +1 -4
  111. package/dist/next.es.js.map +1 -1
  112. package/dist/prop-controllers.cjs.js +0 -3
  113. package/dist/prop-controllers.cjs.js.map +1 -1
  114. package/dist/prop-controllers.es.js +0 -3
  115. package/dist/prop-controllers.es.js.map +1 -1
  116. package/dist/react-page.cjs.js +926 -1573
  117. package/dist/react-page.cjs.js.map +1 -1
  118. package/dist/react-page.es.js +922 -1559
  119. package/dist/react-page.es.js.map +1 -1
  120. package/dist/react.cjs.js +0 -3
  121. package/dist/react.cjs.js.map +1 -1
  122. package/dist/react.es.js +0 -3
  123. package/dist/react.es.js.map +1 -1
  124. package/dist/slate.cjs.js +391 -58
  125. package/dist/slate.cjs.js.map +1 -1
  126. package/dist/slate.es.js +387 -59
  127. package/dist/slate.es.js.map +1 -1
  128. package/dist/text-input.cjs.js +22 -0
  129. package/dist/text-input.cjs.js.map +1 -1
  130. package/dist/text-input.es.js +18 -1
  131. package/dist/text-input.es.js.map +1 -1
  132. package/dist/types/src/api/react.d.ts.map +1 -1
  133. package/dist/types/src/components/builtin/Button/Button.d.ts +1 -1
  134. package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
  135. package/dist/types/src/components/page/Page.d.ts.map +1 -1
  136. package/dist/types/src/controls/control.d.ts +3 -2
  137. package/dist/types/src/controls/control.d.ts.map +1 -1
  138. package/dist/types/src/controls/icon-radio-group.d.ts +32 -0
  139. package/dist/types/src/controls/icon-radio-group.d.ts.map +1 -0
  140. package/dist/types/src/controls/index.d.ts +1 -0
  141. package/dist/types/src/controls/index.d.ts.map +1 -1
  142. package/dist/types/src/controls/rich-text/translation.d.ts +1 -1
  143. package/dist/types/src/controls/rich-text/translation.d.ts.map +1 -1
  144. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +7 -3
  145. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
  146. package/dist/types/src/controls/shape.d.ts +1 -2
  147. package/dist/types/src/controls/shape.d.ts.map +1 -1
  148. package/dist/types/src/controls/style-v2.d.ts +16 -7
  149. package/dist/types/src/controls/style-v2.d.ts.map +1 -1
  150. package/dist/types/src/next/client.d.ts.map +1 -1
  151. package/dist/types/src/next/document.d.ts.map +1 -1
  152. package/dist/types/src/prop-controllers/descriptors.d.ts +4 -2
  153. package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
  154. package/dist/types/src/prop-controllers/introspection.d.ts.map +1 -1
  155. package/dist/types/src/runtimes/react/controls/control.d.ts +3 -1
  156. package/dist/types/src/runtimes/react/controls/control.d.ts.map +1 -1
  157. package/dist/types/src/runtimes/react/controls/icon-radio-group.d.ts +4 -0
  158. package/dist/types/src/runtimes/react/controls/icon-radio-group.d.ts.map +1 -0
  159. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
  160. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts +10 -0
  161. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts.map +1 -0
  162. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts +10 -0
  163. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts.map +1 -0
  164. package/dist/types/src/runtimes/react/controls/style-v2.d.ts +10 -1
  165. package/dist/types/src/runtimes/react/controls/style-v2.d.ts.map +1 -1
  166. package/dist/types/src/runtimes/react/controls.d.ts.map +1 -1
  167. package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
  168. package/dist/types/src/slate/BlockPlugin/index.d.ts +1 -0
  169. package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
  170. package/dist/types/src/slate/ColorPlugin/index.d.ts +10 -0
  171. package/dist/types/src/slate/ColorPlugin/index.d.ts.map +1 -0
  172. package/dist/types/src/slate/InlineModePlugin/index.d.ts +1 -0
  173. package/dist/types/src/slate/InlineModePlugin/index.d.ts.map +1 -1
  174. package/dist/types/src/slate/InlinePlugin/getValue.d.ts +5 -0
  175. package/dist/types/src/slate/InlinePlugin/getValue.d.ts.map +1 -0
  176. package/dist/types/src/slate/InlinePlugin/index.d.ts +16 -0
  177. package/dist/types/src/slate/InlinePlugin/index.d.ts.map +1 -0
  178. package/dist/types/src/slate/InlinePlugin/onChange.d.ts +4 -0
  179. package/dist/types/src/slate/InlinePlugin/onChange.d.ts.map +1 -0
  180. package/dist/types/src/slate/InlinePlugin/types.d.ts +9 -0
  181. package/dist/types/src/slate/InlinePlugin/types.d.ts.map +1 -0
  182. package/dist/types/src/slate/LinkPlugin/getValue.d.ts +5 -0
  183. package/dist/types/src/slate/LinkPlugin/getValue.d.ts.map +1 -0
  184. package/dist/types/src/slate/LinkPlugin/index.d.ts +15 -0
  185. package/dist/types/src/slate/LinkPlugin/index.d.ts.map +1 -0
  186. package/dist/types/src/slate/LinkPlugin/onChange.d.ts +4 -0
  187. package/dist/types/src/slate/LinkPlugin/onChange.d.ts.map +1 -0
  188. package/dist/types/src/slate/LinkPlugin/types.d.ts +5 -0
  189. package/dist/types/src/slate/LinkPlugin/types.d.ts.map +1 -0
  190. package/dist/types/src/slate/TextAlignPlugin/index.d.ts +3 -1
  191. package/dist/types/src/slate/TextAlignPlugin/index.d.ts.map +1 -1
  192. package/dist/types/src/slate/index.d.ts +3 -0
  193. package/dist/types/src/slate/index.d.ts.map +1 -1
  194. package/dist/types/src/slate/types.d.ts +21 -0
  195. package/dist/types/src/slate/types.d.ts.map +1 -1
  196. package/dist/types/src/slate/utils/responsive.d.ts +16 -0
  197. package/dist/types/src/slate/utils/responsive.d.ts.map +1 -0
  198. package/dist/types.cjs2.js +753 -0
  199. package/dist/types.cjs2.js.map +1 -0
  200. package/dist/types.es2.js +736 -0
  201. package/dist/types.es2.js.map +1 -0
  202. package/package.json +1 -1
  203. package/dist/deepEqual.cjs.js +0 -40
  204. package/dist/deepEqual.cjs.js.map +0 -1
  205. package/dist/deepEqual.es.js +0 -39
  206. package/dist/deepEqual.es.js.map +0 -1
package/dist/slate.es.js CHANGED
@@ -5,84 +5,177 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
7
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
8
+ var __spreadValues = (a, b2) => {
9
+ for (var prop in b2 || (b2 = {}))
10
+ if (__hasOwnProp.call(b2, prop))
11
+ __defNormalProp(a, prop, b2[prop]);
12
12
  if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
13
+ for (var prop of __getOwnPropSymbols(b2)) {
14
+ if (__propIsEnum.call(b2, prop))
15
+ __defNormalProp(a, prop, b2[prop]);
16
16
  }
17
17
  return a;
18
18
  };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
19
+ var __spreadProps = (a, b2) => __defProps(a, __getOwnPropDescs(b2));
20
20
  export { T as TypographyActions, w as withTypography } from "./index.es5.js";
21
- import { aY as unstable_StyleV2, b8 as createRichTextV2Plugin, bc as getBlocksInSelection, bd as ElementUtils, aJ as Select } from "./react-page.es.js";
22
- export { be as BlockActions, bi as BlockPlugin, bm as BlockTextAlignment, bk as BlockType, bl as InlineType, bf as ListActions, bj as RootBlockType, bg as onKeyDown, bh as withBlock } from "./react-page.es.js";
21
+ import { g as getSelection, E as ElementUtils, f as filterForSubtreeRoots, i as isSupportedInlineType, a as isSupportedInlineEntry, u as unwrapInline, w as wrapInline, s as supportedInlineOptions } from "./types.es2.js";
22
+ export { B as BlockActions, c as BlockPlugin, L as ListActions, o as onKeyDown, b as withBlock } from "./types.es2.js";
23
23
  export { I as InlineModePlugin, w as withInlineMode } from "./index.es6.js";
24
24
  export { w as withBuilder } from "./index.es7.js";
25
- import { Transforms } from "slate";
25
+ import { b6 as createRichTextV2Plugin, aW as unstable_StyleV2, aw as Color, ba as InlineType, aC as Link, Z as useStyle } from "./react-page.es.js";
26
+ export { bd as BlockTextAlignment, bc as BlockType, ba as InlineType, bb as RootBlockType } from "./react-page.es.js";
27
+ import { c as unstable_IconRadioGroup, u as unstable_IconRadioGroupIcon } from "./text-input.es.js";
28
+ import { Transforms, Editor, Text } from "slate";
29
+ import { K as deepEqual } from "./index.es.js";
30
+ import "react";
31
+ import { cx } from "@emotion/css";
32
+ import "@emotion/serialize";
33
+ import "@emotion/utils";
34
+ import { jsx, Fragment } from "react/jsx-runtime";
35
+ import { L as Link$1 } from "./index.es3.js";
26
36
  import "./state/breakpoints.es.js";
37
+ import "./actions.es.js";
27
38
  import "is-hotkey";
28
39
  import "slate-react";
29
- import { d as deepEqual } from "./deepEqual.es.js";
30
40
  import "redux";
31
41
  import "redux-thunk";
32
- import "./actions.es.js";
33
- import "react";
34
- import "@emotion/css";
35
- import "@emotion/serialize";
36
- import "@emotion/utils";
37
- import "react/jsx-runtime";
38
- const textAlignDefinition = Select({
39
- options: [{
40
- label: "Left",
41
- value: "left"
42
- }, {
43
- label: "Center",
44
- value: "center"
45
- }, {
46
- label: "Right",
47
- value: "right"
48
- }],
49
- defaultValue: "left"
50
- });
51
- const definitionWithObject = unstable_StyleV2({
52
- type: textAlignDefinition,
53
- getStyle(textAlign) {
54
- return {
55
- textAlign
56
- };
57
- }
58
- });
42
+ import "use-sync-external-store/shim/with-selector";
43
+ import "next/dynamic";
44
+ import "./combobox.es.js";
45
+ import "use-sync-external-store/shim";
46
+ import "./types.es.js";
47
+ import "./box-models.es.js";
48
+ import "css-box-model";
49
+ import "color";
50
+ import "scroll-into-view-if-needed";
51
+ import "react-dom";
52
+ import "html-react-parser";
53
+ import "next/head";
54
+ import "zod";
55
+ import "@emotion/server/create-instance";
56
+ import "next/document";
57
+ import "cors";
58
+ import "path-to-regexp";
59
+ import "cookie";
60
+ import "http-proxy";
61
+ import "set-cookie-parser";
62
+ import "./constants.es.js";
63
+ import "uuid";
64
+ import "corporate-ipsum";
65
+ import "next/link";
66
+ function setResponsiveValue(editor, key, value, options) {
67
+ Editor.withoutNormalizing(editor, () => {
68
+ const at = getSelection(editor);
69
+ if (!at)
70
+ return;
71
+ const atRef = Editor.rangeRef(editor, at);
72
+ if (atRef.current) {
73
+ Transforms.setNodes(editor, {
74
+ slice: true
75
+ }, {
76
+ at: atRef.current,
77
+ match: options.match,
78
+ split: options.split
79
+ });
80
+ }
81
+ if (atRef.current) {
82
+ const nodesToUpdate = Array.from(Editor.nodes(editor, {
83
+ at: atRef.current,
84
+ match: (node, path) => options.match(node, path) && node.slice === true
85
+ }));
86
+ for (const [, path] of nodesToUpdate) {
87
+ Transforms.setNodes(editor, {
88
+ [key]: value
89
+ }, { at: path });
90
+ }
91
+ }
92
+ atRef.unref();
93
+ });
94
+ }
95
+ function getResponsiveValue(editor, key, options) {
96
+ const matchingValues = Array.from(Editor.nodes(editor, {
97
+ at: getSelection(editor),
98
+ match: options == null ? void 0 : options.match
99
+ })).filter(([node, path]) => options.match(node, path)).map(([node]) => node[key]);
100
+ const value = matchingValues.length === 0 ? void 0 : matchingValues.reduce((a, b2) => deepEqual(a, b2) ? b2 : void 0);
101
+ return value;
102
+ }
103
+ function normalizeResponsiveValue(editor, key, options) {
104
+ return (entry) => {
105
+ const [node, path] = entry;
106
+ if (!options.match(node, path)) {
107
+ return false;
108
+ }
109
+ const responsiveValue = node == null ? void 0 : node[key];
110
+ if (Array.isArray(responsiveValue) && responsiveValue.length === 0) {
111
+ Transforms.unsetNodes(editor, key, { at: path });
112
+ return true;
113
+ }
114
+ if ((node == null ? void 0 : node.slice) != null) {
115
+ Transforms.unsetNodes(editor, "slice", { at: path });
116
+ return true;
117
+ }
118
+ return false;
119
+ };
120
+ }
121
+ const TEXT_ALIGN_KEY = "textAlign";
122
+ const withTextAlign = (editor) => {
123
+ const {
124
+ normalizeNode
125
+ } = editor;
126
+ editor.normalizeNode = (entry) => {
127
+ if (normalizeResponsiveValue(editor, TEXT_ALIGN_KEY, {
128
+ match: ElementUtils.isRootBlock
129
+ })(entry)) {
130
+ return;
131
+ }
132
+ normalizeNode(entry);
133
+ };
134
+ return editor;
135
+ };
59
136
  function TextAlignPlugin() {
60
137
  return createRichTextV2Plugin({
61
138
  control: {
62
- definition: definitionWithObject,
63
- onChange: (editor, value) => {
64
- const rootElements = getBlocksInSelection(editor);
65
- for (const [node, path] of rootElements) {
66
- if (ElementUtils.isBlock(node)) {
67
- Transforms.setNodes(editor, {
68
- ["textAlign"]: value
69
- }, {
70
- at: path
71
- });
72
- }
139
+ definition: unstable_StyleV2({
140
+ type: unstable_IconRadioGroup({
141
+ label: "Alignment",
142
+ options: [{
143
+ icon: unstable_IconRadioGroupIcon.TextAlignLeft,
144
+ label: "Left Align",
145
+ value: "left"
146
+ }, {
147
+ icon: unstable_IconRadioGroupIcon.TextAlignCenter,
148
+ label: "Center Align",
149
+ value: "center"
150
+ }, {
151
+ icon: unstable_IconRadioGroupIcon.TextAlignRight,
152
+ label: "Right Align",
153
+ value: "right"
154
+ }, {
155
+ icon: unstable_IconRadioGroupIcon.TextAlignJustify,
156
+ label: "Justify",
157
+ value: "justify"
158
+ }],
159
+ defaultValue: "left"
160
+ }),
161
+ getStyle(textAlign) {
162
+ return {
163
+ textAlign
164
+ };
73
165
  }
74
- },
75
- getValue: (editor) => {
76
- const blocks = getBlocksInSelection(editor).map(([block]) => {
77
- return block.textAlign;
78
- });
79
- const value = blocks.length === 0 ? void 0 : blocks.reduce((a, b) => deepEqual(a, b) ? b : void 0);
80
- return value;
81
- },
166
+ }),
167
+ onChange: (editor, value) => setResponsiveValue(editor, TEXT_ALIGN_KEY, value, {
168
+ match: ElementUtils.isRootBlock,
169
+ split: false
170
+ }),
171
+ getValue: (editor) => getResponsiveValue(editor, TEXT_ALIGN_KEY, {
172
+ match: ElementUtils.isRootBlock
173
+ }),
82
174
  getElementValue: (element) => {
83
175
  return ElementUtils.isRootBlock(element) ? element.textAlign : void 0;
84
176
  }
85
177
  },
178
+ withPlugin: withTextAlign,
86
179
  renderElement: (renderElement, className) => (props) => {
87
180
  return renderElement(__spreadProps(__spreadValues({}, props), {
88
181
  element: __spreadProps(__spreadValues({}, props.element), {
@@ -92,5 +185,240 @@ function TextAlignPlugin() {
92
185
  }
93
186
  });
94
187
  }
95
- export { TextAlignPlugin, definitionWithObject };
188
+ const COLOR_KEY = "color";
189
+ function ColorPlugin() {
190
+ return createRichTextV2Plugin({
191
+ control: {
192
+ definition: unstable_StyleV2({
193
+ type: Color({
194
+ label: "Color"
195
+ }),
196
+ getStyle(color) {
197
+ return {
198
+ color
199
+ };
200
+ }
201
+ }),
202
+ onChange: (editor, value) => {
203
+ setResponsiveValue(editor, COLOR_KEY, value, {
204
+ match: Text.isText,
205
+ split: true
206
+ });
207
+ },
208
+ getValue: (editor) => getResponsiveValue(editor, COLOR_KEY, {
209
+ match: Text.isText
210
+ }),
211
+ getLeafValue: (text) => {
212
+ return Text.isText(text) ? text == null ? void 0 : text.color : void 0;
213
+ }
214
+ },
215
+ withPlugin: (editor) => {
216
+ const {
217
+ normalizeNode
218
+ } = editor;
219
+ editor.normalizeNode = (entry) => {
220
+ if (normalizeResponsiveValue(editor, COLOR_KEY, {
221
+ match: Text.isText
222
+ })(entry)) {
223
+ return;
224
+ }
225
+ normalizeNode(entry);
226
+ };
227
+ return editor;
228
+ },
229
+ renderLeaf: (renderLeaf, className) => (props) => {
230
+ return renderLeaf(__spreadProps(__spreadValues({}, props), {
231
+ leaf: __spreadProps(__spreadValues({}, props.leaf), {
232
+ className
233
+ })
234
+ }));
235
+ }
236
+ });
237
+ }
238
+ function getSupportedInlinesAndTextInSelection(editor) {
239
+ return Array.from(Editor.nodes(editor, {
240
+ at: getSelection(editor),
241
+ match: (node) => ElementUtils.isInline(node) && isSupportedInlineType(node.type) || Text.isText(node)
242
+ }));
243
+ }
244
+ const getValue$1 = (editor) => {
245
+ var _a;
246
+ const roots = filterForSubtreeRoots(getSupportedInlinesAndTextInSelection(editor));
247
+ const areAllRootsSupportedInlineTypesOrText = roots.every((entry) => isSupportedInlineEntry(entry) || Text.isText(entry[0]));
248
+ if (!areAllRootsSupportedInlineTypesOrText)
249
+ return void 0;
250
+ const matchingValues = roots.filter(isSupportedInlineEntry).map(([node]) => node);
251
+ return (_a = matchingValues.reduce((a, b2) => deepEqual(a, b2) ? b2 : void 0, matchingValues.at(0))) == null ? void 0 : _a.type;
252
+ };
253
+ const onChange$1 = (editor, value) => {
254
+ function unwrapAllSupportedTypes() {
255
+ supportedInlineOptions.forEach(({ value: optionValue }) => unwrapInline(editor, optionValue));
256
+ }
257
+ function unwrapAllInlines() {
258
+ Transforms.unwrapNodes(editor, {
259
+ match: (node) => ElementUtils.isInline(node),
260
+ at: getSelection(editor)
261
+ });
262
+ }
263
+ if (value == null)
264
+ return unwrapAllSupportedTypes();
265
+ if (!isSupportedInlineType(value))
266
+ return;
267
+ const roots = filterForSubtreeRoots(getSupportedInlinesAndTextInSelection(editor));
268
+ const root = roots.at(0);
269
+ if (roots.length === 1 && root != null && isSupportedInlineEntry(root) && root[0].type === value) {
270
+ unwrapInline(editor, value);
271
+ } else {
272
+ unwrapAllInlines();
273
+ wrapInline(editor, { type: value, children: [] });
274
+ }
275
+ };
276
+ const withInline = (editor) => {
277
+ const {
278
+ isInline
279
+ } = editor;
280
+ editor.isInline = (entry) => {
281
+ return ElementUtils.isInline(entry) && isInline(entry);
282
+ };
283
+ return editor;
284
+ };
285
+ function InlinePlugin() {
286
+ return createRichTextV2Plugin({
287
+ control: {
288
+ definition: unstable_IconRadioGroup({
289
+ label: "Inline",
290
+ options: supportedInlineOptions
291
+ }),
292
+ onChange: onChange$1,
293
+ getValue: getValue$1,
294
+ getElementValue: (element) => {
295
+ return ElementUtils.isInline(element) ? element.type : void 0;
296
+ }
297
+ },
298
+ withPlugin: withInline,
299
+ renderElement: (renderElement) => (props) => {
300
+ return /* @__PURE__ */ jsx(InlinePluginComponent$1, __spreadProps(__spreadValues({}, props), {
301
+ renderElement
302
+ }));
303
+ }
304
+ });
305
+ }
306
+ function InlinePluginComponent$1({
307
+ element,
308
+ attributes,
309
+ children,
310
+ renderElement
311
+ }) {
312
+ switch (element.type) {
313
+ case InlineType.Code:
314
+ return /* @__PURE__ */ jsx("code", __spreadProps(__spreadValues({}, attributes), {
315
+ children
316
+ }));
317
+ case InlineType.SuperScript:
318
+ return /* @__PURE__ */ jsx("sup", __spreadProps(__spreadValues({}, attributes), {
319
+ children
320
+ }));
321
+ case InlineType.SubScript:
322
+ return /* @__PURE__ */ jsx("sub", __spreadProps(__spreadValues({}, attributes), {
323
+ children
324
+ }));
325
+ default:
326
+ return /* @__PURE__ */ jsx(Fragment, {
327
+ children: renderElement({
328
+ element,
329
+ attributes,
330
+ children
331
+ })
332
+ });
333
+ }
334
+ }
335
+ function isLinkElement(node) {
336
+ return ElementUtils.isInline(node) && node.type === InlineType.Link;
337
+ }
338
+ function isLinkEntry(inline) {
339
+ return ElementUtils.isInline(inline[0]) && inline[0].type === InlineType.Link;
340
+ }
341
+ function getLinksAndTextInSelection(editor) {
342
+ return Array.from(Editor.nodes(editor, {
343
+ at: getSelection(editor),
344
+ match: (node) => ElementUtils.isInline(node) && isLinkElement(node) || Text.isText(node)
345
+ }));
346
+ }
347
+ const getValue = (editor) => {
348
+ var _a;
349
+ const roots = filterForSubtreeRoots(getLinksAndTextInSelection(editor));
350
+ const areAllRootsLinks = roots.every(([root]) => isLinkElement(root) || Text.isText(root));
351
+ if (!areAllRootsLinks)
352
+ return void 0;
353
+ const matchingValues = roots.map(([node]) => node).filter(isLinkElement);
354
+ return (_a = matchingValues.reduce((a, b2) => deepEqual(a, b2) ? b2 : void 0, matchingValues.at(0))) == null ? void 0 : _a.link;
355
+ };
356
+ const onChange = (editor, value) => {
357
+ if (value == null)
358
+ return unwrapInline(editor, InlineType.Link);
359
+ const roots = filterForSubtreeRoots(getLinksAndTextInSelection(editor));
360
+ const root = roots.at(0);
361
+ if (roots.length === 1 && root != null && isLinkEntry(root)) {
362
+ Transforms.setNodes(editor, {
363
+ link: value
364
+ }, { at: root[1] });
365
+ } else {
366
+ unwrapInline(editor, InlineType.Link);
367
+ wrapInline(editor, { type: InlineType.Link, link: value, children: [] });
368
+ }
369
+ };
370
+ const withLink = (editor) => {
371
+ const {
372
+ isInline
373
+ } = editor;
374
+ editor.isInline = (entry) => {
375
+ return ElementUtils.isInline(entry) && isInline(entry);
376
+ };
377
+ return editor;
378
+ };
379
+ function InlinePluginComponent({
380
+ element,
381
+ attributes,
382
+ children,
383
+ renderElement
384
+ }) {
385
+ const linkStyle = useStyle({
386
+ textDecoration: "none"
387
+ });
388
+ switch (element.type) {
389
+ case InlineType.Link:
390
+ return /* @__PURE__ */ jsx(Link$1, __spreadProps(__spreadValues({}, attributes), {
391
+ link: element.link,
392
+ className: cx(linkStyle, element.className),
393
+ children
394
+ }));
395
+ default:
396
+ return renderElement({
397
+ element,
398
+ attributes,
399
+ children
400
+ });
401
+ }
402
+ }
403
+ function LinkPlugin() {
404
+ return createRichTextV2Plugin({
405
+ control: {
406
+ definition: Link({
407
+ label: "On Click"
408
+ }),
409
+ onChange,
410
+ getValue,
411
+ getElementValue: (element) => {
412
+ return ElementUtils.isInline(element) && isLinkElement(element) ? element.link : void 0;
413
+ }
414
+ },
415
+ withPlugin: withLink,
416
+ renderElement: (renderElement) => (props) => {
417
+ return /* @__PURE__ */ jsx(InlinePluginComponent, __spreadProps(__spreadValues({}, props), {
418
+ renderElement
419
+ }));
420
+ }
421
+ });
422
+ }
423
+ export { COLOR_KEY, ColorPlugin, InlinePlugin, LinkPlugin, TextAlignPlugin, withInline, withLink, withTextAlign };
96
424
  //# sourceMappingURL=slate.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"slate.es.js","sources":["../src/slate/TextAlignPlugin/index.tsx"],"sourcesContent":["import { Element, Transforms } from 'slate'\nimport {\n ControlDefinitionData,\n Select,\n createRichTextV2Plugin,\n unstable_StyleV2,\n} from '../../controls'\nimport { getBlocksInSelection } from '../selectors'\nimport deepEqual from '../../utils/deepEqual'\nimport { ElementUtils } from '../utils/element'\n\nconst textAlignDefinition = Select({\n options: [\n {\n label: 'Left',\n value: 'left',\n },\n {\n label: 'Center',\n value: 'center',\n },\n {\n label: 'Right',\n value: 'right',\n },\n ],\n defaultValue: 'left',\n})\n\nexport const definitionWithObject = unstable_StyleV2({\n type: textAlignDefinition,\n getStyle(textAlign: ControlDefinitionData<typeof textAlignDefinition>) {\n return { textAlign }\n },\n})\n\nexport function TextAlignPlugin() {\n return createRichTextV2Plugin({\n control: {\n definition: definitionWithObject,\n onChange: (editor, value) => {\n const rootElements = getBlocksInSelection(editor)\n\n for (const [node, path] of rootElements) {\n if (ElementUtils.isBlock(node)) {\n Transforms.setNodes(\n editor,\n {\n ['textAlign']: value,\n },\n { at: path },\n )\n }\n }\n },\n getValue: editor => {\n const blocks = getBlocksInSelection(editor).map(([block]) => {\n return block.textAlign\n })\n\n const value =\n blocks.length === 0\n ? undefined\n : blocks.reduce((a, b) => (deepEqual(a, b) ? b : undefined))\n\n return value\n },\n getElementValue: (element: Element) => {\n return ElementUtils.isRootBlock(element) ? element.textAlign : undefined\n },\n },\n renderElement: (renderElement, className) => props => {\n return renderElement({\n ...props,\n element: {\n ...props.element,\n className,\n },\n })\n },\n })\n}\n"],"names":["textAlignDefinition","Select","options","label","value","defaultValue","definitionWithObject","unstable_StyleV2","type","getStyle","textAlign","createRichTextV2Plugin","control","definition","onChange","editor","rootElements","getBlocksInSelection","node","path","ElementUtils","isBlock","Transforms","setNodes","at","getValue","blocks","map","block","length","undefined","reduce","a","b","deepEqual","getElementValue","element","isRootBlock","renderElement","className","props"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,MAAMA,sBAAsBC,OAAO;AAAA,EACjCC,SAAS,CACP;AAAA,IACEC,OAAO;AAAA,IACPC,OAAO;AAAA,EAAA,GAET;AAAA,IACED,OAAO;AAAA,IACPC,OAAO;AAAA,EAAA,GAET;AAAA,IACED,OAAO;AAAA,IACPC,OAAO;AAAA,EAAA,CAXF;AAAA,EAcTC,cAAc;AAfmB,CAAD;AAkB3B,MAAMC,uBAAuBC,iBAAiB;AAAA,EACnDC,MAAMR;AAAAA,EACNS,SAASC,WAA8D;AAC9D,WAAA;AAAA,MAAEA;AAAAA,IAAAA;AAAAA,EACV;AAJkD,CAAD;AAOlB,2BAAA;AAChC,SAAOC,uBAAuB;AAAA,IAC5BC,SAAS;AAAA,MACPC,YAAYP;AAAAA,MACZQ,UAAU,CAACC,QAAQX,UAAU;AACrBY,cAAAA,eAAeC,qBAAqBF,MAAD;AAE9B,mBAAA,CAACG,MAAMC,SAASH,cAAc;AACnCI,cAAAA,aAAaC,QAAQH,IAArB,GAA4B;AAC9BI,uBAAWC,SACTR,QACA;AAAA,eACG,cAAcX;AAAAA,YAAAA,GAEjB;AAAA,cAAEoB,IAAIL;AAAAA,YAAAA,CALR;AAAA,UAOD;AAAA,QACF;AAAA,MAfI;AAAA,MAiBPM,UAAUV,CAAU,WAAA;AAClB,cAAMW,SAAST,qBAAqBF,MAAD,EAASY,IAAI,CAAC,CAACC,WAAW;AACpDA,iBAAAA,MAAMlB;AAAAA,QAAAA,CADA;AAIf,cAAMN,QACJsB,OAAOG,WAAW,IACdC,SACAJ,OAAOK,OAAO,CAACC,GAAGC,MAAOC,UAAUF,GAAGC,CAAJ,IAASA,IAAIH,MAA/C;AAEC1B,eAAAA;AAAAA,MA3BF;AAAA,MA6BP+B,iBAAiB,CAACC,YAAqB;AAC9BhB,eAAAA,aAAaiB,YAAYD,OAAzB,IAAoCA,QAAQ1B,YAAYoB;AAAAA,MAChE;AAAA,IAhCyB;AAAA,IAkC5BQ,eAAe,CAACA,eAAeC,cAAcC,CAAS,UAAA;AACpD,aAAOF,cAAc,iCAChBE,QADgB;AAAA,QAEnBJ,SAAS,iCACJI,MAAMJ,UADF;AAAA,UAEPG;AAAAA,QAFO;AAAA,MAAA,EAFS;AAAA,IAOrB;AAAA,EAAA,CA1C0B;AA4C9B;;"}
1
+ {"version":3,"file":"slate.es.js","sources":["../src/slate/utils/responsive.ts","../src/slate/TextAlignPlugin/index.tsx","../src/slate/ColorPlugin/index.tsx","../src/slate/InlinePlugin/getValue.ts","../src/slate/InlinePlugin/onChange.ts","../src/slate/InlinePlugin/index.tsx","../src/slate/LinkPlugin/types.ts","../src/slate/LinkPlugin/getValue.ts","../src/slate/LinkPlugin/onChange.ts","../src/slate/LinkPlugin/index.tsx"],"sourcesContent":["import { Editor, Transforms, NodeMatch, Descendant, NodeEntry } from 'slate'\nimport { getSelection } from '../selectors'\nimport deepEqual from '../../utils/deepEqual'\n\ntype SetResponsiveValueOptions<T extends Descendant> = {\n match: NodeMatch<T>\n split: boolean\n}\n\nexport function setResponsiveValue<T extends Descendant, K extends keyof T>(\n editor: Editor,\n key: K,\n value: T[K] | undefined,\n options: SetResponsiveValueOptions<T>,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = getSelection(editor)\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes<Descendant>(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: options.match,\n split: options.split,\n },\n )\n }\n\n if (atRef.current) {\n const nodesToUpdate = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: (node, path) => options.match(node, path) && node.slice === true,\n }),\n )\n\n for (const [, path] of nodesToUpdate) {\n Transforms.setNodes(\n editor,\n {\n [key]: value,\n },\n { at: path },\n )\n }\n }\n\n atRef.unref()\n })\n}\n\ntype GetResponsiveValueOptions<T extends Descendant> = {\n match: NodeMatch<T>\n}\n\nexport function getResponsiveValue<T extends Descendant, K extends keyof T>(\n editor: Editor,\n key: K,\n options: GetResponsiveValueOptions<T>,\n): T[K] | undefined {\n const matchingValues = Array.from(\n Editor.nodes(editor, {\n at: getSelection(editor),\n match: options?.match,\n }),\n )\n .filter(([node, path]) => options.match(node, path))\n .map(([node]) => node[key]) as (T[K] | undefined)[]\n\n const value =\n matchingValues.length === 0\n ? undefined\n : matchingValues.reduce((a, b) => (deepEqual(a, b) ? b : undefined))\n\n return value\n}\n\ntype NormalizeResponsiveValueOptions<T extends Descendant> = {\n match: NodeMatch<T>\n}\n\nexport function normalizeResponsiveValue<T extends Descendant, K extends keyof T & string>(\n editor: Editor,\n key: K,\n options: NormalizeResponsiveValueOptions<T>,\n) {\n return (entry: NodeEntry) => {\n const [node, path] = entry\n\n if (!options.match(node, path)) {\n return false\n }\n\n const responsiveValue = node?.[key]\n\n if (Array.isArray(responsiveValue) && responsiveValue.length === 0) {\n Transforms.unsetNodes(editor, key, { at: path })\n return true\n }\n\n if (node?.slice != null) {\n Transforms.unsetNodes(editor, 'slice', { at: path })\n return true\n }\n\n return false\n }\n}\n","import { Editor, Element } from 'slate'\nimport {\n createRichTextV2Plugin,\n unstable_IconRadioGroup,\n unstable_IconRadioGroupIcon,\n unstable_StyleV2,\n} from '../../controls'\nimport { ElementUtils } from '../utils/element'\nimport { TextAlignProperty } from 'csstype'\nimport {\n getResponsiveValue,\n normalizeResponsiveValue,\n setResponsiveValue,\n} from '../utils/responsive'\n\nconst TEXT_ALIGN_KEY = 'textAlign'\n\nexport const withTextAlign = (editor: Editor) => {\n const { normalizeNode } = editor\n editor.normalizeNode = entry => {\n if (\n normalizeResponsiveValue(editor, TEXT_ALIGN_KEY, { match: ElementUtils.isRootBlock })(entry)\n ) {\n return\n }\n normalizeNode(entry)\n }\n\n return editor\n}\n\nexport function TextAlignPlugin() {\n return createRichTextV2Plugin({\n control: {\n definition: unstable_StyleV2({\n type: unstable_IconRadioGroup({\n label: 'Alignment',\n options: [\n {\n icon: unstable_IconRadioGroupIcon.TextAlignLeft,\n label: 'Left Align',\n value: 'left',\n },\n {\n icon: unstable_IconRadioGroupIcon.TextAlignCenter,\n label: 'Center Align',\n value: 'center',\n },\n {\n icon: unstable_IconRadioGroupIcon.TextAlignRight,\n label: 'Right Align',\n value: 'right',\n },\n {\n icon: unstable_IconRadioGroupIcon.TextAlignJustify,\n label: 'Justify',\n value: 'justify',\n },\n ],\n defaultValue: 'left',\n }),\n getStyle(textAlign: TextAlignProperty) {\n return { textAlign }\n },\n }),\n onChange: (editor, value) =>\n setResponsiveValue(editor, TEXT_ALIGN_KEY, value, {\n match: ElementUtils.isRootBlock,\n split: false,\n }),\n getValue: editor =>\n getResponsiveValue(editor, TEXT_ALIGN_KEY, { match: ElementUtils.isRootBlock }),\n getElementValue: (element: Element) => {\n return ElementUtils.isRootBlock(element) ? element.textAlign : undefined\n },\n },\n withPlugin: withTextAlign,\n renderElement: (renderElement, className) => props => {\n return renderElement({\n ...props,\n element: {\n ...props.element,\n className,\n },\n })\n },\n })\n}\n","import { Editor, Text } from 'slate'\nimport {\n Color,\n createRichTextV2Plugin,\n unstable_StyleV2,\n ColorControlDefinition,\n} from '../../controls'\nimport { ControlDefinitionValue } from '../../runtimes/react/controls/control'\nimport {\n getResponsiveValue,\n normalizeResponsiveValue,\n setResponsiveValue,\n} from '../utils/responsive'\n\nexport const COLOR_KEY = 'color'\n\nexport function ColorPlugin() {\n return createRichTextV2Plugin({\n control: {\n definition: unstable_StyleV2({\n type: Color({\n label: 'Color',\n }),\n getStyle(color: ControlDefinitionValue<ColorControlDefinition>) {\n return { color }\n },\n }),\n onChange: (editor, value) => {\n setResponsiveValue(editor, COLOR_KEY, value, {\n match: Text.isText,\n split: true,\n })\n },\n getValue: editor => getResponsiveValue(editor, COLOR_KEY, { match: Text.isText }),\n getLeafValue: (text: Text) => {\n return Text.isText(text) ? text?.color : undefined\n },\n },\n withPlugin: (editor: Editor) => {\n const { normalizeNode } = editor\n editor.normalizeNode = entry => {\n if (normalizeResponsiveValue(editor, COLOR_KEY, { match: Text.isText })(entry)) {\n return\n }\n\n normalizeNode(entry)\n }\n\n return editor\n },\n renderLeaf: (renderLeaf, className) => props => {\n return renderLeaf({\n ...props,\n leaf: {\n ...props.leaf,\n className,\n },\n })\n },\n })\n}\n","import { Editor, NodeEntry, Text } from 'slate'\nimport { ElementUtils } from '../utils/element'\nimport { getSelection } from '../selectors'\nimport { filterForSubtreeRoots } from '../BlockPlugin/utils/filterForSubtreeRoots'\nimport deepEqual from '../../utils/deepEqual'\nimport { SupportedInline, isSupportedInlineType, isSupportedInlineEntry } from './types'\n\nexport function getSupportedInlinesAndTextInSelection(\n editor: Editor,\n): NodeEntry<SupportedInline | Text>[] {\n return Array.from(\n Editor.nodes(editor, {\n at: getSelection(editor),\n match: node =>\n (ElementUtils.isInline(node) && isSupportedInlineType(node.type)) || Text.isText(node),\n }),\n ) as NodeEntry<Text | SupportedInline>[]\n}\n\nexport const getValue = (editor: Editor) => {\n const roots = filterForSubtreeRoots(getSupportedInlinesAndTextInSelection(editor))\n\n const areAllRootsSupportedInlineTypesOrText = roots.every(\n entry => isSupportedInlineEntry(entry) || Text.isText(entry[0]),\n )\n\n if (!areAllRootsSupportedInlineTypesOrText) return undefined\n\n const matchingValues = roots.filter(isSupportedInlineEntry).map(([node]) => node)\n\n return matchingValues.reduce((a, b) => (deepEqual(a, b) ? b : undefined), matchingValues.at(0))\n ?.type\n}\n","import { getSupportedInlinesAndTextInSelection } from './getValue'\nimport { Editor, Transforms } from 'slate'\nimport { ElementUtils } from '../utils/element'\nimport { unwrapInline } from '../BlockPlugin/unwrapInline'\nimport { wrapInline } from '../BlockPlugin/wrapInline'\nimport { getSelection } from '../selectors'\nimport { filterForSubtreeRoots } from '../BlockPlugin/utils/filterForSubtreeRoots'\nimport {\n SupportedInlineType,\n isSupportedInlineEntry,\n isSupportedInlineType,\n supportedInlineOptions,\n} from './types'\n\nexport const onChange = (editor: Editor, value: SupportedInlineType) => {\n function unwrapAllSupportedTypes() {\n supportedInlineOptions.forEach(({ value: optionValue }) => unwrapInline(editor, optionValue))\n }\n\n function unwrapAllInlines() {\n Transforms.unwrapNodes(editor, {\n match: node => ElementUtils.isInline(node),\n at: getSelection(editor),\n })\n }\n\n if (value == null) return unwrapAllSupportedTypes()\n\n if (!isSupportedInlineType(value)) return\n\n const roots = filterForSubtreeRoots(getSupportedInlinesAndTextInSelection(editor))\n const root = roots.at(0)\n\n if (\n roots.length === 1 &&\n root != null &&\n isSupportedInlineEntry(root) &&\n root[0].type === value\n ) {\n unwrapInline(editor, value)\n } else {\n unwrapAllInlines()\n wrapInline(editor, { type: value, children: [] })\n }\n}\n","import { Editor, Element } from 'slate'\nimport { RenderElement, createRichTextV2Plugin, unstable_IconRadioGroup } from '../../controls'\nimport { ElementUtils } from '../utils/element'\nimport { InlineType } from '../types'\nimport { RenderElementProps } from 'slate-react'\nimport { supportedInlineOptions } from './types'\nimport { onChange } from './onChange'\nimport { getValue } from './getValue'\n\nexport const withInline = (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\nexport function InlinePlugin() {\n return createRichTextV2Plugin({\n control: {\n definition: unstable_IconRadioGroup({\n label: 'Inline',\n options: supportedInlineOptions,\n }),\n onChange,\n getValue,\n getElementValue: (element: Element) => {\n return ElementUtils.isInline(element) ? element.type : undefined\n },\n },\n withPlugin: withInline,\n renderElement: renderElement => props => {\n return <InlinePluginComponent {...props} renderElement={renderElement} />\n },\n })\n}\n\nfunction InlinePluginComponent({\n element,\n attributes,\n children,\n renderElement,\n}: RenderElementProps & { renderElement: RenderElement }) {\n switch (element.type) {\n case InlineType.Code:\n return <code {...attributes}>{children}</code>\n case InlineType.SuperScript:\n return <sup {...attributes}>{children}</sup>\n case InlineType.SubScript:\n return <sub {...attributes}>{children}</sub>\n\n default:\n return (\n <>\n {renderElement({\n element,\n attributes,\n children,\n })}\n </>\n )\n }\n}\n","import { Node, NodeEntry } from 'slate'\nimport { ElementUtils } from '../utils/element'\nimport { InlineType, LinkElement } from '../types'\n\nexport function isLinkElement(node: Node): node is LinkElement {\n return ElementUtils.isInline(node) && node.type === InlineType.Link\n}\n\nexport function isLinkEntry(inline: NodeEntry<Node>): inline is NodeEntry<LinkElement> {\n return ElementUtils.isInline(inline[0]) && inline[0].type === InlineType.Link\n}\n","import { Editor, NodeEntry, Text } from 'slate'\nimport { ElementUtils } from '../utils/element'\nimport { LinkElement } from '../types'\nimport deepEqual from '../../utils/deepEqual'\nimport { getSelection } from '../selectors'\nimport { filterForSubtreeRoots } from '../BlockPlugin/utils/filterForSubtreeRoots'\nimport { isLinkElement } from './types'\n\nexport function getLinksAndTextInSelection(editor: Editor): NodeEntry<LinkElement | Text>[] {\n return Array.from(\n Editor.nodes(editor, {\n at: getSelection(editor),\n match: node => (ElementUtils.isInline(node) && isLinkElement(node)) || Text.isText(node),\n }),\n ) as NodeEntry<Text | LinkElement>[]\n}\n\nexport const getValue = (editor: Editor) => {\n const roots = filterForSubtreeRoots(getLinksAndTextInSelection(editor))\n\n const areAllRootsLinks = roots.every(([root]) => isLinkElement(root) || Text.isText(root))\n\n if (!areAllRootsLinks) return undefined\n\n const matchingValues = roots.map(([node]) => node).filter(isLinkElement)\n\n return matchingValues.reduce((a, b) => (deepEqual(a, b) ? b : undefined), matchingValues.at(0))\n ?.link\n}\n","import { Editor, Transforms } from 'slate'\nimport { LinkControlData } from '../../controls'\nimport { unwrapInline } from '../BlockPlugin/unwrapInline'\nimport { wrapInline } from '../BlockPlugin/wrapInline'\nimport { InlineType } from '../types'\nimport { filterForSubtreeRoots } from '../BlockPlugin/utils/filterForSubtreeRoots'\nimport { isLinkEntry } from './types'\nimport { getLinksAndTextInSelection } from './getValue'\n\nexport const onChange = (editor: Editor, value: LinkControlData) => {\n if (value == null) return unwrapInline(editor, InlineType.Link)\n\n const roots = filterForSubtreeRoots(getLinksAndTextInSelection(editor))\n const root = roots.at(0)\n\n // If the root of our selection is a link we just want to modify it\n if (roots.length === 1 && root != null && isLinkEntry(root)) {\n Transforms.setNodes(\n editor,\n {\n link: value,\n },\n { at: root[1] },\n )\n }\n // In all other cases we want to remove all existing links and wrap the current selection in a new link\n else {\n unwrapInline(editor, InlineType.Link)\n wrapInline(editor, { type: InlineType.Link, link: value, children: [] })\n }\n}\n","import { Editor, Element } from 'slate'\nimport { Link, RenderElement, createRichTextV2Plugin } from '../../controls'\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}\n className={cx(linkStyle, element.className)}\n >\n {children}\n </LinkComponent>\n )\n\n default:\n return renderElement({\n element,\n attributes,\n children,\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":["TEXT_ALIGN_KEY","withTextAlign","editor","normalizeNode","entry","normalizeResponsiveValue","match","ElementUtils","isRootBlock","createRichTextV2Plugin","control","definition","unstable_StyleV2","type","unstable_IconRadioGroup","label","options","icon","unstable_IconRadioGroupIcon","TextAlignLeft","value","TextAlignCenter","TextAlignRight","TextAlignJustify","defaultValue","getStyle","textAlign","onChange","setResponsiveValue","split","getValue","getResponsiveValue","getElementValue","element","undefined","withPlugin","renderElement","className","props","COLOR_KEY","Color","color","Text","isText","getLeafValue","text","renderLeaf","leaf","withInline","isInline","supportedInlineOptions","InlinePluginComponent","attributes","children","InlineType","Code","SuperScript","SubScript","_Fragment","withLink","linkStyle","useStyle","textDecoration","Link","LinkComponent","link","cx","isLinkElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUE,4BAAA,QACA,KACA,OACA,SACA;AACO,SAAA,mBAAmB,QAAQ,MAAM;AAChC,UAAA,KAAK,aAAa,MAAM;AAC9B,QAAI,CAAC;AAAI;AACT,UAAM,QAAQ,OAAO,SAAS,QAAQ,EAAE;AAExC,QAAI,MAAM,SAAS;AACjB,iBAAW,SACT,QACA;AAAA,QACE,OAAO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,MACAE,iBAAiB,CAACC,YAAqB;AAC9B1B,eAAAA,aAAa0C,SAAShB,OAAtB,KAAkCkC,cAAclC,OAAD,IAAYA,QAAQgC,OAAO/B;AAAAA,MAClF;AAAA,IATyB;AAAA,IAW5BC,YAAYwB;AAAAA,IACZvB,eAAeA,mBAAiBE,CAAS,UAAA;AAChC,iCAAC,uBAAD,iCAA2BA,QAA3B;AAAA,QAAkC;AAAA,MAAA,EAAzC;AAAA,IACD;AAAA,EAAA,CAd0B;AAgB9B;;"}
@@ -3,10 +3,27 @@ const CheckboxControlType = "makeswift::controls::checkbox";
3
3
  function Checkbox(config = {}) {
4
4
  return { type: CheckboxControlType, config };
5
5
  }
6
+ const unstable_IconRadioGroupIcon = {
7
+ TextAlignCenter: "TextAlignCenter",
8
+ TextAlignJustify: "TextAlignJustify",
9
+ TextAlignLeft: "TextAlignLeft",
10
+ TextAlignRight: "TextAlignRight",
11
+ Superscript: "Superscript16",
12
+ Subscript: "Subscript16",
13
+ Code: "Code16"
14
+ };
15
+ const IconRadioGroupControlType = "makeswift::controls::icon-radio-group";
16
+ function unstable_IconRadioGroup(config) {
17
+ return { type: IconRadioGroupControlType, config };
18
+ }
6
19
  const NumberControlType = "makeswift::controls::number";
7
20
  function Number(config = {}) {
8
21
  return { type: NumberControlType, config };
9
22
  }
23
+ const SelectControlType = "makeswift::controls::select";
24
+ function Select(config) {
25
+ return { type: SelectControlType, config };
26
+ }
10
27
  const TextAreaControlType = "makeswift::controls::text-area";
11
28
  function TextArea(config = {}) {
12
29
  return { type: TextAreaControlType, config };
@@ -17,10 +34,15 @@ function TextInput(config = {}) {
17
34
  }
18
35
  exports.Checkbox = Checkbox;
19
36
  exports.CheckboxControlType = CheckboxControlType;
37
+ exports.IconRadioGroupControlType = IconRadioGroupControlType;
20
38
  exports.Number = Number;
21
39
  exports.NumberControlType = NumberControlType;
40
+ exports.Select = Select;
41
+ exports.SelectControlType = SelectControlType;
22
42
  exports.TextArea = TextArea;
23
43
  exports.TextAreaControlType = TextAreaControlType;
24
44
  exports.TextInput = TextInput;
25
45
  exports.TextInputControlType = TextInputControlType;
46
+ exports.unstable_IconRadioGroup = unstable_IconRadioGroup;
47
+ exports.unstable_IconRadioGroupIcon = unstable_IconRadioGroupIcon;
26
48
  //# sourceMappingURL=text-input.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"text-input.cjs.js","sources":["../src/controls/checkbox.ts","../src/controls/number.ts","../src/controls/text-area.ts","../src/controls/text-input.ts"],"sourcesContent":["export type CheckboxControlData = boolean\n\nexport const CheckboxControlType = 'makeswift::controls::checkbox'\n\ntype CheckboxControlConfig = {\n label?: string\n defaultValue?: boolean\n}\n\nexport type CheckboxControlDefinition<C extends CheckboxControlConfig = CheckboxControlConfig> = {\n type: typeof CheckboxControlType\n config: C\n}\n\nexport function Checkbox<C extends CheckboxControlConfig>(\n config: C = {} as C,\n): CheckboxControlDefinition<C> {\n return { type: CheckboxControlType, config }\n}\n","export type NumberControlData = number\n\nexport const NumberControlType = 'makeswift::controls::number'\n\ntype NumberControlConfig = {\n label?: string\n labelOrientation?: 'vertical' | 'horizontal'\n defaultValue?: number\n min?: number\n max?: number\n step?: number\n suffix?: string\n}\n\nexport type NumberControlDefinition<C extends NumberControlConfig = NumberControlConfig> = {\n type: typeof NumberControlType\n config: C\n}\n\nexport function Number<C extends NumberControlConfig>(\n config: C = {} as C,\n): NumberControlDefinition<C> {\n return { type: NumberControlType, config }\n}\n","export type TextAreaControlData = string\n\nexport const TextAreaControlType = 'makeswift::controls::text-area'\n\ntype TextAreaControlConfig = {\n label?: string\n defaultValue?: string\n rows?: number\n}\n\nexport type TextAreaControlDefinition<C extends TextAreaControlConfig = TextAreaControlConfig> = {\n type: typeof TextAreaControlType\n config: C\n}\n\nexport function TextArea<C extends TextAreaControlConfig>(\n config: C = {} as C,\n): TextAreaControlDefinition<C> {\n return { type: TextAreaControlType, config }\n}\n","export type TextInputControlData = string\n\nexport const TextInputControlType = 'makeswift::controls::text-input'\n\ntype TextInputControlConfig = {\n label?: string\n defaultValue?: string\n}\n\nexport type TextInputControlDefinition<C extends TextInputControlConfig = TextInputControlConfig> =\n {\n type: typeof TextInputControlType\n config: C\n }\n\nexport function TextInput<C extends TextInputControlConfig>(\n config: C = {} as C,\n): TextInputControlDefinition<C> {\n return { type: TextInputControlType, config }\n}\n"],"names":[],"mappings":";AAEO,MAAM,sBAAsB;AAajC,kBAAA,SAAY,IACkB;AACvB,SAAA,EAAE,MAAM,qBAAqB;AACtC;AChBO,MAAM,oBAAoB;AAkB/B,gBAAA,SAAY,IACgB;AACrB,SAAA,EAAE,MAAM,mBAAmB;AACpC;ACrBO,MAAM,sBAAsB;AAcjC,kBAAA,SAAY,IACkB;AACvB,SAAA,EAAE,MAAM,qBAAqB;AACtC;ACjBO,MAAM,uBAAuB;AAclC,mBAAA,SAAY,IACmB;AACxB,SAAA,EAAE,MAAM,sBAAsB;AACvC;;;;;;;;;"}
1
+ {"version":3,"file":"text-input.cjs.js","sources":["../src/controls/checkbox.ts","../src/controls/icon-radio-group.ts","../src/controls/number.ts","../src/controls/select.ts","../src/controls/text-area.ts","../src/controls/text-input.ts"],"sourcesContent":["export type CheckboxControlData = boolean\n\nexport const CheckboxControlType = 'makeswift::controls::checkbox'\n\ntype CheckboxControlConfig = {\n label?: string\n defaultValue?: boolean\n}\n\nexport type CheckboxControlDefinition<C extends CheckboxControlConfig = CheckboxControlConfig> = {\n type: typeof CheckboxControlType\n config: C\n}\n\nexport function Checkbox<C extends CheckboxControlConfig>(\n config: C = {} as C,\n): CheckboxControlDefinition<C> {\n return { type: CheckboxControlType, config }\n}\n","export const unstable_IconRadioGroupIcon = {\n TextAlignCenter: 'TextAlignCenter',\n TextAlignJustify: 'TextAlignJustify',\n TextAlignLeft: 'TextAlignLeft',\n TextAlignRight: 'TextAlignRight',\n Superscript: 'Superscript16',\n Subscript: 'Subscript16',\n Code: 'Code16',\n} as const\n\nexport type IconRadioGroupIcon =\n typeof unstable_IconRadioGroupIcon[keyof typeof unstable_IconRadioGroupIcon]\n\nexport const IconRadioGroupControlType = 'makeswift::controls::icon-radio-group'\n\nexport type IconRadioGroupOption<T extends string> = {\n value: T\n icon: IconRadioGroupIcon\n label: string\n}\n\ntype IconRadioGroupControlConfig<T extends string = string> = {\n label?: string\n defaultValue?: T\n options: IconRadioGroupOption<T>[]\n}\n\nexport type IconRadioGroupControlDefinition<\n C extends IconRadioGroupControlConfig = IconRadioGroupControlConfig,\n> = {\n type: typeof IconRadioGroupControlType\n config: C\n}\n\nexport type IconRadioGroupControlDefinitionOption<\n T extends IconRadioGroupControlDefinition = IconRadioGroupControlDefinition,\n> = T['config'] extends IconRadioGroupControlConfig<infer U> ? U : never\n\nexport type IconRadioGroupControlData<\n T extends IconRadioGroupControlDefinition = IconRadioGroupControlDefinition,\n> = IconRadioGroupControlDefinitionOption<T>\n\nexport function unstable_IconRadioGroup<T extends string, C extends IconRadioGroupControlConfig<T>>(\n config: C & { options: IconRadioGroupOption<T>[] },\n): IconRadioGroupControlDefinition<C> {\n return { type: IconRadioGroupControlType, config }\n}\n","export type NumberControlData = number\n\nexport const NumberControlType = 'makeswift::controls::number'\n\ntype NumberControlConfig = {\n label?: string\n labelOrientation?: 'vertical' | 'horizontal'\n defaultValue?: number\n min?: number\n max?: number\n step?: number\n suffix?: string\n}\n\nexport type NumberControlDefinition<C extends NumberControlConfig = NumberControlConfig> = {\n type: typeof NumberControlType\n config: C\n}\n\nexport function Number<C extends NumberControlConfig>(\n config: C = {} as C,\n): NumberControlDefinition<C> {\n return { type: NumberControlType, config }\n}\n","export const SelectControlType = 'makeswift::controls::select'\n\ntype SelectControlOption<T extends string> = { value: T; label: string }\n\ntype SelectControlConfig<T extends string = string> = {\n label?: string\n labelOrientation?: 'horizontal' | 'vertical'\n options: SelectControlOption<T>[]\n defaultValue?: T\n}\n\nexport type SelectControlDefinition<C extends SelectControlConfig = SelectControlConfig> = {\n type: typeof SelectControlType\n config: C\n}\n\nexport type SelectControlDefinitionOption<T extends SelectControlDefinition> =\n T['config'] extends SelectControlConfig<infer U> ? U : never\n\nexport type SelectControlData<T extends SelectControlDefinition = SelectControlDefinition> =\n SelectControlDefinitionOption<T>\n\nexport function Select<T extends string, C extends SelectControlConfig<T>>(\n config: C & { options: SelectControlOption<T>[] },\n): SelectControlDefinition<C> {\n return { type: SelectControlType, config }\n}\n","export type TextAreaControlData = string\n\nexport const TextAreaControlType = 'makeswift::controls::text-area'\n\ntype TextAreaControlConfig = {\n label?: string\n defaultValue?: string\n rows?: number\n}\n\nexport type TextAreaControlDefinition<C extends TextAreaControlConfig = TextAreaControlConfig> = {\n type: typeof TextAreaControlType\n config: C\n}\n\nexport function TextArea<C extends TextAreaControlConfig>(\n config: C = {} as C,\n): TextAreaControlDefinition<C> {\n return { type: TextAreaControlType, config }\n}\n","export type TextInputControlData = string\n\nexport const TextInputControlType = 'makeswift::controls::text-input'\n\ntype TextInputControlConfig = {\n label?: string\n defaultValue?: string\n}\n\nexport type TextInputControlDefinition<C extends TextInputControlConfig = TextInputControlConfig> =\n {\n type: typeof TextInputControlType\n config: C\n }\n\nexport function TextInput<C extends TextInputControlConfig>(\n config: C = {} as C,\n): TextInputControlDefinition<C> {\n return { type: TextInputControlType, config }\n}\n"],"names":[],"mappings":";AAEO,MAAM,sBAAsB;AAajC,kBAAA,SAAY,IACkB;AACvB,SAAA,EAAE,MAAM,qBAAqB;AACtC;AClBO,MAAM,8BAA8B;AAAA,EACzC,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,WAAW;AAAA,EACX,MAAM;AACR;AAKO,MAAM,4BAA4B;AA6BlC,iCACL,QACoC;AAC7B,SAAA,EAAE,MAAM,2BAA2B;AAC5C;AC5CO,MAAM,oBAAoB;AAkB/B,gBAAA,SAAY,IACgB;AACrB,SAAA,EAAE,MAAM,mBAAmB;AACpC;ACvBO,MAAM,oBAAoB;AAsB1B,gBACL,QAC4B;AACrB,SAAA,EAAE,MAAM,mBAAmB;AACpC;ACxBO,MAAM,sBAAsB;AAcjC,kBAAA,SAAY,IACkB;AACvB,SAAA,EAAE,MAAM,qBAAqB;AACtC;ACjBO,MAAM,uBAAuB;AAclC,mBAAA,SAAY,IACmB;AACxB,SAAA,EAAE,MAAM,sBAAsB;AACvC;;;;;;;;;;;;;;"}
@@ -2,10 +2,27 @@ const CheckboxControlType = "makeswift::controls::checkbox";
2
2
  function Checkbox(config = {}) {
3
3
  return { type: CheckboxControlType, config };
4
4
  }
5
+ const unstable_IconRadioGroupIcon = {
6
+ TextAlignCenter: "TextAlignCenter",
7
+ TextAlignJustify: "TextAlignJustify",
8
+ TextAlignLeft: "TextAlignLeft",
9
+ TextAlignRight: "TextAlignRight",
10
+ Superscript: "Superscript16",
11
+ Subscript: "Subscript16",
12
+ Code: "Code16"
13
+ };
14
+ const IconRadioGroupControlType = "makeswift::controls::icon-radio-group";
15
+ function unstable_IconRadioGroup(config) {
16
+ return { type: IconRadioGroupControlType, config };
17
+ }
5
18
  const NumberControlType = "makeswift::controls::number";
6
19
  function Number(config = {}) {
7
20
  return { type: NumberControlType, config };
8
21
  }
22
+ const SelectControlType = "makeswift::controls::select";
23
+ function Select(config) {
24
+ return { type: SelectControlType, config };
25
+ }
9
26
  const TextAreaControlType = "makeswift::controls::text-area";
10
27
  function TextArea(config = {}) {
11
28
  return { type: TextAreaControlType, config };
@@ -14,5 +31,5 @@ const TextInputControlType = "makeswift::controls::text-input";
14
31
  function TextInput(config = {}) {
15
32
  return { type: TextInputControlType, config };
16
33
  }
17
- export { CheckboxControlType as C, NumberControlType as N, TextAreaControlType as T, TextInputControlType as a, Checkbox as b, Number as c, TextArea as d, TextInput as e };
34
+ export { CheckboxControlType as C, IconRadioGroupControlType as I, NumberControlType as N, SelectControlType as S, TextAreaControlType as T, TextInputControlType as a, Checkbox as b, unstable_IconRadioGroup as c, Number as d, Select as e, TextArea as f, TextInput as g, unstable_IconRadioGroupIcon as u };
18
35
  //# sourceMappingURL=text-input.es.js.map