feat(starter-kit): enable more extensions in the starter-kit for easier onboarding (#5466)

This commit is contained in:
Nick Perez 2024-08-10 18:15:43 +02:00 committed by GitHub
parent d086c4e423
commit 64a74f62be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 49 additions and 6 deletions

View File

@ -0,0 +1,7 @@
---
"@tiptap/starter-kit": major
---
We have now added the Link, ListKeymap, and Underline extensions to the starter kit for a smoother onboarding experience
If you have theses extensions in your project, you can remove them from your project and use the ones from the starter kit instead.

12
package-lock.json generated
View File

@ -4730,10 +4730,6 @@
"vite": "^4.0.0"
}
},
"node_modules/@tiptap-shared/rollup-config": {
"resolved": "shared/rollup-config",
"link": true
},
"node_modules/@tiptap/core": {
"resolved": "packages/core",
"link": true
@ -17411,11 +17407,14 @@
"@tiptap/extension-history": "^3.0.0-next.0",
"@tiptap/extension-horizontal-rule": "^3.0.0-next.0",
"@tiptap/extension-italic": "^3.0.0-next.0",
"@tiptap/extension-link": "^3.0.0-next.0",
"@tiptap/extension-list-item": "^3.0.0-next.0",
"@tiptap/extension-list-keymap": "^3.0.0-next.0",
"@tiptap/extension-ordered-list": "^3.0.0-next.0",
"@tiptap/extension-paragraph": "^3.0.0-next.0",
"@tiptap/extension-strike": "^3.0.0-next.0",
"@tiptap/extension-text": "^3.0.0-next.0"
"@tiptap/extension-text": "^3.0.0-next.0",
"@tiptap/extension-underline": "^3.0.0-next.0"
},
"funding": {
"type": "github",
@ -17508,7 +17507,8 @@
}
},
"shared/rollup-config": {
"name": "@tiptap-shared/rollup-config"
"name": "@tiptap-shared/rollup-config",
"extraneous": true
}
}
}

View File

@ -43,9 +43,12 @@
"@tiptap/extension-horizontal-rule": "^3.0.0-next.0",
"@tiptap/extension-italic": "^3.0.0-next.0",
"@tiptap/extension-list-item": "^3.0.0-next.0",
"@tiptap/extension-list-keymap": "^3.0.0-next.0",
"@tiptap/extension-link": "^3.0.0-next.0",
"@tiptap/extension-ordered-list": "^3.0.0-next.0",
"@tiptap/extension-paragraph": "^3.0.0-next.0",
"@tiptap/extension-strike": "^3.0.0-next.0",
"@tiptap/extension-underline": "^3.0.0-next.0",
"@tiptap/extension-text": "^3.0.0-next.0"
},
"repository": {

View File

@ -12,11 +12,14 @@ import { Heading, HeadingOptions } from '@tiptap/extension-heading'
import { History, HistoryOptions } from '@tiptap/extension-history'
import { HorizontalRule, HorizontalRuleOptions } from '@tiptap/extension-horizontal-rule'
import { Italic, ItalicOptions } from '@tiptap/extension-italic'
import { Link, LinkOptions } from '@tiptap/extension-link'
import { ListItem, ListItemOptions } from '@tiptap/extension-list-item'
import { ListKeymap, ListKeymapOptions } from '@tiptap/extension-list-keymap'
import { OrderedList, OrderedListOptions } from '@tiptap/extension-ordered-list'
import { Paragraph, ParagraphOptions } from '@tiptap/extension-paragraph'
import { Strike, StrikeOptions } from '@tiptap/extension-strike'
import { Text } from '@tiptap/extension-text'
import { Underline, UnderlineOptions } from '@tiptap/extension-underline'
export interface StarterKitOptions {
/**
@ -103,6 +106,18 @@ export interface StarterKitOptions {
*/
listItem: Partial<ListItemOptions> | false,
/**
* If set to false, the listItemKeymap extension will not be registered
* @example listKeymap: false
*/
listKeymap: Partial<ListKeymapOptions> | false,
/**
* If set to false, the link extension will not be registered
* @example link: false
*/
link: Partial<LinkOptions> | false,
/**
* If set to false, the orderedList extension will not be registered
* @example orderedList: false
@ -126,6 +141,12 @@ export interface StarterKitOptions {
* @example text: false
*/
text: false,
/**
* If set to false, the underline extension will not be registered
* @example underline: false
*/
underline: Partial<UnderlineOptions> | false,
}
/**
@ -195,6 +216,14 @@ export const StarterKit = Extension.create<StarterKitOptions>({
extensions.push(ListItem.configure(this.options?.listItem))
}
if (this.options.listKeymap !== false) {
extensions.push(ListKeymap.configure(this.options?.listKeymap))
}
if (this.options.link !== false) {
extensions.push(Link.configure(this.options?.link))
}
if (this.options.orderedList !== false) {
extensions.push(OrderedList.configure(this.options?.orderedList))
}
@ -211,6 +240,10 @@ export const StarterKit = Extension.create<StarterKitOptions>({
extensions.push(Text.configure(this.options?.text))
}
if (this.options.underline !== false) {
extensions.push(Underline.configure(this.options?.underline))
}
return extensions
},
})