Show version

* Add default mermaid content
This commit is contained in:
Philipinho
2024-09-01 17:30:34 +01:00
parent 11dbc079be
commit 1141796f24
5 changed files with 140 additions and 121 deletions

View File

@ -1,5 +1,5 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from 'react';
import { Group, Text, ScrollArea, ActionIcon, rem } from "@mantine/core"; import { Group, Text, ScrollArea, ActionIcon, rem } from '@mantine/core';
import { import {
IconUser, IconUser,
IconSettings, IconSettings,
@ -8,9 +8,9 @@ import {
IconUsersGroup, IconUsersGroup,
IconSpaces, IconSpaces,
IconBrush, IconBrush,
} from "@tabler/icons-react"; } from '@tabler/icons-react';
import { Link, useLocation, useNavigate } from "react-router-dom"; import { Link, useLocation, useNavigate } from 'react-router-dom';
import classes from "./settings.module.css"; import classes from './settings.module.css';
interface DataItem { interface DataItem {
label: string; label: string;
@ -25,27 +25,27 @@ interface DataGroup {
const groupedData: DataGroup[] = [ const groupedData: DataGroup[] = [
{ {
heading: "Account", heading: 'Account',
items: [ items: [
{ label: "Profile", icon: IconUser, path: "/settings/account/profile" }, { label: 'Profile', icon: IconUser, path: '/settings/account/profile' },
{ {
label: "Preferences", label: 'Preferences',
icon: IconBrush, icon: IconBrush,
path: "/settings/account/preferences", path: '/settings/account/preferences',
}, },
], ],
}, },
{ {
heading: "Workspace", heading: 'Workspace',
items: [ items: [
{ label: "General", icon: IconSettings, path: "/settings/workspace" }, { label: 'General', icon: IconSettings, path: '/settings/workspace' },
{ {
label: "Members", label: 'Members',
icon: IconUsers, icon: IconUsers,
path: "/settings/members", path: '/settings/members',
}, },
{ label: "Groups", icon: IconUsersGroup, path: "/settings/groups" }, { label: 'Groups', icon: IconUsersGroup, path: '/settings/groups' },
{ label: "Spaces", icon: IconSpaces, path: "/settings/spaces" }, { label: 'Spaces', icon: IconSpaces, path: '/settings/spaces' },
], ],
}, },
]; ];
@ -93,6 +93,17 @@ export default function SettingsSidebar() {
</Group> </Group>
<ScrollArea w="100%">{menuItems}</ScrollArea> <ScrollArea w="100%">{menuItems}</ScrollArea>
<div className={classes.version}>
<Text
className={classes.version}
c="dimmed"
component="a"
href="https://github.com/docmost/docmost/releases"
target="_blank"
>
v{APP_VERSION}
</Text>
</div>
</div> </div>
); );
} }

View File

@ -57,3 +57,8 @@
display: flex; display: flex;
align-items: center; align-items: center;
} }
.version {
padding-left: var(--mantine-spacing-xs) ;
padding-top: 10px;
}

View File

