@dou-ui/code 0.1.0-alpha.0 → 0.1.0-alpha.2
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/code-editor.js.map +1 -1
- package/dist/code-editor.vue_vue_type_script_setup_true_lang.js +234 -73
- package/dist/code-editor.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/code-keys.vue_vue_type_script_setup_true_lang.js +138 -62
- package/dist/code-keys.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/code-keys2.js.map +1 -1
- package/dist/locale.js +6 -12
- package/dist/locale.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/code-diff.vue.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/locale.d.ts +5 -5
- package/dist/types/types.d.ts +2 -2
- package/dist/types/view/viewport.d.ts +16 -0
- package/dist/types/view/viewport.test.d.ts +1 -0
- package/dist/view/viewport.js +31 -0
- package/dist/view/viewport.js.map +1 -0
- package/package.json +3 -3
|
@@ -13,6 +13,7 @@ import { lineParts, tokenTypes } from "./language/language.js";
|
|
|
13
13
|
import { CodeHighlighter } from "./language/highlighter.js";
|
|
14
14
|
import { SyntaxWorkerClient, holdWorker, ownWorker } from "./language/worker-client.js";
|
|
15
15
|
import { format, useCodeMessages } from "./locale.js";
|
|
16
|
+
import { visibleViewport } from "./view/viewport.js";
|
|
16
17
|
import code_keys_default from "./code-keys2.js";
|
|
17
18
|
import { CODE_EDITOR_KEY } from "./extension.js";
|
|
18
19
|
import render_part_default from "./render-part.js";
|
|
@@ -23,7 +24,7 @@ import { LineLayout, UNWRAPPED, rowOfCol, updateRows, wrapLine } from "./view/la
|
|
|
23
24
|
import { Measure } from "./view/measure.js";
|
|
24
25
|
import { DouFindReplace, DouToggle, DouTooltip, holdPointer, isApplePlatform, isComposing, scrollPositionOf, useLocale, useNamespace, useTeleport, useZIndex } from "dou-ui";
|
|
25
26
|
import { Fragment, Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, getCurrentInstance, isMemoSame, markRaw, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, provide, reactive, ref, renderList, resolveDynamicComponent, shallowReactive, shallowRef, toDisplayString, toRaw, unref, watch, withCtx, withModifiers } from "vue";
|
|
26
|
-
import { AlertTriangleIcon, ChevronDownIcon, ChevronRightIcon, FunctionIcon, InfoIcon, LetterCaseIcon, LightbulbIcon, PackageIcon, RegexIcon, SquareCodeIcon, SymbolClassIcon, SymbolConstantIcon, SymbolKeywordIcon, SymbolTypeAliasIcon, TypeIcon, VariableIcon, WholeWordIcon, WrenchIcon, XCircleIcon } from "@dou-ui/icons";
|
|
27
|
+
import { AlertTriangleIcon, ChevronDownIcon, ChevronRightIcon, FunctionIcon, GripVerticalIcon, InfoIcon, LetterCaseIcon, LightbulbIcon, PackageIcon, RegexIcon, SquareCodeIcon, SymbolClassIcon, SymbolConstantIcon, SymbolKeywordIcon, SymbolTypeAliasIcon, TypeIcon, VariableIcon, WholeWordIcon, WrenchIcon, XCircleIcon } from "@dou-ui/icons";
|
|
27
28
|
// src/code-editor.vue?vue&type=script&setup=true&lang.ts
|
|
28
29
|
var _hoisted_1 = [
|
|
29
30
|
"title",
|
|
@@ -57,6 +58,7 @@ var _hoisted_16 = [
|
|
|
57
58
|
"disabled"
|
|
58
59
|
];
|
|
59
60
|
var _hoisted_17 = ["role", "aria-label"];
|
|
61
|
+
var _hoisted_18 = ["aria-label", "title"];
|
|
60
62
|
var MAX_HEIGHT = 8e6;
|
|
61
63
|
var OVERSCAN = 6;
|
|
62
64
|
/** The textarea mirrors at most this much text around the cursor. */
|
|
@@ -69,6 +71,8 @@ var GAP = 8;
|
|
|
69
71
|
var HANDLE = 24;
|
|
70
72
|
var KEYS_HEIGHT = 44;
|
|
71
73
|
var KEYS_GAP = 8;
|
|
74
|
+
var TABBABLE = "a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]";
|
|
75
|
+
/** Tab out of the bar goes on to what follows the editor; Shift+Tab, or Escape, back into it. */
|
|
72
76
|
var MINI_ROW = 2;
|
|
73
77
|
var MINI_CELL = 1;
|
|
74
78
|
/** The minimap's width, padding included. */
|
|
@@ -2590,9 +2594,13 @@ var code_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
2590
2594
|
}
|
|
2591
2595
|
bumpViewport();
|
|
2592
2596
|
}
|
|
2593
|
-
|
|
2597
|
+
/** Whether the focus is on the bar of keys itself, reached by Escape then Tab: the bar stays while it is. */
|
|
2598
|
+
const keysFocused = ref(false);
|
|
2599
|
+
/** The bar of keys, on a touch screen while the editor takes input, or while the focus is on it. */
|
|
2600
|
+
const showKeys = computed(() => !!props.keys && coarse.value && (focused.value || keysFocused.value) && !props.readonly && !props.disabled);
|
|
2601
|
+
const floatingOpen = computed(() => !!(problemBox.value || completion.value || signature.value) || touchUi.value && focused.value || showKeys.value);
|
|
2594
2602
|
watch(floatingOpen, (open, _old, onCleanup) => {
|
|
2595
|
-
if (!open ||
|
|
2603
|
+
if (!open || typeof window === "undefined") return;
|
|
2596
2604
|
floatingZ.value = nextZIndex();
|
|
2597
2605
|
readFrameFont();
|
|
2598
2606
|
readAnchorMode();
|
|
@@ -2648,16 +2656,12 @@ var code_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
2648
2656
|
*/
|
|
2649
2657
|
function pageBox() {
|
|
2650
2658
|
viewportTick.value;
|
|
2651
|
-
const
|
|
2652
|
-
const left = vv ? vv.offsetLeft : 0;
|
|
2653
|
-
const top = vv ? vv.offsetTop : 0;
|
|
2654
|
-
const width = vv ? vv.width : document.documentElement.clientWidth;
|
|
2655
|
-
const height = vv ? vv.height : document.documentElement.clientHeight;
|
|
2659
|
+
const { left, top, width, height } = visibleViewport();
|
|
2656
2660
|
return {
|
|
2657
2661
|
left,
|
|
2658
2662
|
top,
|
|
2659
2663
|
right: left + width,
|
|
2660
|
-
bottom: top + height
|
|
2664
|
+
bottom: top + height
|
|
2661
2665
|
};
|
|
2662
2666
|
}
|
|
2663
2667
|
/** After each change: opens, updates or closes the completion list and the parameter hints, and moves the snippet's places. */
|
|
@@ -3050,7 +3054,14 @@ var code_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3050
3054
|
}
|
|
3051
3055
|
const leaving = tabLeaves && (name === "tab" || name === "shift+tab");
|
|
3052
3056
|
tabLeaves = name === "escape";
|
|
3053
|
-
if (leaving)
|
|
3057
|
+
if (leaving) {
|
|
3058
|
+
const first = name === "tab" && !shownWidgets.value.length ? keysEl.value?.querySelector("button") : null;
|
|
3059
|
+
if (first) {
|
|
3060
|
+
event.preventDefault();
|
|
3061
|
+
first.focus();
|
|
3062
|
+
}
|
|
3063
|
+
return;
|
|
3064
|
+
}
|
|
3054
3065
|
for (const command of keymap.value.get(name) ?? []) if (command(target)) {
|
|
3055
3066
|
event.preventDefault();
|
|
3056
3067
|
event.stopPropagation();
|
|
@@ -3735,7 +3746,6 @@ var code_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3735
3746
|
caret
|
|
3736
3747
|
};
|
|
3737
3748
|
});
|
|
3738
|
-
const showKeys = computed(() => !!props.keys && coarse.value && focused.value && !props.readonly && !props.disabled);
|
|
3739
3749
|
const keysList = computed(() => Array.isArray(props.keys) ? props.keys : void 0);
|
|
3740
3750
|
const keysEditor = { run };
|
|
3741
3751
|
const { next: nextZIndex } = useZIndex();
|
|
@@ -3744,41 +3754,189 @@ var code_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3744
3754
|
if (shown) keysZIndex.value = nextZIndex();
|
|
3745
3755
|
});
|
|
3746
3756
|
/**
|
|
3747
|
-
* The bar of keys
|
|
3748
|
-
*
|
|
3749
|
-
*
|
|
3757
|
+
* The bar of keys sits in the page below the editor, and scrolls with it:
|
|
3758
|
+
* it never follows the keyboard, whose bars and panels each browser draws
|
|
3759
|
+
* its own way. A finger moves it anywhere by its grip, and it keeps that
|
|
3760
|
+
* place by the editor while the editor is in use.
|
|
3750
3761
|
*/
|
|
3751
|
-
const
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3762
|
+
const keysEl = ref();
|
|
3763
|
+
/** Where the bar is, from the editor's top left corner; `null` until it first shows. */
|
|
3764
|
+
const keysAt = ref(null);
|
|
3765
|
+
/** Whether a finger or a key moved the bar: then it stays put, even as the keyboard comes up. */
|
|
3766
|
+
let keysMoved = false;
|
|
3767
|
+
const keysShift = ref({
|
|
3768
|
+
x: 0,
|
|
3769
|
+
y: 0
|
|
3757
3770
|
});
|
|
3758
|
-
function
|
|
3759
|
-
const
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3771
|
+
function readKeysShift() {
|
|
3772
|
+
const el = keysEl.value;
|
|
3773
|
+
if (!el) return;
|
|
3774
|
+
const rect = el.getBoundingClientRect();
|
|
3775
|
+
const at = keysClient.value;
|
|
3776
|
+
if (!at) return;
|
|
3777
|
+
keysShift.value = {
|
|
3778
|
+
x: keysShift.value.x + at.x - rect.left,
|
|
3779
|
+
y: keysShift.value.y + at.y - rect.top
|
|
3780
|
+
};
|
|
3781
|
+
}
|
|
3782
|
+
/** The editor's box in the window, as of the last scroll. */
|
|
3783
|
+
function rootInPage() {
|
|
3784
|
+
viewportTick.value;
|
|
3785
|
+
return root.value?.getBoundingClientRect() ?? null;
|
|
3786
|
+
}
|
|
3787
|
+
/** The bar's width: the editor's, within the window. */
|
|
3788
|
+
const keysWidth = computed(() => {
|
|
3789
|
+
const rect = rootInPage();
|
|
3790
|
+
if (!rect) return 0;
|
|
3791
|
+
return Math.max(0, Math.min(rect.width, visibleViewport().width - 16));
|
|
3792
|
+
});
|
|
3793
|
+
/** Keeps the bar within the part of the page in view. */
|
|
3794
|
+
function clampKeys(at) {
|
|
3795
|
+
const rect = rootInPage();
|
|
3796
|
+
if (!rect) return at;
|
|
3797
|
+
const view = visibleViewport();
|
|
3798
|
+
const x = rect.left + at.x;
|
|
3799
|
+
const y = rect.top + at.y;
|
|
3800
|
+
const left = Math.max(view.left + KEYS_GAP, Math.min(x, view.left + view.width - keysWidth.value - KEYS_GAP));
|
|
3801
|
+
const top = Math.max(view.top + KEYS_GAP, Math.min(y, view.top + view.height - KEYS_HEIGHT - KEYS_GAP));
|
|
3802
|
+
return {
|
|
3803
|
+
x: left - rect.left,
|
|
3804
|
+
y: top - rect.top
|
|
3770
3805
|
};
|
|
3771
3806
|
}
|
|
3807
|
+
/** Below the editor, a gap apart, or as low as the page in view goes. */
|
|
3808
|
+
function placeKeys() {
|
|
3809
|
+
const rect = rootInPage();
|
|
3810
|
+
if (!rect) return;
|
|
3811
|
+
keysAt.value = clampKeys({
|
|
3812
|
+
x: 0,
|
|
3813
|
+
y: rect.height + KEYS_GAP
|
|
3814
|
+
});
|
|
3815
|
+
}
|
|
3816
|
+
const keysClient = computed(() => {
|
|
3817
|
+
const rect = rootInPage();
|
|
3818
|
+
const at = keysAt.value;
|
|
3819
|
+
return rect && at ? {
|
|
3820
|
+
x: rect.left + at.x,
|
|
3821
|
+
y: rect.top + at.y
|
|
3822
|
+
} : null;
|
|
3823
|
+
});
|
|
3772
3824
|
const keysStyle = computed(() => {
|
|
3773
|
-
const
|
|
3825
|
+
const at = keysClient.value;
|
|
3826
|
+
if (!at) return {
|
|
3827
|
+
visibility: "hidden",
|
|
3828
|
+
zIndex: keysZIndex.value
|
|
3829
|
+
};
|
|
3774
3830
|
return {
|
|
3775
|
-
transform: `translate(${
|
|
3776
|
-
width: `${
|
|
3831
|
+
transform: `translate(${at.x + keysShift.value.x}px, ${at.y + keysShift.value.y}px)`,
|
|
3832
|
+
width: `${keysWidth.value}px`,
|
|
3777
3833
|
zIndex: keysZIndex.value
|
|
3778
3834
|
};
|
|
3779
3835
|
});
|
|
3836
|
+
watch(showKeys, (shown) => {
|
|
3837
|
+
if (!shown) keysFocused.value = false;
|
|
3838
|
+
else if (typeof window !== "undefined") settleKeys();
|
|
3839
|
+
});
|
|
3780
3840
|
/**
|
|
3781
|
-
*
|
|
3841
|
+
* Brings the bar into the page in view: not moved yet, to its place below
|
|
3842
|
+
* the editor; moved, only as far as it takes to be seen again.
|
|
3843
|
+
*/
|
|
3844
|
+
function settleKeys() {
|
|
3845
|
+
if (!showKeys.value) return;
|
|
3846
|
+
if (keysMoved && keysAt.value) keysAt.value = clampKeys(keysAt.value);
|
|
3847
|
+
else placeKeys();
|
|
3848
|
+
}
|
|
3849
|
+
/** How much of the bottom of the page in view the bar takes, when it sits there. */
|
|
3850
|
+
function keysRoom() {
|
|
3851
|
+
const rect = showKeys.value && keysAt.value ? root.value?.getBoundingClientRect() : null;
|
|
3852
|
+
if (!rect || !keysAt.value) return 0;
|
|
3853
|
+
const view = visibleViewport();
|
|
3854
|
+
const bottom = view.top + view.height;
|
|
3855
|
+
const top = rect.top + keysAt.value.y;
|
|
3856
|
+
return top + KEYS_HEIGHT >= bottom - KEYS_GAP - 1 ? bottom - top + KEYS_GAP : 0;
|
|
3857
|
+
}
|
|
3858
|
+
function onKeysKeydown(event) {
|
|
3859
|
+
const bar = keysEl.value;
|
|
3860
|
+
if (!bar) return;
|
|
3861
|
+
if (event.key === "Escape") {
|
|
3862
|
+
event.preventDefault();
|
|
3863
|
+
input.value?.focus();
|
|
3864
|
+
return;
|
|
3865
|
+
}
|
|
3866
|
+
if (event.key !== "Tab") return;
|
|
3867
|
+
const inside = [...bar.querySelectorAll(TABBABLE)].filter((el) => el.tabIndex >= 0);
|
|
3868
|
+
const here = inside.indexOf(document.activeElement);
|
|
3869
|
+
if (event.shiftKey && here <= 0) {
|
|
3870
|
+
event.preventDefault();
|
|
3871
|
+
input.value?.focus();
|
|
3872
|
+
} else if (!event.shiftKey && here === inside.length - 1) {
|
|
3873
|
+
event.preventDefault();
|
|
3874
|
+
const from = document.activeElement;
|
|
3875
|
+
for (const el of document.querySelectorAll(TABBABLE)) {
|
|
3876
|
+
if (el.tabIndex < 0 || bar.contains(el) || !root.value || root.value.contains(el) || !(root.value.compareDocumentPosition(el) & Node.DOCUMENT_POSITION_FOLLOWING)) continue;
|
|
3877
|
+
el.focus();
|
|
3878
|
+
if (document.activeElement === el) return;
|
|
3879
|
+
}
|
|
3880
|
+
from?.blur();
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3883
|
+
function onKeysFocusOut(event) {
|
|
3884
|
+
if (!keysEl.value?.contains(event.relatedTarget)) keysFocused.value = false;
|
|
3885
|
+
}
|
|
3886
|
+
watch([showKeys, viewportTick], () => readKeysShift(), { flush: "post" });
|
|
3887
|
+
/** A finger on the bar's grip: where it went down, and where the bar was then. */
|
|
3888
|
+
let keysDrag = null;
|
|
3889
|
+
function onKeysGripDown(event) {
|
|
3890
|
+
if (event.button !== 0 || !keysAt.value) return;
|
|
3891
|
+
event.preventDefault();
|
|
3892
|
+
const hold = holdPointer(event, keysEl.value, endKeysDrag);
|
|
3893
|
+
hold.grab();
|
|
3894
|
+
keysDrag = {
|
|
3895
|
+
pointer: event.pointerId,
|
|
3896
|
+
x: event.clientX,
|
|
3897
|
+
y: event.clientY,
|
|
3898
|
+
from: keysAt.value,
|
|
3899
|
+
hold
|
|
3900
|
+
};
|
|
3901
|
+
window.addEventListener("pointermove", onKeysGripMove);
|
|
3902
|
+
window.addEventListener("pointerup", endKeysDrag);
|
|
3903
|
+
window.addEventListener("pointercancel", endKeysDrag);
|
|
3904
|
+
}
|
|
3905
|
+
function onKeysGripMove(event) {
|
|
3906
|
+
const press = keysDrag;
|
|
3907
|
+
if (!press || event.pointerId !== press.pointer) return;
|
|
3908
|
+
keysMoved = true;
|
|
3909
|
+
keysAt.value = clampKeys({
|
|
3910
|
+
x: press.from.x + event.clientX - press.x,
|
|
3911
|
+
y: press.from.y + event.clientY - press.y
|
|
3912
|
+
});
|
|
3913
|
+
}
|
|
3914
|
+
function endKeysDrag() {
|
|
3915
|
+
keysDrag?.hold.release();
|
|
3916
|
+
keysDrag = null;
|
|
3917
|
+
window.removeEventListener("pointermove", onKeysGripMove);
|
|
3918
|
+
window.removeEventListener("pointerup", endKeysDrag);
|
|
3919
|
+
window.removeEventListener("pointercancel", endKeysDrag);
|
|
3920
|
+
}
|
|
3921
|
+
/** The grip moves by the arrow keys too, a step at a time. */
|
|
3922
|
+
function onKeysGripKey(event) {
|
|
3923
|
+
const step = {
|
|
3924
|
+
ArrowUp: [0, -1],
|
|
3925
|
+
ArrowDown: [0, 1],
|
|
3926
|
+
ArrowLeft: [-1, 0],
|
|
3927
|
+
ArrowRight: [1, 0]
|
|
3928
|
+
}[event.key];
|
|
3929
|
+
if (!step || !keysAt.value) return;
|
|
3930
|
+
event.preventDefault();
|
|
3931
|
+
keysMoved = true;
|
|
3932
|
+
const by = event.shiftKey ? 40 : 8;
|
|
3933
|
+
keysAt.value = clampKeys({
|
|
3934
|
+
x: keysAt.value.x + step[0] * by,
|
|
3935
|
+
y: keysAt.value.y + step[1] * by
|
|
3936
|
+
});
|
|
3937
|
+
}
|
|
3938
|
+
/**
|
|
3939
|
+
* Keeps the main cursor clear of the phone's keyboard:
|
|
3782
3940
|
* scrolls the editor when the cursor can move inside it, else the page.
|
|
3783
3941
|
*/
|
|
3784
3942
|
function followViewport() {
|
|
@@ -3790,8 +3948,11 @@ var code_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3790
3948
|
const lh = lineHeight.value;
|
|
3791
3949
|
const room = lh / 2 + (handles.value.length ? HANDLE : 0);
|
|
3792
3950
|
const rect = el.getBoundingClientRect();
|
|
3793
|
-
const
|
|
3794
|
-
const
|
|
3951
|
+
const view = visibleViewport();
|
|
3952
|
+
const covered = keysRoom();
|
|
3953
|
+
const bottom = view.top + view.height - covered;
|
|
3954
|
+
const visibleTop = Math.max(rect.top, view.top);
|
|
3955
|
+
const visibleBottom = Math.min(rect.bottom, bottom);
|
|
3795
3956
|
if (at.bottom + room > visibleBottom && visibleBottom - visibleTop >= lh * 3) {
|
|
3796
3957
|
el.scrollTop += (at.bottom + room - visibleBottom) / ratio.value;
|
|
3797
3958
|
onScroll();
|
|
@@ -3800,12 +3961,13 @@ var code_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3800
3961
|
onScroll();
|
|
3801
3962
|
}
|
|
3802
3963
|
const after = coordsAtPos(mainRange(state.value.selection).head);
|
|
3803
|
-
if (!after) return;
|
|
3804
|
-
const
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3964
|
+
if (!after || after.bottom + room <= bottom) return;
|
|
3965
|
+
const before = window.scrollY;
|
|
3966
|
+
window.scrollBy(0, after.bottom + room - bottom);
|
|
3967
|
+
if (covered && keysAt.value) keysAt.value = {
|
|
3968
|
+
x: keysAt.value.x,
|
|
3969
|
+
y: keysAt.value.y + window.scrollY - before
|
|
3970
|
+
};
|
|
3809
3971
|
}
|
|
3810
3972
|
/** How much of the window the keyboard took when last seen. */
|
|
3811
3973
|
let keyboardHeight = 0;
|
|
@@ -3820,18 +3982,14 @@ var code_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3820
3982
|
* cursor then would fight the finger.
|
|
3821
3983
|
*/
|
|
3822
3984
|
function onViewportChange() {
|
|
3823
|
-
readViewport();
|
|
3824
3985
|
const now = readKeyboard();
|
|
3825
3986
|
const grew = now > keyboardHeight + 1;
|
|
3826
3987
|
keyboardHeight = now;
|
|
3827
|
-
if (grew
|
|
3988
|
+
if (!grew || fingerScrolling) return;
|
|
3989
|
+
settleKeys();
|
|
3990
|
+
followViewport();
|
|
3828
3991
|
}
|
|
3829
3992
|
/**
|
|
3830
|
-
* While the page scrolls, the bar of keys fades out: the browser moves the
|
|
3831
|
-
* page faster than the bar can follow the keyboard, and it would shake.
|
|
3832
|
-
*/
|
|
3833
|
-
const pageScrolling = ref(false);
|
|
3834
|
-
/**
|
|
3835
3993
|
* A finger scrolls the page, by dragging or by the glide after it: the view
|
|
3836
3994
|
* resizing meanwhile is the browser's bars, never a reason to scroll back.
|
|
3837
3995
|
* The browser scrolling to the cursor on its own, as a tap brings the
|
|
@@ -3839,20 +3997,12 @@ var code_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3839
3997
|
*/
|
|
3840
3998
|
let fingerScrolling = false;
|
|
3841
3999
|
let pageScrollTimer = 0;
|
|
3842
|
-
/** Until when a page scroll is the editor's own, keeping the cursor in view, which leaves the bar be. */
|
|
3843
|
-
let ownScrollUntil = 0;
|
|
3844
4000
|
function settleLater() {
|
|
3845
4001
|
clearTimeout(pageScrollTimer);
|
|
3846
|
-
pageScrollTimer = window.setTimeout(() =>
|
|
3847
|
-
readViewport();
|
|
3848
|
-
pageScrolling.value = false;
|
|
3849
|
-
fingerScrolling = false;
|
|
3850
|
-
}, 160);
|
|
4002
|
+
pageScrollTimer = window.setTimeout(() => fingerScrolling = false, 160);
|
|
3851
4003
|
}
|
|
3852
4004
|
function onPageScroll() {
|
|
3853
|
-
if (
|
|
3854
|
-
pageScrolling.value = true;
|
|
3855
|
-
settleLater();
|
|
4005
|
+
if (fingerScrolling) settleLater();
|
|
3856
4006
|
}
|
|
3857
4007
|
function onFingerMove() {
|
|
3858
4008
|
fingerScrolling = true;
|
|
@@ -3862,24 +4012,17 @@ var code_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3862
4012
|
const following = computed(() => coarse.value && focused.value);
|
|
3863
4013
|
function unfollow() {
|
|
3864
4014
|
if (typeof window === "undefined") return;
|
|
3865
|
-
|
|
3866
|
-
vv?.removeEventListener("resize", onViewportChange);
|
|
3867
|
-
vv?.removeEventListener("scroll", readViewport);
|
|
3868
|
-
vv?.removeEventListener("scroll", onPageScroll);
|
|
4015
|
+
window.visualViewport?.removeEventListener("resize", onViewportChange);
|
|
3869
4016
|
window.removeEventListener("scroll", onPageScroll);
|
|
3870
4017
|
window.removeEventListener("touchmove", onFingerMove);
|
|
3871
4018
|
clearTimeout(pageScrollTimer);
|
|
3872
|
-
pageScrolling.value = false;
|
|
3873
4019
|
fingerScrolling = false;
|
|
3874
4020
|
}
|
|
3875
4021
|
watch(following, (on) => {
|
|
3876
4022
|
const vv = window.visualViewport;
|
|
3877
4023
|
if (on) {
|
|
3878
|
-
readViewport();
|
|
3879
4024
|
keyboardHeight = readKeyboard();
|
|
3880
4025
|
vv?.addEventListener("resize", onViewportChange);
|
|
3881
|
-
vv?.addEventListener("scroll", readViewport);
|
|
3882
|
-
vv?.addEventListener("scroll", onPageScroll, { passive: true });
|
|
3883
4026
|
window.addEventListener("scroll", onPageScroll, { passive: true });
|
|
3884
4027
|
window.addEventListener("touchmove", onFingerMove, { passive: true });
|
|
3885
4028
|
} else unfollow();
|
|
@@ -4901,13 +5044,31 @@ var code_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
4901
5044
|
}), 128))], 2)) : createCommentVNode("", true),
|
|
4902
5045
|
(openBlock(), createBlock(Teleport, { to: "body" }, [showKeys.value ? (openBlock(), createElementBlock("div", {
|
|
4903
5046
|
key: 0,
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
5047
|
+
ref_key: "keysEl",
|
|
5048
|
+
ref: keysEl,
|
|
5049
|
+
class: normalizeClass([
|
|
5050
|
+
unref(ns).e("keys"),
|
|
5051
|
+
unref(ns).is("fixed", anchorMode.value === "fixed"),
|
|
5052
|
+
unref(ns).is("scrolling", boxScrolling.value)
|
|
5053
|
+
]),
|
|
5054
|
+
style: normalizeStyle(keysStyle.value),
|
|
5055
|
+
onFocusin: _cache[26] || (_cache[26] = ($event) => keysFocused.value = true),
|
|
5056
|
+
onFocusout: onKeysFocusOut,
|
|
5057
|
+
onKeydown: onKeysKeydown
|
|
5058
|
+
}, [createElementVNode("button", {
|
|
5059
|
+
type: "button",
|
|
5060
|
+
class: normalizeClass(unref(ns).e("keys-grip")),
|
|
5061
|
+
"aria-label": unref(messages).moveKeys,
|
|
5062
|
+
title: unref(messages).moveKeys,
|
|
5063
|
+
"aria-keyshortcuts": "ArrowUp ArrowDown ArrowLeft ArrowRight",
|
|
5064
|
+
onPointerdown: onKeysGripDown,
|
|
5065
|
+
onKeydown: onKeysGripKey,
|
|
5066
|
+
onMousedown: _cache[25] || (_cache[25] = withModifiers(() => {}, ["prevent"]))
|
|
5067
|
+
}, [createVNode(unref(GripVerticalIcon))], 42, _hoisted_18), createVNode(code_keys_default, {
|
|
4907
5068
|
editor: keysEditor,
|
|
4908
5069
|
keys: keysList.value,
|
|
4909
5070
|
messages: unref(messages)
|
|
4910
|
-
}, null, 8, ["keys", "messages"])],
|
|
5071
|
+
}, null, 8, ["keys", "messages"])], 38)) : createCommentVNode("", true)]))
|
|
4911
5072
|
], 6);
|
|
4912
5073
|
};
|
|
4913
5074
|
}
|