@seafile/seafile-editor 0.3.90 → 0.3.93
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/components/toolbar.js +11 -1
- package/dist/css/richeditor/navbar-imgbutton.css +4 -0
- package/dist/editor/controller/normalize-controller.js +0 -0
- package/dist/editor/controller/shortcut-controller.js +9 -10
- package/dist/editor/custom/custom.js +0 -0
- package/dist/editor/editor-utils/clear-format-utils.js +94 -0
- package/dist/editor/editor-utils/common-editor-utils.js +8 -0
- package/package.json +1 -1
- package/public/locales/en/seafile-editor.json +1 -0
- package/public/locales/zh-CN/seafile-editor.json +1 -0
- package/public/media/seafile-editor-font/iconfont.eot +0 -0
- package/public/media/seafile-editor-font/iconfont.svg +6 -4
- package/public/media/seafile-editor-font/iconfont.ttf +0 -0
- package/public/media/seafile-editor-font/iconfont.woff +0 -0
- package/public/media/seafile-editor-font/iconfont.woff2 +0 -0
- package/public/media/seafile-editor-font.css +10 -6
|
@@ -199,7 +199,17 @@ var ToolBar = /*#__PURE__*/function (_React$Component) {
|
|
|
199
199
|
onInsertRow: this.editorUtils.onInsertRow,
|
|
200
200
|
onRemoveRow: this.editorUtils.onRemoveRow,
|
|
201
201
|
onSetAlign: this.editorUtils.onSetAlign
|
|
202
|
-
})
|
|
202
|
+
}), /*#__PURE__*/React.createElement(ButtonGroup, {
|
|
203
|
+
className: 'editor-btn-group'
|
|
204
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
205
|
+
className: 'editor-clear-format',
|
|
206
|
+
isRichEditor: true,
|
|
207
|
+
text: t('Clear_format'),
|
|
208
|
+
id: 'clearButton',
|
|
209
|
+
icon: 'iconfont icon-clear-format',
|
|
210
|
+
onMouseDown: this.editorUtils.clearFormat,
|
|
211
|
+
isActive: readOnly
|
|
212
|
+
}))), this.props.hasSidePanel && /*#__PURE__*/React.createElement("div", {
|
|
203
213
|
className: "button-container"
|
|
204
214
|
}, !this.props.isShowSidePanel && /*#__PURE__*/React.createElement(ButtonGroup, {
|
|
205
215
|
className: "editor-btn-group position-absolute dropdown-menu-right"
|
|
File without changes
|
|
@@ -8,6 +8,7 @@ import CodeUtils from '../editor-utils/block-element-utils/code-utils';
|
|
|
8
8
|
import TextUtils from '../editor-utils/text-utils';
|
|
9
9
|
import TableUtils from '../editor-utils/block-element-utils/table-utils';
|
|
10
10
|
import BlockquoteUtils from '../editor-utils/block-element-utils/blockquote-utils';
|
|
11
|
+
import { clearBlockFormat, clearMarkerFormat } from '../editor-utils/clear-format-utils';
|
|
11
12
|
var SHORTCUTS = {
|
|
12
13
|
'1.': 'ordered_list',
|
|
13
14
|
'*': 'unordered_list',
|
|
@@ -333,19 +334,12 @@ var withMarkdownShortcut = function withMarkdownShortcut(editor) {
|
|
|
333
334
|
_Editor$nodes10 = _slicedToArray(_Editor$nodes9, 1),
|
|
334
335
|
_node3 = _Editor$nodes10[0];
|
|
335
336
|
|
|
336
|
-
var listItemPath = _node3[1];
|
|
337
|
-
var listNode = Node.parent(editor, listItemPath); // Unwrap the list item when the selection is at the first list item of the first node of document
|
|
337
|
+
var listItemPath = _node3[1]; // Unwrap the list item when the selection is at the first list item
|
|
338
338
|
|
|
339
|
-
if (
|
|
339
|
+
if (listItemPath.at(-1) === 0 && anchor.path[listItemPath.length] === 0) {
|
|
340
340
|
listUtils.unwrapList();
|
|
341
341
|
return;
|
|
342
|
-
} //
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
if (listNode.children.length === 1 && Node.text(listNode).length === 0) {
|
|
346
|
-
listUtils.unwrapList();
|
|
347
|
-
return;
|
|
348
|
-
} // list items with mutiple chidren
|
|
342
|
+
} // List items with mutiple chidren
|
|
349
343
|
|
|
350
344
|
|
|
351
345
|
var currentChildBlockIndex = anchor.path[anchor.path.length - 2];
|
|
@@ -416,6 +410,11 @@ var withMarkdownShortcut = function withMarkdownShortcut(editor) {
|
|
|
416
410
|
});
|
|
417
411
|
return;
|
|
418
412
|
|
|
413
|
+
case 'clear_format':
|
|
414
|
+
clearBlockFormat(editor);
|
|
415
|
+
clearMarkerFormat(editor);
|
|
416
|
+
return;
|
|
417
|
+
|
|
419
418
|
default:
|
|
420
419
|
exec(command);
|
|
421
420
|
}
|
|
File without changes
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Editor, Path, Node } from 'slate';
|
|
2
|
+
|
|
3
|
+
var removeEmptyParentNode = function removeEmptyParentNode(editor, pathRef) {
|
|
4
|
+
var path = pathRef.current;
|
|
5
|
+
var currentNode = Node.get(editor, path);
|
|
6
|
+
var children = currentNode.children;
|
|
7
|
+
|
|
8
|
+
while ((children.length === 0 || children.length === 1 && children[0].text === '') && currentNode.type) {
|
|
9
|
+
Editor.removeNodes(editor, {
|
|
10
|
+
at: path
|
|
11
|
+
});
|
|
12
|
+
path = Path.parent(path);
|
|
13
|
+
currentNode = Node.get(editor, path);
|
|
14
|
+
children = currentNode.children;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
pathRef.unref();
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
var clearBlockFormat = function clearBlockFormat(editor) {
|
|
21
|
+
// get selected block node, like the paragraphs in the blockquote;
|
|
22
|
+
var nodes = Editor.nodes(editor, {
|
|
23
|
+
match: 'block',
|
|
24
|
+
voids: false
|
|
25
|
+
});
|
|
26
|
+
var nodesList = [];
|
|
27
|
+
var pathRefs = Array.from(nodes, function (item) {
|
|
28
|
+
nodesList.push(item);
|
|
29
|
+
return Editor.pathRef(editor, item[1]);
|
|
30
|
+
});
|
|
31
|
+
var firstNode = nodesList[0],
|
|
32
|
+
firstNodeRef = pathRefs[0];
|
|
33
|
+
nodesList.shift();
|
|
34
|
+
pathRefs.shift(); // move first block to outest and set the block to paragraph
|
|
35
|
+
|
|
36
|
+
while (firstNodeRef.current.length > 1) {
|
|
37
|
+
Editor.liftNodes(editor, {
|
|
38
|
+
at: firstNodeRef.current
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (firstNode[0].type !== 'paragraph') {
|
|
43
|
+
Editor.setNodes(editor, {
|
|
44
|
+
type: 'paragraph',
|
|
45
|
+
at: firstNodeRef.current,
|
|
46
|
+
split: true
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
nodesList.forEach(function (item, index) {
|
|
51
|
+
var toPath = index === 0 ? Path.next(firstNodeRef.current) : Path.next(pathRefs[index - 1].current);
|
|
52
|
+
var currentPath = pathRefs[index].current;
|
|
53
|
+
|
|
54
|
+
if (currentPath.length > 1) {
|
|
55
|
+
var parentPath = Path.parent(currentPath);
|
|
56
|
+
var parentRef = Editor.pathRef(editor, parentPath); // move current node to outest
|
|
57
|
+
|
|
58
|
+
Editor.moveNodes(editor, {
|
|
59
|
+
at: currentPath,
|
|
60
|
+
to: toPath
|
|
61
|
+
}); // remove empty parent node
|
|
62
|
+
|
|
63
|
+
removeEmptyParentNode(editor, parentRef);
|
|
64
|
+
} // set current block node to paragraph
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
if (item[0].type !== 'paragraph') {
|
|
68
|
+
Editor.setNodes(editor, {
|
|
69
|
+
type: 'paragraph',
|
|
70
|
+
at: currentPath,
|
|
71
|
+
split: true
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
firstNodeRef.unref();
|
|
76
|
+
pathRefs.forEach(function (ref) {
|
|
77
|
+
return ref.unref();
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
var clearMarkerFormat = function clearMarkerFormat(editor) {
|
|
82
|
+
// clear all markers of selected texts;
|
|
83
|
+
var textProperties = {
|
|
84
|
+
BOLD: false,
|
|
85
|
+
ITALIC: false,
|
|
86
|
+
CODE: false
|
|
87
|
+
};
|
|
88
|
+
editor.exec({
|
|
89
|
+
type: 'format_text',
|
|
90
|
+
properties: textProperties
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export { clearBlockFormat, clearMarkerFormat };
|
|
@@ -366,6 +366,14 @@ var EditorUtils = /*#__PURE__*/function () {
|
|
|
366
366
|
}
|
|
367
367
|
};
|
|
368
368
|
|
|
369
|
+
this.clearFormat = function (event) {
|
|
370
|
+
event.preventDefault();
|
|
371
|
+
|
|
372
|
+
_this.editor.exec({
|
|
373
|
+
type: 'clear_format'
|
|
374
|
+
});
|
|
375
|
+
};
|
|
376
|
+
|
|
369
377
|
this.unwrapLink = function () {
|
|
370
378
|
_this.inlineElementUtils.unwrapLink();
|
|
371
379
|
};
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -14,13 +14,15 @@
|
|
|
14
14
|
/>
|
|
15
15
|
<missing-glyph />
|
|
16
16
|
|
|
17
|
-
<glyph glyph-name="
|
|
17
|
+
<glyph glyph-name="-clear-format" unicode="" d="M918.4 579.2L640 816c-25.6 22.4-64 22.4-83.2-6.4L112 310.4c-9.6-9.6-16-25.6-16-41.6s9.6-32 22.4-41.6L256 112h326.4l342.4 384c19.2 25.6 19.2 60.8-6.4 83.2z m-384-380.8H300.8L224 268.79999999999995c-6.4 6.4-9.6 9.6-9.6 16s0 16 6.4 22.4l185.6 211.2 233.6-201.6-105.6-118.4zM147.2 41.60000000000002h739.2c32 0 51.2-22.4 51.2-51.2 0-32-22.4-51.2-51.2-51.2H147.2c-32 0-51.2 22.4-51.2 51.2 0 28.8 22.4 51.2 51.2 51.2z" horiz-adv-x="1024" />
|
|
18
18
|
|
|
19
|
-
<glyph glyph-name="
|
|
19
|
+
<glyph glyph-name="-enlarge" unicode="" d="M432 860.8C211.2 860.8 32 681.6 32 460.8s179.2-400 400-400c99.2 0 188.8 35.2 256 92.8l217.6-217.6c19.2-19.2 48-19.2 67.2 0s19.2 48 0 67.2L755.2 224c48 67.2 76.8 147.2 76.8 236.8 0 220.8-179.2 400-400 400z m0-99.2c166.4 0 300.8-134.4 300.8-300.8S598.4 160 432 160s-300.8 134.4-300.8 300.8 134.4 300.8 300.8 300.8z m-3.2-124.8c-25.6 0-48-22.4-48-48v-80H300.8c-25.6 0-48-22.4-48-48s22.4-48 48-48h80v-80c0-25.6 22.4-48 48-48s48 22.4 48 48v80h80c25.6 0 48 22.4 48 48s-22.4 48-48 48h-80V588.8c0 25.6-22.4 48-48 48z" horiz-adv-x="1024" />
|
|
20
20
|
|
|
21
|
-
<glyph glyph-name="
|
|
21
|
+
<glyph glyph-name="-shrink" unicode="" d="M432 860.8C211.2 860.8 32 681.6 32 460.8s179.2-400 400-400c99.2 0 188.8 35.2 256 92.8l217.6-217.6c19.2-19.2 48-19.2 67.2 0s19.2 48 0 67.2L755.2 224c48 67.2 76.8 147.2 76.8 236.8 0 220.8-179.2 400-400 400z m0-99.2c166.4 0 300.8-134.4 300.8-300.8S598.4 160 432 160s-300.8 134.4-300.8 300.8 134.4 300.8 300.8 300.8z m-131.2-252.8c-25.6 0-48-22.4-48-48s22.4-48 48-48h256c25.6 0 48 22.4 48 48s-22.4 48-48 48h-256z" horiz-adv-x="1024" />
|
|
22
22
|
|
|
23
|
-
<glyph glyph-name="
|
|
23
|
+
<glyph glyph-name="-right" unicode="" d="M640 380.79999999999995L278.4 742.4c-22.4 19.2-22.4 54.4 0 76.8s57.6 22.4 76.8 0l406.4-400c22.4-22.4 22.4-57.6 0-76.8L355.2-60.799999999999955c-22.4-22.4-57.6-22.4-76.8 0s-22.4 57.6 0 76.8L640 380.79999999999995z" horiz-adv-x="1024" />
|
|
24
|
+
|
|
25
|
+
<glyph glyph-name="-left" unicode="" d="M412.8 380.79999999999995L774.4 742.4c22.4 19.2 22.4 54.4 0 76.8s-57.6 22.4-76.8 0L291.2 419.2c-22.4-22.4-22.4-57.6 0-76.8l406.4-403.2c22.4-22.4 57.6-22.4 76.8 0s22.4 57.6 0 76.8L412.8 380.79999999999995z" horiz-adv-x="1024" />
|
|
24
26
|
|
|
25
27
|
<glyph glyph-name="-formula" unicode="" d="M393.6 576.384h89.6v-128h-118.4l-12.8-54.4c-38.4-166.4-54.4-243.2-73.6-307.2-25.6-105.6-105.6-179.2-217.6-179.2h-16c-6.4 0-12.8 6.4-12.8 12.8v92.8c0 9.6 3.2 12.8 12.8 12.8h16c41.6 9.6 67.2 35.2 80 92.8 19.2 64 35.2 140.8 70.4 304l6.4 25.6-172.8-3.2c-6.4 0-12.8 6.4-12.8 12.8v102.4c0 6.4 6.4 12.8 12.8 12.8l198.4 3.2c16 60.8 22.4 89.6 32 128 35.2 137.6 153.6 182.4 326.4 150.4 3.2 0 9.6 0 12.8-3.2 6.4 0 12.8-9.6 9.6-16l-19.2-115.2c0-6.4-9.6-12.8-16-9.6-6.4 0-12.8 3.2-16 3.2-115.2 22.4-137.6 22.4-153.6-41.6-6.4-35.2-16-54.4-25.6-96zM758.4 448.384l140.8 128h83.2c6.4 0 12.8-6.4 12.8-12.8v-105.6c0-6.4-6.4-12.8-12.8-12.8h-25.6l-128-115.2 86.4-124.8h12.8c6.4 0 12.8-6.4 12.8-12.8v-96c0-6.4-6.4-12.8-12.8-12.8h-96l-99.2 144-131.2-144h-92.8c-6.4 0-12.8 6.4-12.8 12.8v96c0 6.4 6.4 12.8 12.8 12.8h19.2l140.8 137.6-70.4 105.6h-124.8v128h204.8l80-128z" horiz-adv-x="1024" />
|
|
26
28
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
@font-face {
|
|
2
2
|
font-family: "iconfont"; /* Project id 1206766 */
|
|
3
|
-
src: url('./seafile-editor-font/iconfont.eot?t=
|
|
4
|
-
src: url('./seafile-editor-font/iconfont.eot?t=
|
|
5
|
-
url('./seafile-editor-font/iconfont.woff2?t=
|
|
6
|
-
url('./seafile-editor-font/iconfont.woff?t=
|
|
7
|
-
url('./seafile-editor-font/iconfont.ttf?t=
|
|
8
|
-
url('./seafile-editor-font/iconfont.svg?t=
|
|
3
|
+
src: url('./seafile-editor-font/iconfont.eot?t=1645422890587'); /* IE9 */
|
|
4
|
+
src: url('./seafile-editor-font/iconfont.eot?t=1645422890587#iefix') format('embedded-opentype'), /* IE6-IE8 */
|
|
5
|
+
url('./seafile-editor-font/iconfont.woff2?t=1645422890587') format('woff2'),
|
|
6
|
+
url('./seafile-editor-font/iconfont.woff?t=1645422890587') format('woff'),
|
|
7
|
+
url('./seafile-editor-font/iconfont.ttf?t=1645422890587') format('truetype'),
|
|
8
|
+
url('./seafile-editor-font/iconfont.svg?t=1645422890587#iconfont') format('svg');
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.iconfont {
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
-moz-osx-font-smoothing: grayscale;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
.icon-clear-format:before {
|
|
20
|
+
content: "\e760";
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
.iconenlarge:before {
|
|
20
24
|
content: "\e757";
|
|
21
25
|
}
|