dn-react-text-editor 0.3.5 → 0.3.7

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/html.d.mts CHANGED
@@ -1,8 +1,9 @@
1
- import React, { DetailedHTMLProps } from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { DetailedHTMLProps, HTMLAttributes } from 'react';
2
3
 
3
4
  declare function createInnerHTML(raw: string): string;
4
5
  declare function createTextEditorView(options?: {
5
6
  className?: string;
6
- }): ({ className, dangerouslySetInnerHTML, ...props }: DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>) => React.JSX.Element;
7
+ }): ({ className, dangerouslySetInnerHTML, ...props }: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>) => react_jsx_runtime.JSX.Element;
7
8
 
8
9
  export { createInnerHTML, createTextEditorView };
package/dist/html.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import React, { DetailedHTMLProps } from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { DetailedHTMLProps, HTMLAttributes } from 'react';
2
3
 
3
4
  declare function createInnerHTML(raw: string): string;
4
5
  declare function createTextEditorView(options?: {
5
6
  className?: string;
6
- }): ({ className, dangerouslySetInnerHTML, ...props }: DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>) => React.JSX.Element;
7
+ }): ({ className, dangerouslySetInnerHTML, ...props }: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>) => react_jsx_runtime.JSX.Element;
7
8
 
8
9
  export { createInnerHTML, createTextEditorView };
package/dist/html.js CHANGED
@@ -88,7 +88,7 @@ function cn(...classes) {
88
88
  }
89
89
 
90
90
  // src/html.tsx
