@seafile/seafile-editor 0.3.84 → 0.3.85

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.
@@ -210,43 +210,39 @@ var Plugin = function Plugin(_editor) {
210
210
 
211
211
  var table = _this.tableUtils.getSelectedTableCells();
212
212
 
213
- if (!table) {
214
- setEventTransfer(event, 'text', SfEditor.text(editor, editor.selection));
213
+ if (table) {
214
+ setEventTransfer(event, 'fragment', table);
215
215
  return;
216
216
  }
217
-
218
- setEventTransfer(event, 'fragment', table);
219
- return;
220
217
  }
221
218
 
222
- if (_this.codeUtils.isInCodeBlock() && !Range.isCollapsed(editor.selection)) {
223
- var anchorPoint = editor.selection.anchor;
224
- var focusPoint = editor.selection.focus;
225
- var anchorCodeBlock = Editor.match(_this.editor, anchorPoint, {
226
- type: 'code_block'
219
+ if (editor.selection && !Range.isCollapsed(editor.selection)) {
220
+ // get block deepest block node.
221
+ // for example: code line in a code block, paragraph in a list
222
+ var blockList = Editor.nodes(editor, {
223
+ at: editor.selection,
224
+ match: 'block'
227
225
  });
228
- var focusCodeBlock = Editor.match(_this.editor, focusPoint, {
229
- type: 'code_block'
230
- });
231
- /*
232
- If the selection is within the range of the selected code block
233
- copy the selected code line as paragraph
234
- */
235
226
 
236
- if (anchorCodeBlock && focusCodeBlock && Path.equals(focusCodeBlock[1], anchorCodeBlock[1])) {
237
- event.preventDefault();
238
- var fragment = Node.fragment(editor, editor.selection);
239
- fragment = fragment[0].children.map(function (codeLine) {
240
- var text = Node.text(codeLine);
241
- return {
242
- type: 'paragraph',
243
- children: [{
244
- text: text
245
- }]
246
- };
247
- });
248
- setEventTransfer(event, 'fragment', fragment);
249
- return;
227
+ if (blockList) {
228
+ var nodeList = Array.from(blockList);
229
+ /**
230
+ * if only one block element selected, write the selected content as paragraph or text to clipboard
231
+ * instead of use slate default behavior which write the outest element to clipboard
232
+ */
233
+
234
+ if (nodeList.length === 1) {
235
+ event.preventDefault();
236
+ var node = nodeList[0][0];
237
+
238
+ if (node && node.type === 'paragraph') {
239
+ setEventTransfer(event, 'fragment', [node]);
240
+ } else {
241
+ setEventTransfer(event, 'text', SfEditor.text(editor, editor.selection));
242
+ }
243
+
244
+ return;
245
+ }
250
246
  }
251
247
  }
252
248
  };
@@ -496,7 +496,7 @@ function _nodeToSlate(node, opts) {
496
496
  return {
497
497
  type: 'link',
498
498
  data: data,
499
- nodes: children
499
+ children: children
500
500
  };
501
501
  } else {
502
502
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-editor",
3
- "version": "0.3.84",
3
+ "version": "0.3.85",
4
4
  "private": false,
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "^0.0.9",