diff --git a/packages/client/package.json b/packages/client/package.json index 83e9cf6c..a7d43d8f 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -39,6 +39,8 @@ "@tiptap/extension-paragraph": "^2.0.0-beta.23", "@tiptap/extension-placeholder": "^2.0.0-beta.47", "@tiptap/extension-strike": "^2.0.0-beta.27", + "@tiptap/extension-subscript": "^2.0.0-beta.10", + "@tiptap/extension-superscript": "^2.0.0-beta.10", "@tiptap/extension-table": "^2.0.0-beta.48", "@tiptap/extension-table-cell": "^2.0.0-beta.20", "@tiptap/extension-table-header": "^2.0.0-beta.22", diff --git a/packages/client/src/components/icons/IconSub.tsx b/packages/client/src/components/icons/IconSub.tsx new file mode 100644 index 00000000..6eb2a3ef --- /dev/null +++ b/packages/client/src/components/icons/IconSub.tsx @@ -0,0 +1,22 @@ +import { Icon } from '@douyinfe/semi-ui'; + +export const IconSub: React.FC<{ style?: React.CSSProperties }> = ({ style = {} }) => { + return ( + + + + + + + } + /> + ); +}; diff --git a/packages/client/src/components/icons/IconSup.tsx b/packages/client/src/components/icons/IconSup.tsx new file mode 100644 index 00000000..f2e7b0d1 --- /dev/null +++ b/packages/client/src/components/icons/IconSup.tsx @@ -0,0 +1,22 @@ +import { Icon } from '@douyinfe/semi-ui'; + +export const IconSup: React.FC<{ style?: React.CSSProperties }> = ({ style = {} }) => { + return ( + + + + + + + } + /> + ); +}; diff --git a/packages/client/src/components/icons/index.tsx b/packages/client/src/components/icons/index.tsx index fb4feb8f..2a157225 100644 --- a/packages/client/src/components/icons/index.tsx +++ b/packages/client/src/components/icons/index.tsx @@ -45,3 +45,5 @@ export * from './IconHeading3'; export * from './IconTableHeaderRow'; export * from './IconTableHeaderColumn'; export * from './IconTableHeaderCell'; +export * from './IconSub'; +export * from './IconSup'; diff --git a/packages/client/src/components/tiptap/basekit.tsx b/packages/client/src/components/tiptap/basekit.tsx index e4fd19e2..f038dce9 100644 --- a/packages/client/src/components/tiptap/basekit.tsx +++ b/packages/client/src/components/tiptap/basekit.tsx @@ -36,6 +36,8 @@ import { SearchNReplace } from './extensions/search'; import { SelectionExtension } from './extensions/selection'; import { Status } from './extensions/status'; import { Strike } from './extensions/strike'; +import { Subscript } from './extensions/subscript'; +import { Superscript } from './extensions/superscript'; import { Table } from './extensions/table'; import { TableCell } from './extensions/tableCell'; import { TableHeader } from './extensions/tableHeader'; @@ -89,6 +91,8 @@ export const BaseKit = [ SelectionExtension, Status, Strike, + Subscript, + Superscript, Table, TableCell, TableHeader, diff --git a/packages/client/src/components/tiptap/extensions/emoji.ts b/packages/client/src/components/tiptap/extensions/emoji.ts index 59c09133..260e168e 100644 --- a/packages/client/src/components/tiptap/extensions/emoji.ts +++ b/packages/client/src/components/tiptap/extensions/emoji.ts @@ -60,33 +60,29 @@ export const Emoji = Node.create({ new Plugin({ key: new PluginKey('emojiPlaceholder'), props: { - decorations: (state) => { - if (!editor.isEditable) return; - - const parent = findParentNode((node) => node.type.name === 'paragraph')(state.selection); - if (!parent) { - return; - } - - const decorations: Decoration[] = []; - const isEmpty = parent && parent.node.content.size === 0; - const isSlash = parent && parent.node.textContent === ':'; - const isTopLevel = state.selection.$from.depth === 1; - - if (isTopLevel) { - if (isSlash) { - decorations.push( - Decoration.node(parent.pos, parent.pos + parent.node.nodeSize, { - 'class': 'placeholder', - 'data-placeholder': ` 继续输入进行过滤`, - }) - ); - } - - return DecorationSet.create(state.doc, decorations); - } - return null; - }, + // decorations: (state) => { + // if (!editor.isEditable) return; + // const parent = findParentNode((node) => node.type.name === 'paragraph')(state.selection); + // if (!parent) { + // return; + // } + // const decorations: Decoration[] = []; + // const isEmpty = parent && parent.node.content.size === 0; + // const isSlash = parent && parent.node.textContent === ':'; + // const isTopLevel = state.selection.$from.depth === 1; + // if (isTopLevel) { + // if (isSlash) { + // decorations.push( + // Decoration.node(parent.pos, parent.pos + parent.node.nodeSize, { + // 'class': 'placeholder', + // 'data-placeholder': ` 继续输入进行过滤`, + // }) + // ); + // } + // return DecorationSet.create(state.doc, decorations); + // } + // return null; + // }, }, }), ]; diff --git a/packages/client/src/components/tiptap/extensions/evokeMenu.tsx b/packages/client/src/components/tiptap/extensions/evokeMenu.tsx index d9e397e3..976b50f5 100644 --- a/packages/client/src/components/tiptap/extensions/evokeMenu.tsx +++ b/packages/client/src/components/tiptap/extensions/evokeMenu.tsx @@ -42,43 +42,38 @@ export const EvokeMenu = Node.create({ new Plugin({ key: new PluginKey('evokeMenuPlaceholder'), props: { - decorations: (state) => { - if (!editor.isEditable) return; - - const parent = findParentNode((node) => node.type.name === 'paragraph')(state.selection); - if (!parent) { - return; - } - - const decorations: Decoration[] = []; - const isEmpty = parent && parent.node.content.size === 0; - const isSlash = parent && parent.node.textContent === '/'; - const isTopLevel = state.selection.$from.depth === 1; - const hasOtherChildren = parent && parent.node.content.childCount > 1; - - if (isTopLevel) { - if (isEmpty) { - decorations.push( - Decoration.node(parent.pos, parent.pos + parent.node.nodeSize, { - 'class': 'is-empty', - 'data-placeholder': '输入 / 唤起更多', - }) - ); - } - - if (isSlash && !hasOtherChildren) { - decorations.push( - Decoration.node(parent.pos, parent.pos + parent.node.nodeSize, { - 'class': 'is-empty', - 'data-placeholder': ` 继续输入进行过滤`, - }) - ); - } - - return DecorationSet.create(state.doc, decorations); - } - return null; - }, + // decorations: (state) => { + // if (!editor.isEditable) return; + // const parent = findParentNode((node) => node.type.name === 'paragraph')(state.selection); + // if (!parent) { + // return; + // } + // const decorations: Decoration[] = []; + // const isEmpty = parent && parent.node.content.size === 0; + // const isSlash = parent && parent.node.textContent === '/'; + // const isTopLevel = state.selection.$from.depth === 1; + // const hasOtherChildren = parent && parent.node.content.childCount > 1; + // if (isTopLevel) { + // if (isEmpty) { + // decorations.push( + // Decoration.node(parent.pos, parent.pos + parent.node.nodeSize, { + // 'class': 'is-empty', + // 'data-placeholder': '输入 / 唤起更多', + // }) + // ); + // } + // if (isSlash && !hasOtherChildren) { + // decorations.push( + // Decoration.node(parent.pos, parent.pos + parent.node.nodeSize, { + // 'class': 'is-empty', + // 'data-placeholder': ` 继续输入进行过滤`, + // }) + // ); + // } + // return DecorationSet.create(state.doc, decorations); + // } + // return null; + // }, }, }), ]; diff --git a/packages/client/src/components/tiptap/extensions/subscript.ts b/packages/client/src/components/tiptap/extensions/subscript.ts new file mode 100644 index 00000000..18c9f724 --- /dev/null +++ b/packages/client/src/components/tiptap/extensions/subscript.ts @@ -0,0 +1,3 @@ +import Subscript from '@tiptap/extension-subscript'; + +export { Subscript }; diff --git a/packages/client/src/components/tiptap/extensions/superscript.ts b/packages/client/src/components/tiptap/extensions/superscript.ts new file mode 100644 index 00000000..2d1ce12e --- /dev/null +++ b/packages/client/src/components/tiptap/extensions/superscript.ts @@ -0,0 +1,3 @@ +import Superscript from '@tiptap/extension-superscript'; + +export { Superscript }; diff --git a/packages/client/src/components/tiptap/extensions/tableCell.tsx b/packages/client/src/components/tiptap/extensions/tableCell.tsx index f3f80654..d6816567 100644 --- a/packages/client/src/components/tiptap/extensions/tableCell.tsx +++ b/packages/client/src/components/tiptap/extensions/tableCell.tsx @@ -105,7 +105,7 @@ export const TableCell = BuiltInTableCell.extend({ return !!cells?.some((cell, index) => isRowSelected(index)(editor.state.selection)); }, init: (dom, editor) => { - dom.classList.add('table-controller-wrapper'); + dom.classList.add('bubble-memu-table-cell'); dom.classList.add('row'); ReactDOM.render( <> diff --git a/packages/client/src/components/tiptap/extensions/tableHeader.tsx b/packages/client/src/components/tiptap/extensions/tableHeader.tsx index acd512c5..52c939ae 100644 --- a/packages/client/src/components/tiptap/extensions/tableHeader.tsx +++ b/packages/client/src/components/tiptap/extensions/tableHeader.tsx @@ -94,7 +94,7 @@ export const TableHeader = BuiltInTableHeader.extend({ return !!cells?.some((cell, index) => isColumnSelected(index)(selection)); }, init: (dom, editor) => { - dom.classList.add('table-controller-wrapper'); + dom.classList.add('bubble-memu-table-cell'); ReactDOM.render( diff --git a/packages/client/src/components/tiptap/menus/baseMenu.tsx b/packages/client/src/components/tiptap/menus/baseMenu.tsx index 082b5122..fc9f59f0 100644 --- a/packages/client/src/components/tiptap/menus/baseMenu.tsx +++ b/packages/client/src/components/tiptap/menus/baseMenu.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { Button } from '@douyinfe/semi-ui'; import { IconBold, IconItalic, IconStrikeThrough, IconUnderline, IconCode } from '@douyinfe/semi-icons'; +import { IconSup, IconSub } from 'components/icons'; import { Tooltip } from 'components/tooltip'; import { isTitleActive } from '../services/isActive'; import { ColorMenu } from './color'; @@ -62,6 +63,26 @@ export const BaseMenu: React.FC<{ editor: any }> = ({ editor }) => { /> + +