@dou-ui/code 0.1.0-alpha.5 → 0.1.0-alpha.6
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-diff.js.map +1 -1
- package/dist/code-diff.vue_vue_type_script_setup_true_lang.js +66 -9
- package/dist/code-diff.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/code-editor.js.map +1 -1
- package/dist/code-editor.vue_vue_type_script_setup_true_lang.js +61 -5
- package/dist/code-editor.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/extension.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/extension.d.ts +24 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/types.d.ts +23 -2
- package/package.json +3 -3
|
@@ -807,12 +807,28 @@ var code_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
807
807
|
for (const extension of extensions.value) for (const gutter of extension.gutters ?? []) columns.push({
|
|
808
808
|
name: gutter.name,
|
|
809
809
|
width: gutter.width ?? 16,
|
|
810
|
-
markers: () => gutter.markers(context),
|
|
811
|
-
onPress: gutter.onPress && ((line, event) => gutter.onPress(line, event, context))
|
|
810
|
+
markers: () => withHoverMarker(gutter.markers?.(context) ?? [], gutter.hoverMarker),
|
|
811
|
+
onPress: gutter.onPress && ((line, event) => gutter.onPress(line, event, context)),
|
|
812
|
+
pressOn: gutter.pressOn
|
|
812
813
|
});
|
|
813
814
|
return columns;
|
|
814
815
|
});
|
|
815
816
|
const gutterCells = computed(() => gutterColumns.value.reduce((sum, column) => sum + column.width, 0));
|
|
817
|
+
/** A column's markers, and its `hoverMarker` on the other lines in view. */
|
|
818
|
+
function withHoverMarker(own, hover) {
|
|
819
|
+
if (!hover) return own;
|
|
820
|
+
const taken = new Set(own.map((marker) => marker.line));
|
|
821
|
+
const out = [...own];
|
|
822
|
+
for (let line = visibleFrom.value; line <= visibleTo.value; line++) if (!taken.has(line)) out.push({
|
|
823
|
+
icon: hover.icon,
|
|
824
|
+
text: hover.text,
|
|
825
|
+
class: hover.class,
|
|
826
|
+
title: typeof hover.title === "function" ? hover.title(line) : hover.title,
|
|
827
|
+
line,
|
|
828
|
+
visible: "hover"
|
|
829
|
+
});
|
|
830
|
+
return out;
|
|
831
|
+
}
|
|
816
832
|
/** The worst problem on each line in view, as a marker. */
|
|
817
833
|
function problemMarkers() {
|
|
818
834
|
const text = doc.value;
|
|
@@ -3339,6 +3355,27 @@ var code_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3339
3355
|
}
|
|
3340
3356
|
/** A tap that may turn into a scroll or a long press; touches only act once they end in place. */
|
|
3341
3357
|
let touch = null;
|
|
3358
|
+
/** A finger or pen on a pressable gutter cell, which presses if it lifts in place. */
|
|
3359
|
+
let cellTap = null;
|
|
3360
|
+
/**
|
|
3361
|
+
* A tap on a gutter cell lifted in place. A marker still out of sight (shown
|
|
3362
|
+
* on hover, which a finger can't do) isn't pressed yet: the cursor moves to
|
|
3363
|
+
* its line, which shows it, and the next tap presses it.
|
|
3364
|
+
*/
|
|
3365
|
+
function endCellTap(event) {
|
|
3366
|
+
const tap = cellTap;
|
|
3367
|
+
cellTap = null;
|
|
3368
|
+
if (!tap) return;
|
|
3369
|
+
const column = gutterColumns.value[tap.column];
|
|
3370
|
+
if (!column?.onPress || props.disabled) return;
|
|
3371
|
+
if ((gutterMarkers.value[tap.column]?.get(tap.line))?.visible === "hover" && !(focused.value && activeLineNumber.value === tap.line)) {
|
|
3372
|
+
touchUi.value = true;
|
|
3373
|
+
select("char", doc.value.line(tap.line).from, false);
|
|
3374
|
+
focusInput();
|
|
3375
|
+
return;
|
|
3376
|
+
}
|
|
3377
|
+
column.onPress(tap.line, event);
|
|
3378
|
+
}
|
|
3342
3379
|
/** The fold toggle or folded marker under a pointer, as the line it belongs to. */
|
|
3343
3380
|
function foldTarget(event) {
|
|
3344
3381
|
const el = event.target?.closest?.("[data-fold], [data-unfold]");
|
|
@@ -3355,11 +3392,24 @@ var code_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3355
3392
|
function onPointerDown(event, area) {
|
|
3356
3393
|
if (event.button !== 0 || props.disabled) return;
|
|
3357
3394
|
const cell = event.target?.closest?.("[data-gutter-cell]");
|
|
3358
|
-
const
|
|
3395
|
+
const c = Number(cell?.getAttribute("data-gutter-cell"));
|
|
3396
|
+
const column = cell && gutterColumns.value[c];
|
|
3359
3397
|
if (column?.onPress) {
|
|
3360
3398
|
event.preventDefault();
|
|
3361
3399
|
event.stopPropagation();
|
|
3362
|
-
|
|
3400
|
+
const line = Number(cell.getAttribute("data-line"));
|
|
3401
|
+
if (event.pointerType === "touch" || event.pointerType === "pen") {
|
|
3402
|
+
onPointerCancel();
|
|
3403
|
+
cellTap = {
|
|
3404
|
+
x: event.clientX,
|
|
3405
|
+
y: event.clientY,
|
|
3406
|
+
pointer: event.pointerId,
|
|
3407
|
+
column: c,
|
|
3408
|
+
line
|
|
3409
|
+
};
|
|
3410
|
+
return;
|
|
3411
|
+
}
|
|
3412
|
+
column.onPress(line, event);
|
|
3363
3413
|
return;
|
|
3364
3414
|
}
|
|
3365
3415
|
const fold = foldTarget(event);
|
|
@@ -3452,10 +3502,15 @@ var code_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3452
3502
|
return count;
|
|
3453
3503
|
}
|
|
3454
3504
|
function onPointerMove(event) {
|
|
3505
|
+
if (cellTap && event.pointerId === cellTap.pointer) {
|
|
3506
|
+
if (Math.hypot(event.clientX - cellTap.x, event.clientY - cellTap.y) > 8) cellTap = null;
|
|
3507
|
+
return;
|
|
3508
|
+
}
|
|
3455
3509
|
if (!touch || event.pointerId !== touch.pointer) return;
|
|
3456
3510
|
if (Math.hypot(event.clientX - touch.x, event.clientY - touch.y) > 8) onPointerCancel();
|
|
3457
3511
|
}
|
|
3458
3512
|
function onPointerUp(event, area) {
|
|
3513
|
+
if (cellTap && event.pointerId === cellTap.pointer) return endCellTap(event);
|
|
3459
3514
|
if (!touch || event.pointerId !== touch.pointer) return;
|
|
3460
3515
|
onPointerCancel();
|
|
3461
3516
|
const iconLine = area === "gutter" ? problemIconLine(event) : null;
|
|
@@ -3476,6 +3531,7 @@ var code_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3476
3531
|
focusInput();
|
|
3477
3532
|
}
|
|
3478
3533
|
function onPointerCancel() {
|
|
3534
|
+
cellTap = null;
|
|
3479
3535
|
if (touch) {
|
|
3480
3536
|
clearTimeout(touch.timer);
|
|
3481
3537
|
touch.hold.release();
|
|
@@ -4676,7 +4732,7 @@ var code_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
4676
4732
|
],
|
|
4677
4733
|
style: { width: `${column.width}px` },
|
|
4678
4734
|
title: gutterMarkers.value[c]?.get(row.n)?.title,
|
|
4679
|
-
"data-gutter-cell": column.onPress ? c : void 0,
|
|
4735
|
+
"data-gutter-cell": column.onPress && (column.pressOn !== "markers" || gutterMarkers.value[c]?.has(row.n)) ? c : void 0,
|
|
4680
4736
|
"data-line": row.n
|
|
4681
4737
|
}, { ref_for: true }, column.onPress && gutterMarkers.value[c]?.get(row.n) && !__props.disabled ? {
|
|
4682
4738
|
role: "button",
|