dn-react-text-editor 0.3.1 → 0.3.3
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/README.md +0 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +65 -57
- package/dist/index.mjs +63 -56
- package/dist/{create_text_editor.d.mts → text_editor.d.mts} +3 -4
- package/dist/{create_text_editor.d.ts → text_editor.d.ts} +3 -4
- package/dist/{create_text_editor.js → text_editor.js} +58 -60
- package/dist/{create_text_editor.mjs → text_editor.mjs} +54 -56
- package/dist/text_editor_controller.d.mts +3 -1
- package/dist/text_editor_controller.d.ts +3 -1
- package/dist/text_editor_controller.js +13 -3
- package/dist/text_editor_controller.mjs +11 -2
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { TextEditor, TextEditorProps } from './text_editor.mjs';
|
|
2
2
|
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
|
-
export { TextEditorController, TextEditorControllerProps } from './text_editor_controller.mjs';
|
|
5
|
+
export { ConfigTextEditorOptions, TextEditorController, TextEditorControllerProps, configTextEditorController } from './text_editor_controller.mjs';
|
|
6
6
|
import 'react';
|
|
7
7
|
import 'orderedmap';
|
|
8
8
|
import 'prosemirror-model';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { TextEditor, TextEditorProps } from './text_editor.js';
|
|
2
2
|
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
|
-
export { TextEditorController, TextEditorControllerProps } from './text_editor_controller.js';
|
|
5
|
+
export { ConfigTextEditorOptions, TextEditorController, TextEditorControllerProps, configTextEditorController } from './text_editor_controller.js';
|
|
6
6
|
import 'react';
|
|
7
7
|
import 'orderedmap';
|
|
8
8
|
import 'prosemirror-model';
|
package/dist/index.js
CHANGED
|
@@ -30,16 +30,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
TextEditor: () => TextEditor,
|
|
33
34
|
TextEditorController: () => TextEditorController,
|
|
35
|
+
configTextEditorController: () => configTextEditorController,
|
|
34
36
|
createAttachFile: () => createAttachFile,
|
|
35
37
|
createInnerHTML: () => createInnerHTML,
|
|
36
38
|
createSchema: () => createSchema,
|
|
37
|
-
createTextEditor: () => createTextEditor,
|
|
38
39
|
createTextEditorView: () => createTextEditorView
|
|
39
40
|
});
|
|
40
41
|
module.exports = __toCommonJS(index_exports);
|
|
41
42
|
|
|
42
|
-
// src/
|
|
43
|
+
// src/text_editor.tsx
|
|
43
44
|
var import_react2 = __toESM(require("react"));
|
|
44
45
|
var import_react3 = require("react");
|
|
45
46
|
|
|
@@ -1010,7 +1011,7 @@ var TextEditorController = class {
|
|
|
1010
1011
|
})();
|
|
1011
1012
|
return {
|
|
1012
1013
|
...propsAttributes,
|
|
1013
|
-
class: cn(this.props
|
|
1014
|
+
class: cn(this.props.className, propsAttributes?.class),
|
|
1014
1015
|
spellcheck: propsAttributes?.spellcheck || "false",
|
|
1015
1016
|
style: this.props.style || "width: 100%; height: inherit; outline: none;"
|
|
1016
1017
|
};
|
|
@@ -1073,60 +1074,66 @@ var TextEditorController = class {
|
|
|
1073
1074
|
this.view?.destroy();
|
|
1074
1075
|
}
|
|
1075
1076
|
};
|
|
1077
|
+
var configTextEditorController = (options = {}) => {
|
|
1078
|
+
return (props) => new TextEditorController({
|
|
1079
|
+
...props,
|
|
1080
|
+
className: props.className || options.className,
|
|
1081
|
+
style: props.style || options.style,
|
|
1082
|
+
attachFile: props.attachFile || options.attachFile
|
|
1083
|
+
});
|
|
1084
|
+
};
|
|
1076
1085
|
|
|
1077
|
-
// src/
|
|
1078
|
-
function
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
}
|
|
1129
|
-
return Component;
|
|
1086
|
+
// src/text_editor.tsx
|
|
1087
|
+
function TextEditor({
|
|
1088
|
+
controller: externalController,
|
|
1089
|
+
name,
|
|
1090
|
+
className,
|
|
1091
|
+
autoFocus,
|
|
1092
|
+
onChange,
|
|
1093
|
+
mode,
|
|
1094
|
+
state,
|
|
1095
|
+
editor,
|
|
1096
|
+
defaultValue,
|
|
1097
|
+
updateDelay,
|
|
1098
|
+
placeholder,
|
|
1099
|
+
attachFile,
|
|
1100
|
+
style,
|
|
1101
|
+
...props
|
|
1102
|
+
} = {}) {
|
|
1103
|
+
const containerRef = (0, import_react3.useRef)(null);
|
|
1104
|
+
const innerController = (0, import_react2.useMemo)(
|
|
1105
|
+
() => new TextEditorController({
|
|
1106
|
+
mode,
|
|
1107
|
+
state,
|
|
1108
|
+
editor,
|
|
1109
|
+
autoFocus,
|
|
1110
|
+
placeholder,
|
|
1111
|
+
updateDelay,
|
|
1112
|
+
defaultValue,
|
|
1113
|
+
attachFile,
|
|
1114
|
+
style
|
|
1115
|
+
}),
|
|
1116
|
+
[]
|
|
1117
|
+
);
|
|
1118
|
+
const controller = externalController || innerController;
|
|
1119
|
+
(0, import_react3.useEffect)(() => {
|
|
1120
|
+
const container = containerRef.current;
|
|
1121
|
+
if (!container) {
|
|
1122
|
+
return;
|
|
1123
|
+
}
|
|
1124
|
+
controller.bind(container);
|
|
1125
|
+
return () => {
|
|
1126
|
+
controller.dispose();
|
|
1127
|
+
};
|
|
1128
|
+
}, [controller]);
|
|
1129
|
+
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(
|
|
1130
|
+
TextEditorInput,
|
|
1131
|
+
{
|
|
1132
|
+
name,
|
|
1133
|
+
controller,
|
|
1134
|
+
onChange
|
|
1135
|
+
}
|
|
1136
|
+
));
|
|
1130
1137
|
}
|
|
1131
1138
|
|
|
1132
1139
|
// src/html.tsx
|
|
@@ -1175,10 +1182,11 @@ function createTextEditorView(options = {}) {
|
|
|
1175
1182
|
}
|
|
1176
1183
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1177
1184
|
0 && (module.exports = {
|
|
1185
|
+
TextEditor,
|
|
1178
1186
|
TextEditorController,
|
|
1187
|
+
configTextEditorController,
|
|
1179
1188
|
createAttachFile,
|
|
1180
1189
|
createInnerHTML,
|
|
1181
1190
|
createSchema,
|
|
1182
|
-
createTextEditor,
|
|
1183
1191
|
createTextEditorView
|
|
1184
1192
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/text_editor.tsx
|
|
2
2
|
import React2, {
|
|
3
3
|
useMemo
|
|
4
4
|
} from "react";
|
|
@@ -975,7 +975,7 @@ var TextEditorController = class {
|
|
|
975
975
|
})();
|
|
976
976
|
return {
|
|
977
977
|
...propsAttributes,
|
|
978
|
-
class: cn(this.props
|
|
978
|
+
class: cn(this.props.className, propsAttributes?.class),
|
|
979
979
|
spellcheck: propsAttributes?.spellcheck || "false",
|
|
980
980
|
style: this.props.style || "width: 100%; height: inherit; outline: none;"
|
|
981
981
|
};
|
|
@@ -1038,60 +1038,66 @@ var TextEditorController = class {
|
|
|
1038
1038
|
this.view?.destroy();
|
|
1039
1039
|
}
|
|
1040
1040
|
};
|
|
1041
|
+
var configTextEditorController = (options = {}) => {
|
|
1042
|
+
return (props) => new TextEditorController({
|
|
1043
|
+
...props,
|
|
1044
|
+
className: props.className || options.className,
|
|
1045
|
+
style: props.style || options.style,
|
|
1046
|
+
attachFile: props.attachFile || options.attachFile
|
|
1047
|
+
});
|
|
1048
|
+
};
|
|
1041
1049
|
|
|
1042
|
-
// src/
|
|
1043
|
-
function
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
}
|
|
1094
|
-
return Component;
|
|
1050
|
+
// src/text_editor.tsx
|
|
1051
|
+
function TextEditor({
|
|
1052
|
+
controller: externalController,
|
|
1053
|
+
name,
|
|
1054
|
+
className,
|
|
1055
|
+
autoFocus,
|
|
1056
|
+
onChange,
|
|
1057
|
+
mode,
|
|
1058
|
+
state,
|
|
1059
|
+
editor,
|
|
1060
|
+
defaultValue,
|
|
1061
|
+
updateDelay,
|
|
1062
|
+
placeholder,
|
|
1063
|
+
attachFile,
|
|
1064
|
+
style,
|
|
1065
|
+
...props
|
|
1066
|
+
} = {}) {
|
|
1067
|
+
const containerRef = useRef(null);
|
|
1068
|
+
const innerController = useMemo(
|
|
1069
|
+
() => new TextEditorController({
|
|
1070
|
+
mode,
|
|
1071
|
+
state,
|
|
1072
|
+
editor,
|
|
1073
|
+
autoFocus,
|
|
1074
|
+
placeholder,
|
|
1075
|
+
updateDelay,
|
|
1076
|
+
defaultValue,
|
|
1077
|
+
attachFile,
|
|
1078
|
+
style
|
|
1079
|
+
}),
|
|
1080
|
+
[]
|
|
1081
|
+
);
|
|
1082
|
+
const controller = externalController || innerController;
|
|
1083
|
+
useEffect2(() => {
|
|
1084
|
+
const container = containerRef.current;
|
|
1085
|
+
if (!container) {
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
controller.bind(container);
|
|
1089
|
+
return () => {
|
|
1090
|
+
controller.dispose();
|
|
1091
|
+
};
|
|
1092
|
+
}, [controller]);
|
|
1093
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("div", { ...props, ref: containerRef, className }), /* @__PURE__ */ React2.createElement(
|
|
1094
|
+
TextEditorInput,
|
|
1095
|
+
{
|
|
1096
|
+
name,
|
|
1097
|
+
controller,
|
|
1098
|
+
onChange
|
|
1099
|
+
}
|
|
1100
|
+
));
|
|
1095
1101
|
}
|
|
1096
1102
|
|
|
1097
1103
|
// src/html.tsx
|
|
@@ -1139,10 +1145,11 @@ function createTextEditorView(options = {}) {
|
|
|
1139
1145
|
};
|
|
1140
1146
|
}
|
|
1141
1147
|
export {
|
|
1148
|
+
TextEditor,
|
|
1142
1149
|
TextEditorController,
|
|
1150
|
+
configTextEditorController,
|
|
1143
1151
|
createAttachFile,
|
|
1144
1152
|
createInnerHTML,
|
|
1145
1153
|
createSchema,
|
|
1146
|
-
createTextEditor,
|
|
1147
1154
|
createTextEditorView
|
|
1148
1155
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DetailedHTMLProps, InputHTMLAttributes
|
|
1
|
+
import React, { DetailedHTMLProps, InputHTMLAttributes } from 'react';
|
|
2
2
|
import { TextEditorController, TextEditorControllerProps } from './text_editor_controller.mjs';
|
|
3
3
|
import 'prosemirror-model';
|
|
4
4
|
import 'prosemirror-state';
|
|
@@ -13,7 +13,6 @@ type TextEditorProps = Omit<HTMLElementProps, "ref"> & {
|
|
|
13
13
|
controller?: TextEditorController;
|
|
14
14
|
name?: string;
|
|
15
15
|
} & TextEditorControllerProps;
|
|
16
|
-
|
|
17
|
-
declare function createTextEditor(options?: CreateTextEditorOptions): FC<TextEditorProps>;
|
|
16
|
+
declare function TextEditor({ controller: externalController, name, className, autoFocus, onChange, mode, state, editor, defaultValue, updateDelay, placeholder, attachFile, style, ...props }?: TextEditorProps): React.JSX.Element;
|
|
18
17
|
|
|
19
|
-
export { type TextEditorProps
|
|
18
|
+
export { TextEditor, type TextEditorProps };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DetailedHTMLProps, InputHTMLAttributes
|
|
1
|
+
import React, { DetailedHTMLProps, InputHTMLAttributes } from 'react';
|
|
2
2
|
import { TextEditorController, TextEditorControllerProps } from './text_editor_controller.js';
|
|
3
3
|
import 'prosemirror-model';
|
|
4
4
|
import 'prosemirror-state';
|
|
@@ -13,7 +13,6 @@ type TextEditorProps = Omit<HTMLElementProps, "ref"> & {
|
|
|
13
13
|
controller?: TextEditorController;
|
|
14
14
|
name?: string;
|
|
15
15
|
} & TextEditorControllerProps;
|
|
16
|
-
|
|
17
|
-
declare function createTextEditor(options?: CreateTextEditorOptions): FC<TextEditorProps>;
|
|
16
|
+
declare function TextEditor({ controller: externalController, name, className, autoFocus, onChange, mode, state, editor, defaultValue, updateDelay, placeholder, attachFile, style, ...props }?: TextEditorProps): React.JSX.Element;
|
|
18
17
|
|
|
19
|
-
export { type TextEditorProps
|
|
18
|
+
export { TextEditor, type TextEditorProps };
|
|
@@ -27,12 +27,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// src/
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
33
|
-
|
|
30
|
+
// src/text_editor.tsx
|
|
31
|
+
var text_editor_exports = {};
|
|
32
|
+
__export(text_editor_exports, {
|
|
33
|
+
TextEditor: () => TextEditor
|
|
34
34
|
});
|
|
35
|
-
module.exports = __toCommonJS(
|
|
35
|
+
module.exports = __toCommonJS(text_editor_exports);
|
|
36
36
|
var import_react2 = __toESM(require("react"));
|
|
37
37
|
var import_react3 = require("react");
|
|
38
38
|
|
|
@@ -1003,7 +1003,7 @@ var TextEditorController = class {
|
|
|
1003
1003
|
})();
|
|
1004
1004
|
return {
|
|
1005
1005
|
...propsAttributes,
|
|
1006
|
-
class: cn(this.props
|
|
1006
|
+
class: cn(this.props.className, propsAttributes?.class),
|
|
1007
1007
|
spellcheck: propsAttributes?.spellcheck || "false",
|
|
1008
1008
|
style: this.props.style || "width: 100%; height: inherit; outline: none;"
|
|
1009
1009
|
};
|
|
@@ -1067,61 +1067,59 @@ var TextEditorController = class {
|
|
|
1067
1067
|
}
|
|
1068
1068
|
};
|
|
1069
1069
|
|
|
1070
|
-
// src/
|
|
1071
|
-
function
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
}
|
|
1122
|
-
return Component;
|
|
1070
|
+
// src/text_editor.tsx
|
|
1071
|
+
function TextEditor({
|
|
1072
|
+
controller: externalController,
|
|
1073
|
+
name,
|
|
1074
|
+
className,
|
|
1075
|
+
autoFocus,
|
|
1076
|
+
onChange,
|
|
1077
|
+
mode,
|
|
1078
|
+
state,
|
|
1079
|
+
editor,
|
|
1080
|
+
defaultValue,
|
|
1081
|
+
updateDelay,
|
|
1082
|
+
placeholder,
|
|
1083
|
+
attachFile,
|
|
1084
|
+
style,
|
|
1085
|
+
...props
|
|
1086
|
+
} = {}) {
|
|
1087
|
+
const containerRef = (0, import_react3.useRef)(null);
|
|
1088
|
+
const innerController = (0, import_react2.useMemo)(
|
|
1089
|
+
() => new TextEditorController({
|
|
1090
|
+
mode,
|
|
1091
|
+
state,
|
|
1092
|
+
editor,
|
|
1093
|
+
autoFocus,
|
|
1094
|
+
placeholder,
|
|
1095
|
+
updateDelay,
|
|
1096
|
+
defaultValue,
|
|
1097
|
+
attachFile,
|
|
1098
|
+
style
|
|
1099
|
+
}),
|
|
1100
|
+
[]
|
|
1101
|
+
);
|
|
1102
|
+
const controller = externalController || innerController;
|
|
1103
|
+
(0, import_react3.useEffect)(() => {
|
|
1104
|
+
const container = containerRef.current;
|
|
1105
|
+
if (!container) {
|
|
1106
|
+
return;
|
|
1107
|
+
}
|
|
1108
|
+
controller.bind(container);
|
|
1109
|
+
return () => {
|
|
1110
|
+
controller.dispose();
|
|
1111
|
+
};
|
|
1112
|
+
}, [controller]);
|
|
1113
|
+
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(
|
|
1114
|
+
TextEditorInput,
|
|
1115
|
+
{
|
|
1116
|
+
name,
|
|
1117
|
+
controller,
|
|
1118
|
+
onChange
|
|
1119
|
+
}
|
|
1120
|
+
));
|
|
1123
1121
|
}
|
|
1124
1122
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1125
1123
|
0 && (module.exports = {
|
|
1126
|
-
|
|
1124
|
+
TextEditor
|
|
1127
1125
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/text_editor.tsx
|
|
2
2
|
import React2, {
|
|
3
3
|
useMemo
|
|
4
4
|
} from "react";
|
|
@@ -975,7 +975,7 @@ var TextEditorController = class {
|
|
|
975
975
|
})();
|
|
976
976
|
return {
|
|
977
977
|
...propsAttributes,
|
|
978
|
-
class: cn(this.props
|
|
978
|
+
class: cn(this.props.className, propsAttributes?.class),
|
|
979
979
|
spellcheck: propsAttributes?.spellcheck || "false",
|
|
980
980
|
style: this.props.style || "width: 100%; height: inherit; outline: none;"
|
|
981
981
|
};
|
|
@@ -1039,60 +1039,58 @@ var TextEditorController = class {
|
|
|
1039
1039
|
}
|
|
1040
1040
|
};
|
|
1041
1041
|
|
|
1042
|
-
// src/
|
|
1043
|
-
function
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
}
|
|
1094
|
-
return Component;
|
|
1042
|
+
// src/text_editor.tsx
|
|
1043
|
+
function TextEditor({
|
|
1044
|
+
controller: externalController,
|
|
1045
|
+
name,
|
|
1046
|
+
className,
|
|
1047
|
+
autoFocus,
|
|
1048
|
+
onChange,
|
|
1049
|
+
mode,
|
|
1050
|
+
state,
|
|
1051
|
+
editor,
|
|
1052
|
+
defaultValue,
|
|
1053
|
+
updateDelay,
|
|
1054
|
+
placeholder,
|
|
1055
|
+
attachFile,
|
|
1056
|
+
style,
|
|
1057
|
+
...props
|
|
1058
|
+
} = {}) {
|
|
1059
|
+
const containerRef = useRef(null);
|
|
1060
|
+
const innerController = useMemo(
|
|
1061
|
+
() => new TextEditorController({
|
|
1062
|
+
mode,
|
|
1063
|
+
state,
|
|
1064
|
+
editor,
|
|
1065
|
+
autoFocus,
|
|
1066
|
+
placeholder,
|
|
1067
|
+
updateDelay,
|
|
1068
|
+
defaultValue,
|
|
1069
|
+
attachFile,
|
|
1070
|
+
style
|
|
1071
|
+
}),
|
|
1072
|
+
[]
|
|
1073
|
+
);
|
|
1074
|
+
const controller = externalController || innerController;
|
|
1075
|
+
useEffect2(() => {
|
|
1076
|
+
const container = containerRef.current;
|
|
1077
|
+
if (!container) {
|
|
1078
|
+
return;
|
|
1079
|
+
}
|
|
1080
|
+
controller.bind(container);
|
|
1081
|
+
return () => {
|
|
1082
|
+
controller.dispose();
|
|
1083
|
+
};
|
|
1084
|
+
}, [controller]);
|
|
1085
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("div", { ...props, ref: containerRef, className }), /* @__PURE__ */ React2.createElement(
|
|
1086
|
+
TextEditorInput,
|
|
1087
|
+
{
|
|
1088
|
+
name,
|
|
1089
|
+
controller,
|
|
1090
|
+
onChange
|
|
1091
|
+
}
|
|
1092
|
+
));
|
|
1095
1093
|
}
|
|
1096
1094
|
export {
|
|
1097
|
-
|
|
1095
|
+
TextEditor
|
|
1098
1096
|
};
|
|
@@ -52,5 +52,7 @@ declare class TextEditorController {
|
|
|
52
52
|
};
|
|
53
53
|
dispose(): void;
|
|
54
54
|
}
|
|
55
|
+
type ConfigTextEditorOptions = Pick<TextEditorControllerProps, "className" | "style" | "attachFile">;
|
|
56
|
+
declare const configTextEditorController: (options?: ConfigTextEditorOptions) => (props: TextEditorControllerProps) => TextEditorController;
|
|
55
57
|
|
|
56
|
-
export { TextEditorController, type TextEditorControllerProps };
|
|
58
|
+
export { type ConfigTextEditorOptions, TextEditorController, type TextEditorControllerProps, configTextEditorController };
|
|
@@ -52,5 +52,7 @@ declare class TextEditorController {
|
|
|
52
52
|
};
|
|
53
53
|
dispose(): void;
|
|
54
54
|
}
|
|
55
|
+
type ConfigTextEditorOptions = Pick<TextEditorControllerProps, "className" | "style" | "attachFile">;
|
|
56
|
+
declare const configTextEditorController: (options?: ConfigTextEditorOptions) => (props: TextEditorControllerProps) => TextEditorController;
|
|
55
57
|
|
|
56
|
-
export { TextEditorController, type TextEditorControllerProps };
|
|
58
|
+
export { type ConfigTextEditorOptions, TextEditorController, type TextEditorControllerProps, configTextEditorController };
|
|
@@ -30,7 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/text_editor_controller.tsx
|
|
31
31
|
var text_editor_controller_exports = {};
|
|
32
32
|
__export(text_editor_controller_exports, {
|
|
33
|
-
TextEditorController: () => TextEditorController
|
|
33
|
+
TextEditorController: () => TextEditorController,
|
|
34
|
+
configTextEditorController: () => configTextEditorController
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(text_editor_controller_exports);
|
|
36
37
|
var import_prosemirror_state5 = require("prosemirror-state");
|
|
@@ -967,7 +968,7 @@ var TextEditorController = class {
|
|
|
967
968
|
})();
|
|
968
969
|
return {
|
|
969
970
|
...propsAttributes,
|
|
970
|
-
class: cn(this.props
|
|
971
|
+
class: cn(this.props.className, propsAttributes?.class),
|
|
971
972
|
spellcheck: propsAttributes?.spellcheck || "false",
|
|
972
973
|
style: this.props.style || "width: 100%; height: inherit; outline: none;"
|
|
973
974
|
};
|
|
@@ -1030,7 +1031,16 @@ var TextEditorController = class {
|
|
|
1030
1031
|
this.view?.destroy();
|
|
1031
1032
|
}
|
|
1032
1033
|
};
|
|
1034
|
+
var configTextEditorController = (options = {}) => {
|
|
1035
|
+
return (props) => new TextEditorController({
|
|
1036
|
+
...props,
|
|
1037
|
+
className: props.className || options.className,
|
|
1038
|
+
style: props.style || options.style,
|
|
1039
|
+
attachFile: props.attachFile || options.attachFile
|
|
1040
|
+
});
|
|
1041
|
+
};
|
|
1033
1042
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1034
1043
|
0 && (module.exports = {
|
|
1035
|
-
TextEditorController
|
|
1044
|
+
TextEditorController,
|
|
1045
|
+
configTextEditorController
|
|
1036
1046
|
});
|
|
@@ -935,7 +935,7 @@ var TextEditorController = class {
|
|
|
935
935
|
})();
|
|
936
936
|
return {
|
|
937
937
|
...propsAttributes,
|
|
938
|
-
class: cn(this.props
|
|
938
|
+
class: cn(this.props.className, propsAttributes?.class),
|
|
939
939
|
spellcheck: propsAttributes?.spellcheck || "false",
|
|
940
940
|
style: this.props.style || "width: 100%; height: inherit; outline: none;"
|
|
941
941
|
};
|
|
@@ -998,6 +998,15 @@ var TextEditorController = class {
|
|
|
998
998
|
this.view?.destroy();
|
|
999
999
|
}
|
|
1000
1000
|
};
|
|
1001
|
+
var configTextEditorController = (options = {}) => {
|
|
1002
|
+
return (props) => new TextEditorController({
|
|
1003
|
+
...props,
|
|
1004
|
+
className: props.className || options.className,
|
|
1005
|
+
style: props.style || options.style,
|
|
1006
|
+
attachFile: props.attachFile || options.attachFile
|
|
1007
|
+
});
|
|
1008
|
+
};
|
|
1001
1009
|
export {
|
|
1002
|
-
TextEditorController
|
|
1010
|
+
TextEditorController,
|
|
1011
|
+
configTextEditorController
|
|
1003
1012
|
};
|