|
1 | | -import { updateBlockTr } from "../../../api/blockManipulation/commands/updateBlock/updateBlock.js"; |
2 | | -import { getBlockInfoFromTransaction } from "../../../api/getBlockInfoFromPos.js"; |
3 | | -import { createBlockConfig, createBlockSpec } from "../../../schema/index.js"; |
4 | 1 | import { createBlockNoteExtension } from "../../../editor/BlockNoteExtension.js"; |
| 2 | +import { createBlockConfig, createBlockSpec } from "../../../schema/index.js"; |
5 | 3 | import { defaultProps } from "../../defaultProps.js"; |
6 | 4 | import { handleEnter } from "../../utils/listItemEnterHandler.js"; |
7 | 5 | import { getListItemContent } from "../getListItemContent.js"; |
@@ -81,23 +79,22 @@ export const createNumberedListItemBlockSpec = createBlockSpec( |
81 | 79 | Enter: ({ editor }) => { |
82 | 80 | return handleEnter(editor, "numberedListItem"); |
83 | 81 | }, |
84 | | - "Mod-Shift-7": ({ editor }) => |
85 | | - editor.transact((tr) => { |
86 | | - const blockInfo = getBlockInfoFromTransaction(tr); |
| 82 | + "Mod-Shift-7": ({ editor }) => { |
| 83 | + const cursorPosition = editor.getTextCursorPosition(); |
87 | 84 |
|
88 | | - if ( |
89 | | - !blockInfo.isBlockContainer || |
90 | | - blockInfo.blockContent.node.type.spec.content !== "inline*" |
91 | | - ) { |
92 | | - return true; |
93 | | - } |
| 85 | + if ( |
| 86 | + editor.schema.blockSchema[cursorPosition.block.type].content !== |
| 87 | + "inline" |
| 88 | + ) { |
| 89 | + return false; |
| 90 | + } |
94 | 91 |
|
95 | | - updateBlockTr(tr, blockInfo.bnBlock.beforePos, { |
96 | | - type: "numberedListItem", |
97 | | - props: {}, |
98 | | - }); |
99 | | - return true; |
100 | | - }), |
| 92 | + editor.updateBlock(cursorPosition.block, { |
| 93 | + type: "numberedListItem", |
| 94 | + props: {}, |
| 95 | + }); |
| 96 | + return true; |
| 97 | + }, |
101 | 98 | }, |
102 | 99 | plugins: [NumberedListIndexingDecorationPlugin()], |
103 | 100 | }), |
|
0 commit comments