diff --git a/COMPONENTS.md b/COMPONENTS.md index ecf1e1c..0794f58 100644 --- a/COMPONENTS.md +++ b/COMPONENTS.md @@ -134,7 +134,9 @@ Zone de texte multiligne avec compteur et redimensionnement. ## MalioInputRichText -Éditeur de texte riche basé sur **TipTap v3** + **StarterKit** + **tiptap-markdown**. Toolbar avec gras, italique, barré, titres H2/H3, listes, citation, code, code-block, lien, undo/redo. Sortie en markdown (par défaut) ou HTML. +Éditeur de texte riche basé sur **TipTap v3** + **StarterKit** + **tiptap-markdown** + **TextStyle/Color/Highlight**. Toolbar avec gras, italique, barré, titres H2/H3, listes, citation, code, code-block, lien, **couleur du texte**, **surlignage**, undo/redo. Sortie en HTML (par défaut) ou markdown. + +> Couleurs et surlignages ne sont **pas persistés en markdown**. Pour les conserver au save/reload, utiliser `output-format="html"`. | Prop | Type | Défaut | Description | |------|------|--------|-------------| @@ -149,7 +151,7 @@ Zone de texte multiligne avec compteur et redimensionnement. | `hint` | `string` | `''` | Message d'aide | | `error` | `string` | `''` | Message d'erreur | | `success` | `string` | `''` | Message de succès | -| `outputFormat` | `'markdown' \| 'html'` | `'markdown'` | Format émis dans `update:modelValue` | +| `outputFormat` | `'markdown' \| 'html'` | `'html'` | Format émis dans `update:modelValue` | | `groupClass` | `string` | `''` | Classes CSS conteneur (twMerge) | | `labelClass` | `string` | `''` | Classes CSS label (twMerge) | | `editorClass` | `string` | `''` | Classes CSS wrapper éditeur (twMerge) | @@ -159,7 +161,7 @@ Zone de texte multiligne avec compteur et redimensionnement. ```vue - + ``` diff --git a/app/components/malio/input/InputRichText.test.ts b/app/components/malio/input/InputRichText.test.ts index f193f20..15ee4ca 100644 --- a/app/components/malio/input/InputRichText.test.ts +++ b/app/components/malio/input/InputRichText.test.ts @@ -61,10 +61,42 @@ describe('MalioInputRichText', () => { expect(wrapper.find('button[title="Gras"]').exists()).toBe(true) expect(wrapper.find('button[title="Italique"]').exists()).toBe(true) expect(wrapper.find('button[title="Lien"]').exists()).toBe(true) + expect(wrapper.find('button[title="Couleur du texte"]').exists()).toBe(true) + expect(wrapper.find('button[title="Surlignage"]').exists()).toBe(true) expect(wrapper.find('button[title="Annuler"]').exists()).toBe(true) expect(wrapper.find('button[title="Rétablir"]').exists()).toBe(true) }) + it('opens and closes the text color palette', async () => { + const wrapper = await mountComponent({modelValue: ''}) + + expect(wrapper.find('[aria-label="Palette couleur du texte"]').exists()).toBe(false) + + await wrapper.get('button[title="Couleur du texte"]').trigger('click') + expect(wrapper.find('[aria-label="Palette couleur du texte"]').exists()).toBe(true) + + await wrapper.get('button[title="Couleur du texte"]').trigger('click') + expect(wrapper.find('[aria-label="Palette couleur du texte"]').exists()).toBe(false) + }) + + it('opens the highlight palette and closes the color palette', async () => { + const wrapper = await mountComponent({modelValue: ''}) + + await wrapper.get('button[title="Couleur du texte"]').trigger('click') + expect(wrapper.find('[aria-label="Palette couleur du texte"]').exists()).toBe(true) + + await wrapper.get('button[title="Surlignage"]').trigger('click') + expect(wrapper.find('[aria-label="Palette de surlignage"]').exists()).toBe(true) + expect(wrapper.find('[aria-label="Palette couleur du texte"]').exists()).toBe(false) + }) + + it('disables color and highlight buttons when readonly', async () => { + const wrapper = await mountComponent({readonly: true, modelValue: ''}) + + expect(wrapper.get('button[title="Couleur du texte"]').attributes('disabled')).toBeDefined() + expect(wrapper.get('button[title="Surlignage"]').attributes('disabled')).toBeDefined() + }) + it('does not render the toolbar in readonly display mode (editable=false)', async () => { const wrapper = await mountComponent({editable: false, modelValue: '**hi**'}) diff --git a/app/components/malio/input/InputRichText.vue b/app/components/malio/input/InputRichText.vue index 7f1a402..e07ae1b 100644 --- a/app/components/malio/input/InputRichText.vue +++ b/app/components/malio/input/InputRichText.vue @@ -46,6 +46,110 @@