svedit 0.12.0 → 0.13.0
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/README.md +33 -21
- package/dist/Command.svelte.d.ts +38 -30
- package/dist/Command.svelte.d.ts.map +1 -1
- package/dist/Command.svelte.js +271 -326
- package/dist/CustomProperty.svelte +3 -5
- package/dist/CustomProperty.svelte.d.ts +3 -6
- package/dist/CustomProperty.svelte.d.ts.map +1 -1
- package/dist/KeyMapper.svelte.d.ts +19 -6
- package/dist/KeyMapper.svelte.d.ts.map +1 -1
- package/dist/KeyMapper.svelte.js +95 -112
- package/dist/Node.svelte +16 -13
- package/dist/Node.svelte.d.ts +3 -5
- package/dist/Node.svelte.d.ts.map +1 -1
- package/dist/NodeArrayProperty.svelte +39 -22
- package/dist/NodeArrayProperty.svelte.d.ts +3 -5
- package/dist/NodeArrayProperty.svelte.d.ts.map +1 -1
- package/dist/NodeCaret.svelte +1 -1
- package/dist/NodeCaret.svelte.d.ts +6 -14
- package/dist/NodeCaret.svelte.d.ts.map +1 -1
- package/dist/NodeGap.svelte +12 -6
- package/dist/NodeGap.svelte.d.ts +7 -14
- package/dist/NodeGap.svelte.d.ts.map +1 -1
- package/dist/NodeGapMarkers.svelte +19 -10
- package/dist/NodeGapMarkers.svelte.d.ts +6 -11
- package/dist/NodeGapMarkers.svelte.d.ts.map +1 -1
- package/dist/NodeSelectionMarkers.svelte +20 -6
- package/dist/NodeSelectionMarkers.svelte.d.ts +2 -5
- package/dist/NodeSelectionMarkers.svelte.d.ts.map +1 -1
- package/dist/Session.svelte.d.ts +81 -129
- package/dist/Session.svelte.d.ts.map +1 -1
- package/dist/Session.svelte.js +542 -648
- package/dist/Svedit.svelte +144 -138
- package/dist/Svedit.svelte.d.ts +30 -10
- package/dist/Svedit.svelte.d.ts.map +1 -1
- package/dist/TextProperty.svelte +32 -18
- package/dist/TextProperty.svelte.d.ts +3 -5
- package/dist/TextProperty.svelte.d.ts.map +1 -1
- package/dist/Transaction.svelte.d.ts +64 -127
- package/dist/Transaction.svelte.d.ts.map +1 -1
- package/dist/Transaction.svelte.js +839 -1001
- package/dist/UnknownNode.svelte +4 -3
- package/dist/UnknownNode.svelte.d.ts +5 -9
- package/dist/UnknownNode.svelte.d.ts.map +1 -1
- package/dist/doc_utils.d.ts +67 -155
- package/dist/doc_utils.d.ts.map +1 -1
- package/dist/doc_utils.js +619 -863
- package/dist/index.d.ts +20 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -17
- package/dist/node_visibility.svelte.d.ts +110 -9
- package/dist/node_visibility.svelte.d.ts.map +1 -1
- package/dist/node_visibility.svelte.js +473 -544
- package/dist/paste_utils.d.ts +11 -44
- package/dist/paste_utils.d.ts.map +1 -1
- package/dist/paste_utils.js +111 -152
- package/dist/transforms.svelte.d.ts +9 -7
- package/dist/transforms.svelte.d.ts.map +1 -1
- package/dist/transforms.svelte.js +125 -150
- package/dist/types.d.ts +277 -309
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +40 -119
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +346 -473
- package/package.json +69 -70
- package/src/lib/{Command.svelte.js → Command.svelte.ts} +29 -17
- package/src/lib/CustomProperty.svelte +3 -5
- package/src/lib/{KeyMapper.svelte.js → KeyMapper.svelte.ts} +28 -11
- package/src/lib/Node.svelte +16 -13
- package/src/lib/NodeArrayProperty.svelte +39 -22
- package/src/lib/NodeCaret.svelte +1 -1
- package/src/lib/NodeGap.svelte +12 -6
- package/src/lib/NodeGapMarkers.svelte +19 -10
- package/src/lib/NodeSelectionMarkers.svelte +20 -6
- package/src/lib/{Session.svelte.js → Session.svelte.ts} +130 -127
- package/src/lib/Svedit.svelte +144 -138
- package/src/lib/TextProperty.svelte +32 -18
- package/src/lib/{Transaction.svelte.js → Transaction.svelte.ts} +139 -143
- package/src/lib/UnknownNode.svelte +4 -3
- package/src/lib/{doc_utils.js → doc_utils.ts} +247 -206
- package/src/lib/{index.js → index.ts} +47 -0
- package/src/lib/{node_visibility.svelte.js → node_visibility.svelte.ts} +68 -92
- package/src/lib/{paste_utils.js → paste_utils.ts} +47 -58
- package/src/lib/{transforms.svelte.js → transforms.svelte.ts} +39 -21
- package/src/lib/{types.d.ts → types.ts} +143 -66
- package/src/lib/{utils.js → utils.ts} +110 -129
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import { getContext } from 'svelte';
|
|
3
3
|
import NodeCaret from './NodeCaret.svelte';
|
|
4
4
|
import { PATH_SEPARATOR, serialize_path } from './utils.js';
|
|
5
|
+
import type { DocumentPath, SveditRenderContext } from './types.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* ┌─────────────────────────────────────────────────────────────────┐
|
|
@@ -28,9 +29,9 @@
|
|
|
28
29
|
* re-evaluates when THIS array's visible-index set changes.
|
|
29
30
|
*/
|
|
30
31
|
|
|
31
|
-
let { path, count } = $props();
|
|
32
|
+
let { path, count }: { path: DocumentPath; count: number } = $props();
|
|
32
33
|
|
|
33
|
-
const svedit = getContext('svedit');
|
|
34
|
+
const svedit = getContext<SveditRenderContext>('svedit');
|
|
34
35
|
let path_str = $derived(serialize_path(path));
|
|
35
36
|
let visible = $derived(svedit.visibility_registry.get_array_indices(path_str));
|
|
36
37
|
|
|
@@ -51,8 +52,16 @@
|
|
|
51
52
|
? `;--_f:${anchor_prefix}${PATH_SEPARATOR}0;--_s:${anchor_prefix}${PATH_SEPARATOR}1`
|
|
52
53
|
: '';
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
type GapMarker = {
|
|
56
|
+
key: string;
|
|
57
|
+
offset: number;
|
|
58
|
+
type: string;
|
|
59
|
+
vars: string;
|
|
60
|
+
is_first: boolean;
|
|
61
|
+
is_last: boolean;
|
|
62
|
+
has_pair: boolean;
|
|
63
|
+
};
|
|
64
|
+
const result: GapMarker[] = [];
|
|
56
65
|
|
|
57
66
|
if (count === 0) {
|
|
58
67
|
if (visible.has(0)) {
|
|
@@ -73,15 +82,15 @@
|
|
|
73
82
|
// 1000 nodes with ~30 visible, this drops 1001 SvelteSet/SvelteMap
|
|
74
83
|
// reads per re-derivation to ~30. Filter stale indices >= count
|
|
75
84
|
// that may briefly remain after a node delete (until MO fires).
|
|
76
|
-
const sorted = [];
|
|
85
|
+
const sorted: number[] = [];
|
|
77
86
|
for (const i of visible) {
|
|
78
87
|
if (i >= 0 && i < count) sorted.push(i);
|
|
79
88
|
}
|
|
80
89
|
sorted.sort((a, b) => a - b);
|
|
81
90
|
if (sorted.length === 0) return result;
|
|
82
91
|
|
|
83
|
-
const offsets = [];
|
|
84
|
-
function add_offset(offset) {
|
|
92
|
+
const offsets: number[] = [];
|
|
93
|
+
function add_offset(offset: number) {
|
|
85
94
|
if (!offsets.includes(offset)) offsets.push(offset);
|
|
86
95
|
}
|
|
87
96
|
|
|
@@ -112,7 +121,7 @@
|
|
|
112
121
|
? `${g_prefix}${PATH_SEPARATOR}0-gap-before`
|
|
113
122
|
: `${g_prefix}${PATH_SEPARATOR}${offset - 1}-gap-after`;
|
|
114
123
|
|
|
115
|
-
let type, vars;
|
|
124
|
+
let type: string, vars: string;
|
|
116
125
|
if (is_first || is_last) {
|
|
117
126
|
type = 'gap-edge';
|
|
118
127
|
const adjacent = is_first
|
|
@@ -646,4 +655,4 @@
|
|
|
646
655
|
outline: 1px solid blue;
|
|
647
656
|
outline-offset: 0.5px;
|
|
648
657
|
} */
|
|
649
|
-
</style>
|
|
658
|
+
</style>
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import { getContext } from 'svelte';
|
|
3
3
|
import { serialize_path } from './utils.js';
|
|
4
|
+
import type { DocumentPath, SveditContext } from './types.js';
|
|
4
5
|
|
|
5
|
-
const svedit = getContext('svedit');
|
|
6
|
+
const svedit = getContext<SveditContext>('svedit');
|
|
6
7
|
let selected_node_paths = $derived(get_selected_node_paths());
|
|
7
8
|
|
|
8
|
-
function get_selected_node_paths() {
|
|
9
|
-
const paths = [];
|
|
9
|
+
function get_selected_node_paths(): DocumentPath[] | undefined {
|
|
10
|
+
const paths: DocumentPath[] = [];
|
|
10
11
|
const selection = svedit.session.selection;
|
|
11
12
|
if (!selection) return;
|
|
12
13
|
if (selection.type !== 'node' || selection.anchor_offset === selection.focus_offset) return;
|
|
@@ -36,10 +37,23 @@
|
|
|
36
37
|
<style>
|
|
37
38
|
.selected-node-overlay,
|
|
38
39
|
.selected-property-overlay {
|
|
40
|
+
/* Selection frame: a single 1px outline, offset -0.5px so the
|
|
41
|
+
hairline centers on the node's edge and neighboring frames merge
|
|
42
|
+
into one shared line. Alternatives tried and rejected:
|
|
43
|
+
- Plain 1px border: adjacent selected nodes stack their borders
|
|
44
|
+
into a 2px seam between them, which looks ugly.
|
|
45
|
+
- Thick translucent frame (8px border) plus an inner hairline
|
|
46
|
+
outline: multiple nested lines take more cognitive effort to
|
|
47
|
+
parse than a single line.
|
|
48
|
+
- Inset box-shadow rings (1px stroke + 8px translucent): same
|
|
49
|
+
layered-frame look, same objection.
|
|
50
|
+
Performance note: outlines don't participate in layout, so
|
|
51
|
+
selection changes can't trigger reflows. */
|
|
39
52
|
position: absolute;
|
|
40
53
|
background: var(--svedit-editing-fill);
|
|
41
|
-
|
|
42
|
-
|
|
54
|
+
outline: 1px solid var(--svedit-editing-stroke);
|
|
55
|
+
outline-offset: -0.5px;
|
|
56
|
+
border-radius: 1px;
|
|
43
57
|
top: anchor(top);
|
|
44
58
|
left: anchor(left);
|
|
45
59
|
bottom: anchor(bottom);
|