@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
@@ -0,0 +1,103 @@
1
+ import {
2
+ __spreadValues,
3
+ init_react_import
4
+ } from "./chunk-M6W7YEVX.mjs";
5
+
6
+ // components/RichTextEditor/extension.ts
7
+ init_react_import();
8
+ import { Extension } from "@tiptap/core";
9
+ import { Blockquote } from "@tiptap/extension-blockquote";
10
+ import { Bold } from "@tiptap/extension-bold";
11
+ import { Code } from "@tiptap/extension-code";
12
+ import { CodeBlock } from "@tiptap/extension-code-block";
13
+ import { Document } from "@tiptap/extension-document";
14
+ import { HardBreak } from "@tiptap/extension-hard-break";
15
+ import { Heading } from "@tiptap/extension-heading";
16
+ import { HorizontalRule } from "@tiptap/extension-horizontal-rule";
17
+ import { Italic } from "@tiptap/extension-italic";
18
+ import { Link } from "@tiptap/extension-link";
19
+ import {
20
+ BulletList,
21
+ ListItem,
22
+ ListKeymap,
23
+ OrderedList
24
+ } from "@tiptap/extension-list";
25
+ import { Paragraph } from "@tiptap/extension-paragraph";
26
+ import { Strike } from "@tiptap/extension-strike";
27
+ import { Text } from "@tiptap/extension-text";
28
+ import TextAlign from "@tiptap/extension-text-align";
29
+ import { Underline } from "@tiptap/extension-underline";
30
+ var defaultEditorRichTextOptions = {
31
+ textAlign: {
32
+ types: ["heading", "paragraph"]
33
+ }
34
+ };
35
+ var EditorRichText = Extension.create({
36
+ name: "editorRichText",
37
+ addExtensions() {
38
+ const extensions = [];
39
+ const options = __spreadValues(__spreadValues({}, this.options), defaultEditorRichTextOptions);
40
+ if (options.bold !== false) {
41
+ extensions.push(Bold.configure(options.bold));
42
+ }
43
+ if (options.blockquote !== false) {
44
+ extensions.push(Blockquote.configure(options.blockquote));
45
+ }
46
+ if (options.code !== false) {
47
+ extensions.push(Code.configure(options.code));
48
+ }
49
+ if (options.codeBlock !== false) {
50
+ extensions.push(CodeBlock.configure(options.codeBlock));
51
+ }
52
+ if (options.document !== false) {
53
+ extensions.push(Document.configure(options.document));
54
+ }
55
+ if (options.hardBreak !== false) {
56
+ extensions.push(HardBreak.configure(options.hardBreak));
57
+ }
58
+ if (options.heading !== false) {
59
+ extensions.push(Heading.configure(options.heading));
60
+ }
61
+ if (options.horizontalRule !== false) {
62
+ extensions.push(HorizontalRule.configure(options.horizontalRule));
63
+ }
64
+ if (options.italic !== false) {
65
+ extensions.push(Italic.configure(options.italic));
66
+ }
67
+ if (options.listItem !== false) {
68
+ extensions.push(ListItem.configure(options.listItem));
69
+ if (options.bulletList !== false) {
70
+ extensions.push(BulletList.configure(options.bulletList));
71
+ }
72
+ if (options.orderedList !== false) {
73
+ extensions.push(OrderedList.configure(options.orderedList));
74
+ }
75
+ }
76
+ if (options.listKeymap !== false) {
77
+ extensions.push(ListKeymap.configure(options == null ? void 0 : options.listKeymap));
78
+ }
79
+ if (options.link !== false) {
80
+ extensions.push(Link.configure(options == null ? void 0 : options.link));
81
+ }
82
+ if (options.paragraph !== false) {
83
+ extensions.push(Paragraph.configure(options.paragraph));
84
+ }
85
+ if (options.strike !== false) {
86
+ extensions.push(Strike.configure(options.strike));
87
+ }
88
+ if (options.text !== false) {
89
+ extensions.push(Text.configure(options.text));
90
+ }
91
+ if (options.textAlign !== false) {
92
+ extensions.push(TextAlign.configure(options.textAlign));
93
+ }
94
+ if (options.underline !== false) {
95
+ extensions.push(Underline.configure(options == null ? void 0 : options.underline));
96
+ }
97
+ return extensions;
98
+ }
99
+ });
100
+
101
+ export {
102
+ EditorRichText
103
+ };
@@ -0,0 +1,53 @@
1
+ import {
2
+ AlignCenter,
3
+ AlignJustify,
4
+ AlignLeft,
5
+ AlignRight
6
+ } from "./chunk-SURZYH7D.mjs";
7
+ import {
8
+ init_react_import
9
+ } from "./chunk-M6W7YEVX.mjs";
10
+
11
+ // components/RichTextMenu/controls/AlignSelect/use-options.ts
12
+ init_react_import();
13
+ import { useMemo } from "react";
14
+ var optionNodes = {
15
+ left: { label: "Left", icon: AlignLeft },
16
+ center: { label: "Center", icon: AlignCenter },
17
+ right: { label: "Right", icon: AlignRight },
18
+ justify: { label: "Justify", icon: AlignJustify }
19
+ };
20
+ var useAlignOptions = (fieldOptions) => {
21
+ var _a;
22
+ let blockOptions = [];
23
+ if ((fieldOptions == null ? void 0 : fieldOptions.textAlign) !== false) {
24
+ if (!((_a = fieldOptions == null ? void 0 : fieldOptions.textAlign) == null ? void 0 : _a.alignments)) {
25
+ blockOptions = ["left", "center", "right", "justify"];
26
+ } else {
27
+ if (fieldOptions == null ? void 0 : fieldOptions.textAlign.alignments.includes("left")) {
28
+ blockOptions.push("left");
29
+ }
30
+ if (fieldOptions == null ? void 0 : fieldOptions.textAlign.alignments.includes("center")) {
31
+ blockOptions.push("center");
32
+ }
33
+ if (fieldOptions == null ? void 0 : fieldOptions.textAlign.alignments.includes("right")) {
34
+ blockOptions.push("right");
35
+ }
36
+ if (fieldOptions == null ? void 0 : fieldOptions.textAlign.alignments.includes("justify")) {
37
+ blockOptions.push("justify");
38
+ }
39
+ }
40
+ }
41
+ return useMemo(
42
+ () => blockOptions.map((item) => ({
43
+ value: item,
44
+ label: optionNodes[item].label,
45
+ icon: optionNodes[item].icon
46
+ })),
47
+ [blockOptions]
48
+ );
49
+ };
50
+
51
+ export {
52
+ useAlignOptions
53
+ };
@@ -0,0 +1,63 @@
1
+ import {
2
+ Heading1,
3
+ Heading2,
4
+ Heading3,
5
+ Heading4,
6
+ Heading5,
7
+ Heading6
8
+ } from "./chunk-SURZYH7D.mjs";
9
+ import {
10
+ init_react_import
11
+ } from "./chunk-M6W7YEVX.mjs";
12
+
13
+ // components/RichTextMenu/controls/HeadingSelect/use-options.ts
14
+ init_react_import();
15
+ import { useMemo } from "react";
16
+ var optionNodes = {
17
+ h1: { label: "Heading 1", icon: Heading1 },
18
+ h2: { label: "Heading 2", icon: Heading2 },
19
+ h3: { label: "Heading 3", icon: Heading3 },
20
+ h4: { label: "Heading 4", icon: Heading4 },
21
+ h5: { label: "Heading 5", icon: Heading5 },
22
+ h6: { label: "Heading 6", icon: Heading6 }
23
+ };
24
+ var useHeadingOptions = (fieldOptions) => {
25
+ var _a;
26
+ let blockOptions = [];
27
+ if ((fieldOptions == null ? void 0 : fieldOptions.heading) !== false) {
28
+ if (!((_a = fieldOptions == null ? void 0 : fieldOptions.heading) == null ? void 0 : _a.levels)) {
29
+ blockOptions = ["h1", "h2", "h3", "h4", "h5", "h6"];
30
+ } else {
31
+ if (fieldOptions == null ? void 0 : fieldOptions.heading.levels.includes(1)) {
32
+ blockOptions.push("h1");
33
+ }
34
+ if (fieldOptions == null ? void 0 : fieldOptions.heading.levels.includes(2)) {
35
+ blockOptions.push("h2");
36
+ }
37
+ if (fieldOptions == null ? void 0 : fieldOptions.heading.levels.includes(3)) {
38
+ blockOptions.push("h3");
39
+ }
40
+ if (fieldOptions == null ? void 0 : fieldOptions.heading.levels.includes(4)) {
41
+ blockOptions.push("h4");
42
+ }
43
+ if (fieldOptions == null ? void 0 : fieldOptions.heading.levels.includes(5)) {
44
+ blockOptions.push("h5");
45
+ }
46
+ if (fieldOptions == null ? void 0 : fieldOptions.heading.levels.includes(6)) {
47
+ blockOptions.push("h6");
48
+ }
49
+ }
50
+ }
51
+ return useMemo(
52
+ () => blockOptions.map((item) => ({
53
+ value: item,
54
+ label: optionNodes[item].label,
55
+ icon: optionNodes[item].icon
56
+ })),
57
+ [blockOptions]
58
+ );
59
+ };
60
+
61
+ export {
62
+ useHeadingOptions
63
+ };
@@ -0,0 +1,114 @@
1
+ import {
2
+ styles_module_default
3
+ } from "./chunk-MFI3RDA4.mjs";
4
+ import {
5
+ LoadedRichTextMenuInner
6
+ } from "./chunk-V2OPYD42.mjs";
7
+ import {
8
+ useAppStore,
9
+ useAppStoreApi
10
+ } from "./chunk-SURZYH7D.mjs";
11
+ import {
12
+ get_class_name_factory_default
13
+ } from "./chunk-Y2EFNT5P.mjs";
14
+ import {
15
+ __spreadValues,
16
+ init_react_import
17
+ } from "./chunk-M6W7YEVX.mjs";
18
+
19
+ // components/RichTextEditor/components/EditorInner.tsx
20
+ init_react_import();
21
+ import {
22
+ memo,
23
+ useCallback
24
+ } from "react";
25
+ import { jsx, jsxs } from "react/jsx-runtime";
26
+ var getClassName = get_class_name_factory_default("RichTextEditor", styles_module_default);
27
+ var EditorInner = memo(
28
+ ({
29
+ children,
30
+ menu,
31
+ readOnly = false,
32
+ field,
33
+ inline = false,
34
+ editor,
35
+ id
36
+ }) => {
37
+ const { initialHeight } = field;
38
+ const isActive = useAppStore(
39
+ (s) => {
40
+ var _a;
41
+ return ((_a = s.currentRichText) == null ? void 0 : _a.id) === id && inline === s.currentRichText.inline;
42
+ }
43
+ );
44
+ const appStoreApi = useAppStoreApi();
45
+ const handleHotkeyCapture = useCallback(
46
+ (event) => {
47
+ var _a, _b;
48
+ if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "i") {
49
+ event.stopPropagation();
50
+ event.preventDefault();
51
+ (_b = editor == null ? void 0 : (_a = editor.commands).toggleItalic) == null ? void 0 : _b.call(_a);
52
+ }
53
+ if (event.key.toLowerCase() === "backspace") {
54
+ event.stopPropagation();
55
+ }
56
+ },
57
+ [editor]
58
+ );
59
+ const handleBlur = useCallback(
60
+ (e) => {
61
+ var _a, _b;
62
+ const targetInMenu = !!((_b = (_a = e.relatedTarget) == null ? void 0 : _a.closest) == null ? void 0 : _b.call(
63
+ _a,
64
+ "[data-editor-rte-menu]"
65
+ ));
66
+ if (e.relatedTarget && !targetInMenu) {
67
+ appStoreApi.setState({
68
+ currentRichText: null
69
+ });
70
+ } else {
71
+ e.stopPropagation();
72
+ }
73
+ },
74
+ [appStoreApi]
75
+ );
76
+ return /* @__PURE__ */ jsxs(
77
+ "div",
78
+ {
79
+ className: getClassName({
80
+ editor: !inline,
81
+ inline,
82
+ isActive,
83
+ disabled: readOnly
84
+ }),
85
+ style: inline ? {} : { height: initialHeight != null ? initialHeight : 192, overflowY: "auto" },
86
+ onKeyDownCapture: handleHotkeyCapture,
87
+ onBlur: handleBlur,
88
+ children: [
89
+ !inline && /* @__PURE__ */ jsx("div", { className: getClassName("menu"), children: menu }),
90
+ children
91
+ ]
92
+ }
93
+ );
94
+ }
95
+ );
96
+ EditorInner.displayName = "EditorInner";
97
+
98
+ // components/RichTextMenu/index.tsx
99
+ init_react_import();
100
+ import { lazy, Suspense } from "react";
101
+ import { jsx as jsx2 } from "react/jsx-runtime";
102
+ var LoadedRichTextMenuFull = lazy(
103
+ () => import("./full-OBTPW7TC.mjs").then((m) => ({
104
+ default: m.LoadedRichTextMenuFull
105
+ }))
106
+ );
107
+ var LoadedRichTextMenu = (props) => {
108
+ return /* @__PURE__ */ jsx2(Suspense, { fallback: /* @__PURE__ */ jsx2(LoadedRichTextMenuInner, __spreadValues({}, props)), children: /* @__PURE__ */ jsx2(LoadedRichTextMenuFull, __spreadValues({}, props)) });
109
+ };
110
+
111
+ export {
112
+ EditorInner,
113
+ LoadedRichTextMenu
114
+ };