jodit 4.2.19 → 4.2.22

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 (85) hide show
  1. package/CHANGELOG.md +16 -5
  2. package/es2015/jodit.css +47 -1
  3. package/es2015/jodit.fat.min.css +1 -1
  4. package/es2015/jodit.fat.min.js +2 -2
  5. package/es2015/jodit.js +75 -63
  6. package/es2015/jodit.min.css +1 -1
  7. package/es2015/jodit.min.js +2 -2
  8. package/es2015/plugins/debug/debug.js +1 -1
  9. package/es2015/plugins/debug/debug.min.js +1 -1
  10. package/es2015/plugins/speech-recognize/speech-recognize.css +3 -2
  11. package/es2015/plugins/speech-recognize/speech-recognize.js +98 -77
  12. package/es2015/plugins/speech-recognize/speech-recognize.min.css +1 -1
  13. package/es2015/plugins/speech-recognize/speech-recognize.min.js +2 -2
  14. package/es2018/jodit.css +47 -1
  15. package/es2018/jodit.fat.min.css +1 -1
  16. package/es2018/jodit.fat.min.js +2 -2
  17. package/es2018/jodit.js +75 -63
  18. package/es2018/jodit.min.css +1 -1
  19. package/es2018/jodit.min.js +2 -2
  20. package/es2018/plugins/debug/debug.js +1 -1
  21. package/es2018/plugins/debug/debug.min.js +1 -1
  22. package/es2018/plugins/speech-recognize/speech-recognize.css +3 -2
  23. package/es2018/plugins/speech-recognize/speech-recognize.js +98 -77
  24. package/es2018/plugins/speech-recognize/speech-recognize.min.css +1 -1
  25. package/es2018/plugins/speech-recognize/speech-recognize.min.js +2 -2
  26. package/es2021/jodit.css +47 -1
  27. package/es2021/jodit.fat.min.css +1 -1
  28. package/es2021/jodit.fat.min.js +2 -2
  29. package/es2021/jodit.js +75 -63
  30. package/es2021/jodit.min.css +1 -1
  31. package/es2021/jodit.min.js +2 -2
  32. package/es2021/plugins/debug/debug.js +1 -1
  33. package/es2021/plugins/debug/debug.min.js +1 -1
  34. package/es2021/plugins/speech-recognize/speech-recognize.css +3 -2
  35. package/es2021/plugins/speech-recognize/speech-recognize.js +98 -77
  36. package/es2021/plugins/speech-recognize/speech-recognize.min.css +1 -1
  37. package/es2021/plugins/speech-recognize/speech-recognize.min.js +2 -2
  38. package/es2021.en/jodit.css +47 -1
  39. package/es2021.en/jodit.fat.min.css +1 -1
  40. package/es2021.en/jodit.fat.min.js +2 -2
  41. package/es2021.en/jodit.js +75 -63
  42. package/es2021.en/jodit.min.css +1 -1
  43. package/es2021.en/jodit.min.js +2 -2
  44. package/es2021.en/plugins/debug/debug.js +1 -1
  45. package/es2021.en/plugins/debug/debug.min.js +1 -1
  46. package/es2021.en/plugins/speech-recognize/speech-recognize.css +3 -2
  47. package/es2021.en/plugins/speech-recognize/speech-recognize.js +98 -77
  48. package/es2021.en/plugins/speech-recognize/speech-recognize.min.css +1 -1
  49. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +2 -2
  50. package/es5/jodit.css +77 -2
  51. package/es5/jodit.fat.min.css +1 -1
  52. package/es5/jodit.fat.min.js +2 -2
  53. package/es5/jodit.js +78 -62
  54. package/es5/jodit.min.css +3 -3
  55. package/es5/jodit.min.js +2 -2
  56. package/es5/plugins/debug/debug.js +1 -1
  57. package/es5/plugins/debug/debug.min.js +1 -1
  58. package/es5/plugins/speech-recognize/speech-recognize.css +3 -2
  59. package/es5/plugins/speech-recognize/speech-recognize.js +99 -79
  60. package/es5/plugins/speech-recognize/speech-recognize.min.css +1 -1
  61. package/es5/plugins/speech-recognize/speech-recognize.min.js +2 -2
  62. package/esm/core/constants.js +1 -1
  63. package/esm/core/ui/button/button/button.d.ts +1 -0
  64. package/esm/core/ui/button/button/button.js +7 -0
  65. package/esm/core/ui/button/tooltip/tooltip.d.ts +3 -4
  66. package/esm/core/ui/button/tooltip/tooltip.js +44 -44
  67. package/esm/modules/toolbar/button/button.d.ts +1 -0
  68. package/esm/modules/widget/tabs/tabs.js +21 -16
  69. package/esm/plugins/speech-recognize/config.d.ts +1 -1
  70. package/esm/plugins/speech-recognize/config.js +13 -5
  71. package/esm/plugins/speech-recognize/helpers/recognize-manager.d.ts +3 -2
  72. package/esm/plugins/speech-recognize/helpers/recognize-manager.js +45 -31
  73. package/esm/plugins/speech-recognize/interface.d.ts +1 -0
  74. package/esm/plugins/speech-recognize/speech-recognize.d.ts +5 -1
  75. package/esm/plugins/speech-recognize/speech-recognize.js +17 -17
  76. package/esm/types/ui.d.ts +1 -0
  77. package/package.json +1 -1
  78. package/types/core/ui/button/button/button.d.ts +1 -0
  79. package/types/core/ui/button/tooltip/tooltip.d.ts +3 -4
  80. package/types/modules/toolbar/button/button.d.ts +1 -0
  81. package/types/plugins/speech-recognize/config.d.ts +1 -1
  82. package/types/plugins/speech-recognize/helpers/recognize-manager.d.ts +3 -2
  83. package/types/plugins/speech-recognize/interface.d.ts +1 -0
  84. package/types/plugins/speech-recognize/speech-recognize.d.ts +5 -1
  85. package/types/types/ui.d.ts +1 -0
