Skip to content

Commit

Permalink
fix(lists): bullet-list and ordered-list no longer depend on list-ite…
Browse files Browse the repository at this point in the history
…m or text-style extensions #5707
  • Loading branch information
nperez0111 committed Oct 23, 2024
1 parent cbbb8a5 commit 12e177b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
6 changes: 6 additions & 0 deletions .changeset/light-pens-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@tiptap/extension-ordered-list": patch
"@tiptap/extension-bullet-list": patch
---

This resolves an issue where the bullet-list and ordered-list extensions were depending on the list-item and text-style extensions unneccesarily. They are no longer imported and constants are used instead.
8 changes: 2 additions & 6 deletions packages/extension-bullet-list/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@
"dist"
],
"devDependencies": {
"@tiptap/core": "^2.9.0",
"@tiptap/extension-list-item": "^2.9.0",
"@tiptap/extension-text-style": "^2.9.0"
"@tiptap/core": "^2.9.0"
},
"peerDependencies": {
"@tiptap/core": "^2.7.0",
"@tiptap/extension-list-item": "^2.7.0",
"@tiptap/extension-text-style": "^2.7.0"
"@tiptap/core": "^2.7.0"
},
"repository": {
"type": "git",
Expand Down
9 changes: 5 additions & 4 deletions packages/extension-bullet-list/src/bullet-list.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'
import { ListItem } from '@tiptap/extension-list-item'
import { TextStyle } from '@tiptap/extension-text-style'

const ListItemName = 'listItem'
const TextStyleName = 'textStyle'

export interface BulletListOptions {
/**
Expand Down Expand Up @@ -86,7 +87,7 @@ export const BulletList = Node.create<BulletListOptions>({
return {
toggleBulletList: () => ({ commands, chain }) => {
if (this.options.keepAttributes) {
return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run()
return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run()
}
return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
},
Expand All @@ -111,7 +112,7 @@ export const BulletList = Node.create<BulletListOptions>({
type: this.type,
keepMarks: this.options.keepMarks,
keepAttributes: this.options.keepAttributes,
getAttributes: () => { return this.editor.getAttributes(TextStyle.name) },
getAttributes: () => { return this.editor.getAttributes(TextStyleName) },
editor: this.editor,
})
}
Expand Down
8 changes: 2 additions & 6 deletions packages/extension-ordered-list/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@
"dist"
],
"devDependencies": {
"@tiptap/core": "^2.9.0",
"@tiptap/extension-list-item": "^2.9.0",
"@tiptap/extension-text-style": "^2.9.0"
"@tiptap/core": "^2.9.0"
},
"peerDependencies": {
"@tiptap/core": "^2.7.0",
"@tiptap/extension-list-item": "^2.7.0",
"@tiptap/extension-text-style": "^2.7.0"
"@tiptap/core": "^2.7.0"
},
"repository": {
"type": "git",
Expand Down
9 changes: 5 additions & 4 deletions packages/extension-ordered-list/src/ordered-list.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core'
import { ListItem } from '@tiptap/extension-list-item'
import { TextStyle } from '@tiptap/extension-text-style'

const ListItemName = 'listItem'
const TextStyleName = 'textStyle'

export interface OrderedListOptions {
/**
Expand Down Expand Up @@ -110,7 +111,7 @@ export const OrderedList = Node.create<OrderedListOptions>({
return {
toggleOrderedList: () => ({ commands, chain }) => {
if (this.options.keepAttributes) {
return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run()
return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run()
}
return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
},
Expand All @@ -137,7 +138,7 @@ export const OrderedList = Node.create<OrderedListOptions>({
type: this.type,
keepMarks: this.options.keepMarks,
keepAttributes: this.options.keepAttributes,
getAttributes: match => ({ start: +match[1], ...this.editor.getAttributes(TextStyle.name) }),
getAttributes: match => ({ start: +match[1], ...this.editor.getAttributes(TextStyleName) }),
joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
editor: this.editor,
})
Expand Down

0 comments on commit 12e177b

Please sign in to comment.