/** * `highlight` โ€” inline text background mark (9-token palette). * * Complements StarterKit's bold/italic/strikethrough/code. The color is * stored as a token name from the shared closed palette (PRODUCT-SPEC ยง7 * color menu: 9 text + 9 background tokens) โ€” never a raw hex โ€” so the * server can validate it with the same `@factory/shared` palette check. */ import { Mark, mergeAttributes } from "@tiptap/core"; export interface HighlightOptions { readonly HTMLAttributes: Record; } declare module "@tiptap/core" { interface Config { options: HighlightOptions; } } export const HighlightMark = Mark.create({ name: "factoryHighlight", group: "mark", addOptions() { return { HTMLAttributes: { class: "factory-highlight", }, }; }, addAttributes() { return { color: { default: null, parseHTML: (element) => element.getAttribute("data-highlight"), renderHTML: (attributes) => attributes.color === null ? {} : { "data-highlight": attributes.color }, }, }; }, parseHTML() { return [{ tag: "span.factory-highlight" }]; }, renderHTML({ HTMLAttributes }) { return [ "span", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0, ]; }, });