handsontable 0.0.0-next-f3514b0-20240124 → 0.0.0-next-0146b3f-20240129

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of handsontable might be problematic. Click here for more details.

@@ -14,11 +14,12 @@ class CheckboxEditor extends _baseEditor.BaseEditor {
14
14
  return EDITOR_TYPE;
15
15
  }
16
16
  beginEditing(initialValue, event) {
17
- // Just some events connected with checkbox editor are delegated here. Some `keydown` events like `enter` and `space` key press
18
- // are handled inside `checkboxRenderer`. Some events come here from `editorManager`. Below `if` statement was created by author
19
- // for purpose of handling only `doubleclick` event which may be done on a cell with checkbox.
17
+ // Just some events connected with the checkbox editor are delegated here. Some `keydown` events like `enter` and
18
+ // `space` key presses are handled inside `checkboxRenderer`. Some events come here from `editorManager`. The below
19
+ // `if` statement was created by the author for the purpose of handling only the `doubleclick` event on the TD
20
+ // element with a checkbox.
20
21
 
21
- if (event && event.type === 'mouseup') {
22
+ if (event && event.type === 'mouseup' && event.target.nodeName === 'TD') {
22
23
  const checkbox = this.TD.querySelector('input[type="checkbox"]');
23
24
  if (!(0, _element.hasClass)(checkbox, 'htBadValue')) {
24
25
  checkbox.click();
@@ -11,11 +11,12 @@ export class CheckboxEditor extends BaseEditor {
11
11
  return EDITOR_TYPE;
12
12
  }
13
13
  beginEditing(initialValue, event) {
14
- // Just some events connected with checkbox editor are delegated here. Some `keydown` events like `enter` and `space` key press
15
- // are handled inside `checkboxRenderer`. Some events come here from `editorManager`. Below `if` statement was created by author
16
- // for purpose of handling only `doubleclick` event which may be done on a cell with checkbox.
14
+ // Just some events connected with the checkbox editor are delegated here. Some `keydown` events like `enter` and
15
+ // `space` key presses are handled inside `checkboxRenderer`. Some events come here from `editorManager`. The below
16
+ // `if` statement was created by the author for the purpose of handling only the `doubleclick` event on the TD
17
+ // element with a checkbox.
17
18
 
18
- if (event && event.type === 'mouseup') {
19
+ if (event && event.type === 'mouseup' && event.target.nodeName === 'TD') {
19
20
  const checkbox = this.TD.querySelector('input[type="checkbox"]');
20
21
  if (!hasClass(checkbox, 'htBadValue')) {
21
22
  checkbox.click();
package/helpers/mixed.js CHANGED
@@ -134,7 +134,7 @@ const domMessages = {
134
134
  function _injectProductInfo(key, element) {
135
135
  const hasValidType = !isEmpty(key);
136
136
  const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
137
- const hotVersion = "0.0.0-next-f3514b0-20240124";
137
+ const hotVersion = "0.0.0-next-0146b3f-20240129";
138
138
  let keyValidityDate;
139
139
  let consoleMessageState = 'invalid';
140
140
  let domMessageState = 'invalid';
package/helpers/mixed.mjs CHANGED
@@ -124,7 +124,7 @@ const domMessages = {
124
124
  export function _injectProductInfo(key, element) {
125
125
  const hasValidType = !isEmpty(key);
126
126
  const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
127
- const hotVersion = "0.0.0-next-f3514b0-20240124";
127
+ const hotVersion = "0.0.0-next-0146b3f-20240129";
128
128
  let keyValidityDate;
129
129
  let consoleMessageState = 'invalid';
130
130
  let domMessageState = 'invalid';
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "url": "https://github.com/handsontable/handsontable/issues"
11
11
  },
12
12
  "author": "Handsoncode <hello@handsontable.com>",
13
- "version": "0.0.0-next-f3514b0-20240124",
13
+ "version": "0.0.0-next-0146b3f-20240129",
14
14
  "main": "index",
15
15
  "module": "index.mjs",
16
16
  "jsnext:main": "index.mjs",
@@ -132,12 +132,6 @@ function UndoRedo(instance) {
132
132
  }
133
133
  plugin.done(() => new UndoRedo.RowMoveAction(rows, finalIndex));
134
134
  });
135
- instance.addHook('beforeColumnMove', (columns, finalIndex) => {
136
- if (columns === false) {
137
- return;
138
- }
139
- plugin.done(() => new UndoRedo.ColumnMoveAction(columns, finalIndex));
140
- });
141
135
  instance.addHook('beforeMergeCells', (cellRange, auto) => {
142
136
  if (auto) {
143
137
  return;
@@ -720,15 +714,15 @@ UndoRedo.UnmergeCellsAction = UnmergeCellsAction;
720
714
  */
721
715
  UndoRedo.RowMoveAction = function (rows, finalIndex) {
722
716
  this.rows = rows.slice();
723
- this.finalRowIndex = finalIndex;
717
+ this.finalIndex = finalIndex;
724
718
  this.actionType = 'row_move';
725
719
  };
726
720
  (0, _object.inherit)(UndoRedo.RowMoveAction, UndoRedo.Action);
727
721
  UndoRedo.RowMoveAction.prototype.undo = function (instance, undoneCallback) {
728
722
  const manualRowMove = instance.getPlugin('manualRowMove');
729
723
  const copyOfRows = [].concat(this.rows);
730
- const rowsMovedUp = copyOfRows.filter(a => a > this.finalRowIndex);
731
- const rowsMovedDown = copyOfRows.filter(a => a <= this.finalRowIndex);
724
+ const rowsMovedUp = copyOfRows.filter(a => a > this.finalIndex);
725
+ const rowsMovedDown = copyOfRows.filter(a => a <= this.finalIndex);
732
726
  const allMovedRows = rowsMovedUp.sort((a, b) => b - a).concat(rowsMovedDown.sort((a, b) => a - b));
733
727
  instance.addHookOnce('afterViewRender', undoneCallback);
734
728
 
@@ -745,50 +739,10 @@ UndoRedo.RowMoveAction.prototype.undo = function (instance, undoneCallback) {
745
739
  UndoRedo.RowMoveAction.prototype.redo = function (instance, redoneCallback) {
746
740
  const manualRowMove = instance.getPlugin('manualRowMove');
747
741
  instance.addHookOnce('afterViewRender', redoneCallback);
748
- manualRowMove.moveRows(this.rows.slice(), this.finalRowIndex);
749
- instance.render();
750
- instance.deselectCell();
751
- instance.selectRows(this.finalRowIndex, this.finalRowIndex + this.rows.length - 1);
752
- };
753
-
754
- /**
755
- * ManualColumnMove action.
756
- *
757
- * @private
758
- * @param {number[]} columns An array with moved columns.
759
- * @param {number} finalIndex The destination index.
760
- */
761
- UndoRedo.ColumnMoveAction = function (columns, finalIndex) {
762
- this.columns = columns.slice();
763
- this.finalColumnIndex = finalIndex;
764
- this.actionType = 'col_move';
765
- };
766
- (0, _object.inherit)(UndoRedo.ColumnMoveAction, UndoRedo.Action);
767
- UndoRedo.ColumnMoveAction.prototype.undo = function (instance, undoneCallback) {
768
- const manualColumnMove = instance.getPlugin('manualColumnMove');
769
- const copyOfColumns = [].concat(this.columns);
770
- const columnsMovedLeft = copyOfColumns.filter(a => a > this.finalColumnIndex);
771
- const rowsMovedRight = copyOfColumns.filter(a => a <= this.finalColumnIndex);
772
- const allMovedColumns = columnsMovedLeft.sort((a, b) => b - a).concat(rowsMovedRight.sort((a, b) => a - b));
773
- instance.addHookOnce('afterViewRender', undoneCallback);
774
-
775
- // Moving columns from those with higher indexes to those with lower indexes when action was performed from right to left
776
- // Moving columns from those with lower indexes to those with higher indexes when action was performed from left to right
777
- for (let i = 0; i < allMovedColumns.length; i += 1) {
778
- const newPhysicalColumn = instance.toVisualColumn(allMovedColumns[i]);
779
- manualColumnMove.moveColumn(newPhysicalColumn, allMovedColumns[i]);
780
- }
781
- instance.render();
782
- instance.deselectCell();
783
- instance.selectColumns(this.columns[0], this.columns[0] + this.columns.length - 1);
784
- };
785
- UndoRedo.ColumnMoveAction.prototype.redo = function (instance, redoneCallback) {
786
- const manualColumnMove = instance.getPlugin('manualColumnMove');
787
- instance.addHookOnce('afterViewRender', redoneCallback);
788
- manualColumnMove.moveColumns(this.columns.slice(), this.finalColumnIndex);
742
+ manualRowMove.moveRows(this.rows.slice(), this.finalIndex);
789
743
  instance.render();
790
744
  instance.deselectCell();
791
- instance.selectColumns(this.finalColumnIndex, this.finalColumnIndex + this.columns.length - 1);
745
+ instance.selectRows(this.finalIndex, this.finalIndex + this.rows.length - 1);
792
746
  };
793
747
 
794
748
  /**
@@ -128,12 +128,6 @@ function UndoRedo(instance) {
128
128
  }
129
129
  plugin.done(() => new UndoRedo.RowMoveAction(rows, finalIndex));
130
130
  });
131
- instance.addHook('beforeColumnMove', (columns, finalIndex) => {
132
- if (columns === false) {
133
- return;
134
- }
135
- plugin.done(() => new UndoRedo.ColumnMoveAction(columns, finalIndex));
136
- });
137
131
  instance.addHook('beforeMergeCells', (cellRange, auto) => {
138
132
  if (auto) {
139
133
  return;
@@ -716,15 +710,15 @@ UndoRedo.UnmergeCellsAction = UnmergeCellsAction;
716
710
  */
717
711
  UndoRedo.RowMoveAction = function (rows, finalIndex) {
718
712
  this.rows = rows.slice();
719
- this.finalRowIndex = finalIndex;
713
+ this.finalIndex = finalIndex;
720
714
  this.actionType = 'row_move';
721
715
  };
722
716
  inherit(UndoRedo.RowMoveAction, UndoRedo.Action);
723
717
  UndoRedo.RowMoveAction.prototype.undo = function (instance, undoneCallback) {
724
718
  const manualRowMove = instance.getPlugin('manualRowMove');
725
719
  const copyOfRows = [].concat(this.rows);
726
- const rowsMovedUp = copyOfRows.filter(a => a > this.finalRowIndex);
727
- const rowsMovedDown = copyOfRows.filter(a => a <= this.finalRowIndex);
720
+ const rowsMovedUp = copyOfRows.filter(a => a > this.finalIndex);
721
+ const rowsMovedDown = copyOfRows.filter(a => a <= this.finalIndex);
728
722
  const allMovedRows = rowsMovedUp.sort((a, b) => b - a).concat(rowsMovedDown.sort((a, b) => a - b));
729
723
  instance.addHookOnce('afterViewRender', undoneCallback);
730
724
 
@@ -741,50 +735,10 @@ UndoRedo.RowMoveAction.prototype.undo = function (instance, undoneCallback) {
741
735
  UndoRedo.RowMoveAction.prototype.redo = function (instance, redoneCallback) {
742
736
  const manualRowMove = instance.getPlugin('manualRowMove');
743
737
  instance.addHookOnce('afterViewRender', redoneCallback);
744
- manualRowMove.moveRows(this.rows.slice(), this.finalRowIndex);
745
- instance.render();
746
- instance.deselectCell();
747
- instance.selectRows(this.finalRowIndex, this.finalRowIndex + this.rows.length - 1);
748
- };
749
-
750
- /**
751
- * ManualColumnMove action.
752
- *
753
- * @private
754
- * @param {number[]} columns An array with moved columns.
755
- * @param {number} finalIndex The destination index.
756
- */
757
- UndoRedo.ColumnMoveAction = function (columns, finalIndex) {
758
- this.columns = columns.slice();
759
- this.finalColumnIndex = finalIndex;
760
- this.actionType = 'col_move';
761
- };
762
- inherit(UndoRedo.ColumnMoveAction, UndoRedo.Action);
763
- UndoRedo.ColumnMoveAction.prototype.undo = function (instance, undoneCallback) {
764
- const manualColumnMove = instance.getPlugin('manualColumnMove');
765
- const copyOfColumns = [].concat(this.columns);
766
- const columnsMovedLeft = copyOfColumns.filter(a => a > this.finalColumnIndex);
767
- const rowsMovedRight = copyOfColumns.filter(a => a <= this.finalColumnIndex);
768
- const allMovedColumns = columnsMovedLeft.sort((a, b) => b - a).concat(rowsMovedRight.sort((a, b) => a - b));
769
- instance.addHookOnce('afterViewRender', undoneCallback);
770
-
771
- // Moving columns from those with higher indexes to those with lower indexes when action was performed from right to left
772
- // Moving columns from those with lower indexes to those with higher indexes when action was performed from left to right
773
- for (let i = 0; i < allMovedColumns.length; i += 1) {
774
- const newPhysicalColumn = instance.toVisualColumn(allMovedColumns[i]);
775
- manualColumnMove.moveColumn(newPhysicalColumn, allMovedColumns[i]);
776
- }
777
- instance.render();
778
- instance.deselectCell();
779
- instance.selectColumns(this.columns[0], this.columns[0] + this.columns.length - 1);
780
- };
781
- UndoRedo.ColumnMoveAction.prototype.redo = function (instance, redoneCallback) {
782
- const manualColumnMove = instance.getPlugin('manualColumnMove');
783
- instance.addHookOnce('afterViewRender', redoneCallback);
784
- manualColumnMove.moveColumns(this.columns.slice(), this.finalColumnIndex);
738
+ manualRowMove.moveRows(this.rows.slice(), this.finalIndex);
785
739
  instance.render();
786
740
  instance.deselectCell();
787
- instance.selectColumns(this.finalColumnIndex, this.finalColumnIndex + this.columns.length - 1);
741
+ instance.selectRows(this.finalIndex, this.finalIndex + this.rows.length - 1);
788
742
  };
789
743
 
790
744
  /**
@@ -5,6 +5,7 @@ exports._dataToHTML = _dataToHTML;
5
5
  exports.htmlToGridSettings = htmlToGridSettings;
6
6
  exports.instanceToHTML = instanceToHTML;
7
7
  require("core-js/modules/es.array.push.js");
8
+ require("core-js/modules/es.string.replace-all.js");
8
9
  var _mixed = require("./../helpers/mixed");
9
10
  const ESCAPED_HTML_CHARS = {
10
11
  '&nbsp;': '\x20',
@@ -140,7 +141,14 @@ function htmlToGridSettings(element) {
140
141
  if (typeof checkElement === 'string') {
141
142
  const escapedAdjacentHTML = checkElement.replace(/<td\b[^>]*?>([\s\S]*?)<\/\s*td>/g, cellFragment => {
142
143
  const openingTag = cellFragment.match(/<td\b[^>]*?>/g)[0];
143
- const cellValue = cellFragment.substring(openingTag.length, cellFragment.lastIndexOf('<')).replace(/(<(?!br)([^>]+)>)/gi, '');
144
+ const paragraphRegexp = /<p.*?>/g;
145
+ const cellValue = cellFragment.substring(openingTag.length, cellFragment.lastIndexOf('<')).trim() // Removing whitespaces from the start and the end of HTML fragment
146
+ .replaceAll(/\n\s+/g, ' ') // HTML tags may be split using multiple new lines and whitespaces
147
+ .replaceAll(paragraphRegexp, '\n') // Only paragraphs should split text using new line characters
148
+ .replace('\n', '') // First paragraph shouldn't start with new line characters
149
+ .replaceAll(/<\/(.*)>\s+$/mg, '</$1>') // HTML tags may end with whitespace.
150
+ .replace(/(<(?!br)([^>]+)>)/gi, '') // Removing HTML tags
151
+ .replaceAll(/^&nbsp;$/mg, ''); // Removing single &nbsp; characters separating new lines
144
152
  const closingTag = '</td>';
145
153
  return `${openingTag}${cellValue}${closingTag}`;
146
154
  });
@@ -1,4 +1,5 @@
1
1
  import "core-js/modules/es.array.push.js";
2
+ import "core-js/modules/es.string.replace-all.js";
2
3
  import { isEmpty } from "./../helpers/mixed.mjs";
3
4
  const ESCAPED_HTML_CHARS = {
4
5
  '&nbsp;': '\x20',
@@ -134,7 +135,14 @@ export function htmlToGridSettings(element) {
134
135
  if (typeof checkElement === 'string') {
135
136
  const escapedAdjacentHTML = checkElement.replace(/<td\b[^>]*?>([\s\S]*?)<\/\s*td>/g, cellFragment => {
136
137
  const openingTag = cellFragment.match(/<td\b[^>]*?>/g)[0];
137
- const cellValue = cellFragment.substring(openingTag.length, cellFragment.lastIndexOf('<')).replace(/(<(?!br)([^>]+)>)/gi, '');
138
+ const paragraphRegexp = /<p.*?>/g;
139
+ const cellValue = cellFragment.substring(openingTag.length, cellFragment.lastIndexOf('<')).trim() // Removing whitespaces from the start and the end of HTML fragment
140
+ .replaceAll(/\n\s+/g, ' ') // HTML tags may be split using multiple new lines and whitespaces
141
+ .replaceAll(paragraphRegexp, '\n') // Only paragraphs should split text using new line characters
142
+ .replace('\n', '') // First paragraph shouldn't start with new line characters
143
+ .replaceAll(/<\/(.*)>\s+$/mg, '</$1>') // HTML tags may end with whitespace.
144
+ .replace(/(<(?!br)([^>]+)>)/gi, '') // Removing HTML tags
145
+ .replaceAll(/^&nbsp;$/mg, ''); // Removing single &nbsp; characters separating new lines
138
146
  const closingTag = '</td>';
139
147
  return `${openingTag}${cellValue}${closingTag}`;
140
148
  });