@seafile/sdoc-editor 0.1.79 → 0.1.80

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.
@@ -114,13 +114,10 @@ export var setClipboardData = function setClipboardData(value) {
114
114
  return Node.string(line);
115
115
  }).join('\n');
116
116
  copy(text, {
117
- format: 'text/plain'
117
+ format: 'text/plain',
118
+ onCopy: function onCopy(data) {
119
+ // Set the sdoc editor to format the data
120
+ data.setData('text/code-block', JSON.stringify(value));
121
+ }
118
122
  });
119
-
120
- // Store the code block data
121
- var clipboardData = {
122
- text: text,
123
- codeBlockNode: value
124
- };
125
- sessionStorage.setItem('clipboardData', JSON.stringify(clipboardData));
126
123
  };
@@ -22,11 +22,8 @@ var withCodeBlock = function withCodeBlock(editor) {
22
22
  return insertText(data);
23
23
  };
24
24
  newEditor.insertData = function (data) {
25
- var text = data.getData('text/plain');
26
- var _ref = JSON.parse(sessionStorage.getItem('clipboardData')) || {},
27
- storageText = _ref.text,
28
- codeBlockNode = _ref.codeBlockNode;
29
- if (codeBlockNode && text === storageText && !getSelectedNodeByType(editor, CODE_BLOCK)) {
25
+ if (data.types.includes('text/code-block') && !getSelectedNodeByType(editor, CODE_BLOCK)) {
26
+ var codeBlockNode = JSON.parse(data.getData('text/code-block'));
30
27
  return insertNode(codeBlockNode);
31
28
  }
32
29
  return insertData(data);
@@ -95,10 +92,10 @@ var withCodeBlock = function withCodeBlock(editor) {
95
92
  };
96
93
 
97
94
  // Rewrite normalizeNode
98
- newEditor.normalizeNode = function (_ref2) {
99
- var _ref3 = _slicedToArray(_ref2, 2),
100
- node = _ref3[0],
101
- path = _ref3[1];
95
+ newEditor.normalizeNode = function (_ref) {
96
+ var _ref2 = _slicedToArray(_ref, 2),
97
+ node = _ref2[0],
98
+ path = _ref2[1];
102
99
  var type = getNodeType(node);
103
100
  if (type === CODE_BLOCK) {
104
101
  // code-block is the last node in the editor and needs to be followed by a p node
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.79",
3
+ "version": "0.1.80",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",