diff --git a/package.json b/package.json index 3ab8ee6..f737c8d 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "@tiptap/extension-placeholder": "^2.0.2", "@tiptap/extension-subscript": "^2.0.2", "@tiptap/extension-superscript": "^2.0.2", + "@tiptap/extension-text-align": "^2.0.2", "@tiptap/extension-typography": "^2.0.2", "@tiptap/extension-underline": "^2.0.2", "@tiptap/pm": "^2.0.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dbd26c3..9d6e299 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -31,6 +31,9 @@ devDependencies: '@tiptap/extension-superscript': specifier: ^2.0.2 version: 2.0.2(@tiptap/core@2.0.2) + '@tiptap/extension-text-align': + specifier: ^2.0.2 + version: 2.0.2(@tiptap/core@2.0.2) '@tiptap/extension-typography': specifier: ^2.0.2 version: 2.0.2(@tiptap/core@2.0.2) @@ -1228,6 +1231,14 @@ packages: '@tiptap/core': 2.0.2(@tiptap/pm@2.0.2) dev: true + /@tiptap/extension-text-align@2.0.2(@tiptap/core@2.0.2): + resolution: {integrity: sha512-cNYOQPpqAOquTjSm2lSzP9J1d5T9FueWArq2A3FsYzOSZfVAJmqp9gn/bfCKveKgE5m7nLN3g3o+RNryIWTr2w==} + peerDependencies: + '@tiptap/core': ^2.0.0 + dependencies: + '@tiptap/core': 2.0.2(@tiptap/pm@2.0.2) + dev: true + /@tiptap/extension-text@2.0.2(@tiptap/core@2.0.2): resolution: {integrity: sha512-kAO+WurWOyHIV/x8qHMF3bSlWrdlPtjEYmf+w8wHKy3FzE55eF6SsGt4FymClNkJmyXdgflXBB3Wv/Z53myy8g==} peerDependencies: diff --git a/src/extensions.ts b/src/extensions.ts index 81c6e04..7341ca2 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -6,6 +6,7 @@ import { Subscript } from "@tiptap/extension-subscript"; import { Superscript } from "@tiptap/extension-superscript"; import { CharacterCount } from "@tiptap/extension-character-count"; import { Typography } from "@tiptap/extension-typography"; +import { TextAlign } from "@tiptap/extension-text-align"; export const extensions: Extensions = [ StarterKit, @@ -15,4 +16,7 @@ export const extensions: Extensions = [ Superscript, CharacterCount, Typography, + TextAlign.configure({ + types: ["heading", "paragraph"], + }), ]; diff --git a/src/icons/align-center.vue b/src/icons/align-center.vue new file mode 100644 index 0000000..641777b --- /dev/null +++ b/src/icons/align-center.vue @@ -0,0 +1,5 @@ + diff --git a/src/icons/align-justify.vue b/src/icons/align-justify.vue new file mode 100644 index 0000000..8f9f7a4 --- /dev/null +++ b/src/icons/align-justify.vue @@ -0,0 +1,5 @@ + diff --git a/src/icons/align-left.vue b/src/icons/align-left.vue new file mode 100644 index 0000000..8a70bde --- /dev/null +++ b/src/icons/align-left.vue @@ -0,0 +1,5 @@ + diff --git a/src/icons/align-right.vue b/src/icons/align-right.vue new file mode 100644 index 0000000..2a9d73e --- /dev/null +++ b/src/icons/align-right.vue @@ -0,0 +1,5 @@ + diff --git a/src/messages.json b/src/messages.json index b6e0469..1034ce5 100644 --- a/src/messages.json +++ b/src/messages.json @@ -6,7 +6,8 @@ "clear_format": "Clear text formatting", "highlight": "Highlight", "count_chars": "no characters | 1 character | {count} characters", - "count_words": "no words | 1 word | {count} words" + "count_words": "no words | 1 word | {count} words", + "text_align": "Text align" } }, "fr": { @@ -16,7 +17,8 @@ "clear_format": "Effacer la mise en forme", "highlight": "Surligner", "count_chars": "aucun caractère | 1 caractère | {count} caractères", - "count_words": "aucun mot | 1 mot | {count} mots" + "count_words": "aucun mot | 1 mot | {count} mots", + "text_align": "Alignement du texte" } } } diff --git a/src/tiptap-editor.vue b/src/tiptap-editor.vue index b5c5b84..091fd5b 100644 --- a/src/tiptap-editor.vue +++ b/src/tiptap-editor.vue @@ -225,6 +225,42 @@
+ + + + + + + + + + + {{ opt.shortcut }} + + + + + + + + + (); +const alignOptions = [ + { + align: "left", + icon: IconAlignLeft, + text: t("wysiwyg_options.alignleft"), + shortcut: translateShortcut(["meta", "shift", "l"]), + }, + { + align: "center", + icon: IconAlignCenter, + text: t("wysiwyg_options.aligncenter"), + shortcut: translateShortcut(["meta", "shift", "e"]), + }, + { + align: "right", + icon: IconAlignRight, + text: t("wysiwyg_options.alignright"), + shortcut: translateShortcut(["meta", "shift", "r"]), + }, + { + align: "justify", + icon: IconAlignJustify, + text: t("wysiwyg_options.alignjustify"), + shortcut: translateShortcut(["meta", "shift", "j"]), + }, +]; + const placeholder = Placeholder.configure({ placeholder: props.placeholder, });