91
- var import_react = __toESM(require("react"));
91
+ var import_jsx_runtime = require("react/jsx-runtime");
92
92
  function createInnerHTML(raw) {
93
93
  return raw.replace(/<\/p>/g, "<br></p>").replace(/(<p><br><\/p>)+$/g, "").replace(
94
94
  /<code class="language-(\w+)">([\s\S]*?)<\/code>/g,
@@ -116,7 +116,7 @@ function createTextEditorView(options = {}) {
116
116
  dangerouslySetInnerHTML,
117
117
  ...props
118
118
  }) {
119
- return /* @__PURE__ */ import_react.default.createElement(
119
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
120
120
  "div",
121
121
  {
122
122
  ...props,
package/dist/html.mjs CHANGED
@@ -51,7 +51,7 @@ function cn(...classes) {
51
51
  }
52
52
 
53
53
  // src/html.tsx
54
- import React from "react";
54
+ import { jsx } from "react/jsx-runtime";
55
55
  function createInnerHTML(raw) {
56
56
  return raw.replace(/<\/p>/g, "<br></p>").replace(/(<p><br><\/p>)+$/g, "").replace(
57
57
  /<code class="language-(\w+)">([\s\S]*?)<\/code>/g,
@@ -79,7 +79,7 @@ function createTextEditorView(options = {}) {
79
79
  dangerouslySetInnerHTML,
80
80
  ...props
81
81
  }) {
82
- return /* @__PURE__ */ React.createElement(
82
+ return /* @__PURE__ */ jsx(
83
83
  "div",
84
84
  {
85
85
  ...props,
package/dist/index.d.mts CHANGED
@@ -3,6 +3,7 @@ export { createSchema } from './schema.mjs';
3
3
  export { AttachFile, AttachFileOptions, GenerateMetadata, UploadFile, createAttachFile } from './attach_file.mjs';
4
4
  export { createInnerHTML, createTextEditorView } from './html.mjs';
5
5
  export { ConfigTextEditorOptions, TextEditorController, TextEditorControllerProps, configTextEditorController } from './text_editor_controller.mjs';
6
+ import 'react/jsx-runtime';
6
7
  import 'react';
7
8
  import 'orderedmap';
8
9
  import 'prosemirror-model';
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export { createSchema } from './schema.js';
3
3
  export { AttachFile, AttachFileOptions, GenerateMetadata, UploadFile, createAttachFile } from './attach_file.js';
4
4
  export { createInnerHTML, createTextEditorView } from './html.js';
5
5
  export { ConfigTextEditorOptions, TextEditorController, TextEditorControllerProps, configTextEditorController } from './text_editor_controller.js';
6
+ import 'react/jsx-runtime';
6
7
  import 'react';
7
8
  import 'orderedmap';
8
9
  import 'prosemirror-model';
package/dist/index.js CHANGED
@@ -41,14 +41,15 @@ __export(index_exports, {
41
41
  module.exports = __toCommonJS(index_exports);
42
42
 
43
43
  // src/text_editor.tsx
44
- var import_react2 = __toESM(require("react"));
44
+ var import_react2 = require("react");
45
45
  var import_react3 = require("react");
46
46
 
47
47
  // src/input.tsx
48
- var import_react = __toESM(require("react"));
48
+ var import_react = require("react");
49
49
  var import_rxjs = require("rxjs");
50
+ var import_jsx_runtime = require("react/jsx-runtime");
50
51
  function TextEditorInput({ controller, onChange, ...props }) {
51
- const inputRef = import_react.default.useRef(null);
52
+ const inputRef = (0, import_react.useRef)(null);
52
53
  (0, import_react.useEffect)(() => {
53
54
  const sub = controller.subject.pipe(
54
55
  (0, import_rxjs.filter)((tr) => tr.docChanged),
@@ -64,7 +65,7 @@ function TextEditorInput({ controller, onChange, ...props }) {
64
65
  sub.unsubscribe();
65
66
  };
66
67
  }, []);
67
- return /* @__PURE__ */ import_react.default.createElement(
68
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
68
69
  "input",
69
70
  {
70
71
  ...props,
@@ -1087,8 +1088,8 @@ var TextEditorController = class {
1087
1088
  this.view?.destroy();
1088
1089
  }
1089
1090
  };
1090
- var configTextEditorController = (options = {} = {}) => {
1091
- return (props) => new TextEditorController({
1091
+ var configTextEditorController = (options = {}) => {
1092
+ return (props = {}) => new TextEditorController({
1092
1093
  ...props,
1093
1094
  className: props.className || options.className,
1094
1095
  style: props.style || options.style,
@@ -1097,8 +1098,8 @@ var configTextEditorController = (options = {} = {}) => {
1097
1098
  };
1098
1099
 
1099
1100
  // src/text_editor.tsx
1101
+ var import_jsx_runtime2 = require("react/jsx-runtime");
1100
1102
  function TextEditor({
1101
- controller: externalController,
1102
1103
  ref,
1103
1104
  name,
1104
1105
  className,
@@ -1115,7 +1116,7 @@ function TextEditor({
1115
1116
  ...props
1116
1117
  } = {}) {
1117
1118
  const containerRef = (0, import_react3.useRef)(null);
1118
- const innerController = (0, import_react2.useMemo)(
1119
+ const controller = (0, import_react2.useMemo)(
1119
1120
  () => new TextEditorController({
1120
1121
  mode,
1121
1122
  state,
@@ -1129,7 +1130,6 @@ function TextEditor({
1129
1130
  }),
1130
1131
  []
1131
1132
  );
1132
- const controller = externalController || innerController;
1133
1133
  (0, import_react2.useImperativeHandle)(ref, () => controller, [controller]);
1134
1134
  (0, import_react3.useEffect)(() => {
1135
1135
  const container = containerRef.current;
@@ -1141,19 +1141,22 @@ function TextEditor({
1141
1141
  controller.dispose();
1142
1142
  };
1143
1143
  }, [controller]);
1144
- return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("div", { ...props, ref: containerRef, className }), /* @__PURE__ */ import_react2.default.createElement(
1145
- TextEditorInput,
1146
- {
1147
- name,
1148
- controller,
1149
- onChange
1150
- }
1151
- ));
1144
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
1145
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ...props, ref: containerRef, className }),
1146
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1147
+ TextEditorInput,
1148
+ {
1149
+ name,
1150
+ controller,
1151
+ onChange
1152
+ }
1153
+ )
1154
+ ] });
1152
1155
  }
1153
1156
 
1154
1157
  // src/html.tsx
1155
1158
  var import_html_entities = require("html-entities");
1156
- var import_react4 = __toESM(require("react"));
1159
+ var import_jsx_runtime3 = require("react/jsx-runtime");
1157
1160
  function createInnerHTML(raw) {
1158
1161
  return raw.replace(/<\/p>/g, "<br></p>").replace(/(<p><br><\/p>)+$/g, "").replace(
1159
1162
  /<code class="language-(\w+)">([\s\S]*?)<\/code>/g,
@@ -1181,7 +1184,7 @@ function createTextEditorView(options = {}) {
1181
1184
  dangerouslySetInnerHTML,
1182
1185
  ...props
1183
1186
  }) {
1184
- return /* @__PURE__ */ import_react4.default.createElement(
1187
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1185
1188
  "div",
1186
1189
  {
1187
1190
  ...props,
package/dist/index.mjs CHANGED
@@ -1,17 +1,19 @@
1
1
  // src/text_editor.tsx
2
- import React2, {
2
+ import {
3
3
  useImperativeHandle,
4
4
  useMemo
5
5
  } from "react";
6
- import { useEffect as useEffect2, useRef } from "react";
6
+ import { useEffect as useEffect2, useRef as useRef2 } from "react";
7
7
 
8
8
  // src/input.tsx
9
- import React, {
10
- useEffect
9
+ import {
10
+ useEffect,
11
+ useRef
11
12
  } from "react";
12
13
  import { debounceTime, filter } from "rxjs";
14
+ import { jsx } from "react/jsx-runtime";
13
15
  function TextEditorInput({ controller, onChange, ...props }) {
14
- const inputRef = React.useRef(null);
16
+ const inputRef = useRef(null);
15
17
  useEffect(() => {
16
18
  const sub = controller.subject.pipe(
17
19
  filter((tr) => tr.docChanged),
@@ -27,7 +29,7 @@ function TextEditorInput({ controller, onChange, ...props }) {
27
29
  sub.unsubscribe();
28
30
  };
29
31
  }, []);
30
- return /* @__PURE__ */ React.createElement(
32
+ return /* @__PURE__ */ jsx(
31
33
  "input",
32
34
  {
33
35
  ...props,
@@ -1052,8 +1054,8 @@ var TextEditorController = class {
1052
1054
  this.view?.destroy();
1053
1055
  }
1054
1056
  };
1055
- var configTextEditorController = (options = {} = {}) => {
1056
- return (props) => new TextEditorController({
1057
+ var configTextEditorController = (options = {}) => {
1058
+ return (props = {}) => new TextEditorController({
1057
1059
  ...props,
1058
1060
  className: props.className || options.className,
1059
1061
  style: props.style || options.style,
@@ -1062,8 +1064,8 @@ var configTextEditorController = (options = {} = {}) => {
1062
1064
  };
1063
1065
 
1064
1066
  // src/text_editor.tsx
1067
+ import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
1065
1068
  function TextEditor({
1066
- controller: externalController,
1067
1069
  ref,
1068
1070
  name,
1069
1071
  className,
@@ -1079,8 +1081,8 @@ function TextEditor({
1079
1081
  style,
1080
1082
  ...props
1081
1083
  } = {}) {
1082
- const containerRef = useRef(null);
1083
- const innerController = useMemo(
1084
+ const containerRef = useRef2(null);
1085
+ const controller = useMemo(
1084
1086
  () => new TextEditorController({
1085
1087
  mode,
1086
1088
  state,
@@ -1094,7 +1096,6 @@ function TextEditor({
1094
1096
  }),
1095
1097
  []
1096
1098
  );
1097
- const controller = externalController || innerController;
1098
1099
  useImperativeHandle(ref, () => controller, [controller]);
1099
1100
  useEffect2(() => {
1100
1101
  const container = containerRef.current;
@@ -1106,19 +1107,22 @@ function TextEditor({
1106
1107
  controller.dispose();
1107
1108
  };
1108
1109
  }, [controller]);
1109
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("div", { ...props, ref: containerRef, className }), /* @__PURE__ */ React2.createElement(
1110
- TextEditorInput,
1111
- {
1112
- name,
1113
- controller,
1114
- onChange
1115
- }
1116
- ));
1110
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1111
+ /* @__PURE__ */ jsx2("div", { ...props, ref: containerRef, className }),
1112
+ /* @__PURE__ */ jsx2(
1113
+ TextEditorInput,
1114
+ {
1115
+ name,
1116
+ controller,
1117
+ onChange
1118
+ }
1119
+ )
1120
+ ] });
1117
1121
  }
1118
1122
 
1119
1123
  // src/html.tsx
1120
1124
  import { decode } from "html-entities";
1121
- import React3 from "react";
1125
+ import { jsx as jsx3 } from "react/jsx-runtime";
1122
1126
  function createInnerHTML(raw) {
1123
1127
  return raw.replace(/<\/p>/g, "<br></p>").replace(/(<p><br><\/p>)+$/g, "").replace(
1124
1128
  /<code class="language-(\w+)">([\s\S]*?)<\/code>/g,
@@ -1146,7 +1150,7 @@ function createTextEditorView(options = {}) {
1146
1150
  dangerouslySetInnerHTML,
1147
1151
  ...props
1148
1152
  }) {
1149
- return /* @__PURE__ */ React3.createElement(
1153
+ return /* @__PURE__ */ jsx3(
1150
1154
  "div",
1151
1155
  {
1152
1156
  ...props,
package/dist/input.d.mts CHANGED
@@ -1,4 +1,5 @@
1
- import React, { DetailedHTMLProps, HTMLAttributes } from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { DetailedHTMLProps, HTMLAttributes, ChangeEvent } from 'react';
2
3
  import { TextEditorController } from './text_editor_controller.mjs';
3
4
  import 'prosemirror-model';
4
5
  import 'prosemirror-state';
@@ -11,8 +12,8 @@ import 'rxjs';
11
12
  type Props = Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
12
13
  controller: TextEditorController;
13
14
  name?: string;
14
- onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
15
+ onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
15
16
  };
16
- declare function TextEditorInput({ controller, onChange, ...props }: Props): React.JSX.Element;
17
+ declare function TextEditorInput({ controller, onChange, ...props }: Props): react_jsx_runtime.JSX.Element;
17
18
 
18
19
  export { TextEditorInput };
package/dist/input.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import React, { DetailedHTMLProps, HTMLAttributes } from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { DetailedHTMLProps, HTMLAttributes, ChangeEvent } from 'react';
2
3
  import { TextEditorController } from './text_editor_controller.js';
3
4
  import 'prosemirror-model';
4
5
  import 'prosemirror-state';
@@ -11,8 +12,8 @@ import 'rxjs';
11
12
  type Props = Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
12
13
  controller: TextEditorController;
13
14
  name?: string;
14
- onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
15
+ onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
15
16
  };
16
- declare function TextEditorInput({ controller, onChange, ...props }: Props): React.JSX.Element;
17
+ declare function TextEditorInput({ controller, onChange, ...props }: Props): react_jsx_runtime.JSX.Element;
17
18
 
18
19
  export { TextEditorInput };
package/dist/input.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
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
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/input.tsx
@@ -33,10 +23,11 @@ __export(input_exports, {
33
23
  TextEditorInput: () => TextEditorInput
34
24
  });
35
25
  module.exports = __toCommonJS(input_exports);
36
- var import_react = __toESM(require("react"));
26
+ var import_react = require("react");
37
27
  var import_rxjs = require("rxjs");
28
+ var import_jsx_runtime = require("react/jsx-runtime");
38
29
  function TextEditorInput({ controller, onChange, ...props }) {
39
- const inputRef = import_react.default.useRef(null);
30
+ const inputRef = (0, import_react.useRef)(null);
40
31
  (0, import_react.useEffect)(() => {
41
32
  const sub = controller.subject.pipe(
42
33
  (0, import_rxjs.filter)((tr) => tr.docChanged),
@@ -52,7 +43,7 @@ function TextEditorInput({ controller, onChange, ...props }) {
52
43
  sub.unsubscribe();
53
44
  };
54
45
  }, []);
55
- return /* @__PURE__ */ import_react.default.createElement(
46
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
56
47
  "input",
57
48
  {
58
49
  ...props,
package/dist/input.mjs CHANGED
@@ -1,10 +1,12 @@
1
1
  // src/input.tsx
2
- import React, {
3
- useEffect
2
+ import {
3
+ useEffect,
4
+ useRef
4
5
  } from "react";
5
6
  import { debounceTime, filter } from "rxjs";
7
+ import { jsx } from "react/jsx-runtime";
6
8
  function TextEditorInput({ controller, onChange, ...props }) {
7
- const inputRef = React.useRef(null);
9
+ const inputRef = useRef(null);
8
10
  useEffect(() => {
9
11
  const sub = controller.subject.pipe(
10
12
  filter((tr) => tr.docChanged),
@@ -20,7 +22,7 @@ function TextEditorInput({ controller, onChange, ...props }) {
20
22
  sub.unsubscribe();
21
23
  };
22
24
  }, []);
23
- return /* @__PURE__ */ React.createElement(
25
+ return /* @__PURE__ */ jsx(
24
26
  "input",
25
27
  {
26
28
  ...props,
@@ -1,4 +1,5 @@
1
- import React, { DetailedHTMLProps, InputHTMLAttributes, Ref } from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { DetailedHTMLProps, InputHTMLAttributes, Ref } from 'react';
2
3
  import { TextEditorController, TextEditorControllerProps } from './text_editor_controller.mjs';
3
4
  import 'prosemirror-model';
4
5
  import 'prosemirror-state';
@@ -10,10 +11,9 @@ import 'rxjs';
10
11
 
11
12
  type HTMLElementProps = DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
12
13
  type TextEditorProps = Omit<HTMLElementProps, "ref"> & {
13
- controller?: TextEditorController;
14
14
  name?: string;
15
15
  ref?: Ref<TextEditorController>;
16
16
  } & TextEditorControllerProps;
17
- declare function TextEditor({ controller: externalController, ref, name, className, autoFocus, onChange, mode, state, editor, defaultValue, updateDelay, placeholder, attachFile, style, ...props }?: TextEditorProps): React.JSX.Element;
17
+ declare function TextEditor({ ref, name, className, autoFocus, onChange, mode, state, editor, defaultValue, updateDelay, placeholder, attachFile, style, ...props }?: TextEditorProps): react_jsx_runtime.JSX.Element;
18
18
 
19
19
  export { TextEditor, type TextEditorProps };
@@ -1,4 +1,5 @@
1
- import React, { DetailedHTMLProps, InputHTMLAttributes, Ref } from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { DetailedHTMLProps, InputHTMLAttributes, Ref } from 'react';
2
3
  import { TextEditorController, TextEditorControllerProps } from './text_editor_controller.js';
3
4
  import 'prosemirror-model';
4
5
  import 'prosemirror-state';
@@ -10,10 +11,9 @@ import 'rxjs';
10
11
 
11
12
  type HTMLElementProps = DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
12
13
  type TextEditorProps = Omit<HTMLElementProps, "ref"> & {
13
- controller?: TextEditorController;
14
14
  name?: string;
15
15
  ref?: Ref<TextEditorController>;
16
16
  } & TextEditorControllerProps;
17
- declare function TextEditor({ controller: externalController, ref, name, className, autoFocus, onChange, mode, state, editor, defaultValue, updateDelay, placeholder, attachFile, style, ...props }?: TextEditorProps): React.JSX.Element;
17
+ declare function TextEditor({ ref, name, className, autoFocus, onChange, mode, state, editor, defaultValue, updateDelay, placeholder, attachFile, style, ...props }?: TextEditorProps): react_jsx_runtime.JSX.Element;
18
18
 
19
19
  export { TextEditor, type TextEditorProps };
@@ -33,14 +33,15 @@ __export(text_editor_exports, {
33
33
  TextEditor: () => TextEditor
34
34
  });
35
35
  module.exports = __toCommonJS(text_editor_exports);
36
- var import_react2 = __toESM(require("react"));
36
+ var import_react2 = require("react");
37
37
  var import_react3 = require("react");
38
38
 
39
39
  // src/input.tsx
40
- var import_react = __toESM(require("react"));
40
+ var import_react = require("react");
41
41
  var import_rxjs = require("rxjs");
42
+ var import_jsx_runtime = require("react/jsx-runtime");
42
43
  function TextEditorInput({ controller, onChange, ...props }) {
43
- const inputRef = import_react.default.useRef(null);
44
+ const inputRef = (0, import_react.useRef)(null);
44
45
  (0, import_react.useEffect)(() => {
45
46
  const sub = controller.subject.pipe(
46
47
  (0, import_rxjs.filter)((tr) => tr.docChanged),
@@ -56,7 +57,7 @@ function TextEditorInput({ controller, onChange, ...props }) {
56
57
  sub.unsubscribe();
57
58
  };
58
59
  }, []);
59
- return /* @__PURE__ */ import_react.default.createElement(
60
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
60
61
  "input",
61
62
  {
62
63
  ...props,
@@ -1081,8 +1082,8 @@ var TextEditorController = class {
1081
1082
  };
1082
1083
 
1083
1084
  // src/text_editor.tsx
1085
+ var import_jsx_runtime2 = require("react/jsx-runtime");
1084
1086
  function TextEditor({
1085
- controller: externalController,
1086
1087
  ref,
1087
1088
  name,
1088
1089
  className,
@@ -1099,7 +1100,7 @@ function TextEditor({
1099
1100
  ...props
1100
1101
  } = {}) {
1101
1102
  const containerRef = (0, import_react3.useRef)(null);
1102
- const innerController = (0, import_react2.useMemo)(
1103
+ const controller = (0, import_react2.useMemo)(
1103
1104
  () => new TextEditorController({
1104
1105
  mode,
1105
1106
  state,
@@ -1113,7 +1114,6 @@ function TextEditor({
1113
1114
  }),
1114
1115
  []
1115
1116
  );
1116
- const controller = externalController || innerController;
1117
1117
  (0, import_react2.useImperativeHandle)(ref, () => controller, [controller]);
1118
1118
  (0, import_react3.useEffect)(() => {
1119
1119
  const container = containerRef.current;
@@ -1125,14 +1125,17 @@ function TextEditor({
1125
1125
  controller.dispose();
1126
1126
  };
1127
1127
  }, [controller]);
1128
- return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("div", { ...props, ref: containerRef, className }), /* @__PURE__ */ import_react2.default.createElement(
1129
- TextEditorInput,
1130
- {
1131
- name,
1132
- controller,
1133
- onChange
1134
- }
1135
- ));
1128
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
1129
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ...props, ref: containerRef, className }),
1130
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1131
+ TextEditorInput,
1132
+ {
1133
+ name,
1134
+ controller,
1135
+ onChange
1136
+ }
1137
+ )
1138
+ ] });
1136
1139
  }
1137
1140
  // Annotate the CommonJS export names for ESM import in node:
1138
1141
  0 && (module.exports = {
@@ -1,17 +1,19 @@
1
1
  // src/text_editor.tsx
2
- import React2, {
2
+ import {
3
3
  useImperativeHandle,
4
4
  useMemo
5
5
  } from "react";
6
- import { useEffect as useEffect2, useRef } from "react";
6
+ import { useEffect as useEffect2, useRef as useRef2 } from "react";
7
7
 
8
8
  // src/input.tsx
9
- import React, {
10
- useEffect
9
+ import {
10
+ useEffect,
11
+ useRef
11
12
  } from "react";
12
13
  import { debounceTime, filter } from "rxjs";
14
+ import { jsx } from "react/jsx-runtime";
13
15
  function TextEditorInput({ controller, onChange, ...props }) {
14
- const inputRef = React.useRef(null);
16
+ const inputRef = useRef(null);
15
17
  useEffect(() => {
16
18
  const sub = controller.subject.pipe(
17
19
  filter((tr) => tr.docChanged),
@@ -27,7 +29,7 @@ function TextEditorInput({ controller, onChange, ...props }) {
27
29
  sub.unsubscribe();
28
30
  };
29
31
  }, []);
30
- return /* @__PURE__ */ React.createElement(
32
+ return /* @__PURE__ */ jsx(
31
33
  "input",
32
34
  {
33
35
  ...props,
@@ -1054,8 +1056,8 @@ var TextEditorController = class {
1054
1056
  };
1055
1057
 
1056
1058
  // src/text_editor.tsx
1059
+ import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
1057
1060
  function TextEditor({
1058
- controller: externalController,
1059
1061
  ref,
1060
1062
  name,
1061
1063
  className,
@@ -1071,8 +1073,8 @@ function TextEditor({
1071
1073
  style,
1072
1074
  ...props
1073
1075
  } = {}) {
1074
- const containerRef = useRef(null);
1075
- const innerController = useMemo(
1076
+ const containerRef = useRef2(null);
1077
+ const controller = useMemo(
1076
1078
  () => new TextEditorController({
1077
1079
  mode,
1078
1080
  state,
@@ -1086,7 +1088,6 @@ function TextEditor({
1086
1088
  }),
1087
1089
  []
1088
1090
  );
1089
- const controller = externalController || innerController;
1090
1091
  useImperativeHandle(ref, () => controller, [controller]);
1091
1092
  useEffect2(() => {
1092
1093
  const container = containerRef.current;
@@ -1098,14 +1099,17 @@ function TextEditor({
1098
1099
  controller.dispose();
1099
1100
  };
1100
1101
  }, [controller]);
1101
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("div", { ...props, ref: containerRef, className }), /* @__PURE__ */ React2.createElement(
1102
- TextEditorInput,
1103
- {
1104
- name,
1105
- controller,
1106
- onChange
1107
- }
1108
- ));
1102
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1103
+ /* @__PURE__ */ jsx2("div", { ...props, ref: containerRef, className }),
1104
+ /* @__PURE__ */ jsx2(
1105
+ TextEditorInput,
1106
+ {
1107
+ name,
1108
+ controller,
1109
+ onChange
1110
+ }
1111
+ )
1112
+ ] });
1109
1113
  }
1110
1114
  export {
1111
1115
  TextEditor
@@ -56,6 +56,6 @@ declare class TextEditorController {
56
56
  dispose(): void;
57
57
  }
58
58
  type ConfigTextEditorOptions = Pick<TextEditorControllerProps, "className" | "style" | "attachFile">;
59
- declare const configTextEditorController: (options?: ConfigTextEditorOptions) => (props: TextEditorControllerProps) => TextEditorController;
59
+ declare const configTextEditorController: (options?: ConfigTextEditorOptions) => (props?: TextEditorControllerProps) => TextEditorController;
60
60
 
61
61
  export { type ConfigTextEditorOptions, TextEditorController, type TextEditorControllerProps, configTextEditorController };
@@ -56,6 +56,6 @@ declare class TextEditorController {
56
56
  dispose(): void;
57
57
  }
58
58
  type ConfigTextEditorOptions = Pick<TextEditorControllerProps, "className" | "style" | "attachFile">;
59
- declare const configTextEditorController: (options?: ConfigTextEditorOptions) => (props: TextEditorControllerProps) => TextEditorController;
59
+ declare const configTextEditorController: (options?: ConfigTextEditorOptions) => (props?: TextEditorControllerProps) => TextEditorController;
60
60
 
61
61
  export { type ConfigTextEditorOptions, TextEditorController, type TextEditorControllerProps, configTextEditorController };
@@ -1044,8 +1044,8 @@ var TextEditorController = class {
1044
1044
  this.view?.destroy();
1045
1045
  }
1046
1046
  };
1047
- var configTextEditorController = (options = {} = {}) => {
1048
- return (props) => new TextEditorController({
1047
+ var configTextEditorController = (options = {}) => {
1048
+ return (props = {}) => new TextEditorController({
1049
1049
  ...props,
1050
1050
  className: props.className || options.className,
1051
1051
  style: props.style || options.style,
@@ -1011,8 +1011,8 @@ var TextEditorController = class {
1011
1011
  this.view?.destroy();
1012
1012
  }
1013
1013
  };
1014
- var configTextEditorController = (options = {} = {}) => {
1015
- return (props) => new TextEditorController({
1014
+ var configTextEditorController = (options = {}) => {
1015
+ return (props = {}) => new TextEditorController({
1016
1016
  ...props,
1017
1017
  className: props.className || options.className,
1018
1018
  style: props.style || options.style,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dn-react-text-editor",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.js",