tabulator-tables 5.4.2 → 5.4.4
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/.babelrc.json +3 -3
- package/.editorconfig +6 -6
- package/.eslintignore +3 -3
- package/.eslintrc.js +28 -28
- package/.github/ISSUE_TEMPLATE/bug_report.md +58 -58
- package/.github/ISSUE_TEMPLATE/documentation.md +14 -14
- package/.github/ISSUE_TEMPLATE/feature_request.md +24 -24
- package/.github/ISSUE_TEMPLATE/question.md +12 -12
- package/.github/workflows/bad-files-check.yml +39 -39
- package/.github/workflows/lint-and-test.yml +30 -30
- package/CODE_OF_CONDUCT.md +46 -46
- package/CONTRIBUTING.md +22 -22
- package/LICENSE +20 -20
- package/README.md +76 -76
- package/bower.json +40 -40
- package/build/Bundler.js +185 -185
- package/build/rollup.js +6 -6
- package/dist/css/tabulator.css +1 -5
- package/dist/css/tabulator.css.map +1 -1
- package/dist/css/tabulator.min.css +1 -1
- package/dist/css/tabulator.min.css.map +1 -1
- package/dist/css/tabulator_bootstrap3.css +1 -5
- package/dist/css/tabulator_bootstrap3.css.map +1 -1
- package/dist/css/tabulator_bootstrap3.min.css +1 -1
- package/dist/css/tabulator_bootstrap3.min.css.map +1 -1
- package/dist/css/tabulator_bootstrap4.css +1 -5
- package/dist/css/tabulator_bootstrap4.css.map +1 -1
- package/dist/css/tabulator_bootstrap4.min.css +1 -1
- package/dist/css/tabulator_bootstrap4.min.css.map +1 -1
- package/dist/css/tabulator_bootstrap5.css +1 -5
- package/dist/css/tabulator_bootstrap5.css.map +1 -1
- package/dist/css/tabulator_bootstrap5.min.css +1 -1
- package/dist/css/tabulator_bootstrap5.min.css.map +1 -1
- package/dist/css/tabulator_bulma.css +1 -5
- package/dist/css/tabulator_bulma.css.map +1 -1
- package/dist/css/tabulator_bulma.min.css +1 -1
- package/dist/css/tabulator_bulma.min.css.map +1 -1
- package/dist/css/tabulator_materialize.css +1 -5
- package/dist/css/tabulator_materialize.css.map +1 -1
- package/dist/css/tabulator_materialize.min.css +1 -1
- package/dist/css/tabulator_materialize.min.css.map +1 -1
- package/dist/css/tabulator_midnight.css +1 -5
- package/dist/css/tabulator_midnight.css.map +1 -1
- package/dist/css/tabulator_midnight.min.css +1 -1
- package/dist/css/tabulator_midnight.min.css.map +1 -1
- package/dist/css/tabulator_modern.css +1 -5
- package/dist/css/tabulator_modern.css.map +1 -1
- package/dist/css/tabulator_modern.min.css +1 -1
- package/dist/css/tabulator_modern.min.css.map +1 -1
- package/dist/css/tabulator_semanticui.css +103 -107
- package/dist/css/tabulator_semanticui.css.map +1 -1
- package/dist/css/tabulator_semanticui.min.css +1 -1
- package/dist/css/tabulator_semanticui.min.css.map +1 -1
- package/dist/css/tabulator_simple.css +1 -5
- package/dist/css/tabulator_simple.css.map +1 -1
- package/dist/css/tabulator_simple.min.css +1 -1
- package/dist/css/tabulator_simple.min.css.map +1 -1
- package/dist/css/tabulator_site.css +1 -5
- package/dist/css/tabulator_site.css.map +1 -1
- package/dist/css/tabulator_site.min.css +1 -1
- package/dist/css/tabulator_site.min.css.map +1 -1
- package/dist/js/jquery_wrapper.js +55 -55
- package/dist/js/tabulator.js +25847 -25653
- package/dist/js/tabulator.js.map +1 -1
- package/dist/js/tabulator.min.js +2 -2
- package/dist/js/tabulator.min.js.map +1 -1
- package/dist/js/tabulator_esm.js +25926 -25732
- package/dist/js/tabulator_esm.js.map +1 -1
- package/dist/js/tabulator_esm.min.js +2 -2
- package/dist/js/tabulator_esm.min.js.map +1 -1
- package/package.json +65 -65
- package/src/js/builds/esm.js +14 -14
- package/src/js/builds/jquery_wrapper.js +55 -55
- package/src/js/core/ColumnManager.js +730 -730
- package/src/js/core/CoreFeature.js +138 -138
- package/src/js/core/FooterManager.js +101 -101
- package/src/js/core/Module.js +141 -141
- package/src/js/core/RowManager.js +1112 -1082
- package/src/js/core/Tabulator.js +895 -893
- package/src/js/core/TabulatorFull.js +10 -10
- package/src/js/core/cell/Cell.js +295 -295
- package/src/js/core/cell/CellComponent.js +76 -76
- package/src/js/core/column/Column.js +949 -949
- package/src/js/core/column/ColumnComponent.js +152 -152
- package/src/js/core/column/defaults/options.js +17 -17
- package/src/js/core/defaults/options.js +65 -65
- package/src/js/core/modules/core.js +2 -2
- package/src/js/core/modules/optional.js +34 -34
- package/src/js/core/rendering/Renderer.js +203 -203
- package/src/js/core/rendering/renderers/BasicHorizontal.js +19 -19
- package/src/js/core/rendering/renderers/BasicVertical.js +79 -78
- package/src/js/core/rendering/renderers/VirtualDomHorizontal.js +577 -577
- package/src/js/core/rendering/renderers/VirtualDomVertical.js +579 -579
- package/src/js/core/row/PseudoRow.js +44 -44
- package/src/js/core/row/Row.js +457 -457
- package/src/js/core/row/RowComponent.js +93 -93
- package/src/js/core/tools/Alert.js +61 -61
- package/src/js/core/tools/ComponentFunctionBinder.js +32 -32
- package/src/js/core/tools/DataLoader.js +119 -119
- package/src/js/core/tools/DeprecationAdvisor.js +46 -46
- package/src/js/core/tools/ExternalEventBus.js +104 -104
- package/src/js/core/tools/Helpers.js +46 -46
- package/src/js/core/tools/InteractionMonitor.js +321 -321
- package/src/js/core/tools/InternalEventBus.js +161 -161
- package/src/js/core/tools/ModuleBinder.js +104 -104
- package/src/js/core/tools/OptionsList.js +44 -40
- package/src/js/core/tools/Popup.js +304 -304
- package/src/js/core/tools/TableRegistry.js +61 -61
- package/src/js/modules/Accessor/Accessor.js +115 -115
- package/src/js/modules/Ajax/Ajax.js +143 -143
- package/src/js/modules/Ajax/defaults/config.js +2 -2
- package/src/js/modules/Ajax/defaults/contentTypeFormatters.js +44 -44
- package/src/js/modules/Ajax/defaults/loaderPromise.js +86 -86
- package/src/js/modules/Ajax/defaults/urlGenerator.js +43 -43
- package/src/js/modules/Clipboard/Clipboard.js +279 -279
- package/src/js/modules/Clipboard/defaults/pasteActions.js +10 -10
- package/src/js/modules/Clipboard/defaults/pasteParsers.js +74 -74
- package/src/js/modules/ColumnCalcs/CalcComponent.js +47 -47
- package/src/js/modules/ColumnCalcs/ColumnCalcs.js +581 -568
- package/src/js/modules/ColumnCalcs/defaults/calculations.js +85 -85
- package/src/js/modules/Comms/Comms.js +51 -51
- package/src/js/modules/DataTree/DataTree.js +603 -603
- package/src/js/modules/Download/Download.js +148 -148
- package/src/js/modules/Download/defaults/downloaders/csv.js +61 -61
- package/src/js/modules/Download/defaults/downloaders/html.js +4 -4
- package/src/js/modules/Download/defaults/downloaders/json.js +33 -33
- package/src/js/modules/Download/defaults/downloaders/jsonLines.js +31 -31
- package/src/js/modules/Download/defaults/downloaders/pdf.js +111 -111
- package/src/js/modules/Download/defaults/downloaders/xlsx.js +98 -98
- package/src/js/modules/Download/defaults/downloaders.js +14 -14
- package/src/js/modules/Edit/Edit.js +735 -736
- package/src/js/modules/Edit/List.js +1037 -1033
- package/src/js/modules/Edit/defaults/editors/autocomplete.js +11 -11
- package/src/js/modules/Edit/defaults/editors/date.js +138 -110
- package/src/js/modules/Edit/defaults/editors/datetime.js +125 -97
- package/src/js/modules/Edit/defaults/editors/input.js +76 -74
- package/src/js/modules/Edit/defaults/editors/list.js +6 -6
- package/src/js/modules/Edit/defaults/editors/number.js +109 -107
- package/src/js/modules/Edit/defaults/editors/progress.js +126 -126
- package/src/js/modules/Edit/defaults/editors/range.js +80 -78
- package/src/js/modules/Edit/defaults/editors/select.js +9 -9
- package/src/js/modules/Edit/defaults/editors/star.js +145 -145
- package/src/js/modules/Edit/defaults/editors/textarea.js +122 -120
- package/src/js/modules/Edit/defaults/editors/tickCross.js +94 -96
- package/src/js/modules/Edit/defaults/editors/time.js +126 -98
- package/src/js/modules/Edit/defaults/editors.js +28 -28
- package/src/js/modules/Edit/inputMask.js +73 -73
- package/src/js/modules/Export/Export.js +623 -617
- package/src/js/modules/Export/ExportColumn.js +10 -10
- package/src/js/modules/Export/ExportRow.js +9 -9
- package/src/js/modules/Filter/Filter.js +892 -889
- package/src/js/modules/Filter/defaults/filters.js +107 -107
- package/src/js/modules/Format/Format.js +212 -212
- package/src/js/modules/Format/defaults/formatters/buttonCross.js +2 -2
- package/src/js/modules/Format/defaults/formatters/buttonTick.js +2 -2
- package/src/js/modules/Format/defaults/formatters/color.js +3 -3
- package/src/js/modules/Format/defaults/formatters/datetime.js +36 -36
- package/src/js/modules/Format/defaults/formatters/datetimediff.js +40 -40
- package/src/js/modules/Format/defaults/formatters/handle.js +3 -3
- package/src/js/modules/Format/defaults/formatters/html.js +2 -2
- package/src/js/modules/Format/defaults/formatters/image.js +39 -39
- package/src/js/modules/Format/defaults/formatters/link.js +77 -77
- package/src/js/modules/Format/defaults/formatters/lookup.js +9 -9
- package/src/js/modules/Format/defaults/formatters/money.js +36 -36
- package/src/js/modules/Format/defaults/formatters/plaintext.js +2 -2
- package/src/js/modules/Format/defaults/formatters/progress.js +132 -132
- package/src/js/modules/Format/defaults/formatters/responsiveCollapse.js +43 -43
- package/src/js/modules/Format/defaults/formatters/rowSelection.js +59 -59
- package/src/js/modules/Format/defaults/formatters/rownum.js +9 -9
- package/src/js/modules/Format/defaults/formatters/star.js +37 -37
- package/src/js/modules/Format/defaults/formatters/textarea.js +3 -3
- package/src/js/modules/Format/defaults/formatters/tickCross.js +21 -21
- package/src/js/modules/Format/defaults/formatters/traffic.js +46 -46
- package/src/js/modules/Format/defaults/formatters.js +42 -42
- package/src/js/modules/FrozenColumns/FrozenColumns.js +299 -299
- package/src/js/modules/FrozenRows/FrozenRows.js +169 -159
- package/src/js/modules/GroupRows/Group.js +597 -595
- package/src/js/modules/GroupRows/GroupComponent.js +66 -66
- package/src/js/modules/GroupRows/GroupRows.js +639 -623
- package/src/js/modules/History/History.js +171 -171
- package/src/js/modules/History/defaults/redoers.js +24 -24
- package/src/js/modules/History/defaults/undoers.js +24 -24
- package/src/js/modules/HtmlTableImport/HtmlTableImport.js +181 -181
- package/src/js/modules/Import/Import.js +193 -193
- package/src/js/modules/Import/defaults/importers/array.js +4 -4
- package/src/js/modules/Import/defaults/importers/csv.js +62 -62
- package/src/js/modules/Import/defaults/importers/json.js +7 -7
- package/src/js/modules/Import/defaults/importers.js +8 -8
- package/src/js/modules/Interaction/Interaction.js +325 -325
- package/src/js/modules/Keybindings/Keybindings.js +172 -172
- package/src/js/modules/Keybindings/defaults/actions.js +118 -118
- package/src/js/modules/Keybindings/defaults/bindings.js +12 -12
- package/src/js/modules/Layout/Layout.js +49 -49
- package/src/js/modules/Layout/defaults/modes/fitColumns.js +171 -171
- package/src/js/modules/Layout/defaults/modes/fitData.js +9 -9
- package/src/js/modules/Layout/defaults/modes/fitDataGeneral.js +9 -9
- package/src/js/modules/Layout/defaults/modes/fitDataStretch.js +39 -39
- package/src/js/modules/Layout/defaults/modes.js +11 -11
- package/src/js/modules/Localize/Localize.js +185 -194
- package/src/js/modules/Localize/defaults/langs.js +36 -36
- package/src/js/modules/Menu/Menu.js +302 -302
- package/src/js/modules/MoveColumns/MoveColumns.js +299 -299
- package/src/js/modules/MoveRows/MoveRows.js +635 -635
- package/src/js/modules/Mutator/Mutator.js +161 -161
- package/src/js/modules/Page/Page.js +881 -881
- package/src/js/modules/Page/defaults/pageCounters/pages.js +32 -32
- package/src/js/modules/Page/defaults/pageCounters/rows.js +39 -39
- package/src/js/modules/Page/defaults/pageCounters.js +7 -7
- package/src/js/modules/Persistence/Persistence.js +458 -458
- package/src/js/modules/Persistence/defaults/readers.js +29 -29
- package/src/js/modules/Persistence/defaults/writers.js +12 -12
- package/src/js/modules/Popup/Popup.js +231 -231
- package/src/js/modules/Print/Print.js +137 -124
- package/src/js/modules/ReactiveData/ReactiveData.js +408 -408
- package/src/js/modules/ResizeColumns/ResizeColumns.js +309 -309
- package/src/js/modules/ResizeRows/ResizeRows.js +111 -111
- package/src/js/modules/ResizeTable/ResizeTable.js +159 -159
- package/src/js/modules/ResponsiveLayout/ResponsiveLayout.js +345 -345
- package/src/js/modules/SelectRow/SelectRow.js +446 -436
- package/src/js/modules/Sort/Sort.js +470 -470
- package/src/js/modules/Sort/defaults/sorters/alphanum.js +43 -43
- package/src/js/modules/Sort/defaults/sorters/array.js +53 -53
- package/src/js/modules/Sort/defaults/sorters/boolean.js +6 -6
- package/src/js/modules/Sort/defaults/sorters/date.js +9 -9
- package/src/js/modules/Sort/defaults/sorters/datetime.js +43 -43
- package/src/js/modules/Sort/defaults/sorters/exists.js +6 -6
- package/src/js/modules/Sort/defaults/sorters/number.js +39 -39
- package/src/js/modules/Sort/defaults/sorters/string.js +33 -33
- package/src/js/modules/Sort/defaults/sorters/time.js +9 -9
- package/src/js/modules/Sort/defaults/sorters.js +20 -20
- package/src/js/modules/Tooltip/Tooltip.js +130 -130
- package/src/js/modules/Validate/Validate.js +305 -305
- package/src/js/modules/Validate/defaults/validators.js +138 -138
- package/src/scss/tabulator.scss +1464 -1466
- package/src/scss/themes/bootstrap/functions4.scss +118 -118
- package/src/scss/themes/bootstrap/functions5.scss +302 -302
- package/src/scss/themes/bootstrap/tabulator_bootstrap3.scss +284 -284
- package/src/scss/themes/bootstrap/tabulator_bootstrap4.scss +544 -544
- package/src/scss/themes/bootstrap/tabulator_bootstrap5.scss +574 -574
- package/src/scss/themes/bootstrap/variables3.scss +870 -870
- package/src/scss/themes/bootstrap/variables4.scss +930 -930
- package/src/scss/themes/bootstrap/variables5.scss +1641 -1641
- package/src/scss/themes/bulma/tabulator_bulma.scss +252 -252
- package/src/scss/themes/bulma/variables.scss +197 -197
- package/src/scss/themes/materialize/tabulator_materialize.scss +265 -265
- package/src/scss/themes/materialize/variables.scss +70 -70
- package/src/scss/themes/semanticui/tabulator_semanticui.scss +561 -561
- package/src/scss/themes/semanticui/variables.scss +839 -839
- package/src/scss/themes/semanticui/variables_table.scss +247 -247
- package/src/scss/themes/tabulator_midnight.scss +158 -158
- package/src/scss/themes/tabulator_modern.scss +231 -231
- package/src/scss/themes/tabulator_simple.scss +102 -102
- package/src/scss/themes/tabulator_site.scss +189 -189
|
@@ -1,280 +1,280 @@
|
|
|
1
|
-
import Module from '../../core/Module.js';
|
|
2
|
-
|
|
3
|
-
import defaultPasteActions from './defaults/pasteActions.js';
|
|
4
|
-
import defaultPasteParsers from './defaults/pasteParsers.js';
|
|
5
|
-
|
|
6
|
-
class Clipboard extends Module{
|
|
7
|
-
|
|
8
|
-
constructor(table){
|
|
9
|
-
super(table);
|
|
10
|
-
|
|
11
|
-
this.mode = true;
|
|
12
|
-
this.pasteParser = function(){};
|
|
13
|
-
this.pasteAction = function(){};
|
|
14
|
-
this.customSelection = false;
|
|
15
|
-
this.rowRange = false;
|
|
16
|
-
this.blocked = true; //block copy actions not originating from this command
|
|
17
|
-
|
|
18
|
-
this.registerTableOption("clipboard", false); //enable clipboard
|
|
19
|
-
this.registerTableOption("clipboardCopyStyled", true); //formatted table data
|
|
20
|
-
this.registerTableOption("clipboardCopyConfig", false); //clipboard config
|
|
21
|
-
this.registerTableOption("clipboardCopyFormatter", false); //DEPRECATED - REMOVE in 5.0
|
|
22
|
-
this.registerTableOption("clipboardCopyRowRange", "active"); //restrict clipboard to visible rows only
|
|
23
|
-
this.registerTableOption("clipboardPasteParser", "table"); //convert pasted clipboard data to rows
|
|
24
|
-
this.registerTableOption("clipboardPasteAction", "insert"); //how to insert pasted data into the table
|
|
25
|
-
|
|
26
|
-
this.registerColumnOption("clipboard");
|
|
27
|
-
this.registerColumnOption("titleClipboard");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
initialize(){
|
|
31
|
-
this.mode = this.table.options.clipboard;
|
|
32
|
-
|
|
33
|
-
this.rowRange = this.table.options.clipboardCopyRowRange;
|
|
34
|
-
|
|
35
|
-
if(this.mode === true || this.mode === "copy"){
|
|
36
|
-
this.table.element.addEventListener("copy", (e) => {
|
|
37
|
-
var plain, html, list;
|
|
38
|
-
|
|
39
|
-
if(!this.blocked){
|
|
40
|
-
e.preventDefault();
|
|
41
|
-
|
|
42
|
-
if(this.customSelection){
|
|
43
|
-
plain = this.customSelection;
|
|
44
|
-
|
|
45
|
-
if(this.table.options.clipboardCopyFormatter){
|
|
46
|
-
plain = this.table.options.clipboardCopyFormatter("plain", plain);
|
|
47
|
-
}
|
|
48
|
-
}else{
|
|
49
|
-
|
|
50
|
-
list = this.table.modules.export.generateExportList(this.table.options.clipboardCopyConfig, this.table.options.clipboardCopyStyled, this.rowRange, "clipboard");
|
|
51
|
-
|
|
52
|
-
html = this.table.modules.export.generateHTMLTable(list);
|
|
53
|
-
plain = html ? this.generatePlainContent(list) : "";
|
|
54
|
-
|
|
55
|
-
if(this.table.options.clipboardCopyFormatter){
|
|
56
|
-
plain = this.table.options.clipboardCopyFormatter("plain", plain);
|
|
57
|
-
html = this.table.options.clipboardCopyFormatter("html", html);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (window.clipboardData && window.clipboardData.setData) {
|
|
62
|
-
window.clipboardData.setData('Text', plain);
|
|
63
|
-
} else if (e.clipboardData && e.clipboardData.setData) {
|
|
64
|
-
e.clipboardData.setData('text/plain', plain);
|
|
65
|
-
if(html){
|
|
66
|
-
e.clipboardData.setData('text/html', html);
|
|
67
|
-
}
|
|
68
|
-
} else if (e.originalEvent && e.originalEvent.clipboardData.setData) {
|
|
69
|
-
e.originalEvent.clipboardData.setData('text/plain', plain);
|
|
70
|
-
if(html){
|
|
71
|
-
e.originalEvent.clipboardData.setData('text/html', html);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
this.dispatchExternal("clipboardCopied", plain, html);
|
|
76
|
-
|
|
77
|
-
this.reset();
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if(this.mode === true || this.mode === "paste"){
|
|
83
|
-
this.table.element.addEventListener("paste", (e) => {
|
|
84
|
-
this.paste(e);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
this.setPasteParser(this.table.options.clipboardPasteParser);
|
|
89
|
-
this.setPasteAction(this.table.options.clipboardPasteAction);
|
|
90
|
-
|
|
91
|
-
this.registerTableFunction("copyToClipboard", this.copy.bind(this));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
reset(){
|
|
95
|
-
this.blocked = true;
|
|
96
|
-
this.customSelection = false;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
generatePlainContent (list) {
|
|
100
|
-
var output = [];
|
|
101
|
-
|
|
102
|
-
list.forEach((row) => {
|
|
103
|
-
var rowData = [];
|
|
104
|
-
|
|
105
|
-
row.columns.forEach((col) => {
|
|
106
|
-
var value = "";
|
|
107
|
-
|
|
108
|
-
if(col){
|
|
109
|
-
|
|
110
|
-
if(row.type === "group"){
|
|
111
|
-
col.value = col.component.getKey();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if(col.value === null){
|
|
115
|
-
value = "";
|
|
116
|
-
}else{
|
|
117
|
-
switch(typeof col.value){
|
|
118
|
-
case "object":
|
|
119
|
-
value = JSON.stringify(col.value);
|
|
120
|
-
break;
|
|
121
|
-
|
|
122
|
-
case "undefined":
|
|
123
|
-
value = "";
|
|
124
|
-
break;
|
|
125
|
-
|
|
126
|
-
default:
|
|
127
|
-
value = col.value;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
rowData.push(value);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
output.push(rowData.join("\t"));
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
return output.join("\n");
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
copy (range, internal) {
|
|
142
|
-
var sel, textRange;
|
|
143
|
-
this.blocked = false;
|
|
144
|
-
this.customSelection = false;
|
|
145
|
-
|
|
146
|
-
if (this.mode === true || this.mode === "copy") {
|
|
147
|
-
|
|
148
|
-
this.rowRange = range || this.table.options.clipboardCopyRowRange;
|
|
149
|
-
|
|
150
|
-
if (typeof window.getSelection != "undefined" && typeof document.createRange != "undefined") {
|
|
151
|
-
range = document.createRange();
|
|
152
|
-
range.selectNodeContents(this.table.element);
|
|
153
|
-
sel = window.getSelection();
|
|
154
|
-
|
|
155
|
-
if (sel.toString() && internal) {
|
|
156
|
-
this.customSelection = sel.toString();
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
sel.removeAllRanges();
|
|
160
|
-
sel.addRange(range);
|
|
161
|
-
} else if (typeof document.selection != "undefined" && typeof document.body.createTextRange != "undefined") {
|
|
162
|
-
textRange = document.body.createTextRange();
|
|
163
|
-
textRange.moveToElementText(this.table.element);
|
|
164
|
-
textRange.select();
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
document.execCommand('copy');
|
|
168
|
-
|
|
169
|
-
if (sel) {
|
|
170
|
-
sel.removeAllRanges();
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
//PASTE EVENT HANDLING
|
|
176
|
-
setPasteAction(action){
|
|
177
|
-
|
|
178
|
-
switch(typeof action){
|
|
179
|
-
case "string":
|
|
180
|
-
this.pasteAction = Clipboard.pasteActions[action];
|
|
181
|
-
|
|
182
|
-
if(!this.pasteAction){
|
|
183
|
-
console.warn("Clipboard Error - No such paste action found:", action);
|
|
184
|
-
}
|
|
185
|
-
break;
|
|
186
|
-
|
|
187
|
-
case "function":
|
|
188
|
-
this.pasteAction = action;
|
|
189
|
-
break;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
setPasteParser(parser){
|
|
194
|
-
switch(typeof parser){
|
|
195
|
-
case "string":
|
|
196
|
-
this.pasteParser = Clipboard.pasteParsers[parser];
|
|
197
|
-
|
|
198
|
-
if(!this.pasteParser){
|
|
199
|
-
console.warn("Clipboard Error - No such paste parser found:", parser);
|
|
200
|
-
}
|
|
201
|
-
break;
|
|
202
|
-
|
|
203
|
-
case "function":
|
|
204
|
-
this.pasteParser = parser;
|
|
205
|
-
break;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
paste(e){
|
|
210
|
-
var data, rowData, rows;
|
|
211
|
-
|
|
212
|
-
if(this.checkPaseOrigin(e)){
|
|
213
|
-
|
|
214
|
-
data = this.getPasteData(e);
|
|
215
|
-
|
|
216
|
-
rowData = this.pasteParser.call(this, data);
|
|
217
|
-
|
|
218
|
-
if(rowData){
|
|
219
|
-
e.preventDefault();
|
|
220
|
-
|
|
221
|
-
if(this.table.modExists("mutator")){
|
|
222
|
-
rowData = this.mutateData(rowData);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
rows = this.pasteAction.call(this, rowData);
|
|
226
|
-
|
|
227
|
-
this.dispatchExternal("clipboardPasted", data, rowData, rows);
|
|
228
|
-
}else{
|
|
229
|
-
this.dispatchExternal("clipboardPasteError", data);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
mutateData(data){
|
|
235
|
-
var output = [];
|
|
236
|
-
|
|
237
|
-
if(Array.isArray(data)){
|
|
238
|
-
data.forEach((row) => {
|
|
239
|
-
output.push(this.table.modules.mutator.transformRow(row, "clipboard"));
|
|
240
|
-
});
|
|
241
|
-
}else{
|
|
242
|
-
output = data;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return output;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
checkPaseOrigin(e){
|
|
250
|
-
var valid = true;
|
|
251
|
-
|
|
252
|
-
if(e.target.tagName != "DIV" || this.table.modules.edit.currentCell){
|
|
253
|
-
valid = false;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
return valid;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
getPasteData(e){
|
|
260
|
-
var data;
|
|
261
|
-
|
|
262
|
-
if (window.clipboardData && window.clipboardData.getData) {
|
|
263
|
-
data = window.clipboardData.getData('Text');
|
|
264
|
-
} else if (e.clipboardData && e.clipboardData.getData) {
|
|
265
|
-
data = e.clipboardData.getData('text/plain');
|
|
266
|
-
} else if (e.originalEvent && e.originalEvent.clipboardData.getData) {
|
|
267
|
-
data = e.originalEvent.clipboardData.getData('text/plain');
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return data;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
Clipboard.moduleName = "clipboard";
|
|
275
|
-
|
|
276
|
-
//load defaults
|
|
277
|
-
Clipboard.pasteActions = defaultPasteActions;
|
|
278
|
-
Clipboard.pasteParsers = defaultPasteParsers;
|
|
279
|
-
|
|
1
|
+
import Module from '../../core/Module.js';
|
|
2
|
+
|
|
3
|
+
import defaultPasteActions from './defaults/pasteActions.js';
|
|
4
|
+
import defaultPasteParsers from './defaults/pasteParsers.js';
|
|
5
|
+
|
|
6
|
+
class Clipboard extends Module{
|
|
7
|
+
|
|
8
|
+
constructor(table){
|
|
9
|
+
super(table);
|
|
10
|
+
|
|
11
|
+
this.mode = true;
|
|
12
|
+
this.pasteParser = function(){};
|
|
13
|
+
this.pasteAction = function(){};
|
|
14
|
+
this.customSelection = false;
|
|
15
|
+
this.rowRange = false;
|
|
16
|
+
this.blocked = true; //block copy actions not originating from this command
|
|
17
|
+
|
|
18
|
+
this.registerTableOption("clipboard", false); //enable clipboard
|
|
19
|
+
this.registerTableOption("clipboardCopyStyled", true); //formatted table data
|
|
20
|
+
this.registerTableOption("clipboardCopyConfig", false); //clipboard config
|
|
21
|
+
this.registerTableOption("clipboardCopyFormatter", false); //DEPRECATED - REMOVE in 5.0
|
|
22
|
+
this.registerTableOption("clipboardCopyRowRange", "active"); //restrict clipboard to visible rows only
|
|
23
|
+
this.registerTableOption("clipboardPasteParser", "table"); //convert pasted clipboard data to rows
|
|
24
|
+
this.registerTableOption("clipboardPasteAction", "insert"); //how to insert pasted data into the table
|
|
25
|
+
|
|
26
|
+
this.registerColumnOption("clipboard");
|
|
27
|
+
this.registerColumnOption("titleClipboard");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
initialize(){
|
|
31
|
+
this.mode = this.table.options.clipboard;
|
|
32
|
+
|
|
33
|
+
this.rowRange = this.table.options.clipboardCopyRowRange;
|
|
34
|
+
|
|
35
|
+
if(this.mode === true || this.mode === "copy"){
|
|
36
|
+
this.table.element.addEventListener("copy", (e) => {
|
|
37
|
+
var plain, html, list;
|
|
38
|
+
|
|
39
|
+
if(!this.blocked){
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
|
|
42
|
+
if(this.customSelection){
|
|
43
|
+
plain = this.customSelection;
|
|
44
|
+
|
|
45
|
+
if(this.table.options.clipboardCopyFormatter){
|
|
46
|
+
plain = this.table.options.clipboardCopyFormatter("plain", plain);
|
|
47
|
+
}
|
|
48
|
+
}else{
|
|
49
|
+
|
|
50
|
+
list = this.table.modules.export.generateExportList(this.table.options.clipboardCopyConfig, this.table.options.clipboardCopyStyled, this.rowRange, "clipboard");
|
|
51
|
+
|
|
52
|
+
html = this.table.modules.export.generateHTMLTable(list);
|
|
53
|
+
plain = html ? this.generatePlainContent(list) : "";
|
|
54
|
+
|
|
55
|
+
if(this.table.options.clipboardCopyFormatter){
|
|
56
|
+
plain = this.table.options.clipboardCopyFormatter("plain", plain);
|
|
57
|
+
html = this.table.options.clipboardCopyFormatter("html", html);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (window.clipboardData && window.clipboardData.setData) {
|
|
62
|
+
window.clipboardData.setData('Text', plain);
|
|
63
|
+
} else if (e.clipboardData && e.clipboardData.setData) {
|
|
64
|
+
e.clipboardData.setData('text/plain', plain);
|
|
65
|
+
if(html){
|
|
66
|
+
e.clipboardData.setData('text/html', html);
|
|
67
|
+
}
|
|
68
|
+
} else if (e.originalEvent && e.originalEvent.clipboardData.setData) {
|
|
69
|
+
e.originalEvent.clipboardData.setData('text/plain', plain);
|
|
70
|
+
if(html){
|
|
71
|
+
e.originalEvent.clipboardData.setData('text/html', html);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
this.dispatchExternal("clipboardCopied", plain, html);
|
|
76
|
+
|
|
77
|
+
this.reset();
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if(this.mode === true || this.mode === "paste"){
|
|
83
|
+
this.table.element.addEventListener("paste", (e) => {
|
|
84
|
+
this.paste(e);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
this.setPasteParser(this.table.options.clipboardPasteParser);
|
|
89
|
+
this.setPasteAction(this.table.options.clipboardPasteAction);
|
|
90
|
+
|
|
91
|
+
this.registerTableFunction("copyToClipboard", this.copy.bind(this));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
reset(){
|
|
95
|
+
this.blocked = true;
|
|
96
|
+
this.customSelection = false;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
generatePlainContent (list) {
|
|
100
|
+
var output = [];
|
|
101
|
+
|
|
102
|
+
list.forEach((row) => {
|
|
103
|
+
var rowData = [];
|
|
104
|
+
|
|
105
|
+
row.columns.forEach((col) => {
|
|
106
|
+
var value = "";
|
|
107
|
+
|
|
108
|
+
if(col){
|
|
109
|
+
|
|
110
|
+
if(row.type === "group"){
|
|
111
|
+
col.value = col.component.getKey();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if(col.value === null){
|
|
115
|
+
value = "";
|
|
116
|
+
}else{
|
|
117
|
+
switch(typeof col.value){
|
|
118
|
+
case "object":
|
|
119
|
+
value = JSON.stringify(col.value);
|
|
120
|
+
break;
|
|
121
|
+
|
|
122
|
+
case "undefined":
|
|
123
|
+
value = "";
|
|
124
|
+
break;
|
|
125
|
+
|
|
126
|
+
default:
|
|
127
|
+
value = col.value;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
rowData.push(value);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
output.push(rowData.join("\t"));
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
return output.join("\n");
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
copy (range, internal) {
|
|
142
|
+
var sel, textRange;
|
|
143
|
+
this.blocked = false;
|
|
144
|
+
this.customSelection = false;
|
|
145
|
+
|
|
146
|
+
if (this.mode === true || this.mode === "copy") {
|
|
147
|
+
|
|
148
|
+
this.rowRange = range || this.table.options.clipboardCopyRowRange;
|
|
149
|
+
|
|
150
|
+
if (typeof window.getSelection != "undefined" && typeof document.createRange != "undefined") {
|
|
151
|
+
range = document.createRange();
|
|
152
|
+
range.selectNodeContents(this.table.element);
|
|
153
|
+
sel = window.getSelection();
|
|
154
|
+
|
|
155
|
+
if (sel.toString() && internal) {
|
|
156
|
+
this.customSelection = sel.toString();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
sel.removeAllRanges();
|
|
160
|
+
sel.addRange(range);
|
|
161
|
+
} else if (typeof document.selection != "undefined" && typeof document.body.createTextRange != "undefined") {
|
|
162
|
+
textRange = document.body.createTextRange();
|
|
163
|
+
textRange.moveToElementText(this.table.element);
|
|
164
|
+
textRange.select();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
document.execCommand('copy');
|
|
168
|
+
|
|
169
|
+
if (sel) {
|
|
170
|
+
sel.removeAllRanges();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
//PASTE EVENT HANDLING
|
|
176
|
+
setPasteAction(action){
|
|
177
|
+
|
|
178
|
+
switch(typeof action){
|
|
179
|
+
case "string":
|
|
180
|
+
this.pasteAction = Clipboard.pasteActions[action];
|
|
181
|
+
|
|
182
|
+
if(!this.pasteAction){
|
|
183
|
+
console.warn("Clipboard Error - No such paste action found:", action);
|
|
184
|
+
}
|
|
185
|
+
break;
|
|
186
|
+
|
|
187
|
+
case "function":
|
|
188
|
+
this.pasteAction = action;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
setPasteParser(parser){
|
|
194
|
+
switch(typeof parser){
|
|
195
|
+
case "string":
|
|
196
|
+
this.pasteParser = Clipboard.pasteParsers[parser];
|
|
197
|
+
|
|
198
|
+
if(!this.pasteParser){
|
|
199
|
+
console.warn("Clipboard Error - No such paste parser found:", parser);
|
|
200
|
+
}
|
|
201
|
+
break;
|
|
202
|
+
|
|
203
|
+
case "function":
|
|
204
|
+
this.pasteParser = parser;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
paste(e){
|
|
210
|
+
var data, rowData, rows;
|
|
211
|
+
|
|
212
|
+
if(this.checkPaseOrigin(e)){
|
|
213
|
+
|
|
214
|
+
data = this.getPasteData(e);
|
|
215
|
+
|
|
216
|
+
rowData = this.pasteParser.call(this, data);
|
|
217
|
+
|
|
218
|
+
if(rowData){
|
|
219
|
+
e.preventDefault();
|
|
220
|
+
|
|
221
|
+
if(this.table.modExists("mutator")){
|
|
222
|
+
rowData = this.mutateData(rowData);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
rows = this.pasteAction.call(this, rowData);
|
|
226
|
+
|
|
227
|
+
this.dispatchExternal("clipboardPasted", data, rowData, rows);
|
|
228
|
+
}else{
|
|
229
|
+
this.dispatchExternal("clipboardPasteError", data);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
mutateData(data){
|
|
235
|
+
var output = [];
|
|
236
|
+
|
|
237
|
+
if(Array.isArray(data)){
|
|
238
|
+
data.forEach((row) => {
|
|
239
|
+
output.push(this.table.modules.mutator.transformRow(row, "clipboard"));
|
|
240
|
+
});
|
|
241
|
+
}else{
|
|
242
|
+
output = data;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return output;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
checkPaseOrigin(e){
|
|
250
|
+
var valid = true;
|
|
251
|
+
|
|
252
|
+
if(e.target.tagName != "DIV" || this.table.modules.edit.currentCell){
|
|
253
|
+
valid = false;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return valid;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
getPasteData(e){
|
|
260
|
+
var data;
|
|
261
|
+
|
|
262
|
+
if (window.clipboardData && window.clipboardData.getData) {
|
|
263
|
+
data = window.clipboardData.getData('Text');
|
|
264
|
+
} else if (e.clipboardData && e.clipboardData.getData) {
|
|
265
|
+
data = e.clipboardData.getData('text/plain');
|
|
266
|
+
} else if (e.originalEvent && e.originalEvent.clipboardData.getData) {
|
|
267
|
+
data = e.originalEvent.clipboardData.getData('text/plain');
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return data;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
Clipboard.moduleName = "clipboard";
|
|
275
|
+
|
|
276
|
+
//load defaults
|
|
277
|
+
Clipboard.pasteActions = defaultPasteActions;
|
|
278
|
+
Clipboard.pasteParsers = defaultPasteParsers;
|
|
279
|
+
|
|
280
280
|
export default Clipboard;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
replace:function(rows){
|
|
3
|
-
return this.table.setData(rows);
|
|
4
|
-
},
|
|
5
|
-
update:function(rows){
|
|
6
|
-
return this.table.updateOrAddData(rows);
|
|
7
|
-
},
|
|
8
|
-
insert:function(rows){
|
|
9
|
-
return this.table.addData(rows);
|
|
10
|
-
},
|
|
1
|
+
export default {
|
|
2
|
+
replace:function(rows){
|
|
3
|
+
return this.table.setData(rows);
|
|
4
|
+
},
|
|
5
|
+
update:function(rows){
|
|
6
|
+
return this.table.updateOrAddData(rows);
|
|
7
|
+
},
|
|
8
|
+
insert:function(rows){
|
|
9
|
+
return this.table.addData(rows);
|
|
10
|
+
},
|
|
11
11
|
};
|