@reacteditor/core 0.0.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +85 -0
  2. package/dist/Editor-GBV2O5RD.css +415 -0
  3. package/dist/Editor-IKMJILGR.mjs +204 -0
  4. package/dist/Render-EFT7YD2C.css +103 -0
  5. package/dist/Render-VDC7AEQK.mjs +55 -0
  6. package/dist/actions-BCDhqbeL.d.mts +849 -0
  7. package/dist/actions-BCDhqbeL.d.ts +849 -0
  8. package/dist/chunk-2YLS65V2.mjs +103 -0
  9. package/dist/chunk-6B2Q5R3C.mjs +53 -0
  10. package/dist/chunk-DXGQXXQG.mjs +63 -0
  11. package/dist/chunk-F7S5S6I2.mjs +114 -0
  12. package/dist/chunk-GAUBBDIR.mjs +463 -0
  13. package/dist/chunk-GUMYXUO3.mjs +33 -0
  14. package/dist/chunk-M6W7YEVX.mjs +95 -0
  15. package/dist/chunk-MFI3RDA4.mjs +11 -0
  16. package/dist/chunk-QNHSXCWU.mjs +8692 -0
  17. package/dist/chunk-SURZYH7D.mjs +1726 -0
  18. package/dist/chunk-V2OPYD42.mjs +708 -0
  19. package/dist/chunk-VD3EVRUF.mjs +476 -0
  20. package/dist/chunk-VOLQMQPK.mjs +146 -0
  21. package/dist/chunk-VUEM62JF.mjs +523 -0
  22. package/dist/chunk-Y2EFNT5P.mjs +108 -0
  23. package/dist/full-ELX6RALJ.css +311 -0
  24. package/dist/full-OBTPW7TC.mjs +93 -0
  25. package/dist/index-ComBHfdn.d.ts +117 -0
  26. package/dist/index-DVwiIwYU.d.mts +117 -0
  27. package/dist/index.css +3033 -0
  28. package/dist/index.d.mts +396 -0
  29. package/dist/index.d.ts +396 -0
  30. package/dist/index.js +14688 -0
  31. package/dist/index.mjs +87 -0
  32. package/dist/internal.d.mts +27 -0
  33. package/dist/internal.d.ts +27 -0
  34. package/dist/internal.js +931 -0
  35. package/dist/internal.mjs +13 -0
  36. package/dist/loaded-35WC23HJ.mjs +60 -0
  37. package/dist/loaded-TBSVRJPY.css +90 -0
  38. package/dist/loaded-ULSROV73.mjs +57 -0
  39. package/dist/loaded-YYRJPIWZ.mjs +57 -0
  40. package/dist/no-external.css +3031 -0
  41. package/dist/no-external.d.mts +21 -0
  42. package/dist/no-external.d.ts +21 -0
  43. package/dist/no-external.js +14688 -0
  44. package/dist/no-external.mjs +87 -0
  45. package/dist/rsc.css +103 -0
  46. package/dist/rsc.d.mts +27 -0
  47. package/dist/rsc.d.ts +27 -0
  48. package/dist/rsc.js +1493 -0
  49. package/dist/rsc.mjs +148 -0
  50. package/dist/walk-tree-BPIigVTF.d.mts +29 -0
  51. package/dist/walk-tree-BZq1CPCH.d.ts +29 -0
  52. package/package.json +139 -0
