jodit 4.2.21 → 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.
- package/CHANGELOG.md +9 -5
- package/es2015/jodit.css +1 -1
- package/es2015/jodit.fat.min.css +1 -1
- package/es2015/jodit.fat.min.js +2 -2
- package/es2015/jodit.js +2 -2
- package/es2015/jodit.min.js +2 -2
- package/es2015/plugins/debug/debug.js +1 -1
- package/es2015/plugins/debug/debug.min.js +1 -1
- package/es2015/plugins/speech-recognize/speech-recognize.css +3 -2
- package/es2015/plugins/speech-recognize/speech-recognize.js +98 -77
- package/es2015/plugins/speech-recognize/speech-recognize.min.css +1 -1
- package/es2015/plugins/speech-recognize/speech-recognize.min.js +2 -2
- package/es2018/jodit.css +1 -1
- package/es2018/jodit.fat.min.css +1 -1
- package/es2018/jodit.fat.min.js +2 -2
- package/es2018/jodit.js +2 -2
- package/es2018/jodit.min.js +2 -2
- package/es2018/plugins/debug/debug.js +1 -1
- package/es2018/plugins/debug/debug.min.js +1 -1
- package/es2018/plugins/speech-recognize/speech-recognize.css +3 -2
- package/es2018/plugins/speech-recognize/speech-recognize.js +98 -77
- package/es2018/plugins/speech-recognize/speech-recognize.min.css +1 -1
- package/es2018/plugins/speech-recognize/speech-recognize.min.js +2 -2
- package/es2021/jodit.css +1 -1
- package/es2021/jodit.fat.min.css +1 -1
- package/es2021/jodit.fat.min.js +2 -2
- package/es2021/jodit.js +2 -2
- package/es2021/jodit.min.js +2 -2
- package/es2021/plugins/debug/debug.js +1 -1
- package/es2021/plugins/debug/debug.min.js +1 -1
- package/es2021/plugins/speech-recognize/speech-recognize.css +3 -2
- package/es2021/plugins/speech-recognize/speech-recognize.js +98 -77
- package/es2021/plugins/speech-recognize/speech-recognize.min.css +1 -1
- package/es2021/plugins/speech-recognize/speech-recognize.min.js +2 -2
- package/es2021.en/jodit.css +1 -1
- package/es2021.en/jodit.fat.min.css +1 -1
- package/es2021.en/jodit.fat.min.js +2 -2
- package/es2021.en/jodit.js +2 -2
- package/es2021.en/jodit.min.js +2 -2
- package/es2021.en/plugins/debug/debug.js +1 -1
- package/es2021.en/plugins/debug/debug.min.js +1 -1
- package/es2021.en/plugins/speech-recognize/speech-recognize.css +3 -2
- package/es2021.en/plugins/speech-recognize/speech-recognize.js +98 -77
- package/es2021.en/plugins/speech-recognize/speech-recognize.min.css +1 -1
- package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +2 -2
- package/es5/jodit.css +2 -2
- package/es5/jodit.fat.min.css +1 -1
- package/es5/jodit.fat.min.js +2 -2
- package/es5/jodit.js +2 -2
- package/es5/jodit.min.css +2 -2
- package/es5/jodit.min.js +2 -2
- package/es5/plugins/debug/debug.js +1 -1
- package/es5/plugins/debug/debug.min.js +1 -1
- package/es5/plugins/speech-recognize/speech-recognize.css +3 -2
- package/es5/plugins/speech-recognize/speech-recognize.js +99 -79
- package/es5/plugins/speech-recognize/speech-recognize.min.css +1 -1
- package/es5/plugins/speech-recognize/speech-recognize.min.js +2 -2
- package/esm/core/constants.js +1 -1
- package/esm/plugins/speech-recognize/config.d.ts +1 -1
- package/esm/plugins/speech-recognize/config.js +13 -5
- package/esm/plugins/speech-recognize/helpers/recognize-manager.d.ts +3 -2
- package/esm/plugins/speech-recognize/helpers/recognize-manager.js +45 -31
- package/esm/plugins/speech-recognize/interface.d.ts +1 -0
- package/esm/plugins/speech-recognize/speech-recognize.d.ts +5 -1
- package/esm/plugins/speech-recognize/speech-recognize.js +17 -17
- package/package.json +1 -1
- package/types/plugins/speech-recognize/config.d.ts +1 -1
- package/types/plugins/speech-recognize/helpers/recognize-manager.d.ts +3 -2
- package/types/plugins/speech-recognize/interface.d.ts +1 -0
- package/types/plugins/speech-recognize/speech-recognize.d.ts +5 -1
|
@@ -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.
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
95
|
-
|
|
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.
|
|
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
|
-
|
|
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.
|
|
131
|
-
|
|
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
|
-
|
|
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 (
|
|
152
|
-
|
|
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.
|
|
170
|
+
this.stop();
|
|
157
171
|
}
|
|
158
172
|
_makeSound(frequency) {
|
|
159
173
|
if (this.sound) {
|
|
@@ -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
|
-
|
|
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(
|
|
28
|
-
super(
|
|
29
|
-
this.
|
|
30
|
-
|
|
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.
|
|
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
|
-
|
|
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/package.json
CHANGED
|
@@ -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
|
|
45
|
-
private
|
|
44
|
+
private _onResults;
|
|
45
|
+
private __interimResults;
|
|
46
|
+
private _onProgress;
|
|
46
47
|
private _onError;
|
|
47
48
|
private _makeSound;
|
|
48
49
|
}
|
|
@@ -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
|
-
|
|
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;
|