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/html.d.mts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { DetailedHTMLProps } from 'react';
|
|
2
|
+
|
|
3
|
+
declare function createInnerHTML(raw: string): string;
|
|
4
|
+
declare function createTextEditorView(options?: {
|
|
5
|
+
className?: string;
|
|
6
|
+
}): ({ className, dangerouslySetInnerHTML, ...props }: DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>) => React.JSX.Element;
|
|
7
|
+
|
|
8
|
+
export { createInnerHTML, createTextEditorView };
|
package/dist/html.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { DetailedHTMLProps } from 'react';
|
|
2
|
+
|
|
3
|
+
declare function createInnerHTML(raw: string): string;
|
|
4
|
+
declare function createTextEditorView(options?: {
|
|
5
|
+
className?: string;
|
|
6
|
+
}): ({ className, dangerouslySetInnerHTML, ...props }: DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>) => React.JSX.Element;
|
|
7
|
+
|
|
8
|
+
export { createInnerHTML, createTextEditorView };
|
package/dist/html.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
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/html.tsx
|
|
31
|
+
var html_exports = {};
|
|
32
|
+
__export(html_exports, {
|
|
33
|
+
createInnerHTML: () => createInnerHTML,
|
|
34
|
+
createTextEditorView: () => createTextEditorView
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(html_exports);
|
|
37
|
+
|
|
38
|
+
// src/plugins/highlighter.ts
|
|
39
|
+
var import_highlight = __toESM(require("highlight.js"));
|
|
40
|
+
var import_bash = __toESM(require("highlight.js/lib/languages/bash"));
|
|
41
|
+
var import_c = __toESM(require("highlight.js/lib/languages/c"));
|
|
42
|
+
var import_cpp = __toESM(require("highlight.js/lib/languages/cpp"));
|
|
43
|
+
var import_css = __toESM(require("highlight.js/lib/languages/css"));
|
|
44
|
+
var import_java = __toESM(require("highlight.js/lib/languages/java"));
|
|
45
|
+
var import_typescript = __toESM(require("highlight.js/lib/languages/typescript"));
|
|
46
|
+
var import_javascript = __toESM(require("highlight.js/lib/languages/javascript"));
|
|
47
|
+
var import_json = __toESM(require("highlight.js/lib/languages/json"));
|
|
48
|
+
var import_xml = __toESM(require("highlight.js/lib/languages/xml"));
|
|
49
|
+
var import_python = __toESM(require("highlight.js/lib/languages/python"));
|
|
50
|
+
var import_dart = __toESM(require("highlight.js/lib/languages/dart"));
|
|
51
|
+
var import_csharp = __toESM(require("highlight.js/lib/languages/csharp"));
|
|
52
|
+
var import_markdown = __toESM(require("highlight.js/lib/languages/markdown"));
|
|
53
|
+
var import_nginx = __toESM(require("highlight.js/lib/languages/nginx"));
|
|
54
|
+
var import_php = __toESM(require("highlight.js/lib/languages/php"));
|
|
55
|
+
var import_ruby = __toESM(require("highlight.js/lib/languages/ruby"));
|
|
56
|
+
var import_sql = __toESM(require("highlight.js/lib/languages/sql"));
|
|
57
|
+
var import_swift = __toESM(require("highlight.js/lib/languages/swift"));
|
|
58
|
+
var import_yaml = __toESM(require("highlight.js/lib/languages/yaml"));
|
|
59
|
+
var import_rust = __toESM(require("highlight.js/lib/languages/rust"));
|
|
60
|
+
import_highlight.default.registerLanguage("bash", import_bash.default);
|
|
61
|
+
import_highlight.default.registerLanguage("c", import_c.default);
|
|
62
|
+
import_highlight.default.registerLanguage("cpp", import_cpp.default);
|
|
63
|
+
import_highlight.default.registerLanguage("css", import_css.default);
|
|
64
|
+
import_highlight.default.registerLanguage("java", import_java.default);
|
|
65
|
+
import_highlight.default.registerLanguage("markdown", import_markdown.default);
|
|
66
|
+
import_highlight.default.registerLanguage("nginx", import_nginx.default);
|
|
67
|
+
import_highlight.default.registerLanguage("php", import_php.default);
|
|
68
|
+
import_highlight.default.registerLanguage("ruby", import_ruby.default);
|
|
69
|
+
import_highlight.default.registerLanguage("sql", import_sql.default);
|
|
70
|
+
import_highlight.default.registerLanguage("swift", import_swift.default);
|
|
71
|
+
import_highlight.default.registerLanguage("yaml", import_yaml.default);
|
|
72
|
+
import_highlight.default.registerLanguage("rust", import_rust.default);
|
|
73
|
+
import_highlight.default.registerLanguage("json", import_json.default);
|
|
74
|
+
import_highlight.default.registerLanguage("javascript", import_javascript.default);
|
|
75
|
+
import_highlight.default.registerLanguage("typescript", import_typescript.default);
|
|
76
|
+
import_highlight.default.registerLanguage("xml", import_xml.default);
|
|
77
|
+
import_highlight.default.registerLanguage("python", import_python.default);
|
|
78
|
+
import_highlight.default.registerLanguage("dart", import_dart.default);
|
|
79
|
+
import_highlight.default.registerLanguage("csharp", import_csharp.default);
|
|
80
|
+
var highlighter = import_highlight.default;
|
|
81
|
+
|
|
82
|
+
// src/html.tsx
|
|
83
|
+
var import_html_entities = require("html-entities");
|
|
84
|
+
|
|
85
|
+
// src/cn.ts
|
|
86
|
+
function cn(...classes) {
|
|
87
|
+
return classes.filter(Boolean).join(" ").trim();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// src/html.tsx
|
|
91
|
+
var import_react = __toESM(require("react"));
|
|
92
|
+
function createInnerHTML(raw) {
|
|
93
|
+
return raw.replace(/<\/p>/g, "<br></p>").replace(/(<p><br><\/p>)+$/g, "").replace(
|
|
94
|
+
/<code class="language-(\w+)">([\s\S]*?)<\/code>/g,
|
|
95
|
+
(_, lang, code) => {
|
|
96
|
+
try {
|
|
97
|
+
const highlighted = highlighter.highlight(code, {
|
|
98
|
+
language: lang
|
|
99
|
+
}).value;
|
|
100
|
+
return `<code class="language-${lang}">${(0, import_html_entities.decode)(highlighted)}</code>`;
|
|
101
|
+
} catch (e) {
|
|
102
|
+
return `<code class="language-${lang}">${(0, import_html_entities.decode)(code)}</code>`;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
).replace(
|
|
106
|
+
/<a([^>]*target="_blank"[^>]*)>(.*?)<\/a>/g,
|
|
107
|
+
(_, attrs, content) => {
|
|
108
|
+
return `<a${attrs} rel="noopener noreferrer" target="_blank">${content}<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M18.25 15.5a.75.75 0 0 1-.75-.75V7.56L7.28 17.78a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L16.44 6.5H9.25a.75.75 0 0 1 0-1.5h9a.75.75 0 0 1 .75.75v9a.75.75 0 0 1-.75.75Z"></path></svg></a>`;
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
function createTextEditorView(options = {}) {
|
|
113
|
+
return function Component({
|
|
114
|
+
className,
|
|
115
|
+
dangerouslySetInnerHTML,
|
|
116
|
+
...props
|
|
117
|
+
}) {
|
|
118
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
119
|
+
"div",
|
|
120
|
+
{
|
|
121
|
+
...props,
|
|
122
|
+
className: cn(options?.className, className),
|
|
123
|
+
dangerouslySetInnerHTML: {
|
|
124
|
+
__html: createInnerHTML(
|
|
125
|
+
String(dangerouslySetInnerHTML?.__html || "")
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
133
|
+
0 && (module.exports = {
|
|
134
|
+
createInnerHTML,
|
|
135
|
+
createTextEditorView
|
|
136
|
+
});
|
package/dist/html.mjs
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
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 highlighter = hljs;
|
|
44
|
+
|
|
45
|
+
// src/html.tsx
|
|
46
|
+
import { decode } from "html-entities";
|
|
47
|
+
|
|
48
|
+
// src/cn.ts
|
|
49
|
+
function cn(...classes) {
|
|
50
|
+
return classes.filter(Boolean).join(" ").trim();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/html.tsx
|
|
54
|
+
import React from "react";
|
|
55
|
+
function createInnerHTML(raw) {
|
|
56
|
+
return raw.replace(/<\/p>/g, "<br></p>").replace(/(<p><br><\/p>)+$/g, "").replace(
|
|
57
|
+
/<code class="language-(\w+)">([\s\S]*?)<\/code>/g,
|
|
58
|
+
(_, lang, code) => {
|
|
59
|
+
try {
|
|
60
|
+
const highlighted = highlighter.highlight(code, {
|
|
61
|
+
language: lang
|
|
62
|
+
}).value;
|
|
63
|
+
return `<code class="language-${lang}">${decode(highlighted)}</code>`;
|
|
64
|
+
} catch (e) {
|
|
65
|
+
return `<code class="language-${lang}">${decode(code)}</code>`;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
).replace(
|
|
69
|
+
/<a([^>]*target="_blank"[^>]*)>(.*?)<\/a>/g,
|
|
70
|
+
(_, attrs, content) => {
|
|
71
|
+
return `<a${attrs} rel="noopener noreferrer" target="_blank">${content}<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M18.25 15.5a.75.75 0 0 1-.75-.75V7.56L7.28 17.78a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L16.44 6.5H9.25a.75.75 0 0 1 0-1.5h9a.75.75 0 0 1 .75.75v9a.75.75 0 0 1-.75.75Z"></path></svg></a>`;
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
function createTextEditorView(options = {}) {
|
|
76
|
+
return function Component({
|
|
77
|
+
className,
|
|
78
|
+
dangerouslySetInnerHTML,
|
|
79
|
+
...props
|
|
80
|
+
}) {
|
|
81
|
+
return /* @__PURE__ */ React.createElement(
|
|
82
|
+
"div",
|
|
83
|
+
{
|
|
84
|
+
...props,
|
|
85
|
+
className: cn(options?.className, className),
|
|
86
|
+
dangerouslySetInnerHTML: {
|
|
87
|
+
__html: createInnerHTML(
|
|
88
|
+
String(dangerouslySetInnerHTML?.__html || "")
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
createInnerHTML,
|
|
97
|
+
createTextEditorView
|
|
98
|
+
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
export { TextEditorController, TextEditorProps, createTextEditor } from './
|
|
1
|
+
export { TextEditorController, TextEditorProps, createTextEditor } from './create_text_editor.mjs';
|
|
2
2
|
export { createSchema } from './schema.mjs';
|
|
3
|
-
export { AttachFile, createAttachFile } from './attach_file.mjs';
|
|
4
|
-
|
|
5
|
-
import 'prosemirror-model';
|
|
3
|
+
export { AttachFile, AttachFileOptions, GenerateMetadata, UploadFile, createAttachFile } from './attach_file.mjs';
|
|
4
|
+
export { createInnerHTML, createTextEditorView } from './html.mjs';
|
|
6
5
|
import 'react';
|
|
7
6
|
import 'prosemirror-state';
|
|
8
7
|
import 'prosemirror-view';
|
|
9
8
|
import 'rxjs';
|
|
9
|
+
import './commands.mjs';
|
|
10
|
+
import 'prosemirror-model';
|
|
11
|
+
import './text_editor_controller.mjs';
|
|
12
|
+
import 'orderedmap';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
export { TextEditorController, TextEditorProps, createTextEditor } from './
|
|
1
|
+
export { TextEditorController, TextEditorProps, createTextEditor } from './create_text_editor.js';
|
|
2
2
|
export { createSchema } from './schema.js';
|
|
3
|
-
export { AttachFile, createAttachFile } from './attach_file.js';
|
|
4
|
-
|
|
5
|
-
import 'prosemirror-model';
|
|
3
|
+
export { AttachFile, AttachFileOptions, GenerateMetadata, UploadFile, createAttachFile } from './attach_file.js';
|
|
4
|
+
export { createInnerHTML, createTextEditorView } from './html.js';
|
|
6
5
|
import 'react';
|
|
7
6
|
import 'prosemirror-state';
|
|
8
7
|
import 'prosemirror-view';
|
|
9
8
|
import 'rxjs';
|
|
9
|
+
import './commands.js';
|
|
10
|
+
import 'prosemirror-model';
|
|
11
|
+
import './text_editor_controller.js';
|
|
12
|
+
import 'orderedmap';
|