@revolist/revogrid 4.2.0-next.11 → 4.2.0-next.13
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/custom-element/revogr-clipboard.js +48 -5
- package/dist/cjs/revogr-clipboard.cjs.entry.js +48 -5
- package/dist/collection/components/clipboard/revogr-clipboard.d.ts +52 -1
- package/dist/collection/components/clipboard/revogr-clipboard.js +209 -21
- package/dist/collection/components.d.ts +51 -0
- package/dist/esm/revogr-clipboard.entry.js +48 -5
- package/dist/revo-grid/revogr-clipboard.entry.js +1 -1
- package/dist/types/components/clipboard/revogr-clipboard.d.ts +52 -1
- package/dist/types/components.d.ts +51 -0
- package/package.json +1 -1
|
@@ -7,23 +7,66 @@ const Clipboard = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
7
7
|
constructor() {
|
|
8
8
|
super();
|
|
9
9
|
this.__registerHost();
|
|
10
|
-
this.copyRegion = createEvent(this, "copyRegion", 3);
|
|
11
10
|
this.pasteRegion = createEvent(this, "pasteRegion", 3);
|
|
11
|
+
this.beforePaste = createEvent(this, "beforepaste", 7);
|
|
12
|
+
this.beforePasteApply = createEvent(this, "beforepasteapply", 7);
|
|
13
|
+
this.afterPasteApply = createEvent(this, "afterpasteapply", 7);
|
|
14
|
+
this.beforeCopy = createEvent(this, "beforecopy", 7);
|
|
15
|
+
this.beforeCopyApply = createEvent(this, "beforecopyapply", 7);
|
|
16
|
+
this.copyRegion = createEvent(this, "copyRegion", 3);
|
|
12
17
|
}
|
|
13
18
|
onPaste(e) {
|
|
14
19
|
const clipboardData = this.getData(e);
|
|
15
20
|
const isHTML = clipboardData.types.indexOf('text/html') > -1;
|
|
16
21
|
const data = isHTML ? clipboardData.getData('text/html') : clipboardData.getData('text');
|
|
17
|
-
const
|
|
18
|
-
|
|
22
|
+
const beforePaste = this.beforePaste.emit({
|
|
23
|
+
raw: data,
|
|
24
|
+
event: e,
|
|
25
|
+
});
|
|
26
|
+
if (beforePaste.defaultPrevented) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const parsedData = isHTML ? this.htmlParse(beforePaste.detail.raw) : this.textParse(beforePaste.detail.raw);
|
|
30
|
+
const beforePasteApply = this.beforePasteApply.emit({
|
|
31
|
+
raw: data,
|
|
32
|
+
parsed: parsedData,
|
|
33
|
+
event: e,
|
|
34
|
+
});
|
|
35
|
+
if (beforePasteApply.defaultPrevented) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
this.pasteRegion.emit(beforePasteApply.detail.parsed);
|
|
39
|
+
const afterPasteApply = this.afterPasteApply.emit({
|
|
40
|
+
raw: data,
|
|
41
|
+
parsed: parsedData,
|
|
42
|
+
event: e,
|
|
43
|
+
});
|
|
44
|
+
if (afterPasteApply.defaultPrevented) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
19
47
|
e.preventDefault();
|
|
20
48
|
}
|
|
21
49
|
copyStarted(e) {
|
|
22
|
-
this.
|
|
50
|
+
const beforeCopy = this.beforeCopy.emit({
|
|
51
|
+
event: e,
|
|
52
|
+
});
|
|
53
|
+
if (beforeCopy.defaultPrevented) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const data = this.getData(e);
|
|
57
|
+
this.copyRegion.emit(data);
|
|
23
58
|
e.preventDefault();
|
|
24
59
|
}
|
|
25
60
|
async doCopy(e, data) {
|
|
26
|
-
|
|
61
|
+
const beforeCopyApply = this.beforeCopyApply.emit({
|
|
62
|
+
event: e,
|
|
63
|
+
data,
|
|
64
|
+
});
|
|
65
|
+
if (beforeCopyApply.defaultPrevented) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const parsed = data ? this.parserCopy(data) : '';
|
|
69
|
+
e.setData('text/plain', parsed);
|
|
27
70
|
}
|
|
28
71
|
parserCopy(data) {
|
|
29
72
|
return data.map(rgRow => rgRow.join('\t')).join('\n');
|
|
@@ -10,23 +10,66 @@ const index = require('./index-4bdf65e1.js');
|
|
|
10
10
|
const Clipboard = class {
|
|
11
11
|
constructor(hostRef) {
|
|
12
12
|
index.registerInstance(this, hostRef);
|
|
13
|
-
this.copyRegion = index.createEvent(this, "copyRegion", 3);
|
|
14
13
|
this.pasteRegion = index.createEvent(this, "pasteRegion", 3);
|
|
14
|
+
this.beforePaste = index.createEvent(this, "beforepaste", 7);
|
|
15
|
+
this.beforePasteApply = index.createEvent(this, "beforepasteapply", 7);
|
|
16
|
+
this.afterPasteApply = index.createEvent(this, "afterpasteapply", 7);
|
|
17
|
+
this.beforeCopy = index.createEvent(this, "beforecopy", 7);
|
|
18
|
+
this.beforeCopyApply = index.createEvent(this, "beforecopyapply", 7);
|
|
19
|
+
this.copyRegion = index.createEvent(this, "copyRegion", 3);
|
|
15
20
|
}
|
|
16
21
|
onPaste(e) {
|
|
17
22
|
const clipboardData = this.getData(e);
|
|
18
23
|
const isHTML = clipboardData.types.indexOf('text/html') > -1;
|
|
19
24
|
const data = isHTML ? clipboardData.getData('text/html') : clipboardData.getData('text');
|
|
20
|
-
const
|
|
21
|
-
|
|
25
|
+
const beforePaste = this.beforePaste.emit({
|
|
26
|
+
raw: data,
|
|
27
|
+
event: e,
|
|
28
|
+
});
|
|
29
|
+
if (beforePaste.defaultPrevented) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const parsedData = isHTML ? this.htmlParse(beforePaste.detail.raw) : this.textParse(beforePaste.detail.raw);
|
|
33
|
+
const beforePasteApply = this.beforePasteApply.emit({
|
|
34
|
+
raw: data,
|
|
35
|
+
parsed: parsedData,
|
|
36
|
+
event: e,
|
|
37
|
+
});
|
|
38
|
+
if (beforePasteApply.defaultPrevented) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
this.pasteRegion.emit(beforePasteApply.detail.parsed);
|
|
42
|
+
const afterPasteApply = this.afterPasteApply.emit({
|
|
43
|
+
raw: data,
|
|
44
|
+
parsed: parsedData,
|
|
45
|
+
event: e,
|
|
46
|
+
});
|
|
47
|
+
if (afterPasteApply.defaultPrevented) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
22
50
|
e.preventDefault();
|
|
23
51
|
}
|
|
24
52
|
copyStarted(e) {
|
|
25
|
-
this.
|
|
53
|
+
const beforeCopy = this.beforeCopy.emit({
|
|
54
|
+
event: e,
|
|
55
|
+
});
|
|
56
|
+
if (beforeCopy.defaultPrevented) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const data = this.getData(e);
|
|
60
|
+
this.copyRegion.emit(data);
|
|
26
61
|
e.preventDefault();
|
|
27
62
|
}
|
|
28
63
|
async doCopy(e, data) {
|
|
29
|
-
|
|
64
|
+
const beforeCopyApply = this.beforeCopyApply.emit({
|
|
65
|
+
event: e,
|
|
66
|
+
data,
|
|
67
|
+
});
|
|
68
|
+
if (beforeCopyApply.defaultPrevented) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const parsed = data ? this.parserCopy(data) : '';
|
|
72
|
+
e.setData('text/plain', parsed);
|
|
30
73
|
}
|
|
31
74
|
parserCopy(data) {
|
|
32
75
|
return data.map(rgRow => rgRow.join('\t')).join('\n');
|
|
@@ -1,8 +1,59 @@
|
|
|
1
1
|
import { EventEmitter } from '../../stencil-public-runtime';
|
|
2
2
|
import { RevoGrid } from '../../interfaces';
|
|
3
3
|
export declare class Clipboard {
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Fired when region pasted
|
|
6
|
+
* @event pasteregion
|
|
7
|
+
* @property {string[][]} data - data to paste
|
|
8
|
+
* @property {boolean} defaultPrevented - if true, paste will be canceled
|
|
9
|
+
*/
|
|
5
10
|
pasteRegion: EventEmitter<string[][]>;
|
|
11
|
+
/**
|
|
12
|
+
* Fired before paste applied to the grid
|
|
13
|
+
* @event beforepaste
|
|
14
|
+
* @property {string} raw - raw data from clipboard
|
|
15
|
+
* @property {ClipboardEvent} event - original event
|
|
16
|
+
* @property {boolean} defaultPrevented - if true, paste will be canceled
|
|
17
|
+
*/
|
|
18
|
+
beforePaste: EventEmitter;
|
|
19
|
+
/**
|
|
20
|
+
* Fired before paste applied to the grid and after data parsed
|
|
21
|
+
* @event beforepasteapply
|
|
22
|
+
* @property {string} raw - raw data from clipboard
|
|
23
|
+
* @property {string[][]} parsed - parsed data
|
|
24
|
+
*/
|
|
25
|
+
beforePasteApply: EventEmitter;
|
|
26
|
+
/**
|
|
27
|
+
* Fired after paste applied to the grid
|
|
28
|
+
* @event afterpasteapply
|
|
29
|
+
* @property {string} raw - raw data from clipboard
|
|
30
|
+
* @property {string[][]} parsed - parsed data
|
|
31
|
+
* @property {ClipboardEvent} event - original event
|
|
32
|
+
* @property {boolean} defaultPrevented - if true, paste will be canceled
|
|
33
|
+
*/
|
|
34
|
+
afterPasteApply: EventEmitter;
|
|
35
|
+
/**
|
|
36
|
+
* Fired before copy triggered
|
|
37
|
+
* @event beforecopy
|
|
38
|
+
* @property {ClipboardEvent} event - original event
|
|
39
|
+
* @property {boolean} defaultPrevented - if true, copy will be canceled
|
|
40
|
+
*/
|
|
41
|
+
beforeCopy: EventEmitter;
|
|
42
|
+
/**
|
|
43
|
+
* Fired before copy applied to the clipboard
|
|
44
|
+
* @event beforecopyapply
|
|
45
|
+
* @property {DataTransfer} event - original event
|
|
46
|
+
* @property {string} data - data to copy
|
|
47
|
+
* @property {boolean} defaultPrevented - if true, copy will be canceled
|
|
48
|
+
*/
|
|
49
|
+
beforeCopyApply: EventEmitter;
|
|
50
|
+
/**
|
|
51
|
+
* Fired when region copied
|
|
52
|
+
* @event copyregion
|
|
53
|
+
* @property {DataTransfer} data - data to copy
|
|
54
|
+
* @property {boolean} defaultPrevented - if true, copy will be canceled
|
|
55
|
+
*/
|
|
56
|
+
copyRegion: EventEmitter<DataTransfer>;
|
|
6
57
|
onPaste(e: ClipboardEvent): void;
|
|
7
58
|
copyStarted(e: ClipboardEvent): void;
|
|
8
59
|
doCopy(e: DataTransfer, data?: RevoGrid.DataFormat[][]): Promise<void>;
|
|
@@ -3,16 +3,54 @@ export class Clipboard {
|
|
|
3
3
|
const clipboardData = this.getData(e);
|
|
4
4
|
const isHTML = clipboardData.types.indexOf('text/html') > -1;
|
|
5
5
|
const data = isHTML ? clipboardData.getData('text/html') : clipboardData.getData('text');
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const beforePaste = this.beforePaste.emit({
|
|
7
|
+
raw: data,
|
|
8
|
+
event: e,
|
|
9
|
+
});
|
|
10
|
+
if (beforePaste.defaultPrevented) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const parsedData = isHTML ? this.htmlParse(beforePaste.detail.raw) : this.textParse(beforePaste.detail.raw);
|
|
14
|
+
const beforePasteApply = this.beforePasteApply.emit({
|
|
15
|
+
raw: data,
|
|
16
|
+
parsed: parsedData,
|
|
17
|
+
event: e,
|
|
18
|
+
});
|
|
19
|
+
if (beforePasteApply.defaultPrevented) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
this.pasteRegion.emit(beforePasteApply.detail.parsed);
|
|
23
|
+
const afterPasteApply = this.afterPasteApply.emit({
|
|
24
|
+
raw: data,
|
|
25
|
+
parsed: parsedData,
|
|
26
|
+
event: e,
|
|
27
|
+
});
|
|
28
|
+
if (afterPasteApply.defaultPrevented) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
8
31
|
e.preventDefault();
|
|
9
32
|
}
|
|
10
33
|
copyStarted(e) {
|
|
11
|
-
this.
|
|
34
|
+
const beforeCopy = this.beforeCopy.emit({
|
|
35
|
+
event: e,
|
|
36
|
+
});
|
|
37
|
+
if (beforeCopy.defaultPrevented) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const data = this.getData(e);
|
|
41
|
+
this.copyRegion.emit(data);
|
|
12
42
|
e.preventDefault();
|
|
13
43
|
}
|
|
14
44
|
async doCopy(e, data) {
|
|
15
|
-
|
|
45
|
+
const beforeCopyApply = this.beforeCopyApply.emit({
|
|
46
|
+
event: e,
|
|
47
|
+
data,
|
|
48
|
+
});
|
|
49
|
+
if (beforeCopyApply.defaultPrevented) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const parsed = data ? this.parserCopy(data) : '';
|
|
53
|
+
e.setData('text/plain', parsed);
|
|
16
54
|
}
|
|
17
55
|
parserCopy(data) {
|
|
18
56
|
return data.map(rgRow => rgRow.join('\t')).join('\n');
|
|
@@ -43,14 +81,179 @@ export class Clipboard {
|
|
|
43
81
|
static get is() { return "revogr-clipboard"; }
|
|
44
82
|
static get events() {
|
|
45
83
|
return [{
|
|
84
|
+
"method": "pasteRegion",
|
|
85
|
+
"name": "pasteRegion",
|
|
86
|
+
"bubbles": false,
|
|
87
|
+
"cancelable": true,
|
|
88
|
+
"composed": true,
|
|
89
|
+
"docs": {
|
|
90
|
+
"tags": [{
|
|
91
|
+
"name": "event",
|
|
92
|
+
"text": "pasteregion"
|
|
93
|
+
}, {
|
|
94
|
+
"name": "property",
|
|
95
|
+
"text": "{string[][]} data - data to paste"
|
|
96
|
+
}, {
|
|
97
|
+
"name": "property",
|
|
98
|
+
"text": "{boolean} defaultPrevented - if true, paste will be canceled"
|
|
99
|
+
}],
|
|
100
|
+
"text": "Fired when region pasted"
|
|
101
|
+
},
|
|
102
|
+
"complexType": {
|
|
103
|
+
"original": "string[][]",
|
|
104
|
+
"resolved": "string[][]",
|
|
105
|
+
"references": {}
|
|
106
|
+
}
|
|
107
|
+
}, {
|
|
108
|
+
"method": "beforePaste",
|
|
109
|
+
"name": "beforepaste",
|
|
110
|
+
"bubbles": true,
|
|
111
|
+
"cancelable": true,
|
|
112
|
+
"composed": true,
|
|
113
|
+
"docs": {
|
|
114
|
+
"tags": [{
|
|
115
|
+
"name": "event",
|
|
116
|
+
"text": "beforepaste"
|
|
117
|
+
}, {
|
|
118
|
+
"name": "property",
|
|
119
|
+
"text": "{string} raw - raw data from clipboard"
|
|
120
|
+
}, {
|
|
121
|
+
"name": "property",
|
|
122
|
+
"text": "{ClipboardEvent} event - original event"
|
|
123
|
+
}, {
|
|
124
|
+
"name": "property",
|
|
125
|
+
"text": "{boolean} defaultPrevented - if true, paste will be canceled"
|
|
126
|
+
}],
|
|
127
|
+
"text": "Fired before paste applied to the grid"
|
|
128
|
+
},
|
|
129
|
+
"complexType": {
|
|
130
|
+
"original": "any",
|
|
131
|
+
"resolved": "any",
|
|
132
|
+
"references": {}
|
|
133
|
+
}
|
|
134
|
+
}, {
|
|
135
|
+
"method": "beforePasteApply",
|
|
136
|
+
"name": "beforepasteapply",
|
|
137
|
+
"bubbles": true,
|
|
138
|
+
"cancelable": true,
|
|
139
|
+
"composed": true,
|
|
140
|
+
"docs": {
|
|
141
|
+
"tags": [{
|
|
142
|
+
"name": "event",
|
|
143
|
+
"text": "beforepasteapply"
|
|
144
|
+
}, {
|
|
145
|
+
"name": "property",
|
|
146
|
+
"text": "{string} raw - raw data from clipboard"
|
|
147
|
+
}, {
|
|
148
|
+
"name": "property",
|
|
149
|
+
"text": "{string[][]} parsed - parsed data"
|
|
150
|
+
}],
|
|
151
|
+
"text": "Fired before paste applied to the grid and after data parsed"
|
|
152
|
+
},
|
|
153
|
+
"complexType": {
|
|
154
|
+
"original": "any",
|
|
155
|
+
"resolved": "any",
|
|
156
|
+
"references": {}
|
|
157
|
+
}
|
|
158
|
+
}, {
|
|
159
|
+
"method": "afterPasteApply",
|
|
160
|
+
"name": "afterpasteapply",
|
|
161
|
+
"bubbles": true,
|
|
162
|
+
"cancelable": true,
|
|
163
|
+
"composed": true,
|
|
164
|
+
"docs": {
|
|
165
|
+
"tags": [{
|
|
166
|
+
"name": "event",
|
|
167
|
+
"text": "afterpasteapply"
|
|
168
|
+
}, {
|
|
169
|
+
"name": "property",
|
|
170
|
+
"text": "{string} raw - raw data from clipboard"
|
|
171
|
+
}, {
|
|
172
|
+
"name": "property",
|
|
173
|
+
"text": "{string[][]} parsed - parsed data"
|
|
174
|
+
}, {
|
|
175
|
+
"name": "property",
|
|
176
|
+
"text": "{ClipboardEvent} event - original event"
|
|
177
|
+
}, {
|
|
178
|
+
"name": "property",
|
|
179
|
+
"text": "{boolean} defaultPrevented - if true, paste will be canceled"
|
|
180
|
+
}],
|
|
181
|
+
"text": "Fired after paste applied to the grid"
|
|
182
|
+
},
|
|
183
|
+
"complexType": {
|
|
184
|
+
"original": "any",
|
|
185
|
+
"resolved": "any",
|
|
186
|
+
"references": {}
|
|
187
|
+
}
|
|
188
|
+
}, {
|
|
189
|
+
"method": "beforeCopy",
|
|
190
|
+
"name": "beforecopy",
|
|
191
|
+
"bubbles": true,
|
|
192
|
+
"cancelable": true,
|
|
193
|
+
"composed": true,
|
|
194
|
+
"docs": {
|
|
195
|
+
"tags": [{
|
|
196
|
+
"name": "event",
|
|
197
|
+
"text": "beforecopy"
|
|
198
|
+
}, {
|
|
199
|
+
"name": "property",
|
|
200
|
+
"text": "{ClipboardEvent} event - original event"
|
|
201
|
+
}, {
|
|
202
|
+
"name": "property",
|
|
203
|
+
"text": "{boolean} defaultPrevented - if true, copy will be canceled"
|
|
204
|
+
}],
|
|
205
|
+
"text": "Fired before copy triggered"
|
|
206
|
+
},
|
|
207
|
+
"complexType": {
|
|
208
|
+
"original": "any",
|
|
209
|
+
"resolved": "any",
|
|
210
|
+
"references": {}
|
|
211
|
+
}
|
|
212
|
+
}, {
|
|
213
|
+
"method": "beforeCopyApply",
|
|
214
|
+
"name": "beforecopyapply",
|
|
215
|
+
"bubbles": true,
|
|
216
|
+
"cancelable": true,
|
|
217
|
+
"composed": true,
|
|
218
|
+
"docs": {
|
|
219
|
+
"tags": [{
|
|
220
|
+
"name": "event",
|
|
221
|
+
"text": "beforecopyapply"
|
|
222
|
+
}, {
|
|
223
|
+
"name": "property",
|
|
224
|
+
"text": "{DataTransfer} event - original event"
|
|
225
|
+
}, {
|
|
226
|
+
"name": "property",
|
|
227
|
+
"text": "{string} data - data to copy"
|
|
228
|
+
}, {
|
|
229
|
+
"name": "property",
|
|
230
|
+
"text": "{boolean} defaultPrevented - if true, copy will be canceled"
|
|
231
|
+
}],
|
|
232
|
+
"text": "Fired before copy applied to the clipboard"
|
|
233
|
+
},
|
|
234
|
+
"complexType": {
|
|
235
|
+
"original": "any",
|
|
236
|
+
"resolved": "any",
|
|
237
|
+
"references": {}
|
|
238
|
+
}
|
|
239
|
+
}, {
|
|
46
240
|
"method": "copyRegion",
|
|
47
241
|
"name": "copyRegion",
|
|
48
242
|
"bubbles": false,
|
|
49
243
|
"cancelable": true,
|
|
50
244
|
"composed": true,
|
|
51
245
|
"docs": {
|
|
52
|
-
"tags": [
|
|
53
|
-
|
|
246
|
+
"tags": [{
|
|
247
|
+
"name": "event",
|
|
248
|
+
"text": "copyregion"
|
|
249
|
+
}, {
|
|
250
|
+
"name": "property",
|
|
251
|
+
"text": "{DataTransfer} data - data to copy"
|
|
252
|
+
}, {
|
|
253
|
+
"name": "property",
|
|
254
|
+
"text": "{boolean} defaultPrevented - if true, copy will be canceled"
|
|
255
|
+
}],
|
|
256
|
+
"text": "Fired when region copied"
|
|
54
257
|
},
|
|
55
258
|
"complexType": {
|
|
56
259
|
"original": "DataTransfer",
|
|
@@ -61,21 +264,6 @@ export class Clipboard {
|
|
|
61
264
|
}
|
|
62
265
|
}
|
|
63
266
|
}
|
|
64
|
-
}, {
|
|
65
|
-
"method": "pasteRegion",
|
|
66
|
-
"name": "pasteRegion",
|
|
67
|
-
"bubbles": false,
|
|
68
|
-
"cancelable": true,
|
|
69
|
-
"composed": true,
|
|
70
|
-
"docs": {
|
|
71
|
-
"tags": [],
|
|
72
|
-
"text": ""
|
|
73
|
-
},
|
|
74
|
-
"complexType": {
|
|
75
|
-
"original": "string[][]",
|
|
76
|
-
"resolved": "string[][]",
|
|
77
|
-
"references": {}
|
|
78
|
-
}
|
|
79
267
|
}];
|
|
80
268
|
}
|
|
81
269
|
static get methods() {
|
|
@@ -780,7 +780,58 @@ declare namespace LocalJSX {
|
|
|
780
780
|
"useClipboard"?: boolean;
|
|
781
781
|
}
|
|
782
782
|
interface RevogrClipboard {
|
|
783
|
+
/**
|
|
784
|
+
* Fired after paste applied to the grid
|
|
785
|
+
* @event afterpasteapply
|
|
786
|
+
* @property {string} raw - raw data from clipboard
|
|
787
|
+
* @property {string[][]} parsed - parsed data
|
|
788
|
+
* @property {ClipboardEvent} event - original event
|
|
789
|
+
* @property {boolean} defaultPrevented - if true, paste will be canceled
|
|
790
|
+
*/
|
|
791
|
+
"onAfterpasteapply"?: (event: RevogrClipboardCustomEvent<any>) => void;
|
|
792
|
+
/**
|
|
793
|
+
* Fired before copy triggered
|
|
794
|
+
* @event beforecopy
|
|
795
|
+
* @property {ClipboardEvent} event - original event
|
|
796
|
+
* @property {boolean} defaultPrevented - if true, copy will be canceled
|
|
797
|
+
*/
|
|
798
|
+
"onBeforecopy"?: (event: RevogrClipboardCustomEvent<any>) => void;
|
|
799
|
+
/**
|
|
800
|
+
* Fired before copy applied to the clipboard
|
|
801
|
+
* @event beforecopyapply
|
|
802
|
+
* @property {DataTransfer} event - original event
|
|
803
|
+
* @property {string} data - data to copy
|
|
804
|
+
* @property {boolean} defaultPrevented - if true, copy will be canceled
|
|
805
|
+
*/
|
|
806
|
+
"onBeforecopyapply"?: (event: RevogrClipboardCustomEvent<any>) => void;
|
|
807
|
+
/**
|
|
808
|
+
* Fired before paste applied to the grid
|
|
809
|
+
* @event beforepaste
|
|
810
|
+
* @property {string} raw - raw data from clipboard
|
|
811
|
+
* @property {ClipboardEvent} event - original event
|
|
812
|
+
* @property {boolean} defaultPrevented - if true, paste will be canceled
|
|
813
|
+
*/
|
|
814
|
+
"onBeforepaste"?: (event: RevogrClipboardCustomEvent<any>) => void;
|
|
815
|
+
/**
|
|
816
|
+
* Fired before paste applied to the grid and after data parsed
|
|
817
|
+
* @event beforepasteapply
|
|
818
|
+
* @property {string} raw - raw data from clipboard
|
|
819
|
+
* @property {string[][]} parsed - parsed data
|
|
820
|
+
*/
|
|
821
|
+
"onBeforepasteapply"?: (event: RevogrClipboardCustomEvent<any>) => void;
|
|
822
|
+
/**
|
|
823
|
+
* Fired when region copied
|
|
824
|
+
* @event copyregion
|
|
825
|
+
* @property {DataTransfer} data - data to copy
|
|
826
|
+
* @property {boolean} defaultPrevented - if true, copy will be canceled
|
|
827
|
+
*/
|
|
783
828
|
"onCopyRegion"?: (event: RevogrClipboardCustomEvent<DataTransfer>) => void;
|
|
829
|
+
/**
|
|
830
|
+
* Fired when region pasted
|
|
831
|
+
* @event pasteregion
|
|
832
|
+
* @property {string[][]} data - data to paste
|
|
833
|
+
* @property {boolean} defaultPrevented - if true, paste will be canceled
|
|
834
|
+
*/
|
|
784
835
|
"onPasteRegion"?: (event: RevogrClipboardCustomEvent<string[][]>) => void;
|
|
785
836
|
}
|
|
786
837
|
interface RevogrData {
|
|
@@ -6,23 +6,66 @@ import { r as registerInstance, c as createEvent } from './index-8d2e158d.js';
|
|
|
6
6
|
const Clipboard = class {
|
|
7
7
|
constructor(hostRef) {
|
|
8
8
|
registerInstance(this, hostRef);
|
|
9
|
-
this.copyRegion = createEvent(this, "copyRegion", 3);
|
|
10
9
|
this.pasteRegion = createEvent(this, "pasteRegion", 3);
|
|
10
|
+
this.beforePaste = createEvent(this, "beforepaste", 7);
|
|
11
|
+
this.beforePasteApply = createEvent(this, "beforepasteapply", 7);
|
|
12
|
+
this.afterPasteApply = createEvent(this, "afterpasteapply", 7);
|
|
13
|
+
this.beforeCopy = createEvent(this, "beforecopy", 7);
|
|
14
|
+
this.beforeCopyApply = createEvent(this, "beforecopyapply", 7);
|
|
15
|
+
this.copyRegion = createEvent(this, "copyRegion", 3);
|
|
11
16
|
}
|
|
12
17
|
onPaste(e) {
|
|
13
18
|
const clipboardData = this.getData(e);
|
|
14
19
|
const isHTML = clipboardData.types.indexOf('text/html') > -1;
|
|
15
20
|
const data = isHTML ? clipboardData.getData('text/html') : clipboardData.getData('text');
|
|
16
|
-
const
|
|
17
|
-
|
|
21
|
+
const beforePaste = this.beforePaste.emit({
|
|
22
|
+
raw: data,
|
|
23
|
+
event: e,
|
|
24
|
+
});
|
|
25
|
+
if (beforePaste.defaultPrevented) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const parsedData = isHTML ? this.htmlParse(beforePaste.detail.raw) : this.textParse(beforePaste.detail.raw);
|
|
29
|
+
const beforePasteApply = this.beforePasteApply.emit({
|
|
30
|
+
raw: data,
|
|
31
|
+
parsed: parsedData,
|
|
32
|
+
event: e,
|
|
33
|
+
});
|
|
34
|
+
if (beforePasteApply.defaultPrevented) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this.pasteRegion.emit(beforePasteApply.detail.parsed);
|
|
38
|
+
const afterPasteApply = this.afterPasteApply.emit({
|
|
39
|
+
raw: data,
|
|
40
|
+
parsed: parsedData,
|
|
41
|
+
event: e,
|
|
42
|
+
});
|
|
43
|
+
if (afterPasteApply.defaultPrevented) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
18
46
|
e.preventDefault();
|
|
19
47
|
}
|
|
20
48
|
copyStarted(e) {
|
|
21
|
-
this.
|
|
49
|
+
const beforeCopy = this.beforeCopy.emit({
|
|
50
|
+
event: e,
|
|
51
|
+
});
|
|
52
|
+
if (beforeCopy.defaultPrevented) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const data = this.getData(e);
|
|
56
|
+
this.copyRegion.emit(data);
|
|
22
57
|
e.preventDefault();
|
|
23
58
|
}
|
|
24
59
|
async doCopy(e, data) {
|
|
25
|
-
|
|
60
|
+
const beforeCopyApply = this.beforeCopyApply.emit({
|
|
61
|
+
event: e,
|
|
62
|
+
data,
|
|
63
|
+
});
|
|
64
|
+
if (beforeCopyApply.defaultPrevented) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const parsed = data ? this.parserCopy(data) : '';
|
|
68
|
+
e.setData('text/plain', parsed);
|
|
26
69
|
}
|
|
27
70
|
parserCopy(data) {
|
|
28
71
|
return data.map(rgRow => rgRow.join('\t')).join('\n');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Built by Revolist
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,c as
|
|
4
|
+
import{r as t,c as s}from"./index-f30539e6.js";const e=class{constructor(e){t(this,e),this.pasteRegion=s(this,"pasteRegion",3),this.beforePaste=s(this,"beforepaste",7),this.beforePasteApply=s(this,"beforepasteapply",7),this.afterPasteApply=s(this,"afterpasteapply",7),this.beforeCopy=s(this,"beforecopy",7),this.beforeCopyApply=s(this,"beforecopyapply",7),this.copyRegion=s(this,"copyRegion",3)}onPaste(t){const s=this.getData(t),e=s.types.indexOf("text/html")>-1,r=s.getData(e?"text/html":"text"),i=this.beforePaste.emit({raw:r,event:t});if(i.defaultPrevented)return;const o=e?this.htmlParse(i.detail.raw):this.textParse(i.detail.raw),n=this.beforePasteApply.emit({raw:r,parsed:o,event:t});n.defaultPrevented||(this.pasteRegion.emit(n.detail.parsed),this.afterPasteApply.emit({raw:r,parsed:o,event:t}).defaultPrevented||t.preventDefault())}copyStarted(t){if(this.beforeCopy.emit({event:t}).defaultPrevented)return;const s=this.getData(t);this.copyRegion.emit(s),t.preventDefault()}async doCopy(t,s){if(this.beforeCopyApply.emit({event:t,data:s}).defaultPrevented)return;const e=s?this.parserCopy(s):"";t.setData("text/plain",e)}parserCopy(t){return t.map((t=>t.join("\t"))).join("\n")}textParse(t){const s=[],e=t.split(/\r\n|\n|\r/);for(let t in e)s.push(e[t].split("\t"));return s}htmlParse(t){const s=[],e=document.createRange().createContextualFragment(t).querySelector("table");if(!e)return this.textParse(t);for(const t of Array.from(e.rows))s.push(Array.from(t.cells).map((t=>t.innerText)));return s}getData(t){return t.clipboardData||(null===window||void 0===window?void 0:window.clipboardData)}};export{e as revogr_clipboard}
|
|
@@ -1,8 +1,59 @@
|
|
|
1
1
|
import { EventEmitter } from '../../stencil-public-runtime';
|
|
2
2
|
import { RevoGrid } from '../../interfaces';
|
|
3
3
|
export declare class Clipboard {
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Fired when region pasted
|
|
6
|
+
* @event pasteregion
|
|
7
|
+
* @property {string[][]} data - data to paste
|
|
8
|
+
* @property {boolean} defaultPrevented - if true, paste will be canceled
|
|
9
|
+
*/
|
|
5
10
|
pasteRegion: EventEmitter<string[][]>;
|
|
11
|
+
/**
|
|
12
|
+
* Fired before paste applied to the grid
|
|
13
|
+
* @event beforepaste
|
|
14
|
+
* @property {string} raw - raw data from clipboard
|
|
15
|
+
* @property {ClipboardEvent} event - original event
|
|
16
|
+
* @property {boolean} defaultPrevented - if true, paste will be canceled
|
|
17
|
+
*/
|
|
18
|
+
beforePaste: EventEmitter;
|
|
19
|
+
/**
|
|
20
|
+
* Fired before paste applied to the grid and after data parsed
|
|
21
|
+
* @event beforepasteapply
|
|
22
|
+
* @property {string} raw - raw data from clipboard
|
|
23
|
+
* @property {string[][]} parsed - parsed data
|
|
24
|
+
*/
|
|
25
|
+
beforePasteApply: EventEmitter;
|
|
26
|
+
/**
|
|
27
|
+
* Fired after paste applied to the grid
|
|
28
|
+
* @event afterpasteapply
|
|
29
|
+
* @property {string} raw - raw data from clipboard
|
|
30
|
+
* @property {string[][]} parsed - parsed data
|
|
31
|
+
* @property {ClipboardEvent} event - original event
|
|
32
|
+
* @property {boolean} defaultPrevented - if true, paste will be canceled
|
|
33
|
+
*/
|
|
34
|
+
afterPasteApply: EventEmitter;
|
|
35
|
+
/**
|
|
36
|
+
* Fired before copy triggered
|
|
37
|
+
* @event beforecopy
|
|
38
|
+
* @property {ClipboardEvent} event - original event
|
|
39
|
+
* @property {boolean} defaultPrevented - if true, copy will be canceled
|
|
40
|
+
*/
|
|
41
|
+
beforeCopy: EventEmitter;
|
|
42
|
+
/**
|
|
43
|
+
* Fired before copy applied to the clipboard
|
|
44
|
+
* @event beforecopyapply
|
|
45
|
+
* @property {DataTransfer} event - original event
|
|
46
|
+
* @property {string} data - data to copy
|
|
47
|
+
* @property {boolean} defaultPrevented - if true, copy will be canceled
|
|
48
|
+
*/
|
|
49
|
+
beforeCopyApply: EventEmitter;
|
|
50
|
+
/**
|
|
51
|
+
* Fired when region copied
|
|
52
|
+
* @event copyregion
|
|
53
|
+
* @property {DataTransfer} data - data to copy
|
|
54
|
+
* @property {boolean} defaultPrevented - if true, copy will be canceled
|
|
55
|
+
*/
|
|
56
|
+
copyRegion: EventEmitter<DataTransfer>;
|
|
6
57
|
onPaste(e: ClipboardEvent): void;
|
|
7
58
|
copyStarted(e: ClipboardEvent): void;
|
|
8
59
|
doCopy(e: DataTransfer, data?: RevoGrid.DataFormat[][]): Promise<void>;
|
|
@@ -780,7 +780,58 @@ declare namespace LocalJSX {
|
|
|
780
780
|
"useClipboard"?: boolean;
|
|
781
781
|
}
|
|
782
782
|
interface RevogrClipboard {
|
|
783
|
+
/**
|
|
784
|
+
* Fired after paste applied to the grid
|
|
785
|
+
* @event afterpasteapply
|
|
786
|
+
* @property {string} raw - raw data from clipboard
|
|
787
|
+
* @property {string[][]} parsed - parsed data
|
|
788
|
+
* @property {ClipboardEvent} event - original event
|
|
789
|
+
* @property {boolean} defaultPrevented - if true, paste will be canceled
|
|
790
|
+
*/
|
|
791
|
+
"onAfterpasteapply"?: (event: RevogrClipboardCustomEvent<any>) => void;
|
|
792
|
+
/**
|
|
793
|
+
* Fired before copy triggered
|
|
794
|
+
* @event beforecopy
|
|
795
|
+
* @property {ClipboardEvent} event - original event
|
|
796
|
+
* @property {boolean} defaultPrevented - if true, copy will be canceled
|
|
797
|
+
*/
|
|
798
|
+
"onBeforecopy"?: (event: RevogrClipboardCustomEvent<any>) => void;
|
|
799
|
+
/**
|
|
800
|
+
* Fired before copy applied to the clipboard
|
|
801
|
+
* @event beforecopyapply
|
|
802
|
+
* @property {DataTransfer} event - original event
|
|
803
|
+
* @property {string} data - data to copy
|
|
804
|
+
* @property {boolean} defaultPrevented - if true, copy will be canceled
|
|
805
|
+
*/
|
|
806
|
+
"onBeforecopyapply"?: (event: RevogrClipboardCustomEvent<any>) => void;
|
|
807
|
+
/**
|
|
808
|
+
* Fired before paste applied to the grid
|
|
809
|
+
* @event beforepaste
|
|
810
|
+
* @property {string} raw - raw data from clipboard
|
|
811
|
+
* @property {ClipboardEvent} event - original event
|
|
812
|
+
* @property {boolean} defaultPrevented - if true, paste will be canceled
|
|
813
|
+
*/
|
|
814
|
+
"onBeforepaste"?: (event: RevogrClipboardCustomEvent<any>) => void;
|
|
815
|
+
/**
|
|
816
|
+
* Fired before paste applied to the grid and after data parsed
|
|
817
|
+
* @event beforepasteapply
|
|
818
|
+
* @property {string} raw - raw data from clipboard
|
|
819
|
+
* @property {string[][]} parsed - parsed data
|
|
820
|
+
*/
|
|
821
|
+
"onBeforepasteapply"?: (event: RevogrClipboardCustomEvent<any>) => void;
|
|
822
|
+
/**
|
|
823
|
+
* Fired when region copied
|
|
824
|
+
* @event copyregion
|
|
825
|
+
* @property {DataTransfer} data - data to copy
|
|
826
|
+
* @property {boolean} defaultPrevented - if true, copy will be canceled
|
|
827
|
+
*/
|
|
783
828
|
"onCopyRegion"?: (event: RevogrClipboardCustomEvent<DataTransfer>) => void;
|
|
829
|
+
/**
|
|
830
|
+
* Fired when region pasted
|
|
831
|
+
* @event pasteregion
|
|
832
|
+
* @property {string[][]} data - data to paste
|
|
833
|
+
* @property {boolean} defaultPrevented - if true, paste will be canceled
|
|
834
|
+
*/
|
|
784
835
|
"onPasteRegion"?: (event: RevogrClipboardCustomEvent<string[][]>) => void;
|
|
785
836
|
}
|
|
786
837
|
interface RevogrData {
|