@makeswift/runtime 0.28.10-canary.10 → 0.28.10-canary.11
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/cjs/api/graphql-api-client.js +1 -1
- package/dist/cjs/api/rest-api-client.js +1 -1
- package/dist/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/controls/index.js.map +1 -1
- package/dist/cjs/controls/rich-text-v2/rich-text-v2.js +1 -1
- package/dist/cjs/controls/rich-text-v2/rich-text-v2.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text/ReadOnlyText.js +1 -0
- package/dist/cjs/runtimes/react/controls/rich-text/ReadOnlyText.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.js +12 -14
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/index.js +2 -12
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/index.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.js +10 -3
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.js +2 -2
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.js +4 -4
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.js +15 -15
- package/dist/cjs/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/index.js +9 -3
- package/dist/cjs/runtimes/react/controls/rich-text-v2/index.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/render-rich-text-v2.js +46 -0
- package/dist/cjs/runtimes/react/controls/rich-text-v2/render-rich-text-v2.js.map +1 -0
- package/dist/cjs/runtimes/react/controls/rich-text-v2/{rich-text-v2.js → rich-text-v2-value.js} +10 -14
- package/dist/cjs/runtimes/react/controls/rich-text-v2/rich-text-v2-value.js.map +1 -0
- package/dist/esm/api/graphql-api-client.js +1 -1
- package/dist/esm/api/rest-api-client.js +1 -1
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/controls/index.js.map +1 -1
- package/dist/esm/controls/rich-text-v2/rich-text-v2.js +1 -1
- package/dist/esm/controls/rich-text-v2/rich-text-v2.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text/ReadOnlyText.js +1 -0
- package/dist/esm/runtimes/react/controls/rich-text/ReadOnlyText.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.js +11 -13
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/index.js +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/index.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.js +10 -3
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.js +2 -2
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.js +4 -4
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.js +19 -17
- package/dist/esm/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/index.js +4 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/index.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/render-rich-text-v2.js +12 -0
- package/dist/esm/runtimes/react/controls/rich-text-v2/render-rich-text-v2.js.map +1 -0
- package/dist/esm/runtimes/react/controls/rich-text-v2/rich-text-v2-value.js +17 -0
- package/dist/esm/runtimes/react/controls/rich-text-v2/rich-text-v2-value.js.map +1 -0
- package/dist/types/controls/index.d.ts +1 -1
- package/dist/types/controls/index.d.ts.map +1 -1
- package/dist/types/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text/ReadOnlyText.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts +4 -8
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/index.d.ts +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/index.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts +1 -3
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts +1 -3
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.d.ts +2 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts +5 -5
- package/dist/types/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/index.d.ts +7 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/index.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/render-rich-text-v2.d.ts +5 -0
- package/dist/types/runtimes/react/controls/rich-text-v2/render-rich-text-v2.d.ts.map +1 -0
- package/dist/types/runtimes/react/controls/rich-text-v2/rich-text-v2-value.d.ts +8 -0
- package/dist/types/runtimes/react/controls/rich-text-v2/rich-text-v2-value.d.ts.map +1 -0
- package/package.json +3 -3
- package/dist/cjs/runtimes/react/controls/rich-text-v2/rich-text-v2.js.map +0 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/rich-text-v2.js +0 -23
- package/dist/esm/runtimes/react/controls/rich-text-v2/rich-text-v2.js.map +0 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/rich-text-v2.d.ts +0 -9
- package/dist/types/runtimes/react/controls/rich-text-v2/rich-text-v2.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text-v2/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text-v2/index.ts"],"sourcesContent":["import { type ReactNode } from 'react'\n\nimport { RichTextV2Definition } from '../../../../controls/rich-text-v2'\n\nexport type RichTextV2ControlValue = ReactNode\nexport type Descriptors = { text?: RichTextV2Definition }\n\nexport { renderRichTextV2 } from './render-rich-text-v2'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,iCAAiC;","names":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var render_rich_text_v2_exports = {};
|
|
30
|
+
__export(render_rich_text_v2_exports, {
|
|
31
|
+
renderRichTextV2: () => renderRichTextV2
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(render_rich_text_v2_exports);
|
|
34
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
var import_rich_text_v2 = require("../../../../controls/rich-text-v2");
|
|
37
|
+
var import_rich_text_v2_value = require("./rich-text-v2-value");
|
|
38
|
+
const ReadOnlyTextV1 = (0, import_react.lazy)(() => Promise.resolve().then(() => __toESM(require("../rich-text/ReadOnlyText"))));
|
|
39
|
+
function renderRichTextV2(data, config, control) {
|
|
40
|
+
return import_rich_text_v2.RichTextV2Definition.isV1Data(data) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReadOnlyTextV1, { text: data }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_rich_text_v2_value.RichTextV2Value, { data, config, control });
|
|
41
|
+
}
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
renderRichTextV2
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=render-rich-text-v2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text-v2/render-rich-text-v2.tsx"],"sourcesContent":["import { type ReactNode, lazy } from 'react'\n\nimport { type DataType, type ConfigType } from '@makeswift/controls'\n\nimport { RichTextV2Control, RichTextV2Definition } from '../../../../controls/rich-text-v2'\n\nimport { RichTextV2Value } from './rich-text-v2-value'\n\nconst ReadOnlyTextV1 = lazy(() => import('../rich-text/ReadOnlyText'))\n\nexport function renderRichTextV2(\n data: DataType<RichTextV2Definition> | undefined,\n config: ConfigType<RichTextV2Definition>,\n control: RichTextV2Control | null,\n): ReactNode {\n return RichTextV2Definition.isV1Data(data) ? (\n <ReadOnlyTextV1 text={data} />\n ) : (\n <RichTextV2Value data={data} config={config} control={control} />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBI;AAhBJ,mBAAqC;AAIrC,0BAAwD;AAExD,gCAAgC;AAEhC,MAAM,qBAAiB,mBAAK,MAAM,6CAAO,2BAA2B,GAAC;AAE9D,SAAS,iBACd,MACA,QACA,SACW;AACX,SAAO,yCAAqB,SAAS,IAAI,IACvC,4CAAC,kBAAe,MAAM,MAAM,IAE5B,4CAAC,6CAAgB,MAAY,QAAgB,SAAkB;AAEnE;","names":[]}
|
package/dist/cjs/runtimes/react/controls/rich-text-v2/{rich-text-v2.js → rich-text-v2-value.js}
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
"use client";
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -26,30 +27,25 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
27
|
mod
|
|
27
28
|
));
|
|
28
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
31
|
-
|
|
30
|
+
var rich_text_v2_value_exports = {};
|
|
31
|
+
__export(rich_text_v2_value_exports, {
|
|
32
|
+
RichTextV2Value: () => RichTextV2Value
|
|
32
33
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
34
|
+
module.exports = __toCommonJS(rich_text_v2_value_exports);
|
|
34
35
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
36
|
var import_react = require("react");
|
|
36
|
-
var import_rich_text_v2 = require("../../../../controls/rich-text-v2");
|
|
37
37
|
var import_use_is_read_only = require("../../hooks/use-is-read-only");
|
|
38
38
|
const EditableText = (0, import_react.lazy)(() => Promise.resolve().then(() => __toESM(require("./EditableTextV2"))));
|
|
39
39
|
const ReadOnlyText = (0, import_react.lazy)(() => Promise.resolve().then(() => __toESM(require("./ReadOnlyTextV2"))));
|
|
40
|
-
|
|
41
|
-
function renderRichTextV2(data, definition, control) {
|
|
42
|
-
return import_rich_text_v2.RichTextV2Definition.isV1Data(data) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReadOnlyTextV1, { text: data }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RichTextV2, { data, definition, control });
|
|
43
|
-
}
|
|
44
|
-
function RichTextV2({
|
|
40
|
+
function RichTextV2Value({
|
|
45
41
|
data,
|
|
46
|
-
|
|
42
|
+
config,
|
|
47
43
|
control
|
|
48
44
|
}) {
|
|
49
|
-
return (0, import_use_is_read_only.useIsReadOnly)() ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReadOnlyText, { text: data,
|
|
45
|
+
return (0, import_use_is_read_only.useIsReadOnly)() ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReadOnlyText, { text: data, config }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EditableText, { text: data, config, control });
|
|
50
46
|
}
|
|
51
47
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
48
|
0 && (module.exports = {
|
|
53
|
-
|
|
49
|
+
RichTextV2Value
|
|
54
50
|
});
|
|
55
|
-
//# sourceMappingURL=rich-text-v2.js.map
|
|
51
|
+
//# sourceMappingURL=rich-text-v2-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text-v2/rich-text-v2-value.tsx"],"sourcesContent":["'use client'\n\nimport { lazy } from 'react'\n\nimport { type ConfigType } from '@makeswift/controls'\n\nimport {\n type RichTextDataV2,\n RichTextV2Definition,\n RichTextV2Control,\n} from '../../../../controls/rich-text-v2'\n\nimport { useIsReadOnly } from '../../hooks/use-is-read-only'\n\nconst EditableText = lazy(() => import('./EditableTextV2'))\nconst ReadOnlyText = lazy(() => import('./ReadOnlyTextV2'))\n\nexport function RichTextV2Value({\n data,\n config,\n control,\n}: {\n data: RichTextDataV2 | undefined\n config: ConfigType<RichTextV2Definition>\n control: RichTextV2Control | null\n}) {\n return useIsReadOnly() ? (\n <ReadOnlyText text={data} config={config} />\n ) : (\n <EditableText text={data} config={config} control={control} />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BI;AAzBJ,mBAAqB;AAUrB,8BAA8B;AAE9B,MAAM,mBAAe,mBAAK,MAAM,6CAAO,kBAAkB,GAAC;AAC1D,MAAM,mBAAe,mBAAK,MAAM,6CAAO,kBAAkB,GAAC;AAEnD,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,aAAO,uCAAc,IACnB,4CAAC,gBAAa,MAAM,MAAM,QAAgB,IAE1C,4CAAC,gBAAa,MAAM,MAAM,QAAgB,SAAkB;AAEhE;","names":[]}
|
|
@@ -4,7 +4,7 @@ class MakeswiftGraphQLApiClient {
|
|
|
4
4
|
graphqlClient;
|
|
5
5
|
constructor({ endpoint }) {
|
|
6
6
|
this.graphqlClient = new GraphQLClient(endpoint, {
|
|
7
|
-
"makeswift-runtime-version": "0.28.10-canary.
|
|
7
|
+
"makeswift-runtime-version": "0.28.10-canary.11"
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
10
|
async getUnversionedResources({
|
|
@@ -163,7 +163,7 @@ class MakeswiftRestAPIClient {
|
|
|
163
163
|
const requestHeaders = new Headers({
|
|
164
164
|
"x-api-key": this.apiKey,
|
|
165
165
|
"makeswift-site-api-key": this.apiKey,
|
|
166
|
-
"makeswift-runtime-version": "0.28.10-canary.
|
|
166
|
+
"makeswift-runtime-version": "0.28.10-canary.11"
|
|
167
167
|
});
|
|
168
168
|
if (siteVersion?.token) {
|
|
169
169
|
requestUrl.searchParams.set("version", siteVersion.version);
|
|
@@ -8,7 +8,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
|
|
|
8
8
|
return ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
|
|
9
9
|
}
|
|
10
10
|
return ApiResponse.json({
|
|
11
|
-
version: "0.28.10-canary.
|
|
11
|
+
version: "0.28.10-canary.11",
|
|
12
12
|
interactionMode: true,
|
|
13
13
|
clientSideNavigation: false,
|
|
14
14
|
elementFromPoint: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/controls/index.ts"],"sourcesContent":["export * from './control'\n\nexport {\n ControlDefinition,\n ControlDefinitionVisitor,\n Checkbox,\n CheckboxDefinition,\n Code,\n CodeDefinition,\n Color,\n ColorDefinition,\n Combobox,\n ComboboxDefinition,\n isDependsOnConfig,\n isProvidesConfig,\n isContextValue,\n unstable_ContextValue,\n type ProvidesConfig,\n type DependsOnConfig,\n type AnyContextValue,\n type ContextValueDependencies,\n type ContextValues,\n Font,\n FontDefinition,\n unstable_Gallery,\n unstable_GalleryDefinition,\n type GalleryOption,\n type GalleryPage,\n Group,\n GroupDefinition,\n GroupControl,\n IconRadioGroup,\n IconRadioGroupDefinition,\n type IconRadioGroupIcon,\n Image,\n ImageDefinition,\n List,\n ListDefinition,\n ListControl,\n Number,\n NumberDefinition,\n Select,\n SelectDefinition,\n Shape,\n ShapeDefinition,\n ShapeControl,\n Slider,\n SliderDefinition,\n Style,\n StyleDefinition,\n type StyleProperty,\n StyleControl,\n TextInput,\n TextInputDefinition,\n TextArea,\n TextAreaDefinition,\n unstable_Typography,\n unstable_TypographyDefinition,\n} from '@makeswift/controls'\n\nexport { Link, LinkDefinition } from './link'\nexport { RichTextV1Definition, RichTextV1Control } from './rich-text'\nexport { RichText, RichTextV2Definition, RichTextV2Control } from './rich-text-v2'\nexport { Slot, SlotDefinition, SlotControl } from './slot'\nexport { unstable_StyleV2, StyleV2Definition, StyleV2Control } from './style-v2/style-v2'\n"],"mappings":"AAAA,cAAc;AAEd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/controls/index.ts"],"sourcesContent":["export * from './control'\n\nexport {\n ControlDefinition,\n ControlDefinitionVisitor,\n Checkbox,\n CheckboxDefinition,\n Code,\n CodeDefinition,\n Color,\n ColorDefinition,\n Combobox,\n ComboboxDefinition,\n isDependsOnConfig,\n isProvidesConfig,\n isContextValue,\n unstable_ContextValue,\n type ProvidesConfig,\n type DependsOnConfig,\n type AnyContextValue,\n type ContextValueDependencies,\n type ContextValues,\n type ContextValue,\n Font,\n FontDefinition,\n unstable_Gallery,\n unstable_GalleryDefinition,\n type GalleryOption,\n type GalleryPage,\n Group,\n GroupDefinition,\n GroupControl,\n IconRadioGroup,\n IconRadioGroupDefinition,\n type IconRadioGroupIcon,\n Image,\n ImageDefinition,\n List,\n ListDefinition,\n ListControl,\n Number,\n NumberDefinition,\n Select,\n SelectDefinition,\n Shape,\n ShapeDefinition,\n ShapeControl,\n Slider,\n SliderDefinition,\n Style,\n StyleDefinition,\n type StyleProperty,\n StyleControl,\n TextInput,\n TextInputDefinition,\n TextArea,\n TextAreaDefinition,\n unstable_Typography,\n unstable_TypographyDefinition,\n} from '@makeswift/controls'\n\nexport { Link, LinkDefinition } from './link'\nexport { RichTextV1Definition, RichTextV1Control } from './rich-text'\nexport { RichText, RichTextV2Definition, RichTextV2Control } from './rich-text-v2'\nexport { Slot, SlotDefinition, SlotControl } from './slot'\nexport { unstable_StyleV2, StyleV2Definition, StyleV2Control } from './style-v2/style-v2'\n"],"mappings":"AAAA,cAAc;AAEd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAOA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,MAAM,sBAAsB;AACrC,SAAS,sBAAsB,yBAAyB;AACxD,SAAS,UAAU,sBAAsB,yBAAyB;AAClE,SAAS,MAAM,gBAAgB,mBAAmB;AAClD,SAAS,kBAAkB,mBAAmB,sBAAsB;","names":[]}
|
|
@@ -72,7 +72,7 @@ class Definition extends BaseRichTextDefinition {
|
|
|
72
72
|
resolveValue(data, _resolver, _stylesheet, control) {
|
|
73
73
|
const stableValue = StableValue({
|
|
74
74
|
name: Definition.type,
|
|
75
|
-
read: () => renderRichTextV2(data, this, control ?? null)
|
|
75
|
+
read: () => renderRichTextV2(data, this.config, control ?? null)
|
|
76
76
|
});
|
|
77
77
|
return {
|
|
78
78
|
...stableValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/controls/rich-text-v2/rich-text-v2.ts"],"sourcesContent":["import { ReactNode } from 'react'\nimport { z } from 'zod'\n// @ts-expect-error: there are no types for 'corporate-ipsum'\nimport ipsum from 'corporate-ipsum'\n\nimport {\n RichTextDefinition as BaseRichTextDefinition,\n isNotNil,\n ControlDefinition,\n SerializationSchema,\n StableValue,\n type Data,\n type Resolvable,\n type ControlInstanceArgs,\n type DeserializedRecord,\n type SchemaType,\n type SchemaTypeAny,\n type RichTextPluginControl,\n type ResourceResolver,\n type Stylesheet,\n type RichTextMode,\n} from '@makeswift/controls'\n\nimport { LinkPlugin } from '../../slate/LinkPlugin'\nimport { InlinePlugin } from '../../slate/InlinePlugin'\nimport { TextAlignPlugin } from '../../slate/TextAlignPlugin'\nimport { BlockPlugin } from '../../slate/BlockPlugin'\nimport { TypographyPlugin } from '../../slate/TypographyPlugin'\nimport { InlineModePlugin } from '../../slate/InlineModePlugin'\nimport { toText } from '../../slate/utils'\n\nimport { renderRichTextV2 } from '../../runtimes/react/controls/rich-text-v2'\n\nimport { RichTextV2Plugin, Plugin } from './plugin'\nimport { RichTextV2Control } from './control'\nimport { getTranslatableData } from './translations/get-translations'\n\ntype DataType = z.infer<typeof Definition.schema.data>\ntype DataV2Type = z.infer<typeof Definition.schema.dataV2>\ntype InstanceType = RichTextV2Control\ntype UserConfig = z.infer<typeof Definition.schema.userConfig>\ntype Config = UserConfig & {\n defaultValue: string\n plugins: RichTextV2Plugin[]\n}\n\nclass Definition extends BaseRichTextDefinition<ReactNode, Config, InstanceType> {\n constructor({ mode, defaultValue }: UserConfig, plugins?: RichTextV2Plugin[]) {\n super({\n mode,\n defaultValue:\n defaultValue ??\n (mode === Definition.Mode.Inline ? 'Edit this text' : Definition.generateParagraph()),\n plugins:\n plugins ??\n (mode === Definition.Mode.Inline\n ? [InlineModePlugin()]\n : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]),\n })\n }\n\n static generateParagraph(): string {\n return ipsum(3)\n }\n\n static deserialize(\n data: DeserializedRecord,\n deserializeCallback: (r: DeserializedRecord) => ControlDefinition,\n ): RichTextV2Definition {\n if (data.type !== Definition.type) {\n throw new Error(`RichText: expected type ${Definition.type}, got ${data.type}`)\n }\n\n const { config } = Definition.fullSchema({\n pluginDef: SerializationSchema.deserializedRecord,\n }).definition.parse(data)\n\n const { plugins, ...userConfig } = config\n\n return new RichTextV2Definition(\n userConfig,\n plugins.map(({ control }) =>\n control ? { control: { definition: deserializeCallback(control?.definition) } } : {},\n ),\n )\n }\n\n static fullSchema<S extends SchemaTypeAny>({ pluginDef }: { pluginDef: S }) {\n const baseSchema = super.schema\n const plugin = z.object({\n control: z\n .object({\n definition: pluginDef,\n })\n .optional(),\n })\n\n const config = baseSchema.userConfig.extend({\n defaultValue: z.string(),\n plugins: z.array(plugin),\n })\n\n return {\n ...baseSchema,\n config,\n definition: z.object({\n type: baseSchema.type,\n config,\n }),\n }\n }\n\n get configSchema(): SchemaType<Config> {\n return Definition.fullSchema({ pluginDef: z.any() as SchemaType<ControlDefinition> }).config\n }\n\n createInstance(args: ControlInstanceArgs) {\n return new RichTextV2Control(this, args)\n }\n\n resolveValue(\n data: DataType | undefined,\n _resolver: ResourceResolver,\n _stylesheet: Stylesheet,\n control?: InstanceType,\n ): Resolvable<ReactNode | undefined> {\n const stableValue = StableValue({\n name: Definition.type,\n read: () => renderRichTextV2(data, this, control ?? null),\n })\n\n return {\n ...stableValue,\n triggerResolve: async () => {},\n }\n }\n\n getTranslatableData(data: DataType | undefined): Data {\n if (data == null) return null\n return getTranslatableData(Definition.dataToNodes(data), this.config.plugins)\n }\n\n get pluginControls(): RichTextPluginControl[] {\n return this.config.plugins.map(plugin => plugin.control).filter(isNotNil)\n }\n\n pluginControlAt(index: number): RichTextPluginControl | undefined {\n return this.pluginControls[index]\n }\n\n toText(data: DataType | undefined): string {\n if (data == null) return ''\n return toText(Definition.dataToNodes(data), this.config.mode ?? Definition.Mode.Block)\n }\n}\n\nexport class RichTextV2Definition extends Definition {}\n\nexport function RichText(config?: UserConfig): RichTextV2Definition {\n return new RichTextV2Definition(config ?? {})\n}\n\nRichText.Mode = Definition.Mode\nRichText.isV1Data = Definition.isV1Data\nRichText.dataToNodes = Definition.dataToNodes\nRichText.Plugin = Plugin\n\nexport { RichTextMode as RichTextV2Mode, type DataV2Type as RichTextDataV2, RichTextV2Control }\n"],"mappings":"AACA,SAAS,SAAS;AAElB,OAAO,WAAW;AAElB;AAAA,EACE,sBAAsB;AAAA,EACtB;AAAA,EAEA;AAAA,EACA;AAAA,OAWK;AAEP,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,cAAc;AAEvB,SAAS,wBAAwB;AAEjC,SAA2B,cAAc;AACzC,SAAS,yBAAyB;AAClC,SAAS,2BAA2B;AAWpC,MAAM,mBAAmB,uBAAwD;AAAA,EAC/E,YAAY,EAAE,MAAM,aAAa,GAAe,SAA8B;AAC5E,UAAM;AAAA,MACJ;AAAA,MACA,cACE,iBACC,SAAS,WAAW,KAAK,SAAS,mBAAmB,WAAW,kBAAkB;AAAA,MACrF,SACE,YACC,SAAS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,EAAmC,CAAC,EAAE;AAAA,EACxF;AAAA,EAEA,eAAe,MAA2B;AACxC,WAAO,IAAI,kBAAkB,MAAM,IAAI;AAAA,EACzC;AAAA,EAEA,aACE,MACA,WACA,aACA,SACmC;AACnC,UAAM,cAAc,YAAY;AAAA,MAC9B,MAAM,WAAW;AAAA,MACjB,MAAM,MAAM,iBAAiB,MAAM,
|
|
1
|
+
{"version":3,"sources":["../../../../src/controls/rich-text-v2/rich-text-v2.ts"],"sourcesContent":["import { ReactNode } from 'react'\nimport { z } from 'zod'\n// @ts-expect-error: there are no types for 'corporate-ipsum'\nimport ipsum from 'corporate-ipsum'\n\nimport {\n RichTextDefinition as BaseRichTextDefinition,\n isNotNil,\n ControlDefinition,\n SerializationSchema,\n StableValue,\n type Data,\n type Resolvable,\n type ControlInstanceArgs,\n type DeserializedRecord,\n type SchemaType,\n type SchemaTypeAny,\n type RichTextPluginControl,\n type ResourceResolver,\n type Stylesheet,\n type RichTextMode,\n} from '@makeswift/controls'\n\nimport { LinkPlugin } from '../../slate/LinkPlugin'\nimport { InlinePlugin } from '../../slate/InlinePlugin'\nimport { TextAlignPlugin } from '../../slate/TextAlignPlugin'\nimport { BlockPlugin } from '../../slate/BlockPlugin'\nimport { TypographyPlugin } from '../../slate/TypographyPlugin'\nimport { InlineModePlugin } from '../../slate/InlineModePlugin'\nimport { toText } from '../../slate/utils'\n\nimport { renderRichTextV2 } from '../../runtimes/react/controls/rich-text-v2'\n\nimport { RichTextV2Plugin, Plugin } from './plugin'\nimport { RichTextV2Control } from './control'\nimport { getTranslatableData } from './translations/get-translations'\n\ntype DataType = z.infer<typeof Definition.schema.data>\ntype DataV2Type = z.infer<typeof Definition.schema.dataV2>\ntype InstanceType = RichTextV2Control\ntype UserConfig = z.infer<typeof Definition.schema.userConfig>\ntype Config = UserConfig & {\n defaultValue: string\n plugins: RichTextV2Plugin[]\n}\n\nclass Definition extends BaseRichTextDefinition<ReactNode, Config, InstanceType> {\n constructor({ mode, defaultValue }: UserConfig, plugins?: RichTextV2Plugin[]) {\n super({\n mode,\n defaultValue:\n defaultValue ??\n (mode === Definition.Mode.Inline ? 'Edit this text' : Definition.generateParagraph()),\n plugins:\n plugins ??\n (mode === Definition.Mode.Inline\n ? [InlineModePlugin()]\n : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]),\n })\n }\n\n static generateParagraph(): string {\n return ipsum(3)\n }\n\n static deserialize(\n data: DeserializedRecord,\n deserializeCallback: (r: DeserializedRecord) => ControlDefinition,\n ): RichTextV2Definition {\n if (data.type !== Definition.type) {\n throw new Error(`RichText: expected type ${Definition.type}, got ${data.type}`)\n }\n\n const { config } = Definition.fullSchema({\n pluginDef: SerializationSchema.deserializedRecord,\n }).definition.parse(data)\n\n const { plugins, ...userConfig } = config\n\n return new RichTextV2Definition(\n userConfig,\n plugins.map(({ control }) =>\n control ? { control: { definition: deserializeCallback(control?.definition) } } : {},\n ),\n )\n }\n\n static fullSchema<S extends SchemaTypeAny>({ pluginDef }: { pluginDef: S }) {\n const baseSchema = super.schema\n const plugin = z.object({\n control: z\n .object({\n definition: pluginDef,\n })\n .optional(),\n })\n\n const config = baseSchema.userConfig.extend({\n defaultValue: z.string(),\n plugins: z.array(plugin),\n })\n\n return {\n ...baseSchema,\n config,\n definition: z.object({\n type: baseSchema.type,\n config,\n }),\n }\n }\n\n get configSchema(): SchemaType<Config> {\n return Definition.fullSchema({ pluginDef: z.any() as SchemaType<ControlDefinition> }).config\n }\n\n createInstance(args: ControlInstanceArgs) {\n return new RichTextV2Control(this, args)\n }\n\n resolveValue(\n data: DataType | undefined,\n _resolver: ResourceResolver,\n _stylesheet: Stylesheet,\n control?: InstanceType,\n ): Resolvable<ReactNode | undefined> {\n const stableValue = StableValue({\n name: Definition.type,\n read: () => renderRichTextV2(data, this.config, control ?? null),\n })\n\n return {\n ...stableValue,\n triggerResolve: async () => {},\n }\n }\n\n getTranslatableData(data: DataType | undefined): Data {\n if (data == null) return null\n return getTranslatableData(Definition.dataToNodes(data), this.config.plugins)\n }\n\n get pluginControls(): RichTextPluginControl[] {\n return this.config.plugins.map(plugin => plugin.control).filter(isNotNil)\n }\n\n pluginControlAt(index: number): RichTextPluginControl | undefined {\n return this.pluginControls[index]\n }\n\n toText(data: DataType | undefined): string {\n if (data == null) return ''\n return toText(Definition.dataToNodes(data), this.config.mode ?? Definition.Mode.Block)\n }\n}\n\nexport class RichTextV2Definition extends Definition {}\n\nexport function RichText(config?: UserConfig): RichTextV2Definition {\n return new RichTextV2Definition(config ?? {})\n}\n\nRichText.Mode = Definition.Mode\nRichText.isV1Data = Definition.isV1Data\nRichText.dataToNodes = Definition.dataToNodes\nRichText.Plugin = Plugin\n\nexport { RichTextMode as RichTextV2Mode, type DataV2Type as RichTextDataV2, RichTextV2Control }\n"],"mappings":"AACA,SAAS,SAAS;AAElB,OAAO,WAAW;AAElB;AAAA,EACE,sBAAsB;AAAA,EACtB;AAAA,EAEA;AAAA,EACA;AAAA,OAWK;AAEP,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,cAAc;AAEvB,SAAS,wBAAwB;AAEjC,SAA2B,cAAc;AACzC,SAAS,yBAAyB;AAClC,SAAS,2BAA2B;AAWpC,MAAM,mBAAmB,uBAAwD;AAAA,EAC/E,YAAY,EAAE,MAAM,aAAa,GAAe,SAA8B;AAC5E,UAAM;AAAA,MACJ;AAAA,MACA,cACE,iBACC,SAAS,WAAW,KAAK,SAAS,mBAAmB,WAAW,kBAAkB;AAAA,MACrF,SACE,YACC,SAAS,WAAW,KAAK,SACtB,CAAC,iBAAiB,CAAC,IACnB,CAAC,YAAY,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,aAAa,GAAG,WAAW,CAAC;AAAA,IAC3F,CAAC;AAAA,EACH;AAAA,EAEA,OAAO,oBAA4B;AACjC,WA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,MAAM,WAAW;AAAA,MACjB,MAAM,MAAM,iBAAiB,MAAM,KAAK,QAAQ,WAAW,IAAI;AAAA,IACjE,CAAC;AAED,WAAO;AAAA,MACL,GAAG;AAAA,MACH,gBAAgB,YAAY;AAAA,MAAC;AAAA,IAC/B;AAAA,EACF;AAAA,EAEA,oBAAoB,MAAkC;AACpD,QAAI,QAAQ;AAAM,aAAO;AACzB,WAAO,oBAAoB,WAAW,YAAY,IAAI,GAAG,KAAK,OAAO,OAAO;AAAA,EAC9E;AAAA,EAEA,IAAI,iBAA0C;AAC5C,WAAO,KAAK,OAAO,QAAQ,IAAI,YAAU,OAAO,OAAO,EAAE,OAAO,QAAQ;AAAA,EAC1E;AAAA,EAEA,gBAAgB,OAAkD;AAChE,WAAO,KAAK,eAAe,KAAK;AAAA,EAClC;AAAA,EAEA,OAAO,MAAoC;AACzC,QAAI,QAAQ;AAAM,aAAO;AACzB,WAAO,OAAO,WAAW,YAAY,IAAI,GAAG,KAAK,OAAO,QAAQ,WAAW,KAAK,KAAK;AAAA,EACvF;AACF;AAEO,MAAM,6BAA6B,WAAW;AAAC;AAE/C,SAAS,SAAS,QAA2C;AAClE,SAAO,IAAI,qBAAqB,UAAU,CAAC,CAAC;AAC9C;AAEA,SAAS,OAAO,WAAW;AAC3B,SAAS,WAAW,WAAW;AAC/B,SAAS,cAAc,WAAW;AAClC,SAAS,SAAS;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Text } from 'slate'\n\nimport { Slate, RichTextValue, richTextDTOtoDAO } from '@makeswift/controls'\n\nimport { useResponsiveStyle } from '../../../../components/utils/responsive-style'\nimport { InlineType, BlockType } from '../../../../slate/types'\nimport { useStyle } from '../../use-style'\nimport useEnhancedTypography, { useTypographyClassName } from '../typography'\nimport { Link } from '../../../../components/shared/Link'\n\ntype Props = {\n id?: string\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst ReadOnlyText = forwardRef(function ReadOnlyText(\n { id, text, width, margin }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendants = text == null ? [] : richTextDTOtoDAO(text)\n const descendantsAsString = getText(descendants)\n\n return (\n <div\n ref={ref}\n id={id}\n style={{\n /**\n * These are the default styles that Slate uses for its editable div.\n * https://github.com/ianstormtaylor/slate/blob/4bd15ed3950e3a0871f5d0ecb391bb637c05e59d/packages/slate-react/src/components/editable.tsx\n * Search for `disableDefaultStyles`\n */\n position: 'relative',\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n }}\n className={cx(width, margin)}\n >\n {descendantsAsString === '' ? <Placeholder /> : <Descendants descendants={descendants} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\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: Slate.Inline\n}\n\nfunction InlineElement({ descendant }: 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} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link ?? undefined}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Slate.Block\n}\n\nexport function BlockElement({ descendant }: 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 switch (descendant.type) {\n case BlockType.Default:\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\n default:\n return null\n }\n}\n\nfunction Descendants({ descendants }: { descendants: Descendant[] }) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (Slate.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} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Slate.Block {\n if ('text' in descendant) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if ('text' in 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.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"],"mappings":"AA0CoC,SA8KhC,UA9KgC;AA1CpC,SAAS,UAAU;AACnB,SAAuB,kBAAkB;AAGzC,SAAS,OAAsB,wBAAwB;AAEvD,SAAS,0BAA0B;AACnC,SAAS,YAAY,iBAAiB;AACtC,SAAS,gBAAgB;AACzB,OAAO,yBAAyB,8BAA8B;AAC9D,SAAS,YAAY;AASrB,MAAM,eAAe,WAAW,SAASA,cACvC,EAAE,IAAI,MAAM,OAAO,OAAO,GAC1B,KACA;AACA,QAAM,cAAc,QAAQ,OAAO,CAAC,IAAI,iBAAiB,IAAI;AAC7D,QAAM,sBAAsB,QAAQ,WAAW;AAE/C,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAML,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,UAAU;AAAA,MACZ;AAAA,MACA,WAAW,GAAG,OAAO,MAAM;AAAA,MAE1B,kCAAwB,KAAK,oBAAC,eAAY,IAAK,oBAAC,eAAY,aAA0B;AAAA;AAAA,EACzF;AAEJ,CAAC;AAED,IAAO,uBAAQ;AAEf,SAAS,YAAY,EAAE,OAAO,qBAAqB,GAAsB;AACvE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,SAAS;AAAA,QAClB,SAAS;AAAA,QACT,OAAO;AAAA,QACP,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,SAAS;AAAA,QACT,eAAe;AAAA,MACjB,CAAC;AAAA,MAEA;AAAA;AAAA,EACH;AAEJ;AAMO,SAAS,YAAY,EA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A,IAET;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,oBAAoB,YAAgC;AAC3D,MAAI,UAAU,YAAY;AACxB,WAAO,WAAW,QAAQ;AAAA,EAC5B;AAEA,UAAQ,WAAW,MAAM;AAAA,IACvB,KAAK,WAAW;AAAA,IAChB,KAAK,WAAW;AAAA,IAChB,KAAK,WAAW;AAAA,IAChB,KAAK,WAAW;AACd,aAAO,WAAW,SAAS,IAAI,CAAAC,gBAAc,oBAAoBA,WAAU,CAAC,EAAE,KAAK,EAAE,KAAK;AAAA,IAC5F,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AACb,aACE,WAAW,SACR,IAAI,CAAAA,gBAAc,oBAAoBA,WAAU,CAAC,EACjD,KAAK,WAAW,SAAS,MAAM,OAAO,IAAI,OAAO,EAAE,KAAK;AAAA,IAE/D;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,QAAQ,YAAkC;AACjD,SAAO,WAAW,IAAI,mBAAmB,EAAE,KAAK,IAAI;AACtD;","names":["ReadOnlyText","descendant"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text/ReadOnlyText.tsx"],"sourcesContent":["'use client'\n\nimport { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Text } from 'slate'\n\nimport { Slate, RichTextValue, richTextDTOtoDAO } from '@makeswift/controls'\n\nimport { useResponsiveStyle } from '../../../../components/utils/responsive-style'\nimport { InlineType, BlockType } from '../../../../slate/types'\nimport { useStyle } from '../../use-style'\nimport useEnhancedTypography, { useTypographyClassName } from '../typography'\nimport { Link } from '../../../../components/shared/Link'\n\ntype Props = {\n id?: string\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst ReadOnlyText = forwardRef(function ReadOnlyText(\n { id, text, width, margin }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendants = text == null ? [] : richTextDTOtoDAO(text)\n const descendantsAsString = getText(descendants)\n\n return (\n <div\n ref={ref}\n id={id}\n style={{\n /**\n * These are the default styles that Slate uses for its editable div.\n * https://github.com/ianstormtaylor/slate/blob/4bd15ed3950e3a0871f5d0ecb391bb637c05e59d/packages/slate-react/src/components/editable.tsx\n * Search for `disableDefaultStyles`\n */\n position: 'relative',\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n }}\n className={cx(width, margin)}\n >\n {descendantsAsString === '' ? <Placeholder /> : <Descendants descendants={descendants} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\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: Slate.Inline\n}\n\nfunction InlineElement({ descendant }: 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} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link ?? undefined}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Slate.Block\n}\n\nexport function BlockElement({ descendant }: 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 switch (descendant.type) {\n case BlockType.Default:\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\n default:\n return null\n }\n}\n\nfunction Descendants({ descendants }: { descendants: Descendant[] }) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (Slate.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} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Slate.Block {\n if ('text' in descendant) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if ('text' in 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.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"],"mappings":";AA4CoC,SA8KhC,UA9KgC;AA1CpC,SAAS,UAAU;AACnB,SAAuB,kBAAkB;AAGzC,SAAS,OAAsB,wBAAwB;AAEvD,SAAS,0BAA0B;AACnC,SAAS,YAAY,iBAAiB;AACtC,SAAS,gBAAgB;AACzB,OAAO,yBAAyB,8BAA8B;AAC9D,SAAS,YAAY;AASrB,MAAM,eAAe,WAAW,SAASA,cACvC,EAAE,IAAI,MAAM,OAAO,OAAO,GAC1B,KACA;AACA,QAAM,cAAc,QAAQ,OAAO,CAAC,IAAI,iBAAiB,IAAI;AAC7D,QAAM,sBAAsB,QAAQ,WAAW;AAE/C,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAML,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,UAAU;AAAA,MACZ;AAAA,MACA,WAAW,GAAG,OAAO,MAAM;AAAA,MAE1B,kCAAwB,KAAK,oBAAC,eAAY,IAAK,oBAAC,eAAY,aAA0B;AAAA;AAAA,EACzF;AAEJ,CAAC;AAED,IAAO,uBAAQ;AAEf,SAAS,YAAY,EAAE,OAAO,qBAAqB,GAAsB;AACvE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,SAAS;AAAA,QAClB,SAAS;AAAA,QACT,OAAO;AAAA,QACP,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,SAAS;AAAA,QACT,eAAe;AAAA,MACjB,CAAC;AAAA,MAEA;AAAA;AAAA,EACH;AA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AAK,UAAU;AACb,aAAO;AAAA,IAET;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,oBAAoB,YAAgC;AAC3D,MAAI,UAAU,YAAY;AACxB,WAAO,WAAW,QAAQ;AAAA,EAC5B;AAEA,UAAQ,WAAW,MAAM;AAAA,IACvB,KAAK,WAAW;AAAA,IAChB,KAAK,WAAW;AAAA,IAChB,KAAK,WAAW;AAAA,IAChB,KAAK,WAAW;AACd,aAAO,WAAW,SAAS,IAAI,CAAAC,gBAAc,oBAAoBA,WAAU,CAAC,EAAE,KAAK,EAAE,KAAK;AAAA,IAC5F,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AACb,aACE,WAAW,SACR,IAAI,CAAAA,gBAAc,oBAAoBA,WAAU,CAAC,EACjD,KAAK,WAAW,SAAS,MAAM,OAAO,IAAI,OAAO,EAAE,KAAK;AAAA,IAE/D;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,QAAQ,YAAkC;AACjD,SAAO,WAAW,IAAI,mBAAmB,EAAE,KAAK,IAAI;AACtD;","names":["ReadOnlyText","descendant"]}
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
import {
|
|
19
19
|
RichText
|
|
20
20
|
} from "../../../../../controls/rich-text-v2";
|
|
21
|
-
import { useBuilderEditMode } from "
|
|
21
|
+
import { useBuilderEditMode } from "../../../hooks/use-builder-edit-mode";
|
|
22
22
|
import { useSlateReset } from "../../use-slate-reset";
|
|
23
23
|
import { BuilderEditMode } from "../../../../../state/modules/builder-edit-mode";
|
|
24
24
|
import { pollBoxModel } from "../../../poll-box-model";
|
|
@@ -28,8 +28,8 @@ import { RichTextV2Element } from "./render-element";
|
|
|
28
28
|
import { RichTextV2Leaf } from "./render-leaf";
|
|
29
29
|
import { useSyncRemoteChanges } from "./useRemoteChanges";
|
|
30
30
|
import { defaultValue, usePresetValue } from "./usePresetValue";
|
|
31
|
-
function EditableTextV2({ text,
|
|
32
|
-
const plugins = useMemo(() =>
|
|
31
|
+
function EditableTextV2({ text, config, control }) {
|
|
32
|
+
const plugins = useMemo(() => config.plugins, [config]);
|
|
33
33
|
const [editor] = useState(
|
|
34
34
|
() => plugins.reduceRight(
|
|
35
35
|
(editor2, plugin) => plugin?.withPlugin?.(editor2) ?? editor2,
|
|
@@ -53,9 +53,9 @@ function EditableTextV2({ text, definition, control }) {
|
|
|
53
53
|
isPreservingFocus.current = false;
|
|
54
54
|
ReactEditor.deselect(editor);
|
|
55
55
|
}
|
|
56
|
-
}, [editMode]);
|
|
56
|
+
}, [editMode, editor]);
|
|
57
57
|
useSyncRemoteChanges(editor, text);
|
|
58
|
-
const presetValue = usePresetValue(
|
|
58
|
+
const presetValue = usePresetValue(config);
|
|
59
59
|
const initialValue = useMemo(
|
|
60
60
|
() => (text && RichText.dataToNodes(text)) ?? presetValue,
|
|
61
61
|
[text, presetValue]
|
|
@@ -71,15 +71,15 @@ function EditableTextV2({ text, definition, control }) {
|
|
|
71
71
|
}, [control, initialValue, presetValue]);
|
|
72
72
|
const renderElement = useCallback(
|
|
73
73
|
(props) => {
|
|
74
|
-
return /* @__PURE__ */ jsx(RichTextV2Element, { ...props,
|
|
74
|
+
return /* @__PURE__ */ jsx(RichTextV2Element, { ...props, plugins });
|
|
75
75
|
},
|
|
76
|
-
[plugins
|
|
76
|
+
[plugins]
|
|
77
77
|
);
|
|
78
78
|
const renderLeaf = useCallback(
|
|
79
79
|
(props) => {
|
|
80
|
-
return /* @__PURE__ */ jsx(RichTextV2Leaf, { ...props,
|
|
80
|
+
return /* @__PURE__ */ jsx(RichTextV2Leaf, { ...props, plugins });
|
|
81
81
|
},
|
|
82
|
-
[plugins
|
|
82
|
+
[plugins]
|
|
83
83
|
);
|
|
84
84
|
const handleFocus = useCallback(() => {
|
|
85
85
|
isPreservingFocus.current = true;
|
|
@@ -110,7 +110,7 @@ function EditableTextV2({ text, definition, control }) {
|
|
|
110
110
|
e.preventDefault();
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
|
-
[
|
|
113
|
+
[editMode]
|
|
114
114
|
);
|
|
115
115
|
const handleClick = useCallback(
|
|
116
116
|
(e) => {
|
|
@@ -144,9 +144,7 @@ function EditableTextV2({ text, definition, control }) {
|
|
|
144
144
|
}
|
|
145
145
|
) });
|
|
146
146
|
}
|
|
147
|
-
var editable_text_v2_default = EditableTextV2;
|
|
148
147
|
export {
|
|
149
|
-
EditableTextV2
|
|
150
|
-
editable_text_v2_default as default
|
|
148
|
+
EditableTextV2
|
|
151
149
|
};
|
|
152
150
|
//# sourceMappingURL=editable-text-v2.js.map
|
package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.tsx"],"sourcesContent":["'use client'\n\nimport {\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.tsx"],"sourcesContent":["'use client'\n\nimport {\n type FocusEvent,\n type KeyboardEvent,\n type MouseEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport { createEditor } from 'slate'\nimport isHotkey from 'is-hotkey'\nimport {\n withReact,\n ReactEditor,\n RenderElementProps,\n RenderLeafProps,\n Slate,\n Editable,\n} from 'slate-react'\n\nimport { type ConfigType } from '@makeswift/controls'\n\nimport {\n RichTextV2Definition,\n RichText,\n RichTextV2Control,\n type RichTextDataV2,\n} from '../../../../../controls/rich-text-v2'\n\nimport { useBuilderEditMode } from '../../../hooks/use-builder-edit-mode'\nimport { useSlateReset } from '../../use-slate-reset'\nimport { BuilderEditMode } from '../../../../../state/modules/builder-edit-mode'\nimport { pollBoxModel } from '../../../poll-box-model'\nimport { withBuilder, withLocalChanges } from '../../../../../slate'\n\nimport { useSyncDOMSelection } from './useSyncDOMSelection'\nimport { RichTextV2Element } from './render-element'\nimport { RichTextV2Leaf } from './render-leaf'\nimport { useSyncRemoteChanges } from './useRemoteChanges'\nimport { defaultValue, usePresetValue } from './usePresetValue'\n\ntype Props = {\n text?: RichTextDataV2\n config: ConfigType<RichTextV2Definition>\n control: RichTextV2Control | null\n}\n\nexport function EditableTextV2({ text, config, control }: Props) {\n const plugins = useMemo(() => config.plugins, [config])\n\n const [editor] = useState(() =>\n plugins.reduceRight(\n (editor, plugin) => plugin?.withPlugin?.(editor) ?? editor,\n withLocalChanges(withBuilder(withReact(createEditor()))),\n ),\n )\n\n useEffect(() => {\n if (control == null) return\n\n const element = ReactEditor.toDOMNode(editor, editor)\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeBoxModel(boxModel),\n })\n }, [editor, control])\n\n // ------ Preserving selection ------\n\n const isPreservingFocus = useRef(false)\n useSyncDOMSelection(editor, isPreservingFocus)\n const editMode = useBuilderEditMode()\n\n useEffect(() => {\n /**\n * This is required because clicking on the overlay has `relatedTarget` null just like the sidebar, but\n * - in the case of the overlay we switch to BUILD mode\n * - in the case of the sidebar we preserve the selection\n */\n if (editMode !== BuilderEditMode.CONTENT) {\n isPreservingFocus.current = false\n ReactEditor.deselect(editor)\n }\n }, [editMode, editor])\n\n // ------ Syncing remote changes ------\n\n useSyncRemoteChanges(editor, text)\n\n // ------ Default value ------\n\n const presetValue = usePresetValue(config)\n\n const initialValue = useMemo(\n () => (text && RichText.dataToNodes(text)) ?? presetValue,\n [text, presetValue],\n )\n\n useEffect(() => {\n control?.setEditor(editor)\n control?.setDefaultValue(defaultValue)\n }, [control, editor])\n\n /**\n * When initialValue is set to the default value we need to trigger an local change so that the sidebar updates and so the data is saved\n */\n useEffect(() => {\n if (initialValue === presetValue) {\n control?.onLocalUserChange()\n }\n }, [control, initialValue, presetValue])\n\n // ------ Rendering ------\n\n const renderElement = useCallback(\n (props: RenderElementProps) => {\n return <RichTextV2Element {...props} plugins={plugins} />\n },\n [plugins],\n )\n\n const renderLeaf = useCallback(\n (props: RenderLeafProps) => {\n return <RichTextV2Leaf {...props} plugins={plugins} />\n },\n [plugins],\n )\n\n // ------ Event handlers ------\n\n const handleFocus = useCallback(() => {\n isPreservingFocus.current = true\n control?.select()\n }, [control])\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (isHotkey('mod+shift+z', e)) return control?.redo()\n if (isHotkey('mod+z', e)) return control?.undo()\n if (isHotkey('escape')(e)) {\n isPreservingFocus.current = false\n ReactEditor.blur(editor)\n control?.switchToBuildMode()\n }\n\n if (editMode === BuilderEditMode.CONTENT) {\n e.stopPropagation()\n }\n\n plugins.forEach(plugin => plugin?.onKeyDown?.(e, editor))\n },\n [control, plugins, editor, editMode],\n )\n\n const handleKeyUp = useCallback(\n (e: KeyboardEvent) => {\n if (editMode === BuilderEditMode.CONTENT) {\n e.stopPropagation()\n e.preventDefault()\n }\n },\n [editMode],\n )\n\n const handleClick = useCallback(\n (e: MouseEvent) => {\n if (editMode === BuilderEditMode.CONTENT) {\n e.stopPropagation()\n e.preventDefault()\n }\n },\n [editMode],\n )\n\n const handleBlur = useCallback((e: FocusEvent) => {\n // outside of iframe (overlay, sidebar, etc)\n if (e.relatedTarget == null) return\n // another text\n if (e.relatedTarget?.getAttribute('contenteditable') === 'true')\n isPreservingFocus.current = false\n }, [])\n\n const slateReset = useSlateReset()\n\n return (\n <Slate editor={editor} value={initialValue}>\n <Editable\n className={slateReset}\n renderLeaf={renderLeaf}\n renderElement={renderElement}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}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,QAAQ,YAAU,QAAQ,YAAY,GAAG,MAAM,CAAC;AAAA,IAC1D;AAAA,IACA,CAAC,SAAS,SAAS,QAAQ,QAAQ;AAAA,EACrC;AAEA,QAAM,cAAc;AAAA,IAClB,CAAC,MAAqB;AACpB,UAAI,aAAa,gBAAgB,SAAS;AACxC,UAAE,gBAAgB;AAClB,UAAE,eAAe;AAAA,MACnB;AAAA,IACF;AAAA,IACA,CAAC,QAAQ;AAAA,EACX;AAEA,QAAM,cAAc;AAAA,IAClB,CAAC,MAAkB;AACjB,UAAI,aAAa,gBAAgB,SAAS;AACxC,UAAE,gBAAgB;AAClB,UAAE,eAAe;AAAA,MACnB;AAAA,IACF;AAAA,IACA,CAAC,QAAQ;AAAA,EACX;AAEA,QAAM,aAAa,YAAY,CAAC,MAAkB;AAEhD,QAAI,EAAE,iBAAiB;AAAM;AAE7B,QAAI,EAAE,eAAe,aAAa,iBAAiB,MAAM;AACvD,wBAAkB,UAAU;AAAA,EAChC,GAAG,CAAC,CAAC;AAEL,QAAM,aAAa,cAAc;AAEjC,SACE,oBAAC,SAAM,QAAgB,OAAO,cAC5B;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT,WAAW;AAAA,MACX,SAAS;AAAA,MACT,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,UAAU,aAAa,gBAAgB;AAAA,MACvC,aAAY;AAAA;AAAA,EACd,GACF;AAEJ;","names":["editor"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/index.tsx"],"sourcesContent":["export * from './editable-text-v2'\nimport EditableTextV2 from './editable-text-v2'\nexport default EditableTextV2\n"],"mappings":"AAAA,cAAc;AACd,
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/index.tsx"],"sourcesContent":["export * from './editable-text-v2'\nimport { EditableTextV2 } from './editable-text-v2'\nexport default EditableTextV2\n"],"mappings":"AAAA,cAAc;AACd,SAAS,sBAAsB;AAC/B,IAAO,yBAAQ;","names":[]}
|
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ControlValue } from "../../control";
|
|
3
|
-
function RichTextV2Element({
|
|
3
|
+
function RichTextV2Element({ plugins, ...props }) {
|
|
4
4
|
function initialRenderElement(props2) {
|
|
5
5
|
return props2.children;
|
|
6
6
|
}
|
|
7
7
|
const renderElement = plugins.reduce(
|
|
8
|
-
(renderFn, plugin) => (props2)
|
|
8
|
+
(renderFn, plugin) => function RenderElementPlugin(props2) {
|
|
9
9
|
const { control, renderElement: renderElement2 } = plugin;
|
|
10
10
|
if (renderElement2 == null)
|
|
11
11
|
return renderFn(props2);
|
|
12
12
|
if (control == null || control.getElementValue == null)
|
|
13
13
|
return renderElement2(renderFn, void 0)(props2);
|
|
14
|
-
return /* @__PURE__ */ jsx(
|
|
14
|
+
return /* @__PURE__ */ jsx(
|
|
15
|
+
ControlValue,
|
|
16
|
+
{
|
|
17
|
+
definition: control.definition,
|
|
18
|
+
data: control.getElementValue(props2.element),
|
|
19
|
+
children: (value) => renderElement2(renderFn, value)(props2)
|
|
20
|
+
}
|
|
21
|
+
);
|
|
15
22
|
},
|
|
16
23
|
initialRenderElement
|
|
17
24
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.tsx"],"sourcesContent":["import { RenderElementProps } from 'slate-react'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.tsx"],"sourcesContent":["import { RenderElementProps } from 'slate-react'\n\nimport { RichTextV2Plugin } from '../../../../../controls/rich-text-v2/plugin'\n\nimport { ControlValue } from '../../control'\n\ntype RichTextV2ElementProps = RenderElementProps & {\n plugins: RichTextV2Plugin[]\n}\n\nexport function RichTextV2Element({ plugins, ...props }: RichTextV2ElementProps) {\n function initialRenderElement(props: RenderElementProps) {\n return props.children\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) =>\n function RenderElementPlugin(props: RenderElementProps) {\n const { control, renderElement } = plugin\n\n if (renderElement == null) return renderFn(props)\n\n if (control == null || control.getElementValue == null)\n return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue\n definition={control.definition}\n data={control.getElementValue(props.element)}\n >\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement(props)\n}\n"],"mappings":"AA0BU;AAtBV,SAAS,oBAAoB;AAMtB,SAAS,kBAAkB,EAAE,SAAS,GAAG,MAAM,GAA2B;AAC/E,WAAS,qBAAqBA,QAA2B;AACvD,WAAOA,OAAM;AAAA,EACf;AAEA,QAAM,gBAAgB,QAAQ;AAAA,IAC5B,CAAC,UAAU,WACT,SAAS,oBAAoBA,QAA2B;AACtD,YAAM,EAAE,SAAS,eAAAC,eAAc,IAAI;AAEnC,UAAIA,kBAAiB;AAAM,eAAO,SAASD,MAAK;AAEhD,UAAI,WAAW,QAAQ,QAAQ,mBAAmB;AAChD,eAAOC,eAAc,UAAU,MAAS,EAAED,MAAK;AAEjD,aACE;AAAA,QAAC;AAAA;AAAA,UACC,YAAY,QAAQ;AAAA,UACpB,MAAM,QAAQ,gBAAgBA,OAAM,OAAO;AAAA,UAE1C,qBAASC,eAAc,UAAU,KAAK,EAAED,MAAK;AAAA;AAAA,MAChD;AAAA,IAEJ;AAAA,IACF;AAAA,EACF;AAEA,SAAO,cAAc,KAAK;AAC5B;","names":["props","renderElement"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ControlValue } from "../../control";
|
|
3
|
-
function RichTextV2Leaf({
|
|
3
|
+
function RichTextV2Leaf({ plugins, ...props }) {
|
|
4
4
|
function initialRenderLeaf({ attributes, children, leaf }) {
|
|
5
5
|
return /* @__PURE__ */ jsx("span", { className: leaf.className, ...attributes, children });
|
|
6
6
|
}
|
|
7
7
|
const renderLeaf = plugins.reduce(
|
|
8
|
-
(renderFn, plugin) => (props2)
|
|
8
|
+
(renderFn, plugin) => function RenderLeafPlugin(props2) {
|
|
9
9
|
const { control, renderLeaf: renderLeaf2 } = plugin;
|
|
10
10
|
if (control?.definition == null || renderLeaf2 == null)
|
|
11
11
|
return renderFn(props2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport { RenderLeafProps } from 'slate-react'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport { RenderLeafProps } from 'slate-react'\nimport { RichTextV2Plugin } from '../../../../../controls/rich-text-v2/plugin'\nimport { ControlValue } from '../../control'\n\ntype RichTextV2LeafProps = RenderLeafProps & {\n plugins: RichTextV2Plugin[]\n}\n\nexport function RichTextV2Leaf({ plugins, ...props }: RichTextV2LeafProps) {\n function initialRenderLeaf({ attributes, children, leaf }: RenderLeafProps): ReactNode {\n return (\n <span className={leaf.className} {...attributes}>\n {children}\n </span>\n )\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) =>\n function RenderLeafPlugin(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(props)\n}\n"],"mappings":"AAYM;AATN,SAAS,oBAAoB;AAMtB,SAAS,eAAe,EAAE,SAAS,GAAG,MAAM,GAAwB;AACzE,WAAS,kBAAkB,EAAE,YAAY,UAAU,KAAK,GAA+B;AACrF,WACE,oBAAC,UAAK,WAAW,KAAK,WAAY,GAAG,YAClC,UACH;AAAA,EAEJ;AAEA,QAAM,aAAa,QAAQ;AAAA,IACzB,CAAC,UAAU,WACT,SAAS,iBAAiBA,QAAwB;AAChD,YAAM,EAAE,SAAS,YAAAC,YAAW,IAAI;AAEhC,UAAI,SAAS,cAAc,QAAQA,eAAc;AAAM,eAAO,SAASD,MAAK;AAE5E,UAAI,QAAQ,gBAAgB;AAAM,eAAOC,YAAW,UAAU,MAAS,EAAED,MAAK;AAE9E,aACE,oBAAC,gBAAa,YAAY,QAAQ,YAAY,MAAM,QAAQ,aAAaA,OAAM,IAAI,GAChF,qBAASC,YAAW,UAAU,KAAK,EAAED,MAAK,GAC7C;AAAA,IAEJ;AAAA,IACF;AAAA,EACF;AAEA,SAAO,WAAW,KAAK;AACzB;","names":["props","renderLeaf"]}
|
|
@@ -3,7 +3,7 @@ import { Slate, getBaseBreakpoint } from "@makeswift/controls";
|
|
|
3
3
|
import { DefaultBreakpointID } from "../../../../../state/modules/breakpoints";
|
|
4
4
|
import { useBreakpoints } from "../../../hooks/use-breakpoints";
|
|
5
5
|
import { RichText } from "../../../../../controls";
|
|
6
|
-
function usePresetValue(
|
|
6
|
+
function usePresetValue(config) {
|
|
7
7
|
const breakpoints = useBreakpoints();
|
|
8
8
|
return useMemo(
|
|
9
9
|
() => [
|
|
@@ -11,8 +11,8 @@ function usePresetValue(definition) {
|
|
|
11
11
|
type: Slate.BlockType.Default,
|
|
12
12
|
children: [
|
|
13
13
|
{
|
|
14
|
-
text:
|
|
15
|
-
...
|
|
14
|
+
text: config.defaultValue ?? "",
|
|
15
|
+
...config.mode === RichText.Mode.Inline ? {} : {
|
|
16
16
|
typography: {
|
|
17
17
|
style: [
|
|
18
18
|
{
|
|
@@ -36,7 +36,7 @@ function usePresetValue(definition) {
|
|
|
36
36
|
]
|
|
37
37
|
}
|
|
38
38
|
],
|
|
39
|
-
[
|
|
39
|
+
[config.mode, config.defaultValue, breakpoints]
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
42
|
const defaultValue = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { Descendant } from 'slate'\nimport { Slate, getBaseBreakpoint } from '@makeswift/controls'\n\nimport { DefaultBreakpointID } from '../../../../../state/modules/breakpoints'\nimport { useBreakpoints } from '../../../hooks/use-breakpoints'\nimport { RichTextV2Definition, RichText } from '../../../../../controls'\n\nexport function usePresetValue(
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { Descendant } from 'slate'\n\nimport { type ConfigType, Slate, getBaseBreakpoint } from '@makeswift/controls'\n\nimport { DefaultBreakpointID } from '../../../../../state/modules/breakpoints'\nimport { useBreakpoints } from '../../../hooks/use-breakpoints'\nimport { RichTextV2Definition, RichText } from '../../../../../controls'\n\nexport function usePresetValue(config: ConfigType<RichTextV2Definition>): Descendant[] {\n const breakpoints = useBreakpoints()\n return useMemo(\n () => [\n {\n type: Slate.BlockType.Default,\n children: [\n {\n text: config.defaultValue ?? '',\n ...(config.mode === RichText.Mode.Inline\n ? {}\n : {\n typography: {\n style: [\n {\n deviceId: getBaseBreakpoint(breakpoints).id,\n value: {\n fontWeight: 400,\n fontSize: { value: 18, unit: 'px' },\n lineHeight: 1.5,\n },\n },\n ...(breakpoints.some(({ id }) => id === DefaultBreakpointID.Mobile)\n ? [\n {\n deviceId: DefaultBreakpointID.Mobile,\n value: { fontSize: { value: 16, unit: 'px' } },\n },\n ]\n : []),\n ],\n },\n }),\n },\n ],\n },\n ],\n [config.mode, config.defaultValue, breakpoints],\n )\n}\n\nexport const defaultValue = [\n {\n type: Slate.BlockType.Default,\n children: [\n {\n text: '',\n },\n ],\n },\n]\n"],"mappings":"AAAA,SAAS,eAAe;AAGxB,SAA0B,OAAO,yBAAyB;AAE1D,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAA+B,gBAAgB;AAExC,SAAS,eAAe,QAAwD;AACrF,QAAM,cAAc,eAAe;AACnC,SAAO;AAAA,IACL,MAAM;AAAA,MACJ;AAAA,QACE,MAAM,MAAM,UAAU;AAAA,QACtB,UAAU;AAAA,UACR;AAAA,YACE,MAAM,OAAO,gBAAgB;AAAA,YAC7B,GAAI,OAAO,SAAS,SAAS,KAAK,SAC9B,CAAC,IACD;AAAA,cACE,YAAY;AAAA,gBACV,OAAO;AAAA,kBACL;AAAA,oBACE,UAAU,kBAAkB,WAAW,EAAE;AAAA,oBACzC,OAAO;AAAA,sBACL,YAAY;AAAA,sBACZ,UAAU,EAAE,OAAO,IAAI,MAAM,KAAK;AAAA,sBAClC,YAAY;AAAA,oBACd;AAAA,kBACF;AAAA,kBACA,GAAI,YAAY,KAAK,CAAC,EAAE,GAAG,MAAM,OAAO,oBAAoB,MAAM,IAC9D;AAAA,oBACE;AAAA,sBACE,UAAU,oBAAoB;AAAA,sBAC9B,OAAO,EAAE,UAAU,EAAE,OAAO,IAAI,MAAM,KAAK,EAAE;AAAA,oBAC/C;AAAA,kBACF,IACA,CAAC;AAAA,gBACP;AAAA,cACF;AAAA,YACF;AAAA,UACN;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,OAAO,MAAM,OAAO,cAAc,WAAW;AAAA,EAChD;AACF;AAEO,MAAM,eAAe;AAAA,EAC1B;AAAA,IACE,MAAM,MAAM,UAAU;AAAA,IACtB,UAAU;AAAA,MACR;AAAA,QACE,MAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
|
-
import {
|
|
2
|
+
import { forwardRef, useMemo } from "react";
|
|
3
|
+
import {
|
|
4
|
+
RichText
|
|
5
|
+
} from "../../../../controls/rich-text-v2";
|
|
4
6
|
import { useStyle } from "../../use-style";
|
|
5
7
|
import { toText } from "../../../../slate/utils";
|
|
6
8
|
import { ControlValue } from "../control";
|
|
7
|
-
const ReadOnlyTextV2 = forwardRef(function ReadOnlyText({ text,
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
);
|
|
9
|
+
const ReadOnlyTextV2 = forwardRef(function ReadOnlyText({ text, config }, ref) {
|
|
10
|
+
const descendants = useMemo(() => text?.descendants ?? [], [text?.descendants]);
|
|
11
|
+
const plugins = useMemo(() => config?.plugins ?? [], [config]);
|
|
12
|
+
const descendantsAsString = toText(descendants, config?.mode ?? RichText.Mode.Block);
|
|
12
13
|
return /* @__PURE__ */ jsx(
|
|
13
14
|
"div",
|
|
14
15
|
{
|
|
@@ -23,13 +24,7 @@ const ReadOnlyTextV2 = forwardRef(function ReadOnlyText({ text, definition }, re
|
|
|
23
24
|
whiteSpace: "pre-wrap",
|
|
24
25
|
wordWrap: "break-word"
|
|
25
26
|
},
|
|
26
|
-
children: descendantsAsString === "" ? /* @__PURE__ */ jsx(Placeholder, {}) : /* @__PURE__ */ jsx(
|
|
27
|
-
Descendants,
|
|
28
|
-
{
|
|
29
|
-
plugins: definition?.config.plugins ?? [],
|
|
30
|
-
descendants: text?.descendants ?? []
|
|
31
|
-
}
|
|
32
|
-
)
|
|
27
|
+
children: descendantsAsString === "" ? /* @__PURE__ */ jsx(Placeholder, {}) : /* @__PURE__ */ jsx(Descendants, { plugins, descendants })
|
|
33
28
|
}
|
|
34
29
|
);
|
|
35
30
|
});
|
|
@@ -55,7 +50,7 @@ function LeafComponent({ plugins, ...props }) {
|
|
|
55
50
|
return /* @__PURE__ */ jsx("span", { className: leaf.className, children: leaf.text === "" ? "\uFEFF" : leaf.text });
|
|
56
51
|
}
|
|
57
52
|
const renderLeaf = plugins.reduce(
|
|
58
|
-
(renderFn, plugin) => (props2)
|
|
53
|
+
(renderFn, plugin) => function RenderLeafPlugin(props2) {
|
|
59
54
|
const { control, renderLeaf: renderLeaf2 } = plugin;
|
|
60
55
|
if (control?.definition == null || renderLeaf2 == null)
|
|
61
56
|
return renderFn(props2);
|
|
@@ -72,13 +67,20 @@ function ElementComponent({ plugins, ...props }) {
|
|
|
72
67
|
return /* @__PURE__ */ jsx(Descendants, { descendants: props2.element.children, plugins });
|
|
73
68
|
}
|
|
74
69
|
const renderElement = plugins.reduce(
|
|
75
|
-
(renderFn, plugin) => (props2)
|
|
70
|
+
(renderFn, plugin) => function RenderElementPlugin(props2) {
|
|
76
71
|
const { control, renderElement: renderElement2 } = plugin;
|
|
77
72
|
if (control?.definition == null || renderElement2 == null)
|
|
78
73
|
return renderFn(props2);
|
|
79
74
|
if (control.getElementValue == null)
|
|
80
75
|
return renderElement2(renderFn, void 0)(props2);
|
|
81
|
-
return /* @__PURE__ */ jsx(
|
|
76
|
+
return /* @__PURE__ */ jsx(
|
|
77
|
+
ControlValue,
|
|
78
|
+
{
|
|
79
|
+
definition: control.definition,
|
|
80
|
+
data: control.getElementValue(props2.element),
|
|
81
|
+
children: (value) => renderElement2(renderFn, value)(props2)
|
|
82
|
+
}
|
|
83
|
+
);
|
|
82
84
|
},
|
|
83
85
|
initialRenderElement
|
|
84
86
|
);
|