package/dist/rsc.mjs ADDED
@@ -0,0 +1,148 @@
1
+ import {
2
+ SlotRenderPure,
3
+ migrate,
4
+ resolveAllData,
5
+ transformProps,
6
+ useRichtextProps,
7
+ useSlots
8
+ } from "./chunk-VD3EVRUF.mjs";
9
+ import "./chunk-MFI3RDA4.mjs";
10
+ import "./chunk-VOLQMQPK.mjs";
11
+ import "./chunk-Y2EFNT5P.mjs";
12
+ import {
13
+ rootAreaId,
14
+ rootDroppableId,
15
+ rootZone,
16
+ setupZone,
17
+ walkTree
18
+ } from "./chunk-GAUBBDIR.mjs";
19
+ import {
20
+ __spreadProps,
21
+ __spreadValues,
22
+ init_react_import
23
+ } from "./chunk-M6W7YEVX.mjs";
24
+
25
+ // bundle/rsc.tsx
26
+ init_react_import();
27
+
28
+ // components/ServerRender/index.tsx
29
+ init_react_import();
30
+ import { Fragment, jsx } from "react/jsx-runtime";
31
+ function DropZoneRenderItem({
32
+ item,
33
+ data,
34
+ config,
35
+ metadata
36
+ }) {
37
+ const Component = config.components[item.type];
38
+ const props = __spreadProps(__spreadValues({}, item.props), {
39
+ editor: {
40
+ renderDropZone: ({ zone }) => /* @__PURE__ */ jsx(
41
+ DropZoneRender,
42
+ {
43
+ zone,
44
+ data,
45
+ areaId: item.props.id,
46
+ config,
47
+ metadata
48
+ }
49
+ ),
50
+ metadata,
51
+ dragRef: null,
52
+ isEditing: false
53
+ }
54
+ });
55
+ const renderItem = __spreadProps(__spreadValues({}, item), { props });
56
+ const propsWithSlots = useSlots(config, renderItem, (slotProps) => /* @__PURE__ */ jsx(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
57
+ const richtextProps = useRichtextProps(Component == null ? void 0 : Component.fields, propsWithSlots);
58
+ if (!Component) {
59
+ return null;
60
+ }
61
+ return /* @__PURE__ */ jsx(Component.render, __spreadValues(__spreadValues({}, propsWithSlots), richtextProps));
62
+ }
63
+ function DropZoneRender({
64
+ zone,
65
+ data,
66
+ areaId = "root",
67
+ config,
68
+ metadata = {}
69
+ }) {
70
+ let zoneCompound = rootDroppableId;
71
+ let content = (data == null ? void 0 : data.content) || [];
72
+ if (!data || !config) {
73
+ return null;
74
+ }
75
+ if (areaId !== rootAreaId && zone !== rootZone) {
76
+ zoneCompound = `${areaId}:${zone}`;
77
+ content = setupZone(data, zoneCompound).zones[zoneCompound];
78
+ }
79
+ return /* @__PURE__ */ jsx(Fragment, { children: content.map((item) => {
80
+ return /* @__PURE__ */ jsx(
81
+ DropZoneRenderItem,
82
+ {
83
+ item,
84
+ data,
85
+ config,
86
+ metadata
87
+ },
88
+ item.props.id
89
+ );
90
+ }) });
91
+ }
92
+ function Render({
93
+ config,
94
+ data,
95
+ metadata = {}
96
+ }) {
97
+ var _a, _b;
98
+ const rootProps = "props" in data.root ? data.root.props : data.root;
99
+ const title = rootProps.title || "";
100
+ const props = __spreadProps(__spreadValues({}, rootProps), {
101
+ editor: {
102
+ renderDropZone: ({ zone }) => /* @__PURE__ */ jsx(
103
+ DropZoneRender,
104
+ {
105
+ zone,
106
+ data,
107
+ config,
108
+ metadata
109
+ }
110
+ ),
111
+ isEditing: false,
112
+ dragRef: null,
113
+ metadata
114
+ },
115
+ title,
116
+ editMode: false,
117
+ id: "editor-root"
118
+ });
119
+ const propsWithSlots = useSlots(config, { type: "root", props }, (props2) => /* @__PURE__ */ jsx(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
120
+ const richtextProps = useRichtextProps((_a = config.root) == null ? void 0 : _a.fields, props);
121
+ if ((_b = config.root) == null ? void 0 : _b.render) {
122
+ return /* @__PURE__ */ jsx(config.root.render, __spreadProps(__spreadValues(__spreadValues({}, propsWithSlots), richtextProps), { children: /* @__PURE__ */ jsx(
123
+ DropZoneRender,
124
+ {
125
+ config,
126
+ data,
127
+ zone: rootZone,
128
+ metadata
129
+ }
130
+ ) }));
131
+ }
132
+ return /* @__PURE__ */ jsx(
133
+ DropZoneRender,
134
+ {
135
+ config,
136
+ data,
137
+ zone: rootZone,
138
+ metadata
139
+ }
140
+ );
141
+ }
142
+ export {
143
+ Render,
144
+ migrate,
145
+ resolveAllData,
146
+ transformProps,
147
+ walkTree
148
+ };
@@ -0,0 +1,29 @@
1
+ import { C as Config, D as Data, W as WithId, U as UserGenerics, a as Content, b as ComponentData, c as DefaultComponents, d as DefaultComponentProps, e as DefaultRootFieldProps, M as Metadata, R as RootData } from './actions-BCDhqbeL.mjs';
2
+
3
+ type MigrationOptions<UserConfig extends Config> = {
4
+ migrateDynamicZonesForComponent?: {
5
+ [ComponentName in keyof UserConfig["components"]]: (props: WithId<UserGenerics<UserConfig>["UserProps"][ComponentName]>, zones: Record<string, Content>) => ComponentData["props"];
6
+ };
7
+ };
8
+ declare function migrate<UserConfig extends Config = Config>(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions<UserConfig>): Data;
9
+
10
+ type PropTransform<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
11
+ [ComponentName in keyof Components]: (props: Components[ComponentName] & {
12
+ [key: string]: any;
13
+ }) => Components[ComponentName];
14
+ } & {
15
+ root: (props: RootProps & {
16
+ [key: string]: any;
17
+ }) => RootProps;
18
+ }>;
19
+ declare function transformProps<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Components, RootProps>, config?: Config): Data;
20
+
21
+ declare function resolveAllData<Components extends DefaultComponents = DefaultComponents, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, metadata?: Metadata, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Components, RootProps>>;
22
+
23
+ type WalkTreeOptions = {
24
+ parentId: string;
25
+ propName: string;
26
+ };
27
+ declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
28
+
29
+ export { migrate as m, resolveAllData as r, transformProps as t, walkTree as w };
@@ -0,0 +1,29 @@
1
+ import { C as Config, D as Data, W as WithId, U as UserGenerics, a as Content, b as ComponentData, c as DefaultComponents, d as DefaultComponentProps, e as DefaultRootFieldProps, M as Metadata, R as RootData } from './actions-BCDhqbeL.js';
2
+
3
+ type MigrationOptions<UserConfig extends Config> = {
4
+ migrateDynamicZonesForComponent?: {
5
+ [ComponentName in keyof UserConfig["components"]]: (props: WithId<UserGenerics<UserConfig>["UserProps"][ComponentName]>, zones: Record<string, Content>) => ComponentData["props"];
6
+ };
7
+ };
8
+ declare function migrate<UserConfig extends Config = Config>(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions<UserConfig>): Data;
9
+
10
+ type PropTransform<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
11
+ [ComponentName in keyof Components]: (props: Components[ComponentName] & {
12
+ [key: string]: any;
13
+ }) => Components[ComponentName];
14
+ } & {
15
+ root: (props: RootProps & {
16
+ [key: string]: any;
17
+ }) => RootProps;
18
+ }>;
19
+ declare function transformProps<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Components, RootProps>, config?: Config): Data;
20
+
21
+ declare function resolveAllData<Components extends DefaultComponents = DefaultComponents, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, metadata?: Metadata, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Components, RootProps>>;
22
+
23
+ type WalkTreeOptions = {
24
+ parentId: string;
25
+ propName: string;
26
+ };
27
+ declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
28
+
29
+ export { migrate as m, resolveAllData as r, transformProps as t, walkTree as w };
package/package.json ADDED
@@ -0,0 +1,139 @@
1
+ {
2
+ "name": "@reacteditor/core",
3
+ "version": "0.0.1-alpha.0",
4
+ "description": "The open-source visual editor for React",
5
+ "author": "Rami Bitar <rami@frontend.co>",
6
+ "repository": "frontend-inc/react-editor",
7
+ "bugs": "https://github.com/frontend-inc/react-editor/issues",
8
+ "homepage": "https://frontend.co",
9
+ "keywords": [
10
+ "editor",
11
+ "visual",
12
+ "editor",
13
+ "react",
14
+ "drag and drop",
15
+ "dnd",
16
+ "page",
17
+ "website",
18
+ "builder",
19
+ "headless",
20
+ "cms",
21
+ "low-code",
22
+ "no-code",
23
+ "javascript",
24
+ "typescript",
25
+ "WYSIWYG"
26
+ ],
27
+ "private": false,
28
+ "main": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "react-server": {
33
+ "types": "./dist/rsc.d.ts",
34
+ "import": "./dist/rsc.mjs",
35
+ "require": "./dist/rsc.js"
36
+ },
37
+ "default": {
38
+ "types": "./dist/index.d.ts",
39
+ "import": "./dist/index.mjs",
40
+ "require": "./dist/index.js"
41
+ }
42
+ },
43
+ "./rsc": {
44
+ "types": "./dist/rsc.d.ts",
45
+ "import": "./dist/rsc.mjs",
46
+ "require": "./dist/rsc.js"
47
+ },
48
+ "./internal": {
49
+ "types": "./dist/internal.d.ts",
50
+ "import": "./dist/internal.mjs",
51
+ "require": "./dist/internal.js"
52
+ },
53
+ "./react-editor.css": "./dist/index.css",
54
+ "./no-external.css": "./dist/no-external.css",
55
+ "./dist/index.css": "./dist/index.css",
56
+ "./package.json": "./package.json"
57
+ },
58
+ "typesVersions": {
59
+ "*": {
60
+ "rsc": [
61
+ "./dist/rsc.js"
62
+ ]
63
+ }
64
+ },
65
+ "license": "MIT",
66
+ "scripts": {
67
+ "lint": "eslint \"**/*.ts*\"",
68
+ "build": "rm -rf dist && tsup bundle/index.ts bundle/rsc.tsx bundle/no-external.ts bundle/internal.ts",
69
+ "test": "jest",
70
+ "prepare": "cp ../../README.md . && yarn build",
71
+ "postpublish": "rm README.md"
72
+ },
73
+ "files": [
74
+ "dist"
75
+ ],
76
+ "devDependencies": {
77
+ "@juggle/resize-observer": "^3.4.0",
78
+ "@testing-library/jest-dom": "^6.6.3",
79
+ "@testing-library/react": "^16.1.0",
80
+ "@types/deep-diff": "^1.0.3",
81
+ "@types/flat": "^5.0.5",
82
+ "@types/jest": "^29.5.14",
83
+ "@types/object-hash": "^3.0.6",
84
+ "@types/react": "^19.2.7",
85
+ "@types/react-dom": "^19.2.3",
86
+ "@types/uuid": "^10.0.0",
87
+ "css-box-model": "^1.2.1",
88
+ "eslint": "^7.32.0",
89
+ "eslint-config-custom": "*",
90
+ "identity-obj-proxy": "^3.0.0",
91
+ "jest": "^29.7.0",
92
+ "jest-environment-jsdom": "^30.0.0-beta.3",
93
+ "lucide-react": "^0.468.0",
94
+ "ts-jest": "^29.3.4",
95
+ "tsconfig": "*",
96
+ "tsup": "^8.2.4",
97
+ "tsup-config": "*",
98
+ "typescript": "^5.5.4"
99
+ },
100
+ "dependencies": {
101
+ "@dnd-kit/helpers": "0.1.18",
102
+ "@dnd-kit/react": "0.1.18",
103
+ "@radix-ui/react-popover": "^1.1.15",
104
+ "@radix-ui/react-select": "^2.2.6",
105
+ "@tanstack/react-virtual": "^3.13.9",
106
+ "@tiptap/core": "^3.11.1",
107
+ "@tiptap/extension-blockquote": "^3.11.1",
108
+ "@tiptap/extension-bold": "^3.11.1",
109
+ "@tiptap/extension-code": "^3.11.1",
110
+ "@tiptap/extension-code-block": "^3.11.1",
111
+ "@tiptap/extension-document": "^3.11.1",
112
+ "@tiptap/extension-hard-break": "^3.11.1",
113
+ "@tiptap/extension-heading": "^3.11.1",
114
+ "@tiptap/extension-horizontal-rule": "^3.11.1",
115
+ "@tiptap/extension-italic": "^3.11.1",
116
+ "@tiptap/extension-link": "^3.11.1",
117
+ "@tiptap/extension-list": "^3.11.1",
118
+ "@tiptap/extension-paragraph": "^3.11.1",
119
+ "@tiptap/extension-strike": "^3.11.1",
120
+ "@tiptap/extension-text": "^3.11.1",
121
+ "@tiptap/extension-text-align": "^3.11.1",
122
+ "@tiptap/extension-underline": "^3.11.1",
123
+ "@tiptap/html": "^3.11.1",
124
+ "@tiptap/pm": "^3.11.1",
125
+ "@tiptap/react": "^3.11.1",
126
+ "deep-diff": "^1.0.2",
127
+ "fast-equals": "5.2.2",
128
+ "flat": "^5.0.2",
129
+ "happy-dom": "^20.0.10",
130
+ "object-hash": "^3.0.0",
131
+ "react-hotkeys-hook": "^4.6.1",
132
+ "use-debounce": "^9.0.4",
133
+ "uuid": "^9.0.1",
134
+ "zustand": "^5.0.3"
135
+ },
136
+ "peerDependencies": {
137
+ "react": "^18.0.0 || ^19.0.0"
138
+ }
139
+ }