Export template source from be30143a326d5d7d7b0cbabea5bc5ac0301ef5b9:examples/local-first/packages/language-reader-presentation
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import type { Annotation } from "./canvas/types.js";
|
||||
|
||||
/** Several views of one cached semantic item. These are authored presentation
|
||||
* choices, not separate computations or independently generated annotations. */
|
||||
export type AnnotationRender = {
|
||||
style: Annotation["style"];
|
||||
underlinePattern?: Annotation["underlinePattern"];
|
||||
placement?: Annotation["placement"];
|
||||
reveal: "always" | "click" | "hover";
|
||||
content?: "result" | "source";
|
||||
};
|
||||
export function renderAnnotations(item: Annotation, source: string, renders: readonly AnnotationRender[] | undefined) {
|
||||
if (!renders?.length) return [item];
|
||||
return renders.map(
|
||||
(render, index): Annotation => ({
|
||||
...item,
|
||||
id: `${item.id}:render:${index}`,
|
||||
...render,
|
||||
text: render.content === "source" ? source.slice(item.start, item.end) : item.text,
|
||||
}),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user