@opositatest/markdown-text-editor 1.4.0 → 1.4.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/README.md +18 -0
- package/dist/editor.js +47 -25
- package/dist/react/index.js +2339 -2317
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,9 +30,27 @@ The editor currently focuses on text-first rich content that serializes cleanly
|
|
|
30
30
|
- Block quotes
|
|
31
31
|
- Code blocks
|
|
32
32
|
- Links
|
|
33
|
+
- Tables
|
|
33
34
|
- Inline styles: bold, italic, underline, strikethrough, and inline code
|
|
34
35
|
- Display math blocks written in LaTeX
|
|
35
36
|
|
|
37
|
+
Indented / nested blocks are **not** part of the supported surface: `Tab` never indents (see [Tab key](#tab-key)).
|
|
38
|
+
|
|
39
|
+
### Tab key
|
|
40
|
+
|
|
41
|
+
`Tab` behaves like it does in any other form control: it moves focus to the next focusable element of the
|
|
42
|
+
host page (`Shift-Tab` moves to the previous one), so it never indents a block or uses the browser's focus as a
|
|
43
|
+
trap. `Escape` still blurs the editor.
|
|
44
|
+
|
|
45
|
+
The only exceptions are BlockNote's own behaviours *inside* a block:
|
|
46
|
+
|
|
47
|
+
- **Code blocks**: `Tab` inserts two spaces. `Shift-Tab` leaves the editor.
|
|
48
|
+
- **Tables**: `Tab` / `Shift-Tab` move between cells. At the first/last cell they leave the editor instead of
|
|
49
|
+
indenting the table.
|
|
50
|
+
|
|
51
|
+
Markdown that already contains nested lists (pasted content or a document saved before this rule) is still
|
|
52
|
+
parsed and re-exported unchanged, but indentation can no longer be created from the keyboard.
|
|
53
|
+
|
|
36
54
|
### Math / LaTeX blocks
|
|
37
55
|
|
|
38
56
|
The package includes a custom math block on top of the default BlockNote schema. It renders display formulas with KaTeX and stores them as fenced display-math blocks in Markdown:
|
package/dist/editor.js
CHANGED
|
@@ -87998,20 +87998,42 @@ var Q9 = {
|
|
|
87998
87998
|
}
|
|
87999
87999
|
},
|
|
88000
88000
|
generic: { ctrl_shortcut: "Ctrl" }
|
|
88001
|
-
};
|
|
88001
|
+
}, H_e = "codeBlock", U_e = "no-tab-indentation";
|
|
88002
|
+
function W_e(e) {
|
|
88003
|
+
return e.key !== "Tab" || !e.shiftKey && e.isInCodeBlock ? !1 : !e.canMoveToAdjacentTableCell;
|
|
88004
|
+
}
|
|
88005
|
+
function G_e(e) {
|
|
88006
|
+
return e.selection.$from.parent.type.name === H_e;
|
|
88007
|
+
}
|
|
88008
|
+
function K_e(e, t) {
|
|
88009
|
+
return tS(t)(e, void 0);
|
|
88010
|
+
}
|
|
88011
|
+
function q_e(e, t) {
|
|
88012
|
+
return W_e({
|
|
88013
|
+
key: t.key,
|
|
88014
|
+
shiftKey: t.shiftKey,
|
|
88015
|
+
isInCodeBlock: G_e(e.state),
|
|
88016
|
+
canMoveToAdjacentTableCell: K_e(e.state, t.shiftKey ? -1 : 1)
|
|
88017
|
+
});
|
|
88018
|
+
}
|
|
88019
|
+
var J_e = () => ({
|
|
88020
|
+
key: U_e,
|
|
88021
|
+
prosemirrorPlugins: [new sr({ props: { handleDOMEvents: { keydown: q_e } } })]
|
|
88022
|
+
});
|
|
88002
88023
|
//#endregion
|
|
88003
88024
|
//#region src/hooks/use-app-block-note-editor/use-app-block-note-editor.ts
|
|
88004
|
-
async function
|
|
88025
|
+
async function Y_e(e) {
|
|
88005
88026
|
return new Promise((t) => {
|
|
88006
88027
|
let n = new FileReader();
|
|
88007
88028
|
n.onloadend = () => t(n.result), n.readAsDataURL(e);
|
|
88008
88029
|
});
|
|
88009
88030
|
}
|
|
88010
|
-
function
|
|
88031
|
+
function X_e(e) {
|
|
88011
88032
|
let { placeholder: t } = e;
|
|
88012
88033
|
return Z1({
|
|
88013
88034
|
schema: J9,
|
|
88014
|
-
|
|
88035
|
+
extensions: [J_e],
|
|
88036
|
+
uploadFile: Y_e,
|
|
88015
88037
|
dictionary: t ? {
|
|
88016
88038
|
...Q9,
|
|
88017
88039
|
placeholders: {
|
|
@@ -88024,15 +88046,15 @@ function U_e(e) {
|
|
|
88024
88046
|
}
|
|
88025
88047
|
//#endregion
|
|
88026
88048
|
//#region src/editor/editor-field/editor-field-markdown.ts
|
|
88027
|
-
var
|
|
88028
|
-
function
|
|
88029
|
-
let n =
|
|
88049
|
+
var Z_e = /^<img\s+[^>]*\bwidth="\d+(?:\.\d+)?"[^>]*\/?>$/i, Q_e = /(\w+)="([^"]*)"/g;
|
|
88050
|
+
function $_e(e, t) {
|
|
88051
|
+
let n = nve(t).flatMap((t) => {
|
|
88030
88052
|
if (t.type === "math") return [{
|
|
88031
88053
|
type: "math",
|
|
88032
88054
|
props: { latex: t.value }
|
|
88033
88055
|
}];
|
|
88034
88056
|
if (t.type === "image") {
|
|
88035
|
-
let e =
|
|
88057
|
+
let e = eve(t.value);
|
|
88036
88058
|
return e ? [e] : [];
|
|
88037
88059
|
}
|
|
88038
88060
|
return t.value.trim() ? e.tryParseMarkdownToBlocks(t.value) : [];
|
|
@@ -88055,9 +88077,9 @@ function $9(e, t = e.document) {
|
|
|
88055
88077
|
}
|
|
88056
88078
|
return i(), n.join("\n\n").trim();
|
|
88057
88079
|
}
|
|
88058
|
-
function
|
|
88080
|
+
function eve(e) {
|
|
88059
88081
|
let t = {};
|
|
88060
|
-
for (let n of e.matchAll(
|
|
88082
|
+
for (let n of e.matchAll(Q_e)) t[n[1]] = tve(n[2]);
|
|
88061
88083
|
let n = t.src;
|
|
88062
88084
|
return n ? {
|
|
88063
88085
|
type: "image",
|
|
@@ -88067,10 +88089,10 @@ function q_e(e) {
|
|
|
88067
88089
|
}
|
|
88068
88090
|
} : null;
|
|
88069
88091
|
}
|
|
88070
|
-
function
|
|
88092
|
+
function tve(e) {
|
|
88071
88093
|
return e.replace(/"/g, "\"").replace(/&/g, "&");
|
|
88072
88094
|
}
|
|
88073
|
-
function
|
|
88095
|
+
function nve(e) {
|
|
88074
88096
|
let t = e.replace(/\r\n?/g, "\n");
|
|
88075
88097
|
if (!t.trim()) return [];
|
|
88076
88098
|
let n = t.split("\n"), r = [], i = [], a = null;
|
|
@@ -88094,7 +88116,7 @@ function Y_e(e) {
|
|
|
88094
88116
|
a.push(e);
|
|
88095
88117
|
continue;
|
|
88096
88118
|
}
|
|
88097
|
-
if (
|
|
88119
|
+
if (Z_e.test(t)) {
|
|
88098
88120
|
o(), r.push({
|
|
88099
88121
|
type: "image",
|
|
88100
88122
|
value: t
|
|
@@ -88107,9 +88129,9 @@ function Y_e(e) {
|
|
|
88107
88129
|
}
|
|
88108
88130
|
//#endregion
|
|
88109
88131
|
//#region src/editor/hooks/use-editor-field-controller.ts
|
|
88110
|
-
function
|
|
88111
|
-
let { defaultValue: t, enabledMediaBlocks: n = [], hiddenSlashMenuItems: r = [], onChange: i, onReady: a, placeholder: o, ref: s, value: c } = e, l = (0, E.useRef)(c ?? t ?? ""), u = (0, E.useRef)(!1), d =
|
|
88112
|
-
u.current = !0, d.replaceBlocks(d.document,
|
|
88132
|
+
function rve(e) {
|
|
88133
|
+
let { defaultValue: t, enabledMediaBlocks: n = [], hiddenSlashMenuItems: r = [], onChange: i, onReady: a, placeholder: o, ref: s, value: c } = e, l = (0, E.useRef)(c ?? t ?? ""), u = (0, E.useRef)(!1), d = X_e({ placeholder: o }), f = d, p = (0, E.useCallback)((e) => {
|
|
88134
|
+
u.current = !0, d.replaceBlocks(d.document, $_e(f, e)), l.current = $9(f), u.current = !1;
|
|
88113
88135
|
}, [d, f]), m = (0, E.useCallback)(() => {
|
|
88114
88136
|
d.focus();
|
|
88115
88137
|
}, [d]), h = (0, E.useCallback)(() => l.current, []), g = (0, E.useCallback)((e) => {
|
|
@@ -88165,12 +88187,12 @@ function X_e(e) {
|
|
|
88165
88187
|
}
|
|
88166
88188
|
//#endregion
|
|
88167
88189
|
//#region src/editor/editor-field/editor-field.tsx
|
|
88168
|
-
function
|
|
88190
|
+
function ive(e, t) {
|
|
88169
88191
|
let n = {};
|
|
88170
88192
|
if (e && (n.width = e), t && (n.height = t, n["--markdown-text-editor-height"] = t), !(!e && !t)) return n;
|
|
88171
88193
|
}
|
|
88172
|
-
var
|
|
88173
|
-
let { editor: m, handleBlockNoteChange: h, handleSuggestionMenuItems: g } =
|
|
88194
|
+
var ave = (0, E.forwardRef)(function({ className: e, defaultValue: t, disabled: n = !1, enabledMediaBlocks: r = [], formattingToolbar: i = !0, height: a, hiddenSlashMenuItems: o = [], onChange: s, onReady: c, placeholder: l, readonly: u = !1, value: d, width: f }, p) {
|
|
88195
|
+
let { editor: m, handleBlockNoteChange: h, handleSuggestionMenuItems: g } = rve({
|
|
88174
88196
|
defaultValue: t,
|
|
88175
88197
|
enabledMediaBlocks: r,
|
|
88176
88198
|
hiddenSlashMenuItems: o,
|
|
@@ -88179,7 +88201,7 @@ var Q_e = (0, E.forwardRef)(function({ className: e, defaultValue: t, disabled:
|
|
|
88179
88201
|
placeholder: l,
|
|
88180
88202
|
ref: p,
|
|
88181
88203
|
value: d
|
|
88182
|
-
}), _ =
|
|
88204
|
+
}), _ = ive(f, a);
|
|
88183
88205
|
return /* @__PURE__ */ (0, D.jsx)("div", {
|
|
88184
88206
|
className: e,
|
|
88185
88207
|
"data-disabled": n ? "true" : void 0,
|
|
@@ -88199,7 +88221,7 @@ var Q_e = (0, E.forwardRef)(function({ className: e, defaultValue: t, disabled:
|
|
|
88199
88221
|
})
|
|
88200
88222
|
})
|
|
88201
88223
|
});
|
|
88202
|
-
}),
|
|
88224
|
+
}), ove = class extends HTMLElement {
|
|
88203
88225
|
static formAssociated = !0;
|
|
88204
88226
|
static get observedAttributes() {
|
|
88205
88227
|
return [...m];
|
|
@@ -88331,7 +88353,7 @@ var Q_e = (0, E.forwardRef)(function({ className: e, defaultValue: t, disabled:
|
|
|
88331
88353
|
return this.required && !this.disabled && !this.readOnly && this.currentValue === "";
|
|
88332
88354
|
}
|
|
88333
88355
|
renderReact() {
|
|
88334
|
-
!this.isConnected || !this.root || this.root.render(/* @__PURE__ */ (0, D.jsx)(
|
|
88356
|
+
!this.isConnected || !this.root || this.root.render(/* @__PURE__ */ (0, D.jsx)(ave, {
|
|
88335
88357
|
ref: this.handleEditorRef,
|
|
88336
88358
|
value: this.currentValue,
|
|
88337
88359
|
disabled: this.disabled,
|
|
@@ -88409,10 +88431,10 @@ var Q_e = (0, E.forwardRef)(function({ className: e, defaultValue: t, disabled:
|
|
|
88409
88431
|
};
|
|
88410
88432
|
//#endregion
|
|
88411
88433
|
//#region src/markdown-text-editor/register-markdown-text-editor.ts
|
|
88412
|
-
function
|
|
88413
|
-
customElements.get("markdown-text-editor") || customElements.define(d,
|
|
88434
|
+
function sve() {
|
|
88435
|
+
customElements.get("markdown-text-editor") || customElements.define(d, ove);
|
|
88414
88436
|
}
|
|
88415
|
-
|
|
88437
|
+
sve();
|
|
88416
88438
|
//#endregion
|
|
88417
88439
|
|
|
88418
88440
|
export {};
|