mirror of https://github.com/fantasticit/think.git
refactor: refactor tiptap
parent
52329d92f0
commit
e90330ad9d
|
@ -1,7 +1,7 @@
|
||||||
import { Node, mergeAttributes } from '@tiptap/core';
|
import { Node, mergeAttributes } from '@tiptap/core';
|
||||||
import { ReactNodeViewRenderer } from '@tiptap/react';
|
import { ReactNodeViewRenderer } from '@tiptap/react';
|
||||||
import { AttachmentWrapper } from '../wrappers/attachment';
|
import { AttachmentWrapper } from '../wrappers/attachment';
|
||||||
import { getDatasetAttribute } from '../services/dataset';
|
import { getDatasetAttribute } from '../utils/dataset';
|
||||||
|
|
||||||
declare module '@tiptap/core' {
|
declare module '@tiptap/core' {
|
||||||
interface Commands<ReturnType> {
|
interface Commands<ReturnType> {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import { Node, Command, mergeAttributes, wrappingInputRule } from '@tiptap/core';
|
import { Node, mergeAttributes, wrappingInputRule } from '@tiptap/core';
|
||||||
import { ReactNodeViewRenderer } from '@tiptap/react';
|
import { ReactNodeViewRenderer } from '@tiptap/react';
|
||||||
import { BannerWrapper } from '../wrappers/banner';
|
import { BannerWrapper } from '../wrappers/banner';
|
||||||
import { typesAvailable } from '../services/markdown/markdown-to-html/markdownBanner';
|
import { getDatasetAttribute } from '../utils/dataset';
|
||||||
import { getDatasetAttribute } from '../services/dataset';
|
|
||||||
|
|
||||||
declare module '@tiptap/core' {
|
declare module '@tiptap/core' {
|
||||||
interface Commands<ReturnType> {
|
interface Commands<ReturnType> {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Blockquote as BuiltInBlockquote } from '@tiptap/extension-blockquote';
|
import { Blockquote as BuiltInBlockquote } from '@tiptap/extension-blockquote';
|
||||||
import { wrappingInputRule } from '@tiptap/core';
|
import { wrappingInputRule } from '@tiptap/core';
|
||||||
import { getParents } from '../services/dom';
|
import { getParents } from '../utils/dom';
|
||||||
import { getMarkdownSource } from '../services/markdown';
|
import { getMarkdownSource } from '../markdown/markdown-to-prosemirror';
|
||||||
|
|
||||||
export const Blockquote = BuiltInBlockquote.extend({
|
export const Blockquote = BuiltInBlockquote.extend({
|
||||||
addAttributes() {
|
addAttributes() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { BulletList as BuiltInBulletList } from '@tiptap/extension-bullet-list';
|
import { BulletList as BuiltInBulletList } from '@tiptap/extension-bullet-list';
|
||||||
import { getMarkdownSource } from '../services/markdown';
|
import { getMarkdownSource } from '../markdown/markdown-to-prosemirror';
|
||||||
|
|
||||||
export const BulletList = BuiltInBulletList.extend({
|
export const BulletList = BuiltInBulletList.extend({
|
||||||
addAttributes() {
|
addAttributes() {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { lowlight } from 'lowlight/lib/all';
|
||||||
import { Node, textblockTypeInputRule, mergeAttributes } from '@tiptap/core';
|
import { Node, textblockTypeInputRule, mergeAttributes } from '@tiptap/core';
|
||||||
import { Plugin, PluginKey, TextSelection } from 'prosemirror-state';
|
import { Plugin, PluginKey, TextSelection } from 'prosemirror-state';
|
||||||
import { ReactNodeViewRenderer } from '@tiptap/react';
|
import { ReactNodeViewRenderer } from '@tiptap/react';
|
||||||
import { LowlightPlugin } from '../services/lowlight-plugin';
|
import { LowlightPlugin } from '../utils/lowlight-plugin';
|
||||||
import { CodeBlockWrapper } from '../wrappers/code-block';
|
import { CodeBlockWrapper } from '../wrappers/code-block';
|
||||||
|
|
||||||
export interface CodeBlockOptions {
|
export interface CodeBlockOptions {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Extension } from '@tiptap/core';
|
import { Extension } from '@tiptap/core';
|
||||||
import { Plugin } from 'prosemirror-state';
|
import { Plugin } from 'prosemirror-state';
|
||||||
import { findColors } from '../services/color';
|
import { findColors } from '../utils/color';
|
||||||
|
|
||||||
export const ColorHighlighter = Extension.create({
|
export const ColorHighlighter = Extension.create({
|
||||||
name: 'colorHighlighter',
|
name: 'colorHighlighter',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Node, mergeAttributes } from '@tiptap/core';
|
import { Node, mergeAttributes } from '@tiptap/core';
|
||||||
import { ReactNodeViewRenderer } from '@tiptap/react';
|
import { ReactNodeViewRenderer } from '@tiptap/react';
|
||||||
import { CountdownWrapper } from '../wrappers/countdown';
|
import { CountdownWrapper } from '../wrappers/countdown';
|
||||||
import { getDatasetAttribute } from '../services/dataset';
|
import { getDatasetAttribute } from '../utils/dataset';
|
||||||
|
|
||||||
declare module '@tiptap/core' {
|
declare module '@tiptap/core' {
|
||||||
interface Commands<ReturnType> {
|
interface Commands<ReturnType> {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Node, mergeAttributes, wrappingInputRule } from '@tiptap/core';
|
import { Node, mergeAttributes, wrappingInputRule } from '@tiptap/core';
|
||||||
import { ReactNodeViewRenderer } from '@tiptap/react';
|
import { ReactNodeViewRenderer } from '@tiptap/react';
|
||||||
import { DocumentChildrenWrapper } from '../wrappers/document-children';
|
import { DocumentChildrenWrapper } from '../wrappers/document-children';
|
||||||
import { getDatasetAttribute } from '../services/dataset';
|
import { getDatasetAttribute } from '../utils/dataset';
|
||||||
|
|
||||||
declare module '@tiptap/core' {
|
declare module '@tiptap/core' {
|
||||||
interface Commands<ReturnType> {
|
interface Commands<ReturnType> {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Node, mergeAttributes, wrappingInputRule } from '@tiptap/core';
|
import { Node, mergeAttributes, wrappingInputRule } from '@tiptap/core';
|
||||||
import { ReactNodeViewRenderer } from '@tiptap/react';
|
import { ReactNodeViewRenderer } from '@tiptap/react';
|
||||||
import { DocumentReferenceWrapper } from '../wrappers/document-reference';
|
import { DocumentReferenceWrapper } from '../wrappers/document-reference';
|
||||||
import { getDatasetAttribute } from '../services/dataset';
|
import { getDatasetAttribute } from '../utils/dataset';
|
||||||
|
|
||||||
declare module '@tiptap/core' {
|
declare module '@tiptap/core' {
|
||||||
interface Commands<ReturnType> {
|
interface Commands<ReturnType> {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Mark, mergeAttributes, markInputRule } from '@tiptap/core';
|
import { Mark, mergeAttributes, markInputRule } from '@tiptap/core';
|
||||||
import { PARSE_HTML_PRIORITY_LOWEST } from '../constants';
|
import { PARSE_HTML_PRIORITY_LOWEST } from '../constants';
|
||||||
import { markInputRegex, extractMarkAttributesFromMatch } from '../services/mark-utils';
|
import { markInputRegex, extractMarkAttributesFromMatch } from '../utils/mark-utils';
|
||||||
|
|
||||||
export const marks = [{ name: 'underline', tag: 'u' }];
|
export const marks = [{ name: 'underline', tag: 'u' }];
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Node, mergeAttributes } from '@tiptap/core';
|
import { Node, mergeAttributes } from '@tiptap/core';
|
||||||
import { ReactNodeViewRenderer } from '@tiptap/react';
|
import { ReactNodeViewRenderer } from '@tiptap/react';
|
||||||
import { IframeWrapper } from '../wrappers/iframe';
|
import { IframeWrapper } from '../wrappers/iframe';
|
||||||
import { getDatasetAttribute } from '../services/dataset';
|
import { getDatasetAttribute } from '../utils/dataset';
|
||||||
|
|
||||||
declare module '@tiptap/core' {
|
declare module '@tiptap/core' {
|
||||||
interface Commands<ReturnType> {
|
interface Commands<ReturnType> {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { Command, Extension } from '@tiptap/core';
|
import { Command, Extension } from '@tiptap/core';
|
||||||
import { sinkListItem, liftListItem } from 'prosemirror-schema-list';
|
import { sinkListItem, liftListItem } from 'prosemirror-schema-list';
|
||||||
import { TextSelection, AllSelection, Transaction } from 'prosemirror-state';
|
import { TextSelection, AllSelection, Transaction } from 'prosemirror-state';
|
||||||
import { isListActive } from '../services/is-active';
|
import { isListActive } from '../utils/is-active';
|
||||||
import { clamp } from '../services/clamp';
|
import { clamp } from '../utils/clamp';
|
||||||
import { getNodeType } from '../services/type';
|
import { getNodeType } from '../utils/type';
|
||||||
import { isListNode } from '../services/node';
|
import { isListNode } from '../utils/node';
|
||||||
|
|
||||||
type IndentOptions = {
|
type IndentOptions = {
|
||||||
types: string[];
|
types: string[];
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Node, mergeAttributes, nodeInputRule } from '@tiptap/core';
|
import { Node, mergeAttributes, nodeInputRule } from '@tiptap/core';
|
||||||
import { ReactNodeViewRenderer } from '@tiptap/react';
|
import { ReactNodeViewRenderer } from '@tiptap/react';
|
||||||
import { MindWrapper } from '../wrappers/mind';
|
import { MindWrapper } from '../wrappers/mind';
|
||||||
import { getDatasetAttribute } from '../services/dataset';
|
import { getDatasetAttribute } from '../utils/dataset';
|
||||||
|
|
||||||
const DEFAULT_MIND_DATA = {
|
const DEFAULT_MIND_DATA = {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { OrderedList as BuiltInOrderedList } from '@tiptap/extension-ordered-list';
|
import { OrderedList as BuiltInOrderedList } from '@tiptap/extension-ordered-list';
|
||||||
import { getMarkdownSource } from '../services/markdown';
|
import { getMarkdownSource } from '../markdown/markdown-to-prosemirror';
|
||||||
|
|
||||||
export const OrderedList = BuiltInOrderedList.extend({
|
export const OrderedList = BuiltInOrderedList.extend({
|
||||||
addAttributes() {
|
addAttributes() {
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import { Extension } from '@tiptap/core';
|
import { Extension } from '@tiptap/core';
|
||||||
import { Plugin, PluginKey } from 'prosemirror-state';
|
import { Plugin, PluginKey } from 'prosemirror-state';
|
||||||
import { EXTENSION_PRIORITY_HIGHEST } from '../constants';
|
import { EXTENSION_PRIORITY_HIGHEST } from '../constants';
|
||||||
import { handleFileEvent } from '../services/upload';
|
import { handleFileEvent } from '../utils/upload';
|
||||||
import { isInCode, LANGUAGES } from '../services/code';
|
import { isInCode, LANGUAGES } from '../utils/code';
|
||||||
import {
|
import {
|
||||||
isMarkdown,
|
isMarkdown,
|
||||||
normalizePastedMarkdown,
|
normalizePastedMarkdown,
|
||||||
markdownToProsemirror,
|
markdownToProsemirror,
|
||||||
prosemirrorToMarkdown,
|
prosemirrorToMarkdown,
|
||||||
} from '../services/markdown';
|
} from '../markdown/markdown-to-prosemirror';
|
||||||
import { isTitleNode } from '../services/node';
|
import { isTitleNode } from '../utils/node';
|
||||||
|
|
||||||
export const Paste = Extension.create({
|
export const Paste = Extension.create({
|
||||||
name: 'paste',
|
name: 'paste',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Extension } from '@tiptap/core';
|
import { Extension } from '@tiptap/core';
|
||||||
import { Plugin, PluginKey, NodeSelection, TextSelection, Selection, AllSelection } from 'prosemirror-state';
|
import { Plugin, PluginKey, NodeSelection, TextSelection, Selection, AllSelection } from 'prosemirror-state';
|
||||||
import { Decoration, DecorationSet } from 'prosemirror-view';
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
||||||
import { getCurrentNode, isInCodeBlock, isInBanner } from '../services/node';
|
import { getCurrentNode, isInCodeBlock, isInBanner } from '../utils/node';
|
||||||
import { EXTENSION_PRIORITY_HIGHEST } from '../constants';
|
import { EXTENSION_PRIORITY_HIGHEST } from '../constants';
|
||||||
|
|
||||||
export const selectionPluginKey = new PluginKey('selection');
|
export const selectionPluginKey = new PluginKey('selection');
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Node, mergeAttributes } from '@tiptap/core';
|
import { Node, mergeAttributes } from '@tiptap/core';
|
||||||
import { ReactNodeViewRenderer } from '@tiptap/react';
|
import { ReactNodeViewRenderer } from '@tiptap/react';
|
||||||
import { StatusWrapper } from '../wrappers/status';
|
import { StatusWrapper } from '../wrappers/status';
|
||||||
import { getDatasetAttribute } from '../services/dataset';
|
import { getDatasetAttribute } from '../utils/dataset';
|
||||||
|
|
||||||
declare module '@tiptap/core' {
|
declare module '@tiptap/core' {
|
||||||
interface Commands<ReturnType> {
|
interface Commands<ReturnType> {
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {
|
||||||
isTableSelected,
|
isTableSelected,
|
||||||
selectRow,
|
selectRow,
|
||||||
selectTable,
|
selectTable,
|
||||||
} from '../services/table';
|
} from '../utils/table';
|
||||||
import { FloatMenuView } from '../views/float-menu';
|
import { FloatMenuView } from '../views/float-menu';
|
||||||
|
|
||||||
export const TableCell = BuiltInTableCell.extend({
|
export const TableCell = BuiltInTableCell.extend({
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { TableHeader as BuiltInTableHeader } from '@tiptap/extension-table-heade
|
||||||
import { Tooltip } from 'components/tooltip';
|
import { Tooltip } from 'components/tooltip';
|
||||||
import { Plugin, PluginKey } from 'prosemirror-state';
|
import { Plugin, PluginKey } from 'prosemirror-state';
|
||||||
import { Decoration, DecorationSet } from 'prosemirror-view';
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
||||||
import { getCellsInRow, isColumnSelected, isTableSelected, selectColumn } from '../services/table';
|
import { getCellsInRow, isColumnSelected, isTableSelected, selectColumn } from '../utils/table';
|
||||||
import { FloatMenuView } from '../views/float-menu';
|
import { FloatMenuView } from '../views/float-menu';
|
||||||
|
|
||||||
// @flow
|
// @flow
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Node, mergeAttributes } from '@tiptap/core';
|
import { Node, mergeAttributes } from '@tiptap/core';
|
||||||
import { Plugin, PluginKey } from 'prosemirror-state';
|
import { Plugin, PluginKey } from 'prosemirror-state';
|
||||||
import { isInTitle } from '../services/node';
|
import { isInTitle } from '../utils/node';
|
||||||
import { TextSelection } from 'prosemirror-state';
|
import { TextSelection } from 'prosemirror-state';
|
||||||
|
|
||||||
export interface TitleOptions {
|
export interface TitleOptions {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { CollaborationCursor } from './collaboration-cursor';
|
||||||
import History from '@tiptap/extension-history';
|
import History from '@tiptap/extension-history';
|
||||||
import { getRandomColor } from 'helpers/color';
|
import { getRandomColor } from 'helpers/color';
|
||||||
import { Document } from './extensions/document';
|
import { Document } from './extensions/document';
|
||||||
export { BaseKit, CommentKit } from './basekit';
|
export { BaseKit, CommentKit } from './start-kit';
|
||||||
|
|
||||||
export { getSchema } from '@tiptap/core';
|
export { getSchema } from '@tiptap/core';
|
||||||
export * from './menubar';
|
export * from './menubar';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { BaseKit } from '../../../basekit';
|
import { BaseKit } from '../../../start-kit';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过 tiptap extension 的配置从 DOM 节点上获取属性值
|
* 通过 tiptap extension 的配置从 DOM 节点上获取属性值
|
||||||
|
@ -17,11 +17,7 @@ const getAttribute = (
|
||||||
accu[key] = conf.default;
|
accu[key] = conf.default;
|
||||||
|
|
||||||
if (conf.parseHTML) {
|
if (conf.parseHTML) {
|
||||||
// try {
|
|
||||||
accu[key] = conf.parseHTML(element);
|
accu[key] = conf.parseHTML(element);
|
||||||
// } catch (e) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return accu;
|
return accu;
|
|
@ -1,6 +1,6 @@
|
||||||
import { htmlToPromsemirror } from './html-to-prosemirror';
|
import { htmlToPromsemirror } from './html-to-prosemirror';
|
||||||
import { markdownToHTML } from './markdown-to-html';
|
import { markdownToHTML } from './markdown-to-html';
|
||||||
export { prosemirrorToMarkdown } from './prosemirror-to-markdown';
|
export { prosemirrorToMarkdown } from '../prosemirror-to-markdown';
|
||||||
export * from './helpers';
|
export * from './helpers';
|
||||||
export * from './markdown-source-map';
|
export * from './markdown-source-map';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import container from 'markdown-it-container';
|
import container from 'markdown-it-container';
|
||||||
import { strToJSON, jsonToDOMDataset } from '../../dataset';
|
import { strToJSON, jsonToDOMDataset } from '../../../utils/dataset';
|
||||||
|
|
||||||
export const createMarkdownContainer = (types: string | Array<string>) => (md) => {
|
export const createMarkdownContainer = (types: string | Array<string>) => (md) => {
|
||||||
if (!Array.isArray(types)) {
|
if (!Array.isArray(types)) {
|
|
@ -1,4 +1,4 @@
|
||||||
import { jsonToStr } from '../../dataset';
|
import { jsonToStr } from '../../utils/dataset';
|
||||||
|
|
||||||
const uniq = (arr: string[]) => [...new Set(arr)];
|
const uniq = (arr: string[]) => [...new Set(arr)];
|
||||||
|
|
|
@ -1,39 +1,39 @@
|
||||||
import { MarkdownSerializer as ProseMirrorMarkdownSerializer, defaultMarkdownSerializer } from 'prosemirror-markdown';
|
import { MarkdownSerializer as ProseMirrorMarkdownSerializer, defaultMarkdownSerializer } from 'prosemirror-markdown';
|
||||||
import { Attachment } from '../../../extensions/attachment';
|
import { Attachment } from '../../extensions/attachment';
|
||||||
import { Banner } from '../../../extensions/banner';
|
import { Banner } from '../../extensions/banner';
|
||||||
import { Bold } from '../../../extensions/bold';
|
import { Bold } from '../../extensions/bold';
|
||||||
import { BulletList } from '../../../extensions/bullet-list';
|
import { BulletList } from '../../extensions/bullet-list';
|
||||||
import { Code } from '../../../extensions/code';
|
import { Code } from '../../extensions/code';
|
||||||
import { CodeBlock } from '../../../extensions/code-block';
|
import { CodeBlock } from '../../extensions/code-block';
|
||||||
import { Countdown } from '../../../extensions/countdown';
|
import { Countdown } from '../../extensions/countdown';
|
||||||
import { DocumentChildren } from '../../../extensions/document-children';
|
import { DocumentChildren } from '../../extensions/document-children';
|
||||||
import { DocumentReference } from '../../../extensions/document-reference';
|
import { DocumentReference } from '../../extensions/document-reference';
|
||||||
import { HardBreak } from '../../../extensions/hard-break';
|
import { HardBreak } from '../../extensions/hard-break';
|
||||||
import { Heading } from '../../../extensions/heading';
|
import { Heading } from '../../extensions/heading';
|
||||||
import { HorizontalRule } from '../../../extensions/horizontal-rule';
|
import { HorizontalRule } from '../../extensions/horizontal-rule';
|
||||||
import { marks } from '../../../extensions/html-marks';
|
import { marks } from '../../extensions/html-marks';
|
||||||
import { Iframe } from '../../../extensions/iframe';
|
import { Iframe } from '../../extensions/iframe';
|
||||||
import { Image } from '../../../extensions/image';
|
import { Image } from '../../extensions/image';
|
||||||
import { Italic } from '../../../extensions/italic';
|
import { Italic } from '../../extensions/italic';
|
||||||
import { Katex } from '../../../extensions/katex';
|
import { Katex } from '../../extensions/katex';
|
||||||
import { Link } from '../../../extensions/link';
|
import { Link } from '../../extensions/link';
|
||||||
import { ListItem } from '../../../extensions/listItem';
|
import { ListItem } from '../../extensions/listItem';
|
||||||
import { Mind } from '../../../extensions/mind';
|
import { Mind } from '../../extensions/mind';
|
||||||
import { OrderedList } from '../../../extensions/ordered-list';
|
import { OrderedList } from '../../extensions/ordered-list';
|
||||||
import { Paragraph } from '../../../extensions/paragraph';
|
import { Paragraph } from '../../extensions/paragraph';
|
||||||
import { Status } from '../../../extensions/status';
|
import { Status } from '../../extensions/status';
|
||||||
import { Strike } from '../../../extensions/strike';
|
import { Strike } from '../../extensions/strike';
|
||||||
import { Subscript } from '../../../extensions/subscript';
|
import { Subscript } from '../../extensions/subscript';
|
||||||
import { Superscript } from '../../../extensions/superscript';
|
import { Superscript } from '../../extensions/superscript';
|
||||||
import { Table } from '../../../extensions/table';
|
import { Table } from '../../extensions/table';
|
||||||
import { TableCell } from '../../../extensions/table-cell';
|
import { TableCell } from '../../extensions/table-cell';
|
||||||
import { TableHeader } from '../../../extensions/table-header';
|
import { TableHeader } from '../../extensions/table-header';
|
||||||
import { TableRow } from '../../../extensions/table-row';
|
import { TableRow } from '../../extensions/table-row';
|
||||||
import { Text } from '../../../extensions/text';
|
import { Text } from '../../extensions/text';
|
||||||
import { TaskItem } from '../../../extensions/task-item';
|
import { TaskItem } from '../../extensions/task-item';
|
||||||
import { TaskList } from '../../../extensions/task-list';
|
import { TaskList } from '../../extensions/task-list';
|
||||||
import { TextStyle } from '../../../extensions/text-style';
|
import { TextStyle } from '../../extensions/text-style';
|
||||||
import { Title } from '../../../extensions/title';
|
import { Title } from '../../extensions/title';
|
||||||
import {
|
import {
|
||||||
isPlainURL,
|
isPlainURL,
|
||||||
renderHardBreak,
|
renderHardBreak,
|
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||||
import { Editor } from '@tiptap/core';
|
import { Editor } from '@tiptap/core';
|
||||||
import { Button, Dropdown, Tooltip } from '@douyinfe/semi-ui';
|
import { Button, Dropdown, Tooltip } from '@douyinfe/semi-ui';
|
||||||
import { IconAlignLeft, IconAlignCenter, IconAlignRight, IconAlignJustify } from '@douyinfe/semi-icons';
|
import { IconAlignLeft, IconAlignCenter, IconAlignRight, IconAlignJustify } from '@douyinfe/semi-icons';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
|
|
||||||
export const Align: React.FC<{ editor: Editor }> = ({ editor }) => {
|
export const Align: React.FC<{ editor: Editor }> = ({ editor }) => {
|
||||||
const current = (() => {
|
const current = (() => {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Editor } from '@tiptap/core';
|
||||||
import { Button } from '@douyinfe/semi-ui';
|
import { Button } from '@douyinfe/semi-ui';
|
||||||
import { IconMark } from '@douyinfe/semi-icons';
|
import { IconMark } from '@douyinfe/semi-icons';
|
||||||
import { Tooltip } from 'components/tooltip';
|
import { Tooltip } from 'components/tooltip';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
import { ColorPicker } from '../_components/color-picker';
|
import { ColorPicker } from '../_components/color-picker';
|
||||||
|
|
||||||
export const BackgroundColor: React.FC<{ editor: Editor }> = ({ editor }) => {
|
export const BackgroundColor: React.FC<{ editor: Editor }> = ({ editor }) => {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { Tooltip } from 'components/tooltip';
|
||||||
import { BubbleMenu } from '../../views/bubble-menu';
|
import { BubbleMenu } from '../../views/bubble-menu';
|
||||||
import { Divider } from '../../divider';
|
import { Divider } from '../../divider';
|
||||||
import { Banner } from '../../extensions/banner';
|
import { Banner } from '../../extensions/banner';
|
||||||
import { deleteNode } from '../../services/delete-node';
|
import { deleteNode } from '../../utils/delete-node';
|
||||||
|
|
||||||
export const BannerBubbleMenu: React.FC<{ editor: Editor }> = ({ editor }) => {
|
export const BannerBubbleMenu: React.FC<{ editor: Editor }> = ({ editor }) => {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Editor } from '@tiptap/core';
|
||||||
import { Button } from '@douyinfe/semi-ui';
|
import { Button } from '@douyinfe/semi-ui';
|
||||||
import { Tooltip } from 'components/tooltip';
|
import { Tooltip } from 'components/tooltip';
|
||||||
import { IconQuote } from 'components/icons';
|
import { IconQuote } from 'components/icons';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
|
|
||||||
export const Blockquote: React.FC<{ editor: Editor }> = ({ editor }) => {
|
export const Blockquote: React.FC<{ editor: Editor }> = ({ editor }) => {
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Editor } from '@tiptap/core';
|
||||||
import { Button } from '@douyinfe/semi-ui';
|
import { Button } from '@douyinfe/semi-ui';
|
||||||
import { IconBold } from '@douyinfe/semi-icons';
|
import { IconBold } from '@douyinfe/semi-icons';
|
||||||
import { Tooltip } from 'components/tooltip';
|
import { Tooltip } from 'components/tooltip';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
|
|
||||||
export const Bold: React.FC<{ editor: Editor }> = ({ editor }) => {
|
export const Bold: React.FC<{ editor: Editor }> = ({ editor }) => {
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Editor } from '@tiptap/core';
|
||||||
import { Button } from '@douyinfe/semi-ui';
|
import { Button } from '@douyinfe/semi-ui';
|
||||||
import { IconList } from 'components/icons';
|
import { IconList } from 'components/icons';
|
||||||
import { Tooltip } from 'components/tooltip';
|
import { Tooltip } from 'components/tooltip';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
|
|
||||||
export const BulletList: React.FC<{ editor: Editor }> = ({ editor }) => {
|
export const BulletList: React.FC<{ editor: Editor }> = ({ editor }) => {
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Editor } from '@tiptap/core';
|
||||||
import { Button } from '@douyinfe/semi-ui';
|
import { Button } from '@douyinfe/semi-ui';
|
||||||
import { IconCode } from '@douyinfe/semi-icons';
|
import { IconCode } from '@douyinfe/semi-icons';
|
||||||
import { Tooltip } from 'components/tooltip';
|
import { Tooltip } from 'components/tooltip';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
|
|
||||||
export const Code: React.FC<{ editor: Editor }> = ({ editor }) => {
|
export const Code: React.FC<{ editor: Editor }> = ({ editor }) => {
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import { Select } from '@douyinfe/semi-ui';
|
import { Select } from '@douyinfe/semi-ui';
|
||||||
import { Editor } from '@tiptap/core';
|
import { Editor } from '@tiptap/core';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
|
|
||||||
export const FONT_SIZES = [12, 13, 14, 15, 16, 19, 22, 24, 29, 32, 40, 48];
|
export const FONT_SIZES = [12, 13, 14, 15, 16, 19, 22, 24, 29, 32, 40, 48];
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import { Editor } from '@tiptap/core';
|
import { Editor } from '@tiptap/core';
|
||||||
import { Select } from '@douyinfe/semi-ui';
|
import { Select } from '@douyinfe/semi-ui';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
|
|
||||||
const getCurrentCaretTitle = (editor) => {
|
const getCurrentCaretTitle = (editor) => {
|
||||||
if (editor.isActive('heading', { level: 1 })) return 1;
|
if (editor.isActive('heading', { level: 1 })) return 1;
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Editor } from '@tiptap/core';
|
||||||
import { Button } from '@douyinfe/semi-ui';
|
import { Button } from '@douyinfe/semi-ui';
|
||||||
import { Tooltip } from 'components/tooltip';
|
import { Tooltip } from 'components/tooltip';
|
||||||
import { IconHorizontalRule } from 'components/icons';
|
import { IconHorizontalRule } from 'components/icons';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
|
|
||||||
export const HorizontalRule: React.FC<{ editor: Editor }> = ({ editor }) => {
|
export const HorizontalRule: React.FC<{ editor: Editor }> = ({ editor }) => {
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Editor } from '@tiptap/core';
|
||||||
import { Button } from '@douyinfe/semi-ui';
|
import { Button } from '@douyinfe/semi-ui';
|
||||||
import { IconIndentLeft, IconIndentRight } from '@douyinfe/semi-icons';
|
import { IconIndentLeft, IconIndentRight } from '@douyinfe/semi-icons';
|
||||||
import { Tooltip } from 'components/tooltip';
|
import { Tooltip } from 'components/tooltip';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
|
|
||||||
export const Ident: React.FC<{ editor: Editor }> = ({ editor }) => {
|
export const Ident: React.FC<{ editor: Editor }> = ({ editor }) => {
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
|
|
|
@ -17,7 +17,7 @@ import {
|
||||||
IconCountdown,
|
IconCountdown,
|
||||||
} from 'components/icons';
|
} from 'components/icons';
|
||||||
import { GridSelect } from 'components/grid-select';
|
import { GridSelect } from 'components/grid-select';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
import { createCountdown } from '../countdown/service';
|
import { createCountdown } from '../countdown/service';
|
||||||
|
|
||||||
export const Insert: React.FC<{ editor: Editor }> = ({ editor }) => {
|
export const Insert: React.FC<{ editor: Editor }> = ({ editor }) => {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Editor } from '@tiptap/core';
|
||||||
import { Button } from '@douyinfe/semi-ui';
|
import { Button } from '@douyinfe/semi-ui';
|
||||||
import { IconItalic } from '@douyinfe/semi-icons';
|
import { IconItalic } from '@douyinfe/semi-icons';
|
||||||
import { Tooltip } from 'components/tooltip';
|
import { Tooltip } from 'components/tooltip';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
|
|
||||||
export const Italic: React.FC<{ editor: Editor }> = ({ editor }) => {
|
export const Italic: React.FC<{ editor: Editor }> = ({ editor }) => {
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
|
|
|
@ -5,8 +5,8 @@ import { Tooltip } from 'components/tooltip';
|
||||||
import { Divider } from '../../divider';
|
import { Divider } from '../../divider';
|
||||||
import { BubbleMenu } from '../../views/bubble-menu';
|
import { BubbleMenu } from '../../views/bubble-menu';
|
||||||
import { Link } from '../../extensions/link';
|
import { Link } from '../../extensions/link';
|
||||||
import { isMarkActive } from '../../services/is-active';
|
import { isMarkActive } from '../../utils/is-active';
|
||||||
import { findMarkPosition } from '../../services/find-position';
|
import { findMarkPosition } from '../../utils/find-position';
|
||||||
import { triggerOpenLinkSettingModal } from '../_event';
|
import { triggerOpenLinkSettingModal } from '../_event';
|
||||||
|
|
||||||
export const LinkBubbleMenu = ({ editor }) => {
|
export const LinkBubbleMenu = ({ editor }) => {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Editor } from '@tiptap/core';
|
||||||
import { Button } from '@douyinfe/semi-ui';
|
import { Button } from '@douyinfe/semi-ui';
|
||||||
import { Tooltip } from 'components/tooltip';
|
import { Tooltip } from 'components/tooltip';
|
||||||
import { IconLink } from 'components/icons';
|
import { IconLink } from 'components/icons';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
import { createOrToggleLink } from './service';
|
import { createOrToggleLink } from './service';
|
||||||
import { LinkBubbleMenu } from './bubble';
|
import { LinkBubbleMenu } from './bubble';
|
||||||
import { LinkSettingModal } from './modal';
|
import { LinkSettingModal } from './modal';
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Form, Modal } from '@douyinfe/semi-ui';
|
||||||
import { FormApi } from '@douyinfe/semi-ui/lib/es/form';
|
import { FormApi } from '@douyinfe/semi-ui/lib/es/form';
|
||||||
import { Editor } from '@tiptap/core';
|
import { Editor } from '@tiptap/core';
|
||||||
import { useToggle } from 'hooks/use-toggle';
|
import { useToggle } from 'hooks/use-toggle';
|
||||||
import { isValidURL } from '../../services/valid-url';
|
import { isValidURL } from '../../utils/valid-url';
|
||||||
import { event, OPEN_LINK_SETTING_MODAL } from '../_event';
|
import { event, OPEN_LINK_SETTING_MODAL } from '../_event';
|
||||||
|
|
||||||
type IProps = { editor: Editor };
|
type IProps = { editor: Editor };
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Editor } from '@tiptap/core';
|
import { Editor } from '@tiptap/core';
|
||||||
import { isMarkActive } from '../../services/is-active';
|
import { isMarkActive } from '../../utils/is-active';
|
||||||
import { triggerOpenLinkSettingModal } from '../_event';
|
import { triggerOpenLinkSettingModal } from '../_event';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Editor } from '@tiptap/core';
|
||||||
import { Button } from '@douyinfe/semi-ui';
|
import { Button } from '@douyinfe/semi-ui';
|
||||||
import { IconOrderedList } from 'components/icons';
|
import { IconOrderedList } from 'components/icons';
|
||||||
import { Tooltip } from 'components/tooltip';
|
import { Tooltip } from 'components/tooltip';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
|
|
||||||
export const OrderedList: React.FC<{ editor: Editor }> = ({ editor }) => {
|
export const OrderedList: React.FC<{ editor: Editor }> = ({ editor }) => {
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Editor } from '@tiptap/core';
|
||||||
import { Button } from '@douyinfe/semi-ui';
|
import { Button } from '@douyinfe/semi-ui';
|
||||||
import { IconStrikeThrough } from '@douyinfe/semi-icons';
|
import { IconStrikeThrough } from '@douyinfe/semi-icons';
|
||||||
import { Tooltip } from 'components/tooltip';
|
import { Tooltip } from 'components/tooltip';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
|
|
||||||
export const Strike: React.FC<{ editor: Editor }> = ({ editor }) => {
|
export const Strike: React.FC<{ editor: Editor }> = ({ editor }) => {
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||||
import { Button } from '@douyinfe/semi-ui';
|
import { Button } from '@douyinfe/semi-ui';
|
||||||
import { IconSub } from 'components/icons';
|
import { IconSub } from 'components/icons';
|
||||||
import { Tooltip } from 'components/tooltip';
|
import { Tooltip } from 'components/tooltip';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
|
|
||||||
export const Subscript: React.FC<{ editor: any }> = ({ editor }) => {
|
export const Subscript: React.FC<{ editor: any }> = ({ editor }) => {
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||||
import { Button } from '@douyinfe/semi-ui';
|
import { Button } from '@douyinfe/semi-ui';
|
||||||
import { IconSup } from 'components/icons';
|
import { IconSup } from 'components/icons';
|
||||||
import { Tooltip } from 'components/tooltip';
|
import { Tooltip } from 'components/tooltip';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
|
|
||||||
export const Superscript: React.FC<{ editor: any }> = ({ editor }) => {
|
export const Superscript: React.FC<{ editor: any }> = ({ editor }) => {
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Editor } from '@tiptap/core';
|
||||||
import { Button } from '@douyinfe/semi-ui';
|
import { Button } from '@douyinfe/semi-ui';
|
||||||
import { Tooltip } from 'components/tooltip';
|
import { Tooltip } from 'components/tooltip';
|
||||||
import { IconTask } from 'components/icons';
|
import { IconTask } from 'components/icons';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
|
|
||||||
export const TaskList: React.FC<{ editor: Editor }> = ({ editor }) => {
|
export const TaskList: React.FC<{ editor: Editor }> = ({ editor }) => {
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Editor } from '@tiptap/core';
|
||||||
import { Button } from '@douyinfe/semi-ui';
|
import { Button } from '@douyinfe/semi-ui';
|
||||||
import { IconFont } from '@douyinfe/semi-icons';
|
import { IconFont } from '@douyinfe/semi-icons';
|
||||||
import { Tooltip } from 'components/tooltip';
|
import { Tooltip } from 'components/tooltip';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
import { ColorPicker } from '../_components/color-picker';
|
import { ColorPicker } from '../_components/color-picker';
|
||||||
|
|
||||||
export const TextColor: React.FC<{ editor: Editor }> = ({ editor }) => {
|
export const TextColor: React.FC<{ editor: Editor }> = ({ editor }) => {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Editor } from '@tiptap/core';
|
||||||
import { Button } from '@douyinfe/semi-ui';
|
import { Button } from '@douyinfe/semi-ui';
|
||||||
import { IconUnderline } from '@douyinfe/semi-icons';
|
import { IconUnderline } from '@douyinfe/semi-icons';
|
||||||
import { Tooltip } from 'components/tooltip';
|
import { Tooltip } from 'components/tooltip';
|
||||||
import { isTitleActive } from '../../services/is-active';
|
import { isTitleActive } from '../../utils/is-active';
|
||||||
|
|
||||||
export const Underline: React.FC<{ editor: Editor }> = ({ editor }) => {
|
export const Underline: React.FC<{ editor: Editor }> = ({ editor }) => {
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue