-
-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Numeric List Continuation Issue #431
Comments
When pressing Enter on an empty list block that is not at the first depth, the current implementation decreases the block depth without checking the context of the outer depth. This can cause unexpected behavior, especially in numbered lists, where the numbering should ideally continue from the previous depth. Code Context:
if (!hasText) {
if (isBlockIsInFirstDepth) {
const currentOrder = block.meta.order;
editor.batchOperations(() => {
editor.deleteBlock({ blockId: block.id });
editor.insertBlock(defaultBlock.type, { at: currentOrder, focus: true, blockData: defaultBlock });
});
return;
}
// Before decreasing the depth, check the previous depth for a numbered list.
// If the previous depth contains a numbered-list, continue numbering from there.
// This will ensure that numbered lists remain consistent across depths.
editor.decreaseBlockDepth({ blockId: block.id });
return;
}
export function decreaseBlockDepth(editor: YooEditor, options: BlockDepthOptions = {}) {
const { at = editor.path.current, blockId } = options;
const block = blockId ? editor.children[blockId] : findPluginBlockByPath(editor, { at });
if (!block) return;
const isBulletedList =block.type === 'bulleted-list';
const parentBlock= // HOW TO GET PARENT BLOCK??
if(isBulletedList && parentBlock.type === 'numbered-list'){
// Then do some other type of transformation, that is we need to inserting block to numbered one continuing from parent block
}
else{
const newDepth = Math.max(0, block.meta.depth - 1);
const operation: YooptaOperation = {
type: 'set_block_meta',
id: block.id,
properties: { depth: newDepth },
prevProperties: { depth: block.meta.depth },
};
editor.applyTransforms([operation]);
}
|
Has this bug been raised before?
Description
Bug : Numeric List Continuation Issue with Nested Lists
Description:
When using the numeric list feature in the editor, pressing "Enter" twice to create a new list item does not properly continue the numeric sequence from the previous list. Instead, it breaks the numeric sequence and incorrectly switches to a bullet list before exiting on the third "Enter" key press.
Steps to Reproduce:
Observed Behavior with Screenshots:
Nested List Creation (Working as Expected):
Pressing "Enter" inside the nested list creates a new nested item, which works as expected.
Breaking Numeric Sequence:
On the third "Enter" press, the editor incorrectly switches to a bullet list instead of continuing the numeric sequence.
Exiting the List (Working as Expected):
Pressing "Enter" again exits the list properly, which works as expected.
Expected Behavior:
For example:
Actual Behavior:
Environment:
Additional Notes:
This issue disrupts the flow of numeric lists, especially when working with nested structures, and requires manual intervention to fix the list sequence.
Screenshots
No response
Do you want to work on this issue?
No
The text was updated successfully, but these errors were encountered: