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;
}
let depth = -2;
let pos = listItemPos.$pos;
let depth = 0;
const pos = listItemPos.$pos;
// 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
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));
const resolvedPos = state.doc.resolve(Math.max(pos.pos - 1, 0));
// Traverse up the document structure from the adjusted position
for (let d = adjustedPos.depth; d > 0; d--) {
const node = adjustedPos.node(d);
for (let d = resolvedPos.depth; d > 0; d--) {
const node = resolvedPos.node(d);
if (node.type.name === "bulletList" || node.type.name === "orderedList") {
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 { listItemHasSubList } from "src/ui/extensions/custom-list-keymap/list-helpers/list-item-has-sub-list";
import { isCursorInSubList } from "./is-sublist";
import { nextListIsDeeper } from "./next-list-is-deeper";
import { prevListIsHigher } from "./prev-list-is-deeper";
import { prevListIsHigher } from "src/ui/extensions/custom-list-keymap/list-helpers/prev-list-is-higher";
export const handleBackspace = (editor: Editor, name: string, parentListTypes: string[]) => {
// 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) &&
// currentListItemHasSubList &&
// currentNodeSize > 4 &&
// !previousListItemHasSubList &&
// !previousListItemHasSubList
isCurrentListItemSublist
) {
console.log("ran 0");
editor.chain().liftListItem(name).run();
return editor.commands.joinItemBackward();
// editor.chain().liftListItem(name).run();
return false;
// return editor.commands.joinItemBackward();
// return editor.chain().liftListItem(name).run();
}

View File

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

View File

@ -18,6 +18,7 @@ import {
findTableAncestor,
EditorMenuItem,
UploadImage,
TodoListItem,
} from "@plane/editor-core";
import { Selection } from "@tiptap/pm/state";
@ -43,7 +44,7 @@ export const FixedMenu = (props: EditorBubbleMenuProps) => {
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)];