jodit 3.6.2 → 3.6.6

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.
Files changed (48) hide show
  1. package/CHANGELOG.MD +21 -0
  2. package/README.md +1 -3
  3. package/build/jodit.css +6 -6
  4. package/build/jodit.es2018.css +3 -3
  5. package/build/jodit.es2018.en.css +3 -3
  6. package/build/jodit.es2018.en.js +194 -73
  7. package/build/jodit.es2018.en.min.css +1 -1
  8. package/build/jodit.es2018.en.min.js +2 -2
  9. package/build/jodit.es2018.js +194 -73
  10. package/build/jodit.es2018.min.css +1 -1
  11. package/build/jodit.es2018.min.js +2 -2
  12. package/build/jodit.js +443 -308
  13. package/build/jodit.min.css +2 -2
  14. package/build/jodit.min.js +2 -2
  15. package/package.json +2 -2
  16. package/src/config.ts +2 -0
  17. package/src/core/decorators/persistent.ts +1 -1
  18. package/src/core/decorators/watch.ts +6 -0
  19. package/src/core/helpers/checker/is-url.ts +3 -3
  20. package/src/core/plugin-system.ts +1 -0
  21. package/src/core/ui/helpers/get-control-type.ts +2 -1
  22. package/src/core/ui/list/group.ts +3 -2
  23. package/src/core/ui/popup/popup.ts +17 -8
  24. package/src/core/view/view-with-toolbar.ts +1 -1
  25. package/src/core/view/view.ts +9 -4
  26. package/src/jodit.ts +7 -2
  27. package/src/modules/dialog/dialog.ts +2 -1
  28. package/src/modules/file-browser/config.ts +2 -0
  29. package/src/plugins/clipboard/drag-and-drop-element.ts +1 -0
  30. package/src/plugins/index.ts +1 -0
  31. package/src/plugins/inline-popup/config/items/cells.ts +1 -0
  32. package/src/plugins/inline-popup/inline-popup.ts +39 -9
  33. package/src/plugins/justify.ts +3 -0
  34. package/src/plugins/link/link.ts +8 -2
  35. package/src/plugins/resizer/resizer.ts +52 -55
  36. package/src/plugins/select.ts +88 -0
  37. package/src/plugins/table/select-cells.ts +43 -43
  38. package/src/styles/jodit.less +1 -1
  39. package/src/styles/variables.less +1 -1
  40. package/src/types/view.d.ts +2 -0
  41. package/test/bootstrap.js +7 -0
  42. package/test/tests/acceptance/commandsTest.js +1 -2
  43. package/test/tests/acceptance/imageTest.js +1 -1
  44. package/test/tests/acceptance/inlineModeTest.js +21 -16
  45. package/test/tests/acceptance/plugins/inline-popup.js +1 -2
  46. package/test/tests/acceptance/plugins/link.js +145 -17
  47. package/test/tests/acceptance/tableTest.js +184 -197
  48. package/test/tests/acceptance/toolbarTest.js +34 -3
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is awesome and usefully wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/)
4
- * Version: v3.6.2
4
+ * Version: v3.6.6
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -35,6 +35,7 @@ return /******/ (() => { // webpackBootstrap
35
35
 
36
36
  class Config {
37
37
  constructor() {
38
+ this.namespace = '';
38
39
  this.iframe = false;
39
40
  this.license = '';
40
41
  this.preset = 'custom';
@@ -3662,9 +3663,9 @@ function isURL(str) {
3662
3663
  const pattern = new RegExp('^(https?:\\/\\/)' +
3663
3664
  '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|' +
3664
3665
  '((\\d{1,3}\\.){3}\\d{1,3}))' +
3665
- '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' +
3666
- '(\\?[;&a-z\\d%_.~+=-]*)?' +
3667
- '(\\#[-a-z\\d_]*)?$', 'i');
3666
+ '(\\:\\d+)?(\\/[-a-zа-яё\\d%_.~+]*)*' +
3667
+ '(\\?[;&a-zа-яё\\d%_.~+=-]*)?' +
3668
+ '(\\#[-a-zа-яё\\d_]*)?$', 'i');
3668
3669
  return pattern.test(str);
3669
3670
  }
3670
3671
 
@@ -5270,7 +5271,8 @@ UIList = (0,tslib_es6.__decorate)([
5270
5271
 
5271
5272
  function getControlType(button, controls) {
5272
5273
  let buttonControl;
5273
- controls || (controls = _config__WEBPACK_IMPORTED_MODULE_1__/* .Config.defaultOptions.controls */ .D.defaultOptions.controls);
5274
+ if (!controls)
5275
+ controls = _config__WEBPACK_IMPORTED_MODULE_1__/* .Config.defaultOptions.controls */ .D.defaultOptions.controls;
5274
5276
  if (!(0,_helpers__WEBPACK_IMPORTED_MODULE_0__.isString)(button)) {
5275
5277
  buttonControl = { name: 'empty', ...(0,_helpers__WEBPACK_IMPORTED_MODULE_0__.ConfigFlatten)(button) };
5276
5278
  if (controls[buttonControl.name] !== undefined) {
@@ -5461,7 +5463,7 @@ function persistent(target, propertyKey) {
5461
5463
  target.hookStatus(core_component/* STATUSES.ready */.n$.ready, (component) => {
5462
5464
  const jodit = (0,helpers.isViewObject)(component)
5463
5465
  ? component
5464
- : component.jodit, storageKey = `${component.componentName}_prop_${propertyKey}`, initialValue = component[propertyKey];
5466
+ : component.jodit, storageKey = `${jodit.options.namespace}${component.componentName}_prop_${propertyKey}`, initialValue = component[propertyKey];
5465
5467
  Object.defineProperty(component, propertyKey, {
5466
5468
  get() {
5467
5469
  var _a;
@@ -5551,6 +5553,11 @@ function watch(observeFields, context) {
5551
5553
  view.events
5552
5554
  .on(context || component, eventName, callback)
5553
5555
  .on(eventName, callback);
5556
+ view.hookStatus('beforeDestruct', () => {
5557
+ view.events
5558
+ .off(context || component, eventName, callback)
5559
+ .off(eventName, callback);
5560
+ });
5554
5561
  return;
5555
5562
  }
5556
5563
  const parts = field.split('.'), [key] = parts;
@@ -5746,12 +5753,12 @@ let UIGroup = UIGroup_1 = class UIGroup extends _element__WEBPACK_IMPORTED_MODUL
5746
5753
  ...this.elements
5747
5754
  ];
5748
5755
  while (stack.length) {
5749
- const elm = stack.pop();
5756
+ const elm = stack.shift();
5750
5757
  if ((0,_helpers__WEBPACK_IMPORTED_MODULE_2__.isArray)(elm)) {
5751
5758
  stack.push(...elm);
5752
5759
  }
5753
5760
  else if (elm instanceof UIGroup_1) {
5754
- stack.push(...elm.elements.reverse());
5761
+ stack.push(...elm.elements);
5755
5762
  }
5756
5763
  else {
5757
5764
  elm && result.push(elm);
@@ -6254,8 +6261,9 @@ var decorators = __webpack_require__(33);
6254
6261
 
6255
6262
 
6256
6263
  class Popup extends ui_element/* UIElement */.u {
6257
- constructor(jodit) {
6264
+ constructor(jodit, smart = true) {
6258
6265
  super(jodit);
6266
+ this.smart = smart;
6259
6267
  this.isOpened = false;
6260
6268
  this.strategy = 'leftBottom';
6261
6269
  this.viewBound = () => ({
@@ -6429,26 +6437,32 @@ class Popup extends ui_element/* UIElement */.u {
6429
6437
  addGlobalListeners() {
6430
6438
  const up = this.updatePosition, ow = this.ow;
6431
6439
  global/* eventEmitter.on */.TB.on('closeAllPopups', this.close);
6440
+ if (this.smart) {
6441
+ this.j.e
6442
+ .on('escape', this.close)
6443
+ .on('mousedown touchstart', this.closeOnOutsideClick)
6444
+ .on(ow, 'mousedown touchstart', this.closeOnOutsideClick);
6445
+ }
6432
6446
  this.j.e
6433
6447
  .on('closeAllPopups', this.close)
6434
- .on('escape', this.close)
6435
6448
  .on('resize', up)
6436
6449
  .on(this.container, 'scroll mousewheel', up)
6437
- .on('mousedown touchstart', this.closeOnOutsideClick)
6438
- .on(ow, 'mousedown touchstart', this.closeOnOutsideClick)
6439
6450
  .on(ow, 'scroll', up)
6440
6451
  .on(ow, 'resize', up);
6441
6452
  }
6442
6453
  removeGlobalListeners() {
6443
6454
  const up = this.updatePosition, ow = this.ow;
6444
6455
  global/* eventEmitter.off */.TB.off('closeAllPopups', this.close);
6456
+ if (this.smart) {
6457
+ this.j.e
6458
+ .off('escape', this.close)
6459
+ .off('mousedown touchstart', this.closeOnOutsideClick)
6460
+ .off(ow, 'mousedown touchstart', this.closeOnOutsideClick);
6461
+ }
6445
6462
  this.j.e
6446
6463
  .off('closeAllPopups', this.close)
6447
- .off('escape', this.close)
6448
6464
  .off('resize', up)
6449
6465
  .off(this.container, 'scroll mousewheel', up)
6450
- .off('mousedown touchstart', this.closeOnOutsideClick)
6451
- .off(ow, 'mousedown touchstart', this.closeOnOutsideClick)
6452
6466
  .off(ow, 'scroll', up)
6453
6467
  .off(ow, 'resize', up);
6454
6468
  }
@@ -12496,6 +12510,7 @@ __webpack_require__.d(plugins_namespaceObject, {
12496
12510
  "resizeHandler": () => (resizeHandler),
12497
12511
  "resizer": () => (resizer),
12498
12512
  "search": () => (search),
12513
+ "select": () => (select_select),
12499
12514
  "selectCells": () => (selectCells),
12500
12515
  "size": () => (size),
12501
12516
  "source": () => (source),
@@ -13182,7 +13197,7 @@ class View extends component/* Component */.wA {
13182
13197
  this.isView = true;
13183
13198
  this.mods = {};
13184
13199
  this.components = new Set();
13185
- this.version = "3.6.2";
13200
+ this.version = "3.6.6";
13186
13201
  this.async = new Async();
13187
13202
  this.buffer = Storage.makeStorage();
13188
13203
  this.storage = Storage.makeStorage(true, this.componentName);
@@ -13280,7 +13295,10 @@ class View extends component/* Component */.wA {
13280
13295
  return this.__isFullSize;
13281
13296
  }
13282
13297
  getVersion() {
13283
- return this.version;
13298
+ return "3.6.6";
13299
+ }
13300
+ static getVersion() {
13301
+ return "3.6.6";
13284
13302
  }
13285
13303
  initOptions(options) {
13286
13304
  this.options = (0,helpers.ConfigProto)(options || {}, (0,helpers.ConfigProto)(this.options || {}, View.defaultOptions));
@@ -13339,6 +13357,7 @@ class View extends component/* Component */.wA {
13339
13357
  View.defaultOptions = {
13340
13358
  extraButtons: [],
13341
13359
  textIcons: false,
13360
+ namespace: '',
13342
13361
  removeButtons: [],
13343
13362
  zIndex: 100002,
13344
13363
  defaultTimeout: 100,
@@ -14023,6 +14042,7 @@ class ViewWithToolbar extends View {
14023
14042
 
14024
14043
 
14025
14044
  config/* Config.prototype.dialog */.D.prototype.dialog = {
14045
+ namespace: '',
14026
14046
  extraButtons: [],
14027
14047
  resizable: true,
14028
14048
  draggable: true,
@@ -14747,6 +14767,7 @@ const ICON_LOADER = '<i class="jodit-icon_loader"></i>';
14747
14767
 
14748
14768
 
14749
14769
  config/* Config.prototype.filebrowser */.D.prototype.filebrowser = {
14770
+ namespace: '',
14750
14771
  extraButtons: [],
14751
14772
  filter(item, search) {
14752
14773
  search = search.toLowerCase();
@@ -20217,6 +20238,7 @@ class Jodit extends ViewWithToolbar {
20217
20238
  super.destruct();
20218
20239
  }
20219
20240
  }
20241
+ Jodit.fatMode = false;
20220
20242
  Jodit.plugins = global/* pluginSystem */.pw;
20221
20243
  Jodit.modules = global/* modules */.qz;
20222
20244
  Jodit.ns = global/* modules */.qz;
@@ -22795,6 +22817,7 @@ class DragAndDropElement extends Plugin {
22795
22817
  pointerEvents: 'none',
22796
22818
  pointer: 'drag',
22797
22819
  position: 'fixed',
22820
+ opacity: 0.7,
22798
22821
  display: 'inline-block',
22799
22822
  left: event.clientX,
22800
22823
  top: event.clientY,
@@ -24702,17 +24725,20 @@ config/* Config.prototype.popup */.D.prototype.popup = {
24702
24725
  class inlinePopup extends Plugin {
24703
24726
  constructor() {
24704
24727
  super(...arguments);
24728
+ this.requires = ['select'];
24705
24729
  this.type = null;
24706
- this.popup = new ui_popup/* Popup */.G(this.jodit);
24730
+ this.popup = new ui_popup/* Popup */.G(this.jodit, false);
24707
24731
  this.toolbar = makeCollection(this.jodit, this.popup);
24708
24732
  this.snapRange = null;
24733
+ this.elmsList = (0,helpers.keys)(this.j.o.popup, false).filter(s => !this.isExcludedTarget(s));
24709
24734
  }
24710
- onClick(e) {
24711
- const node = e.target, elements = (0,helpers.keys)(this.j.o.popup, false), target = dom/* Dom.isTag */.i.isTag(node, 'img')
24735
+ onClick(node) {
24736
+ const elements = this.elmsList, target = dom/* Dom.isTag */.i.isTag(node, 'img')
24712
24737
  ? node
24713
24738
  : dom/* Dom.closest */.i.closest(node, elements, this.j.editor);
24714
24739
  if (target && this.canShowPopupForType(target.nodeName.toLowerCase())) {
24715
24740
  this.showPopup(() => (0,helpers.position)(target, this.j), target.nodeName.toLowerCase(), target);
24741
+ return false;
24716
24742
  }
24717
24743
  }
24718
24744
  showPopup(rect, type, target) {
@@ -24742,10 +24768,13 @@ class inlinePopup extends Plugin {
24742
24768
  return true;
24743
24769
  }
24744
24770
  hidePopup(type) {
24745
- if (!type || type === this.type) {
24771
+ if (!(0,helpers.isString)(type) || type === this.type) {
24746
24772
  this.popup.close();
24747
24773
  }
24748
24774
  }
24775
+ onOutsideClick(e) {
24776
+ this.popup.close();
24777
+ }
24749
24778
  canShowPopupForType(type) {
24750
24779
  const data = this.j.o.popup[type.toLowerCase()];
24751
24780
  if (this.j.o.readonly || !this.j.o.toolbarInline || !data) {
@@ -24778,9 +24807,9 @@ class inlinePopup extends Plugin {
24778
24807
  .on('showPopup', (elm, rect, type) => {
24779
24808
  this.showPopup(rect, type || ((0,helpers.isString)(elm) ? elm : elm.nodeName), (0,helpers.isString)(elm) ? undefined : elm);
24780
24809
  })
24781
- .on('click', this.onClick)
24782
24810
  .on('mousedown keydown', this.onSelectionStart)
24783
24811
  .on([this.j.ew, this.j.ow], 'mouseup keyup', this.onSelectionEnd);
24812
+ this.addListenersForElements();
24784
24813
  }
24785
24814
  onSelectionStart() {
24786
24815
  this.snapRange = this.j.s.range.cloneRange();
@@ -24833,8 +24862,14 @@ class inlinePopup extends Plugin {
24833
24862
  beforeDestruct(jodit) {
24834
24863
  jodit.e
24835
24864
  .off('showPopup')
24836
- .off('click', this.onClick)
24837
24865
  .off([this.j.ew, this.j.ow], 'mouseup keyup', this.onSelectionEnd);
24866
+ this.removeListenersForElements();
24867
+ }
24868
+ addListenersForElements() {
24869
+ this.j.e.on(this.elmsList.map(e => (0,helpers.camelCase)(`click_${e}`)).join(' '), this.onClick);
24870
+ }
24871
+ removeListenersForElements() {
24872
+ this.j.e.off(this.elmsList.map(e => (0,helpers.camelCase)(`click_${e}`)).join(' '), this.onClick);
24838
24873
  }
24839
24874
  }
24840
24875
  (0,tslib_es6.__decorate)([
@@ -24844,8 +24879,12 @@ class inlinePopup extends Plugin {
24844
24879
  (0,decorators.wait)((ctx) => !ctx.j.isLocked)
24845
24880
  ], inlinePopup.prototype, "showPopup", null);
24846
24881
  (0,tslib_es6.__decorate)([
24882
+ (0,decorators.watch)(':clickEditor'),
24847
24883
  decorators.autobind
24848
24884
  ], inlinePopup.prototype, "hidePopup", null);
24885
+ (0,tslib_es6.__decorate)([
24886
+ (0,decorators.watch)(':outsideClick')
24887
+ ], inlinePopup.prototype, "onOutsideClick", null);
24849
24888
  (0,tslib_es6.__decorate)([
24850
24889
  decorators.autobind
24851
24890
  ], inlinePopup.prototype, "onSelectionStart", null);
@@ -25372,7 +25411,13 @@ class link_link extends Plugin {
25372
25411
  const textWasChanged = getSelectionText() !== content_input.value.trim();
25373
25412
  if (!link) {
25374
25413
  if (!jodit.s.isCollapsed()) {
25375
- links = jodit.s.wrapInTag('a');
25414
+ const node = jodit.s.current();
25415
+ if (dom/* Dom.isTag */.i.isTag(node, ['img'])) {
25416
+ links = [dom/* Dom.wrap */.i.wrap(node, 'a', jodit)];
25417
+ }
25418
+ else {
25419
+ links = jodit.s.wrapInTag('a');
25420
+ }
25376
25421
  }
25377
25422
  else {
25378
25423
  const a = jodit.createInside.element('a');
@@ -26077,9 +26122,7 @@ class redoUndo extends Plugin {
26077
26122
 
26078
26123
 
26079
26124
 
26080
- config/* Config.prototype.useIframeResizer */.D.prototype.useIframeResizer = true;
26081
- config/* Config.prototype.useTableResizer */.D.prototype.useTableResizer = true;
26082
- config/* Config.prototype.useImageResizer */.D.prototype.useImageResizer = true;
26125
+ config/* Config.prototype.allowResizeTags */.D.prototype.allowResizeTags = ['img', 'iframe', 'table', 'jodit'];
26083
26126
  config/* Config.prototype.resizer */.D.prototype.resizer = {
26084
26127
  showSize: true,
26085
26128
  hideSizeTimeout: 1000,
@@ -26169,7 +26212,10 @@ class resizer extends Plugin {
26169
26212
  }
26170
26213
  }
26171
26214
  };
26172
- this.onClickElement = (element) => {
26215
+ this.onClickElement = (element, e) => {
26216
+ if (this.isResized) {
26217
+ return;
26218
+ }
26173
26219
  if (this.element !== element || !this.isShown) {
26174
26220
  this.element = element;
26175
26221
  this.show();
@@ -26228,10 +26274,22 @@ class resizer extends Plugin {
26228
26274
  }
26229
26275
  })
26230
26276
  .on('hideResizer', this.hide)
26231
- .on('change afterInit afterSetMode', editor.async.debounce(this.onChangeEditor.bind(this), editor.defaultTimeout));
26277
+ .on('change afterInit afterSetMode', this.onChangeEditor);
26232
26278
  this.addEventListeners();
26233
26279
  this.onChangeEditor();
26234
26280
  }
26281
+ onEditorClick(e) {
26282
+ let node = e.target;
26283
+ const { editor, options: { allowResizeTags } } = this.j;
26284
+ while (node && node !== editor) {
26285
+ if (dom/* Dom.isTag */.i.isTag(node, allowResizeTags)) {
26286
+ this.bind(node);
26287
+ this.onClickElement(node, e);
26288
+ return;
26289
+ }
26290
+ node = node.parentNode;
26291
+ }
26292
+ }
26235
26293
  addEventListeners() {
26236
26294
  const editor = this.j;
26237
26295
  editor.e
@@ -26285,7 +26343,6 @@ class resizer extends Plugin {
26285
26343
  }
26286
26344
  }
26287
26345
  onChangeEditor() {
26288
- const editor = this.j;
26289
26346
  if (this.isShown) {
26290
26347
  if (!this.element || !this.element.parentNode) {
26291
26348
  this.hide();
@@ -26294,25 +26351,13 @@ class resizer extends Plugin {
26294
26351
  this.updateSize();
26295
26352
  }
26296
26353
  }
26297
- if (!editor.isDestructed) {
26298
- (0,helpers.$$)('img, table, iframe', editor.editor).forEach((elm) => {
26299
- if (editor.getMode() === constants.MODE_SOURCE) {
26300
- return;
26301
- }
26302
- if (!elm[keyBInd] &&
26303
- ((dom/* Dom.isTag */.i.isTag(elm, 'iframe') &&
26304
- editor.o.useIframeResizer) ||
26305
- (dom/* Dom.isTag */.i.isTag(elm, 'img') &&
26306
- editor.o.useImageResizer) ||
26307
- (dom/* Dom.isTag */.i.isTag(elm, 'table') &&
26308
- editor.o.useTableResizer))) {
26309
- elm[keyBInd] = true;
26310
- this.bind(elm);
26311
- }
26312
- });
26313
- }
26354
+ (0,helpers.$$)('iframe', this.j.editor).forEach(this.bind);
26314
26355
  }
26315
26356
  bind(element) {
26357
+ if (element[keyBInd]) {
26358
+ return;
26359
+ }
26360
+ element[keyBInd] = true;
26316
26361
  let wrapper;
26317
26362
  if (dom/* Dom.isTag */.i.isTag(element, 'iframe')) {
26318
26363
  const iframe = element;
@@ -26356,8 +26401,7 @@ class resizer extends Plugin {
26356
26401
  if (constants.IS_IE && dom/* Dom.isTag */.i.isTag(element, 'img')) {
26357
26402
  event.preventDefault();
26358
26403
  }
26359
- })
26360
- .on(element, 'click', () => this.onClickElement(element));
26404
+ });
26361
26405
  }
26362
26406
  showSizeViewer(w, h) {
26363
26407
  if (!this.j.o.resizer.showSize) {
@@ -26390,10 +26434,12 @@ class resizer extends Plugin {
26390
26434
  this.updateSize();
26391
26435
  }
26392
26436
  hide() {
26393
- this.isResized = false;
26394
- this.isShown = false;
26395
- this.element = null;
26396
- dom/* Dom.safeRemove */.i.safeRemove(this.rect);
26437
+ if (!this.isResized) {
26438
+ this.isResized = false;
26439
+ this.isShown = false;
26440
+ this.element = null;
26441
+ dom/* Dom.safeRemove */.i.safeRemove(this.rect);
26442
+ }
26397
26443
  }
26398
26444
  beforeDestruct(jodit) {
26399
26445
  this.hide();
@@ -26401,6 +26447,15 @@ class resizer extends Plugin {
26401
26447
  jodit.e.off(this.j.ow, '.resizer').off('.resizer');
26402
26448
  }
26403
26449
  }
26450
+ (0,tslib_es6.__decorate)([
26451
+ (0,decorators.watch)(':click')
26452
+ ], resizer.prototype, "onEditorClick", null);
26453
+ (0,tslib_es6.__decorate)([
26454
+ (0,decorators.debounce)()
26455
+ ], resizer.prototype, "onChangeEditor", null);
26456
+ (0,tslib_es6.__decorate)([
26457
+ decorators.autobind
26458
+ ], resizer.prototype, "bind", null);
26404
26459
  (0,tslib_es6.__decorate)([
26405
26460
  decorators.autobind
26406
26461
  ], resizer.prototype, "hide", null);
@@ -26874,6 +26929,62 @@ class search extends Plugin {
26874
26929
  decorators.autobind
26875
26930
  ], search.prototype, "calcSticky", null);
26876
26931
 
26932
+ ;// CONCATENATED MODULE: ./src/plugins/select.ts
26933
+ /*!
26934
+ * Jodit Editor (https://xdsoft.net/jodit/)
26935
+ * Released under MIT see LICENSE.txt in the project root for license information.
26936
+ * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
26937
+ */
26938
+
26939
+
26940
+
26941
+
26942
+
26943
+
26944
+ class select_select extends Plugin {
26945
+ constructor() {
26946
+ super(...arguments);
26947
+ this.proxyEventsList = ['click', 'mousedown', 'touchstart', 'mouseup', 'touchend'];
26948
+ }
26949
+ afterInit(jodit) {
26950
+ this.proxyEventsList.forEach((eventName) => {
26951
+ jodit.e.on(eventName + '.inline-popup', this.onStartSelection);
26952
+ });
26953
+ }
26954
+ beforeDestruct(jodit) {
26955
+ this.proxyEventsList.forEach((eventName) => {
26956
+ jodit.e.on(eventName + '.inline-popup', this.onStartSelection);
26957
+ });
26958
+ }
26959
+ onStartSelection(e) {
26960
+ const { j } = this;
26961
+ let result, target = e.target;
26962
+ while (result === undefined && target && target !== j.editor) {
26963
+ result = j.e.fire((0,helpers.camelCase)(e.type + '_' + target.nodeName.toLowerCase()), target, e);
26964
+ target = target.parentElement;
26965
+ }
26966
+ if (e.type === 'click' && result === undefined && target === j.editor) {
26967
+ j.e.fire(e.type + 'Editor', target, e);
26968
+ }
26969
+ }
26970
+ onOutsideClick(e) {
26971
+ const node = e.target;
26972
+ if (dom/* Dom.up */.i.up(node, (elm) => elm === this.j.editor)) {
26973
+ return;
26974
+ }
26975
+ const box = ui/* UIElement.closestElement */.u1.closestElement(node, ui/* Popup */.GI);
26976
+ if (!box) {
26977
+ this.j.e.fire('outsideClick', e);
26978
+ }
26979
+ }
26980
+ }
26981
+ (0,tslib_es6.__decorate)([
26982
+ decorators.autobind
26983
+ ], select_select.prototype, "onStartSelection", null);
26984
+ (0,tslib_es6.__decorate)([
26985
+ (0,decorators.watch)('ow:click')
26986
+ ], select_select.prototype, "onOutsideClick", null);
26987
+
26877
26988
  ;// CONCATENATED MODULE: ./src/plugins/size/config.ts
26878
26989
 
26879
26990
  config/* Config.prototype.width */.D.prototype.width = 'auto';
@@ -28727,6 +28838,7 @@ const select_cells_key = 'table_processor_observer';
28727
28838
  class selectCells extends Plugin {
28728
28839
  constructor() {
28729
28840
  super(...arguments);
28841
+ this.requires = ['select'];
28730
28842
  this.selectedCell = null;
28731
28843
  }
28732
28844
  get module() {
@@ -28737,7 +28849,6 @@ class selectCells extends Plugin {
28737
28849
  return;
28738
28850
  }
28739
28851
  jodit.e
28740
- .on(this.j.ow, 'click.select-cells', this.onRemoveSelection)
28741
28852
  .on('keydown.select-cells', (event) => {
28742
28853
  if (event.key === constants.KEY_TAB) {
28743
28854
  this.unselectCells();
@@ -28745,28 +28856,31 @@ class selectCells extends Plugin {
28745
28856
  })
28746
28857
  .on('beforeCommand.select-cells', this.onExecCommand)
28747
28858
  .on('afterCommand.select-cells', this.onAfterCommand)
28748
- .on('change afterCommand afterSetMode click afterInit'
28749
- .split(' ')
28859
+ .on([
28860
+ 'clickEditor',
28861
+ 'mousedownTd',
28862
+ 'mousedownTh',
28863
+ 'touchstartTd',
28864
+ 'touchstartTh'
28865
+ ]
28750
28866
  .map(e => e + '.select-cells')
28751
- .join(' '), () => {
28752
- (0,helpers.$$)('table', jodit.editor).forEach(this.observe);
28867
+ .join(' '), this.onStartSelection)
28868
+ .on('clickTr', () => {
28869
+ if (this.module.getAllSelectedCells().length) {
28870
+ return false;
28871
+ }
28753
28872
  });
28754
28873
  }
28755
- observe(table) {
28756
- if ((0,helpers.dataBind)(table, select_cells_key)) {
28757
- return;
28758
- }
28759
- this.onRemoveSelection();
28760
- (0,helpers.dataBind)(table, select_cells_key, true);
28761
- this.j.e.on(table, 'mousedown.select-cells touchstart.select-cells', this.onStartSelection.bind(this, table));
28762
- }
28763
- onStartSelection(table, e) {
28874
+ onStartSelection(cell) {
28764
28875
  if (this.j.o.readonly) {
28765
28876
  return;
28766
28877
  }
28767
28878
  this.unselectCells();
28768
- const cell = dom/* Dom.closest */.i.closest(e.target, ['td', 'th'], table);
28769
- if (!cell) {
28879
+ if (cell === this.j.editor) {
28880
+ return;
28881
+ }
28882
+ const table = dom/* Dom.closest */.i.closest(cell, 'table', this.j.editor);
28883
+ if (!cell || !table) {
28770
28884
  return;
28771
28885
  }
28772
28886
  if (!cell.firstChild) {
@@ -28777,7 +28891,10 @@ class selectCells extends Plugin {
28777
28891
  this.j.e
28778
28892
  .on(table, 'mousemove.select-cells touchmove.select-cells', this.onMove.bind(this, table))
28779
28893
  .on(table, 'mouseup.select-cells touchend.select-cells', this.onStopSelection.bind(this, table));
28780
- this.j.e.fire('showPopup', table, () => (0,helpers.position)(cell, this.j), 'cells');
28894
+ return false;
28895
+ }
28896
+ onOutsideClick(e) {
28897
+ this.unselectCells();
28781
28898
  }
28782
28899
  onMove(table, e) {
28783
28900
  if (this.j.o.readonly) {
@@ -28875,7 +28992,7 @@ class selectCells extends Plugin {
28875
28992
  command = command.replace('table', '');
28876
28993
  const cells = this.module.getAllSelectedCells();
28877
28994
  if (cells.length) {
28878
- const cell = cells.shift();
28995
+ const [cell] = cells;
28879
28996
  if (!cell) {
28880
28997
  return;
28881
28998
  }
@@ -28894,7 +29011,7 @@ class selectCells extends Plugin {
28894
29011
  Table.mergeSelected(table, this.j);
28895
29012
  break;
28896
29013
  case 'empty':
28897
- cells.forEach(td => (td.innerHTML = ''));
29014
+ cells.forEach(td => dom/* Dom.detach */.i.detach(td));
28898
29015
  break;
28899
29016
  case 'bin':
28900
29017
  dom/* Dom.safeRemove */.i.safeRemove(table);
@@ -28932,7 +29049,10 @@ class selectCells extends Plugin {
28932
29049
  }
28933
29050
  (0,tslib_es6.__decorate)([
28934
29051
  decorators.autobind
28935
- ], selectCells.prototype, "observe", null);
29052
+ ], selectCells.prototype, "onStartSelection", null);
29053
+ (0,tslib_es6.__decorate)([
29054
+ (0,decorators.watch)(':outsideClick')
29055
+ ], selectCells.prototype, "onOutsideClick", null);
28936
29056
  (0,tslib_es6.__decorate)([
28937
29057
  decorators.autobind
28938
29058
  ], selectCells.prototype, "onRemoveSelection", null);
@@ -29482,6 +29602,7 @@ class xpath extends Plugin {
29482
29602
 
29483
29603
 
29484
29604
 
29605
+
29485
29606
 
29486
29607
 
29487
29608
  // EXTERNAL MODULE: ./src/styles/icons/about.svg