@ -17,123 +17,123 @@ import {
IconPhoto, IconPhoto,
IconTable, IconTable,
IconTypography, IconTypography,
} from '@tabler/icons-react'; } from "@tabler/icons-react";
import { import {
CommandProps, CommandProps,
SlashMenuGroupedItemsType, SlashMenuGroupedItemsType,
} from '@/features/editor/components/slash-menu/types'; } from "@/features/editor/components/slash-menu/types";
import { uploadImageAction } from '@/features/editor/components/image/upload-image-action.tsx'; import { uploadImageAction } from "@/features/editor/components/image/upload-image-action.tsx";
import { uploadVideoAction } from '@/features/editor/components/video/upload-video-action.tsx'; import { uploadVideoAction } from "@/features/editor/components/video/upload-video-action.tsx";
import { uploadAttachmentAction } from '@/features/editor/components/attachment/upload-attachment-action.tsx'; import { uploadAttachmentAction } from "@/features/editor/components/attachment/upload-attachment-action.tsx";
import IconExcalidraw from '@/components/icons/icon-excalidraw'; import IconExcalidraw from "@/components/icons/icon-excalidraw";
import IconMermaid from '@/components/icons/icon-mermaid'; import IconMermaid from "@/components/icons/icon-mermaid";
import IconDrawio from '@/components/icons/icon-drawio'; import IconDrawio from "@/components/icons/icon-drawio";
const CommandGroups: SlashMenuGroupedItemsType = { const CommandGroups: SlashMenuGroupedItemsType = {
basic: [ basic: [
{ {
title: 'Text', title: "Text",
description: 'Just start typing with plain text.', description: "Just start typing with plain text.",
searchTerms: ['p', 'paragraph'], searchTerms: ["p", "paragraph"],
icon: IconTypography, icon: IconTypography,
command: ({ editor, range }: CommandProps) => { command: ({ editor, range }: CommandProps) => {
editor editor
.chain() .chain()
.focus() .focus()
.deleteRange(range) .deleteRange(range)
.toggleNode('paragraph', 'paragraph') .toggleNode("paragraph", "paragraph")
.run(); .run();
}, },
}, },
{ {
title: 'To-do list', title: "To-do list",
description: 'Track tasks with a to-do list.', description: "Track tasks with a to-do list.",
searchTerms: ['todo', 'task', 'list', 'check', 'checkbox'], searchTerms: ["todo", "task", "list", "check", "checkbox"],
icon: IconCheckbox, icon: IconCheckbox,
command: ({ editor, range }: CommandProps) => { command: ({ editor, range }: CommandProps) => {
editor.chain().focus().deleteRange(range).toggleTaskList().run(); editor.chain().focus().deleteRange(range).toggleTaskList().run();
}, },
}, },
{ {
title: 'Heading 1', title: "Heading 1",
description: 'Big section heading.', description: "Big section heading.",
searchTerms: ['title', 'big', 'large'], searchTerms: ["title", "big", "large"],
icon: IconH1, icon: IconH1,
command: ({ editor, range }: CommandProps) => { command: ({ editor, range }: CommandProps) => {
editor editor
.chain() .chain()
.focus() .focus()
.deleteRange(range) .deleteRange(range)
.setNode('heading', { level: 1 }) .setNode("heading", { level: 1 })
.run(); .run();
}, },
}, },
{ {
title: 'Heading 2', title: "Heading 2",
description: 'Medium section heading.', description: "Medium section heading.",
searchTerms: ['subtitle', 'medium'], searchTerms: ["subtitle", "medium"],
icon: IconH2, icon: IconH2,
command: ({ editor, range }: CommandProps) => { command: ({ editor, range }: CommandProps) => {
editor editor
.chain() .chain()
.focus() .focus()
.deleteRange(range) .deleteRange(range)
.setNode('heading', { level: 2 }) .setNode("heading", { level: 2 })
.run(); .run();
}, },
}, },
{ {
title: 'Heading 3', title: "Heading 3",
description: 'Small section heading.', description: "Small section heading.",
searchTerms: ['subtitle', 'small'], searchTerms: ["subtitle", "small"],
icon: IconH3, icon: IconH3,
command: ({ editor, range }: CommandProps) => { command: ({ editor, range }: CommandProps) => {
editor editor
.chain() .chain()
.focus() .focus()
.deleteRange(range) .deleteRange(range)
.setNode('heading', { level: 3 }) .setNode("heading", { level: 3 })
.run(); .run();
}, },
}, },
{ {
title: 'Bullet list', title: "Bullet list",
description: 'Create a simple bullet list.', description: "Create a simple bullet list.",
searchTerms: ['unordered', 'point', 'list'], searchTerms: ["unordered", "point", "list"],
icon: IconList, icon: IconList,
command: ({ editor, range }: CommandProps) => { command: ({ editor, range }: CommandProps) => {
editor.chain().focus().deleteRange(range).toggleBulletList().run(); editor.chain().focus().deleteRange(range).toggleBulletList().run();
}, },
}, },
{ {
title: 'Numbered list', title: "Numbered list",
description: 'Create a list with numbering.', description: "Create a list with numbering.",
searchTerms: ['numbered', 'ordered', 'list'], searchTerms: ["numbered", "ordered", "list"],
icon: IconListNumbers, icon: IconListNumbers,
command: ({ editor, range }: CommandProps) => { command: ({ editor, range }: CommandProps) => {
editor.chain().focus().deleteRange(range).toggleOrderedList().run(); editor.chain().focus().deleteRange(range).toggleOrderedList().run();
}, },
}, },
{ {
title: 'Quote', title: "Quote",
description: 'Create block quote.', description: "Create block quote.",
searchTerms: ['blockquote', 'quotes'], searchTerms: ["blockquote", "quotes"],
icon: IconBlockquote, icon: IconBlockquote,
command: ({ editor, range }: CommandProps) => command: ({ editor, range }: CommandProps) =>
editor.chain().focus().deleteRange(range).toggleBlockquote().run(), editor.chain().focus().deleteRange(range).toggleBlockquote().run(),
}, },
{ {
title: 'Code', title: "Code",
description: 'Capture a code snippet.', description: "Capture a code snippet.",
searchTerms: ['codeblock'], searchTerms: ["codeblock"],
icon: IconCode, icon: IconCode,
command: ({ editor, range }: CommandProps) => command: ({ editor, range }: CommandProps) =>
editor.chain().focus().deleteRange(range).toggleCodeBlock().run(), editor.chain().focus().deleteRange(range).toggleCodeBlock().run(),
}, },
{ {
title: 'Image', title: "Image",
description: 'Upload any image from your device.', description: "Upload any image from your device.",
searchTerms: ['photo', 'picture', 'media'], searchTerms: ["photo", "picture", "media"],
icon: IconPhoto, icon: IconPhoto,
command: ({ editor, range }) => { command: ({ editor, range }) => {
editor.chain().focus().deleteRange(range).run(); editor.chain().focus().deleteRange(range).run();
@ -142,9 +142,9 @@ const CommandGroups: SlashMenuGroupedItemsType = {
if (!pageId) return; if (!pageId) return;
// upload image // upload image
const input = document.createElement('input'); const input = document.createElement("input");
input.type = 'file'; input.type = "file";
input.accept = 'image/*'; input.accept = "image/*";
input.multiple = true; input.multiple = true;
input.onchange = async () => { input.onchange = async () => {
if (input.files?.length) { if (input.files?.length) {
@ -158,9 +158,9 @@ const CommandGroups: SlashMenuGroupedItemsType = {
}, },
}, },
{ {
title: 'Video', title: "Video",
description: 'Upload any video from your device.', description: "Upload any video from your device.",
searchTerms: ['video', 'mp4', 'media'], searchTerms: ["video", "mp4", "media"],
icon: IconMovie, icon: IconMovie,
command: ({ editor, range }) => { command: ({ editor, range }) => {
editor.chain().focus().deleteRange(range).run(); editor.chain().focus().deleteRange(range).run();
@ -169,9 +169,9 @@ const CommandGroups: SlashMenuGroupedItemsType = {
if (!pageId) return; if (!pageId) return;
// upload video // upload video
const input = document.createElement('input'); const input = document.createElement("input");
input.type = 'file'; input.type = "file";
input.accept = 'video/*'; input.accept = "video/*";
input.onchange = async () => { input.onchange = async () => {
if (input.files?.length) { if (input.files?.length) {
const file = input.files[0]; const file = input.files[0];
@ -183,9 +183,9 @@ const CommandGroups: SlashMenuGroupedItemsType = {
}, },
}, },
{ {
title: 'File attachment', title: "File attachment",
description: 'Upload any file from your device.', description: "Upload any file from your device.",
searchTerms: ['file', 'attachment', 'upload', 'pdf', 'csv', 'zip'], searchTerms: ["file", "attachment", "upload", "pdf", "csv", "zip"],
icon: IconPaperclip, icon: IconPaperclip,
command: ({ editor, range }) => { command: ({ editor, range }) => {
editor.chain().focus().deleteRange(range).run(); editor.chain().focus().deleteRange(range).run();
@ -194,16 +194,16 @@ const CommandGroups: SlashMenuGroupedItemsType = {
if (!pageId) return; if (!pageId) return;
// upload file // upload file
const input = document.createElement('input'); const input = document.createElement("input");
input.type = 'file'; input.type = "file";
input.accept = ''; input.accept = "";
input.onchange = async () => { input.onchange = async () => {
if (input.files?.length) { if (input.files?.length) {
const file = input.files[0]; const file = input.files[0];
const pos = editor.view.state.selection.from; const pos = editor.view.state.selection.from;
if (file.type.includes('image/*')) { if (file.type.includes("image/*")) {
uploadImageAction(file, editor.view, pos, pageId); uploadImageAction(file, editor.view, pos, pageId);
} else if (file.type.includes('video/*')) { } else if (file.type.includes("video/*")) {
uploadVideoAction(file, editor.view, pos, pageId); uploadVideoAction(file, editor.view, pos, pageId);
} else { } else {
uploadAttachmentAction(file, editor.view, pos, pageId); uploadAttachmentAction(file, editor.view, pos, pageId);
@ -214,9 +214,9 @@ const CommandGroups: SlashMenuGroupedItemsType = {
}, },
}, },
{ {
title: 'Table', title: "Table",
description: 'Insert a table.', description: "Insert a table.",
searchTerms: ['table', 'rows', 'columns'], searchTerms: ["table", "rows", "columns"],
icon: IconTable, icon: IconTable,
command: ({ editor, range }: CommandProps) => command: ({ editor, range }: CommandProps) =>
editor editor
@ -227,43 +227,43 @@ const CommandGroups: SlashMenuGroupedItemsType = {
.run(), .run(),
}, },
{ {
title: 'Toggle block', title: "Toggle block",
description: 'Insert collapsible block.', description: "Insert collapsible block.",
searchTerms: ['collapsible', 'block', 'toggle', 'details', 'expand'], searchTerms: ["collapsible", "block", "toggle", "details", "expand"],
icon: IconCaretRightFilled, icon: IconCaretRightFilled,
command: ({ editor, range }: CommandProps) => command: ({ editor, range }: CommandProps) =>
editor.chain().focus().deleteRange(range).toggleDetails().run(), editor.chain().focus().deleteRange(range).toggleDetails().run(),
}, },
{ {
title: 'Callout', title: "Callout",
description: 'Insert callout notice.', description: "Insert callout notice.",
searchTerms: [ searchTerms: [
'callout', "callout",
'notice', "notice",
'panel', "panel",
'info', "info",
'warning', "warning",
'success', "success",
'error', "error",
'danger', "danger",
], ],
icon: IconInfoCircle, icon: IconInfoCircle,
command: ({ editor, range }: CommandProps) => command: ({ editor, range }: CommandProps) =>
editor.chain().focus().deleteRange(range).toggleCallout().run(), editor.chain().focus().deleteRange(range).toggleCallout().run(),
}, },
{ {
title: 'Math inline', title: "Math inline",
description: 'Insert inline math equation.', description: "Insert inline math equation.",
searchTerms: [ searchTerms: [
'math', "math",
'inline', "inline",
'mathinline', "mathinline",
'inlinemath', "inlinemath",
'inline math', "inline math",
'equation', "equation",
'katex', "katex",
'latex', "latex",
'tex', "tex",
], ],
icon: IconMathFunction, icon: IconMathFunction,
command: ({ editor, range }: CommandProps) => command: ({ editor, range }: CommandProps) =>
@ -276,47 +276,48 @@ const CommandGroups: SlashMenuGroupedItemsType = {
.run(), .run(),
}, },
{ {
title: 'Math block', title: "Math block",
description: 'Insert math equation', description: "Insert math equation",
searchTerms: [ searchTerms: [
'math', "math",
'block', "block",
'mathblock', "mathblock",
'block math', "block math",
'equation', "equation",
'katex', "katex",
'latex', "latex",
'tex', "tex",
], ],
icon: IconMath, icon: IconMath,
command: ({ editor, range }: CommandProps) => command: ({ editor, range }: CommandProps) =>
editor.chain().focus().deleteRange(range).setMathBlock().run(), editor.chain().focus().deleteRange(range).setMathBlock().run(),
}, },
{ {
title: 'Mermaid diagram', title: "Mermaid diagram",
description: 'Insert mermaid diagram', description: "Insert mermaid diagram",
searchTerms: ['mermaid', 'diagrams', 'chart', 'uml'], searchTerms: ["mermaid", "diagrams", "chart", "uml"],
icon: IconMermaid, icon: IconMermaid,
command: ({ editor, range }: CommandProps) => command: ({ editor, range }: CommandProps) =>
editor editor
.chain() .chain()
.focus() .focus()
.deleteRange(range) .deleteRange(range)
.setCodeBlock({ language: 'mermaid' }) .setCodeBlock({ language: "mermaid" })
.insertContent("flowchart LR\n" + " A --> B")
.run(), .run(),
}, },
{ {
title: 'Draw.io (diagrams.net) ', title: "Draw.io (diagrams.net) ",
description: 'Insert and design Drawio diagrams', description: "Insert and design Drawio diagrams",
searchTerms: ['drawio', 'diagrams', 'charts', 'uml'], searchTerms: ["drawio", "diagrams", "charts", "uml", "whiteboard"],
icon: IconDrawio, icon: IconDrawio,
command: ({ editor, range }: CommandProps) => command: ({ editor, range }: CommandProps) =>
editor.chain().focus().deleteRange(range).setDrawio().run(), editor.chain().focus().deleteRange(range).setDrawio().run(),
}, },
{ {
title: 'Excalidraw diagram', title: "Excalidraw diagram",
description: 'Draw and sketch excalidraw diagrams', description: "Draw and sketch excalidraw diagrams",
searchTerms: ['diagrams', 'draw', 'sketch'], searchTerms: ["diagrams", "draw", "sketch", "whiteboard"],
icon: IconExcalidraw, icon: IconExcalidraw,
command: ({ editor, range }: CommandProps) => command: ({ editor, range }: CommandProps) =>
editor.chain().focus().deleteRange(range).setExcalidraw().run(), editor.chain().focus().deleteRange(range).setExcalidraw().run(),

View File

@ -1 +1,2 @@
/// <reference types="vite/client" /> /// <reference types="vite/client" />
declare const APP_VERSION: string

View File

@ -12,6 +12,7 @@ export default defineConfig(({ mode }) => {
"process.env": { "process.env": {
APP_URL, APP_URL,
}, },
'APP_VERSION': JSON.stringify(process.env.npm_package_version),
}, },
plugins: [react()], plugins: [react()],
resolve: { resolve: {