task list item fixed

This commit is contained in:
Palanikannan1437 2024-03-28 16:25:49 +05:30
parent 8e6429f697
commit 60e38ebce9
5 changed files with 15 additions and 18 deletions

View File

@ -8,18 +8,15 @@ export const getPrevListDepth = (typeOrName: string, state: EditorState) => {
return false; return false;
} }
let depth = -2; let depth = 0;
let pos = listItemPos.$pos; const pos = listItemPos.$pos;
// Adjust the position to ensure we're within the list item, especially for edge cases // Adjust the position to ensure we're within the list item, especially for edge cases
// This adjustment aims to more accurately reflect the document structure const resolvedPos = state.doc.resolve(Math.max(pos.pos - 1, 0));
let adjustedPos = pos;
// Adjusting the position by -3 to account for the off-by-three error
adjustedPos = state.doc.resolve(Math.max(adjustedPos.pos - 3, 0));
// Traverse up the document structure from the adjusted position // Traverse up the document structure from the adjusted position
for (let d = adjustedPos.depth; d > 0; d--) { for (let d = resolvedPos.depth; d > 0; d--) {
const node = adjustedPos.node(d); const node = resolvedPos.node(d);
if (node.type.name === "bulletList" || node.type.name === "orderedList") { if (node.type.name === "bulletList" || node.type.name === "orderedList") {
depth++; depth++;
} }

View File

@ -6,9 +6,7 @@ import { hasListBefore } from "src/ui/extensions/custom-list-keymap/list-helpers
import { hasListItemBefore } from "src/ui/extensions/custom-list-keymap/list-helpers/has-list-item-before"; import { hasListItemBefore } from "src/ui/extensions/custom-list-keymap/list-helpers/has-list-item-before";
import { listItemHasSubList } from "src/ui/extensions/custom-list-keymap/list-helpers/list-item-has-sub-list"; import { listItemHasSubList } from "src/ui/extensions/custom-list-keymap/list-helpers/list-item-has-sub-list";
import { isCursorInSubList } from "./is-sublist"; import { prevListIsHigher } from "src/ui/extensions/custom-list-keymap/list-helpers/prev-list-is-higher";
import { nextListIsDeeper } from "./next-list-is-deeper";
import { prevListIsHigher } from "./prev-list-is-deeper";
export const handleBackspace = (editor: Editor, name: string, parentListTypes: string[]) => { export const handleBackspace = (editor: Editor, name: string, parentListTypes: string[]) => {
// this is required to still handle the undo handling // this is required to still handle the undo handling
@ -89,12 +87,13 @@ export const handleBackspace = (editor: Editor, name: string, parentListTypes: s
// hasListItemBefore(name, editor.state) && // hasListItemBefore(name, editor.state) &&
// currentListItemHasSubList && // currentListItemHasSubList &&
// currentNodeSize > 4 && // currentNodeSize > 4 &&
// !previousListItemHasSubList && // !previousListItemHasSubList
isCurrentListItemSublist isCurrentListItemSublist
) { ) {
console.log("ran 0"); console.log("ran 0");
editor.chain().liftListItem(name).run(); // editor.chain().liftListItem(name).run();
return editor.commands.joinItemBackward(); return false;
// return editor.commands.joinItemBackward();
// return editor.chain().liftListItem(name).run(); // return editor.chain().liftListItem(name).run();
} }

View File

@ -46,17 +46,17 @@ export const CoreEditorExtensions = (
StarterKit.configure({ StarterKit.configure({
bulletList: { bulletList: {
HTMLAttributes: { HTMLAttributes: {
class: "not-prose", class: "",
}, },
}, },
orderedList: { orderedList: {
HTMLAttributes: { HTMLAttributes: {
class: "not-prose", class: "",
}, },
}, },
listItem: { listItem: {
HTMLAttributes: { HTMLAttributes: {
class: "not-prose", class: "",
}, },
}, },
code: false, code: false,

View File

@ -18,6 +18,7 @@ import {
findTableAncestor, findTableAncestor,
EditorMenuItem, EditorMenuItem,
UploadImage, UploadImage,
TodoListItem,
} from "@plane/editor-core"; } from "@plane/editor-core";
import { Selection } from "@tiptap/pm/state"; import { Selection } from "@tiptap/pm/state";
@ -43,7 +44,7 @@ export const FixedMenu = (props: EditorBubbleMenuProps) => {
StrikeThroughItem(editor), StrikeThroughItem(editor),
]; ];
const listItems: BubbleMenuItem[] = [BulletListItem(editor), NumberedListItem(editor)]; const listItems: BubbleMenuItem[] = [BulletListItem(editor), NumberedListItem(editor), TodoListItem(editor)];
const userActionItems: BubbleMenuItem[] = [QuoteItem(editor), CodeItem(editor)]; const userActionItems: BubbleMenuItem[] = [QuoteItem(editor), CodeItem(editor)];