this.removeOldTool()}>
{OldTool &&
}
-
+ {SelectedTool == 'pos-html-tool' ? (
+
+ ) : (
+
+ )}
);
diff --git a/elements/src/components/pos-type-router/selectToolsForTypes.spec.ts b/elements/src/components/pos-type-router/selectToolsForTypes.spec.ts
index ed709f58..9b92f949 100644
--- a/elements/src/components/pos-type-router/selectToolsForTypes.spec.ts
+++ b/elements/src/components/pos-type-router/selectToolsForTypes.spec.ts
@@ -97,4 +97,23 @@ describe('select tools for types', () => {
AvailableTools.Generic,
]);
});
+
+ it('favours HTML tool over generic if one is available', () => {
+ const registeredTools = [
+ {
+ element: 'pos-html-tool',
+ label: 'Example tool',
+ icon: 'list-ul',
+ types: [
+ {
+ uri: 'https://schema.org/Recipe',
+ priority: 20,
+ },
+ ],
+ },
+ ];
+ const types = [{ uri: 'https://schema.org/Recipe', label: 'Recipe' }];
+ const tools = selectToolsForTypes(types, registeredTools);
+ expect(tools).toEqual([registeredTools[0], AvailableTools.Generic]);
+ });
});
diff --git a/elements/src/components/pos-type-router/selectToolsForTypes.ts b/elements/src/components/pos-type-router/selectToolsForTypes.ts
index 261e2968..ea5b8618 100644
--- a/elements/src/components/pos-type-router/selectToolsForTypes.ts
+++ b/elements/src/components/pos-type-router/selectToolsForTypes.ts
@@ -24,6 +24,13 @@ export interface ToolConfig {
types: TypePriority[];
}
+/**
+ * Describes a tool that can be used implemented as a HTML fragment
+ */
+export interface HTMLToolConfig extends ToolConfig {
+ fragment: string;
+}
+
/**
* Describes how well a given RDF type can be handled
*/
@@ -52,10 +59,10 @@ interface ToolPriority {
priority: number;
}
-export function selectToolsForTypes(types: RdfType[]) {
+export function selectToolsForTypes(types: RdfType[], registeredTools: ToolConfig[] = []) {
const typeUris = new Set(types.map(type => type.uri));
- return Object.values(AvailableTools)
+ return [...Object.values(AvailableTools), ...registeredTools]
.map(maxPriorityFor(typeUris))
.filter(onlyRelevant)
.toSorted(byPriority)
diff --git a/package-lock.json b/package-lock.json
index 529a135a..015e1f38 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -113,6 +113,9 @@
"typedoc-plugin-markdown": "^4.9.0",
"typescript": "5.9.3",
"typescript-eslint": "^8.46.3"
+ },
+ "engines": {
+ "node": ">=18.0.0"
}
},
"core/node_modules/@jest/console": {
@@ -1303,6 +1306,7 @@
"@tiptap/pm": "^3.10.1",
"@tiptap/starter-kit": "^3.10.1",
"@uvdsl/solid-oidc-client-browser": "^0.1.3",
+ "dompurify": "^3.3.0",
"idb": "^8.0.3",
"neverthrow": "^8.2.0",
"pollen-css": "^5.0.2",
@@ -10984,6 +10988,15 @@
"url": "https://github.com/fb55/domhandler?sponsor=1"
}
},
+ "node_modules/dompurify": {
+ "version": "3.3.0",
+ "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.3.0.tgz",
+ "integrity": "sha512-r+f6MYR1gGN1eJv0TVQbhA7if/U7P87cdPl3HN5rikqaBSBxLiCb/b9O+2eG0cxz0ghyU+mU1QkbsOwERMYlWQ==",
+ "license": "(MPL-2.0 OR Apache-2.0)",
+ "optionalDependencies": {
+ "@types/trusted-types": "^2.0.7"
+ }
+ },
"node_modules/domutils": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz",