From 27cb57d35607aba76cc27c45f923c3f1321a50d0 Mon Sep 17 00:00:00 2001 From: Ricardo Amaral Date: Thu, 17 Aug 2023 10:56:58 +0100 Subject: [PATCH] Add `ListKeymap` extension for better list handling --- package-lock.json | 19 +++++++++++++++++++ package.json | 1 + src/extensions/rich-text/rich-text-kit.ts | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/package-lock.json b/package-lock.json index 58da2c5d..2cfdb66e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,6 +27,7 @@ "@tiptap/extension-italic": "2.1.1", "@tiptap/extension-link": "2.1.1", "@tiptap/extension-list-item": "2.1.1", + "@tiptap/extension-list-keymap": "2.1.1", "@tiptap/extension-ordered-list": "2.1.1", "@tiptap/extension-paragraph": "2.1.1", "@tiptap/extension-placeholder": "2.1.1", @@ -8245,6 +8246,18 @@ "@tiptap/core": "^2.0.0" } }, + "node_modules/@tiptap/extension-list-keymap": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-list-keymap/-/extension-list-keymap-2.1.1.tgz", + "integrity": "sha512-qO8oXPpF48ay1v5TPYhvkjjYIqJ1RwMjfzsiZoEPkHiG0wxhGSJaospt3/ESLXx77DCEGI2t/WJNcqQ2N8euag==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0" + } + }, "node_modules/@tiptap/extension-ordered-list": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/@tiptap/extension-ordered-list/-/extension-ordered-list-2.1.1.tgz", @@ -35580,6 +35593,12 @@ "integrity": "sha512-UikZsgcdgno5UWXn2TPGZeHi0mHxujw5gtaA6+x9j/oVjVPqevqg2uDilMkig+HrsTWwLVzntvnVsXdu2TneWw==", "requires": {} }, + "@tiptap/extension-list-keymap": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@tiptap/extension-list-keymap/-/extension-list-keymap-2.1.1.tgz", + "integrity": "sha512-qO8oXPpF48ay1v5TPYhvkjjYIqJ1RwMjfzsiZoEPkHiG0wxhGSJaospt3/ESLXx77DCEGI2t/WJNcqQ2N8euag==", + "requires": {} + }, "@tiptap/extension-ordered-list": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/@tiptap/extension-ordered-list/-/extension-ordered-list-2.1.1.tgz", diff --git a/package.json b/package.json index d0cbd470..f6aa38da 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "@tiptap/extension-italic": "2.1.1", "@tiptap/extension-link": "2.1.1", "@tiptap/extension-list-item": "2.1.1", + "@tiptap/extension-list-keymap": "2.1.1", "@tiptap/extension-ordered-list": "2.1.1", "@tiptap/extension-paragraph": "2.1.1", "@tiptap/extension-placeholder": "2.1.1", diff --git a/src/extensions/rich-text/rich-text-kit.ts b/src/extensions/rich-text/rich-text-kit.ts index 343a6f0c..3b17238e 100644 --- a/src/extensions/rich-text/rich-text-kit.ts +++ b/src/extensions/rich-text/rich-text-kit.ts @@ -10,6 +10,7 @@ import { Heading } from '@tiptap/extension-heading' import { History } from '@tiptap/extension-history' import { Italic } from '@tiptap/extension-italic' import { ListItem } from '@tiptap/extension-list-item' +import { ListKeymap } from '@tiptap/extension-list-keymap' import { OrderedList } from '@tiptap/extension-ordered-list' import { Paragraph } from '@tiptap/extension-paragraph' import { Strike } from '@tiptap/extension-strike' @@ -135,6 +136,11 @@ type RichTextKitOptions = { */ listItem: Partial | false + /** + * Set to `false` to disable the `ListKeymap` extension. + */ + listKeymap: false + /** * Set options for the `OrderedList` extension, or `false` to disable. */ @@ -299,6 +305,10 @@ const RichTextKit = Extension.create({ extensions.push(ListItem.configure(this.options?.listItem)) } + if (this.options.listKeymap !== false) { + extensions.push(ListKeymap) + } + if (this.options.orderedList !== false) { extensions.push(OrderedList.configure(this.options?.orderedList)) }