mirror of
https://github.com/bendtherules/completion-viz.git
synced 2026-08-18 13:42:51 +00:00
feat(source): SourceMapping - Add token also to map
This token will be helpful to find completion record from AST token. When you click on source code, this will be used.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Token } from "../types/prism-types";
|
||||
|
||||
export interface TMappingELement {
|
||||
token: Token;
|
||||
start: number;
|
||||
end: number;
|
||||
ref: { current: HTMLElement | null };
|
||||
@@ -20,6 +21,7 @@ export const sourceMapping: TSourceMapping = {
|
||||
lastEnd: 0,
|
||||
registerToken(t: Token) {
|
||||
const obj: TMappingELement = {
|
||||
token: t,
|
||||
start: this.lastEnd,
|
||||
end: this.lastEnd + t.content.length,
|
||||
ref: { current: null },
|
||||
@@ -27,8 +29,6 @@ export const sourceMapping: TSourceMapping = {
|
||||
this.mappingArray.push(obj);
|
||||
this.lastEnd = this.mappingArray[this.mappingArray.length - 1].end;
|
||||
|
||||
console.log(obj, t);
|
||||
|
||||
return function updateHTMLElement(ele) {
|
||||
obj.ref.current = ele;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user