jodit 4.0.0-beta.84 → 4.0.0-beta.85

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 (166) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +4 -4
  3. package/es2015/jodit.css +320 -41
  4. package/es2015/jodit.fat.min.css +1 -1
  5. package/es2015/jodit.fat.min.js +2 -2
  6. package/es2015/jodit.js +2470 -2258
  7. package/es2015/jodit.min.css +1 -1
  8. package/es2015/jodit.min.js +2 -2
  9. package/es2015/plugins/debug/debug.js +4 -4
  10. package/es2015/plugins/debug/debug.min.js +1 -1
  11. package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
  12. package/es2015/plugins/speech-recognize/speech-recognize.js +37 -36
  13. package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
  14. package/es2018/jodit.css +320 -41
  15. package/es2018/jodit.fat.min.css +1 -1
  16. package/es2018/jodit.fat.min.js +2 -2
  17. package/es2018/jodit.js +2469 -2255
  18. package/es2018/jodit.min.css +1 -1
  19. package/es2018/jodit.min.js +2 -2
  20. package/es2018/plugins/debug/debug.js +4 -4
  21. package/es2018/plugins/debug/debug.min.js +1 -1
  22. package/es2018/plugins/speech-recognize/speech-recognize.css +1 -1
  23. package/es2018/plugins/speech-recognize/speech-recognize.js +37 -36
  24. package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
  25. package/es2021/jodit.css +320 -41
  26. package/es2021/jodit.fat.min.css +1 -1
  27. package/es2021/jodit.fat.min.js +2 -2
  28. package/es2021/jodit.js +2459 -2253
  29. package/es2021/jodit.min.css +1 -1
  30. package/es2021/jodit.min.js +2 -2
  31. package/es2021/plugins/debug/debug.js +4 -4
  32. package/es2021/plugins/debug/debug.min.js +1 -1
  33. package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
  34. package/es2021/plugins/speech-recognize/speech-recognize.js +37 -36
  35. package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
  36. package/es2021.en/jodit.css +320 -41
  37. package/es2021.en/jodit.fat.min.css +1 -1
  38. package/es2021.en/jodit.fat.min.js +2 -2
  39. package/es2021.en/jodit.js +2459 -2253
  40. package/es2021.en/jodit.min.css +1 -1
  41. package/es2021.en/jodit.min.js +2 -2
  42. package/es2021.en/plugins/debug/debug.js +4 -4
  43. package/es2021.en/plugins/debug/debug.min.js +1 -1
  44. package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
  45. package/es2021.en/plugins/speech-recognize/speech-recognize.js +37 -36
  46. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
  47. package/es5/jodit.css +400 -103
  48. package/es5/jodit.fat.min.css +1 -1
  49. package/es5/jodit.fat.min.js +2 -2
  50. package/es5/jodit.js +2530 -2312
  51. package/es5/jodit.min.css +3 -3
  52. package/es5/jodit.min.js +2 -2
  53. package/es5/plugins/debug/debug.js +4 -4
  54. package/es5/plugins/debug/debug.min.js +1 -1
  55. package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
  56. package/es5/plugins/speech-recognize/speech-recognize.js +38 -36
  57. package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
  58. package/esm/core/component/component.d.ts +2 -2
  59. package/esm/core/constants.js +2 -2
  60. package/esm/core/dom/dom.js +2 -2
  61. package/esm/core/helpers/checker/is-marker.d.ts +3 -0
  62. package/esm/core/helpers/normalize/normalize-size.d.ts +1 -1
  63. package/esm/core/helpers/normalize/normalize-size.js +2 -2
  64. package/esm/core/helpers/string/trim.d.ts +1 -0
  65. package/esm/core/helpers/string/trim.js +5 -0
  66. package/esm/core/helpers/utils/attr.d.ts +3 -0
  67. package/esm/core/helpers/utils/css.js +1 -0
  68. package/esm/core/plugin/interface.d.ts +3 -0
  69. package/esm/core/selection/style/api/has-same-style.d.ts +1 -1
  70. package/esm/core/selection/style/api/has-same-style.js +7 -4
  71. package/esm/core/selection/style/api/is-suit-element.d.ts +7 -2
  72. package/esm/core/selection/style/api/is-suit-element.js +21 -10
  73. package/esm/core/selection/style/transactions.d.ts +3 -0
  74. package/esm/core/selection/style/transactions.js +3 -3
  75. package/esm/core/storage/engines/local-storage-provider.d.ts +1 -1
  76. package/esm/core/storage/engines/memory-storage-provider.d.ts +1 -1
  77. package/esm/core/ui/button/tooltip/tooltip.d.ts +2 -2
  78. package/esm/core/ui/button/tooltip/tooltip.js +2 -2
  79. package/esm/core/ui/element.d.ts +1 -1
  80. package/esm/core/ui/form/block/block.d.ts +1 -1
  81. package/esm/core/ui/form/block/block.js +1 -1
  82. package/esm/core/ui/group/group.d.ts +0 -1
  83. package/esm/core/ui/group/group.js +0 -2
  84. package/esm/core/ui/group/list.d.ts +1 -0
  85. package/esm/core/ui/group/list.js +14 -2
  86. package/esm/core/ui/helpers/get-control-type.js +9 -2
  87. package/esm/core/ui/popup/popup.d.ts +12 -12
  88. package/esm/core/ui/popup/popup.js +46 -40
  89. package/esm/modules/file-browser/config.js +1 -1
  90. package/esm/modules/image-editor/config.d.ts +3 -0
  91. package/esm/modules/toolbar/button/button.d.ts +5 -5
  92. package/esm/modules/toolbar/button/button.js +25 -24
  93. package/esm/modules/toolbar/button/content.js +1 -1
  94. package/esm/modules/toolbar/button/index.d.ts +1 -0
  95. package/esm/modules/toolbar/button/index.js +1 -0
  96. package/esm/modules/toolbar/button/select/select.d.ts +15 -0
  97. package/esm/modules/toolbar/button/select/select.js +47 -0
  98. package/esm/modules/toolbar/collection/collection.d.ts +1 -0
  99. package/esm/modules/toolbar/collection/collection.js +4 -1
  100. package/esm/modules/toolbar/factory.d.ts +1 -0
  101. package/esm/modules/toolbar/factory.js +4 -0
  102. package/esm/plugins/bold/bold.js +1 -6
  103. package/esm/plugins/bold/interface.d.ts +3 -0
  104. package/esm/plugins/class-span/class-span.js +7 -7
  105. package/esm/plugins/color/config.js +2 -2
  106. package/esm/plugins/delete/interface.d.ts +3 -0
  107. package/esm/plugins/enter/interface.d.ts +3 -0
  108. package/esm/plugins/file/file.js +1 -1
  109. package/esm/plugins/font/config.js +63 -51
  110. package/esm/plugins/font/font.js +1 -1
  111. package/esm/plugins/format-block/config.d.ts +6 -0
  112. package/esm/plugins/format-block/config.js +52 -0
  113. package/esm/plugins/format-block/format-block.d.ts +1 -0
  114. package/esm/plugins/format-block/format-block.js +1 -68
  115. package/esm/plugins/fullsize/config.js +1 -1
  116. package/esm/plugins/iframe/iframe.js +11 -9
  117. package/esm/plugins/image/image.js +1 -1
  118. package/esm/plugins/image-processor/config.js +3 -0
  119. package/esm/plugins/inline-popup/config/items/cells.js +1 -1
  120. package/esm/plugins/justify/justify.js +8 -7
  121. package/esm/plugins/link/config.js +1 -1
  122. package/esm/plugins/mobile/config.js +3 -3
  123. package/esm/plugins/search/interface.d.ts +3 -0
  124. package/esm/plugins/select-cells/select-cells.d.ts +2 -0
  125. package/esm/plugins/symbols/config.js +1 -1
  126. package/esm/plugins/table/config.js +2 -1
  127. package/esm/plugins/video/config.js +1 -1
  128. package/esm/types/messages.d.ts +8 -0
  129. package/esm/types/popup.d.ts +3 -3
  130. package/esm/types/toolbar.d.ts +12 -8
  131. package/esm/typings.d.ts +0 -1
  132. package/package.json +1 -1
  133. package/types/core/component/component.d.ts +2 -2
  134. package/types/core/helpers/checker/is-marker.d.ts +3 -0
  135. package/types/core/helpers/normalize/normalize-size.d.ts +1 -1
  136. package/types/core/helpers/string/trim.d.ts +1 -0
  137. package/types/core/helpers/utils/attr.d.ts +3 -0
  138. package/types/core/plugin/interface.d.ts +3 -0
  139. package/types/core/selection/style/api/has-same-style.d.ts +1 -1
  140. package/types/core/selection/style/api/is-suit-element.d.ts +7 -2
  141. package/types/core/selection/style/transactions.d.ts +3 -0
  142. package/types/core/storage/engines/local-storage-provider.d.ts +1 -1
  143. package/types/core/storage/engines/memory-storage-provider.d.ts +1 -1
  144. package/types/core/ui/button/tooltip/tooltip.d.ts +2 -2
  145. package/types/core/ui/element.d.ts +1 -1
  146. package/types/core/ui/form/block/block.d.ts +1 -1
  147. package/types/core/ui/group/group.d.ts +0 -1
  148. package/types/core/ui/group/list.d.ts +1 -0
  149. package/types/core/ui/popup/popup.d.ts +12 -12
  150. package/types/modules/image-editor/config.d.ts +3 -0
  151. package/types/modules/toolbar/button/button.d.ts +5 -5
  152. package/types/modules/toolbar/button/index.d.ts +1 -0
  153. package/types/modules/toolbar/button/select/select.d.ts +15 -0
  154. package/types/modules/toolbar/collection/collection.d.ts +1 -0
  155. package/types/modules/toolbar/factory.d.ts +1 -0
  156. package/types/plugins/bold/interface.d.ts +3 -0
  157. package/types/plugins/delete/interface.d.ts +3 -0
  158. package/types/plugins/enter/interface.d.ts +3 -0
  159. package/types/plugins/format-block/config.d.ts +6 -0
  160. package/types/plugins/format-block/format-block.d.ts +1 -0
  161. package/types/plugins/search/interface.d.ts +3 -0
  162. package/types/plugins/select-cells/select-cells.d.ts +2 -0
  163. package/types/types/messages.d.ts +8 -0
  164. package/types/types/popup.d.ts +3 -3
  165. package/types/types/toolbar.d.ts +12 -8
  166. package/types/typings.d.ts +0 -1
