mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
editor: fix callout collapse/expand on clicking right after its heading
Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
This commit is contained in:
@@ -23,11 +23,9 @@ import {
|
|||||||
textblockTypeInputRule
|
textblockTypeInputRule
|
||||||
} from "@tiptap/core";
|
} from "@tiptap/core";
|
||||||
import { Heading as TiptapHeading } from "@tiptap/extension-heading";
|
import { Heading as TiptapHeading } from "@tiptap/extension-heading";
|
||||||
import { isClickWithinBounds } from "../../utils/prosemirror.js";
|
|
||||||
import { Plugin, PluginKey, Selection, Transaction } from "@tiptap/pm/state";
|
|
||||||
import { Node } from "@tiptap/pm/model";
|
import { Node } from "@tiptap/pm/model";
|
||||||
import { useToolbarStore } from "../../toolbar/stores/toolbar-store.js";
|
import { Plugin, PluginKey, Selection, Transaction } from "@tiptap/pm/state";
|
||||||
import { Decoration, DecorationSet } from "prosemirror-view";
|
import { Callout } from "../callout/callout.js";
|
||||||
|
|
||||||
const COLLAPSIBLE_BLOCK_TYPES = [
|
const COLLAPSIBLE_BLOCK_TYPES = [
|
||||||
"paragraph",
|
"paragraph",
|
||||||
@@ -188,6 +186,17 @@ export const Heading = TiptapHeading.extend({
|
|||||||
if (typeof getPos === "boolean") return;
|
if (typeof getPos === "boolean") return;
|
||||||
|
|
||||||
const pos = getPos();
|
const pos = getPos();
|
||||||
|
const resolvedPos = editor.state.doc.resolve(pos);
|
||||||
|
|
||||||
|
const callout = findParentNodeClosestToPos(
|
||||||
|
resolvedPos,
|
||||||
|
(node) => node.type.name === Callout.name
|
||||||
|
);
|
||||||
|
// the first callout heading's collapsibility is handled by callout itself
|
||||||
|
if (callout?.node.firstChild === node) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const clientX =
|
const clientX =
|
||||||
e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
|
e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
|
||||||
const clientY =
|
const clientY =
|
||||||
@@ -195,7 +204,7 @@ export const Heading = TiptapHeading.extend({
|
|||||||
const isRtl =
|
const isRtl =
|
||||||
e.target.dir === "rtl" ||
|
e.target.dir === "rtl" ||
|
||||||
findParentNodeClosestToPos(
|
findParentNodeClosestToPos(
|
||||||
editor.state.doc.resolve(pos),
|
resolvedPos,
|
||||||
(node) => !!node.attrs.textDirection
|
(node) => !!node.attrs.textDirection
|
||||||
)?.node.attrs.textDirection === "rtl";
|
)?.node.attrs.textDirection === "rtl";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user