@seafile/seafile-editor 1.0.8 → 1.0.10
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.
|
@@ -3,6 +3,7 @@ import 'prismjs/themes/prism.css';
|
|
|
3
3
|
import 'prismjs/components/prism-javascript';
|
|
4
4
|
import 'prismjs/components/prism-typescript';
|
|
5
5
|
import 'prismjs/components/prism-markup';
|
|
6
|
+
import 'prismjs/components/prism-markup-templating';
|
|
6
7
|
import 'prismjs/components/prism-go';
|
|
7
8
|
import 'prismjs/components/prism-php';
|
|
8
9
|
import 'prismjs/components/prism-c';
|
|
@@ -21,7 +21,8 @@ const codeBlockRule = (element, parseChild) => {
|
|
|
21
21
|
} else {
|
|
22
22
|
const lang = 'plaintext';
|
|
23
23
|
const content = childNodes[0].textContent;
|
|
24
|
-
const
|
|
24
|
+
const textArr = content.split('\n').filter(Boolean);
|
|
25
|
+
const children = textArr.map(text => {
|
|
25
26
|
return {
|
|
26
27
|
id: slugid.nice(),
|
|
27
28
|
type: CODE_LINE,
|
|
@@ -65,7 +66,7 @@ const codeBlockRule = (element, parseChild) => {
|
|
|
65
66
|
}]
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
|
-
const codes = content.
|
|
69
|
+
const codes = content.slugid('\n').filter(Boolean);
|
|
69
70
|
return codes.map(item => {
|
|
70
71
|
return {
|
|
71
72
|
id: slugid.nice(),
|
|
@@ -15,7 +15,11 @@ const tableRule = (element, parseChild) => {
|
|
|
15
15
|
if (nodeName === 'THEAD' || nodeName === 'TBODY') {
|
|
16
16
|
return parseChild(childNodes);
|
|
17
17
|
}
|
|
18
|
-
if (nodeName === 'TR') {
|
|
18
|
+
if (nodeName === 'TR' && childNodes.length > 0) {
|
|
19
|
+
// patch
|
|
20
|
+
const children = Array.from(childNodes);
|
|
21
|
+
const hasTdOrTh = children.some(item => item.nodeName === 'TH' || item.nodeName === 'TD');
|
|
22
|
+
if (!hasTdOrTh) return;
|
|
19
23
|
return {
|
|
20
24
|
id: slugid.nice(),
|
|
21
25
|
type: TABLE_ROW,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import slugid from 'slugid';
|
|
2
2
|
import { generateDefaultText } from '../../extension/core';
|
|
3
3
|
import { BLOCKQUOTE, HEADER, IMAGE, LINK, PARAGRAPH, TABLE, CODE_BLOCK, LIST_ITEM, ORDERED_LIST, UNORDERED_LIST, CHECK_LIST_ITEM, CODE_LINE, TABLE_ROW, TABLE_CELL } from '../../extension/constants/element-types';
|
|
4
|
+
import deserializeHtml from '../html-to-slate';
|
|
4
5
|
const INLINE_KEY_MAP = {
|
|
5
6
|
strong: 'bold',
|
|
6
7
|
emphasis: 'italic'
|
|
@@ -156,8 +157,11 @@ export const transformListItem = node => {
|
|
|
156
157
|
return transformCodeBlock(child);
|
|
157
158
|
} else if (child.type === 'list') {
|
|
158
159
|
return transformList(child);
|
|
160
|
+
} else if (child.type === 'html') {
|
|
161
|
+
// patch
|
|
162
|
+
return transformBlockHtml(child);
|
|
159
163
|
}
|
|
160
|
-
})
|
|
164
|
+
}).flat()
|
|
161
165
|
};
|
|
162
166
|
};
|
|
163
167
|
export const transformOrderedList = node => {
|
|
@@ -279,7 +283,7 @@ export const transformHtml = node => {
|
|
|
279
283
|
} = new DOMParser().parseFromString(node.value, 'text/html');
|
|
280
284
|
const img = body.firstChild;
|
|
281
285
|
const src = img.getAttribute('src');
|
|
282
|
-
if (!src) return defaultTextNode;
|
|
286
|
+
if (!src) return [defaultTextNode];
|
|
283
287
|
const alt = img.getAttribute('alt');
|
|
284
288
|
const title = img.getAttribute('title');
|
|
285
289
|
const width = img.getAttribute('width');
|
|
@@ -307,14 +311,17 @@ export const transformHtml = node => {
|
|
|
307
311
|
};
|
|
308
312
|
return [generateDefaultText(), image, generateDefaultText()];
|
|
309
313
|
}
|
|
310
|
-
return defaultTextNode;
|
|
314
|
+
return [defaultTextNode];
|
|
311
315
|
};
|
|
312
316
|
export const transformBlockHtml = node => {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
317
|
+
if (node.value.slice(0, 4).toLowerCase() === '<img') {
|
|
318
|
+
return {
|
|
319
|
+
id: slugid.nice(),
|
|
320
|
+
type: PARAGRAPH,
|
|
321
|
+
children: transformHtml(node)
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
return deserializeHtml(node.value);
|
|
318
325
|
};
|
|
319
326
|
export const transformMath = node => {
|
|
320
327
|
return {
|