mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
cleanups
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
||||||
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
||||||
import React, { useCallback } from "react";
|
import React, { useCallback } from "react";
|
||||||
import { Node as PMNode } from "prosemirror-model";
|
import { Node as PMNode } from "@tiptap/pm/model";
|
||||||
import {
|
import {
|
||||||
EditorMenuProps,
|
EditorMenuProps,
|
||||||
ShouldShowProps,
|
ShouldShowProps,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
||||||
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
||||||
import React, { useCallback, useRef, useState } from "react";
|
import React, { useCallback, useRef, useState } from "react";
|
||||||
import { DOMSerializer, Node as PMNode } from "prosemirror-model";
|
import { DOMSerializer, Node as PMNode } from "@tiptap/pm/model";
|
||||||
import {
|
import {
|
||||||
EditorMenuProps,
|
EditorMenuProps,
|
||||||
ShouldShowProps,
|
ShouldShowProps,
|
||||||
@@ -56,8 +56,7 @@ const threeColumnPresets: LayoutPreset[] = [
|
|||||||
label: "Left wide",
|
label: "Left wide",
|
||||||
icon: IconLayoutSidebarRight,
|
icon: IconLayoutSidebarRight,
|
||||||
},
|
},
|
||||||
{ layout: "three_right_wide", label: "Right wide", icon: IconLayoutSidebar
|
{ layout: "three_right_wide", label: "Right wide", icon: IconLayoutSidebar },
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
function getPresetsForCount(count: number): LayoutPreset[] {
|
function getPresetsForCount(count: number): LayoutPreset[] {
|
||||||
@@ -243,14 +242,11 @@ export function ColumnsMenu({ editor }: EditorMenuProps) {
|
|||||||
}, [editor]);
|
}, [editor]);
|
||||||
|
|
||||||
const handleDelete = useCallback(() => {
|
const handleDelete = useCallback(() => {
|
||||||
const { state } = editor;
|
|
||||||
const parent = findParentNode(
|
const parent = findParentNode(
|
||||||
(node: PMNode) => node.type.name === "columns",
|
(node: PMNode) => node.type.name === "columns",
|
||||||
)(state.selection);
|
)(editor.state.selection);
|
||||||
if (!parent) return;
|
if (!parent) return;
|
||||||
const { tr } = state;
|
editor.chain().focus().setNodeSelection(parent.pos).deleteSelection().run();
|
||||||
tr.delete(parent.pos, parent.pos + parent.node.nodeSize);
|
|
||||||
editor.view.dispatch(tr);
|
|
||||||
}, [editor]);
|
}, [editor]);
|
||||||
|
|
||||||
const columnCount = editorState?.columnCount || 2;
|
const columnCount = editorState?.columnCount || 2;
|
||||||
@@ -328,7 +324,11 @@ export function ColumnsMenu({ editor }: EditorMenuProps) {
|
|||||||
|
|
||||||
<div className={classes.divider} />
|
<div className={classes.divider} />
|
||||||
|
|
||||||
<Tooltip position="top" label={copied ? t("Copied") : t("Copy")} withinPortal={false}>
|
<Tooltip
|
||||||
|
position="top"
|
||||||
|
label={copied ? t("Copied") : t("Copy")}
|
||||||
|
withinPortal={false}
|
||||||
|
>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
onClick={handleCopy}
|
onClick={handleCopy}
|
||||||
size="lg"
|
size="lg"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
||||||
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
||||||
import { useCallback, useRef, useState } from "react";
|
import { useCallback, useRef, useState } from "react";
|
||||||
import { Node as PMNode } from "prosemirror-model";
|
import { Node as PMNode } from "@tiptap/pm/model";
|
||||||
import {
|
import {
|
||||||
EditorMenuProps,
|
EditorMenuProps,
|
||||||
ShouldShowProps,
|
ShouldShowProps,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
||||||
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
||||||
import { lazy, Suspense, useCallback, useState } from "react";
|
import { lazy, Suspense, useCallback, useState } from "react";
|
||||||
import { Node as PMNode } from "prosemirror-model";
|
import { Node as PMNode } from "@tiptap/pm/model";
|
||||||
import {
|
import {
|
||||||
EditorMenuProps,
|
EditorMenuProps,
|
||||||
ShouldShowProps,
|
ShouldShowProps,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
||||||
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
||||||
import React, { useCallback, useRef } from "react";
|
import React, { useCallback, useRef } from "react";
|
||||||
import { Node as PMNode } from "prosemirror-model";
|
import { Node as PMNode } from "@tiptap/pm/model";
|
||||||
import {
|
import {
|
||||||
EditorMenuProps,
|
EditorMenuProps,
|
||||||
ShouldShowProps,
|
ShouldShowProps,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus";
|
||||||
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
import { findParentNode, posToDOMRect, useEditorState } from "@tiptap/react";
|
||||||
import { useCallback } from "react";
|
import { useCallback } from "react";
|
||||||
import { Node as PMNode } from "prosemirror-model";
|
import { Node as PMNode } from "@tiptap/pm/model";
|
||||||
import {
|
import {
|
||||||
EditorMenuProps,
|
EditorMenuProps,
|
||||||
ShouldShowProps,
|
ShouldShowProps,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Node, mergeAttributes, findParentNode } from "@tiptap/core";
|
import { Node, mergeAttributes, findParentNode } from "@tiptap/core";
|
||||||
import { TextSelection } from "prosemirror-state";
|
import { TextSelection } from "@tiptap/pm/state";
|
||||||
|
|
||||||
export interface ColumnOptions {
|
export interface ColumnOptions {
|
||||||
HTMLAttributes: Record<string, any>;
|
HTMLAttributes: Record<string, any>;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Node, mergeAttributes, findParentNode } from "@tiptap/core";
|
import { Node, mergeAttributes, findParentNode } from "@tiptap/core";
|
||||||
import { Fragment, Node as PMNode } from "prosemirror-model";
|
import { Fragment, Node as PMNode } from "@tiptap/pm/model";
|
||||||
import { Plugin, PluginKey, TextSelection } from "prosemirror-state";
|
import { Plugin, PluginKey, TextSelection } from "@tiptap/pm/state";
|
||||||
import { Decoration, DecorationSet } from "prosemirror-view";
|
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
||||||
|
|
||||||
export type ColumnsLayout =
|
export type ColumnsLayout =
|
||||||
| "two_equal"
|
| "two_equal"
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import TiptapHeading, {
|
|||||||
HeadingOptions as TiptapHeadingOptions,
|
HeadingOptions as TiptapHeadingOptions,
|
||||||
} from "@tiptap/extension-heading";
|
} from "@tiptap/extension-heading";
|
||||||
import { mergeAttributes } from "@tiptap/react";
|
import { mergeAttributes } from "@tiptap/react";
|
||||||
import { Decoration, DecorationSet } from "prosemirror-view";
|
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
||||||
import { Plugin } from "prosemirror-state";
|
import { Plugin } from "@tiptap/pm/state";
|
||||||
import { copyToClipboard } from "../utils";
|
import { copyToClipboard } from "../utils";
|
||||||
|
|
||||||
const copyIcon = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24"><!-- Icon from Material Symbols Light by Google - https://github.com/google/material-design-icons/blob/master/LICENSE --><path fill="currentColor" d="M10.616 16.077H7.077q-1.692 0-2.884-1.192T3 12t1.193-2.885t2.884-1.193h3.539v1H7.077q-1.27 0-2.173.904Q4 10.731 4 12t.904 2.173t2.173.904h3.539zM8.5 12.5v-1h7v1zm4.885 3.577v-1h3.538q1.27 0 2.173-.904Q20 13.269 20 12t-.904-2.173t-2.173-.904h-3.538v-1h3.538q1.692 0 2.885 1.192T21 12t-1.193 2.885t-2.884 1.193z"/></svg>`;
|
const copyIcon = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24"><!-- Icon from Material Symbols Light by Google - https://github.com/google/material-design-icons/blob/master/LICENSE --><path fill="currentColor" d="M10.616 16.077H7.077q-1.692 0-2.884-1.192T3 12t1.193-2.885t2.884-1.193h3.539v1H7.077q-1.27 0-2.173.904Q4 10.731 4 12t.904 2.173t2.173.904h3.539zM8.5 12.5v-1h7v1zm4.885 3.577v-1h3.538q1.27 0 2.173-.904Q20 13.269 20 12t-.904-2.173t-2.173-.904h-3.538v-1h3.538q1.692 0 2.885 1.192T21 12t-1.193 2.885t-2.884 1.193z"/></svg>`;
|
||||||
|
|||||||
Reference in New Issue
Block a user