@progress/kendo-spreadsheet-common 1.0.1 → 1.1.0-develop.1

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/dist/index-esm.js CHANGED
@@ -11203,50 +11203,39 @@ class Controller {
11203
11203
  return;
11204
11204
  }
11205
11205
 
11206
- // this.cellContextMenu.close();
11207
- // this.colHeaderContextMenu.close();
11208
- // this.rowHeaderContextMenu.close();
11209
- // this.drawingContextMenu.close();
11206
+ // emit close here if necessary
11210
11207
 
11211
- // let menu;
11212
-
11213
- // let object = this.objectAt(event);
11208
+ let object = this.objectAt(event);
11214
11209
 
11215
- // if (object.type === "columnresizehandle" || object.type === "rowresizehandle") {
11216
- // return;
11217
- // }
11210
+ if (object.type === "columnresizehandle" || object.type === "rowresizehandle") {
11211
+ return;
11212
+ }
11218
11213
 
11219
- // if (object.ref) {
11220
- // this.navigator.selectForContextMenu(object.ref, SELECTION_MODES[object.type]);
11221
- // } else if (object.type == "drawing") {
11222
- // this.navigator.selectDrawingForContextMenu(object.drawing);
11223
- // }
11214
+ if (object.ref) {
11215
+ this.navigator.selectForContextMenu(object.ref, SELECTION_MODES[object.type]);
11216
+ } else if (object.type == "drawing") {
11217
+ this.navigator.selectDrawingForContextMenu(object.drawing);
11218
+ }
11224
11219
 
11225
- // let isComposite = this.navigator._sheet.select() instanceof UnionRef;
11226
- // let showUnhide = false;
11227
- // let showUnmerge = false;
11228
-
11229
- // if (object.type == "columnheader") {
11230
- // menu = this.colHeaderContextMenu;
11231
- // showUnhide = !isComposite && this.axisManager.selectionIncludesHiddenColumns();
11232
- // } else if (object.type == "rowheader") {
11233
- // menu = this.rowHeaderContextMenu;
11234
- // showUnhide = !isComposite && this.axisManager.selectionIncludesHiddenRows();
11235
- // } else if (object.type == "drawing") {
11236
- // menu = this.drawingContextMenu;
11237
- // } else {
11238
- // menu = this.cellContextMenu;
11239
- // showUnmerge = this.navigator.selectionIncludesMergedCells();
11240
- // }
11220
+ let isComposite = this.navigator._sheet.select() instanceof UnionRef;
11221
+ let showUnhide = false;
11222
+ let showUnmerge = false;
11241
11223
 
11242
- // menu.element.find(COMPOSITE_UNAVAILABLE_ACTION_SELECTORS).toggle(!isComposite);
11243
- // menu.element.find(UNHIDE_ACTION_SELECTORS).toggle(showUnhide);
11244
- // menu.element.find('[data-action=unmerge]').toggle(showUnmerge);
11224
+ if (object.type == "columnheader") {
11225
+ showUnhide = !isComposite && this.axisManager.selectionIncludesHiddenColumns();
11226
+ } else if (object.type == "rowheader") {
11227
+ showUnhide = !isComposite && this.axisManager.selectionIncludesHiddenRows();
11228
+ } else if (object.type == "drawing") ; else {
11229
+ showUnmerge = this.navigator.selectionIncludesMergedCells();
11230
+ }
11245
11231
 
11246
- // // avoid the immediate close
11247
- // setTimeout(function() {
11248
- // menu.open(event.pageX, event.pageY);
11249
- // });
11232
+ this._workbook.trigger("contextmenu", {
11233
+ objectRef: object.ref,
11234
+ targetType: object.type,
11235
+ showUnhide,
11236
+ showUnmerge,
11237
+ originalEvent: event
11238
+ });
11250
11239
  }
11251
11240
 
