tiny-markdown-editor 0.2.2 → 0.2.3
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/dist/tiny-mde.js +10 -2
- package/dist/tiny-mde.min.js +1 -1
- package/dist/tiny-mde.tiny.js +1 -1
- package/lib/TinyMDE.d.ts +1 -0
- package/lib/TinyMDE.js +9 -1
- package/package.json +1 -1
package/lib/TinyMDE.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export declare class Editor {
|
|
|
42
42
|
lastCommandState: Record<string, boolean | null> | null;
|
|
43
43
|
private customInlineGrammar;
|
|
44
44
|
private mergedInlineGrammar;
|
|
45
|
+
private hasFocus;
|
|
45
46
|
listeners: {
|
|
46
47
|
change: EventHandler<ChangeEvent>[];
|
|
47
48
|
selection: EventHandler<SelectionEvent>[];
|
package/lib/TinyMDE.js
CHANGED
|
@@ -16,6 +16,7 @@ class Editor {
|
|
|
16
16
|
this.lastCommandState = null;
|
|
17
17
|
this.customInlineGrammar = {};
|
|
18
18
|
this.mergedInlineGrammar = grammar_1.inlineGrammar;
|
|
19
|
+
this.hasFocus = true;
|
|
19
20
|
this.listeners = {
|
|
20
21
|
change: [],
|
|
21
22
|
selection: [],
|
|
@@ -35,6 +36,7 @@ class Editor {
|
|
|
35
36
|
this.linkLabels = [];
|
|
36
37
|
this.lineDirty = [];
|
|
37
38
|
this.lastCommandState = null;
|
|
39
|
+
this.hasFocus = true;
|
|
38
40
|
this.customInlineGrammar = props.customInlineGrammar || {};
|
|
39
41
|
this.mergedInlineGrammar = (0, grammar_1.createMergedInlineGrammar)(this.customInlineGrammar);
|
|
40
42
|
this.listeners = {
|
|
@@ -174,7 +176,13 @@ class Editor {
|
|
|
174
176
|
}
|
|
175
177
|
this.e.addEventListener("input", (e) => this.handleInputEvent(e));
|
|
176
178
|
this.e.addEventListener("compositionend", (e) => this.handleInputEvent(e));
|
|
177
|
-
document.addEventListener("selectionchange", (e) =>
|
|
179
|
+
document.addEventListener("selectionchange", (e) => {
|
|
180
|
+
if (this.hasFocus) {
|
|
181
|
+
this.handleSelectionChangeEvent(e);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
this.e.addEventListener("blur", () => this.hasFocus = false);
|
|
185
|
+
this.e.addEventListener("focus", () => this.hasFocus = true);
|
|
178
186
|
this.e.addEventListener("paste", (e) => this.handlePaste(e));
|
|
179
187
|
this.e.addEventListener("drop", (e) => this.handleDrop(e));
|
|
180
188
|
this.lineElements = this.e.childNodes;
|