mirror of
https://github.com/docmost/docmost.git
synced 2026-05-19 07:54:05 +08:00
selective placeholder
This commit is contained in:
@@ -16,7 +16,7 @@ import {
|
|||||||
IconMoodSmile,
|
IconMoodSmile,
|
||||||
IconNotes,
|
IconNotes,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { CalloutType } from "@docmost/editor-ext";
|
import { CalloutType, isTextSelected } from "@docmost/editor-ext";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import EmojiPicker from "@/components/ui/emoji-picker.tsx";
|
import EmojiPicker from "@/components/ui/emoji-picker.tsx";
|
||||||
import classes from "../common/toolbar-menu.module.css";
|
import classes from "../common/toolbar-menu.module.css";
|
||||||
@@ -29,6 +29,7 @@ export function CalloutMenu({ editor }: EditorMenuProps) {
|
|||||||
if (!state) {
|
if (!state) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (isTextSelected(editor)) return false;
|
||||||
|
|
||||||
return editor.isActive("callout");
|
return editor.isActive("callout");
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
IconLayoutSidebarRight,
|
IconLayoutSidebarRight,
|
||||||
IconLayoutAlignCenter,
|
IconLayoutAlignCenter,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
|
import { isTextSelected } from "@docmost/editor-ext";
|
||||||
import type { WidthMode, ColumnsLayout } from "@docmost/editor-ext";
|
import type { WidthMode, ColumnsLayout } from "@docmost/editor-ext";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import classes from "../common/toolbar-menu.module.css";
|
import classes from "../common/toolbar-menu.module.css";
|
||||||
@@ -80,6 +81,7 @@ export function ColumnsMenu({ editor }: EditorMenuProps) {
|
|||||||
({ state }: ShouldShowProps) => {
|
({ state }: ShouldShowProps) => {
|
||||||
if (!state) return false;
|
if (!state) return false;
|
||||||
if (!editor.isActive("columns")) return false;
|
if (!editor.isActive("columns")) return false;
|
||||||
|
if (isTextSelected(editor)) return false;
|
||||||
if (nodesWithMenus.some((name) => editor.isActive(name))) return false;
|
if (nodesWithMenus.some((name) => editor.isActive(name))) return false;
|
||||||
|
|
||||||
const parent = findParentNode(
|
const parent = findParentNode(
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
IconTrashX,
|
IconTrashX,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { BubbleMenu } from "@tiptap/react/menus";
|
import { BubbleMenu } from "@tiptap/react/menus";
|
||||||
import { isCellSelection } from "@docmost/editor-ext";
|
import { isCellSelection, isTextSelected } from "@docmost/editor-ext";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import classes from "../common/toolbar-menu.module.css";
|
import classes from "../common/toolbar-menu.module.css";
|
||||||
|
|
||||||
@@ -31,6 +31,7 @@ export const TableMenu = React.memo(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isTextSelected(editor)) return false;
|
||||||
return editor.isActive("table") && !isCellSelection(state.selection);
|
return editor.isActive("table") && !isCellSelection(state.selection);
|
||||||
},
|
},
|
||||||
[editor]
|
[editor]
|
||||||
|
|||||||
@@ -135,7 +135,13 @@ export const mainExtensions = [
|
|||||||
}
|
}
|
||||||
if (node.type.name === "paragraph") {
|
if (node.type.name === "paragraph") {
|
||||||
const $pos = editor.state.doc.resolve(pos);
|
const $pos = editor.state.doc.resolve(pos);
|
||||||
if ($pos.parent.type.name === "column") {
|
const parentName = $pos.parent.type.name;
|
||||||
|
if (
|
||||||
|
parentName === "column" ||
|
||||||
|
parentName === "tableCell" ||
|
||||||
|
parentName === "tableHeader" ||
|
||||||
|
parentName === "callout"
|
||||||
|
) {
|
||||||
return i18n.t("Write...");
|
return i18n.t("Write...");
|
||||||
}
|
}
|
||||||
return i18n.t('Write anything. Enter "/" for commands');
|
return i18n.t('Write anything. Enter "/" for commands');
|
||||||
|
|||||||
Reference in New Issue
Block a user