dn-react-text-editor 0.3.6 → 0.3.9
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 +3 -2
- package/dist/html.d.ts +3 -2
- package/dist/html.js +2 -2
- package/dist/html.mjs +2 -2
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +24 -21
- package/dist/index.mjs +29 -24
- package/dist/input.d.mts +5 -4
- package/dist/input.d.ts +5 -4
- package/dist/input.js +8 -19
- package/dist/input.mjs +10 -10
- package/dist/plugins/upload_placeholder.d.mts +1 -1
- package/dist/plugins/upload_placeholder.d.ts +1 -1
- package/dist/text_editor.d.mts +6 -3
- package/dist/text_editor.d.ts +6 -3
- package/dist/text_editor.js +22 -19
- package/dist/text_editor.mjs +27 -22
- package/package.json +56 -56
package/dist/html.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
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<
|
|
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
|
|
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<
|
|
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
|
|
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__ */
|
|
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
|
|
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__ */
|
|
82
|
+
return /* @__PURE__ */ jsx(
|
|
83
83
|
"div",
|
|
84
84
|
{
|
|
85
85
|
...props,
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,9 @@ 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';
|
|
8
|
+
import './input.mjs';
|
|
7
9
|
import 'orderedmap';
|
|
8
10
|
import 'prosemirror-model';
|
|
9
11
|
import 'prosemirror-view';
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ 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';
|
|
8
|
+
import './input.js';
|
|
7
9
|
import 'orderedmap';
|
|
8
10
|
import 'prosemirror-model';
|
|
9
11
|
import 'prosemirror-view';
|
package/dist/index.js
CHANGED
|
@@ -41,36 +41,35 @@ __export(index_exports, {
|
|
|
41
41
|
module.exports = __toCommonJS(index_exports);
|
|
42
42
|
|
|
43
43
|
// src/text_editor.tsx
|
|
44
|
-
var import_react2 =
|
|
44
|
+
var import_react2 = require("react");
|
|
45
45
|
var import_react3 = require("react");
|
|
46
46
|
|
|
47
47
|
// src/input.tsx
|
|
48
|
-
var import_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.
|
|
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),
|
|
55
56
|
(0, import_rxjs.debounceTime)(controller.props.updateDelay || 0)
|
|
56
57
|
).subscribe(() => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
58
|
+
const input = inputRef.current;
|
|
59
|
+
if (!input) return;
|
|
60
|
+
input.value = controller.value;
|
|
61
|
+
onChange?.(controller.value);
|
|
62
62
|
});
|
|
63
63
|
return () => {
|
|
64
64
|
sub.unsubscribe();
|
|
65
65
|
};
|
|
66
66
|
}, []);
|
|
67
|
-
return /* @__PURE__ */
|
|
67
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
68
68
|
"input",
|
|
69
69
|
{
|
|
70
70
|
...props,
|
|
71
71
|
ref: inputRef,
|
|
72
72
|
type: "hidden",
|
|
73
|
-
onInput: onChange,
|
|
74
73
|
defaultValue: controller.props.defaultValue
|
|
75
74
|
}
|
|
76
75
|
);
|
|
@@ -1097,6 +1096,7 @@ var configTextEditorController = (options = {}) => {
|
|
|
1097
1096
|
};
|
|
1098
1097
|
|
|
1099
1098
|
// src/text_editor.tsx
|
|
1099
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1100
1100
|
function TextEditor({
|
|
1101
1101
|
ref,
|
|
1102
1102
|
name,
|
|
@@ -1129,7 +1129,7 @@ function TextEditor({
|
|
|
1129
1129
|
[]
|
|
1130
1130
|
);
|
|
1131
1131
|
(0, import_react2.useImperativeHandle)(ref, () => controller, [controller]);
|
|
1132
|
-
(0,
|
|
1132
|
+
(0, import_react2.useLayoutEffect)(() => {
|
|
1133
1133
|
const container = containerRef.current;
|
|
1134
1134
|
if (!container) {
|
|
1135
1135
|
return;
|
|
@@ -1139,19 +1139,22 @@ function TextEditor({
|
|
|
1139
1139
|
controller.dispose();
|
|
1140
1140
|
};
|
|
1141
1141
|
}, [controller]);
|
|
1142
|
-
return /* @__PURE__ */
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1142
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1143
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ...props, ref: containerRef, className }),
|
|
1144
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1145
|
+
TextEditorInput,
|
|
1146
|
+
{
|
|
1147
|
+
name,
|
|
1148
|
+
controller,
|
|
1149
|
+
onChange
|
|
1150
|
+
}
|
|
1151
|
+
)
|
|
1152
|
+
] });
|
|
1150
1153
|
}
|
|
1151
1154
|
|
|
1152
1155
|
// src/html.tsx
|
|
1153
1156
|
var import_html_entities = require("html-entities");
|
|
1154
|
-
var
|
|
1157
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1155
1158
|
function createInnerHTML(raw) {
|
|
1156
1159
|
return raw.replace(/<\/p>/g, "<br></p>").replace(/(<p><br><\/p>)+$/g, "").replace(
|
|
1157
1160
|
/<code class="language-(\w+)">([\s\S]*?)<\/code>/g,
|
|
@@ -1179,7 +1182,7 @@ function createTextEditorView(options = {}) {
|
|
|
1179
1182
|
dangerouslySetInnerHTML,
|
|
1180
1183
|
...props
|
|
1181
1184
|
}) {
|
|
1182
|
-
return /* @__PURE__ */
|
|
1185
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1183
1186
|
"div",
|
|
1184
1187
|
{
|
|
1185
1188
|
...props,
|
package/dist/index.mjs
CHANGED
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
// src/text_editor.tsx
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
3
|
useImperativeHandle,
|
|
4
|
+
useLayoutEffect,
|
|
4
5
|
useMemo
|
|
5
6
|
} from "react";
|
|
6
|
-
import {
|
|
7
|
+
import { useRef as useRef2 } from "react";
|
|
7
8
|
|
|
8
9
|
// src/input.tsx
|
|
9
|
-
import
|
|
10
|
-
useEffect
|
|
10
|
+
import {
|
|
11
|
+
useEffect,
|
|
12
|
+
useRef
|
|
11
13
|
} from "react";
|
|
12
14
|
import { debounceTime, filter } from "rxjs";
|
|
15
|
+
import { jsx } from "react/jsx-runtime";
|
|
13
16
|
function TextEditorInput({ controller, onChange, ...props }) {
|
|
14
|
-
const inputRef =
|
|
17
|
+
const inputRef = useRef(null);
|
|
15
18
|
useEffect(() => {
|
|
16
19
|
const sub = controller.subject.pipe(
|
|
17
20
|
filter((tr) => tr.docChanged),
|
|
18
21
|
debounceTime(controller.props.updateDelay || 0)
|
|
19
22
|
).subscribe(() => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
23
|
+
const input = inputRef.current;
|
|
24
|
+
if (!input) return;
|
|
25
|
+
input.value = controller.value;
|
|
26
|
+
onChange?.(controller.value);
|
|
25
27
|
});
|
|
26
28
|
return () => {
|
|
27
29
|
sub.unsubscribe();
|
|
28
30
|
};
|
|
29
31
|
}, []);
|
|
30
|
-
return /* @__PURE__ */
|
|
32
|
+
return /* @__PURE__ */ jsx(
|
|
31
33
|
"input",
|
|
32
34
|
{
|
|
33
35
|
...props,
|
|
34
36
|
ref: inputRef,
|
|
35
37
|
type: "hidden",
|
|
36
|
-
onInput: onChange,
|
|
37
38
|
defaultValue: controller.props.defaultValue
|
|
38
39
|
}
|
|
39
40
|
);
|
|
@@ -1062,6 +1063,7 @@ var configTextEditorController = (options = {}) => {
|
|
|
1062
1063
|
};
|
|
1063
1064
|
|
|
1064
1065
|
// src/text_editor.tsx
|
|
1066
|
+
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
1065
1067
|
function TextEditor({
|
|
1066
1068
|
ref,
|
|
1067
1069
|
name,
|
|
@@ -1078,7 +1080,7 @@ function TextEditor({
|
|
|
1078
1080
|
style,
|
|
1079
1081
|
...props
|
|
1080
1082
|
} = {}) {
|
|
1081
|
-
const containerRef =
|
|
1083
|
+
const containerRef = useRef2(null);
|
|
1082
1084
|
const controller = useMemo(
|
|
1083
1085
|
() => new TextEditorController({
|
|
1084
1086
|
mode,
|
|
@@ -1094,7 +1096,7 @@ function TextEditor({
|
|
|
1094
1096
|
[]
|
|
1095
1097
|
);
|
|
1096
1098
|
useImperativeHandle(ref, () => controller, [controller]);
|
|
1097
|
-
|
|
1099
|
+
useLayoutEffect(() => {
|
|
1098
1100
|
const container = containerRef.current;
|
|
1099
1101
|
if (!container) {
|
|
1100
1102
|
return;
|
|
@@ -1104,19 +1106,22 @@ function TextEditor({
|
|
|
1104
1106
|
controller.dispose();
|
|
1105
1107
|
};
|
|
1106
1108
|
}, [controller]);
|
|
1107
|
-
return /* @__PURE__ */
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1109
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1110
|
+
/* @__PURE__ */ jsx2("div", { ...props, ref: containerRef, className }),
|
|
1111
|
+
/* @__PURE__ */ jsx2(
|
|
1112
|
+
TextEditorInput,
|
|
1113
|
+
{
|
|
1114
|
+
name,
|
|
1115
|
+
controller,
|
|
1116
|
+
onChange
|
|
1117
|
+
}
|
|
1118
|
+
)
|
|
1119
|
+
] });
|
|
1115
1120
|
}
|
|
1116
1121
|
|
|
1117
1122
|
// src/html.tsx
|
|
1118
1123
|
import { decode } from "html-entities";
|
|
1119
|
-
import
|
|
1124
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
1120
1125
|
function createInnerHTML(raw) {
|
|
1121
1126
|
return raw.replace(/<\/p>/g, "<br></p>").replace(/(<p><br><\/p>)+$/g, "").replace(
|
|
1122
1127
|
/<code class="language-(\w+)">([\s\S]*?)<\/code>/g,
|
|
@@ -1144,7 +1149,7 @@ function createTextEditorView(options = {}) {
|
|
|
1144
1149
|
dangerouslySetInnerHTML,
|
|
1145
1150
|
...props
|
|
1146
1151
|
}) {
|
|
1147
|
-
return /* @__PURE__ */
|
|
1152
|
+
return /* @__PURE__ */ jsx3(
|
|
1148
1153
|
"div",
|
|
1149
1154
|
{
|
|
1150
1155
|
...props,
|
package/dist/input.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { DetailedHTMLProps, HTMLAttributes } from 'react';
|
|
2
3
|
import { TextEditorController } from './text_editor_controller.mjs';
|
|
3
4
|
import 'prosemirror-model';
|
|
4
5
|
import 'prosemirror-state';
|
|
@@ -8,11 +9,11 @@ import './schema.mjs';
|
|
|
8
9
|
import 'orderedmap';
|
|
9
10
|
import 'rxjs';
|
|
10
11
|
|
|
11
|
-
type Props = Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
12
|
+
type Props = Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref" | "onChange"> & {
|
|
12
13
|
controller: TextEditorController;
|
|
13
14
|
name?: string;
|
|
14
|
-
onChange?: (
|
|
15
|
+
onChange?: (value: string) => void;
|
|
15
16
|
};
|
|
16
|
-
declare function TextEditorInput({ controller, onChange, ...props }: Props):
|
|
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
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { DetailedHTMLProps, HTMLAttributes } from 'react';
|
|
2
3
|
import { TextEditorController } from './text_editor_controller.js';
|
|
3
4
|
import 'prosemirror-model';
|
|
4
5
|
import 'prosemirror-state';
|
|
@@ -8,11 +9,11 @@ import './schema.js';
|
|
|
8
9
|
import 'orderedmap';
|
|
9
10
|
import 'rxjs';
|
|
10
11
|
|
|
11
|
-
type Props = Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
12
|
+
type Props = Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref" | "onChange"> & {
|
|
12
13
|
controller: TextEditorController;
|
|
13
14
|
name?: string;
|
|
14
|
-
onChange?: (
|
|
15
|
+
onChange?: (value: string) => void;
|
|
15
16
|
};
|
|
16
|
-
declare function TextEditorInput({ controller, onChange, ...props }: Props):
|
|
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,32 +23,31 @@ __export(input_exports, {
|
|
|
33
23
|
TextEditorInput: () => TextEditorInput
|
|
34
24
|
});
|
|
35
25
|
module.exports = __toCommonJS(input_exports);
|
|
36
|
-
var import_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.
|
|
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),
|
|
43
34
|
(0, import_rxjs.debounceTime)(controller.props.updateDelay || 0)
|
|
44
35
|
).subscribe(() => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
36
|
+
const input = inputRef.current;
|
|
37
|
+
if (!input) return;
|
|
38
|
+
input.value = controller.value;
|
|
39
|
+
onChange?.(controller.value);
|
|
50
40
|
});
|
|
51
41
|
return () => {
|
|
52
42
|
sub.unsubscribe();
|
|
53
43
|
};
|
|
54
44
|
}, []);
|
|
55
|
-
return /* @__PURE__ */
|
|
45
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
56
46
|
"input",
|
|
57
47
|
{
|
|
58
48
|
...props,
|
|
59
49
|
ref: inputRef,
|
|
60
50
|
type: "hidden",
|
|
61
|
-
onInput: onChange,
|
|
62
51
|
defaultValue: controller.props.defaultValue
|
|
63
52
|
}
|
|
64
53
|
);
|
package/dist/input.mjs
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
// src/input.tsx
|
|
2
|
-
import
|
|
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 =
|
|
9
|
+
const inputRef = useRef(null);
|
|
8
10
|
useEffect(() => {
|
|
9
11
|
const sub = controller.subject.pipe(
|
|
10
12
|
filter((tr) => tr.docChanged),
|
|
11
13
|
debounceTime(controller.props.updateDelay || 0)
|
|
12
14
|
).subscribe(() => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
15
|
+
const input = inputRef.current;
|
|
16
|
+
if (!input) return;
|
|
17
|
+
input.value = controller.value;
|
|
18
|
+
onChange?.(controller.value);
|
|
18
19
|
});
|
|
19
20
|
return () => {
|
|
20
21
|
sub.unsubscribe();
|
|
21
22
|
};
|
|
22
23
|
}, []);
|
|
23
|
-
return /* @__PURE__ */
|
|
24
|
+
return /* @__PURE__ */ jsx(
|
|
24
25
|
"input",
|
|
25
26
|
{
|
|
26
27
|
...props,
|
|
27
28
|
ref: inputRef,
|
|
28
29
|
type: "hidden",
|
|
29
|
-
onInput: onChange,
|
|
30
30
|
defaultValue: controller.props.defaultValue
|
|
31
31
|
}
|
|
32
32
|
);
|
package/dist/text_editor.d.mts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { DetailedHTMLProps, InputHTMLAttributes, Ref } from 'react';
|
|
3
|
+
import { TextEditorInput } from './input.mjs';
|
|
2
4
|
import { TextEditorController, TextEditorControllerProps } from './text_editor_controller.mjs';
|
|
3
5
|
import 'prosemirror-model';
|
|
4
6
|
import 'prosemirror-state';
|
|
@@ -9,10 +11,11 @@ import 'orderedmap';
|
|
|
9
11
|
import 'rxjs';
|
|
10
12
|
|
|
11
13
|
type HTMLElementProps = DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
12
|
-
type TextEditorProps = Omit<HTMLElementProps, "ref"> & {
|
|
14
|
+
type TextEditorProps = Omit<HTMLElementProps, "ref" | "onChange"> & {
|
|
13
15
|
name?: string;
|
|
14
16
|
ref?: Ref<TextEditorController>;
|
|
17
|
+
onChange?: Parameters<typeof TextEditorInput>[0]["onChange"];
|
|
15
18
|
} & TextEditorControllerProps;
|
|
16
|
-
declare function TextEditor({ ref, name, className, autoFocus, onChange, mode, state, editor, defaultValue, updateDelay, placeholder, attachFile, style, ...props }?: TextEditorProps):
|
|
19
|
+
declare function TextEditor({ ref, name, className, autoFocus, onChange, mode, state, editor, defaultValue, updateDelay, placeholder, attachFile, style, ...props }?: TextEditorProps): react_jsx_runtime.JSX.Element;
|
|
17
20
|
|
|
18
21
|
export { TextEditor, type TextEditorProps };
|
package/dist/text_editor.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { DetailedHTMLProps, InputHTMLAttributes, Ref } from 'react';
|
|
3
|
+
import { TextEditorInput } from './input.js';
|
|
2
4
|
import { TextEditorController, TextEditorControllerProps } from './text_editor_controller.js';
|
|
3
5
|
import 'prosemirror-model';
|
|
4
6
|
import 'prosemirror-state';
|
|
@@ -9,10 +11,11 @@ import 'orderedmap';
|
|
|
9
11
|
import 'rxjs';
|
|
10
12
|
|
|
11
13
|
type HTMLElementProps = DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
12
|
-
type TextEditorProps = Omit<HTMLElementProps, "ref"> & {
|
|
14
|
+
type TextEditorProps = Omit<HTMLElementProps, "ref" | "onChange"> & {
|
|
13
15
|
name?: string;
|
|
14
16
|
ref?: Ref<TextEditorController>;
|
|
17
|
+
onChange?: Parameters<typeof TextEditorInput>[0]["onChange"];
|
|
15
18
|
} & TextEditorControllerProps;
|
|
16
|
-
declare function TextEditor({ ref, name, className, autoFocus, onChange, mode, state, editor, defaultValue, updateDelay, placeholder, attachFile, style, ...props }?: TextEditorProps):
|
|
19
|
+
declare function TextEditor({ ref, name, className, autoFocus, onChange, mode, state, editor, defaultValue, updateDelay, placeholder, attachFile, style, ...props }?: TextEditorProps): react_jsx_runtime.JSX.Element;
|
|
17
20
|
|
|
18
21
|
export { TextEditor, type TextEditorProps };
|
package/dist/text_editor.js
CHANGED
|
@@ -33,36 +33,35 @@ __export(text_editor_exports, {
|
|
|
33
33
|
TextEditor: () => TextEditor
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(text_editor_exports);
|
|
36
|
-
var import_react2 =
|
|
36
|
+
var import_react2 = require("react");
|
|
37
37
|
var import_react3 = require("react");
|
|
38
38
|
|
|
39
39
|
// src/input.tsx
|
|
40
|
-
var import_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.
|
|
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),
|
|
47
48
|
(0, import_rxjs.debounceTime)(controller.props.updateDelay || 0)
|
|
48
49
|
).subscribe(() => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
50
|
+
const input = inputRef.current;
|
|
51
|
+
if (!input) return;
|
|
52
|
+
input.value = controller.value;
|
|
53
|
+
onChange?.(controller.value);
|
|
54
54
|
});
|
|
55
55
|
return () => {
|
|
56
56
|
sub.unsubscribe();
|
|
57
57
|
};
|
|
58
58
|
}, []);
|
|
59
|
-
return /* @__PURE__ */
|
|
59
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
60
60
|
"input",
|
|
61
61
|
{
|
|
62
62
|
...props,
|
|
63
63
|
ref: inputRef,
|
|
64
64
|
type: "hidden",
|
|
65
|
-
onInput: onChange,
|
|
66
65
|
defaultValue: controller.props.defaultValue
|
|
67
66
|
}
|
|
68
67
|
);
|
|
@@ -1081,6 +1080,7 @@ var TextEditorController = class {
|
|
|
1081
1080
|
};
|
|
1082
1081
|
|
|
1083
1082
|
// src/text_editor.tsx
|
|
1083
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1084
1084
|
function TextEditor({
|
|
1085
1085
|
ref,
|
|
1086
1086
|
name,
|
|
@@ -1113,7 +1113,7 @@ function TextEditor({
|
|
|
1113
1113
|
[]
|
|
1114
1114
|
);
|
|
1115
1115
|
(0, import_react2.useImperativeHandle)(ref, () => controller, [controller]);
|
|
1116
|
-
(0,
|
|
1116
|
+
(0, import_react2.useLayoutEffect)(() => {
|
|
1117
1117
|
const container = containerRef.current;
|
|
1118
1118
|
if (!container) {
|
|
1119
1119
|
return;
|
|
@@ -1123,14 +1123,17 @@ function TextEditor({
|
|
|
1123
1123
|
controller.dispose();
|
|
1124
1124
|
};
|
|
1125
1125
|
}, [controller]);
|
|
1126
|
-
return /* @__PURE__ */
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1126
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1127
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ...props, ref: containerRef, className }),
|
|
1128
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1129
|
+
TextEditorInput,
|
|
1130
|
+
{
|
|
1131
|
+
name,
|
|
1132
|
+
controller,
|
|
1133
|
+
onChange
|
|
1134
|
+
}
|
|
1135
|
+
)
|
|
1136
|
+
] });
|
|
1134
1137
|
}
|
|
1135
1138
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1136
1139
|
0 && (module.exports = {
|
package/dist/text_editor.mjs
CHANGED
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
// src/text_editor.tsx
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
3
|
useImperativeHandle,
|
|
4
|
+
useLayoutEffect,
|
|
4
5
|
useMemo
|
|
5
6
|
} from "react";
|
|
6
|
-
import {
|
|
7
|
+
import { useRef as useRef2 } from "react";
|
|
7
8
|
|
|
8
9
|
// src/input.tsx
|
|
9
|
-
import
|
|
10
|
-
useEffect
|
|
10
|
+
import {
|
|
11
|
+
useEffect,
|
|
12
|
+
useRef
|
|
11
13
|
} from "react";
|
|
12
14
|
import { debounceTime, filter } from "rxjs";
|
|
15
|
+
import { jsx } from "react/jsx-runtime";
|
|
13
16
|
function TextEditorInput({ controller, onChange, ...props }) {
|
|
14
|
-
const inputRef =
|
|
17
|
+
const inputRef = useRef(null);
|
|
15
18
|
useEffect(() => {
|
|
16
19
|
const sub = controller.subject.pipe(
|
|
17
20
|
filter((tr) => tr.docChanged),
|
|
18
21
|
debounceTime(controller.props.updateDelay || 0)
|
|
19
22
|
).subscribe(() => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
23
|
+
const input = inputRef.current;
|
|
24
|
+
if (!input) return;
|
|
25
|
+
input.value = controller.value;
|
|
26
|
+
onChange?.(controller.value);
|
|
25
27
|
});
|
|
26
28
|
return () => {
|
|
27
29
|
sub.unsubscribe();
|
|
28
30
|
};
|
|
29
31
|
}, []);
|
|
30
|
-
return /* @__PURE__ */
|
|
32
|
+
return /* @__PURE__ */ jsx(
|
|
31
33
|
"input",
|
|
32
34
|
{
|
|
33
35
|
...props,
|
|
34
36
|
ref: inputRef,
|
|
35
37
|
type: "hidden",
|
|
36
|
-
onInput: onChange,
|
|
37
38
|
defaultValue: controller.props.defaultValue
|
|
38
39
|
}
|
|
39
40
|
);
|
|
@@ -1054,6 +1055,7 @@ var TextEditorController = class {
|
|
|
1054
1055
|
};
|
|
1055
1056
|
|
|
1056
1057
|
// src/text_editor.tsx
|
|
1058
|
+
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
1057
1059
|
function TextEditor({
|
|
1058
1060
|
ref,
|
|
1059
1061
|
name,
|
|
@@ -1070,7 +1072,7 @@ function TextEditor({
|
|
|
1070
1072
|
style,
|
|
1071
1073
|
...props
|
|
1072
1074
|
} = {}) {
|
|
1073
|
-
const containerRef =
|
|
1075
|
+
const containerRef = useRef2(null);
|
|
1074
1076
|
const controller = useMemo(
|
|
1075
1077
|
() => new TextEditorController({
|
|
1076
1078
|
mode,
|
|
@@ -1086,7 +1088,7 @@ function TextEditor({
|
|
|
1086
1088
|
[]
|
|
1087
1089
|
);
|
|
1088
1090
|
useImperativeHandle(ref, () => controller, [controller]);
|
|
1089
|
-
|
|
1091
|
+
useLayoutEffect(() => {
|
|
1090
1092
|
const container = containerRef.current;
|
|
1091
1093
|
if (!container) {
|
|
1092
1094
|
return;
|
|
@@ -1096,14 +1098,17 @@ function TextEditor({
|
|
|
1096
1098
|
controller.dispose();
|
|
1097
1099
|
};
|
|
1098
1100
|
}, [controller]);
|
|
1099
|
-
return /* @__PURE__ */
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1101
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1102
|
+
/* @__PURE__ */ jsx2("div", { ...props, ref: containerRef, className }),
|
|
1103
|
+
/* @__PURE__ */ jsx2(
|
|
1104
|
+
TextEditorInput,
|
|
1105
|
+
{
|
|
1106
|
+
name,
|
|
1107
|
+
controller,
|
|
1108
|
+
onChange
|
|
1109
|
+
}
|
|
1110
|
+
)
|
|
1111
|
+
] });
|
|
1107
1112
|
}
|
|
1108
1113
|
export {
|
|
1109
1114
|
TextEditor
|
package/package.json
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
"name": "dn-react-text-editor",
|
|
3
|
+
"version": "0.3.9",
|
|
4
|
+
"types": "./dist/index.d.ts",
|
|
5
|
+
"main": "./dist/index.mjs",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./prosemirror": {
|
|
15
|
+
"types": "./dist/prosemirror/index.d.ts",
|
|
16
|
+
"import": "./dist/prosemirror/index.mjs",
|
|
17
|
+
"require": "./dist/prosemirror/index.js"
|
|
18
|
+
}
|
|
13
19
|
},
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "NODE_OPTIONS='--max-old-space-size=16384' tsup",
|
|
22
|
+
"dev": "tsup --watch"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/dndnsoft/dn-react-text-editor.git"
|
|
27
|
+
},
|
|
28
|
+
"author": "",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/dndnsoft/dn-react-text-editor/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/dndnsoft/dn-react-text-editor#readme",
|
|
34
|
+
"description": "",
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^24.10.1",
|
|
37
|
+
"@types/react": "^19",
|
|
38
|
+
"@types/react-dom": "^19",
|
|
39
|
+
"tsup": "^8.5.1",
|
|
40
|
+
"typescript": "^5.7.3"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"react": "^19",
|
|
44
|
+
"react-dom": "^19"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"highlight.js": "^11.11.1",
|
|
48
|
+
"html-entities": "^2.6.0",
|
|
49
|
+
"prosemirror-commands": "^1.7.1",
|
|
50
|
+
"prosemirror-highlightjs": "^0.9.1",
|
|
51
|
+
"prosemirror-history": "^1.5.0",
|
|
52
|
+
"prosemirror-keymap": "^1.2.3",
|
|
53
|
+
"prosemirror-model": "^1.25.4",
|
|
54
|
+
"prosemirror-schema-list": "^1.5.1",
|
|
55
|
+
"prosemirror-state": "^1.4.4",
|
|
56
|
+
"prosemirror-view": "^1.41.3",
|
|
57
|
+
"rxjs": "^7.8.2"
|
|
18
58
|
}
|
|
19
|
-
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "NODE_OPTIONS='--max-old-space-size=16384' tsup",
|
|
22
|
-
"dev": "tsup --watch"
|
|
23
|
-
},
|
|
24
|
-
"repository": {
|
|
25
|
-
"type": "git",
|
|
26
|
-
"url": "git+https://github.com/dndnsoft/dn-react-text-editor.git"
|
|
27
|
-
},
|
|
28
|
-
"author": "",
|
|
29
|
-
"license": "MIT",
|
|
30
|
-
"bugs": {
|
|
31
|
-
"url": "https://github.com/dndnsoft/dn-react-text-editor/issues"
|
|
32
|
-
},
|
|
33
|
-
"homepage": "https://github.com/dndnsoft/dn-react-text-editor#readme",
|
|
34
|
-
"description": "",
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"@types/node": "^24.10.1",
|
|
37
|
-
"@types/react": "^19",
|
|
38
|
-
"@types/react-dom": "^19",
|
|
39
|
-
"tsup": "^8.5.1",
|
|
40
|
-
"typescript": "^5.7.3"
|
|
41
|
-
},
|
|
42
|
-
"peerDependencies": {
|
|
43
|
-
"react": "^19",
|
|
44
|
-
"react-dom": "^19"
|
|
45
|
-
},
|
|
46
|
-
"dependencies": {
|
|
47
|
-
"highlight.js": "^11.11.1",
|
|
48
|
-
"html-entities": "^2.6.0",
|
|
49
|
-
"prosemirror-commands": "^1.7.1",
|
|
50
|
-
"prosemirror-highlightjs": "^0.9.1",
|
|
51
|
-
"prosemirror-history": "^1.5.0",
|
|
52
|
-
"prosemirror-keymap": "^1.2.3",
|
|
53
|
-
"prosemirror-model": "^1.25.4",
|
|
54
|
-
"prosemirror-schema-list": "^1.5.1",
|
|
55
|
-
"prosemirror-state": "^1.4.4",
|
|
56
|
-
"prosemirror-view": "^1.41.3",
|
|
57
|
-
"rxjs": "^7.8.2"
|
|
58
|
-
}
|
|
59
|
-
}
|
|
59
|
+
}
|