@makeswift/runtime 0.9.11 → 0.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Box.cjs.js +1 -1
- package/dist/Box.es.js +1 -1
- package/dist/Button.cjs.js +1 -1
- package/dist/Button.es.js +1 -1
- package/dist/Carousel.cjs.js +1 -1
- package/dist/Carousel.es.js +1 -1
- package/dist/Countdown.cjs.js +1 -1
- package/dist/Countdown.es.js +1 -1
- package/dist/Divider.cjs.js +1 -1
- package/dist/Divider.es.js +1 -1
- package/dist/Form.cjs.js +1 -1
- package/dist/Form.es.js +1 -1
- package/dist/Image.cjs.js +1 -1
- package/dist/Image.es.js +1 -1
- package/dist/LiveProvider.cjs.js +1 -1
- package/dist/LiveProvider.es.js +3 -3
- package/dist/Navigation.cjs.js +1 -1
- package/dist/Navigation.es.js +1 -1
- package/dist/PreviewProvider.cjs.js +1 -1
- package/dist/PreviewProvider.es.js +3 -3
- package/dist/ReadOnlyText.cjs.js +18 -3
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +20 -5
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/ReadOnlyTextV2.cjs.js +116 -240
- package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
- package/dist/ReadOnlyTextV2.es.js +115 -238
- package/dist/ReadOnlyTextV2.es.js.map +1 -1
- package/dist/Root.cjs.js +1 -1
- package/dist/Root.es.js +1 -1
- package/dist/SocialLinks.cjs.js +1 -1
- package/dist/SocialLinks.es.js +1 -1
- package/dist/Text.cjs.js +1 -1
- package/dist/Text.es.js +1 -1
- package/dist/components.cjs.js +1 -1
- package/dist/components.es.js +1 -1
- package/dist/control-serialization.es.js +1 -1
- package/dist/controls.cjs.js +28 -18
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +2 -2
- package/dist/index.cjs.js +39 -38
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs10.js +2 -2
- package/dist/index.cjs2.js +3 -3
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.cjs5.js +5 -6
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs6.js +20 -0
- package/dist/index.cjs6.js.map +1 -1
- package/dist/index.cjs8.js +1 -1
- package/dist/index.cjs9.js +27 -31
- package/dist/index.cjs9.js.map +1 -1
- package/dist/index.es.js +14 -14
- package/dist/index.es.js.map +1 -1
- package/dist/index.es10.js +4 -4
- package/dist/index.es2.js +2 -2
- package/dist/index.es3.js +1 -1
- package/dist/index.es5.js +1 -2
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +21 -2
- package/dist/index.es6.js.map +1 -1
- package/dist/index.es8.js +1 -1
- package/dist/index.es9.js +31 -35
- package/dist/index.es9.js.map +1 -1
- package/dist/next.cjs.js +1 -1
- package/dist/next.es.js +2 -2
- package/dist/react-page.cjs.js +310 -147
- package/dist/react-page.cjs.js.map +1 -1
- package/dist/react-page.es.js +297 -146
- package/dist/react-page.es.js.map +1 -1
- package/dist/react.cjs.js +1 -1
- package/dist/react.es.js +1 -1
- package/dist/slate.cjs.js +40 -27
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +49 -37
- package/dist/slate.es.js.map +1 -1
- package/dist/{typography.cjs.js → text-input.cjs.js} +1 -9
- package/dist/text-input.cjs.js.map +1 -0
- package/dist/{typography.es.js → text-input.es.js} +2 -8
- package/dist/text-input.es.js.map +1 -0
- package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -1
- package/dist/types/src/controls/list.d.ts +5 -2
- package/dist/types/src/controls/list.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/introspection.d.ts +5 -0
- package/dist/types/src/controls/rich-text/introspection.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text/introspection.test.d.ts +2 -0
- package/dist/types/src/controls/rich-text/introspection.test.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text-v2/introspection.d.ts +5 -0
- package/dist/types/src/controls/rich-text-v2/introspection.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text-v2/introspection.test.d.ts +2 -0
- package/dist/types/src/controls/rich-text-v2/introspection.test.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +15 -3
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text-v2/translation.d.ts +1 -1
- package/dist/types/src/controls/rich-text-v2/translation.d.ts.map +1 -1
- package/dist/types/src/controls/shape.d.ts +5 -2
- package/dist/types/src/controls/shape.d.ts.map +1 -1
- package/dist/types/src/controls/typography.d.ts +2 -0
- package/dist/types/src/controls/typography.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/descriptors.d.ts +10 -0
- package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/introspection.d.ts +0 -2
- package/dist/types/src/prop-controllers/introspection.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/useRemoteChanges.d.ts +4 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/useRemoteChanges.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts +7 -16
- package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
- package/dist/types/src/slate/LinkPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/LocalChangesPlugin/index.d.ts +16 -0
- package/dist/types/src/slate/LocalChangesPlugin/index.d.ts.map +1 -0
- package/dist/types/src/slate/TextAlignPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/index.d.ts +1 -0
- package/dist/types/src/slate/index.d.ts.map +1 -1
- package/dist/types/src/slate/types.d.ts +2 -2
- package/dist/types/src/slate/types.d.ts.map +1 -1
- package/dist/types.cjs2.js +67 -48
- package/dist/types.cjs2.js.map +1 -1
- package/dist/types.es2.js +64 -45
- package/dist/types.es2.js.map +1 -1
- package/package.json +1 -2
- package/dist/typography.cjs.js.map +0 -1
- package/dist/typography.es.js.map +0 -1
|
@@ -1,33 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __objRest = (source, exclude) => {
|
|
6
|
+
var target = {};
|
|
7
|
+
for (var prop in source)
|
|
8
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
9
|
+
target[prop] = source[prop];
|
|
10
|
+
if (source != null && __getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
12
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
13
|
+
target[prop] = source[prop];
|
|
14
|
+
}
|
|
15
|
+
return target;
|
|
16
|
+
};
|
|
2
17
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
var css = require("@emotion/css");
|
|
4
18
|
var React = require("react");
|
|
5
|
-
var next = require("./index.cjs.js");
|
|
6
19
|
var reactPage = require("./react-page.cjs.js");
|
|
7
|
-
require("./actions.cjs.js");
|
|
8
|
-
var index = require("./index.cjs3.js");
|
|
9
20
|
require("slate");
|
|
10
21
|
require("./state/breakpoints.cjs.js");
|
|
22
|
+
require("./actions.cjs.js");
|
|
11
23
|
require("./types.cjs2.js");
|
|
12
24
|
require("is-hotkey");
|
|
13
25
|
require("slate-react");
|
|
14
26
|
var jsxRuntime = require("react/jsx-runtime");
|
|
27
|
+
require("./index.cjs3.js");
|
|
28
|
+
require("@emotion/css");
|
|
29
|
+
require("uuid");
|
|
30
|
+
var next = require("./index.cjs.js");
|
|
31
|
+
require("redux");
|
|
32
|
+
require("redux-thunk");
|
|
33
|
+
require("@emotion/serialize");
|
|
34
|
+
require("@emotion/utils");
|
|
35
|
+
require("zod");
|
|
36
|
+
require("./text-input.cjs.js");
|
|
37
|
+
require("scroll-into-view-if-needed");
|
|
38
|
+
require("next/link");
|
|
15
39
|
require("use-sync-external-store/shim/with-selector");
|
|
16
40
|
require("next/dynamic");
|
|
17
|
-
require("./typography.cjs.js");
|
|
18
41
|
require("./combobox.cjs.js");
|
|
19
42
|
require("use-sync-external-store/shim");
|
|
20
|
-
require("redux");
|
|
21
|
-
require("redux-thunk");
|
|
22
43
|
require("./types.cjs.js");
|
|
23
44
|
require("./box-models.cjs.js");
|
|
24
45
|
require("css-box-model");
|
|
25
46
|
require("color");
|
|
26
|
-
require("scroll-into-view-if-needed");
|
|
27
47
|
require("react-dom");
|
|
28
48
|
require("html-react-parser");
|
|
29
49
|
require("next/head");
|
|
30
|
-
require("zod");
|
|
31
50
|
require("@emotion/server/create-instance");
|
|
32
51
|
require("next/document");
|
|
33
52
|
require("cors");
|
|
@@ -36,25 +55,20 @@ require("cookie");
|
|
|
36
55
|
require("http-proxy");
|
|
37
56
|
require("set-cookie-parser");
|
|
38
57
|
require("./constants.cjs.js");
|
|
39
|
-
require("uuid");
|
|
40
58
|
require("corporate-ipsum");
|
|
41
|
-
require("@emotion/serialize");
|
|
42
|
-
require("@emotion/utils");
|
|
43
|
-
require("next/link");
|
|
44
59
|
const ReadOnlyTextV2 = React.forwardRef(function ReadOnlyText({
|
|
45
60
|
text: {
|
|
46
61
|
descendants
|
|
47
62
|
},
|
|
48
|
-
|
|
63
|
+
definition
|
|
49
64
|
}, ref) {
|
|
50
65
|
var _a;
|
|
51
66
|
const descendantsAsString = getText(descendants);
|
|
52
|
-
const mode = (_a = control == null ? void 0 : control.descriptor.config.mode) != null ? _a : reactPage.RichTextV2Mode.Block;
|
|
53
67
|
return /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
54
68
|
ref,
|
|
55
69
|
children: descendantsAsString === "" ? /* @__PURE__ */ jsxRuntime.jsx(Placeholder, {}) : /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
plugins: (_a = definition == null ? void 0 : definition.config.plugins) != null ? _a : [],
|
|
71
|
+
descendants
|
|
58
72
|
})
|
|
59
73
|
});
|
|
60
74
|
});
|
|
@@ -73,199 +87,74 @@ function Placeholder({
|
|
|
73
87
|
children: text
|
|
74
88
|
});
|
|
75
89
|
}
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
90
|
+
function LeafComponent(_a) {
|
|
91
|
+
var _b = _a, {
|
|
92
|
+
plugins
|
|
93
|
+
} = _b, props = __objRest(_b, [
|
|
94
|
+
"plugins"
|
|
95
|
+
]);
|
|
96
|
+
function initialRenderLeaf({
|
|
97
|
+
leaf
|
|
98
|
+
}) {
|
|
99
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", {
|
|
100
|
+
className: leaf.className,
|
|
101
|
+
children: leaf.text === "" ? "\uFEFF" : leaf.text
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
const renderLeaf = plugins.reduce((renderFn, plugin) => (props2) => {
|
|
105
|
+
const {
|
|
106
|
+
control,
|
|
107
|
+
renderLeaf: renderLeaf2
|
|
108
|
+
} = plugin;
|
|
109
|
+
if ((control == null ? void 0 : control.definition) == null || renderLeaf2 == null)
|
|
110
|
+
return renderFn(props2);
|
|
111
|
+
if (control.getLeafValue == null)
|
|
112
|
+
return renderLeaf2(renderFn, void 0)(props2);
|
|
113
|
+
return /* @__PURE__ */ jsxRuntime.jsx(next.ControlValue, {
|
|
114
|
+
definition: control.definition,
|
|
115
|
+
data: control.getLeafValue(props2.leaf),
|
|
116
|
+
children: (value) => renderLeaf2(renderFn, value)(props2)
|
|
117
|
+
});
|
|
118
|
+
}, initialRenderLeaf);
|
|
119
|
+
return renderLeaf({
|
|
120
|
+
attributes: {},
|
|
121
|
+
leaf: props.leaf,
|
|
122
|
+
children: null,
|
|
123
|
+
text: props.leaf
|
|
84
124
|
});
|
|
85
125
|
}
|
|
86
|
-
function
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
98
|
-
descendants: descendant.children,
|
|
99
|
-
mode
|
|
100
|
-
})
|
|
101
|
-
});
|
|
102
|
-
case reactPage.InlineType.SuperScript:
|
|
103
|
-
return /* @__PURE__ */ jsxRuntime.jsx("sup", {
|
|
104
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
105
|
-
descendants: descendant.children,
|
|
106
|
-
mode
|
|
107
|
-
})
|
|
108
|
-
});
|
|
109
|
-
case reactPage.InlineType.SubScript:
|
|
110
|
-
return /* @__PURE__ */ jsxRuntime.jsx("sub", {
|
|
111
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
112
|
-
descendants: descendant.children,
|
|
113
|
-
mode
|
|
114
|
-
})
|
|
115
|
-
});
|
|
116
|
-
case reactPage.InlineType.Link:
|
|
117
|
-
return /* @__PURE__ */ jsxRuntime.jsx(index.Link, {
|
|
118
|
-
className: linkClassName,
|
|
119
|
-
link: (_a = descendant.link) != null ? _a : void 0,
|
|
120
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
121
|
-
descendants: descendant.children,
|
|
122
|
-
mode
|
|
123
|
-
})
|
|
124
|
-
});
|
|
126
|
+
function ElementComponent(_c) {
|
|
127
|
+
var _d = _c, {
|
|
128
|
+
plugins
|
|
129
|
+
} = _d, props = __objRest(_d, [
|
|
130
|
+
"plugins"
|
|
131
|
+
]);
|
|
132
|
+
function initialRenderElement(props2) {
|
|
133
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
134
|
+
descendants: props2.element.children,
|
|
135
|
+
plugins
|
|
136
|
+
});
|
|
125
137
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
listStyleType: "disc"
|
|
138
|
+
const renderElement = plugins.reduce((renderFn, plugin) => (props2) => {
|
|
139
|
+
const {
|
|
140
|
+
control,
|
|
141
|
+
renderElement: renderElement2
|
|
142
|
+
} = plugin;
|
|
143
|
+
if ((control == null ? void 0 : control.definition) == null || renderElement2 == null)
|
|
144
|
+
return renderFn(props2);
|
|
145
|
+
if (control.getElementValue == null)
|
|
146
|
+
return renderElement2(renderFn, void 0)(props2);
|
|
147
|
+
return /* @__PURE__ */ jsxRuntime.jsx(next.ControlValue, {
|
|
148
|
+
definition: control.definition,
|
|
149
|
+
data: control.getElementValue(props2.element),
|
|
150
|
+
children: (value) => renderElement2(renderFn, value)(props2)
|
|
151
|
+
});
|
|
152
|
+
}, initialRenderElement);
|
|
153
|
+
return renderElement({
|
|
154
|
+
attributes: {},
|
|
155
|
+
children: null,
|
|
156
|
+
element: props.descendant
|
|
146
157
|
});
|
|
147
|
-
switch (descendant.type) {
|
|
148
|
-
case reactPage.BlockType.Text:
|
|
149
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", {
|
|
150
|
-
className: css.cx(...blockStyles),
|
|
151
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
152
|
-
descendants: descendant.children,
|
|
153
|
-
mode
|
|
154
|
-
})
|
|
155
|
-
});
|
|
156
|
-
case reactPage.BlockType.Paragraph:
|
|
157
|
-
return /* @__PURE__ */ jsxRuntime.jsx("p", {
|
|
158
|
-
className: css.cx(...blockStyles),
|
|
159
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
160
|
-
descendants: descendant.children,
|
|
161
|
-
mode
|
|
162
|
-
})
|
|
163
|
-
});
|
|
164
|
-
case reactPage.BlockType.Heading1:
|
|
165
|
-
return /* @__PURE__ */ jsxRuntime.jsx("h1", {
|
|
166
|
-
className: css.cx(...blockStyles),
|
|
167
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
168
|
-
descendants: descendant.children,
|
|
169
|
-
mode
|
|
170
|
-
})
|
|
171
|
-
});
|
|
172
|
-
case reactPage.BlockType.Heading2:
|
|
173
|
-
return /* @__PURE__ */ jsxRuntime.jsx("h2", {
|
|
174
|
-
className: css.cx(...blockStyles),
|
|
175
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
176
|
-
descendants: descendant.children,
|
|
177
|
-
mode
|
|
178
|
-
})
|
|
179
|
-
});
|
|
180
|
-
case reactPage.BlockType.Heading3:
|
|
181
|
-
return /* @__PURE__ */ jsxRuntime.jsx("h3", {
|
|
182
|
-
className: css.cx(...blockStyles),
|
|
183
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
184
|
-
descendants: descendant.children,
|
|
185
|
-
mode
|
|
186
|
-
})
|
|
187
|
-
});
|
|
188
|
-
case reactPage.BlockType.Heading4:
|
|
189
|
-
return /* @__PURE__ */ jsxRuntime.jsx("h4", {
|
|
190
|
-
className: css.cx(...blockStyles),
|
|
191
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
192
|
-
descendants: descendant.children,
|
|
193
|
-
mode
|
|
194
|
-
})
|
|
195
|
-
});
|
|
196
|
-
case reactPage.BlockType.Heading5:
|
|
197
|
-
return /* @__PURE__ */ jsxRuntime.jsx("h5", {
|
|
198
|
-
className: css.cx(...blockStyles),
|
|
199
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
200
|
-
descendants: descendant.children,
|
|
201
|
-
mode
|
|
202
|
-
})
|
|
203
|
-
});
|
|
204
|
-
case reactPage.BlockType.Heading6:
|
|
205
|
-
return /* @__PURE__ */ jsxRuntime.jsx("h6", {
|
|
206
|
-
className: css.cx(...blockStyles),
|
|
207
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
208
|
-
descendants: descendant.children,
|
|
209
|
-
mode
|
|
210
|
-
})
|
|
211
|
-
});
|
|
212
|
-
case reactPage.BlockType.BlockQuote:
|
|
213
|
-
return /* @__PURE__ */ jsxRuntime.jsx("blockquote", {
|
|
214
|
-
className: css.cx(...blockStyles, quoteStyle),
|
|
215
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
216
|
-
descendants: descendant.children,
|
|
217
|
-
mode
|
|
218
|
-
})
|
|
219
|
-
});
|
|
220
|
-
case reactPage.BlockType.OrderedList:
|
|
221
|
-
return /* @__PURE__ */ jsxRuntime.jsx("ol", {
|
|
222
|
-
className: css.cx(...blockStyles, listStyles),
|
|
223
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
224
|
-
descendants: descendant.children,
|
|
225
|
-
mode
|
|
226
|
-
})
|
|
227
|
-
});
|
|
228
|
-
case reactPage.BlockType.UnorderedList:
|
|
229
|
-
return /* @__PURE__ */ jsxRuntime.jsx("ul", {
|
|
230
|
-
className: css.cx(...blockStyles, listStyles),
|
|
231
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
232
|
-
descendants: descendant.children,
|
|
233
|
-
mode
|
|
234
|
-
})
|
|
235
|
-
});
|
|
236
|
-
case reactPage.BlockType.ListItem:
|
|
237
|
-
return /* @__PURE__ */ jsxRuntime.jsx("li", {
|
|
238
|
-
className: css.cx(...blockStyles),
|
|
239
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
240
|
-
descendants: descendant.children,
|
|
241
|
-
mode
|
|
242
|
-
})
|
|
243
|
-
});
|
|
244
|
-
case reactPage.BlockType.ListItemChild:
|
|
245
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", {
|
|
246
|
-
className: css.cx(...blockStyles),
|
|
247
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
248
|
-
descendants: descendant.children,
|
|
249
|
-
mode
|
|
250
|
-
})
|
|
251
|
-
});
|
|
252
|
-
default:
|
|
253
|
-
if (mode === reactPage.RichTextV2Mode.Inline)
|
|
254
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", {
|
|
255
|
-
className: css.cx(...blockStyles),
|
|
256
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
257
|
-
descendants: descendant.children,
|
|
258
|
-
mode
|
|
259
|
-
})
|
|
260
|
-
});
|
|
261
|
-
return /* @__PURE__ */ jsxRuntime.jsx("p", {
|
|
262
|
-
className: css.cx(...blockStyles),
|
|
263
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
264
|
-
descendants: descendant.children,
|
|
265
|
-
mode
|
|
266
|
-
})
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
158
|
}
|
|
270
159
|
function isText(node) {
|
|
271
160
|
if (typeof node === "object" && "text" in node)
|
|
@@ -274,41 +163,20 @@ function isText(node) {
|
|
|
274
163
|
}
|
|
275
164
|
function Descendants({
|
|
276
165
|
descendants,
|
|
277
|
-
|
|
166
|
+
plugins
|
|
278
167
|
}) {
|
|
279
168
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
280
|
-
children: descendants.map((descendant,
|
|
169
|
+
children: descendants.map((descendant, index) => {
|
|
281
170
|
if (isText(descendant)) {
|
|
282
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
switch (descendant.type) {
|
|
287
|
-
case reactPage.InlineType.Link:
|
|
288
|
-
case reactPage.InlineType.Code:
|
|
289
|
-
case reactPage.InlineType.SubScript:
|
|
290
|
-
case reactPage.InlineType.SuperScript:
|
|
291
|
-
return /* @__PURE__ */ jsxRuntime.jsx(InlineElement, {
|
|
292
|
-
descendant,
|
|
293
|
-
mode
|
|
294
|
-
}, index2);
|
|
295
|
-
case reactPage.BlockType.Heading1:
|
|
296
|
-
case reactPage.BlockType.Heading2:
|
|
297
|
-
case reactPage.BlockType.Heading3:
|
|
298
|
-
case reactPage.BlockType.BlockQuote:
|
|
299
|
-
case reactPage.BlockType.Text:
|
|
300
|
-
case reactPage.BlockType.Paragraph:
|
|
301
|
-
case reactPage.BlockType.OrderedList:
|
|
302
|
-
case reactPage.BlockType.UnorderedList:
|
|
303
|
-
case reactPage.BlockType.ListItem:
|
|
304
|
-
case reactPage.BlockType.ListItemChild:
|
|
305
|
-
return /* @__PURE__ */ jsxRuntime.jsx(BlockElement, {
|
|
306
|
-
descendant,
|
|
307
|
-
mode
|
|
308
|
-
}, index2);
|
|
309
|
-
default:
|
|
310
|
-
return null;
|
|
171
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LeafComponent, {
|
|
172
|
+
plugins,
|
|
173
|
+
leaf: descendant
|
|
174
|
+
}, index);
|
|
311
175
|
}
|
|
176
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ElementComponent, {
|
|
177
|
+
descendant,
|
|
178
|
+
plugins
|
|
179
|
+
}, index);
|
|
312
180
|
})
|
|
313
181
|
});
|
|
314
182
|
}
|
|
@@ -319,13 +187,17 @@ function isBlock(descendant) {
|
|
|
319
187
|
case reactPage.BlockType.Heading1:
|
|
320
188
|
case reactPage.BlockType.Heading2:
|
|
321
189
|
case reactPage.BlockType.Heading3:
|
|
190
|
+
case reactPage.BlockType.Heading4:
|
|
191
|
+
case reactPage.BlockType.Heading5:
|
|
192
|
+
case reactPage.BlockType.Heading6:
|
|
322
193
|
case reactPage.BlockType.BlockQuote:
|
|
323
194
|
case reactPage.BlockType.Paragraph:
|
|
195
|
+
case reactPage.BlockType.Default:
|
|
196
|
+
case reactPage.BlockType.Text:
|
|
324
197
|
case reactPage.BlockType.OrderedList:
|
|
325
198
|
case reactPage.BlockType.UnorderedList:
|
|
326
199
|
case reactPage.BlockType.ListItem:
|
|
327
200
|
case reactPage.BlockType.ListItemChild:
|
|
328
|
-
case reactPage.BlockType.Text:
|
|
329
201
|
return true;
|
|
330
202
|
default:
|
|
331
203
|
return false;
|
|
@@ -345,8 +217,13 @@ function getTextByDescendant(descendant) {
|
|
|
345
217
|
case reactPage.BlockType.Heading1:
|
|
346
218
|
case reactPage.BlockType.Heading2:
|
|
347
219
|
case reactPage.BlockType.Heading3:
|
|
220
|
+
case reactPage.BlockType.Heading4:
|
|
221
|
+
case reactPage.BlockType.Heading5:
|
|
222
|
+
case reactPage.BlockType.Heading6:
|
|
348
223
|
case reactPage.BlockType.BlockQuote:
|
|
349
224
|
case reactPage.BlockType.Paragraph:
|
|
225
|
+
case reactPage.BlockType.Default:
|
|
226
|
+
case reactPage.BlockType.Text:
|
|
350
227
|
case reactPage.BlockType.OrderedList:
|
|
351
228
|
case reactPage.BlockType.UnorderedList:
|
|
352
229
|
case reactPage.BlockType.ListItem:
|
|
@@ -359,7 +236,6 @@ function getTextByDescendant(descendant) {
|
|
|
359
236
|
function getText(descendant) {
|
|
360
237
|
return descendant.map(getTextByDescendant).join("\n");
|
|
361
238
|
}
|
|
362
|
-
exports.
|
|
363
|
-
exports.TextElement = TextElement;
|
|
239
|
+
exports.LeafComponent = LeafComponent;
|
|
364
240
|
exports["default"] = ReadOnlyTextV2;
|
|
365
241
|
//# sourceMappingURL=ReadOnlyTextV2.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadOnlyTextV2.cjs.js","sources":["../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { useResponsiveStyle } from '../../../../components/utils/responsive-style'\nimport { RichTextV2Control, RichTextV2ControlData, RichTextV2Mode } from '../../../../controls'\nimport { useStyle } from '../../use-style'\nimport { Descendant, Text } from 'slate'\nimport { Link } from '../../../../components/shared/Link'\nimport { Inline, InlineType, Block, BlockType } from '../../../../slate'\nimport useEnhancedTypography, { useTypographyClassName } from '../typography'\n\ntype Props = {\n text: RichTextV2ControlData\n control: RichTextV2Control | null\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text: { descendants }, control }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = getText(descendants)\n\n const mode = control?.descriptor.config.mode ?? RichTextV2Mode.Block\n\n return (\n <div ref={ref}>\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants descendants={descendants} mode={mode} />\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\nexport interface TextProps {\n descendant: Text\n}\n\nexport function TextElement({ descendant }: TextProps) {\n const enhancedTypography = useEnhancedTypography(descendant.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return (\n <span className={typographyClassName}>\n {descendant.text === '' ? '\\uFEFF' : descendant.text}\n </span>\n )\n}\n\nexport interface InlineProps {\n descendant: Inline\n mode: RichTextV2Mode\n}\n\nfunction InlineElement({ descendant, mode }: InlineProps) {\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (descendant.type) {\n case InlineType.Code:\n return (\n <code>\n <Descendants descendants={descendant.children} mode={mode} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} mode={mode} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} mode={mode} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link ?? undefined}>\n <Descendants descendants={descendant.children} mode={mode} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n mode: RichTextV2Mode\n}\n\nexport function BlockElement({ descendant, mode }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n const quoteStyle = useStyle({\n padding: '0.5em 10px',\n fontSize: '1.25em',\n fontWeight: '300',\n borderLeft: '5px solid rgba(0, 0, 0, 0.1)',\n })\n\n const listStyles = useStyle({\n listStylePosition: 'inside',\n paddingInlineStart: '20px',\n listStyleType: 'disc',\n })\n\n switch (descendant.type) {\n case BlockType.Text:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </span>\n )\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles, listStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles, listStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </span>\n )\n default:\n if (mode === RichTextV2Mode.Inline)\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </span>\n )\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </p>\n )\n }\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: any): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({ descendants, mode }: { descendants: Descendant[]; mode: RichTextV2Mode }) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <TextElement key={index} descendant={descendant} />\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return <InlineElement key={index} descendant={descendant} mode={mode} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Text:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} mode={mode} />\n default:\n return null\n }\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.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n case BlockType.Text:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if (isText(descendant)) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\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))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"names":["ReadOnlyTextV2","forwardRef","text","descendants","control","ref","descendantsAsString","getText","mode","descriptor","config","RichTextV2Mode","Block","_jsx","useStyle","display","width","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","undefined","blockStyles","margin","useResponsiveStyle","textAlign","quoteStyle","padding","fontSize","fontWeight","borderLeft","listStyles","listStylePosition","paddingInlineStart","listStyleType","BlockType","Text","cx","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","UnorderedList","ListItem","ListItemChild","Inline","node","_Fragment","map","index","isText","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeMA,M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,gBAAAA,oBAAoBnD,WAAD,CADxC,EAEGoD,KAAKpD,WAAWW,SAAS0C,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAAtD,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAAkC;AAC1CA,SAAAA,WAAWgD,IAAIG,mBAAf,EAAoCC,KAAK,IAAzC;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 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)\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.Text:\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): string {\n if (isText(descendant)) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\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.Text:\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))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"names":["ReadOnlyTextV2","forwardRef","text","descendants","definition","ref","descendantsAsString","getText","_jsx","config","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","Text","OrderedList","UnorderedList","ListItem","ListItemChild","InlineType","Link","Code","SubScript","SuperScript","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBMA,MAAAA,iBAA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