@@ -21,6 +21,19 @@ import { getContainer } from "../../../global.js";
21
21
  import { position } from "../../../helpers/size/position.js";
22
22
  import { attr, css } from "../../../helpers/utils/index.js";
23
23
  import { UIElement } from "../../element.js";
24
+ const WINDOW_EVENTS_ON_HIDE = [
25
+ 'scroll.tooltip',
26
+ 'joditCloseDialog',
27
+ 'mouseleave.tooltip'
28
+ ];
29
+ const JODIT_EVENTS_ON_HIDE = [
30
+ 'escape.tooltip',
31
+ 'change.tooltip',
32
+ 'changePlace.tooltip',
33
+ 'afterOpenPopup.tooltip',
34
+ 'hidePopup.tooltip',
35
+ 'closeAllPopups.tooltip'
36
+ ];
24
37
  let UITooltip = UITooltip_1 = class UITooltip extends UIElement {
25
38
  className() {
26
39
  return 'UITooltip';
@@ -39,7 +52,7 @@ let UITooltip = UITooltip_1 = class UITooltip extends UIElement {
39
52
  view.o.showTooltip &&
40
53
  !view.o.useNativeTooltip) {
41
54
  view.hookStatus(STATUSES.ready, () => {
42
- // TODO Move it inside __open method. Now it is here because testcase failed with capturing
55
+ // TODO Move it inside __show method. Now it is here because testcase failed with capturing
43
56
  getContainer(this.j, UITooltip_1).appendChild(this.container);
44
57
  view.e.on(view.container, 'mouseenter.tooltip', this.__onMouseEnter, {
45
58
  capture: true
@@ -47,44 +60,28 @@ let UITooltip = UITooltip_1 = class UITooltip extends UIElement {
47
60
  });
48
61
  }
49
62
  }
50
- __addListenersOnClose() {
63
+ __addListenersOnEnter() {
51
64
  if (this.__listenClose) {
52
65
  return;
53
66
  }
54
67
  this.__listenClose = true;
55
68
  const view = this.j;
56
69
  view.e
57
- .on(view.ow, 'scroll.tooltip', this.__hide)
58
- .on(view.ow, 'joditCloseDialog', this.__hide)
59
- .on(view.container, 'mouseleave.tooltip', this.__hide)
60
- .on([
61
- 'escape.tooltip',
62
- 'change.tooltip',
63
- 'changePlace.tooltip',
64
- 'afterOpenPopup.tooltip',
65
- 'hidePopup.tooltip',
66
- 'closeAllPopups.tooltip'
67
- ], this.__hide)
68
- .on(view.container, 'mouseleave', this.__onMouseLeave, {
70
+ .on(view.ow, WINDOW_EVENTS_ON_HIDE, this.__hide)
71
+ .on(JODIT_EVENTS_ON_HIDE, this.__hide)
72
+ .on(view.container, 'mouseleave.tooltip', this.__onMouseLeave, {
69
73
  capture: true
70
74
  });
71
75
  }
72
- __removeListenersOnClose() {
76
+ __removeListenersOnLeave() {
73
77
  if (!this.__listenClose) {
74
78
  return;
75
79
  }
76
80
  this.__listenClose = false;
77
81
  const view = this.j;
78
82
  view.e
79
- .off(view.ow, 'scroll.tooltip', this.__hide)
80
- .off([
81
- 'escape.tooltip',
82
- 'change.tooltip',
83
- 'changePlace.tooltip',
84
- 'afterOpenPopup.tooltip',
85
- 'hidePopup.tooltip',
86
- 'closeAllPopups.tooltip'
87
- ], this.__hide)
83
+ .off(view.ow, WINDOW_EVENTS_ON_HIDE, this.__hide)
84
+ .off(JODIT_EVENTS_ON_HIDE, this.__hide)
88
85
  .off(view.container, 'mouseleave.tooltip', this.__onMouseLeave);
89
86
  }
90
87
  __onMouseLeave(e) {
@@ -110,29 +107,30 @@ let UITooltip = UITooltip_1 = class UITooltip extends UIElement {
110
107
  return;
111
108
  }
112
109
  this.__currentTarget = e.target;
113
- const pos = position(e.target);
114
- this.__addListenersOnClose();
115
- this.__delayOpen(() => ({
116
- x: pos.left + pos.width / 2,
117
- y: pos.top + pos.height
118
- }), tooltip);
110
+ const target = e.target;
111
+ this.__open(() => {
112
+ const pos = position(target);
113
+ return {
114
+ x: pos.left + pos.width / 2,
115
+ y: pos.top + pos.height
116
+ };
117
+ }, tooltip);
119
118
  }
120
- __delayOpen(getPoint, content) {
121
- const to = this.j.o.showTooltipDelay || this.j.defaultTimeout;
119
+ __open(getPoint, content) {
120
+ this.__addListenersOnEnter();
121
+ this.__isOpened = true;
122
122
  this.j.async.clearTimeout(this.__hideTimeout);
123
123
  this.j.async.clearTimeout(this.__delayShowTimeout);
124
- this.__delayShowTimeout = this.j.async.setTimeout(() => this.__open(getPoint, content), {
125
- timeout: to,
126
- label: 'tooltip'
127
- });
124
+ const to = this.j.o.showTooltipDelay || this.j.defaultTimeout;
125
+ if (!to) {
126
+ this.__show(getPoint, content);
127
+ return;
128
+ }
129
+ this.__delayShowTimeout = this.j.async.setTimeout(() => this.__show(getPoint, content), to);
128
130
  }
129
- __open(getPoint, content) {
131
+ __show(getPoint, content) {
130
132
  this.setMod('visible', true);
131
133
  this.getElm('content').innerHTML = content;
132
- this.__isOpened = true;
133
- this.__setPosition(getPoint);
134
- }
135
- __setPosition(getPoint) {
136
134
  const point = getPoint();
137
135
  css(this.container, {
138
136
  left: point.x,
@@ -142,24 +140,26 @@ let UITooltip = UITooltip_1 = class UITooltip extends UIElement {
142
140
  __hide() {
143
141
  this.j.async.clearTimeout(this.__delayShowTimeout);
144
142
  this.j.async.clearTimeout(this.__hideTimeout);
145
- this.__removeListenersOnClose();
143
+ this.__removeListenersOnLeave();
146
144
  if (this.__isOpened) {
147
145
  this.__isOpened = false;
148
146
  this.setMod('visible', false);
147
+ this.getElm('content').innerHTML = '';
149
148
  css(this.container, {
150
149
  left: -5000
151
150
  });
152
151
  }
153
152
  }
154
153
  __hideDelay() {
154
+ this.j.async.clearTimeout(this.__delayShowTimeout);
155
+ this.j.async.clearTimeout(this.__hideTimeout);
155
156
  if (!this.__isOpened) {
156
157
  return;
157
158
  }
158
- this.j.async.clearTimeout(this.__delayShowTimeout);
159
159
  this.__hideTimeout = this.async.setTimeout(this.__hide, this.j.defaultTimeout);
160
160
  }
161
161
  destruct() {
162
- this.j.e.off(this.j.container, 'mouseenter', this.__onMouseEnter);
162
+ this.j.e.off(this.j.container, 'mouseenter.tooltip', this.__onMouseEnter);
163
163
  this.__hide();
164
164
  super.destruct();
165
165
  }
@@ -25,6 +25,7 @@ export declare class ToolbarButton<T extends IViewBased = IViewBased> extends UI
25
25
  value: string | number | boolean;
26
26
  variant: import("../../../types").ButtonVariant;
27
27
  type: "button" | "submit";
28
+ role: "button" | "tab";
28
29
  disabled: boolean;
29
30
  activated: boolean;
30
31
  icon: import("../../../types").IUIIconState;
@@ -5,8 +5,8 @@
5
5
  */
6
6
  import { Component } from "../../../core/component/index.js";
7
7
  import { Dom } from "../../../core/dom/dom.js";
8
- import { $$ } from "../../../core/helpers/index.js";
9
8
  import { isFunction } from "../../../core/helpers/checker/is-function.js";
9
+ import { attr } from "../../../core/helpers/utils/attr.js";
10
10
  import { Button, UIElement } from "../../../core/ui/index.js";
11
11
  /**
12
12
  * Build tabs system
@@ -37,8 +37,16 @@ import { Button, UIElement } from "../../../core/ui/index.js";
37
37
  * ```
38
38
  */
39
39
  export const TabsWidget = (jodit, tabs, state) => {
40
- const box = jodit.c.div('jodit-tabs'), tabBox = jodit.c.div('jodit-tabs__wrapper'), buttons = jodit.c.div('jodit-tabs__buttons'), nameToTab = {}, buttonList = [];
41
- let firstTab = '', tabCount = 0;
40
+ const box = jodit.c.div('jodit-tabs');
41
+ const tabBox = jodit.c.div('jodit-tabs__wrapper');
42
+ const buttons = jodit.c.div('jodit-tabs__buttons');
43
+ attr(buttons, {
44
+ role: 'tablist',
45
+ 'aria-orientation': 'horizontal'
46
+ });
47
+ const nameToTab = {};
48
+ const buttonList = [];
49
+ let firstTab = '';
42
50
  box.appendChild(buttons);
43
51
  box.appendChild(tabBox);
44
52
  const setActive = (tab) => {
@@ -46,20 +54,21 @@ export const TabsWidget = (jodit, tabs, state) => {
46
54
  return;
47
55
  }
48
56
  buttonList.forEach(b => {
49
- b.state.variant = 'initial';
50
57
  b.state.activated = false;
51
58
  });
52
- $$('.jodit-tab', tabBox).forEach(a => {
53
- a.classList.remove('jodit-tab_active');
54
- });
55
- nameToTab[tab].button.state.variant = 'outline';
59
+ Object.values(nameToTab).forEach(({ tab }) => tab.classList.remove('jodit-tab_active'));
56
60
  nameToTab[tab].button.state.activated = true;
57
61
  nameToTab[tab].tab.classList.add('jodit-tab_active');
58
62
  };
59
63
  tabs.forEach(({ icon, name, content }) => {
60
- const tab = jodit.c.div('jodit-tab'), button = Button(jodit, icon || name, name);
64
+ const tab = jodit.c.div('jodit-tab');
65
+ attr(tab, {
66
+ role: 'tabpanel'
67
+ });
68
+ const button = Button(jodit, icon || name, name);
69
+ button.state.role = 'tab';
61
70
  // Stop lose the focus
62
- jodit.e.on(button.container, 'mousedown', (e) => e.preventDefault());
71
+ jodit.e.on(button.container, 'pointerdown', (e) => e.preventDefault());
63
72
  if (!firstTab) {
64
73
  firstTab = name;
65
74
  }
@@ -89,13 +98,9 @@ export const TabsWidget = (jodit, tabs, state) => {
89
98
  button,
90
99
  tab
91
100
  };
92
- tabCount += 1;
93
101
  });
94
- if (!tabCount) {
95
- return box;
96
- }
97
- $$('a', buttons).forEach(a => {
98
- a.style.width = (100 / tabCount).toFixed(10) + '%';
102
+ Object.values(nameToTab).forEach(({ button }) => {
103
+ button.container.style.width = (100 / tabs.length).toFixed(10) + '%';
99
104
  });
100
105
  const tab = !state || !state.activeTab || !nameToTab[state.activeTab]
101
106
  ? firstTab
@@ -11,7 +11,7 @@ import type { ISpeechRecognizeConstructor } from "./interface";
11
11
  declare module 'jodit/config' {
12
12
  interface Config {
13
13
  speechRecognize: {
14
- readonly api: ISpeechRecognizeConstructor;
14
+ readonly api: ISpeechRecognizeConstructor | null;
15
15
  /**
16
16
  * Returns and sets the language of the current SpeechRecognition.
17
17
  * If not specified, this defaults to the HTML lang attribute value, or
@@ -11,9 +11,9 @@ import { SpeechRecognition } from "./helpers/api.js";
11
11
  import { RecognizeManager } from "./helpers/recognize-manager.js";
12
12
  import speechRecognizeIcon from "./speech-recognize.svg.js";
13
13
  Config.prototype.speechRecognize = {
14
- api: SpeechRecognition,
14
+ api: typeof SpeechRecognition !== 'undefined' ? SpeechRecognition : null,
15
15
  sound: true,
16
- continuous: true,
16
+ continuous: false,
17
17
  interimResults: true,
18
18
  commands: {
19
19
  'newline|enter': 'enter',
@@ -31,6 +31,9 @@ Config.prototype.speechRecognize = {
31
31
  };
32
32
  Icon.set('speech-recognize', speechRecognizeIcon);
33
33
  Config.prototype.controls.speechRecognize = {
34
+ isVisible(j) {
35
+ return Boolean(j.o.speechRecognize.api);
36
+ },
34
37
  isActive(jodit, _) {
35
38
  const api = dataBind(jodit, 'speech');
36
39
  return Boolean(api?.isEnabled);
@@ -39,14 +42,14 @@ Config.prototype.controls.speechRecognize = {
39
42
  return !jodit.o.speechRecognize.api;
40
43
  },
41
44
  exec(jodit, current, { button, control }) {
42
- const { api: Api, lang, continuous, interimResults, sound } = jodit.o.speechRecognize;
43
- if (!Api) {
45
+ const { api: ApiConstructor, lang, continuous, interimResults, sound } = jodit.o.speechRecognize;
46
+ if (!ApiConstructor) {
44
47
  jodit.alert('Speech recognize API unsupported in your browser');
45
48
  return;
46
49
  }
47
50
  let api = dataBind(jodit, 'speech');
48
51
  if (!api) {
49
- const nativeApi = new Api();
52
+ const nativeApi = new ApiConstructor();
50
53
  api = new RecognizeManager(jodit.async, nativeApi);
51
54
  api.lang = lang;
52
55
  api.continuous = continuous;
@@ -58,7 +61,9 @@ Config.prototype.controls.speechRecognize = {
58
61
  });
59
62
  api.on('result', (text) => jodit.e.fire('speechRecognizeResult', text));
60
63
  api.on('progress', (text) => jodit.e.fire('speechRecognizeProgressResult', text));
64
+ api.on('error', (text) => jodit.message.error(text));
61
65
  button.hookStatus('beforeDestruct', () => {
66
+ dataBind(jodit, 'speech', null);
62
67
  api.destruct();
63
68
  });
64
69
  }
@@ -73,6 +78,9 @@ Config.prototype.controls.speechRecognize = {
73
78
  }
74
79
  }
75
80
  api.toggle();
81
+ if (api.isEnabled) {
82
+ button.setMod('pulse', true);
83
+ }
76
84
  button.state.activated = api.isEnabled;
77
85
  },
78
86
  name: 'speechRecognize',
@@ -41,8 +41,9 @@ export declare class RecognizeManager extends Eventify<{
41
41
  private readonly _api;
42
42
  private __on;
43
43
  private __off;
44
- private _progressTimeout;
45
- private _onResult;
44
+ private _onResults;
45
+ private __interimResults;
46
+ private _onProgress;
46
47
  private _onError;
47
48
  private _makeSound;
48
49
  }
@@ -60,7 +60,7 @@ let RecognizeManager = RecognizeManager_1 = class RecognizeManager extends Event
60
60
  }, 5000);
61
61
  this.emit('pulse', true);
62
62
  };
63
- this._progressTimeout = 0;
63
+ this.__interimResults = '';
64
64
  this._api = api;
65
65
  RecognizeManager_1._instances.add(this);
66
66
  }
@@ -82,23 +82,29 @@ let RecognizeManager = RecognizeManager_1 = class RecognizeManager extends Event
82
82
  instance.stop();
83
83
  }
84
84
  });
85
- this._api.start();
85
+ try {
86
+ this._api.start();
87
+ }
88
+ catch (e) {
89
+ this._onError(e);
90
+ this.stop();
91
+ return;
92
+ }
86
93
  this.__on('speechstart', this._onSpeechStart)
87
94
  .__on('error', this._onError)
88
- .__on('result', this._onResult);
95
+ .__on('result', this._onProgress)
96
+ .__on('end', this._onResults);
89
97
  }
90
98
  stop() {
91
99
  if (!this._isEnabled) {
92
100
  return;
93
101
  }
94
- try {
95
- this._api.abort();
96
- this._api.stop();
97
- }
98
- catch { }
102
+ this._api.abort();
103
+ this._api.stop();
99
104
  this.__off('speechstart', this._onSpeechStart)
100
105
  .__off('error', this._onError)
101
- .__off('result', this._onResult);
106
+ .__off('result', this._onProgress)
107
+ .__off('end', this._onResults);
102
108
  this.async.clearTimeout(this._restartTimeout);
103
109
  this._isEnabled = false;
104
110
  this.emit('pulse', false);
@@ -123,37 +129,45 @@ let RecognizeManager = RecognizeManager_1 = class RecognizeManager extends Event
123
129
  this._api.removeEventListener(event, callback);
124
130
  return this;
125
131
  }
126
- _onResult(e) {
132
+ _onResults(e) {
133
+ this.emit('pulse', false);
134
+ this.emit('result', this.__interimResults);
135
+ this.__interimResults = '';
136
+ this._makeSound(PII);
137
+ this.restart();
138
+ }
139
+ _onProgress(e) {
127
140
  if (!this._isEnabled) {
128
141
  return;
129
142
  }
130
- this.async.clearTimeout(this._progressTimeout);
131
- const resultItem = e.results.item(e.resultIndex);
132
- const { transcript } = resultItem.item(0);
133
- const resultHandler = () => {
134
- try {
135
- this.async.clearTimeout(this._restartTimeout);
136
- this.emit('result', transcript);
137
- }
138
- catch { }
139
- this.restart();
140
- this.emit('pulse', false);
141
- this._makeSound(PII);
142
- };
143
- if (resultItem.isFinal === false) {
144
- this.emit('progress', transcript);
145
- this._progressTimeout = this.async.setTimeout(resultHandler, 500);
143
+ this.__interimResults = '';
144
+ if (!e.results) {
146
145
  return;
147
146
  }
148
- resultHandler();
147
+ for (let i = 0; i < e.results.length; i++) {
148
+ const resultItem = e.results.item(i);
149
+ const { transcript } = resultItem.item(0);
150
+ this.__interimResults += transcript;
151
+ }
152
+ if (this.__interimResults) {
153
+ this.emit('progress', this.__interimResults);
154
+ }
149
155
  }
150
- _onError() {
151
- if (!this._isEnabled) {
152
- return;
156
+ _onError(e) {
157
+ if (e.error === 'voice-unavailable') {
158
+ this.emit('error', 'Voice unavailable');
159
+ }
160
+ if (e.error === 'not-allowed') {
161
+ this.emit('error', 'Not allowed');
162
+ }
163
+ if (e.error === 'language-unavailable' ||
164
+ // @ts-ignore
165
+ e.error === 'language-not-supported') {
166
+ this.emit('error', 'Language unavailable');
153
167
  }
154
168
  this._makeSound(WARN);
155
169
  this.emit('pulse', false);
156
- this.restart();
170
+ this.stop();
157
171
  }
158
172
  _makeSound(frequency) {
159
173
  if (this.sound) {
@@ -15,6 +15,7 @@ export interface ISpeechRecognizeResult {
15
15
  transcript: string;
16
16
  };
17
17
  };
18
+ length: number;
18
19
  };
19
20
  }
20
21
  export interface ISpeechRecognize {
@@ -13,10 +13,14 @@ import { Plugin } from "../../core/plugin";
13
13
  import "./config";
14
14
 
15
15
  export declare class SpeechRecognizeNative extends Plugin implements IPlugin {
16
- constructor(j: IJodit);
16
+ buttons: {
17
+ group: string;
18
+ name: string;
19
+ }[];
17
20
  protected afterInit(jodit: IJodit): void;
18
21
  protected beforeDestruct(jodit: IJodit): void;
19
22
  private messagePopup;
23
+ private __hidePopupTimeout;
20
24
  protected onSpeechRecognizeProgressResult(text: string): void;
21
25
  protected onSpeechRecognizeResult(text: string): void;
22
26
  private _checkCommand;
@@ -13,7 +13,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
13
13
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
14
14
  return c > 3 && r && Object.defineProperty(target, key, r), r;
15
15
  };
16
- import { debounce } from "../../core/decorators/debounce/debounce.js";
17
16
  import { watch } from "../../core/decorators/watch/watch.js";
18
17
  import { Dom } from "../../core/dom/dom.js";
19
18
  import { extendLang } from "../../core/global.js";
@@ -24,15 +23,15 @@ import { Jodit } from "../../jodit.js";
24
23
  import { execSpellCommand } from "./helpers/exec-spell-command.js";
25
24
  import * as langs from "./langs/index.js";
26
25
  export class SpeechRecognizeNative extends Plugin {
27
- constructor(j) {
28
- super(j);
29
- this._commandToWord = {};
30
- if (j.o.speechRecognize.api) {
31
- j.registerButton({
26
+ constructor() {
27
+ super(...arguments);
28
+ this.buttons = [
29
+ {
32
30
  group: 'state',
33
31
  name: 'speechRecognize'
34
- });
35
- }
32
+ }
33
+ ];
34
+ this._commandToWord = {};
36
35
  }
37
36
  afterInit(jodit) {
38
37
  const { commands } = jodit.o.speechRecognize;
@@ -53,23 +52,25 @@ export class SpeechRecognizeNative extends Plugin {
53
52
  });
54
53
  }
55
54
  }
56
- beforeDestruct(jodit) { }
55
+ beforeDestruct(jodit) {
56
+ Dom.safeRemove(this.messagePopup);
57
+ }
57
58
  onSpeechRecognizeProgressResult(text) {
58
59
  if (!this.messagePopup) {
59
60
  this.messagePopup = this.j.create.div('jodit-speech-recognize__popup');
60
61
  }
61
62
  this.j.workplace.appendChild(this.messagePopup);
62
- this.j.async.setTimeout(() => {
63
+ this.j.async.clearTimeout(this.__hidePopupTimeout);
64
+ this.__hidePopupTimeout = this.j.async.setTimeout(() => {
63
65
  Dom.safeRemove(this.messagePopup);
64
- }, {
65
- label: 'onSpeechRecognizeProgressResult',
66
- timeout: 1000
67
- });
66
+ }, 1000);
68
67
  this.messagePopup.innerText = text + '|';
69
68
  }
70
69
  onSpeechRecognizeResult(text) {
71
- const { j } = this, { s } = j;
70
+ this.j.async.clearTimeout(this.__hidePopupTimeout);
72
71
  Dom.safeRemove(this.messagePopup);
72
+ const { j } = this;
73
+ const { s } = j;
73
74
  if (!this._checkCommand(text)) {
74
75
  const { range } = s, node = s.current();
75
76
  if (s.isCollapsed() &&
@@ -100,8 +101,7 @@ export class SpeechRecognizeNative extends Plugin {
100
101
  }
101
102
  }
102
103
  __decorate([
103
- watch(':speechRecognizeProgressResult'),
104
- debounce()
104
+ watch(':speechRecognizeProgressResult')
105
105
  ], SpeechRecognizeNative.prototype, "onSpeechRecognizeProgressResult", null);
106
106
  __decorate([
107
107
  watch(':speechRecognizeResult')
package/esm/types/ui.d.ts CHANGED
@@ -37,6 +37,7 @@ export interface IUIButtonState {
37
37
  value: string | number | boolean;
38
38
  variant: ButtonVariant;
39
39
  type: 'button' | 'submit';
40
+ role: 'button' | 'tab';
40
41
  disabled: boolean;
41
42
  activated: boolean;
42
43
  icon: IUIIconState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jodit",
3
- "version": "4.2.19",
3
+ "version": "4.2.22",
4
4
  "description": "Jodit is an awesome and useful wysiwyg editor with filebrowser",
5
5
  "main": "esm/index.js",
6
6
  "types": "types/index.d.ts",
@@ -36,6 +36,7 @@ export declare class UIButton extends UIElement implements IUIButton {
36
36
  protected button: HTMLElement;
37
37
  protected onChangeSize(): void;
38
38
  protected onChangeType(): void;
39
+ protected onChangeRole(): void;
39
40
  /**
40
41
  * Set size from a parent list
41
42
  */
@@ -17,16 +17,15 @@ export declare class UITooltip extends UIElement {
17
17
  protected render(): string;
18
18
  constructor(view: IViewBased);
19
19
  private __listenClose;
20
- private __addListenersOnClose;
21
- private __removeListenersOnClose;
20
+ private __addListenersOnEnter;
21
+ private __removeListenersOnLeave;
22
22
  private __currentTarget;
23
23
  private __onMouseLeave;
24
24
  private __onMouseEnter;
25
25
  private __delayShowTimeout;
26
26
  private __hideTimeout;
27
- private __delayOpen;
28
27
  private __open;
29
- private __setPosition;
28
+ private __show;
30
29
  private __hide;
31
30
  private __hideDelay;
32
31
  destruct(): void;
@@ -25,6 +25,7 @@ export declare class ToolbarButton<T extends IViewBased = IViewBased> extends UI
25
25
  value: string | number | boolean;
26
26
  variant: import("../../../types").ButtonVariant;
27
27
  type: "button" | "submit";
28
+ role: "button" | "tab";
28
29
  disabled: boolean;
29
30
  activated: boolean;
30
31
  icon: import("../../../types").IUIIconState;
@@ -11,7 +11,7 @@ import type { ISpeechRecognizeConstructor } from "./interface";
11
11
  declare module 'jodit/config' {
12
12
  interface Config {
13
13
  speechRecognize: {
14
- readonly api: ISpeechRecognizeConstructor;
14
+ readonly api: ISpeechRecognizeConstructor | null;
15
15
  /**
16
16
  * Returns and sets the language of the current SpeechRecognition.
17
17
  * If not specified, this defaults to the HTML lang attribute value, or
@@ -41,8 +41,9 @@ export declare class RecognizeManager extends Eventify<{
41
41
  private readonly _api;
42
42
  private __on;
43
43
  private __off;
44
- private _progressTimeout;
45
- private _onResult;
44
+ private _onResults;
45
+ private __interimResults;
46
+ private _onProgress;
46
47
  private _onError;
47
48
  private _makeSound;
48
49
  }
@@ -15,6 +15,7 @@ export interface ISpeechRecognizeResult {
15
15
  transcript: string;
16
16
  };
17
17
  };
18
+ length: number;
18
19
  };
19
20
  }
20
21
  export interface ISpeechRecognize {
@@ -13,10 +13,14 @@ import { Plugin } from "../../core/plugin";
13
13
  import "./config";
14
14
 
15
15
  export declare class SpeechRecognizeNative extends Plugin implements IPlugin {
16
- constructor(j: IJodit);
16
+ buttons: {
17
+ group: string;
18
+ name: string;
19
+ }[];
17
20
  protected afterInit(jodit: IJodit): void;
18
21
  protected beforeDestruct(jodit: IJodit): void;
19
22
  private messagePopup;
23
+ private __hidePopupTimeout;
20
24
  protected onSpeechRecognizeProgressResult(text: string): void;
21
25
  protected onSpeechRecognizeResult(text: string): void;
22
26
  private _checkCommand;
@@ -37,6 +37,7 @@ export interface IUIButtonState {
37
37
  value: string | number | boolean;
38
38
  variant: ButtonVariant;
39
39
  type: 'button' | 'submit';
40
+ role: 'button' | 'tab';
40
41
  disabled: boolean;
41
42
  activated: boolean;
42
43
  icon: IUIIconState;