@vonaffenfels/slate-editor 1.1.11 → 1.1.12
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/BlockEditor.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/Toolbar/Toolbar.js +20 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonaffenfels/slate-editor",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.12",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"cssnano": "^5.0.1",
|
|
73
73
|
"escape-html": "^1.0.3"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "772f1444de93f6949ce340b13bc24665493d5ef1",
|
|
76
76
|
"publishConfig": {
|
|
77
77
|
"access": "public"
|
|
78
78
|
}
|
package/src/Toolbar/Toolbar.js
CHANGED
|
@@ -2,9 +2,8 @@ import ReactDOM from "react-dom";
|
|
|
2
2
|
import React, {
|
|
3
3
|
useEffect, useRef, useState,
|
|
4
4
|
} from "react";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
} from "slate-react";
|
|
5
|
+
import {ReactEditor} from "slate-react";
|
|
6
|
+
import {Node} from "slate";
|
|
8
7
|
import classNames from "classnames";
|
|
9
8
|
// eslint-disable-next-line import/no-unresolved
|
|
10
9
|
import "scss/toolbar.scss";
|
|
@@ -106,7 +105,24 @@ export const Toolbar = ({
|
|
|
106
105
|
},
|
|
107
106
|
};
|
|
108
107
|
|
|
109
|
-
|
|
108
|
+
if (lastSelection?.anchor?.path?.length) {
|
|
109
|
+
lastSelection.anchor.path.forEach((p, i) => {
|
|
110
|
+
let slicedPath = lastSelection.anchor.path.slice(0, i + 1);
|
|
111
|
+
let node = Node.get(editor, slicedPath);
|
|
112
|
+
|
|
113
|
+
// Wenn Paragraph, dann auf die Ebene des Paragraphen
|
|
114
|
+
if (node.type === "paragraph") {
|
|
115
|
+
Transforms.insertNodes(editor, [element], {at: slicedPath});
|
|
116
|
+
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Wenn vorletzter Anchor, dann einfügen (letzter ist column, keine row)
|
|
121
|
+
if (i === lastSelection.anchor.path.length - 2) {
|
|
122
|
+
Transforms.insertNodes(editor, [element], {at: slicedPath});
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
110
126
|
};
|
|
111
127
|
|
|
112
128
|
function renderMenu() {
|