Export template source from be30143a326d5d7d7b0cbabea5bc5ac0301ef5b9:examples/local-first/packages/language-reader-presentation

This commit is contained in:
Quixos Template Publisher
2000-01-01 00:00:00 +00:00
commit 19b330933d
61 changed files with 9997 additions and 0 deletions
+22
View File
@@ -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,
}),
);
}