From a6c44bd7943a90fcbc78abaff398c06c4d0c9092 Mon Sep 17 00:00:00 2001 From: kotaindah55 Date: Mon, 17 Mar 2025 10:34:12 +0200 Subject: [PATCH] feat: pick certain tokens from the maps based on their format type --- src/editor-mode/observer/SelectionObserver.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/editor-mode/observer/SelectionObserver.ts b/src/editor-mode/observer/SelectionObserver.ts index 08f4aaf..fd91d98 100644 --- a/src/editor-mode/observer/SelectionObserver.ts +++ b/src/editor-mode/observer/SelectionObserver.ts @@ -389,8 +389,13 @@ export class SelectionObserver { } return false; } + pickMaps(type: Format) { + let level = isInlineFormat(type) ? TokenLevel.INLINE : TokenLevel.BLOCK, + tokens = this.parser.getTokens(level); + return this.maps.map(maps => maps[level]?.filter(tokenIndex => tokens[tokenIndex].type == type)); + } clearMaps() { - this.maps = []; + this.maps = new Array(this.selection.ranges.length).map(() => ({})); } checkSelectionIndexCache() { if (this.indexCaches.selection.number >= this.selection.ranges.length) {