Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a9cf0e9a0 | ||
|
|
390d953b6f |
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"monorepoCommit": "11bc3ae35b0034c113daca4c35d1b341aa31ef70",
|
||||
"monorepoCommit": "488f7e229afed8f03fc3bfa4abe707da0c613460",
|
||||
"sourcePath": "examples/local-first/packages/language-reader-presentation"
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ query Reader {
|
||||
defaultReader {_camino {ref}}
|
||||
inferenceProfile
|
||||
documents(first: 100) { entries { node { archived data { title source url attribution } } } }
|
||||
features(first: 200) { entries { node { authoring {_camino {ref}} options data { name processor style reveal generation scope color enabled configRevision } } } }
|
||||
features(first: 200) { entries { node { authoring {_camino {ref}} options data { name processor enabled configRevision } } } }
|
||||
tasks(first: 20, where: {data: {kind: {in: ["customize", "text"]}}}, orderBy: {data: {createdAt: DESC}}) { entries { node {
|
||||
reader {_camino {ref}}
|
||||
document {_camino {ref}}
|
||||
|
||||
+20
-20
@@ -1,22 +1,22 @@
|
||||
quixos-lock version 1 {
|
||||
quixos source { repository "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos.git"; commit "11bc3ae35b0034c113daca4c35d1b341aa31ef70"; }
|
||||
interface LanguageReader source { repository "https://repos.quixos.org/quixos-templates/interface-language-reader.git"; commit "6c26bde43dc95ce70371fc120689947a23f8c564"; }
|
||||
interface ReadingReader source { repository "https://repos.quixos.org/quixos-templates/interface-reading-reader.git"; commit "caf95ae904857b554f1c1b84803f4b8f2a7895ae"; }
|
||||
interface ReadingDocument source { repository "https://repos.quixos.org/quixos-templates/interface-reading-document.git"; commit "425ce639dd6446e01d791f7aad9fcf0682af7d09"; }
|
||||
interface ReadingFeature source { repository "https://repos.quixos.org/quixos-templates/interface-reading-feature.git"; commit "1cfa42c98466b6b7f4e3b177c9bf076ed0d1d97f"; }
|
||||
interface ReadingJob source { repository "https://repos.quixos.org/quixos-templates/interface-reading-job.git"; commit "680be4948bd0dfb9e512967ac6a48746dc2835a4"; }
|
||||
interface ReadingWord source { repository "https://repos.quixos.org/quixos-templates/interface-reading-word.git"; commit "70e01195cf65994c6e54312498dd69115204ec04"; }
|
||||
interface ReadingVocabulary source { repository "https://repos.quixos.org/quixos-templates/interface-reading-vocabulary.git"; commit "7be1aa0ebcf364d2283cc1423a06383e7658addd"; }
|
||||
interface AgentRequest source { repository "https://repos.quixos.org/quixos-templates/interface-agent-request.git"; commit "ebda8ef7734973e21e47446ed1ddd9d4d51d760d"; }
|
||||
interface AgentThread source { repository "https://repos.quixos.org/quixos-templates/interface-agent-thread.git"; commit "5c5f0e6eea473f3d3e5ccda90c4b99264da1a200"; }
|
||||
interface AgentItem source { repository "https://repos.quixos.org/quixos-templates/interface-agent-item.git"; commit "39cf5dfec15f9ab63d9371512c7dcb0bde273eb2"; }
|
||||
interface AgentQuestion source { repository "https://repos.quixos.org/quixos-templates/interface-agent-question.git"; commit "53fd9bb61b572091319db6927adce8d180f5924f"; }
|
||||
interface StandaloneView source { repository "https://repos.quixos.org/quixos-templates/interface-react-standalone-view.git"; commit "105a9d9957c8c0d7e3f8a0896698f5cad6203efc"; }
|
||||
interface ReactComponent source { repository "https://repos.quixos.org/quixos-templates/interface-react-component.git"; commit "467c619dc09f79b882a5831e2fb07921f35bf550"; }
|
||||
interface PresentationMount source { repository "https://repos.quixos.org/quixos-templates/interface-presentation-mount.git"; commit "837f31b643da53c52ae9d4b61f29c02a1f4c3a83"; }
|
||||
interface PresentationState source { repository "https://repos.quixos.org/quixos-templates/interface-presentation-state.git"; commit "e45cd54d915210819c9eea2b74075807a48f72af"; }
|
||||
interface Presentation source { repository "https://repos.quixos.org/quixos-templates/interface-presentation.git"; commit "1470958778a58992d0732b193ba79bae48a552b0"; }
|
||||
interface ReadingNavigation source { repository "https://repos.quixos.org/quixos-templates/interface-reading-navigation.git"; commit "f237c2d8ef235dabb941b9c8936bcf94b938d7ad"; }
|
||||
interface ReadingServices source { repository "https://repos.quixos.org/quixos-templates/interface-reading-services.git"; commit "89659cf5b6d5688ba9e01b1007a6749b865a2201"; }
|
||||
interface GutenbergCatalog source { repository "https://repos.quixos.org/quixos-templates/interface-gutenberg-catalog.git"; commit "af259cf22a7a63e8ba53c0d44522f4e19b3633d0"; }
|
||||
quixos source { repository "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos.git"; commit "488f7e229afed8f03fc3bfa4abe707da0c613460"; }
|
||||
interface LanguageReader source { repository "https://repos.quixos.org/quixos-templates/interface-language-reader.git"; commit "8de22a0d48b96a31651eb15c4fb4c8a7e244f9e6"; }
|
||||
interface ReadingReader source { repository "https://repos.quixos.org/quixos-templates/interface-reading-reader.git"; commit "f00914748db8594df1a9916d933e7ed801e9beef"; }
|
||||
interface ReadingDocument source { repository "https://repos.quixos.org/quixos-templates/interface-reading-document.git"; commit "7f3c95fc9a4b7bb3ad3c695bb58a74a10db290d3"; }
|
||||
interface ReadingFeature source { repository "https://repos.quixos.org/quixos-templates/interface-reading-feature.git"; commit "3533a0f2cedd3b5993ae08986d7f6a4030c28445"; }
|
||||
interface ReadingJob source { repository "https://repos.quixos.org/quixos-templates/interface-reading-job.git"; commit "71deaa6f479bf226a55ecc2c8b15130f855c6972"; }
|
||||
interface ReadingWord source { repository "https://repos.quixos.org/quixos-templates/interface-reading-word.git"; commit "2623679d1259ec5646a66cae94c78b886416fd36"; }
|
||||
interface ReadingVocabulary source { repository "https://repos.quixos.org/quixos-templates/interface-reading-vocabulary.git"; commit "95f608afeeb255e2eb6c00d22ccc2d8efa13742d"; }
|
||||
interface AgentRequest source { repository "https://repos.quixos.org/quixos-templates/interface-agent-request.git"; commit "e5143427c37b6dc8bbf1b542f95bf08473905f9d"; }
|
||||
interface AgentThread source { repository "https://repos.quixos.org/quixos-templates/interface-agent-thread.git"; commit "bd77d8dfbc8ec72902249a28912fb749a49d943a"; }
|
||||
interface AgentItem source { repository "https://repos.quixos.org/quixos-templates/interface-agent-item.git"; commit "ecd25e19dc169403d66e41dcab660f3d4219b0e2"; }
|
||||
interface AgentQuestion source { repository "https://repos.quixos.org/quixos-templates/interface-agent-question.git"; commit "18ed4818742b6ab013b1dd50ede348c597fd2037"; }
|
||||
interface StandaloneView source { repository "https://repos.quixos.org/quixos-templates/interface-react-standalone-view.git"; commit "fb382e3ca97dfd99b35ed6403198e23a8654c624"; }
|
||||
interface ReactComponent source { repository "https://repos.quixos.org/quixos-templates/interface-react-component.git"; commit "d6ce4d674379ee93645dee5df4b43c1304d44b68"; }
|
||||
interface PresentationMount source { repository "https://repos.quixos.org/quixos-templates/interface-presentation-mount.git"; commit "52d9ef58de0aa8b1c1ba7d38c2606ea51511b6c2"; }
|
||||
interface PresentationState source { repository "https://repos.quixos.org/quixos-templates/interface-presentation-state.git"; commit "ac0194a32b7773d6f738c94371c5b610d1946521"; }
|
||||
interface Presentation source { repository "https://repos.quixos.org/quixos-templates/interface-presentation.git"; commit "4d63aaa32d91524f4f96b7364180b1a62b3eeea2"; }
|
||||
interface ReadingNavigation source { repository "https://repos.quixos.org/quixos-templates/interface-reading-navigation.git"; commit "8f90502dcf3626bca59044cf68709c4db0a3cfac"; }
|
||||
interface ReadingServices source { repository "https://repos.quixos.org/quixos-templates/interface-reading-services.git"; commit "02d0b41c6f1b25439318e2764f6499c2bd6d04ba"; }
|
||||
interface GutenbergCatalog source { repository "https://repos.quixos.org/quixos-templates/interface-gutenberg-catalog.git"; commit "6a7d7881ab0656ea4209934e5e81de1759951e10"; }
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ export const annotationDisplays: Record<
|
||||
string,
|
||||
(items: Item[], options: ConfigValues, context?: { source: string; vocabulary: ReadonlySet<string> }) => Item[]
|
||||
> = {
|
||||
names: (items, options) =>
|
||||
items.map((item) => ({ ...item, color: String(options[item.tag + "Color"] ?? "#66866b") })),
|
||||
grammar: (items, options) =>
|
||||
items.map((item) => ({ ...item, color: String(options[item.tag + "Color"] ?? options.otherColor ?? "#66866b") })),
|
||||
frenchEasyVocabulary: (items, options) =>
|
||||
items.filter((item) => {
|
||||
const match = /^cefr:(A1|A2):(noun|adjective|verb)$/.exec(item.tag);
|
||||
@@ -52,26 +56,13 @@ export function presentAnnotations(
|
||||
options: ConfigValues,
|
||||
context?: { source: string; vocabulary: ReadonlySet<string> },
|
||||
) {
|
||||
const decorated = items.map((item) => ({
|
||||
...item,
|
||||
color:
|
||||
typeof (options[item.tag + "Color"] ?? options.otherColor) === "string"
|
||||
? String(options[item.tag + "Color"] ?? options.otherColor)
|
||||
: undefined,
|
||||
fontFamily: String(options.fontFamily ?? ""),
|
||||
fontSize: Number(options.fontSize ?? 13),
|
||||
underlinePattern: (options.underlinePattern ?? item.underlinePattern ?? "solid") as UnderlinePattern,
|
||||
placement: (options.placement ?? item.placement ?? "above") as "above" | "below",
|
||||
}));
|
||||
return (annotationDisplays[processor]?.(decorated, options, context) ?? decorated).map((item) => {
|
||||
return (annotationDisplays[processor]?.(items, options, context) ?? items).map((item) => {
|
||||
if (
|
||||
(item.underlinePattern && !["solid", "dashed", "squiggly"].includes(item.underlinePattern)) ||
|
||||
(item.placement !== "above" && item.placement !== "below") ||
|
||||
(item.placement && item.placement !== "above" && item.placement !== "below") ||
|
||||
(item.color && !/^#[0-9a-f]{6}$/i.test(item.color)) ||
|
||||
(item.fontFamily && (item.fontFamily.length > 160 || /[\r\n\x00]/.test(item.fontFamily))) ||
|
||||
!Number.isFinite(item.fontSize) ||
|
||||
item.fontSize! < 6 ||
|
||||
item.fontSize! > 72
|
||||
(item.fontSize !== undefined && (!Number.isFinite(item.fontSize) || item.fontSize < 6 || item.fontSize > 72))
|
||||
)
|
||||
throw Error("Invalid annotator appearance");
|
||||
return item;
|
||||
|
||||
+108
-103
@@ -3,29 +3,19 @@ import { ColorPicker, FontPicker, NumberControl, Options, Switch, UnderlinePrevi
|
||||
import type { ComponentType } from "react";
|
||||
import type { AnnotationRender } from "./render-hooks.js";
|
||||
|
||||
export type ConfigValue = string | number | boolean;
|
||||
export type ConfigValues = Record<string, ConfigValue>;
|
||||
export type ConfigField = {
|
||||
key: string;
|
||||
label: string;
|
||||
kind: "color" | "number" | "select" | "toggle" | "text";
|
||||
default: ConfigValue;
|
||||
min?: number;
|
||||
max?: number;
|
||||
computation?: boolean;
|
||||
options?: { value: string; label: string }[];
|
||||
};
|
||||
import { configDefaults, type ConfigValue, type ConfigValues, type ConfigNode } from "./config-schema.js";
|
||||
export type { ConfigValue, ConfigValues, ConfigField, ConfigNode } from "./config-schema.js";
|
||||
export type AnnotatorConfigProps = {
|
||||
fields: ConfigField[];
|
||||
fields: ConfigNode[];
|
||||
values: ConfigValues;
|
||||
disabled: boolean;
|
||||
change: (key: string, value: ConfigValue) => void;
|
||||
};
|
||||
// Authors may install a purpose-built inline component here. The component edits
|
||||
// the same validated processor options as the generated controls; it does not
|
||||
// own persistence, model calls, or the generic appearance/reveal preferences.
|
||||
// own persistence or model calls. Every control, including appearance, is opt-in.
|
||||
export const annotatorConfigViews: Record<string, ComponentType<AnnotatorConfigProps>> = {
|
||||
pinyin: ({ values, disabled, change }) => (
|
||||
pinyin: ({ fields, values, disabled, change }) => (
|
||||
<div className="lr-hsk-control">
|
||||
<label htmlFor="lr-hsk-level">Words above your HSK level</label>
|
||||
<LocalInput
|
||||
@@ -52,6 +42,13 @@ export const annotatorConfigViews: Record<string, ComponentType<AnnotatorConfigP
|
||||
))}
|
||||
</div>
|
||||
<strong>{Number(values.minimumLevel ?? 2) ? `Above HSK ${values.minimumLevel ?? 2}` : "All words"}</strong>
|
||||
<CustomConfig
|
||||
processor="pinyin-appearance"
|
||||
fields={fields.filter((field) => field.key !== "minimumLevel")}
|
||||
values={values}
|
||||
disabled={disabled}
|
||||
change={change}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
};
|
||||
@@ -64,27 +61,21 @@ export function configValues(raw: string): ConfigValues {
|
||||
}
|
||||
}
|
||||
export function configDefinition(raw: string): {
|
||||
fields: ConfigField[];
|
||||
settings: { color?: boolean; font?: boolean; when?: string[] };
|
||||
fields: ConfigNode[];
|
||||
description: string;
|
||||
preset?: { style: string; reveal: string };
|
||||
cache?: { identity: string; inputs: string[]; previousRevisions?: string[] };
|
||||
renders?: AnnotationRender[];
|
||||
} {
|
||||
try {
|
||||
const value = JSON.parse(raw);
|
||||
return Array.isArray(value)
|
||||
? { fields: value, settings: {}, description: "" }
|
||||
: {
|
||||
fields: value.fields ?? [],
|
||||
settings: value.settings ?? {},
|
||||
description: value.description ?? "",
|
||||
preset: value.preset,
|
||||
cache: value.cache,
|
||||
renders: value.renders,
|
||||
};
|
||||
return {
|
||||
fields: value.fields ?? [],
|
||||
description: value.description ?? "",
|
||||
cache: value.cache,
|
||||
renders: value.renders,
|
||||
};
|
||||
} catch {
|
||||
return { fields: [], settings: {}, description: "" };
|
||||
return { fields: [], description: "" };
|
||||
}
|
||||
}
|
||||
export const configFields = (raw: string) => configDefinition(raw).fields;
|
||||
@@ -99,91 +90,105 @@ export function CustomConfig({
|
||||
if (Custom) return <Custom fields={fields} values={values} change={change} disabled={disabled} />;
|
||||
return (
|
||||
<div className="lr-processor-settings">
|
||||
{fields.map((field) => (
|
||||
<div key={field.key} className="lr-field">
|
||||
<span>{field.label}</span>
|
||||
{field.key === "fontFamily" ? (
|
||||
<FontPicker
|
||||
label={field.label}
|
||||
value={String(values[field.key] ?? field.default)}
|
||||
{fields.map((field) =>
|
||||
field.kind === "group" ? (
|
||||
<fieldset key={field.key} className="lr-config-group">
|
||||
<legend>{field.label}</legend>
|
||||
<CustomConfig
|
||||
processor={processor + "/" + field.key}
|
||||
fields={field.fields}
|
||||
values={
|
||||
typeof values[field.key] === "object"
|
||||
? (values[field.key] as ConfigValues)
|
||||
: configDefaults(field.fields)
|
||||
}
|
||||
disabled={disabled}
|
||||
inherit
|
||||
change={(value) => change(field.key, value)}
|
||||
change={(key, value) =>
|
||||
change(field.key, {
|
||||
...configDefaults(field.fields),
|
||||
...(typeof values[field.key] === "object" ? (values[field.key] as ConfigValues) : {}),
|
||||
[key]: value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
) : field.kind === "select" ? (
|
||||
<Options
|
||||
label={field.label}
|
||||
value={String(values[field.key] ?? field.default)}
|
||||
options={(field.options ?? []).map((option) => ({
|
||||
...option,
|
||||
...(field.key === "underlinePattern" ? { preview: <UnderlinePreview pattern={option.value} /> } : {}),
|
||||
}))}
|
||||
disabled={disabled}
|
||||
change={(value) => change(field.key, value)}
|
||||
/>
|
||||
) : field.kind === "toggle" ? (
|
||||
<Switch
|
||||
label={field.label}
|
||||
value={Boolean(values[field.key] ?? field.default)}
|
||||
disabled={disabled}
|
||||
change={(value) => change(field.key, value)}
|
||||
/>
|
||||
) : field.kind === "color" ? (
|
||||
<ColorPicker
|
||||
label={field.label}
|
||||
value={String(values[field.key] ?? field.default)}
|
||||
disabled={disabled}
|
||||
change={(value) => change(field.key, value)}
|
||||
/>
|
||||
) : field.kind === "number" ? (
|
||||
<NumberControl
|
||||
label={field.label}
|
||||
value={Number(values[field.key] ?? field.default)}
|
||||
disabled={disabled}
|
||||
min={field.min}
|
||||
max={field.max}
|
||||
change={(value) => change(field.key, value)}
|
||||
/>
|
||||
) : (
|
||||
<LocalInput
|
||||
aria-label={field.label}
|
||||
value={String(values[field.key] ?? field.default)}
|
||||
disabled={disabled}
|
||||
onChange={(e) => change(field.key, e.target.value)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</fieldset>
|
||||
) : (
|
||||
<div key={field.key} className="lr-field">
|
||||
<span>{field.label}</span>
|
||||
{field.presentation === "font" ? (
|
||||
<FontPicker
|
||||
label={field.label}
|
||||
value={String(values[field.key] ?? field.default)}
|
||||
disabled={disabled}
|
||||
inherit
|
||||
change={(value) => change(field.key, value)}
|
||||
/>
|
||||
) : field.kind === "select" ? (
|
||||
<Options
|
||||
label={field.label}
|
||||
value={String(values[field.key] ?? field.default)}
|
||||
options={(field.options ?? []).map((option) => ({
|
||||
...option,
|
||||
...(field.presentation === "underline"
|
||||
? { preview: <UnderlinePreview pattern={option.value} /> }
|
||||
: {}),
|
||||
}))}
|
||||
disabled={disabled}
|
||||
change={(value) => change(field.key, value)}
|
||||
/>
|
||||
) : field.kind === "toggle" ? (
|
||||
<Switch
|
||||
label={field.label}
|
||||
value={Boolean(values[field.key] ?? field.default)}
|
||||
disabled={disabled}
|
||||
change={(value) => change(field.key, value)}
|
||||
/>
|
||||
) : field.kind === "color" ? (
|
||||
<ColorPicker
|
||||
label={field.label}
|
||||
value={String(values[field.key] ?? field.default)}
|
||||
disabled={disabled}
|
||||
change={(value) => change(field.key, value)}
|
||||
/>
|
||||
) : field.kind === "number" ? (
|
||||
<NumberControl
|
||||
label={field.label}
|
||||
value={Number(values[field.key] ?? field.default)}
|
||||
disabled={disabled}
|
||||
min={field.min}
|
||||
max={field.max}
|
||||
change={(value) => change(field.key, value)}
|
||||
/>
|
||||
) : (
|
||||
<LocalInput
|
||||
aria-label={field.label}
|
||||
value={String(values[field.key] ?? field.default)}
|
||||
disabled={disabled}
|
||||
onChange={(e) => change(field.key, e.target.value)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
),
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export const fontFields: ConfigField[] = [
|
||||
{
|
||||
key: "fontFamily",
|
||||
label: "Annotation font",
|
||||
kind: "select",
|
||||
default: "",
|
||||
options: [
|
||||
{ value: "", label: "Match the reading text" },
|
||||
{ value: '"Noto Serif", Georgia, serif', label: "Serif" },
|
||||
{ value: "system-ui, sans-serif", label: "Sans serif" },
|
||||
{ value: "ui-monospace, monospace", label: "Monospace" },
|
||||
],
|
||||
},
|
||||
|
||||
// Creation suggestions only: these are never injected into a built annotator.
|
||||
export const fontFields: ConfigNode[] = [
|
||||
{ key: "fontFamily", label: "Annotation font", kind: "text", presentation: "font", default: "" },
|
||||
{ key: "fontSize", label: "Annotation font size", kind: "number", default: 13, min: 6, max: 72 },
|
||||
];
|
||||
|
||||
export const underlineFields: ConfigField[] = [
|
||||
export const underlineFields: ConfigNode[] = [
|
||||
{
|
||||
key: "underlinePattern",
|
||||
label: "Underline pattern",
|
||||
kind: "select",
|
||||
presentation: "underline",
|
||||
default: "solid",
|
||||
computation: false,
|
||||
options: [
|
||||
{ value: "solid", label: "Solid" },
|
||||
{ value: "dashed", label: "Dashed" },
|
||||
{ value: "squiggly", label: "Squiggly" },
|
||||
],
|
||||
options: ["solid", "dashed", "squiggly"].map((value) => ({
|
||||
value,
|
||||
label: value[0].toUpperCase() + value.slice(1),
|
||||
})),
|
||||
},
|
||||
];
|
||||
|
||||
+14
-1
@@ -11,7 +11,20 @@ export function cacheConfiguration(
|
||||
return JSON.stringify({
|
||||
processor: identity,
|
||||
scope,
|
||||
options: Object.fromEntries([...inputs].sort().map((key) => [key, options[key]])),
|
||||
options: Object.fromEntries(
|
||||
[...inputs]
|
||||
.sort()
|
||||
.map((key) => [
|
||||
key,
|
||||
key
|
||||
.split(".")
|
||||
.reduce<unknown>(
|
||||
(value, part) =>
|
||||
value && typeof value === "object" ? (value as Record<string, unknown>)[part] : undefined,
|
||||
options,
|
||||
),
|
||||
]),
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
export type ConfigValue = string | number | boolean | ConfigValues;
|
||||
export type ConfigValues = { [key: string]: ConfigValue };
|
||||
export type ConfigField = {
|
||||
key: string;
|
||||
label: string;
|
||||
kind: "color" | "number" | "select" | "toggle" | "text";
|
||||
default: string | number | boolean;
|
||||
min?: number;
|
||||
max?: number;
|
||||
computation?: boolean;
|
||||
presentation?: "font" | "underline" | "position";
|
||||
options?: { value: string; label: string }[];
|
||||
};
|
||||
export type ConfigGroup = { key: string; label: string; kind: "group"; fields: ConfigNode[] };
|
||||
export type ConfigNode = ConfigField | ConfigGroup;
|
||||
export function configDefaults(fields: ConfigNode[]): ConfigValues {
|
||||
return Object.fromEntries(
|
||||
fields.map((field) => [field.key, field.kind === "group" ? configDefaults(field.fields) : field.default]),
|
||||
);
|
||||
}
|
||||
export function configAt(values: ConfigValues, path: string): ConfigValues {
|
||||
const result = path
|
||||
? path
|
||||
.split(".")
|
||||
.reduce<
|
||||
ConfigValue | undefined
|
||||
>((value, key) => (value && typeof value === "object" ? value[key] : undefined), values)
|
||||
: values;
|
||||
return result && typeof result === "object" ? result : {};
|
||||
}
|
||||
+23
-78
@@ -1,3 +1,5 @@
|
||||
import { configDefaults } from "./config-schema.js";
|
||||
import { resolveRenders } from "./render-hooks.js";
|
||||
import { readerExtensionSettings } from "./reader-extensions.js";
|
||||
import { usePrompt } from "./drafts.js";
|
||||
import {
|
||||
@@ -27,10 +29,10 @@ import { ReaderPreview } from "./preview.js";
|
||||
import { interfaces } from "./gen/client.js";
|
||||
import {
|
||||
CustomConfig,
|
||||
configFields,
|
||||
configValues,
|
||||
fontFields,
|
||||
underlineFields,
|
||||
configFields,
|
||||
configValues,
|
||||
type ConfigValues,
|
||||
type ConfigValue,
|
||||
} from "./annotator-config.js";
|
||||
@@ -462,7 +464,7 @@ export function ReaderSettings({
|
||||
aria-current={section === referenceOf(f).object ? "page" : undefined}
|
||||
onClick={() => setSection(referenceOf(f).object)}
|
||||
>
|
||||
<i style={{ background: f.data.color }} />
|
||||
<i className="lr-annotator-dot" />
|
||||
{f.data.name}
|
||||
{!f.data.enabled && <small>Off</small>}
|
||||
</button>
|
||||
@@ -764,10 +766,11 @@ function AnnotatorLibrary({
|
||||
const isArchived = (key: string) => archiveIntent[key] ?? archivedTypes.includes(key);
|
||||
const item = catalog.find((candidate) => candidate.key === selected);
|
||||
const definition = configDefinition(item?.config ?? "{}");
|
||||
const style = definition.preset?.style ?? "highlight";
|
||||
const channels = resolveRenders(definition.renders, values);
|
||||
const style = channels[0]?.style ?? "color";
|
||||
const choose = (candidate: Catalog[number]) => {
|
||||
const fields = configDefinition(candidate.config).fields;
|
||||
setValues(Object.fromEntries(fields.map((field) => [field.key, field.default])));
|
||||
setValues(configDefaults(fields));
|
||||
setTitle(candidate.label);
|
||||
setSelected(candidate.key);
|
||||
setError("");
|
||||
@@ -800,11 +803,6 @@ function AnnotatorLibrary({
|
||||
reader: { ...referenceOf(reader), expectation: { kind: "atom", id: "atom:reading:reader" } },
|
||||
name: title.trim() || item.label,
|
||||
processor: item.key,
|
||||
style,
|
||||
reveal: definition.preset?.reveal ?? "always",
|
||||
generation: item.strategy,
|
||||
scope: item.scope,
|
||||
color: "#53796c",
|
||||
options: JSON.stringify(values),
|
||||
}),
|
||||
),
|
||||
@@ -855,24 +853,13 @@ function AnnotatorLibrary({
|
||||
disabled={busy}
|
||||
change={(key, value) => setValues((previous) => ({ ...previous, [key]: value }))}
|
||||
/>
|
||||
{style === "overhead" && (
|
||||
<LabelPosition
|
||||
value={String(values.placement ?? "above")}
|
||||
disabled={busy}
|
||||
change={(placement) => setValues((previous) => ({ ...previous, placement }))}
|
||||
/>
|
||||
)}
|
||||
<footer>
|
||||
<span>
|
||||
{style === "overhead"
|
||||
? "Text labels"
|
||||
: (appearances.find((appearance) => appearance.key === style)?.title ?? style)}{" "}
|
||||
·{" "}
|
||||
{definition.preset?.reveal === "click"
|
||||
? "On click"
|
||||
: definition.preset?.reveal === "hover"
|
||||
? "On hover"
|
||||
: "Always"}
|
||||
{channels[0]?.reveal === "click" ? "On click" : channels[0]?.reveal === "hover" ? "On hover" : "Always"}
|
||||
</span>
|
||||
<button className="lr-primary" disabled={busy || api.status !== "ready"} onClick={() => void add()}>
|
||||
{busy ? "Adding…" : "Add to reader"}
|
||||
@@ -890,11 +877,11 @@ function AnnotatorLibrary({
|
||||
<article className="lr-type-card" key={candidate.key}>
|
||||
<button className="lr-type-card-select" onClick={() => choose(candidate)}>
|
||||
<span className="lr-type-mark" aria-hidden="true">
|
||||
{config.preset?.style === "overhead"
|
||||
{config.renders?.[0]?.style === "overhead"
|
||||
? "Ā"
|
||||
: config.preset?.style === "sidebar"
|
||||
: config.renders?.[0]?.style === "sidebar"
|
||||
? "☷"
|
||||
: config.preset?.style === "tooltip"
|
||||
: config.renders?.[0]?.style === "tooltip"
|
||||
? "◌"
|
||||
: "Aa"}
|
||||
</span>
|
||||
@@ -1194,7 +1181,11 @@ function NewAnnotator({
|
||||
</div>
|
||||
<footer className="lr-create-footer">
|
||||
<small>Built and checked by the agent. A title is generated if left empty.</small>
|
||||
<button className="lr-primary" disabled={busy || !text.trim()} onClick={() => void build()}>
|
||||
<button
|
||||
className="lr-primary"
|
||||
disabled={busy || api.status !== "ready" || !text.trim()}
|
||||
onClick={() => void build()}
|
||||
>
|
||||
{busy ? "Starting…" : "Create annotator"}
|
||||
</button>
|
||||
</footer>
|
||||
@@ -1228,7 +1219,6 @@ export function ExistingFeature({
|
||||
feedback.track(ops.value.configure.call({ ...settings, ...changes, expectedRevision: configRevision }));
|
||||
}
|
||||
const definition = configDefinition(catalog.find((item) => item.key === d.processor)?.config ?? "{}"),
|
||||
showOptions = revealOptions(d.style).filter((option) => definition.settings.when?.includes(option.value)),
|
||||
persisted = configValues(feature.options),
|
||||
values = draft?.values ?? persisted;
|
||||
useEffect(() => {
|
||||
@@ -1286,29 +1276,13 @@ export function ExistingFeature({
|
||||
/>
|
||||
</label>
|
||||
<p className="lr-output-summary">
|
||||
{appearances.find((a) => a.key === d.style)?.title ?? d.style} ·{" "}
|
||||
{d.reveal === "always" ? "Always shown" : d.reveal === "hover" ? "Shown when hovering" : "Shown when clicked"}
|
||||
{resolveRenders(definition.renders, values)
|
||||
.map(
|
||||
(render) =>
|
||||
`${appearances.find((a) => a.key === render.style)?.title ?? render.style} · ${render.reveal === "always" ? "Always" : render.reveal === "hover" ? "On hover" : "On click"}`,
|
||||
)
|
||||
.join("; ")}
|
||||
</p>
|
||||
{showOptions.length > 0 && (
|
||||
<div className="lr-field">
|
||||
Show annotations
|
||||
<Options
|
||||
label={d.name + " show annotations"}
|
||||
value={d.reveal}
|
||||
options={showOptions.map((o) => ({
|
||||
...o,
|
||||
label: o.value === "always" ? "Always" : o.value === "hover" ? "When hovering" : "When clicked",
|
||||
}))}
|
||||
change={(reveal) => update({ reveal })}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{definition.settings.color && (
|
||||
<div className="lr-field">
|
||||
Annotation color
|
||||
<ColorPicker label={d.name + " color"} value={d.color} change={(color) => update({ color })} />
|
||||
</div>
|
||||
)}
|
||||
<CustomConfig
|
||||
processor={d.processor}
|
||||
fields={definition.fields}
|
||||
@@ -1316,33 +1290,6 @@ export function ExistingFeature({
|
||||
disabled={saving}
|
||||
change={change}
|
||||
/>
|
||||
{(d.style === "underline" || definition.renders?.some((render) => render.style === "underline")) && (
|
||||
<CustomConfig
|
||||
processor="underline-pattern"
|
||||
fields={underlineFields}
|
||||
values={values}
|
||||
disabled={saving}
|
||||
change={change}
|
||||
/>
|
||||
)}
|
||||
{definition.settings.font && d.style === "overhead" && (
|
||||
<>
|
||||
{!definition.fields.some((field) => field.key === "placement") && (
|
||||
<LabelPosition
|
||||
value={String(values.placement ?? "above")}
|
||||
disabled={saving}
|
||||
change={(placement) => change("placement", placement)}
|
||||
/>
|
||||
)}
|
||||
<CustomConfig
|
||||
processor="overhead-font"
|
||||
fields={fontFields}
|
||||
values={values}
|
||||
disabled={saving}
|
||||
change={change}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{draft && (
|
||||
<div className="lr-config-save">
|
||||
<button className="lr-primary" disabled={saving} onClick={() => void save()}>
|
||||
@@ -1401,8 +1348,6 @@ function AskForChange({
|
||||
reader: { ...referenceOf(reader), expectation: { kind: "atom", id: "atom:reading:reader" } },
|
||||
configuration: JSON.stringify({
|
||||
name: feature.data.name,
|
||||
style: feature.data.style,
|
||||
reveal: feature.data.reveal,
|
||||
instructions: text,
|
||||
feature: referenceOf(feature),
|
||||
}),
|
||||
|
||||
@@ -58,3 +58,7 @@ export async function accepted<T>(ticket: { settled: Promise<{ status: string; v
|
||||
if (outcome.status !== "accepted") throw Error(JSON.stringify(outcome));
|
||||
return outcome.value as T;
|
||||
}
|
||||
|
||||
export type ProcessingFeature = FeatureNode & {
|
||||
data: FeatureNode["data"] & { generation: string; scope: string; color: string };
|
||||
};
|
||||
|
||||
+10
-10
@@ -1,3 +1,4 @@
|
||||
import { configDefaults } from "./config-schema.js";
|
||||
import { useMemo } from "react";
|
||||
import { referenceOf, type ExactReference } from "@quixos/camino-react";
|
||||
import { type Catalog, type DocNode, type FeatureNode, type ReaderNode } from "./model.js";
|
||||
@@ -64,13 +65,13 @@ export function ReaderPreview({
|
||||
if (!entry) continue;
|
||||
const definition = configDefinition(entry.config);
|
||||
const options = {
|
||||
...Object.fromEntries(definition.fields.map((field) => [field.key, field.default])),
|
||||
...configDefaults(definition.fields),
|
||||
...configValues(feature.options),
|
||||
};
|
||||
const configuration = cacheConfiguration(
|
||||
definition.cache?.identity ?? feature.data.processor,
|
||||
feature.data.scope,
|
||||
feature.data.generation,
|
||||
entry.scope,
|
||||
entry.strategy,
|
||||
options,
|
||||
definition.cache?.inputs ?? [],
|
||||
);
|
||||
@@ -108,15 +109,14 @@ export function ReaderPreview({
|
||||
id: `${referenceOf(feature).object}:${job.data.key}:${index}`,
|
||||
feature: referenceOf(feature).object,
|
||||
activation: { start: job.data.start, end: job.data.end },
|
||||
priority:
|
||||
(feature.data.scope === "word" ? 0 : feature.data.scope === "sentence" ? 1 : 2) * features.length +
|
||||
order,
|
||||
style: item.style ?? (feature.data.style as Annotation["style"]),
|
||||
reveal: item.reveal ?? (feature.data.reveal as Annotation["reveal"]),
|
||||
color: item.color ?? feature.data.color,
|
||||
priority: (entry.scope === "word" ? 0 : entry.scope === "sentence" ? 1 : 2) * features.length + order,
|
||||
style: item.style ?? "color",
|
||||
reveal: item.reveal ?? "always",
|
||||
color: item.color ?? "",
|
||||
},
|
||||
text,
|
||||
item.style ? undefined : definition.renders,
|
||||
item.style ? [{ style: item.style, reveal: item.reveal ?? "always" }] : definition.renders,
|
||||
options,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
+4
-3
@@ -2,11 +2,12 @@ import { useEffect, useRef, useState } from "react";
|
||||
import { referenceOf, useInterface } from "@quixos/camino-react";
|
||||
import { interfaces } from "./gen/client.js";
|
||||
import { sameCacheConfiguration } from "./cache.js";
|
||||
import { accepted, errorMessage, type DocNode, type FeatureNode } from "./model.js";
|
||||
import { accepted, errorMessage, type DocNode, type ProcessingFeature as FeatureNode } from "./model.js";
|
||||
import { preparationQueue, processorMatches, sameScope } from "./work.js";
|
||||
import type { Range } from "./canvas/types.js";
|
||||
import type { ReadingWindow } from "./canvas/pages.js";
|
||||
import type { AnnotationRender } from "./render-hooks.js";
|
||||
import { resolveRenders, type AnnotationRender } from "./render-hooks.js";
|
||||
import { configValues } from "./annotator-config.js";
|
||||
|
||||
type Planned = { feature: FeatureNode; range: Range; context: string; planning?: "click" | "hover" };
|
||||
/** One admission/cache path for proximity preparation, clicks, hover and retry.
|
||||
@@ -191,7 +192,7 @@ export function useProcessing({
|
||||
(f) =>
|
||||
f.data.enabled &&
|
||||
f.data.generation === "focus" &&
|
||||
(renders[f.data.processor] ?? [{ reveal: f.data.reveal }]).some((render) =>
|
||||
resolveRenders(renders[f.data.processor], configValues(f.options)).some((render) =>
|
||||
kind === "hover" ? render.reveal === "hover" : render.reveal !== "hover",
|
||||
),
|
||||
);
|
||||
|
||||
+38
-7
@@ -1,21 +1,52 @@
|
||||
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. */
|
||||
import { configAt, type ConfigValues } from "./config-schema.js";
|
||||
/** Each channel is code-owned. Options explicitly binds an appearance struct;
|
||||
* several channels can use different structs from the same annotator config. */
|
||||
export type AnnotationRender = {
|
||||
style: Annotation["style"];
|
||||
underlinePattern?: Annotation["underlinePattern"];
|
||||
placement?: Annotation["placement"];
|
||||
color?: string;
|
||||
fontFamily?: string;
|
||||
fontSize?: number;
|
||||
options?: string;
|
||||
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(
|
||||
export function resolveRenders(renders: readonly AnnotationRender[] | undefined, values: ConfigValues = {}) {
|
||||
return (renders ?? []).map((render) => {
|
||||
const bound = render.options === undefined ? {} : configAt(values, render.options);
|
||||
const output = { ...render };
|
||||
for (const key of ["color", "fontFamily", "fontSize", "placement", "underlinePattern", "reveal"] as const)
|
||||
if (bound[key] !== undefined) Object.assign(output, { [key]: bound[key] });
|
||||
if (
|
||||
!["always", "click", "hover"].includes(output.reveal) ||
|
||||
(output.reveal === "hover" && ["overhead", "replace", "bold", "italic"].includes(output.style)) ||
|
||||
(output.style === "tooltip" && output.reveal === "always") ||
|
||||
(output.underlinePattern && !["solid", "dashed", "squiggly"].includes(output.underlinePattern)) ||
|
||||
(output.placement && !["above", "below"].includes(output.placement)) ||
|
||||
(output.color && !/^#[0-9a-f]{6}$/i.test(output.color)) ||
|
||||
(output.fontFamily && (output.fontFamily.length > 160 || /[\r\n\x00]/.test(output.fontFamily))) ||
|
||||
(output.fontSize !== undefined &&
|
||||
(!Number.isFinite(output.fontSize) || output.fontSize < 6 || output.fontSize > 72))
|
||||
)
|
||||
throw Error("Invalid annotator render channel");
|
||||
return output;
|
||||
});
|
||||
}
|
||||
export function renderAnnotations(
|
||||
item: Annotation,
|
||||
source: string,
|
||||
renders: readonly AnnotationRender[] | undefined,
|
||||
values: ConfigValues = {},
|
||||
) {
|
||||
if (!renders?.length) return [];
|
||||
return resolveRenders(renders, values).map(
|
||||
(render, index): Annotation => ({
|
||||
...item,
|
||||
id: `${item.id}:render:${index}`,
|
||||
...render,
|
||||
id: `${item.id}:render:${index}`,
|
||||
color: item.color || render.color || "#66866b",
|
||||
text: render.content === "source" ? source.slice(item.start, item.end) : item.text,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export const readingStyle = `
|
||||
.lr-config-group{border:1px solid #d9dfd6;border-radius:12px;padding:18px;margin:10px 0 20px;min-width:0}.lr-config-group legend{padding:0 8px;font-weight:600;color:#354b3f}.lr-config-group .lr-processor-settings{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:18px}.lr-annotator-dot{background:#66866b}
|
||||
.lr-app{--ink:#303a36;--muted:#7c827b;--line:#e6e6de;--green:#3e6957;position:relative;display:flex;flex:0 1 auto;height:calc(100dvh - var(--reader-top,120px));max-height:100%;min-height:0;background:#fafaf6;color:var(--ink);font:14px/1.5 system-ui,sans-serif;overflow:hidden}
|
||||
|
||||
.lr-app *{box-sizing:border-box}
|
||||
|
||||
+40
-15
@@ -1,10 +1,11 @@
|
||||
import { configDefaults } from "./config-schema.js";
|
||||
import { Texts } from "./texts.js";
|
||||
import { cacheConfiguration, sameCacheConfiguration } from "./cache.js";
|
||||
import { configDefinition, configValues } from "./annotator-config.js";
|
||||
import { presentAnnotations } from "./annotation-display.js";
|
||||
import { Options } from "./controls.js";
|
||||
import { Button, Choice, SegmentedControl, useCommandControl } from "@quixos/camino-react/ui";
|
||||
import { renderAnnotations, type AnnotationRender } from "./render-hooks.js";
|
||||
import { renderAnnotations, resolveRenders, type AnnotationRender } from "./render-hooks.js";
|
||||
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
||||
import {
|
||||
referenceOf,
|
||||
@@ -112,15 +113,15 @@ export const Reader: Modules["Reader"] = ({ subject, navigation, input }) => {
|
||||
const entry = catalog.find((item) => item.key === feature.data.processor);
|
||||
const definition = configDefinition(entry?.config ?? "{}");
|
||||
const options = {
|
||||
...Object.fromEntries(definition.fields.map((field) => [field.key, field.default])),
|
||||
...configDefaults(definition.fields),
|
||||
...configValues(feature.options),
|
||||
};
|
||||
return [
|
||||
referenceOf(feature).object,
|
||||
cacheConfiguration(
|
||||
definition.cache?.identity ?? feature.data.processor,
|
||||
feature.data.scope,
|
||||
feature.data.generation,
|
||||
entry?.scope ?? "word",
|
||||
entry?.strategy ?? "section",
|
||||
options,
|
||||
definition.cache?.inputs ?? [],
|
||||
),
|
||||
@@ -255,6 +256,7 @@ export const Reader: Modules["Reader"] = ({ subject, navigation, input }) => {
|
||||
revisionAliases={revisionAliases}
|
||||
computations={computations}
|
||||
renders={renders}
|
||||
catalog={catalog}
|
||||
reader={activeReader}
|
||||
onOpen={open}
|
||||
navigation={navigation.reference}
|
||||
@@ -319,6 +321,7 @@ function ReadingDocument({
|
||||
revisionAliases,
|
||||
computations,
|
||||
renders,
|
||||
catalog,
|
||||
reader,
|
||||
onOpen,
|
||||
navigation,
|
||||
@@ -338,6 +341,7 @@ function ReadingDocument({
|
||||
revisionAliases: Record<string, readonly string[]>;
|
||||
computations: Record<string, string>;
|
||||
renders: Record<string, AnnotationRender[] | undefined>;
|
||||
catalog: Catalog;
|
||||
reader?: ReaderNode;
|
||||
onOpen: (ref: ExactReference) => void;
|
||||
navigation: ExactReference;
|
||||
@@ -430,14 +434,32 @@ function ReadingDocument({
|
||||
}
|
||||
const features = useMemo(() => {
|
||||
const members = new Set(reader?.features.entries.map((e) => referenceOf(e.node).object) ?? []);
|
||||
return root.features.entries.map((e) => e.node).filter((f) => members.has(referenceOf(f).object));
|
||||
}, [root.features.entries, reader]),
|
||||
return root.features.entries
|
||||
.map((e) => e.node)
|
||||
.filter((f) => members.has(referenceOf(f).object))
|
||||
.flatMap((feature) => {
|
||||
const entry = catalog.find((item) => item.key === feature.data.processor);
|
||||
if (!entry) return [];
|
||||
const channels = resolveRenders(renders[feature.data.processor], configValues(feature.options));
|
||||
return [
|
||||
{
|
||||
...feature,
|
||||
data: {
|
||||
...feature.data,
|
||||
generation: entry.strategy,
|
||||
scope: entry.scope,
|
||||
color: channels[0]?.color ?? "#66866b",
|
||||
},
|
||||
},
|
||||
];
|
||||
});
|
||||
}, [root.features.entries, reader, catalog, renders]),
|
||||
jobs = useMemo(() => doc.jobs.entries.map(({ node }) => node), [doc.jobs.entries]);
|
||||
const enabled = features.filter((feature) => feature.data.enabled);
|
||||
const displays = enabled.flatMap((feature) =>
|
||||
(renders[feature.data.processor] ?? [{ style: feature.data.style, reveal: feature.data.reveal }]).map((render) => ({
|
||||
resolveRenders(renders[feature.data.processor], configValues(feature.options)).map((render) => ({
|
||||
...feature,
|
||||
data: { ...feature.data, style: render.style, reveal: render.reveal },
|
||||
data: { ...feature.data, style: render.style, reveal: render.reveal, color: render.color ?? feature.data.color },
|
||||
})),
|
||||
);
|
||||
const model = useProcessing({
|
||||
@@ -587,12 +609,13 @@ function ReadingDocument({
|
||||
priority:
|
||||
(feature.data.scope === "word" ? 0 : feature.data.scope === "sentence" ? 1 : 2) * features.length +
|
||||
features.indexOf(feature),
|
||||
style: item.style ?? (feature.data.style as Annotation["style"]),
|
||||
reveal: item.reveal ?? (feature.data.reveal as Annotation["reveal"]),
|
||||
color: item.color ?? feature.data.color,
|
||||
style: item.style ?? "color",
|
||||
reveal: item.reveal ?? "always",
|
||||
color: item.color ?? "",
|
||||
},
|
||||
doc.data.text,
|
||||
item.style ? undefined : renders[feature.data.processor],
|
||||
item.style ? [{ style: item.style, reveal: item.reveal ?? "always" }] : renders[feature.data.processor],
|
||||
configValues(feature.options),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -604,7 +627,7 @@ function ReadingDocument({
|
||||
const annotation = annotationMap.find((item) => item.id === id),
|
||||
feature = features.find((feature) => referenceOf(feature).object === annotation?.feature);
|
||||
if (!annotation || !feature) return false;
|
||||
const reveal = annotation.reveal ?? feature.data.reveal;
|
||||
const reveal = annotation.reveal ?? "always";
|
||||
if (reveal === "click" && feature.data.generation === "focus" && feature.data.scope !== "word")
|
||||
return (
|
||||
!!focus &&
|
||||
@@ -679,7 +702,9 @@ function ReadingDocument({
|
||||
configuration: computations[referenceOf(feature).object],
|
||||
revision: revisions[feature.data.processor],
|
||||
aliases: revisionAliases[feature.data.processor],
|
||||
styles: (renders[feature.data.processor] ?? [{ style: feature.data.style }]).map((render) => render.style),
|
||||
styles: resolveRenders(renders[feature.data.processor], configValues(feature.options)).map(
|
||||
(render) => render.style,
|
||||
),
|
||||
})),
|
||||
doc.data.sourceRevision,
|
||||
window.visible,
|
||||
@@ -902,7 +927,7 @@ function ReadingDocument({
|
||||
return {
|
||||
...item,
|
||||
label: feature.data.name,
|
||||
trigger: (item.reveal ?? feature.data.reveal) as "hover" | "click",
|
||||
trigger: item.reveal as "hover" | "click",
|
||||
};
|
||||
}),
|
||||
...pendingTooltips,
|
||||
|
||||
+54
-1
@@ -149,7 +149,7 @@ assert.deepEqual(
|
||||
assert.equal(new Set(outputs.map((output) => output.id)).size, 3);
|
||||
assert(outputs.every((output) => output.feature === semantic.feature && output.start === 6 && output.end === 9));
|
||||
assert.equal(semantic.text, "word", "Rendering never mutates cached semantic data");
|
||||
assert.deepEqual(renderAnnotations(semantic, source, undefined), [semantic]);
|
||||
assert.deepEqual(renderAnnotations(semantic, source, undefined), [], "Missing channels never invent an appearance");
|
||||
console.log("PASS one source rendered as replacement, color and original-text hover tooltip");
|
||||
|
||||
assert(
|
||||
@@ -420,3 +420,56 @@ assert.equal(retrying.size, 0);
|
||||
console.log(
|
||||
"PASS explicit nearby annotator retries, shared identities/aliases, sidebar/off-page exclusion and superseded attempts",
|
||||
);
|
||||
|
||||
// Two channels use independently declared structs, not a single feature type.
|
||||
import { configDefaults } from "../src/config-schema.js";
|
||||
const raw = { ...semantic, color: "" };
|
||||
const multi = renderAnnotations(
|
||||
raw,
|
||||
source,
|
||||
[
|
||||
{ style: "underline", reveal: "always", options: "primary" },
|
||||
{ style: "underline", reveal: "always", options: "secondary" },
|
||||
{ style: "replace", reveal: "click" },
|
||||
{ style: "tooltip", reveal: "hover", content: "source" },
|
||||
],
|
||||
{
|
||||
primary: { color: "#112233", underlinePattern: "squiggly" },
|
||||
secondary: { color: "#445566", underlinePattern: "dashed" },
|
||||
},
|
||||
);
|
||||
assert.deepEqual(
|
||||
multi.slice(0, 2).map((a) => [a.color, a.underlinePattern]),
|
||||
[
|
||||
["#112233", "squiggly"],
|
||||
["#445566", "dashed"],
|
||||
],
|
||||
);
|
||||
const changed = renderAnnotations(raw, source, [{ style: "underline", reveal: "always", options: "primary" }], {
|
||||
primary: { color: "#112233", underlinePattern: "solid" },
|
||||
});
|
||||
assert.equal(changed[0].underlinePattern, "solid");
|
||||
assert.equal(raw.text, "word");
|
||||
assert.throws(
|
||||
() =>
|
||||
renderAnnotations(raw, source, [{ style: "overhead", reveal: "always", options: "label" }], {
|
||||
label: { fontSize: 500 },
|
||||
}),
|
||||
/Invalid annotator render channel/,
|
||||
);
|
||||
assert.throws(
|
||||
() => renderAnnotations(raw, source, [{ style: "overhead", reveal: "hover" }]),
|
||||
/Invalid annotator render channel/,
|
||||
);
|
||||
assert.deepEqual(
|
||||
configDefaults([
|
||||
{
|
||||
kind: "group",
|
||||
key: "underlines",
|
||||
label: "Underlines",
|
||||
fields: [{ kind: "select", key: "pattern", label: "Pattern", default: "dashed" }],
|
||||
},
|
||||
]),
|
||||
{ underlines: { pattern: "dashed" } },
|
||||
);
|
||||
console.log("PASS code-owned settings bind independent render channels without replacing semantic data");
|
||||
|
||||
Reference in New Issue
Block a user