@ones-editor/editor 5.0.8-beta.h1475.2 → 5.0.8-beta.h1475.4
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/@ones-editor/scroll-container/src/scroll-bar-handle.d.ts +3 -1
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/@ones-editor/ui/src/toolbar/toolbar-handler.d.ts +1 -1
- package/@ones-editor/ui-base/src/command-bar/manual-command-bar.d.ts +2 -0
- package/dist/index.js +54 -19
- package/package.json +1 -1
|
@@ -25,7 +25,7 @@ export default class OnesEditorToolbar implements OnesEditorHoveringBlockFilter,
|
|
|
25
25
|
isInToolbar: (event: MouseEvent) => boolean;
|
|
26
26
|
isInBlock(block: BlockElement, event: MouseEvent): boolean;
|
|
27
27
|
handleButtonClick: (toolbar: AbstractCommandBar, item: CommandItem) => void;
|
|
28
|
-
handleClose: () => void;
|
|
28
|
+
handleClose: (toolbar: AbstractCommandBar) => void;
|
|
29
29
|
handleClosing: (bar: unknown, event: MouseEvent | TouchEvent) => boolean;
|
|
30
30
|
bindEvents(): void;
|
|
31
31
|
unbindEvents(): void;
|
|
@@ -8,12 +8,14 @@ export default abstract class ManualCommandBar extends CommandBar implements Abs
|
|
|
8
8
|
_target: HTMLElement | null;
|
|
9
9
|
private cancelFocus?;
|
|
10
10
|
private focusTimer;
|
|
11
|
+
private focusRestoreGeneration;
|
|
11
12
|
constructor(items: CommandItem[], closeable?: Closeable, manualCommandBarOptions?: CommandBarOptions | undefined);
|
|
12
13
|
handleBeforeClose: (event?: MouseEvent | TouchEvent) => boolean;
|
|
13
14
|
private getFocusOwner;
|
|
14
15
|
private restoreFocusAfterClose;
|
|
15
16
|
private isFocusOwner;
|
|
16
17
|
private handleFocusInteraction;
|
|
18
|
+
private handleWindowBlur;
|
|
17
19
|
private clearFocusTimer;
|
|
18
20
|
setProps: (props: ManualShowCommandBarOptions) => void;
|
|
19
21
|
manualShow(target: HTMLElement, options?: ManualShowCommandBarOptions): void;
|
package/dist/index.js
CHANGED
|
@@ -42935,6 +42935,7 @@ ${codeText}
|
|
|
42935
42935
|
__publicField(this, "_target", null);
|
|
42936
42936
|
__publicField(this, "cancelFocus");
|
|
42937
42937
|
__publicField(this, "focusTimer", null);
|
|
42938
|
+
__publicField(this, "focusRestoreGeneration", 0);
|
|
42938
42939
|
__publicField(this, "handleBeforeClose", (event) => {
|
|
42939
42940
|
var _a;
|
|
42940
42941
|
const focusOwner = this.getFocusOwner();
|
|
@@ -42954,6 +42955,9 @@ ${codeText}
|
|
|
42954
42955
|
this.clearFocusTimer();
|
|
42955
42956
|
}
|
|
42956
42957
|
});
|
|
42958
|
+
__publicField(this, "handleWindowBlur", () => {
|
|
42959
|
+
this.clearFocusTimer();
|
|
42960
|
+
});
|
|
42957
42961
|
__publicField(this, "setProps", (props) => {
|
|
42958
42962
|
var _a;
|
|
42959
42963
|
(_a = this.tippyInstance) == null ? void 0 : _a.setProps(props);
|
|
@@ -42972,19 +42976,24 @@ ${codeText}
|
|
|
42972
42976
|
if (!parentEditor || event && !this.isFocusOwner(event.target)) {
|
|
42973
42977
|
return;
|
|
42974
42978
|
}
|
|
42975
|
-
|
|
42976
|
-
document.addEventListener("
|
|
42979
|
+
const generation = this.focusRestoreGeneration;
|
|
42980
|
+
document.addEventListener("mousedown", this.handleFocusInteraction, true);
|
|
42981
|
+
document.addEventListener("focusin", this.handleFocusInteraction, true);
|
|
42982
|
+
window.addEventListener("blur", this.handleWindowBlur);
|
|
42977
42983
|
this.focusTimer = setTimeout(() => {
|
|
42984
|
+
if (generation !== this.focusRestoreGeneration) {
|
|
42985
|
+
return;
|
|
42986
|
+
}
|
|
42978
42987
|
this.clearFocusTimer();
|
|
42979
42988
|
const input2 = parentEditor.querySelector(".editor-input");
|
|
42980
|
-
if (!target.isConnected || !parentEditor.isConnected || !(input2 == null ? void 0 : input2.isConnected)) {
|
|
42989
|
+
if (this._target !== target || !target.isConnected || !parentEditor.isConnected || !(input2 == null ? void 0 : input2.isConnected) || !document.hasFocus()) {
|
|
42981
42990
|
return;
|
|
42982
42991
|
}
|
|
42983
42992
|
const activeElement = document.activeElement;
|
|
42984
42993
|
if (parentEditor.contains(activeElement)) {
|
|
42985
42994
|
return;
|
|
42986
42995
|
}
|
|
42987
|
-
if (!activeElement || activeElement === document.body || this.isInCommandBar(activeElement)) {
|
|
42996
|
+
if (!activeElement || activeElement === document.body || activeElement === document.documentElement || this.isInCommandBar(activeElement)) {
|
|
42988
42997
|
this.cancelFocus = requestInputFocus(input2);
|
|
42989
42998
|
}
|
|
42990
42999
|
}, 100);
|
|
@@ -42996,14 +43005,16 @@ ${codeText}
|
|
|
42996
43005
|
}
|
|
42997
43006
|
clearFocusTimer() {
|
|
42998
43007
|
var _a;
|
|
43008
|
+
this.focusRestoreGeneration += 1;
|
|
42999
43009
|
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
43000
43010
|
this.cancelFocus = void 0;
|
|
43001
43011
|
if (this.focusTimer !== null) {
|
|
43002
43012
|
clearTimeout(this.focusTimer);
|
|
43003
43013
|
this.focusTimer = null;
|
|
43004
43014
|
}
|
|
43005
|
-
document.removeEventListener("mousedown", this.handleFocusInteraction);
|
|
43006
|
-
document.removeEventListener("focusin", this.handleFocusInteraction);
|
|
43015
|
+
document.removeEventListener("mousedown", this.handleFocusInteraction, true);
|
|
43016
|
+
document.removeEventListener("focusin", this.handleFocusInteraction, true);
|
|
43017
|
+
window.removeEventListener("blur", this.handleWindowBlur);
|
|
43007
43018
|
}
|
|
43008
43019
|
manualShow(target, options) {
|
|
43009
43020
|
var _a, _b, _c, _d;
|
|
@@ -43056,7 +43067,7 @@ ${codeText}
|
|
|
43056
43067
|
}
|
|
43057
43068
|
close(reason, e2) {
|
|
43058
43069
|
var _a, _b;
|
|
43059
|
-
if (reason
|
|
43070
|
+
if (reason === "clickBackground" || reason && reason !== "cancelBar" && reason !== "clickItem") {
|
|
43060
43071
|
this.clearFocusTimer();
|
|
43061
43072
|
}
|
|
43062
43073
|
super.close(reason);
|
|
@@ -49114,6 +49125,8 @@ ${codeText}
|
|
|
49114
49125
|
}
|
|
49115
49126
|
function resetScrollbarCore(scrollCore, scrollWrap) {
|
|
49116
49127
|
const scrollContainer = getScrollContainer(scrollWrap);
|
|
49128
|
+
if (!scrollContainer || !getContainerOption(scrollCore, getContainer(scrollContainer)))
|
|
49129
|
+
return;
|
|
49117
49130
|
const scrollbarContainer = getScrollbarContainer(scrollContainer);
|
|
49118
49131
|
const { scrollWidth, clientWidth } = getElementScrollSize(scrollContainer);
|
|
49119
49132
|
const { paddingLeft, paddingRight } = getScrollWrapPaddingSize(scrollWrap);
|
|
@@ -49130,7 +49143,7 @@ ${codeText}
|
|
|
49130
49143
|
}
|
|
49131
49144
|
function debounceByArgs(func, wait) {
|
|
49132
49145
|
const debouncers = /* @__PURE__ */ new Map();
|
|
49133
|
-
|
|
49146
|
+
const debounced = function(...args) {
|
|
49134
49147
|
var _a;
|
|
49135
49148
|
const scrollWrap = args[1];
|
|
49136
49149
|
let key = (scrollWrap == null ? void 0 : scrollWrap.genId) || "";
|
|
@@ -49142,17 +49155,30 @@ ${codeText}
|
|
|
49142
49155
|
if (!debouncers.has(key)) {
|
|
49143
49156
|
debouncers.set(key, debounce__default.default(
|
|
49144
49157
|
(...innerArgs) => {
|
|
49145
|
-
|
|
49146
|
-
|
|
49147
|
-
|
|
49148
|
-
|
|
49149
|
-
|
|
49158
|
+
try {
|
|
49159
|
+
return func.apply(this, innerArgs);
|
|
49160
|
+
} finally {
|
|
49161
|
+
if (scrollWrap)
|
|
49162
|
+
scrollWrap.genId = void 0;
|
|
49163
|
+
debouncers.delete(key);
|
|
49164
|
+
}
|
|
49150
49165
|
},
|
|
49151
49166
|
wait
|
|
49152
49167
|
));
|
|
49153
49168
|
}
|
|
49154
49169
|
return (_a = debouncers.get(key)) == null ? void 0 : _a.apply(this, args);
|
|
49155
49170
|
};
|
|
49171
|
+
debounced.cancel = (scrollWrap) => {
|
|
49172
|
+
var _a, _b;
|
|
49173
|
+
const target = scrollWrap;
|
|
49174
|
+
const key = target.genId;
|
|
49175
|
+
if (!key)
|
|
49176
|
+
return;
|
|
49177
|
+
(_b = (_a = debouncers.get(key)) == null ? void 0 : _a.cancel) == null ? void 0 : _b.call(_a);
|
|
49178
|
+
debouncers.delete(key);
|
|
49179
|
+
target.genId = void 0;
|
|
49180
|
+
};
|
|
49181
|
+
return debounced;
|
|
49156
49182
|
}
|
|
49157
49183
|
const resetScrollbar = debounceByArgs(resetScrollbarCore, 50);
|
|
49158
49184
|
function resetScrollbarLeft(scrollContainer, scrollbarContainer) {
|
|
@@ -49647,6 +49673,7 @@ ${codeText}
|
|
|
49647
49673
|
}
|
|
49648
49674
|
unbindCore(scrollContainer, scrollWrap) {
|
|
49649
49675
|
var _a, _b, _c, _d, _e, _f;
|
|
49676
|
+
resetScrollbar.cancel(scrollWrap);
|
|
49650
49677
|
if (!this.boundContainers.delete(scrollContainer))
|
|
49651
49678
|
return;
|
|
49652
49679
|
const scrollbarContainer = getScrollbarContainer(scrollContainer);
|
|
@@ -55788,8 +55815,15 @@ ${codeText}
|
|
|
55788
55815
|
}
|
|
55789
55816
|
this._lastClickTime = Date.now();
|
|
55790
55817
|
});
|
|
55791
|
-
__publicField(this, "handleClose", () => {
|
|
55818
|
+
__publicField(this, "handleClose", (toolbar2) => {
|
|
55792
55819
|
var _a, _b;
|
|
55820
|
+
if (toolbar2.closeReason === "clickBackground" || !this.editor.rootElement.isConnected) {
|
|
55821
|
+
return;
|
|
55822
|
+
}
|
|
55823
|
+
const focusedElement = document.activeElement;
|
|
55824
|
+
if (focusedElement && focusedElement !== document.body && focusedElement !== document.documentElement && !this.editor.rootElement.contains(focusedElement) && !toolbar2.isInCommandBar(focusedElement)) {
|
|
55825
|
+
return;
|
|
55826
|
+
}
|
|
55793
55827
|
if (shouldFocusToEditor(this.editor) && !clientType.isMobile) {
|
|
55794
55828
|
const activeElement = (_a = document.getSelection()) == null ? void 0 : _a.focusNode;
|
|
55795
55829
|
if (activeElement && isInBlockTools(activeElement)) {
|
|
@@ -74494,10 +74528,11 @@ ${codeText}
|
|
|
74494
74528
|
createTableBorderBar(editor, tableBlock);
|
|
74495
74529
|
}
|
|
74496
74530
|
function hideTableBorderBar(editor, tableBlock) {
|
|
74531
|
+
var _a, _b;
|
|
74497
74532
|
assert(logger$14, isTableBlock(tableBlock), "invalid table block");
|
|
74498
|
-
const tools =
|
|
74533
|
+
const tools = (_a = getBlockContent(tableBlock).querySelector("div[data-type=table-content]")) == null ? void 0 : _a.querySelector(":scope >div[data-type=table-tools]");
|
|
74499
74534
|
const blockTools = getBlockTools(tableBlock);
|
|
74500
|
-
const topTableBorderBar = tools.querySelectorAll(".table-border-bar-container");
|
|
74535
|
+
const topTableBorderBar = (_b = tools == null ? void 0 : tools.querySelectorAll(".table-border-bar-container")) != null ? _b : [];
|
|
74501
74536
|
const leftTableBorderBar = blockTools.querySelectorAll(".table-border-bar-container");
|
|
74502
74537
|
topTableBorderBar.forEach((elem) => {
|
|
74503
74538
|
editor.domEvents.removeEventListener(elem, "click", handleBorderBarClicked);
|
|
@@ -98355,7 +98390,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98355
98390
|
}
|
|
98356
98391
|
}
|
|
98357
98392
|
});
|
|
98358
|
-
editor.version = "5.0.8-beta.h1475.
|
|
98393
|
+
editor.version = "5.0.8-beta.h1475.4";
|
|
98359
98394
|
return editor;
|
|
98360
98395
|
}
|
|
98361
98396
|
function isDoc(doc2) {
|
|
@@ -98491,7 +98526,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98491
98526
|
OnesEditorDropTarget.register(editor);
|
|
98492
98527
|
OnesEditorTocProvider.register(editor);
|
|
98493
98528
|
OnesEditorExclusiveBlock.register(editor);
|
|
98494
|
-
editor.version = "5.0.8-beta.h1475.
|
|
98529
|
+
editor.version = "5.0.8-beta.h1475.4";
|
|
98495
98530
|
return editor;
|
|
98496
98531
|
} catch (error2) {
|
|
98497
98532
|
try {
|
|
@@ -98634,7 +98669,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98634
98669
|
}
|
|
98635
98670
|
}
|
|
98636
98671
|
});
|
|
98637
|
-
editor.version = "5.0.8-beta.h1475.
|
|
98672
|
+
editor.version = "5.0.8-beta.h1475.4";
|
|
98638
98673
|
return editor;
|
|
98639
98674
|
}
|
|
98640
98675
|
const emojis$1 = {
|