mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
notes callout
This commit is contained in:
@@ -274,6 +274,7 @@
|
|||||||
"Add row below": "Add row below",
|
"Add row below": "Add row below",
|
||||||
"Delete table": "Delete table",
|
"Delete table": "Delete table",
|
||||||
"Info": "Info",
|
"Info": "Info",
|
||||||
|
"Note": "Note",
|
||||||
"Success": "Success",
|
"Success": "Success",
|
||||||
"Warning": "Warning",
|
"Warning": "Warning",
|
||||||
"Danger": "Danger",
|
"Danger": "Danger",
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
IconCircleXFilled,
|
IconCircleXFilled,
|
||||||
IconInfoCircleFilled,
|
IconInfoCircleFilled,
|
||||||
IconMoodSmile,
|
IconMoodSmile,
|
||||||
|
IconNotes,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { CalloutType } from "@docmost/editor-ext";
|
import { CalloutType } from "@docmost/editor-ext";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@@ -44,6 +45,7 @@ export function CalloutMenu({ editor }: EditorMenuProps) {
|
|||||||
return {
|
return {
|
||||||
isCallout: ctx.editor.isActive("callout"),
|
isCallout: ctx.editor.isActive("callout"),
|
||||||
isInfo: ctx.editor.isActive("callout", { type: "info" }),
|
isInfo: ctx.editor.isActive("callout", { type: "info" }),
|
||||||
|
isNote: ctx.editor.isActive("callout", { type: "note" }),
|
||||||
isSuccess: ctx.editor.isActive("callout", { type: "success" }),
|
isSuccess: ctx.editor.isActive("callout", { type: "success" }),
|
||||||
isWarning: ctx.editor.isActive("callout", { type: "warning" }),
|
isWarning: ctx.editor.isActive("callout", { type: "warning" }),
|
||||||
isDanger: ctx.editor.isActive("callout", { type: "danger" }),
|
isDanger: ctx.editor.isActive("callout", { type: "danger" }),
|
||||||
@@ -137,7 +139,22 @@ export function CalloutMenu({ editor }: EditorMenuProps) {
|
|||||||
variant="subtle"
|
variant="subtle"
|
||||||
className={clsx({ [classes.active]: editorState?.isInfo })}
|
className={clsx({ [classes.active]: editorState?.isInfo })}
|
||||||
>
|
>
|
||||||
<IconInfoCircleFilled size={18} color="var(--mantine-color-blue-5)" />
|
<IconInfoCircleFilled
|
||||||
|
size={18}
|
||||||
|
color="var(--mantine-color-blue-5)"
|
||||||
|
/>
|
||||||
|
</ActionIcon>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
|
<Tooltip position="top" label={t("Note")}>
|
||||||
|
<ActionIcon
|
||||||
|
onClick={() => setCalloutType("note")}
|
||||||
|
size="lg"
|
||||||
|
aria-label={t("Note")}
|
||||||
|
variant="subtle"
|
||||||
|
className={clsx({ [classes.active]: editorState?.isNote })}
|
||||||
|
>
|
||||||
|
<IconNotes size={18} color="var(--mantine-color-grape-5)" />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
@@ -149,7 +166,10 @@ export function CalloutMenu({ editor }: EditorMenuProps) {
|
|||||||
variant="subtle"
|
variant="subtle"
|
||||||
className={clsx({ [classes.active]: editorState?.isSuccess })}
|
className={clsx({ [classes.active]: editorState?.isSuccess })}
|
||||||
>
|
>
|
||||||
<IconCircleCheckFilled size={18} color="var(--mantine-color-green-5)" />
|
<IconCircleCheckFilled
|
||||||
|
size={18}
|
||||||
|
color="var(--mantine-color-green-5)"
|
||||||
|
/>
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
@@ -161,7 +181,10 @@ export function CalloutMenu({ editor }: EditorMenuProps) {
|
|||||||
variant="subtle"
|
variant="subtle"
|
||||||
className={clsx({ [classes.active]: editorState?.isWarning })}
|
className={clsx({ [classes.active]: editorState?.isWarning })}
|
||||||
>
|
>
|
||||||
<IconAlertTriangleFilled size={18} color="var(--mantine-color-orange-5)" />
|
<IconAlertTriangleFilled
|
||||||
|
size={18}
|
||||||
|
color="var(--mantine-color-orange-5)"
|
||||||
|
/>
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
IconCircleCheckFilled,
|
IconCircleCheckFilled,
|
||||||
IconCircleXFilled,
|
IconCircleXFilled,
|
||||||
IconInfoCircleFilled,
|
IconInfoCircleFilled,
|
||||||
|
IconNotes,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { Alert } from "@mantine/core";
|
import { Alert } from "@mantine/core";
|
||||||
import classes from "./callout.module.css";
|
import classes from "./callout.module.css";
|
||||||
@@ -34,12 +35,14 @@ export default function CalloutView(props: NodeViewProps) {
|
|||||||
|
|
||||||
function getCalloutIcon(type: CalloutType, customIcon?: string) {
|
function getCalloutIcon(type: CalloutType, customIcon?: string) {
|
||||||
if (customIcon && customIcon.trim() !== "") {
|
if (customIcon && customIcon.trim() !== "") {
|
||||||
return <span style={{ fontSize: '18px' }}>{customIcon}</span>;
|
return <span style={{ fontSize: "18px" }}>{customIcon}</span>;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "info":
|
case "info":
|
||||||
return <IconInfoCircleFilled />;
|
return <IconInfoCircleFilled />;
|
||||||
|
case "note":
|
||||||
|
return <IconNotes />;
|
||||||
case "success":
|
case "success":
|
||||||
return <IconCircleCheckFilled />;
|
return <IconCircleCheckFilled />;
|
||||||
case "warning":
|
case "warning":
|
||||||
@@ -55,6 +58,8 @@ function getCalloutColor(type: CalloutType) {
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case "info":
|
case "info":
|
||||||
return "blue";
|
return "blue";
|
||||||
|
case "note":
|
||||||
|
return "grape";
|
||||||
case "success":
|
case "success":
|
||||||
return "green";
|
return "green";
|
||||||
case "warning":
|
case "warning":
|
||||||
|
|||||||
@@ -1,8 +1,21 @@
|
|||||||
export type CalloutType = "default" | "info" | "success" | "warning" | "danger";
|
export type CalloutType =
|
||||||
const validCalloutTypes = ["default", "info", "success", "warning", "danger"];
|
| 'default'
|
||||||
|
| 'info'
|
||||||
|
| 'note'
|
||||||
|
| 'success'
|
||||||
|
| 'warning'
|
||||||
|
| 'danger';
|
||||||
|
const validCalloutTypes = [
|
||||||
|
'default',
|
||||||
|
'info',
|
||||||
|
'note',
|
||||||
|
'success',
|
||||||
|
'warning',
|
||||||
|
'danger',
|
||||||
|
];
|
||||||
|
|
||||||
export function getValidCalloutType(value: string): string {
|
export function getValidCalloutType(value: string): string {
|
||||||
if (value) {
|
if (value) {
|
||||||
return validCalloutTypes.includes(value) ? value : "info";
|
return validCalloutTypes.includes(value) ? value : 'info';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user