dn-react-text-editor 0.2.0 → 0.2.1
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/create_text_editor.d.mts +2 -2
- package/dist/create_text_editor.d.ts +2 -2
- package/dist/create_text_editor.js +18 -7
- package/dist/create_text_editor.mjs +18 -7
- package/dist/index.js +18 -7
- package/dist/index.mjs +18 -7
- package/dist/text_editor_controller.js +4 -4
- package/dist/text_editor_controller.mjs +4 -4
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DetailedHTMLProps, InputHTMLAttributes, Ref, FC } from 'react';
|
|
2
2
|
import { Transaction } from 'prosemirror-state';
|
|
3
3
|
import { EditorView } from 'prosemirror-view';
|
|
4
4
|
import { createSchema } from './schema.mjs';
|
|
@@ -23,6 +23,6 @@ type TextEditorProps = Omit<HTMLElementProps, "ref"> & {
|
|
|
23
23
|
ref?: Ref<TextEditorController>;
|
|
24
24
|
name?: string;
|
|
25
25
|
} & TextEditorControllerProps;
|
|
26
|
-
declare function createTextEditor(options?: CreateTextEditorOptions):
|
|
26
|
+
declare function createTextEditor(options?: CreateTextEditorOptions): FC<TextEditorProps>;
|
|
27
27
|
|
|
28
28
|
export { type TextEditorController, type TextEditorProps, createTextEditor };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DetailedHTMLProps, InputHTMLAttributes, Ref, FC } from 'react';
|
|
2
2
|
import { Transaction } from 'prosemirror-state';
|
|
3
3
|
import { EditorView } from 'prosemirror-view';
|
|
4
4
|
import { createSchema } from './schema.js';
|
|
@@ -23,6 +23,6 @@ type TextEditorProps = Omit<HTMLElementProps, "ref"> & {
|
|
|
23
23
|
ref?: Ref<TextEditorController>;
|
|
24
24
|
name?: string;
|
|
25
25
|
} & TextEditorControllerProps;
|
|
26
|
-
declare function createTextEditor(options?: CreateTextEditorOptions):
|
|
26
|
+
declare function createTextEditor(options?: CreateTextEditorOptions): FC<TextEditorProps>;
|
|
27
27
|
|
|
28
28
|
export { type TextEditorController, type TextEditorProps, createTextEditor };
|
|
@@ -916,7 +916,7 @@ function createAttachFile({
|
|
|
916
916
|
var import_prosemirror_model3 = require("prosemirror-model");
|
|
917
917
|
var import_rxjs2 = require("rxjs");
|
|
918
918
|
function createTextEditorController(container, schema, options, {
|
|
919
|
-
mode,
|
|
919
|
+
mode = "html",
|
|
920
920
|
state,
|
|
921
921
|
editor,
|
|
922
922
|
defaultValue,
|
|
@@ -928,10 +928,10 @@ function createTextEditorController(container, schema, options, {
|
|
|
928
928
|
const prosemirrorSerializer = import_prosemirror_model3.DOMSerializer.fromSchema(schema);
|
|
929
929
|
const wrapper = document.createElement("div");
|
|
930
930
|
const toInnerHTML = (value) => {
|
|
931
|
-
if (mode === "
|
|
932
|
-
return value;
|
|
931
|
+
if (mode === "text") {
|
|
932
|
+
return value.split("\n").map((line) => `<p>${line}</p>`).join("");
|
|
933
933
|
}
|
|
934
|
-
return value
|
|
934
|
+
return value;
|
|
935
935
|
};
|
|
936
936
|
wrapper.innerHTML = toInnerHTML(defaultValue ? String(defaultValue) : "");
|
|
937
937
|
const attachFile = createAttachFile({
|
|
@@ -1037,10 +1037,13 @@ function createTextEditor(options = {}) {
|
|
|
1037
1037
|
ref,
|
|
1038
1038
|
className,
|
|
1039
1039
|
autoFocus,
|
|
1040
|
-
placeholder,
|
|
1041
|
-
defaultValue,
|
|
1042
1040
|
onChange,
|
|
1041
|
+
mode,
|
|
1042
|
+
state,
|
|
1043
|
+
editor,
|
|
1044
|
+
defaultValue,
|
|
1043
1045
|
updateDelay,
|
|
1046
|
+
placeholder,
|
|
1044
1047
|
...props
|
|
1045
1048
|
} = {}) {
|
|
1046
1049
|
const containerRef = (0, import_react3.useRef)(null);
|
|
@@ -1051,7 +1054,14 @@ function createTextEditor(options = {}) {
|
|
|
1051
1054
|
container,
|
|
1052
1055
|
schema,
|
|
1053
1056
|
options,
|
|
1054
|
-
|
|
1057
|
+
{
|
|
1058
|
+
mode,
|
|
1059
|
+
state,
|
|
1060
|
+
editor,
|
|
1061
|
+
defaultValue,
|
|
1062
|
+
updateDelay,
|
|
1063
|
+
placeholder
|
|
1064
|
+
}
|
|
1055
1065
|
);
|
|
1056
1066
|
controllerRef.current = textEditorController;
|
|
1057
1067
|
return textEditorController;
|
|
@@ -1070,6 +1080,7 @@ function createTextEditor(options = {}) {
|
|
|
1070
1080
|
{
|
|
1071
1081
|
ref: controllerRef,
|
|
1072
1082
|
updateDelay,
|
|
1083
|
+
defaultValue,
|
|
1073
1084
|
onChange
|
|
1074
1085
|
}
|
|
1075
1086
|
));
|
|
@@ -888,7 +888,7 @@ function createAttachFile({
|
|
|
888
888
|
import { DOMParser, DOMSerializer } from "prosemirror-model";
|
|
889
889
|
import { Subject } from "rxjs";
|
|
890
890
|
function createTextEditorController(container, schema, options, {
|
|
891
|
-
mode,
|
|
891
|
+
mode = "html",
|
|
892
892
|
state,
|
|
893
893
|
editor,
|
|
894
894
|
defaultValue,
|
|
@@ -900,10 +900,10 @@ function createTextEditorController(container, schema, options, {
|
|
|
900
900
|
const prosemirrorSerializer = DOMSerializer.fromSchema(schema);
|
|
901
901
|
const wrapper = document.createElement("div");
|
|
902
902
|
const toInnerHTML = (value) => {
|
|
903
|
-
if (mode === "
|
|
904
|
-
return value;
|
|
903
|
+
if (mode === "text") {
|
|
904
|
+
return value.split("\n").map((line) => `<p>${line}</p>`).join("");
|
|
905
905
|
}
|
|
906
|
-
return value
|
|
906
|
+
return value;
|
|
907
907
|
};
|
|
908
908
|
wrapper.innerHTML = toInnerHTML(defaultValue ? String(defaultValue) : "");
|
|
909
909
|
const attachFile = createAttachFile({
|
|
@@ -1009,10 +1009,13 @@ function createTextEditor(options = {}) {
|
|
|
1009
1009
|
ref,
|
|
1010
1010
|
className,
|
|
1011
1011
|
autoFocus,
|
|
1012
|
-
placeholder,
|
|
1013
|
-
defaultValue,
|
|
1014
1012
|
onChange,
|
|
1013
|
+
mode,
|
|
1014
|
+
state,
|
|
1015
|
+
editor,
|
|
1016
|
+
defaultValue,
|
|
1015
1017
|
updateDelay,
|
|
1018
|
+
placeholder,
|
|
1016
1019
|
...props
|
|
1017
1020
|
} = {}) {
|
|
1018
1021
|
const containerRef = useRef(null);
|
|
@@ -1023,7 +1026,14 @@ function createTextEditor(options = {}) {
|
|
|
1023
1026
|
container,
|
|
1024
1027
|
schema,
|
|
1025
1028
|
options,
|
|
1026
|
-
|
|
1029
|
+
{
|
|
1030
|
+
mode,
|
|
1031
|
+
state,
|
|
1032
|
+
editor,
|
|
1033
|
+
defaultValue,
|
|
1034
|
+
updateDelay,
|
|
1035
|
+
placeholder
|
|
1036
|
+
}
|
|
1027
1037
|
);
|
|
1028
1038
|
controllerRef.current = textEditorController;
|
|
1029
1039
|
return textEditorController;
|
|
@@ -1042,6 +1052,7 @@ function createTextEditor(options = {}) {
|
|
|
1042
1052
|
{
|
|
1043
1053
|
ref: controllerRef,
|
|
1044
1054
|
updateDelay,
|
|
1055
|
+
defaultValue,
|
|
1045
1056
|
onChange
|
|
1046
1057
|
}
|
|
1047
1058
|
));
|
package/dist/index.js
CHANGED
|
@@ -922,7 +922,7 @@ function createAttachFile({
|
|
|
922
922
|
var import_prosemirror_model3 = require("prosemirror-model");
|
|
923
923
|
var import_rxjs2 = require("rxjs");
|
|
924
924
|
function createTextEditorController(container, schema, options, {
|
|
925
|
-
mode,
|
|
925
|
+
mode = "html",
|
|
926
926
|
state,
|
|
927
927
|
editor,
|
|
928
928
|
defaultValue,
|
|
@@ -934,10 +934,10 @@ function createTextEditorController(container, schema, options, {
|
|
|
934
934
|
const prosemirrorSerializer = import_prosemirror_model3.DOMSerializer.fromSchema(schema);
|
|
935
935
|
const wrapper = document.createElement("div");
|
|
936
936
|
const toInnerHTML = (value) => {
|
|
937
|
-
if (mode === "
|
|
938
|
-
return value;
|
|
937
|
+
if (mode === "text") {
|
|
938
|
+
return value.split("\n").map((line) => `<p>${line}</p>`).join("");
|
|
939
939
|
}
|
|
940
|
-
return value
|
|
940
|
+
return value;
|
|
941
941
|
};
|
|
942
942
|
wrapper.innerHTML = toInnerHTML(defaultValue ? String(defaultValue) : "");
|
|
943
943
|
const attachFile = createAttachFile({
|
|
@@ -1043,10 +1043,13 @@ function createTextEditor(options = {}) {
|
|
|
1043
1043
|
ref,
|
|
1044
1044
|
className,
|
|
1045
1045
|
autoFocus,
|
|
1046
|
-
placeholder,
|
|
1047
|
-
defaultValue,
|
|
1048
1046
|
onChange,
|
|
1047
|
+
mode,
|
|
1048
|
+
state,
|
|
1049
|
+
editor,
|
|
1050
|
+
defaultValue,
|
|
1049
1051
|
updateDelay,
|
|
1052
|
+
placeholder,
|
|
1050
1053
|
...props
|
|
1051
1054
|
} = {}) {
|
|
1052
1055
|
const containerRef = (0, import_react3.useRef)(null);
|
|
@@ -1057,7 +1060,14 @@ function createTextEditor(options = {}) {
|
|
|
1057
1060
|
container,
|
|
1058
1061
|
schema,
|
|
1059
1062
|
options,
|
|
1060
|
-
|
|
1063
|
+
{
|
|
1064
|
+
mode,
|
|
1065
|
+
state,
|
|
1066
|
+
editor,
|
|
1067
|
+
defaultValue,
|
|
1068
|
+
updateDelay,
|
|
1069
|
+
placeholder
|
|
1070
|
+
}
|
|
1061
1071
|
);
|
|
1062
1072
|
controllerRef.current = textEditorController;
|
|
1063
1073
|
return textEditorController;
|
|
@@ -1076,6 +1086,7 @@ function createTextEditor(options = {}) {
|
|
|
1076
1086
|
{
|
|
1077
1087
|
ref: controllerRef,
|
|
1078
1088
|
updateDelay,
|
|
1089
|
+
defaultValue,
|
|
1079
1090
|
onChange
|
|
1080
1091
|
}
|
|
1081
1092
|
));
|
package/dist/index.mjs
CHANGED
|
@@ -888,7 +888,7 @@ function createAttachFile({
|
|
|
888
888
|
import { DOMParser, DOMSerializer } from "prosemirror-model";
|
|
889
889
|
import { Subject } from "rxjs";
|
|
890
890
|
function createTextEditorController(container, schema, options, {
|
|
891
|
-
mode,
|
|
891
|
+
mode = "html",
|
|
892
892
|
state,
|
|
893
893
|
editor,
|
|
894
894
|
defaultValue,
|
|
@@ -900,10 +900,10 @@ function createTextEditorController(container, schema, options, {
|
|
|
900
900
|
const prosemirrorSerializer = DOMSerializer.fromSchema(schema);
|
|
901
901
|
const wrapper = document.createElement("div");
|
|
902
902
|
const toInnerHTML = (value) => {
|
|
903
|
-
if (mode === "
|
|
904
|
-
return value;
|
|
903
|
+
if (mode === "text") {
|
|
904
|
+
return value.split("\n").map((line) => `<p>${line}</p>`).join("");
|
|
905
905
|
}
|
|
906
|
-
return value
|
|
906
|
+
return value;
|
|
907
907
|
};
|
|
908
908
|
wrapper.innerHTML = toInnerHTML(defaultValue ? String(defaultValue) : "");
|
|
909
909
|
const attachFile = createAttachFile({
|
|
@@ -1009,10 +1009,13 @@ function createTextEditor(options = {}) {
|
|
|
1009
1009
|
ref,
|
|
1010
1010
|
className,
|
|
1011
1011
|
autoFocus,
|
|
1012
|
-
placeholder,
|
|
1013
|
-
defaultValue,
|
|
1014
1012
|
onChange,
|
|
1013
|
+
mode,
|
|
1014
|
+
state,
|
|
1015
|
+
editor,
|
|
1016
|
+
defaultValue,
|
|
1015
1017
|
updateDelay,
|
|
1018
|
+
placeholder,
|
|
1016
1019
|
...props
|
|
1017
1020
|
} = {}) {
|
|
1018
1021
|
const containerRef = useRef(null);
|
|
@@ -1023,7 +1026,14 @@ function createTextEditor(options = {}) {
|
|
|
1023
1026
|
container,
|
|
1024
1027
|
schema,
|
|
1025
1028
|
options,
|
|
1026
|
-
|
|
1029
|
+
{
|
|
1030
|
+
mode,
|
|
1031
|
+
state,
|
|
1032
|
+
editor,
|
|
1033
|
+
defaultValue,
|
|
1034
|
+
updateDelay,
|
|
1035
|
+
placeholder
|
|
1036
|
+
}
|
|
1027
1037
|
);
|
|
1028
1038
|
controllerRef.current = textEditorController;
|
|
1029
1039
|
return textEditorController;
|
|
@@ -1042,6 +1052,7 @@ function createTextEditor(options = {}) {
|
|
|
1042
1052
|
{
|
|
1043
1053
|
ref: controllerRef,
|
|
1044
1054
|
updateDelay,
|
|
1055
|
+
defaultValue,
|
|
1045
1056
|
onChange
|
|
1046
1057
|
}
|
|
1047
1058
|
));
|
|
@@ -384,7 +384,7 @@ var createCommands = (schema, view, options = {}) => {
|
|
|
384
384
|
var import_prosemirror_model2 = require("prosemirror-model");
|
|
385
385
|
var import_rxjs = require("rxjs");
|
|
386
386
|
function createTextEditorController(container, schema, options, {
|
|
387
|
-
mode,
|
|
387
|
+
mode = "html",
|
|
388
388
|
state,
|
|
389
389
|
editor,
|
|
390
390
|
defaultValue,
|
|
@@ -396,10 +396,10 @@ function createTextEditorController(container, schema, options, {
|
|
|
396
396
|
const prosemirrorSerializer = import_prosemirror_model2.DOMSerializer.fromSchema(schema);
|
|
397
397
|
const wrapper = document.createElement("div");
|
|
398
398
|
const toInnerHTML = (value) => {
|
|
399
|
-
if (mode === "
|
|
400
|
-
return value;
|
|
399
|
+
if (mode === "text") {
|
|
400
|
+
return value.split("\n").map((line) => `<p>${line}</p>`).join("");
|
|
401
401
|
}
|
|
402
|
-
return value
|
|
402
|
+
return value;
|
|
403
403
|
};
|
|
404
404
|
wrapper.innerHTML = toInnerHTML(defaultValue ? String(defaultValue) : "");
|
|
405
405
|
const attachFile = createAttachFile({
|
|
@@ -352,7 +352,7 @@ var createCommands = (schema, view, options = {}) => {
|
|
|
352
352
|
import { DOMParser, DOMSerializer } from "prosemirror-model";
|
|
353
353
|
import { Subject } from "rxjs";
|
|
354
354
|
function createTextEditorController(container, schema, options, {
|
|
355
|
-
mode,
|
|
355
|
+
mode = "html",
|
|
356
356
|
state,
|
|
357
357
|
editor,
|
|
358
358
|
defaultValue,
|
|
@@ -364,10 +364,10 @@ function createTextEditorController(container, schema, options, {
|
|
|
364
364
|
const prosemirrorSerializer = DOMSerializer.fromSchema(schema);
|
|
365
365
|
const wrapper = document.createElement("div");
|
|
366
366
|
const toInnerHTML = (value) => {
|
|
367
|
-
if (mode === "
|
|
368
|
-
return value;
|
|
367
|
+
if (mode === "text") {
|
|
368
|
+
return value.split("\n").map((line) => `<p>${line}</p>`).join("");
|
|
369
369
|
}
|
|
370
|
-
return value
|
|
370
|
+
return value;
|
|
371
371
|
};
|
|
372
372
|
wrapper.innerHTML = toInnerHTML(defaultValue ? String(defaultValue) : "");
|
|
373
373
|
const attachFile = createAttachFile({
|