From 1ce99e2bb60cbce6c78b874eb0756499c85faad8 Mon Sep 17 00:00:00 2001 From: Dwindi Ramadhana Date: Thu, 1 Jan 2026 23:48:06 +0700 Subject: [PATCH] fix: TipTap button style extraction when parsing HTML Added getAttrs functions to parseHTML in tiptap-button-extension.ts. Now properly extracts text/href/style from DOM elements: - data-button: extracts from data-text, data-href, data-style - a.button: extracts text/href, defaults to solid style - a.button-outline: extracts text/href, defaults to outline style This fixes the issue where buttons appeared unstyled (outline instead of solid) when editing a card that contained buttons. --- .../src/components/ui/tiptap-button-extension.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/admin-spa/src/components/ui/tiptap-button-extension.ts b/admin-spa/src/components/ui/tiptap-button-extension.ts index a5e1666..fd44e1f 100644 --- a/admin-spa/src/components/ui/tiptap-button-extension.ts +++ b/admin-spa/src/components/ui/tiptap-button-extension.ts @@ -39,12 +39,27 @@ export const ButtonExtension = Node.create({ return [ { tag: 'a[data-button]', + getAttrs: (node: HTMLElement) => ({ + text: node.getAttribute('data-text') || node.textContent || 'Click Here', + href: node.getAttribute('data-href') || node.getAttribute('href') || '#', + style: node.getAttribute('data-style') || 'solid', + }), }, { tag: 'a.button', + getAttrs: (node: HTMLElement) => ({ + text: node.textContent || 'Click Here', + href: node.getAttribute('href') || '#', + style: 'solid', + }), }, { tag: 'a.button-outline', + getAttrs: (node: HTMLElement) => ({ + text: node.textContent || 'Click Here', + href: node.getAttribute('href') || '#', + style: 'outline', + }), }, ]; },