11252
11241
  prevent(event) {
@@ -24516,14 +24505,13 @@ class AdjustRowHeightCommand extends Command {
24516
24505
 
24517
24506
  class ToolbarPasteCommand extends Command {
24518
24507
  exec() {
24519
- // PoC only, no clipboard so far
24520
- // if (kendo.support.clipboard.paste) {
24521
- // this._workbook._view.clipboard.focus().select();
24522
- // //reason : focusclipbord
24523
- // document.execCommand('paste');
24524
- // } else {
24525
- // return { reason: "error", type: "useKeyboard" };
24526
- // }
24508
+ if (detectClipboardAccess().paste) {
24509
+ this._workbook._view.clipboard.focus();
24510
+ // explore programmatic pasting further
24511
+ document.execCommand('paste');
24512
+ } else {
24513
+ return { reason: "error", type: "useKeyboard" };
24514
+ }
24527
24515
  }
24528
24516
  }
24529
24517
 
@@ -24602,19 +24590,28 @@ class CopyCommand extends CutCommand {
24602
24590
  // $(textarea).remove();
24603
24591
  // }
24604
24592
 
24593
+ function detectClipboardAccess() {
24594
+ const commands = {
24595
+ copy: document.queryCommandSupported ? document.queryCommandSupported("copy") : false,
24596
+ cut: document.queryCommandSupported ? document.queryCommandSupported("cut") : false,
24597
+ paste: document.queryCommandSupported ? document.queryCommandSupported("paste") : false
24598
+ };
24599
+
24600
+ return commands;
24601
+ }
24602
+
24605
24603
  class ToolbarCopyCommand extends Command {
24606
24604
  constructor(options) {
24607
24605
  super(options);
24608
24606
  this._clipboard = options.workbook.clipboard();
24609
- this.undo = noop;
24607
+ this.cannotUndo = true;
24610
24608
  }
24611
24609
  exec() {
24612
- // PoC only
24613
- // if (kendo.support.clipboard.copy) {
24614
- // document.execCommand('copy');
24615
- // } else {
24616
- return { reason: "error", type: "useKeyboard" };
24617
- // }
24610
+ if (detectClipboardAccess().copy) {
24611
+ document.execCommand('copy');
24612
+ } else {
24613
+ return { reason: "error", type: "useKeyboard" };
24614
+ }
24618
24615
  }
24619
24616
  }
24620
24617
 
@@ -24664,12 +24661,11 @@ class ToolbarCutCommand extends Command {
24664
24661
  this.cannotUndo = true;
24665
24662
  }
24666
24663
  exec() {
24667
- // PoC only
24668
- // if (kendo.support.clipboard.copy) {
24669
- // document.execCommand('cut');
24670
- // } else {
24671
- return { reason: "error", type: "useKeyboard" };
24672
- // }
24664
+ if (detectClipboardAccess().copy) {
24665
+ document.execCommand('cut');
24666
+ } else {
24667
+ return { reason: "error", type: "useKeyboard" };
24668
+ }
24673
24669
  }
24674
24670
  }
24675
24671
 
@@ -26740,6 +26736,7 @@ const events$1 = [
26740
26736
  "paste",
26741
26737
  "changing",
26742
26738
  "change",
26739
+ "contextmenu",
26743
26740
  "excelImport",
26744
26741
  "excelExport",
26745
26742
  "insertSheet",
@@ -27765,6 +27762,7 @@ class SpreadsheetWidget extends Widget {
27765
27762
 
27766
27763
  _keyDown(e) {
27767
27764
  let key = e.keyCode;
27765
+ let controlKey = e.ctrlKey || e.metaKey;
27768
27766
 
27769
27767
  if (key === keys.F11 && e.shiftKey) {
27770
27768
  this._view.sheetsbar._onAddSelect();
@@ -27798,21 +27796,12 @@ class SpreadsheetWidget extends Widget {
27798
27796
  this._view.sheetsbar._createEditor();
27799
27797
  e.preventDefault();
27800
27798
  return;
27801
- } else if (e.ctrlKey && key === keys.B) {
27802
- const bold = this.element.querySelector("[data-tool=bold]");
27803
- if (bold) {
27804
- bold.click();
27805
- }
27806
- } else if (e.ctrlKey && key === keys.I) {
27807
- const italic = this.element.querySelector("[data-tool=italic]");
27808
- if (italic) {
27809
- italic.click();
27810
- }
27811
- } else if (e.ctrlKey && key === keys.U) {
27812
- const underline = this.element.querySelector("[data-tool=underline]");
27813
- if (underline) {
27814
- underline.click();
27815
- }
27799
+ } else if (controlKey && key === keys.B) {
27800
+ this._handleTypographicalEmphasis('bold');
27801
+ } else if (controlKey && key === keys.I) {
27802
+ this._handleTypographicalEmphasis('italic');
27803
+ } else if (controlKey && key === keys.U) {
27804
+ this._handleTypographicalEmphasis('underline');
27816
27805
  } else if (e.altKey && key === keys.H) {
27817
27806
  this._view.tabstrip.select(0);
27818
27807
  e.preventDefault();
@@ -27828,6 +27817,20 @@ class SpreadsheetWidget extends Widget {
27828
27817
  }
27829
27818
  }
27830
27819
 
27820
+ _handleTypographicalEmphasis(command) {
27821
+ const sheet = this.activeSheet();
27822
+
27823
+ if (sheet) {
27824
+ this.executeCommand({
27825
+ command: 'PropertyChangeCommand',
27826
+ options: {
27827
+ property: command,
27828
+ value: !sheet.range(sheet.activeCell())[command]()
27829
+ }
27830
+ });
27831
+ }
27832
+ }
27833
+
27831
27834
  _resize() {
27832
27835
  this.refresh({ layout: true });
27833
27836
  }
@@ -28121,6 +28124,10 @@ class SpreadsheetWidget extends Widget {
28121
28124
  // kendo.ui.progress(this.element, e.toggle);
28122
28125
  }
28123
28126
 
28127
+ _onContextMenu(e) {
28128
+ this.trigger("contextmenu", e);
28129
+ }
28130
+
28124
28131
  _bindWorkbookEvents() {
28125
28132
  this._workbook.bind("cut", this._workbookCut.bind(this));
28126
28133
  this._workbook.bind("copy", this._workbookCopy.bind(this));
@@ -28147,6 +28154,7 @@ class SpreadsheetWidget extends Widget {
28147
28154
  this._workbook.bind("dataBinding", this._workbookDataBinding.bind(this));
28148
28155
  this._workbook.bind("dataBound", this._workbookDataBound.bind(this));
28149
28156
  this._workbook.bind("progress", this._workbookProgress.bind(this));
28157
+ this._workbook.bind("contextmenu", this._onContextMenu.bind(this));
28150
28158
  }
28151
28159
 
28152
28160
  destroy() {
package/dist/index.js CHANGED
@@ -11204,50 +11204,39 @@
11204
11204
  return;
11205
11205
  }
11206
11206
 
11207
- // this.cellContextMenu.close();
11208
- // this.colHeaderContextMenu.close();
11209
- // this.rowHeaderContextMenu.close();
11210
- // this.drawingContextMenu.close();
11207
+ // emit close here if necessary
11211
11208
 
11212
- // let menu;
11213
-
11214
- // let object = this.objectAt(event);
11209
+ let object = this.objectAt(event);
11215
11210
 
11216
- // if (object.type === "columnresizehandle" || object.type === "rowresizehandle") {
11217
- // return;
11218
- // }
11211
+ if (object.type === "columnresizehandle" || object.type === "rowresizehandle") {
11212
+ return;
11213
+ }
11219
11214
 
11220
- // if (object.ref) {
11221
- // this.navigator.selectForContextMenu(object.ref, SELECTION_MODES[object.type]);
11222
- // } else if (object.type == "drawing") {
11223
- // this.navigator.selectDrawingForContextMenu(object.drawing);
11224
- // }
11215
+ if (object.ref) {
11216
+ this.navigator.selectForContextMenu(object.ref, SELECTION_MODES[object.type]);
11217
+ } else if (object.type == "drawing") {
11218
+ this.navigator.selectDrawingForContextMenu(object.drawing);
11219
+ }
11225
11220
 
11226
- // let isComposite = this.navigator._sheet.select() instanceof UnionRef;
11227
- // let showUnhide = false;
11228
- // let showUnmerge = false;
11229
-
11230
- // if (object.type == "columnheader") {
11231
- // menu = this.colHeaderContextMenu;
11232
- // showUnhide = !isComposite && this.axisManager.selectionIncludesHiddenColumns();
11233
- // } else if (object.type == "rowheader") {
11234
- // menu = this.rowHeaderContextMenu;
11235
- // showUnhide = !isComposite && this.axisManager.selectionIncludesHiddenRows();
11236
- // } else if (object.type == "drawing") {
11237
- // menu = this.drawingContextMenu;
11238
- // } else {
11239
- // menu = this.cellContextMenu;
11240
- // showUnmerge = this.navigator.selectionIncludesMergedCells();
11241
- // }
11221
+ let isComposite = this.navigator._sheet.select() instanceof UnionRef;
11222
+ let showUnhide = false;
11223
+ let showUnmerge = false;
11242
11224
 
11243
- // menu.element.find(COMPOSITE_UNAVAILABLE_ACTION_SELECTORS).toggle(!isComposite);
11244
- // menu.element.find(UNHIDE_ACTION_SELECTORS).toggle(showUnhide);
11245
- // menu.element.find('[data-action=unmerge]').toggle(showUnmerge);
11225
+ if (object.type == "columnheader") {
11226
+ showUnhide = !isComposite && this.axisManager.selectionIncludesHiddenColumns();
11227
+ } else if (object.type == "rowheader") {
11228
+ showUnhide = !isComposite && this.axisManager.selectionIncludesHiddenRows();
11229
+ } else if (object.type == "drawing") ; else {
11230
+ showUnmerge = this.navigator.selectionIncludesMergedCells();
11231
+ }
11246
11232
 
11247
- // // avoid the immediate close
11248
- // setTimeout(function() {
11249
- // menu.open(event.pageX, event.pageY);
11250
- // });
11233
+ this._workbook.trigger("contextmenu", {
11234
+ objectRef: object.ref,
11235
+ targetType: object.type,
11236
+ showUnhide,
11237
+ showUnmerge,
11238
+ originalEvent: event
11239
+ });
11251
11240
  }
11252
11241
 
11253
11242
  prevent(event) {
@@ -24517,14 +24506,13 @@
24517
24506
 
24518
24507
  class ToolbarPasteCommand extends Command {
24519
24508
  exec() {
24520
- // PoC only, no clipboard so far
24521
- // if (kendo.support.clipboard.paste) {
24522
- // this._workbook._view.clipboard.focus().select();
24523
- // //reason : focusclipbord
24524
- // document.execCommand('paste');
24525
- // } else {
24526
- // return { reason: "error", type: "useKeyboard" };
24527
- // }
24509
+ if (detectClipboardAccess().paste) {
24510
+ this._workbook._view.clipboard.focus();
24511
+ // explore programmatic pasting further
24512
+ document.execCommand('paste');
24513
+ } else {
24514
+ return { reason: "error", type: "useKeyboard" };
24515
+ }
24528
24516
  }
24529
24517
  }
24530
24518
 
@@ -24603,19 +24591,28 @@
24603
24591
  // $(textarea).remove();
24604
24592
  // }
24605
24593
 
24594
+ function detectClipboardAccess() {
24595
+ const commands = {
24596
+ copy: document.queryCommandSupported ? document.queryCommandSupported("copy") : false,
24597
+ cut: document.queryCommandSupported ? document.queryCommandSupported("cut") : false,
24598
+ paste: document.queryCommandSupported ? document.queryCommandSupported("paste") : false
24599
+ };
24600
+
24601
+ return commands;
24602
+ }
24603
+
24606
24604
  class ToolbarCopyCommand extends Command {
24607
24605
  constructor(options) {
24608
24606
  super(options);
24609
24607
  this._clipboard = options.workbook.clipboard();
24610
- this.undo = noop;
24608
+ this.cannotUndo = true;
24611
24609
  }
24612
24610
  exec() {
24613
- // PoC only
24614
- // if (kendo.support.clipboard.copy) {
24615
- // document.execCommand('copy');
24616
- // } else {
24617
- return { reason: "error", type: "useKeyboard" };
24618
- // }
24611
+ if (detectClipboardAccess().copy) {
24612
+ document.execCommand('copy');
24613
+ } else {
24614
+ return { reason: "error", type: "useKeyboard" };
24615
+ }
24619
24616
  }
24620
24617
  }
24621
24618
 
@@ -24665,12 +24662,11 @@
24665
24662
  this.cannotUndo = true;
24666
24663
  }
24667
24664
  exec() {
24668
- // PoC only
24669
- // if (kendo.support.clipboard.copy) {
24670
- // document.execCommand('cut');
24671
- // } else {
24672
- return { reason: "error", type: "useKeyboard" };
24673
- // }
24665
+ if (detectClipboardAccess().copy) {
24666
+ document.execCommand('cut');
24667
+ } else {
24668
+ return { reason: "error", type: "useKeyboard" };
24669
+ }
24674
24670
  }
24675
24671
  }
24676
24672
 
@@ -26741,6 +26737,7 @@
26741
26737
  "paste",
26742
26738
  "changing",
26743
26739
  "change",
26740
+ "contextmenu",
26744
26741
  "excelImport",
26745
26742
  "excelExport",
26746
26743
  "insertSheet",
@@ -27766,6 +27763,7 @@
27766
27763
 
27767
27764
  _keyDown(e) {
27768
27765
  let key = e.keyCode;
27766
+ let controlKey = e.ctrlKey || e.metaKey;
27769
27767
 
27770
27768
  if (key === keys.F11 && e.shiftKey) {
27771
27769
  this._view.sheetsbar._onAddSelect();
@@ -27799,21 +27797,12 @@
27799
27797
  this._view.sheetsbar._createEditor();
27800
27798
  e.preventDefault();
27801
27799
  return;
27802
- } else if (e.ctrlKey && key === keys.B) {
27803
- const bold = this.element.querySelector("[data-tool=bold]");
27804
- if (bold) {
27805
- bold.click();
27806
- }
27807
- } else if (e.ctrlKey && key === keys.I) {
27808
- const italic = this.element.querySelector("[data-tool=italic]");
27809
- if (italic) {
27810
- italic.click();
27811
- }
27812
- } else if (e.ctrlKey && key === keys.U) {
27813
- const underline = this.element.querySelector("[data-tool=underline]");
27814
- if (underline) {
27815
- underline.click();
27816
- }
27800
+ } else if (controlKey && key === keys.B) {
27801
+ this._handleTypographicalEmphasis('bold');
27802
+ } else if (controlKey && key === keys.I) {
27803
+ this._handleTypographicalEmphasis('italic');
27804
+ } else if (controlKey && key === keys.U) {
27805
+ this._handleTypographicalEmphasis('underline');
27817
27806
  } else if (e.altKey && key === keys.H) {
27818
27807
  this._view.tabstrip.select(0);
27819
27808
  e.preventDefault();
@@ -27829,6 +27818,20 @@
27829
27818
  }
27830
27819
  }
27831
27820
 
27821
+ _handleTypographicalEmphasis(command) {
27822
+ const sheet = this.activeSheet();
27823
+
27824
+ if (sheet) {
27825
+ this.executeCommand({
27826
+ command: 'PropertyChangeCommand',
27827
+ options: {
27828
+ property: command,
27829
+ value: !sheet.range(sheet.activeCell())[command]()
27830
+ }
27831
+ });
27832
+ }
27833
+ }
27834
+
27832
27835
  _resize() {
27833
27836
  this.refresh({ layout: true });
27834
27837
  }
@@ -28122,6 +28125,10 @@
28122
28125
  // kendo.ui.progress(this.element, e.toggle);
28123
28126
  }
28124
28127
 
28128
+ _onContextMenu(e) {
28129
+ this.trigger("contextmenu", e);
28130
+ }
28131
+
28125
28132
  _bindWorkbookEvents() {
28126
28133
  this._workbook.bind("cut", this._workbookCut.bind(this));
28127
28134
  this._workbook.bind("copy", this._workbookCopy.bind(this));
@@ -28148,6 +28155,7 @@
28148
28155
  this._workbook.bind("dataBinding", this._workbookDataBinding.bind(this));
28149
28156
  this._workbook.bind("dataBound", this._workbookDataBound.bind(this));
28150
28157
  this._workbook.bind("progress", this._workbookProgress.bind(this));
28158
+ this._workbook.bind("contextmenu", this._onContextMenu.bind(this));
28151
28159
  }
28152
28160
 
28153
28161
  destroy() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@progress/kendo-spreadsheet-common",
3
3
  "description": "Kendo UI platform-independent Spreadsheet library",
4
- "version": "1.0.1",
4
+ "version": "1.1.0-develop.1",
5
5
  "keywords": [
6
6
  "Kendo UI"
7
7
  ],