@@ -99,7 +99,14 @@ export let UIList = class UIList extends UIGroup {
99
99
  }
100
100
  default:
101
101
  lastBtnSeparator = false;
102
- elm = this.makeButton(control, target);
102
+ switch (control.component) {
103
+ case 'select':
104
+ elm = this.makeSelect(control, target);
105
+ break;
106
+ case 'button':
107
+ default:
108
+ elm = this.makeButton(control, target);
109
+ }
103
110
  }
104
111
  if (elm) {
105
112
  if (!group) {
@@ -134,11 +141,16 @@ export let UIList = class UIList extends UIGroup {
134
141
  this.update();
135
142
  return this;
136
143
  }
144
+ makeSelect(control, target) {
145
+ throw new Error('Not implemented behaviour');
146
+ }
137
147
  /**
138
148
  * Create button instance
139
149
  */
140
150
  makeButton(control, target) {
141
- return new UIButton(this.j);
151
+ return new UIButton(this.j, {
152
+ name: control.name
153
+ });
142
154
  }
143
155
  };
144
156
  __decorate([
@@ -3,7 +3,7 @@
3
3
  * Released under MIT see LICENSE.txt in the project root for license information.
4
4
  * Copyright (c) 2013-2023 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
5
  */
6
- import { ConfigFlatten, isString } from "jodit/esm/core/helpers/index.js";
6
+ import { ConfigFlatten, isArray, isString } from "jodit/esm/core/helpers/index.js";
7
7
  import { Config } from "jodit/esm/config.js";
8
8
  /**
9
9
  * Get control for button name
@@ -47,10 +47,17 @@ export function findControlType(path, controls) {
47
47
  else {
48
48
  key = namespaceOrKey;
49
49
  }
50
+ const list = store[key]?.list;
50
51
  return store[key]
51
52
  ? {
52
53
  name: key,
53
- ...ConfigFlatten(store[key])
54
+ ...ConfigFlatten(store[key]),
55
+ list: isArray(list)
56
+ ? list.reduce((acc, k) => {
57
+ acc[k] = k;
58
+ return acc;
59
+ }, {})
60
+ : list
54
61
  }
55
62
  : undefined;
56
63
  }
@@ -10,18 +10,17 @@
10
10
  */
11
11
 
12
12
  import type { IBound, IPopup, IUIElement, IViewBased, PopupStrategy } from "jodit/esm/types";
13
- import { UIElement } from "jodit/esm/core/ui/element";
13
+ import { UIGroup } from "jodit/esm/core/ui/group/group";
14
14
  type getBoundFunc = () => IBound;
15
- export declare class Popup extends UIElement implements IPopup {
15
+ export declare class Popup extends UIGroup implements IPopup {
16
16
  readonly smart: boolean;
17
- /** @override */
18
17
  className(): string;
19
18
  isOpened: boolean;
20
19
  strategy: PopupStrategy;
20
+ protected appendChildToContainer(childContainer: HTMLElement): void;
21
21
  viewBound: () => IBound;
22
- private targetBound;
23
- private childrenPopups;
24
- /** @override */
22
+ private __targetBound;
23
+ private __childrenPopups;
25
24
  updateParentElement(target: IUIElement): this;
26
25
  /**
27
26
  * Set popup content
@@ -31,7 +30,7 @@ export declare class Popup extends UIElement implements IPopup {
31
30
  * Open popup near with some bound
32
31
  */
33
32
  open(getBound: getBoundFunc, keepPosition?: boolean, parentContainer?: HTMLElement): this;
34
- private calculateZIndex;
33
+ private __calculateZIndex;
35
34
  /**
36
35
  * Calculate static bound for point
37
36
  */
@@ -40,11 +39,11 @@ export declare class Popup extends UIElement implements IPopup {
40
39
  * Update container position
41
40
  */
42
41
  updatePosition(): this;
43
- throttleUpdatePosition(): void;
42
+ private __throttleUpdatePosition;
44
43
  /**
45
44
  * Calculate start point
46
45
  */
47
- private calculatePosition;
46
+ private __calculatePosition;
48
47
  /**
49
48
  * Check if one box is inside second
50
49
  */
@@ -56,15 +55,16 @@ export declare class Popup extends UIElement implements IPopup {
56
55
  /**
57
56
  * Close popup if click was in outside
58
57
  */
59
- private closeOnOutsideClick;
58
+ private __closeOnOutsideClick;
60
59
  isOwnClick(e: MouseEvent): boolean;
61
- private addGlobalListeners;
62
- private removeGlobalListeners;
60
+ private __addGlobalListeners;
61
+ private __removeGlobalListeners;
63
62
  /**
64
63
  * Set ZIndex
65
64
  */
66
65
  setZIndex(index: number | string): void;
67
66
  constructor(jodit: IViewBased, smart?: boolean);
67
+ render(): string;
68
68
  /** @override **/
69
69
  destruct(): any;
70
70
  }
@@ -21,6 +21,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
21
21
  import { Dom } from "jodit/esm/core/dom/dom.js";
22
22
  import { attr, css, isString, kebabCase, markOwner, position, ucfirst } from "jodit/esm/core/helpers/index.js";
23
23
  import { assert } from "jodit/esm/core/helpers/utils/assert.js";
24
+ import { UIGroup } from "jodit/esm/core/ui/group/group.js";
24
25
  import { UIElement } from "jodit/esm/core/ui/element.js";
25
26
  import { autobind, throttle } from "jodit/esm/core/decorators/index.js";
26
27
  import { Component } from "jodit/esm/core/component/component.js";
@@ -32,25 +33,28 @@ const EVENTS_FOR_AUTOCLOSE = [
32
33
  'backSpaceAfterDelete',
33
34
  'beforeCommandDelete'
34
35
  ];
35
- export class Popup extends UIElement {
36
- /** @override */
36
+ export class Popup extends UIGroup {
37
37
  className() {
38
38
  return 'Popup';
39
39
  }
40
- /** @override */
40
+ appendChildToContainer(childContainer) {
41
+ const content = this.getElm('content');
42
+ assert(content, 'Content element should exist');
43
+ content.appendChild(childContainer);
44
+ }
41
45
  updateParentElement(target) {
42
46
  if (target !== this && Component.isInstanceOf(target, Popup)) {
43
- this.childrenPopups.forEach(popup => {
47
+ this.__childrenPopups.forEach(popup => {
44
48
  if (!target.closest(popup) && popup.isOpened) {
45
49
  popup.close();
46
50
  }
47
51
  });
48
- if (!this.childrenPopups.has(target)) {
52
+ if (!this.__childrenPopups.has(target)) {
49
53
  this.j.e.on(target, 'beforeClose', () => {
50
- this.childrenPopups.delete(target);
54
+ this.__childrenPopups.delete(target);
51
55
  });
52
56
  }
53
- this.childrenPopups.add(target);
57
+ this.__childrenPopups.add(target);
54
58
  }
55
59
  return super.updateParentElement(target);
56
60
  }
@@ -58,21 +62,18 @@ export class Popup extends UIElement {
58
62
  * Set popup content
59
63
  */
60
64
  setContent(content) {
61
- Dom.detach(this.container);
62
- const box = this.j.c.div(`${this.componentName}__content`);
63
- let elm;
64
- if (Component.isInstanceOf(content, UIElement)) {
65
- elm = content.container;
66
- content.parentElement = this;
65
+ if (this.allChildren.length) {
66
+ throw new Error('Remove children');
67
67
  }
68
- else if (isString(content)) {
69
- elm = this.j.c.fromHTML(content);
68
+ if (Component.isInstanceOf(content, UIElement)) {
69
+ this.append(content);
70
70
  }
71
71
  else {
72
- elm = content;
72
+ const elm = isString(content)
73
+ ? this.j.c.fromHTML(content)
74
+ : content;
75
+ this.appendChildToContainer(elm);
73
76
  }
74
- box.appendChild(elm);
75
- this.container.appendChild(box);
76
77
  this.updatePosition();
77
78
  return this;
78
79
  }
@@ -81,10 +82,10 @@ export class Popup extends UIElement {
81
82
  */
82
83
  open(getBound, keepPosition = false, parentContainer) {
83
84
  markOwner(this.jodit, this.container);
84
- this.calculateZIndex();
85
+ this.__calculateZIndex();
85
86
  this.isOpened = true;
86
- this.addGlobalListeners();
87
- this.targetBound = !keepPosition
87
+ this.__addGlobalListeners();
88
+ this.__targetBound = !keepPosition
88
89
  ? getBound
89
90
  : this.getKeepBound(getBound);
90
91
  if (parentContainer) {
@@ -101,7 +102,7 @@ export class Popup extends UIElement {
101
102
  this.j.e.fire('afterOpenPopup', this);
102
103
  return this;
103
104
  }
104
- calculateZIndex() {
105
+ __calculateZIndex() {
105
106
  if (this.container.style.zIndex) {
106
107
  return;
107
108
  }
@@ -166,22 +167,22 @@ export class Popup extends UIElement {
166
167
  if (!this.isOpened) {
167
168
  return this;
168
169
  }
169
- const [pos, strategy] = this.calculatePosition(this.targetBound(), this.viewBound(), position(this.container, this.j));
170
+ const [pos, strategy] = this.__calculatePosition(this.__targetBound(), this.viewBound(), position(this.container, this.j));
170
171
  this.setMod('strategy', strategy);
171
172
  css(this.container, {
172
173
  left: pos.left,
173
174
  top: pos.top
174
175
  });
175
- this.childrenPopups.forEach(popup => popup.updatePosition());
176
+ this.__childrenPopups.forEach(popup => popup.updatePosition());
176
177
  return this;
177
178
  }
178
- throttleUpdatePosition() {
179
+ __throttleUpdatePosition() {
179
180
  this.updatePosition();
180
181
  }
181
182
  /**
182
183
  * Calculate start point
183
184
  */
184
- calculatePosition(target, view, container, defaultStrategy = this.strategy) {
185
+ __calculatePosition(target, view, container, defaultStrategy = this.strategy) {
185
186
  const x = {
186
187
  left: target.left,
187
188
  right: target.left - (container.width - target.width)
@@ -242,17 +243,17 @@ export class Popup extends UIElement {
242
243
  return this;
243
244
  }
244
245
  this.isOpened = false;
245
- this.childrenPopups.forEach(popup => popup.close());
246
+ this.__childrenPopups.forEach(popup => popup.close());
246
247
  this.j.e.fire(this, 'beforeClose');
247
248
  this.j.e.fire('beforePopupClose', this);
248
- this.removeGlobalListeners();
249
+ this.__removeGlobalListeners();
249
250
  Dom.safeRemove(this.container);
250
251
  return this;
251
252
  }
252
253
  /**
253
254
  * Close popup if click was in outside
254
255
  */
255
- closeOnOutsideClick(e) {
256
+ __closeOnOutsideClick(e) {
256
257
  if (!this.isOpened || this.isOwnClick(e)) {
257
258
  return;
258
259
  }
@@ -265,14 +266,14 @@ export class Popup extends UIElement {
265
266
  const box = UIElement.closestElement(e.target, Popup);
266
267
  return Boolean(box && (this === box || box.closest(this)));
267
268
  }
268
- addGlobalListeners() {
269
- const up = this.throttleUpdatePosition, ow = this.ow;
269
+ __addGlobalListeners() {
270
+ const up = this.__throttleUpdatePosition, ow = this.ow;
270
271
  eventEmitter.on('closeAllPopups', this.close);
271
272
  if (this.smart) {
272
273
  this.j.e
273
274
  .on(EVENTS_FOR_AUTOCLOSE, this.close)
274
- .on('mousedown touchstart', this.closeOnOutsideClick)
275
- .on(ow, 'mousedown touchstart', this.closeOnOutsideClick);
275
+ .on('mousedown touchstart', this.__closeOnOutsideClick)
276
+ .on(ow, 'mousedown touchstart', this.__closeOnOutsideClick);
276
277
  }
277
278
  this.j.e
278
279
  .on('closeAllPopups', this.close)
@@ -284,14 +285,14 @@ export class Popup extends UIElement {
284
285
  box && this.j.e.on(box, 'scroll mousewheel', up);
285
286
  });
286
287
  }
287
- removeGlobalListeners() {
288
- const up = this.throttleUpdatePosition, ow = this.ow;
288
+ __removeGlobalListeners() {
289
+ const up = this.__throttleUpdatePosition, ow = this.ow;
289
290
  eventEmitter.off('closeAllPopups', this.close);
290
291
  if (this.smart) {
291
292
  this.j.e
292
293
  .off(EVENTS_FOR_AUTOCLOSE, this.close)
293
- .off('mousedown touchstart', this.closeOnOutsideClick)
294
- .off(ow, 'mousedown touchstart', this.closeOnOutsideClick);
294
+ .off('mousedown touchstart', this.__closeOnOutsideClick)
295
+ .off(ow, 'mousedown touchstart', this.__closeOnOutsideClick);
295
296
  }
296
297
  this.j.e
297
298
  .off('closeAllPopups', this.close)
@@ -321,9 +322,14 @@ export class Popup extends UIElement {
321
322
  width: this.ow.innerWidth,
322
323
  height: this.ow.innerHeight
323
324
  });
324
- this.childrenPopups = new Set();
325
+ this.__childrenPopups = new Set();
325
326
  attr(this.container, 'role', 'popup');
326
327
  }
328
+ render() {
329
+ return `<div>
330
+ <div class="&__content"></div>
331
+ </div>`;
332
+ }
327
333
  /** @override **/
328
334
  destruct() {
329
335
  this.close();
@@ -336,10 +342,10 @@ __decorate([
336
342
  __decorate([
337
343
  throttle(10),
338
344
  autobind
339
- ], Popup.prototype, "throttleUpdatePosition", null);
345
+ ], Popup.prototype, "__throttleUpdatePosition", null);
340
346
  __decorate([
341
347
  autobind
342
348
  ], Popup.prototype, "close", null);
343
349
  __decorate([
344
350
  autobind
345
- ], Popup.prototype, "closeOnOutsideClick", null);
351
+ ], Popup.prototype, "__closeOnOutsideClick", null);
@@ -283,7 +283,7 @@ Config.prototype.controls.filebrowser = {
283
283
  },
284
284
  filter: {
285
285
  isInput: true,
286
- getContent: (filebrowser, _, b) => {
286
+ getContent: (filebrowser, b) => {
287
287
  const oldInput = b.container.querySelector('.jodit-input');
288
288
  if (oldInput) {
289
289
  return oldInput;
@@ -3,6 +3,9 @@
3
3
  * Released under MIT see LICENSE.txt in the project root for license information.
4
4
  * Copyright (c) 2013-2023 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
5
  */
6
+ /**
7
+ * @module modules/image-editor
8
+ */
6
9
  import type { ImageEditorOptions } from "jodit/esm/types";
7
10
  declare module 'jodit/config' {
8
11
  interface Config {
@@ -42,11 +42,11 @@ export declare class ToolbarButton<T extends IViewBased = IViewBased> extends UI
42
42
  /**
43
43
  * Calculates whether the button is active
44
44
  */
45
- private calculateActivatedStatus;
45
+ private __calculateActivatedStatus;
46
46
  /**
47
47
  * Calculates whether an element is blocked for the user
48
48
  */
49
- private calculateDisabledStatus;
49
+ private __calculateDisabledStatus;
50
50
  /** @override */
51
51
  protected onChangeActivated(): void;
52
52
  /** @override */
@@ -63,7 +63,7 @@ export declare class ToolbarButton<T extends IViewBased = IViewBased> extends UI
63
63
  /**
64
64
  * Init constant data from control
65
65
  */
66
- private __initFromControl;
66
+ protected __initFromControl(): void;
67
67
  /**
68
68
  * Click on trigger button
69
69
  */
@@ -72,10 +72,10 @@ export declare class ToolbarButton<T extends IViewBased = IViewBased> extends UI
72
72
  /**
73
73
  * Create and open popup list
74
74
  */
75
- private openControlList;
75
+ private __openControlList;
76
76
  protected onOutsideClick(e: MouseEvent): void;
77
77
  private openPopup;
78
- private closePopup;
78
+ private __closePopup;
79
79
  /**
80
80
  * Click handler
81
81
  */
@@ -41,25 +41,26 @@ export let ToolbarButton = class ToolbarButton extends UIButton {
41
41
  }
42
42
  /** @override **/
43
43
  update() {
44
- // @ts-ignore
45
- window.__onupdate = (window.__onupdate ?? 0) + 1;
46
44
  const { control, state } = this, tc = this.closest(ToolbarCollection);
47
- state.disabled = this.calculateDisabledStatus(tc);
48
- state.activated = this.calculateActivatedStatus(tc);
49
- if (isFunction(control.update) && tc) {
50
- control.update(this, tc.jodit);
45
+ if (!tc) {
46
+ return;
47
+ }
48
+ const value = control.value?.(tc.jodit, this);
49
+ if (value !== undefined) {
50
+ state.value = value;
51
51
  }
52
- super.update();
52
+ state.disabled = this.__calculateDisabledStatus(tc);
53
+ state.activated = this.__calculateActivatedStatus(tc);
54
+ control.update?.(tc.jodit, this);
53
55
  }
54
56
  /**
55
57
  * Calculates whether the button is active
56
58
  */
57
- calculateActivatedStatus(tc) {
59
+ __calculateActivatedStatus(tc) {
58
60
  if (isJoditObject(this.j) && !this.j.editorIsActive) {
59
61
  return false;
60
62
  }
61
- if (isFunction(this.control.isActive) &&
62
- this.control.isActive(this.j, this.control, this)) {
63
+ if (this.control.isActive?.(this.j, this)) {
63
64
  return true;
64
65
  }
65
66
  return Boolean(tc && tc.shouldBeActive(this));
@@ -67,7 +68,7 @@ export let ToolbarButton = class ToolbarButton extends UIButton {
67
68
  /**
68
69
  * Calculates whether an element is blocked for the user
69
70
  */
70
- calculateDisabledStatus(tc) {
71
+ __calculateDisabledStatus(tc) {
71
72
  if (this.j.o.disabled) {
72
73
  return true;
73
74
  }
@@ -76,8 +77,7 @@ export let ToolbarButton = class ToolbarButton extends UIButton {
76
77
  !this.j.o.activeButtonsInReadOnly.includes(this.control.name))) {
77
78
  return true;
78
79
  }
79
- if (isFunction(this.control.isDisabled) &&
80
- this.control.isDisabled(this.j, this.control, this)) {
80
+ if (this.control.isDisabled?.(this.j, this)) {
81
81
  return true;
82
82
  }
83
83
  return Boolean(tc && tc.shouldBeDisabled(this));
@@ -212,7 +212,7 @@ export let ToolbarButton = class ToolbarButton extends UIButton {
212
212
  */
213
213
  onTriggerClick(e) {
214
214
  if (this.openedPopup) {
215
- this.closePopup();
215
+ this.__closePopup();
216
216
  return;
217
217
  }
218
218
  const { control: ctr } = this;
@@ -220,14 +220,14 @@ export let ToolbarButton = class ToolbarButton extends UIButton {
220
220
  actionTrigger: this
221
221
  };
222
222
  if (ctr.list) {
223
- return this.openControlList(ctr);
223
+ return this.__openControlList(ctr);
224
224
  }
225
225
  if (isFunction(ctr.popup)) {
226
226
  const popup = this.openPopup();
227
227
  popup.parentElement = this;
228
228
  if (this.j.e.fire(camelCase(`before-${ctr.name}-open-popup`), this.target, ctr, popup) !== false) {
229
229
  const target = this.toolbar?.getTarget(this) ?? this.target ?? null;
230
- const elm = ctr.popup(this.j, target, ctr, this.closePopup, this);
230
+ const elm = ctr.popup(this.j, target, this.__closePopup, this);
231
231
  if (elm) {
232
232
  popup
233
233
  .setContent(isString(elm) ? this.j.c.fromHTML(elm) : elm)
@@ -248,7 +248,7 @@ export let ToolbarButton = class ToolbarButton extends UIButton {
248
248
  /**
249
249
  * Create and open popup list
250
250
  */
251
- openControlList(control) {
251
+ __openControlList(control) {
252
252
  const controls = this.jodit.options.controls ?? {}, getControl = (key) => findControlType(key, controls);
253
253
  const list = control.list, menu = this.openPopup(), toolbar = makeCollection(this.j);
254
254
  menu.parentElement = this;
@@ -287,6 +287,7 @@ export let ToolbarButton = class ToolbarButton extends UIButton {
287
287
  data: control.data,
288
288
  command: control.command,
289
289
  isActive: control.isChildActive,
290
+ value: control.value,
290
291
  isDisabled: control.isChildDisabled,
291
292
  mode: control.mode,
292
293
  args: [...(control.args ? control.args : []), key, value]
@@ -299,7 +300,7 @@ export let ToolbarButton = class ToolbarButton extends UIButton {
299
300
  toolbar.build(isArray(list)
300
301
  ? list.map(getButton)
301
302
  : keys(list, false).map(key => getButton(key, list[key])), this.target);
302
- menu.setContent(toolbar.container).open(() => position(this.container), false, this.j.o.allowTabNavigation ? this.container : undefined);
303
+ menu.setContent(toolbar).open(() => position(this.container), false, this.j.o.allowTabNavigation ? this.container : undefined);
303
304
  this.state.activated = true;
304
305
  }
305
306
  onOutsideClick(e) {
@@ -310,18 +311,18 @@ export let ToolbarButton = class ToolbarButton extends UIButton {
310
311
  !Dom.isNode(e.target) ||
311
312
  (!Dom.isOrContains(this.container, e.target) &&
312
313
  !this.openedPopup.isOwnClick(e))) {
313
- this.closePopup();
314
+ this.__closePopup();
314
315
  }
315
316
  }
316
317
  openPopup() {
317
- this.closePopup();
318
+ this.__closePopup();
318
319
  this.openedPopup = new Popup(this.j, false);
319
320
  this.j.e
320
321
  .on(this.ow, 'mousedown touchstart', this.onOutsideClick)
321
322
  .on('escape closeAllPopups', this.onOutsideClick);
322
323
  return this.openedPopup;
323
324
  }
324
- closePopup() {
325
+ __closePopup() {
325
326
  if (this.openedPopup) {
326
327
  this.j.e
327
328
  .off(this.ow, 'mousedown touchstart', this.onOutsideClick)
@@ -360,7 +361,7 @@ export let ToolbarButton = class ToolbarButton extends UIButton {
360
361
  }
361
362
  }
362
363
  if (ctr.list) {
363
- return this.openControlList(ctr);
364
+ return this.__openControlList(ctr);
364
365
  }
365
366
  if (isFunction(ctr.popup)) {
366
367
  return this.onTriggerClick(originalEvent);
@@ -373,7 +374,7 @@ export let ToolbarButton = class ToolbarButton extends UIButton {
373
374
  }
374
375
  }
375
376
  destruct() {
376
- this.closePopup();
377
+ this.__closePopup();
377
378
  return super.destruct();
378
379
  }
379
380
  };
@@ -391,7 +392,7 @@ __decorate([
391
392
  ], ToolbarButton.prototype, "onOutsideClick", null);
392
393
  __decorate([
393
394
  autobind
394
- ], ToolbarButton.prototype, "closePopup", null);
395
+ ], ToolbarButton.prototype, "__closePopup", null);
395
396
  ToolbarButton = __decorate([
396
397
  component
397
398
  ], ToolbarButton);
@@ -27,7 +27,7 @@ export let ToolbarContent = class ToolbarContent extends UIButton {
27
27
  }
28
28
  /** @override */
29
29
  update() {
30
- const content = this.control.getContent(this.j, this.control, this);
30
+ const content = this.control.getContent(this.j, this);
31
31
  if (isString(content) || content.parentNode !== this.container) {
32
32
  Dom.detach(this.container);
33
33
  this.container.appendChild(isString(content) ? this.j.create.fromHTML(content) : content);
@@ -8,3 +8,4 @@
8
8
  */
9
9
  export * from "./button";
10
10
  export * from "./content";
11
+ export * from "./select/select";
@@ -8,3 +8,4 @@
8
8
  */
9
9
  export * from "./button";
10
10
  export * from "./content";
11
+ export * from "./select/select";
@@ -0,0 +1,15 @@
1
+ /*!
2
+ * Jodit Editor (https://xdsoft.net/jodit/)
3
+ * Released under MIT see LICENSE.txt in the project root for license information.
4
+ * Copyright (c) 2013-2023 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
+ */
6
+ /**
7
+ * @module modules/toolbar/button
8
+ */
9
+
10
+ import type { IViewBased } from "jodit/esm/types";
11
+ import { ToolbarButton } from "../button";
12
+ export declare class ToolbarSelect<T extends IViewBased = IViewBased> extends ToolbarButton<T> {
13
+ className(): string;
14
+ update(): void;
15
+ }
@@ -0,0 +1,47 @@
1
+ /*!
2
+ * Jodit Editor (https://xdsoft.net/jodit/)
3
+ * Released under MIT see LICENSE.txt in the project root for license information.
4
+ * Copyright (c) 2013-2023 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
+ */
6
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
7
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
8
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
9
+ r = Reflect.decorate(decorators, target, key, desc);
10
+ else
11
+ for (var i = decorators.length - 1; i >= 0; i--)
12
+ if (d = decorators[i])
13
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
14
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
15
+ };
16
+ /**
17
+ * @module modules/toolbar/button
18
+ */
19
+ import { component } from "jodit/esm/core/decorators/index.js";
20
+ import { isString } from "jodit/esm/core/helpers/checker/is-string.js";
21
+ import { ToolbarButton } from "../button";
22
+ export let ToolbarSelect = class ToolbarSelect extends ToolbarButton {
23
+ className() {
24
+ return 'ToolbarSelect';
25
+ }
26
+ update() {
27
+ super.update();
28
+ this.state.icon.name = '';
29
+ const { list, data } = this.control;
30
+ if (list) {
31
+ let key = this.state.value ||
32
+ (data && isString(data.currentValue)
33
+ ? data.currentValue
34
+ : undefined);
35
+ if (!key) {
36
+ const keys = Object.keys(list);
37
+ key = keys[0];
38
+ }
39
+ const text = (list[key.toString()] || key).toString();
40
+ this.state.text =
41
+ this.control.textTemplate?.(this.jodit, text) ?? text;
42
+ }
43
+ }
44
+ };
45
+ ToolbarSelect = __decorate([
46
+ component
47
+ ], ToolbarSelect);
@@ -20,6 +20,7 @@ export declare class ToolbarCollection<T extends IViewWithToolbar = IViewWithToo
20
20
  */
21
21
  get firstButton(): Nullable<IToolbarButton>;
22
22
  protected makeButton(control: IControlTypeStrong, target?: Nullable<HTMLElement>): IUIButton;
23
+ protected makeSelect(control: IControlTypeStrong, target?: Nullable<HTMLElement>): IUIButton;
23
24
  /**
24
25
  * Button should be active
25
26
  */
@@ -21,7 +21,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
21
21
  import { error } from "jodit/esm/core/helpers/utils/error/error.js";
22
22
  import { UIList, UITooltip } from "jodit/esm/core/ui/index.js";
23
23
  import { component, autobind } from "jodit/esm/core/decorators/index.js";
24
- import { makeButton } from "jodit/esm/modules/toolbar/factory.js";
24
+ import { makeButton, makeSelect } from "jodit/esm/modules/toolbar/factory.js";
25
25
  export let ToolbarCollection = class ToolbarCollection extends UIList {
26
26
  /** @override */
27
27
  className() {
@@ -37,6 +37,9 @@ export let ToolbarCollection = class ToolbarCollection extends UIList {
37
37
  makeButton(control, target = null) {
38
38
  return makeButton(this.j, control, target);
39
39
  }
40
+ makeSelect(control, target = null) {
41
+ return makeSelect(this.j, control, target);
42
+ }
40
43
  /**
41
44
  * Button should be active
42
45
  */
@@ -17,3 +17,4 @@ export declare function makeCollection(jodit: IViewBased, parentElement?: IUIEle
17
17
  * Button factory
18
18
  */
19
19
  export declare function makeButton(jodit: IViewBased, control: IControlTypeStrong, target?: Nullable<HTMLElement>): IToolbarButton;
20
+ export declare function makeSelect(view: IViewBased, control: IControlTypeStrong, target?: Nullable<HTMLElement>): IToolbarButton;