lexical-medium-editor 1.2.17 → 1.2.19
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 +272 -30
- package/dist-lib/{ImageNode-BhH71HMX.js → ImageNode-Cqkp_4Y6.js} +92 -71
- package/dist-lib/ImageNode-Cqkp_4Y6.js.map +1 -0
- package/dist-lib/editorConfig.es.js +3 -3
- package/dist-lib/index.es.js +715 -702
- package/dist-lib/index.es.js.map +1 -1
- package/dist-lib/lexical-medium-editor.css +1 -1
- package/package.json +1 -1
- package/dist-lib/ImageNode-BhH71HMX.js.map +0 -1
package/README.md
CHANGED
|
@@ -3,63 +3,305 @@ Please refer to the [guide](https://medium-editor-lmr5y.ondigitalocean.app/) for
|
|
|
3
3
|
|
|
4
4
|
## Installation
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
The first step is to install peer dependencies in your project. This package assumes you are working within a React environment, so `react` and `react-dom` should ideally already be part of your project setup. The primary peer dependencies you need to install are:
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
* `@lexical/react`: ">=0.39.0"
|
|
9
|
+
* `@tabler/icons-react`: ">=3.31.0"
|
|
10
|
+
* `lexical`: ">=0.39.0"
|
|
11
|
+
* `react-aria-components`: ">=1.8.0"
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
You can install them using npm. Adjust the versions if needed to match your project's requirements, ensuring they meet the minimum versions specified above. The command to add to install the peer dependencies using npm is:
|
|
11
14
|
|
|
12
|
-
* `@lexical/react`: ">=0.39.0"
|
|
13
|
-
* `@tabler/icons-react`: ">=3.31.0"
|
|
14
|
-
* `lexical`: ">=0.39.0"
|
|
15
|
-
* `react-aria-components`: ">=1.8.0"
|
|
16
|
-
|
|
17
|
-
You can install them using npm. Adjust the versions if needed to match your project's requirements, ensuring they meet the minimum versions specified above.
|
|
18
|
-
|
|
19
|
-
**Using npm:**
|
|
20
15
|
```bash
|
|
21
16
|
npm install @lexical/react @tabler/icons-react lexical react-aria-components
|
|
22
17
|
```
|
|
23
18
|
|
|
24
|
-
|
|
19
|
+
There are other dependencies as well which are listed in the `package.json` file. However, they will be automatically installed by npm. You don't need to manually install them.
|
|
25
20
|
|
|
26
|
-
Once the peer dependencies are installed, you can proceed to install the main package.
|
|
27
|
-
|
|
28
|
-
To install the `lexical-medium-editor` package, run the following command:
|
|
21
|
+
Once the peer dependencies are installed, you can proceed to install the main package. To install using npm, the command is:
|
|
29
22
|
|
|
30
23
|
```bash
|
|
31
|
-
npm install lexical-medium-editor
|
|
24
|
+
npm install lexical-medium-editor@latest
|
|
32
25
|
```
|
|
33
26
|
|
|
34
27
|
## Usage
|
|
35
28
|
|
|
36
|
-
|
|
29
|
+
Once the setup is done, you can create and use an `Editor` component that closely resembles this page as follows:
|
|
30
|
+
|
|
31
|
+
First create an `Editor` component and the associated css as follows:
|
|
32
|
+
|
|
33
|
+
- `src`
|
|
34
|
+
- `components`
|
|
35
|
+
- `Editor.jsx`
|
|
36
|
+
- `editor_styles.css`
|
|
37
|
+
- `App.jsx`
|
|
38
|
+
|
|
39
|
+
The `Editor.jsx` file should look like this:
|
|
37
40
|
|
|
38
41
|
```jsx
|
|
39
42
|
import { useRef } from "react";
|
|
40
|
-
import
|
|
43
|
+
import { Button } from "react-aria-components";
|
|
44
|
+
import { $getRoot } from "lexical";
|
|
45
|
+
import { $generateHtmlFromNodes } from "@lexical/html";
|
|
46
|
+
import LexicalEditor from "lexical-medium-editor";
|
|
41
47
|
import { initialConfig } from "lexical-medium-editor/config";
|
|
42
48
|
import "lexical-medium-editor/styles.css";
|
|
49
|
+
import "./editor_styles.css";
|
|
43
50
|
|
|
44
|
-
|
|
51
|
+
function Navbar({ onCopyHTML, onCopyJSON, onCopyText }) {
|
|
52
|
+
return (
|
|
53
|
+
<nav className="navbar">
|
|
54
|
+
<div className="navbar-links" />
|
|
55
|
+
<div className="action-grp">
|
|
56
|
+
<Button className="navbar-btn" onPress={onCopyHTML}>
|
|
57
|
+
Copy HTML
|
|
58
|
+
</Button>
|
|
59
|
+
<Button className="navbar-btn" onPress={onCopyJSON}>
|
|
60
|
+
Copy JSON
|
|
61
|
+
</Button>
|
|
62
|
+
<Button className="navbar-btn" onPress={onCopyText}>
|
|
63
|
+
Copy Text
|
|
64
|
+
</Button>
|
|
65
|
+
</div>
|
|
66
|
+
</nav>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default function Editor() {
|
|
71
|
+
const editorStateRef = useRef(null);
|
|
45
72
|
const editorRef = useRef(null);
|
|
46
73
|
|
|
47
74
|
const handleOnChange = (editorState) => {
|
|
48
|
-
|
|
75
|
+
editorStateRef.current = editorState;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const copyToClipboard = async (text) => {
|
|
79
|
+
await navigator.clipboard.writeText(text);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const handleCopyHTML = () => {
|
|
83
|
+
const editor = editorRef.current;
|
|
84
|
+
if (editor) {
|
|
85
|
+
editor.read(() => {
|
|
86
|
+
const htmlString = $generateHtmlFromNodes(editor, null);
|
|
87
|
+
copyToClipboard(htmlString);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const handleCopyJSON = () => {
|
|
93
|
+
if (editorStateRef.current) {
|
|
94
|
+
const jsonString = JSON.stringify(editorStateRef.current.toJSON(), null, 2);
|
|
95
|
+
copyToClipboard(jsonString);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const handleCopyText = () => {
|
|
100
|
+
if (editorStateRef.current) {
|
|
101
|
+
editorStateRef.current.read(() => {
|
|
102
|
+
const textContent = $getRoot().getTextContent();
|
|
103
|
+
copyToClipboard(textContent);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
49
106
|
};
|
|
50
107
|
|
|
51
108
|
return (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
109
|
+
<>
|
|
110
|
+
<Navbar
|
|
111
|
+
onCopyHTML={handleCopyHTML}
|
|
112
|
+
onCopyJSON={handleCopyJSON}
|
|
113
|
+
onCopyText={handleCopyText}
|
|
114
|
+
/>
|
|
115
|
+
<div className="editor-wrapper">
|
|
116
|
+
<LexicalEditor
|
|
117
|
+
initialConfig={initialConfig}
|
|
118
|
+
onChange={handleOnChange}
|
|
119
|
+
editorRef={editorRef}
|
|
120
|
+
blockToolbarGap={32}
|
|
121
|
+
isHeadingOneFirst={false}
|
|
122
|
+
spellCheck={false}
|
|
123
|
+
/>
|
|
124
|
+
</div>
|
|
125
|
+
</>
|
|
60
126
|
);
|
|
61
127
|
}
|
|
62
128
|
```
|
|
63
129
|
|
|
64
|
-
|
|
65
|
-
|
|
130
|
+
The `editor_styles.css` file should look like this:
|
|
131
|
+
|
|
132
|
+
```css
|
|
133
|
+
.editor-wrapper {
|
|
134
|
+
margin: 0 auto;
|
|
135
|
+
width: 50%;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@media (max-width: 1200px) {
|
|
139
|
+
.editor-wrapper {
|
|
140
|
+
width: 65%;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@media (max-width: 992px) {
|
|
145
|
+
.editor-wrapper {
|
|
146
|
+
width: 75%;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
@media (max-width: 768px) {
|
|
151
|
+
.editor-wrapper {
|
|
152
|
+
width: 85%;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.navbar {
|
|
157
|
+
display: flex;
|
|
158
|
+
justify-content: space-between;
|
|
159
|
+
align-items: center;
|
|
160
|
+
padding: 8px 16px;
|
|
161
|
+
background-color: white;
|
|
162
|
+
border-bottom: 4px solid #fff34e;
|
|
163
|
+
margin-bottom: 32px;
|
|
164
|
+
height: 64px;
|
|
165
|
+
box-sizing: border-box;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.action-grp {
|
|
169
|
+
gap: 8px;
|
|
170
|
+
display: flex;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.navbar-btn {
|
|
174
|
+
color: var(--text-color-dark);
|
|
175
|
+
background: var(--button-background-dark);
|
|
176
|
+
border: 1px solid var(--border-color-dark);
|
|
177
|
+
border-radius: 4px;
|
|
178
|
+
appearance: none;
|
|
179
|
+
vertical-align: middle;
|
|
180
|
+
font-size: 1rem;
|
|
181
|
+
text-align: center;
|
|
182
|
+
margin: 0;
|
|
183
|
+
outline: none;
|
|
184
|
+
padding: 6px 10px;
|
|
185
|
+
text-decoration: none;
|
|
186
|
+
font-family: "firacode", monospace;
|
|
187
|
+
cursor: pointer;
|
|
188
|
+
|
|
189
|
+
&[data-pressed] {
|
|
190
|
+
box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.1);
|
|
191
|
+
background: var(--button-background-pressed-dark);
|
|
192
|
+
border-color: var(--border-color-pressed-dark);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
&[data-focus-visible] {
|
|
196
|
+
outline: 2px solid var(--focus-ring-color-dark);
|
|
197
|
+
outline-offset: -1px;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
@media (max-width: 576px) {
|
|
202
|
+
.navbar {
|
|
203
|
+
padding: 8px;
|
|
204
|
+
margin-bottom: 16px;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.action-grp {
|
|
208
|
+
gap: 4px;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.navbar-btn {
|
|
212
|
+
padding: 4px 8px;
|
|
213
|
+
font-size: 0.875rem;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
.editor-wrapper {
|
|
218
|
+
width: 95%;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
@media (max-width: 400px) {
|
|
223
|
+
.navbar {
|
|
224
|
+
flex-direction: column;
|
|
225
|
+
height: auto;
|
|
226
|
+
padding: 8px;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.action-grp {
|
|
230
|
+
margin-top: 8px;
|
|
231
|
+
width: 100%;
|
|
232
|
+
justify-content: space-between;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.editor-wrapper {
|
|
236
|
+
width: 100%;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Now you can import and use this component into your main `App.jsx` component and use it like so:
|
|
242
|
+
|
|
243
|
+
```jsx
|
|
244
|
+
import Editor from "./components/Editor";
|
|
245
|
+
import "./App.css";
|
|
246
|
+
|
|
247
|
+
function App() {
|
|
248
|
+
return (
|
|
249
|
+
<div className="app-container">
|
|
250
|
+
<Editor />
|
|
251
|
+
</div>
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export default App;
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
One final change. To use LaTeX, you need to load MathJax v4 into your `index.html` file. This can be done by adding the following tags:
|
|
259
|
+
|
|
260
|
+
```html
|
|
261
|
+
<!doctype html>
|
|
262
|
+
<html lang="en">
|
|
263
|
+
<head>
|
|
264
|
+
<meta charset="UTF-8" />
|
|
265
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
266
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
267
|
+
<title>medium-blog-editor</title>
|
|
268
|
+
<script>
|
|
269
|
+
window.MathJax = {
|
|
270
|
+
tex: {
|
|
271
|
+
inlineMath: [
|
|
272
|
+
["$", "$"],
|
|
273
|
+
["\\(", "\\)"],
|
|
274
|
+
],
|
|
275
|
+
displayMath: [
|
|
276
|
+
["$$", "$$"],
|
|
277
|
+
["\\[", "\\]"],
|
|
278
|
+
],
|
|
279
|
+
},
|
|
280
|
+
chtml: {
|
|
281
|
+
displayOverflow: "scroll",
|
|
282
|
+
linebreaks: {
|
|
283
|
+
inline: true,
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
startup: {
|
|
287
|
+
typeset: false,
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
</script>
|
|
291
|
+
<script
|
|
292
|
+
type="text/javascript"
|
|
293
|
+
id="MathJax-script"
|
|
294
|
+
async
|
|
295
|
+
src="https://cdn.jsdelivr.net/npm/mathjax@4.1.0/tex-mml-chtml.js"
|
|
296
|
+
></script>
|
|
297
|
+
</head>
|
|
298
|
+
<body>
|
|
299
|
+
<div id="root"></div>
|
|
300
|
+
<script type="module" src="/src/main.jsx"></script>
|
|
301
|
+
</body>
|
|
302
|
+
</html>
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
That's it. You're ready to go!
|
|
306
|
+
|
|
307
|
+
Note that this was tested on vite build. It was not thoroughly tested for each scenario. So there's a good chance that you'll encounter errors. If you do, please email them to me at ms.neerajkrishna@gmail.com or you can also raise an issue in the GitHub repository.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsx as o, jsxs as
|
|
2
|
-
import { DecoratorNode as
|
|
3
|
-
import { addClassNamesToElement as a, $findMatchingParent as
|
|
4
|
-
import { useRef as
|
|
1
|
+
import { jsx as o, jsxs as f, Fragment as N } from "react/jsx-runtime";
|
|
2
|
+
import { DecoratorNode as _, $createNodeSelection as O, $setSelection as M, $applyNodeReplacement as l, TextNode as b, ElementNode as v, $getSelection as $, $isRangeSelection as E, $isLineBreakNode as S, $isTextNode as w, $isParagraphNode as T, $createParagraphNode as C, $createTextNode as J } from "lexical";
|
|
3
|
+
import { addClassNamesToElement as a, $findMatchingParent as q } from "@lexical/utils";
|
|
4
|
+
import { useRef as k, useEffect as I } from "react";
|
|
5
5
|
import { renderToString as z } from "react-dom/server";
|
|
6
|
-
const
|
|
7
|
-
const e =
|
|
8
|
-
|
|
6
|
+
const B = ({ children: n, inline: t }) => {
|
|
7
|
+
const e = k(null);
|
|
8
|
+
I(() => {
|
|
9
9
|
e.current && window.MathJax && window.MathJax.typesetPromise && window.MathJax.typesetPromise([e.current]).catch(
|
|
10
10
|
(i) => console.error("MathJax typesetting failed:", i)
|
|
11
11
|
);
|
|
@@ -13,12 +13,12 @@ const I = ({ children: n, inline: t }) => {
|
|
|
13
13
|
const r = `${n}`;
|
|
14
14
|
return /* @__PURE__ */ o("span", { ref: e, children: r });
|
|
15
15
|
};
|
|
16
|
-
class
|
|
16
|
+
class d extends _ {
|
|
17
17
|
static getType() {
|
|
18
18
|
return "math";
|
|
19
19
|
}
|
|
20
20
|
static clone(t) {
|
|
21
|
-
return new
|
|
21
|
+
return new d(t.__equation, t.__inline, t.__key);
|
|
22
22
|
}
|
|
23
23
|
constructor(t, e, r) {
|
|
24
24
|
super(r), this.__equation = t, this.__inline = e;
|
|
@@ -33,8 +33,8 @@ class h extends p {
|
|
|
33
33
|
return this.__inline;
|
|
34
34
|
}
|
|
35
35
|
select() {
|
|
36
|
-
const t =
|
|
37
|
-
return t.add(this.getKey()),
|
|
36
|
+
const t = O();
|
|
37
|
+
return t.add(this.getKey()), M(t), t;
|
|
38
38
|
}
|
|
39
39
|
createDOM(t) {
|
|
40
40
|
const e = document.createElement("span");
|
|
@@ -46,7 +46,7 @@ class h extends p {
|
|
|
46
46
|
static importDOM() {
|
|
47
47
|
return {
|
|
48
48
|
span: (t) => ({
|
|
49
|
-
conversion:
|
|
49
|
+
conversion: H,
|
|
50
50
|
priority: 1
|
|
51
51
|
})
|
|
52
52
|
};
|
|
@@ -57,7 +57,7 @@ class h extends p {
|
|
|
57
57
|
}
|
|
58
58
|
static importJSON(t) {
|
|
59
59
|
const { equation: e, inline: r } = t;
|
|
60
|
-
return
|
|
60
|
+
return D(e, r).updateFromJSON(t);
|
|
61
61
|
}
|
|
62
62
|
exportJSON() {
|
|
63
63
|
return {
|
|
@@ -67,29 +67,29 @@ class h extends p {
|
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
decorate() {
|
|
70
|
-
return /* @__PURE__ */ o(
|
|
70
|
+
return /* @__PURE__ */ o(B, { inline: this.__inline, children: this.__equation });
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
function
|
|
73
|
+
function H(n) {
|
|
74
74
|
let t = null;
|
|
75
75
|
if (n.getAttribute("data-lexical-math") === "true") {
|
|
76
76
|
const e = n.textContent, i = n.getAttribute("data-math-inline") === "true";
|
|
77
|
-
t =
|
|
77
|
+
t = D(e, i);
|
|
78
78
|
}
|
|
79
79
|
return { node: t };
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
return l(new
|
|
81
|
+
function D(n, t) {
|
|
82
|
+
return l(new d(n, t));
|
|
83
83
|
}
|
|
84
84
|
function G(n) {
|
|
85
|
-
return n instanceof
|
|
85
|
+
return n instanceof d;
|
|
86
86
|
}
|
|
87
|
-
class
|
|
87
|
+
class h extends b {
|
|
88
88
|
static getType() {
|
|
89
89
|
return "math-highlight-inline";
|
|
90
90
|
}
|
|
91
91
|
static clone(t) {
|
|
92
|
-
return new
|
|
92
|
+
return new h(t.__equation, t.__key);
|
|
93
93
|
}
|
|
94
94
|
createDOM(t) {
|
|
95
95
|
const e = super.createDOM(t);
|
|
@@ -111,14 +111,14 @@ class d extends v {
|
|
|
111
111
|
return a(e, t._config.theme.math.renderedInline), e.textContent = this.getTextContent(), e.setAttribute("data-lexical-math", "true"), e.setAttribute("data-math-inline", "true"), { element: e };
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
function
|
|
115
|
-
const t = new
|
|
114
|
+
function W(n) {
|
|
115
|
+
const t = new h(n);
|
|
116
116
|
return l(t);
|
|
117
117
|
}
|
|
118
|
-
function
|
|
119
|
-
return n instanceof
|
|
118
|
+
function V(n) {
|
|
119
|
+
return n instanceof h;
|
|
120
120
|
}
|
|
121
|
-
class m extends
|
|
121
|
+
class m extends v {
|
|
122
122
|
static getType() {
|
|
123
123
|
return "math-highlight-block";
|
|
124
124
|
}
|
|
@@ -154,25 +154,25 @@ class m extends D {
|
|
|
154
154
|
return this.remove(), !0;
|
|
155
155
|
}
|
|
156
156
|
insertNewAfter() {
|
|
157
|
-
const t =
|
|
158
|
-
if (
|
|
157
|
+
const t = $();
|
|
158
|
+
if (E(t) && t.isCollapsed()) {
|
|
159
159
|
const e = this.getLastChild(), r = t.anchor.getNode();
|
|
160
|
-
if (r.getKey() === this.getKey() && t.anchor.offset === 0 && this.getChildrenSize() === 0 || e &&
|
|
161
|
-
if (e &&
|
|
160
|
+
if (r.getKey() === this.getKey() && t.anchor.offset === 0 && this.getChildrenSize() === 0 || e && S(e) && r.getKey() === this.getKey() && t.anchor.offset === this.getChildrenSize() || e && w(e) && r.getKey() === e.getKey() && t.anchor.offset === e.getTextContent().length)
|
|
161
|
+
if (e && S(e)) {
|
|
162
162
|
e.remove();
|
|
163
|
-
const u =
|
|
163
|
+
const u = q(this, T), s = C();
|
|
164
164
|
return u ? u.insertAfter(s) : this.insertAfter(s), s.select(), s;
|
|
165
165
|
} else
|
|
166
166
|
return t.insertLineBreak(), null;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
function
|
|
170
|
+
function Q(n) {
|
|
171
171
|
const t = J(n);
|
|
172
172
|
let e = new m(n);
|
|
173
173
|
return l(e.append(t));
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function X(n) {
|
|
176
176
|
return n instanceof m;
|
|
177
177
|
}
|
|
178
178
|
function c() {
|
|
@@ -188,12 +188,12 @@ function c() {
|
|
|
188
188
|
}
|
|
189
189
|
);
|
|
190
190
|
}
|
|
191
|
-
class
|
|
191
|
+
class x extends _ {
|
|
192
192
|
static getType() {
|
|
193
193
|
return "horizontal-divider";
|
|
194
194
|
}
|
|
195
195
|
static clone(t) {
|
|
196
|
-
return new
|
|
196
|
+
return new x(t.__key);
|
|
197
197
|
}
|
|
198
198
|
createDOM(t) {
|
|
199
199
|
const e = document.createElement("div");
|
|
@@ -212,7 +212,7 @@ class f extends p {
|
|
|
212
212
|
static importDOM() {
|
|
213
213
|
return {
|
|
214
214
|
div: (t) => t.getAttribute("data-lexical-horizontal-divider") === "true" ? {
|
|
215
|
-
conversion:
|
|
215
|
+
conversion: L,
|
|
216
216
|
priority: 2
|
|
217
217
|
} : null
|
|
218
218
|
};
|
|
@@ -220,7 +220,7 @@ class f extends p {
|
|
|
220
220
|
exportDOM(t) {
|
|
221
221
|
const { element: e } = super.exportDOM(t);
|
|
222
222
|
return e.setAttribute("data-lexical-horizontal-divider", "true"), { after: (i) => {
|
|
223
|
-
const s = z(/* @__PURE__ */
|
|
223
|
+
const s = z(/* @__PURE__ */ f(N, { children: [
|
|
224
224
|
/* @__PURE__ */ o(c, {}),
|
|
225
225
|
/* @__PURE__ */ o(c, {}),
|
|
226
226
|
/* @__PURE__ */ o(c, {})
|
|
@@ -229,35 +229,41 @@ class f extends p {
|
|
|
229
229
|
}, element: e };
|
|
230
230
|
}
|
|
231
231
|
static importJSON(t) {
|
|
232
|
-
return
|
|
232
|
+
return A().updateFromJSON(t);
|
|
233
233
|
}
|
|
234
234
|
exportJSON() {
|
|
235
235
|
return super.exportJSON();
|
|
236
236
|
}
|
|
237
237
|
decorate() {
|
|
238
|
-
return /* @__PURE__ */
|
|
238
|
+
return /* @__PURE__ */ f(N, { children: [
|
|
239
239
|
/* @__PURE__ */ o(c, {}),
|
|
240
240
|
/* @__PURE__ */ o(c, {}),
|
|
241
241
|
/* @__PURE__ */ o(c, {})
|
|
242
242
|
] });
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function L(n) {
|
|
246
246
|
let t = null;
|
|
247
|
-
return n.getAttribute("data-lexical-horizontal-divider") === "true" && (t =
|
|
247
|
+
return n.getAttribute("data-lexical-horizontal-divider") === "true" && (t = A()), { node: t };
|
|
248
248
|
}
|
|
249
|
-
function
|
|
250
|
-
return l(new
|
|
249
|
+
function A() {
|
|
250
|
+
return l(new x());
|
|
251
251
|
}
|
|
252
|
-
|
|
252
|
+
const p = {
|
|
253
|
+
UPLOADED: "uploaded",
|
|
254
|
+
UPLOADING: "uploading",
|
|
255
|
+
ERROR: "error"
|
|
256
|
+
};
|
|
257
|
+
class g extends _ {
|
|
253
258
|
static getType() {
|
|
254
259
|
return "image";
|
|
255
260
|
}
|
|
256
261
|
static clone(t) {
|
|
257
|
-
|
|
262
|
+
const e = new g(t.__src, t.__uploadState, t.__key);
|
|
263
|
+
return e.__attributes = { ...t.__attributes }, e;
|
|
258
264
|
}
|
|
259
|
-
constructor(t, e) {
|
|
260
|
-
super(
|
|
265
|
+
constructor(t, e = p.UPLOADED, r) {
|
|
266
|
+
super(r), this.__src = t, this.__attributes = {}, this.__uploadState = e;
|
|
261
267
|
}
|
|
262
268
|
createDOM(t) {
|
|
263
269
|
const e = document.createElement("figure");
|
|
@@ -269,7 +275,7 @@ class g extends p {
|
|
|
269
275
|
static importDOM() {
|
|
270
276
|
return {
|
|
271
277
|
figure: (t) => ({
|
|
272
|
-
conversion:
|
|
278
|
+
conversion: P,
|
|
273
279
|
priority: 1
|
|
274
280
|
})
|
|
275
281
|
};
|
|
@@ -285,7 +291,7 @@ class g extends p {
|
|
|
285
291
|
}
|
|
286
292
|
static importJSON(t) {
|
|
287
293
|
const { src: e } = t;
|
|
288
|
-
return
|
|
294
|
+
return y(e).updateFromJSON(t);
|
|
289
295
|
}
|
|
290
296
|
exportJSON() {
|
|
291
297
|
return {
|
|
@@ -294,12 +300,23 @@ class g extends p {
|
|
|
294
300
|
};
|
|
295
301
|
}
|
|
296
302
|
select() {
|
|
297
|
-
const t =
|
|
298
|
-
return t.add(this.getKey()),
|
|
303
|
+
const t = O();
|
|
304
|
+
return t.add(this.getKey()), M(t), t;
|
|
299
305
|
}
|
|
300
306
|
getSrc() {
|
|
301
307
|
return this.__src;
|
|
302
308
|
}
|
|
309
|
+
setSrc(t) {
|
|
310
|
+
const e = this.getWritable();
|
|
311
|
+
return e.__src = t, e;
|
|
312
|
+
}
|
|
313
|
+
getUploadState() {
|
|
314
|
+
return this.__uploadState;
|
|
315
|
+
}
|
|
316
|
+
setUploadState(t) {
|
|
317
|
+
const e = this.getWritable();
|
|
318
|
+
return e.__uploadState = t, e;
|
|
319
|
+
}
|
|
303
320
|
getTextContent() {
|
|
304
321
|
return `
|
|
305
322
|
`;
|
|
@@ -308,40 +325,44 @@ class g extends p {
|
|
|
308
325
|
return !1;
|
|
309
326
|
}
|
|
310
327
|
decorate() {
|
|
311
|
-
const t = { src: this.getSrc(), ...this.__attributes };
|
|
312
|
-
return /* @__PURE__ */ o("img", { ...t })
|
|
328
|
+
const t = { src: this.getSrc(), ...this.__attributes }, e = this.__uploadState;
|
|
329
|
+
return e === p.UPLOADED ? /* @__PURE__ */ o("img", { ...t }) : /* @__PURE__ */ f("div", { className: `medium-img-wrapper medium-img-${e}`, children: [
|
|
330
|
+
/* @__PURE__ */ o("img", { ...t }),
|
|
331
|
+
/* @__PURE__ */ o("div", { className: "medium-img-overlay", children: e === p.UPLOADING ? "Uploading…" : "Upload failed" })
|
|
332
|
+
] });
|
|
313
333
|
}
|
|
314
334
|
}
|
|
315
|
-
function
|
|
335
|
+
function P(n) {
|
|
316
336
|
let t = null;
|
|
317
337
|
if (n.getAttribute("data-lexical-image-container") === "true") {
|
|
318
338
|
const e = n.querySelector("img"), r = e.getAttribute("src");
|
|
319
|
-
t =
|
|
339
|
+
t = y(r);
|
|
320
340
|
for (const i of e.attributes)
|
|
321
341
|
i.name !== "src" && (t.__attributes[i.name] = i.value);
|
|
322
342
|
}
|
|
323
343
|
return { node: t };
|
|
324
344
|
}
|
|
325
|
-
function
|
|
326
|
-
return l(new g(n));
|
|
345
|
+
function y(n, t) {
|
|
346
|
+
return l(new g(n, t));
|
|
327
347
|
}
|
|
328
|
-
function
|
|
348
|
+
function Y(n) {
|
|
329
349
|
return n instanceof g;
|
|
330
350
|
}
|
|
331
351
|
export {
|
|
332
352
|
G as $,
|
|
333
|
-
|
|
353
|
+
x as H,
|
|
334
354
|
g as I,
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
355
|
+
d as M,
|
|
356
|
+
V as a,
|
|
357
|
+
X as b,
|
|
358
|
+
A as c,
|
|
359
|
+
Y as d,
|
|
360
|
+
y as e,
|
|
361
|
+
p as f,
|
|
362
|
+
h as g,
|
|
363
|
+
W as h,
|
|
364
|
+
D as i,
|
|
365
|
+
m as j,
|
|
366
|
+
Q as k
|
|
346
367
|
};
|
|
347
|
-
//# sourceMappingURL=ImageNode-
|
|
368
|
+
//# sourceMappingURL=ImageNode-Cqkp_4Y6.js.map
|