@seafile/seafile-editor 1.0.40 → 1.0.42
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/constants/hot-keys.js +1 -1
- package/dist/extension/plugins/blockquote/plugin.js +1 -1
- package/dist/extension/plugins/markdown/plugin.js +46 -2
- package/dist/extension/plugins/paragraph/plugin.js +15 -1
- package/dist/extension/plugins/text-style/helpers.js +5 -0
- package/dist/extension/toolbar/user-help/shortcut-dialog.js +1 -1
- package/package.json +1 -1
- package/public/locales/en/seafile-editor.json +1 -1
|
@@ -18,7 +18,7 @@ const HELPER_HOTKEYS = exports.HELPER_HOTKEYS = [{
|
|
|
18
18
|
'Heading_5': [['#####', 'space']],
|
|
19
19
|
'Heading_6': [['######', 'space']]
|
|
20
20
|
}, {
|
|
21
|
-
'Make_code_block': [['```']],
|
|
21
|
+
'Make_code_block': [['```', 'space']],
|
|
22
22
|
'Insert_new_line': [['Enter']],
|
|
23
23
|
'Escape_code_block': [['Ctrl', 'Enter'], ['Cmd', 'Enter']],
|
|
24
24
|
'Insert_indent': [['Tab']]
|
|
@@ -69,7 +69,7 @@ const withBlockquote = editor => {
|
|
|
69
69
|
});
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
|
-
const isLast = (0, _core.isLastChild)(blockquoteEntry, currentLineEntry);
|
|
72
|
+
const isLast = (0, _core.isLastChild)(blockquoteEntry, currentLineEntry[1]);
|
|
73
73
|
if (isEmptyLine && isLast) {
|
|
74
74
|
const nextPath = _slate.Path.next(blockquoteEntry[1]);
|
|
75
75
|
_slate.Transforms.moveNodes(newEditor, {
|
|
@@ -10,6 +10,7 @@ var _core = require("../../core");
|
|
|
10
10
|
var _constants = require("../../constants");
|
|
11
11
|
var _elementTypes = require("../../constants/element-types");
|
|
12
12
|
var _helpers = require("../blockquote/helpers");
|
|
13
|
+
var _helpers2 = require("../code-block/helpers");
|
|
13
14
|
const KEY_TO_TYPE_FOR_SPACE = {
|
|
14
15
|
// Title shortcut
|
|
15
16
|
'#': _elementTypes.HEADER1,
|
|
@@ -22,13 +23,15 @@ const KEY_TO_TYPE_FOR_SPACE = {
|
|
|
22
23
|
'*': _elementTypes.UNORDERED_LIST,
|
|
23
24
|
'-': _elementTypes.UNORDERED_LIST,
|
|
24
25
|
// Reference shortcut key
|
|
25
|
-
'>': _elementTypes.BLOCKQUOTE
|
|
26
|
+
'>': _elementTypes.BLOCKQUOTE,
|
|
27
|
+
'```': _elementTypes.CODE_BLOCK
|
|
26
28
|
};
|
|
27
29
|
const KEY_TO_INLINE_TYPE_FOR_SPACE = {
|
|
28
30
|
// Inline shortcut keys
|
|
29
31
|
'**': _constants.TEXT_STYLE_MAP.BOLD,
|
|
30
32
|
'*': _constants.TEXT_STYLE_MAP.ITALIC,
|
|
31
|
-
'***': _constants.TEXT_STYLE_MAP.BOLD_ITALIC
|
|
33
|
+
'***': _constants.TEXT_STYLE_MAP.BOLD_ITALIC,
|
|
34
|
+
'`': _constants.TEXT_STYLE_MAP.CODE
|
|
32
35
|
};
|
|
33
36
|
const getBeforeText = editor => {
|
|
34
37
|
const {
|
|
@@ -89,6 +92,7 @@ const withMarkDown = editor => {
|
|
|
89
92
|
const italicAndBoldType = KEY_TO_INLINE_TYPE_FOR_SPACE[beforeText.slice(-3)];
|
|
90
93
|
const boldType = KEY_TO_INLINE_TYPE_FOR_SPACE[beforeText.slice(-2)];
|
|
91
94
|
const italicType = KEY_TO_INLINE_TYPE_FOR_SPACE[beforeText.slice(-1)];
|
|
95
|
+
const inlineCode = KEY_TO_INLINE_TYPE_FOR_SPACE[beforeText.slice(-1)];
|
|
92
96
|
if (!type && !boldType && !italicType && !italicAndBoldType) return insertText(text);
|
|
93
97
|
if (italicAndBoldType === _constants.TEXT_STYLE_MAP.BOLD_ITALIC) {
|
|
94
98
|
const restStr = beforeText === null || beforeText === void 0 ? void 0 : beforeText.slice(0, beforeText.length - 3);
|
|
@@ -171,6 +175,42 @@ const withMarkDown = editor => {
|
|
|
171
175
|
return insertText(newText);
|
|
172
176
|
}
|
|
173
177
|
}
|
|
178
|
+
if (type !== _elementTypes.CODE_BLOCK && inlineCode === _constants.TEXT_STYLE_MAP.CODE) {
|
|
179
|
+
const restStr = beforeText === null || beforeText === void 0 ? void 0 : beforeText.slice(0, beforeText.length - 1);
|
|
180
|
+
const startOffset = restStr === null || restStr === void 0 ? void 0 : restStr.lastIndexOf('`');
|
|
181
|
+
const endOffset = (beforeText === null || beforeText === void 0 ? void 0 : beforeText.lastIndexOf('`')) + 1;
|
|
182
|
+
|
|
183
|
+
// ``
|
|
184
|
+
if (restStr === '`') {
|
|
185
|
+
return insertText(text);
|
|
186
|
+
}
|
|
187
|
+
if (startOffset === -1 && restStr.length > 0) {
|
|
188
|
+
return insertText(text);
|
|
189
|
+
}
|
|
190
|
+
if (startOffset !== -1) {
|
|
191
|
+
_slate.Transforms.delete(editor, {
|
|
192
|
+
at: {
|
|
193
|
+
anchor: {
|
|
194
|
+
path: range.focus.path,
|
|
195
|
+
offset: startOffset
|
|
196
|
+
},
|
|
197
|
+
focus: {
|
|
198
|
+
...selection.focus
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
voids: true
|
|
202
|
+
});
|
|
203
|
+
const newType = inlineCode.toLowerCase();
|
|
204
|
+
const newText = beforeText.slice(startOffset + 1, endOffset - 1);
|
|
205
|
+
_slate.Editor.addMark(editor, newType, true);
|
|
206
|
+
insertText(newText);
|
|
207
|
+
|
|
208
|
+
// add space with inline code
|
|
209
|
+
_slate.Editor.removeMark(editor, newType);
|
|
210
|
+
insertText(' ');
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
174
214
|
|
|
175
215
|
// Delete element
|
|
176
216
|
_slate.Transforms.select(editor, range);
|
|
@@ -183,6 +223,10 @@ const withMarkDown = editor => {
|
|
|
183
223
|
(0, _helpers.setBlockQuoteType)(editor, false);
|
|
184
224
|
return;
|
|
185
225
|
}
|
|
226
|
+
if (type === _elementTypes.CODE_BLOCK) {
|
|
227
|
+
(0, _helpers2.transformToCodeBlock)(editor);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
186
230
|
_slate.Transforms.setNodes(editor, {
|
|
187
231
|
type
|
|
188
232
|
});
|
|
@@ -9,9 +9,23 @@ var _core = require("../../core");
|
|
|
9
9
|
var _elementTypes = require("../../constants/element-types");
|
|
10
10
|
const withParagraph = editor => {
|
|
11
11
|
const {
|
|
12
|
-
deleteBackward
|
|
12
|
+
deleteBackward,
|
|
13
|
+
insertBreak
|
|
13
14
|
} = editor;
|
|
14
15
|
const newEditor = editor;
|
|
16
|
+
newEditor.insertBreak = () => {
|
|
17
|
+
if (!newEditor.selection) {
|
|
18
|
+
insertBreak();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const [node] = _slate.Editor.nodes(newEditor, {
|
|
22
|
+
mode: 'lowest'
|
|
23
|
+
});
|
|
24
|
+
if (node && node[0].code) {
|
|
25
|
+
_slate.Editor.removeMark(newEditor, 'code');
|
|
26
|
+
}
|
|
27
|
+
insertBreak();
|
|
28
|
+
};
|
|
15
29
|
newEditor.deleteBackward = unit => {
|
|
16
30
|
const {
|
|
17
31
|
selection
|
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.toggleTextStyle = exports.removeMark = exports.isMenuDisabled = exports.isMarkActive = exports.addMark = void 0;
|
|
7
7
|
var _slate = require("slate");
|
|
8
8
|
var _helpers = require("../code-block/helpers");
|
|
9
|
+
var _constants = require("../../constants");
|
|
10
|
+
var _core = require("../../core");
|
|
9
11
|
const isMenuDisabled = (editor, isReadonly) => {
|
|
10
12
|
if (isReadonly) return true;
|
|
11
13
|
const {
|
|
@@ -45,5 +47,8 @@ exports.removeMark = removeMark;
|
|
|
45
47
|
const toggleTextStyle = (editor, type) => {
|
|
46
48
|
const isActive = isMarkActive(editor, type);
|
|
47
49
|
isActive ? removeMark(editor, type) : addMark(editor, type);
|
|
50
|
+
if (type === _constants.TEXT_STYLE_MAP.CODE) {
|
|
51
|
+
(0, _core.focusEditor)(editor);
|
|
52
|
+
}
|
|
48
53
|
};
|
|
49
54
|
exports.toggleTextStyle = toggleTextStyle;
|
|
@@ -104,7 +104,7 @@ class KeyboardShortcuts extends _react.default.PureComponent {
|
|
|
104
104
|
className: "keyboard-shortcut-container"
|
|
105
105
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
106
106
|
className: "col-4"
|
|
107
|
-
}, this.renderShortcut(['```'
|
|
107
|
+
}, this.renderShortcut(['```', 'space'])), /*#__PURE__*/_react.default.createElement("div", {
|
|
108
108
|
className: "col-8"
|
|
109
109
|
}, t(userHelpData[2].shortcutData['Make_code_block']))), this.renderContainer(['Tab'], t(userHelpData[2].shortcutData['Insert_indent'])), this.renderContainer(['Enter'], t(userHelpData[2].shortcutData['Insert_new_line'])), this.renderContainer([controlKey, 'Enter'], t(userHelpData[2].shortcutData['Escape_code_block']))), /*#__PURE__*/_react.default.createElement("div", {
|
|
110
110
|
className: "pb-2"
|
package/package.json
CHANGED