@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
|
-
|
|
26
|
-
|
|
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 (
|
|
99
|
-
var
|
|
100
|
-
node =
|
|
101
|
-
path =
|
|
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
|