svedit 0.1.0 → 0.1.1
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/Svedit.svelte +39 -6
- package/dist/Svedit.svelte.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/lib/Svedit.svelte +39 -6
package/dist/Svedit.svelte
CHANGED
|
@@ -261,7 +261,10 @@
|
|
|
261
261
|
const is_collapsed = selection?.anchor_offset === selection?.focus_offset;
|
|
262
262
|
|
|
263
263
|
// console.log('onkeydown', e.key);
|
|
264
|
-
if (
|
|
264
|
+
if (
|
|
265
|
+
(e.key === 'ArrowRight' && e.altKey && e.ctrlKey && doc.selected_node) ||
|
|
266
|
+
(e.key === 'ArrowRight' && e.altKey && e.ctrlKey && e.shiftKey && doc.selected_node)
|
|
267
|
+
) {
|
|
265
268
|
const node = doc.selected_node;
|
|
266
269
|
const layout_count = doc.config.node_layouts[node.type];
|
|
267
270
|
|
|
@@ -272,7 +275,10 @@
|
|
|
272
275
|
tr.set([doc.selected_node?.id, 'layout'], next_layout);
|
|
273
276
|
doc.apply(tr);
|
|
274
277
|
}
|
|
275
|
-
} else if (
|
|
278
|
+
} else if (
|
|
279
|
+
(e.key === 'ArrowLeft' && e.altKey && e.ctrlKey && doc.selected_node) ||
|
|
280
|
+
(e.key === 'ArrowLeft' && e.altKey && e.ctrlKey && e.shiftKey && doc.selected_node)
|
|
281
|
+
) {
|
|
276
282
|
const node = doc.selected_node;
|
|
277
283
|
const layout_count = doc.config.node_layouts[node.type];
|
|
278
284
|
if (layout_count > 1 && node?.layout) {
|
|
@@ -282,7 +288,10 @@
|
|
|
282
288
|
doc.apply(tr);
|
|
283
289
|
console.log('layout / count / prev_layout', node.layout, layout_count, prev_layout);
|
|
284
290
|
}
|
|
285
|
-
} else if (
|
|
291
|
+
} else if (
|
|
292
|
+
(e.key === 'ArrowDown' && e.altKey && e.ctrlKey && doc.selected_node) ||
|
|
293
|
+
(e.key === 'ArrowDown' && e.altKey && e.ctrlKey && e.shiftKey && doc.selected_node )
|
|
294
|
+
) {
|
|
286
295
|
const node = doc.selected_node;
|
|
287
296
|
|
|
288
297
|
if (doc.selection.type !== 'node') {
|
|
@@ -301,9 +310,10 @@
|
|
|
301
310
|
doc.config.inserters[next_type](tr);
|
|
302
311
|
tr.set_selection(old_selection);
|
|
303
312
|
doc.apply(tr);
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
313
|
+
} else if (
|
|
314
|
+
(e.key === 'ArrowUp' && e.altKey && e.ctrlKey && doc.selected_node) ||
|
|
315
|
+
(e.key === 'ArrowUp' && e.altKey && e.ctrlKey && e.shiftKey && doc.selected_node)
|
|
316
|
+
) {
|
|
307
317
|
const node = doc.selected_node;
|
|
308
318
|
|
|
309
319
|
if (doc.selection.type !== 'node') {
|
|
@@ -483,6 +493,8 @@
|
|
|
483
493
|
|
|
484
494
|
let focus_root_path = focus_root.dataset.path.split('.');
|
|
485
495
|
let anchor_root_path = anchor_root.dataset.path.split('.');
|
|
496
|
+
let focus_node_depth = focus_root_path.length;
|
|
497
|
+
let anchor_node_depth = anchor_root_path.length;
|
|
486
498
|
|
|
487
499
|
// HACK: this works only for one level nesting - should be done recursively to work generally
|
|
488
500
|
if (focus_root_path.length > anchor_root_path.length) {
|
|
@@ -512,6 +524,27 @@
|
|
|
512
524
|
focus_offset += 1;
|
|
513
525
|
}
|
|
514
526
|
|
|
527
|
+
// Exclude first node when anchor_node[data-type="after-node-cursor-trap"]
|
|
528
|
+
// in a non-collapsed forward selection
|
|
529
|
+
if (
|
|
530
|
+
anchor_node.dataset.type === 'after-node-cursor-trap' &&
|
|
531
|
+
!is_backwards &&
|
|
532
|
+
anchor_offset !== focus_offset
|
|
533
|
+
) {
|
|
534
|
+
anchor_offset += 1;
|
|
535
|
+
}
|
|
536
|
+
// Exclude first node when focus_node[data-type="after-node-cursor-trap"]
|
|
537
|
+
// in a non-collapsed backward selection
|
|
538
|
+
else if (
|
|
539
|
+
focus_node.dataset.type === 'after-node-cursor-trap' &&
|
|
540
|
+
is_backwards &&
|
|
541
|
+
anchor_offset !== focus_offset &&
|
|
542
|
+
// EDGE CASE: only apply this rule if focus node and anchor node are in the same container
|
|
543
|
+
focus_node_depth === anchor_node_depth
|
|
544
|
+
) {
|
|
545
|
+
focus_offset += 1;
|
|
546
|
+
}
|
|
547
|
+
|
|
515
548
|
return {
|
|
516
549
|
type: 'node',
|
|
517
550
|
path: anchor_root_path.slice(0, -1),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Svedit.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Svedit.svelte.js"],"names":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"Svedit.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Svedit.svelte.js"],"names":[],"mappings":";;;;;;;AA86BA;;OAAqD;iCAl6BgE,cAAc"}
|
package/package.json
CHANGED
package/src/lib/Svedit.svelte
CHANGED
|
@@ -261,7 +261,10 @@
|
|
|
261
261
|
const is_collapsed = selection?.anchor_offset === selection?.focus_offset;
|
|
262
262
|
|
|
263
263
|
// console.log('onkeydown', e.key);
|
|
264
|
-
if (
|
|
264
|
+
if (
|
|
265
|
+
(e.key === 'ArrowRight' && e.altKey && e.ctrlKey && doc.selected_node) ||
|
|
266
|
+
(e.key === 'ArrowRight' && e.altKey && e.ctrlKey && e.shiftKey && doc.selected_node)
|
|
267
|
+
) {
|
|
265
268
|
const node = doc.selected_node;
|
|
266
269
|
const layout_count = doc.config.node_layouts[node.type];
|
|
267
270
|
|
|
@@ -272,7 +275,10 @@
|
|
|
272
275
|
tr.set([doc.selected_node?.id, 'layout'], next_layout);
|
|
273
276
|
doc.apply(tr);
|
|
274
277
|
}
|
|
275
|
-
} else if (
|
|
278
|
+
} else if (
|
|
279
|
+
(e.key === 'ArrowLeft' && e.altKey && e.ctrlKey && doc.selected_node) ||
|
|
280
|
+
(e.key === 'ArrowLeft' && e.altKey && e.ctrlKey && e.shiftKey && doc.selected_node)
|
|
281
|
+
) {
|
|
276
282
|
const node = doc.selected_node;
|
|
277
283
|
const layout_count = doc.config.node_layouts[node.type];
|
|
278
284
|
if (layout_count > 1 && node?.layout) {
|
|
@@ -282,7 +288,10 @@
|
|
|
282
288
|
doc.apply(tr);
|
|
283
289
|
console.log('layout / count / prev_layout', node.layout, layout_count, prev_layout);
|
|
284
290
|
}
|
|
285
|
-
} else if (
|
|
291
|
+
} else if (
|
|
292
|
+
(e.key === 'ArrowDown' && e.altKey && e.ctrlKey && doc.selected_node) ||
|
|
293
|
+
(e.key === 'ArrowDown' && e.altKey && e.ctrlKey && e.shiftKey && doc.selected_node )
|
|
294
|
+
) {
|
|
286
295
|
const node = doc.selected_node;
|
|
287
296
|
|
|
288
297
|
if (doc.selection.type !== 'node') {
|
|
@@ -301,9 +310,10 @@
|
|
|
301
310
|
doc.config.inserters[next_type](tr);
|
|
302
311
|
tr.set_selection(old_selection);
|
|
303
312
|
doc.apply(tr);
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
313
|
+
} else if (
|
|
314
|
+
(e.key === 'ArrowUp' && e.altKey && e.ctrlKey && doc.selected_node) ||
|
|
315
|
+
(e.key === 'ArrowUp' && e.altKey && e.ctrlKey && e.shiftKey && doc.selected_node)
|
|
316
|
+
) {
|
|
307
317
|
const node = doc.selected_node;
|
|
308
318
|
|
|
309
319
|
if (doc.selection.type !== 'node') {
|
|
@@ -483,6 +493,8 @@
|
|
|
483
493
|
|
|
484
494
|
let focus_root_path = focus_root.dataset.path.split('.');
|
|
485
495
|
let anchor_root_path = anchor_root.dataset.path.split('.');
|
|
496
|
+
let focus_node_depth = focus_root_path.length;
|
|
497
|
+
let anchor_node_depth = anchor_root_path.length;
|
|
486
498
|
|
|
487
499
|
// HACK: this works only for one level nesting - should be done recursively to work generally
|
|
488
500
|
if (focus_root_path.length > anchor_root_path.length) {
|
|
@@ -512,6 +524,27 @@
|
|
|
512
524
|
focus_offset += 1;
|
|
513
525
|
}
|
|
514
526
|
|
|
527
|
+
// Exclude first node when anchor_node[data-type="after-node-cursor-trap"]
|
|
528
|
+
// in a non-collapsed forward selection
|
|
529
|
+
if (
|
|
530
|
+
anchor_node.dataset.type === 'after-node-cursor-trap' &&
|
|
531
|
+
!is_backwards &&
|
|
532
|
+
anchor_offset !== focus_offset
|
|
533
|
+
) {
|
|
534
|
+
anchor_offset += 1;
|
|
535
|
+
}
|
|
536
|
+
// Exclude first node when focus_node[data-type="after-node-cursor-trap"]
|
|
537
|
+
// in a non-collapsed backward selection
|
|
538
|
+
else if (
|
|
539
|
+
focus_node.dataset.type === 'after-node-cursor-trap' &&
|
|
540
|
+
is_backwards &&
|
|
541
|
+
anchor_offset !== focus_offset &&
|
|
542
|
+
// EDGE CASE: only apply this rule if focus node and anchor node are in the same container
|
|
543
|
+
focus_node_depth === anchor_node_depth
|
|
544
|
+
) {
|
|
545
|
+
focus_offset += 1;
|
|
546
|
+
}
|
|
547
|
+
|
|
515
548
|
return {
|
|
516
549
|
type: 'node',
|
|
517
550
|
path: anchor_root_path.slice(0, -1),
|