dn-react-text-editor 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -214
- package/dist/attach_file.d.mts +20 -18
- package/dist/attach_file.d.ts +20 -18
- package/dist/attach_file.js +18 -9
- package/dist/attach_file.mjs +18 -9
- package/dist/base64_file_uploader.d.mts +6 -0
- package/dist/base64_file_uploader.d.ts +6 -0
- package/dist/{plugins/trailing_paragraph.js → base64_file_uploader.js} +19 -22
- package/dist/base64_file_uploader.mjs +18 -0
- package/dist/commands.d.mts +23 -0
- package/dist/commands.d.ts +23 -0
- package/dist/commands.js +110 -0
- package/dist/commands.mjs +75 -0
- package/dist/create_text_editor.d.mts +28 -0
- package/dist/create_text_editor.d.ts +28 -0
- package/dist/create_text_editor.js +1082 -0
- package/dist/create_text_editor.mjs +1053 -0
- package/dist/html.d.mts +8 -0
- package/dist/html.d.ts +8 -0
- package/dist/html.js +136 -0
- package/dist/html.mjs +98 -0
- package/dist/index.d.mts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +790 -380
- package/dist/index.mjs +789 -377
- package/dist/input.d.mts +21 -0
- package/dist/input.d.ts +21 -0
- package/dist/input.js +70 -0
- package/dist/input.mjs +37 -0
- package/dist/plugins/drag_and_drop.d.mts +1 -1
- package/dist/plugins/drag_and_drop.d.ts +1 -1
- package/dist/plugins/drag_and_drop.js +3 -0
- package/dist/plugins/drag_and_drop.mjs +3 -0
- package/dist/plugins/highlighter.d.mts +6 -0
- package/dist/plugins/highlighter.d.ts +6 -0
- package/dist/plugins/highlighter.js +105 -0
- package/dist/plugins/highlighter.mjs +69 -0
- package/dist/plugins/keymap.js +17 -0
- package/dist/plugins/keymap.mjs +17 -0
- package/dist/schema.d.mts +2 -2
- package/dist/schema.d.ts +2 -2
- package/dist/schema.js +255 -14
- package/dist/schema.mjs +245 -14
- package/dist/text_editor_controller.d.mts +46 -0
- package/dist/text_editor_controller.d.ts +46 -0
- package/dist/text_editor_controller.js +503 -0
- package/dist/text_editor_controller.mjs +470 -0
- package/package.json +3 -1
- package/dist/plugins/trailing_paragraph.d.mts +0 -5
- package/dist/plugins/trailing_paragraph.d.ts +0 -5
- package/dist/plugins/trailing_paragraph.mjs +0 -21
- package/dist/text_editor.d.mts +0 -37
- package/dist/text_editor.d.ts +0 -37
- package/dist/text_editor.js +0 -720
- package/dist/text_editor.mjs +0 -687
package/dist/input.d.mts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, { DetailedHTMLProps, HTMLAttributes, RefObject } from 'react';
|
|
2
|
+
import { TextEditorController } from './create_text_editor.mjs';
|
|
3
|
+
import 'prosemirror-state';
|
|
4
|
+
import 'prosemirror-view';
|
|
5
|
+
import './schema.mjs';
|
|
6
|
+
import 'orderedmap';
|
|
7
|
+
import 'prosemirror-model';
|
|
8
|
+
import 'rxjs';
|
|
9
|
+
import './commands.mjs';
|
|
10
|
+
import './attach_file.mjs';
|
|
11
|
+
import './text_editor_controller.mjs';
|
|
12
|
+
|
|
13
|
+
type Props = Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
14
|
+
ref: RefObject<TextEditorController | null>;
|
|
15
|
+
updateDelay?: number;
|
|
16
|
+
name?: string;
|
|
17
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
18
|
+
};
|
|
19
|
+
declare function TextEditorInput({ ref, onChange, updateDelay, ...props }: Props): React.JSX.Element;
|
|
20
|
+
|
|
21
|
+
export { TextEditorInput };
|
package/dist/input.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, { DetailedHTMLProps, HTMLAttributes, RefObject } from 'react';
|
|
2
|
+
import { TextEditorController } from './create_text_editor.js';
|
|
3
|
+
import 'prosemirror-state';
|
|
4
|
+
import 'prosemirror-view';
|
|
5
|
+
import './schema.js';
|
|
6
|
+
import 'orderedmap';
|
|
7
|
+
import 'prosemirror-model';
|
|
8
|
+
import 'rxjs';
|
|
9
|
+
import './commands.js';
|
|
10
|
+
import './attach_file.js';
|
|
11
|
+
import './text_editor_controller.js';
|
|
12
|
+
|
|
13
|
+
type Props = Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
14
|
+
ref: RefObject<TextEditorController | null>;
|
|
15
|
+
updateDelay?: number;
|
|
16
|
+
name?: string;
|
|
17
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
18
|
+
};
|
|
19
|
+
declare function TextEditorInput({ ref, onChange, updateDelay, ...props }: Props): React.JSX.Element;
|
|
20
|
+
|
|
21
|
+
export { TextEditorInput };
|
package/dist/input.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
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
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/input.tsx
|
|
31
|
+
var input_exports = {};
|
|
32
|
+
__export(input_exports, {
|
|
33
|
+
TextEditorInput: () => TextEditorInput
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(input_exports);
|
|
36
|
+
var import_react = __toESM(require("react"));
|
|
37
|
+
var import_rxjs = require("rxjs");
|
|
38
|
+
function TextEditorInput({
|
|
39
|
+
ref,
|
|
40
|
+
onChange,
|
|
41
|
+
updateDelay = 0,
|
|
42
|
+
...props
|
|
43
|
+
}) {
|
|
44
|
+
const inputRef = import_react.default.useRef(null);
|
|
45
|
+
(0, import_react.useEffect)(() => {
|
|
46
|
+
const controller = ref.current;
|
|
47
|
+
if (!controller) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const sub = controller.subject.pipe(
|
|
51
|
+
(0, import_rxjs.filter)((tr) => tr.docChanged),
|
|
52
|
+
(0, import_rxjs.debounceTime)(updateDelay)
|
|
53
|
+
).subscribe(() => {
|
|
54
|
+
if (inputRef.current) {
|
|
55
|
+
inputRef.current.value = controller.value;
|
|
56
|
+
const event = new Event("input", { bubbles: true });
|
|
57
|
+
inputRef.current.dispatchEvent(event);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return () => {
|
|
61
|
+
sub.unsubscribe();
|
|
62
|
+
controller.view.destroy();
|
|
63
|
+
};
|
|
64
|
+
}, []);
|
|
65
|
+
return /* @__PURE__ */ import_react.default.createElement("input", { ...props, ref: inputRef, type: "hidden", onInput: onChange });
|
|
66
|
+
}
|
|
67
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
+
0 && (module.exports = {
|
|
69
|
+
TextEditorInput
|
|
70
|
+
});
|
package/dist/input.mjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// src/input.tsx
|
|
2
|
+
import React, {
|
|
3
|
+
useEffect
|
|
4
|
+
} from "react";
|
|
5
|
+
import { debounceTime, filter } from "rxjs";
|
|
6
|
+
function TextEditorInput({
|
|
7
|
+
ref,
|
|
8
|
+
onChange,
|
|
9
|
+
updateDelay = 0,
|
|
10
|
+
...props
|
|
11
|
+
}) {
|
|
12
|
+
const inputRef = React.useRef(null);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const controller = ref.current;
|
|
15
|
+
if (!controller) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const sub = controller.subject.pipe(
|
|
19
|
+
filter((tr) => tr.docChanged),
|
|
20
|
+
debounceTime(updateDelay)
|
|
21
|
+
).subscribe(() => {
|
|
22
|
+
if (inputRef.current) {
|
|
23
|
+
inputRef.current.value = controller.value;
|
|
24
|
+
const event = new Event("input", { bubbles: true });
|
|
25
|
+
inputRef.current.dispatchEvent(event);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return () => {
|
|
29
|
+
sub.unsubscribe();
|
|
30
|
+
controller.view.destroy();
|
|
31
|
+
};
|
|
32
|
+
}, []);
|
|
33
|
+
return /* @__PURE__ */ React.createElement("input", { ...props, ref: inputRef, type: "hidden", onInput: onChange });
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
TextEditorInput
|
|
37
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
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
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/plugins/highlighter.ts
|
|
31
|
+
var highlighter_exports = {};
|
|
32
|
+
__export(highlighter_exports, {
|
|
33
|
+
highlighter: () => highlighter,
|
|
34
|
+
supportedLanguages: () => supportedLanguages
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(highlighter_exports);
|
|
37
|
+
var import_highlight = __toESM(require("highlight.js"));
|
|
38
|
+
var import_bash = __toESM(require("highlight.js/lib/languages/bash"));
|
|
39
|
+
var import_c = __toESM(require("highlight.js/lib/languages/c"));
|
|
40
|
+
var import_cpp = __toESM(require("highlight.js/lib/languages/cpp"));
|
|
41
|
+
var import_css = __toESM(require("highlight.js/lib/languages/css"));
|
|
42
|
+
var import_java = __toESM(require("highlight.js/lib/languages/java"));
|
|
43
|
+
var import_typescript = __toESM(require("highlight.js/lib/languages/typescript"));
|
|
44
|
+
var import_javascript = __toESM(require("highlight.js/lib/languages/javascript"));
|
|
45
|
+
var import_json = __toESM(require("highlight.js/lib/languages/json"));
|
|
46
|
+
var import_xml = __toESM(require("highlight.js/lib/languages/xml"));
|
|
47
|
+
var import_python = __toESM(require("highlight.js/lib/languages/python"));
|
|
48
|
+
var import_dart = __toESM(require("highlight.js/lib/languages/dart"));
|
|
49
|
+
var import_csharp = __toESM(require("highlight.js/lib/languages/csharp"));
|
|
50
|
+
var import_markdown = __toESM(require("highlight.js/lib/languages/markdown"));
|
|
51
|
+
var import_nginx = __toESM(require("highlight.js/lib/languages/nginx"));
|
|
52
|
+
var import_php = __toESM(require("highlight.js/lib/languages/php"));
|
|
53
|
+
var import_ruby = __toESM(require("highlight.js/lib/languages/ruby"));
|
|
54
|
+
var import_sql = __toESM(require("highlight.js/lib/languages/sql"));
|
|
55
|
+
var import_swift = __toESM(require("highlight.js/lib/languages/swift"));
|
|
56
|
+
var import_yaml = __toESM(require("highlight.js/lib/languages/yaml"));
|
|
57
|
+
var import_rust = __toESM(require("highlight.js/lib/languages/rust"));
|
|
58
|
+
import_highlight.default.registerLanguage("bash", import_bash.default);
|
|
59
|
+
import_highlight.default.registerLanguage("c", import_c.default);
|
|
60
|
+
import_highlight.default.registerLanguage("cpp", import_cpp.default);
|
|
61
|
+
import_highlight.default.registerLanguage("css", import_css.default);
|
|
62
|
+
import_highlight.default.registerLanguage("java", import_java.default);
|
|
63
|
+
import_highlight.default.registerLanguage("markdown", import_markdown.default);
|
|
64
|
+
import_highlight.default.registerLanguage("nginx", import_nginx.default);
|
|
65
|
+
import_highlight.default.registerLanguage("php", import_php.default);
|
|
66
|
+
import_highlight.default.registerLanguage("ruby", import_ruby.default);
|
|
67
|
+
import_highlight.default.registerLanguage("sql", import_sql.default);
|
|
68
|
+
import_highlight.default.registerLanguage("swift", import_swift.default);
|
|
69
|
+
import_highlight.default.registerLanguage("yaml", import_yaml.default);
|
|
70
|
+
import_highlight.default.registerLanguage("rust", import_rust.default);
|
|
71
|
+
import_highlight.default.registerLanguage("json", import_json.default);
|
|
72
|
+
import_highlight.default.registerLanguage("javascript", import_javascript.default);
|
|
73
|
+
import_highlight.default.registerLanguage("typescript", import_typescript.default);
|
|
74
|
+
import_highlight.default.registerLanguage("xml", import_xml.default);
|
|
75
|
+
import_highlight.default.registerLanguage("python", import_python.default);
|
|
76
|
+
import_highlight.default.registerLanguage("dart", import_dart.default);
|
|
77
|
+
import_highlight.default.registerLanguage("csharp", import_csharp.default);
|
|
78
|
+
var supportedLanguages = [
|
|
79
|
+
"bash",
|
|
80
|
+
"c",
|
|
81
|
+
"cpp",
|
|
82
|
+
"css",
|
|
83
|
+
"java",
|
|
84
|
+
"markdown",
|
|
85
|
+
"nginx",
|
|
86
|
+
"php",
|
|
87
|
+
"ruby",
|
|
88
|
+
"sql",
|
|
89
|
+
"swift",
|
|
90
|
+
"yaml",
|
|
91
|
+
"rust",
|
|
92
|
+
"json",
|
|
93
|
+
"javascript",
|
|
94
|
+
"typescript",
|
|
95
|
+
"xml",
|
|
96
|
+
"python",
|
|
97
|
+
"dart",
|
|
98
|
+
"csharp"
|
|
99
|
+
];
|
|
100
|
+
var highlighter = import_highlight.default;
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
highlighter,
|
|
104
|
+
supportedLanguages
|
|
105
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// src/plugins/highlighter.ts
|
|
2
|
+
import hljs from "highlight.js";
|
|
3
|
+
import bash from "highlight.js/lib/languages/bash";
|
|
4
|
+
import c from "highlight.js/lib/languages/c";
|
|
5
|
+
import cpp from "highlight.js/lib/languages/cpp";
|
|
6
|
+
import css from "highlight.js/lib/languages/css";
|
|
7
|
+
import java from "highlight.js/lib/languages/java";
|
|
8
|
+
import ts from "highlight.js/lib/languages/typescript";
|
|
9
|
+
import js from "highlight.js/lib/languages/javascript";
|
|
10
|
+
import json from "highlight.js/lib/languages/json";
|
|
11
|
+
import xml from "highlight.js/lib/languages/xml";
|
|
12
|
+
import python from "highlight.js/lib/languages/python";
|
|
13
|
+
import dart from "highlight.js/lib/languages/dart";
|
|
14
|
+
import csharp from "highlight.js/lib/languages/csharp";
|
|
15
|
+
import markdown from "highlight.js/lib/languages/markdown";
|
|
16
|
+
import nginx from "highlight.js/lib/languages/nginx";
|
|
17
|
+
import php from "highlight.js/lib/languages/php";
|
|
18
|
+
import ruby from "highlight.js/lib/languages/ruby";
|
|
19
|
+
import sql from "highlight.js/lib/languages/sql";
|
|
20
|
+
import swift from "highlight.js/lib/languages/swift";
|
|
21
|
+
import yaml from "highlight.js/lib/languages/yaml";
|
|
22
|
+
import rust from "highlight.js/lib/languages/rust";
|
|
23
|
+
hljs.registerLanguage("bash", bash);
|
|
24
|
+
hljs.registerLanguage("c", c);
|
|
25
|
+
hljs.registerLanguage("cpp", cpp);
|
|
26
|
+
hljs.registerLanguage("css", css);
|
|
27
|
+
hljs.registerLanguage("java", java);
|
|
28
|
+
hljs.registerLanguage("markdown", markdown);
|
|
29
|
+
hljs.registerLanguage("nginx", nginx);
|
|
30
|
+
hljs.registerLanguage("php", php);
|
|
31
|
+
hljs.registerLanguage("ruby", ruby);
|
|
32
|
+
hljs.registerLanguage("sql", sql);
|
|
33
|
+
hljs.registerLanguage("swift", swift);
|
|
34
|
+
hljs.registerLanguage("yaml", yaml);
|
|
35
|
+
hljs.registerLanguage("rust", rust);
|
|
36
|
+
hljs.registerLanguage("json", json);
|
|
37
|
+
hljs.registerLanguage("javascript", js);
|
|
38
|
+
hljs.registerLanguage("typescript", ts);
|
|
39
|
+
hljs.registerLanguage("xml", xml);
|
|
40
|
+
hljs.registerLanguage("python", python);
|
|
41
|
+
hljs.registerLanguage("dart", dart);
|
|
42
|
+
hljs.registerLanguage("csharp", csharp);
|
|
43
|
+
var supportedLanguages = [
|
|
44
|
+
"bash",
|
|
45
|
+
"c",
|
|
46
|
+
"cpp",
|
|
47
|
+
"css",
|
|
48
|
+
"java",
|
|
49
|
+
"markdown",
|
|
50
|
+
"nginx",
|
|
51
|
+
"php",
|
|
52
|
+
"ruby",
|
|
53
|
+
"sql",
|
|
54
|
+
"swift",
|
|
55
|
+
"yaml",
|
|
56
|
+
"rust",
|
|
57
|
+
"json",
|
|
58
|
+
"javascript",
|
|
59
|
+
"typescript",
|
|
60
|
+
"xml",
|
|
61
|
+
"python",
|
|
62
|
+
"dart",
|
|
63
|
+
"csharp"
|
|
64
|
+
];
|
|
65
|
+
var highlighter = hljs;
|
|
66
|
+
export {
|
|
67
|
+
highlighter,
|
|
68
|
+
supportedLanguages
|
|
69
|
+
};
|
package/dist/plugins/keymap.js
CHANGED
|
@@ -23,6 +23,7 @@ __export(keymap_exports, {
|
|
|
23
23
|
buildKeymap: () => buildKeymap
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(keymap_exports);
|
|
26
|
+
var import_prosemirror_state = require("prosemirror-state");
|
|
26
27
|
var import_prosemirror_history = require("prosemirror-history");
|
|
27
28
|
var import_prosemirror_commands = require("prosemirror-commands");
|
|
28
29
|
var import_prosemirror_schema_list = require("prosemirror-schema-list");
|
|
@@ -51,6 +52,22 @@ function buildKeymap(schema) {
|
|
|
51
52
|
return false;
|
|
52
53
|
})
|
|
53
54
|
);
|
|
55
|
+
bind("ArrowDown", (state, dispatch) => {
|
|
56
|
+
const doc = state.doc;
|
|
57
|
+
const lastNode = doc.lastChild;
|
|
58
|
+
if (lastNode && lastNode.type.name !== "paragraph") {
|
|
59
|
+
const paragraphType = state.schema.nodes.paragraph;
|
|
60
|
+
let tr = state.tr;
|
|
61
|
+
const endPos = doc.content.size;
|
|
62
|
+
tr = tr.insert(endPos, paragraphType.create());
|
|
63
|
+
tr = tr.setSelection(import_prosemirror_state.TextSelection.create(tr.doc, tr.doc.content.size));
|
|
64
|
+
if (dispatch) {
|
|
65
|
+
dispatch(tr);
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
});
|
|
54
71
|
return keys;
|
|
55
72
|
}
|
|
56
73
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/plugins/keymap.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/plugins/keymap.tsx
|
|
2
|
+
import { TextSelection } from "prosemirror-state";
|
|
2
3
|
import { undo, redo } from "prosemirror-history";
|
|
3
4
|
import { chainCommands, splitBlockAs } from "prosemirror-commands";
|
|
4
5
|
import { splitListItem } from "prosemirror-schema-list";
|
|
@@ -27,6 +28,22 @@ function buildKeymap(schema) {
|
|
|
27
28
|
return false;
|
|
28
29
|
})
|
|
29
30
|
);
|
|
31
|
+
bind("ArrowDown", (state, dispatch) => {
|
|
32
|
+
const doc = state.doc;
|
|
33
|
+
const lastNode = doc.lastChild;
|
|
34
|
+
if (lastNode && lastNode.type.name !== "paragraph") {
|
|
35
|
+
const paragraphType = state.schema.nodes.paragraph;
|
|
36
|
+
let tr = state.tr;
|
|
37
|
+
const endPos = doc.content.size;
|
|
38
|
+
tr = tr.insert(endPos, paragraphType.create());
|
|
39
|
+
tr = tr.setSelection(TextSelection.create(tr.doc, tr.doc.content.size));
|
|
40
|
+
if (dispatch) {
|
|
41
|
+
dispatch(tr);
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
});
|
|
30
47
|
return keys;
|
|
31
48
|
}
|
|
32
49
|
export {
|
package/dist/schema.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as orderedmap from 'orderedmap';
|
|
2
2
|
import * as prosemirror_model from 'prosemirror-model';
|
|
3
|
-
import { Schema } from 'prosemirror-model';
|
|
3
|
+
import { SchemaSpec, Schema } from 'prosemirror-model';
|
|
4
4
|
|
|
5
|
-
declare function createSchema(): Schema<keyof orderedmap.default<prosemirror_model.NodeSpec>, keyof orderedmap.default<prosemirror_model.MarkSpec>>;
|
|
5
|
+
declare function createSchema(spec?: SchemaSpec): Schema<keyof orderedmap.default<prosemirror_model.NodeSpec>, keyof orderedmap.default<prosemirror_model.MarkSpec>>;
|
|
6
6
|
|
|
7
7
|
export { createSchema };
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as orderedmap from 'orderedmap';
|
|
2
2
|
import * as prosemirror_model from 'prosemirror-model';
|
|
3
|
-
import { Schema } from 'prosemirror-model';
|
|
3
|
+
import { SchemaSpec, Schema } from 'prosemirror-model';
|
|
4
4
|
|
|
5
|
-
declare function createSchema(): Schema<keyof orderedmap.default<prosemirror_model.NodeSpec>, keyof orderedmap.default<prosemirror_model.MarkSpec>>;
|
|
5
|
+
declare function createSchema(spec?: SchemaSpec): Schema<keyof orderedmap.default<prosemirror_model.NodeSpec>, keyof orderedmap.default<prosemirror_model.MarkSpec>>;
|
|
6
6
|
|
|
7
7
|
export { createSchema };
|