Files
laraundfelix/public/js/rich-text-marks.js
T
LarsandClaude Sonnet 5.5 e904b500fb
CI Feature / test (push) Successful in 7m17s
Deploy Test / test (push) Successful in 6m48s
Deploy Test / deploy (push) Successful in 41s
Setze Symbole vor Absätze, Nummern in Kreise und Symbole statt Aufzählungspunkte im Text (ADR-69)
Zwei Werkzeuge im Texteditor (Symbol vor dem Absatz, Listenstil); gespeichert
werden nur Schlüssel, Bild und Farbe setzt die Ausgabe ein. Kreisfarben aus
der Palette, Verwendung wird mitgezählt.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-30 18:58:10 +01:00

31 lines
1.3 KiB
JavaScript

// Zeichen im Text der Website (ADR-69): Symbol vor einem Absatz, Nummern im Kreis, Symbol statt Aufzählungspunkt.
// Der Editor führt nur Schlüssel als Attribute der Knoten: data-symbol am Absatz; data-marker, data-symbol und data-tone an
// Aufzählung und Nummerierung. Bilder und Farben setzt erst die Ausgabe der Website ein.
// Gegenstück: App\Filament\Support\TipTap\TextMarksExtension (PHP-Modell beim Speichern). Filament lädt diese Datei als
// Erweiterung (RichContentPlugin::getTipTapJsExtensions) und stellt TipTap über window.FilamentRichEditor bereit.
const { Extension } = window.FilamentRichEditor.tiptap.core
const attribute = (name) => ({
default: null,
parseHTML: (element) => element.getAttribute(name),
renderHTML: (attributes) => (attributes[name] ? { [name]: attributes[name] } : {}),
})
export default Extension.create({
name: 'textMarks',
addGlobalAttributes() {
return [
{ types: ['paragraph'], attributes: { 'data-symbol': attribute('data-symbol') } },
{
types: ['bulletList', 'orderedList'],
attributes: {
'data-marker': attribute('data-marker'),
'data-symbol': attribute('data-symbol'),
'data-tone': attribute('data-tone'),
},
},
]
},
})