@blocklet/editor 2.3.47 → 2.3.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,7 +23,6 @@ import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
23
23
  import { TablePlugin } from '@lexical/react/LexicalTablePlugin';
24
24
  import { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin';
25
25
  import { useEffect, useState } from 'react';
26
- import { Box, styled, alpha } from '@mui/material';
27
26
  import { useSettings } from './context/SettingsContext';
28
27
  import { useSharedHistoryContext } from './context/SharedHistoryContext';
29
28
  import useHasNodes from './hooks/useHasNodes';
@@ -80,6 +79,7 @@ import { useResponsiveTable } from './hooks/useResponsiveTable';
80
79
  import { useTranslationListener } from './hooks/useTranslationListener';
81
80
  import { PagesKitComponentPlugin } from '../ext/PagesKitComponent/PagesKitComponentPlugin';
82
81
  import { EditorHolderPlugin } from '../ext/EditorHolderPlugin';
82
+ import { StyledEditorContent } from './styled-editor-content';
83
83
  export default function Editor({ children, prepend, placeholder, onChange, autoFocus = true, showToolbar = true, editorRef, onReady, enableHeadingsIdPlugin, }) {
84
84
  const [editor] = useLexicalComposerContext();
85
85
  const [editable, setEditable] = useState(false);
@@ -109,52 +109,7 @@ export default function Editor({ children, prepend, placeholder, onChange, autoF
109
109
  }
110
110
  }, [hasNodes('image'), hasUploader]);
111
111
  if (minimalMode) {
112
- return (_jsxs(_Fragment, { children: [prepend, isRichText && editable && showToolbar && _jsx(ToolbarPlugin, {}), hasNodes('image') && hasUploader && _jsx(DragDropPaste, {}), autoFocus && _jsx(AutoFocusPlugin, { defaultSelection: "rootEnd" }), _jsx(ClearEditorPlugin, {}), !!editable && _jsx(ComponentPickerPlugin, {}), !!editable && _jsx(MentionsPlugin, {}), hasNodes('link') && _jsx(AutoEmbedPlugin, {}), _jsx(PasteSlackImagePlugin, {}), _jsx(EditorContent, { ref: onRef, className: cx('be-content', editable && 'editable'), children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: cx('be-editable', 'notranslate') }), placeholder: _jsx(Placeholder, { className: "be-placeholder", children: placeholder }), ErrorBoundary: LexicalErrorBoundary }) }), hasNodes('code', 'code-highlight') && _jsx(CodeHighlightPlugin, {}), hasNodes('image') && hasUploader && _jsx(ImagesPlugin, {}), hasNodes('video') && _jsx(VideoPlugin, {}), hasNodes('link') && _jsx(LinkPlugin, {}), hasNodes('tweet') && _jsx(TwitterPlugin, {}), hasNodes('youtube') && _jsx(YouTubePlugin, {}), hasNodes('figma') && _jsx(FigmaPlugin, {}), _jsx(PostLinkEmbedPlugin, {}), _jsx(BookmarkPlugin, {}), editable && _jsx(CustomOnChangePlugin, { placeholder: placeholder }), editable && _jsx(TemplatePlugin, {}), !editable && _jsx(BlurTextPlugin, {}), hasNodes('pdf') && _jsx(PdfPlugin, {}), hasNodes('file') && _jsx(FilePlugin, {}), hasNodes('horizontalrule') && _jsx(HorizontalRulePlugin, {}), hasNodes('excalidraw') && _jsx(ExcalidrawPlugin, {}), hasNodes('alert') && _jsx(AlertPlugin, {}), hasNodes('pages-kit-component') && _jsx(PagesKitComponentPlugin, {}), _jsx(TabFocusPlugin, {}), onChange && _jsx(OnChangePlugin, { onChange: onChange }), floatingAnchorElem && editable && (_jsxs(_Fragment, { children: [hasNodes('code') && _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem }), hasNodes('link') && _jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem })] })), _jsx(AiImagePlugin, {}), editorRef && _jsx(EditorRefPlugin, { editorRef: editorRef }), children] }));
112
+ return (_jsxs(_Fragment, { children: [prepend, isRichText && editable && showToolbar && _jsx(ToolbarPlugin, {}), hasNodes('image') && hasUploader && _jsx(DragDropPaste, {}), autoFocus && _jsx(AutoFocusPlugin, { defaultSelection: "rootEnd" }), _jsx(ClearEditorPlugin, {}), !!editable && _jsx(ComponentPickerPlugin, {}), !!editable && _jsx(MentionsPlugin, {}), hasNodes('link') && _jsx(AutoEmbedPlugin, {}), _jsx(PasteSlackImagePlugin, {}), _jsx(StyledEditorContent, { ref: onRef, className: cx('be-content', editable && 'editable'), children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: cx('be-editable', 'notranslate') }), placeholder: _jsx(Placeholder, { className: "be-placeholder", children: placeholder }), ErrorBoundary: LexicalErrorBoundary }) }), hasNodes('code', 'code-highlight') && _jsx(CodeHighlightPlugin, {}), hasNodes('image') && hasUploader && _jsx(ImagesPlugin, {}), hasNodes('video') && _jsx(VideoPlugin, {}), hasNodes('link') && _jsx(LinkPlugin, {}), hasNodes('tweet') && _jsx(TwitterPlugin, {}), hasNodes('youtube') && _jsx(YouTubePlugin, {}), hasNodes('figma') && _jsx(FigmaPlugin, {}), _jsx(PostLinkEmbedPlugin, {}), _jsx(BookmarkPlugin, {}), editable && _jsx(CustomOnChangePlugin, { placeholder: placeholder }), editable && _jsx(TemplatePlugin, {}), !editable && _jsx(BlurTextPlugin, {}), hasNodes('pdf') && _jsx(PdfPlugin, {}), hasNodes('file') && _jsx(FilePlugin, {}), hasNodes('horizontalrule') && _jsx(HorizontalRulePlugin, {}), hasNodes('excalidraw') && _jsx(ExcalidrawPlugin, {}), hasNodes('alert') && _jsx(AlertPlugin, {}), hasNodes('pages-kit-component') && _jsx(PagesKitComponentPlugin, {}), _jsx(TabFocusPlugin, {}), onChange && _jsx(OnChangePlugin, { onChange: onChange }), floatingAnchorElem && editable && (_jsxs(_Fragment, { children: [hasNodes('code') && _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem }), hasNodes('link') && _jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem })] })), _jsx(AiImagePlugin, {}), editorRef && _jsx(EditorRefPlugin, { editorRef: editorRef }), children] }));
113
113
  }
114
- return (_jsxs(_Fragment, { children: [prepend, isRichText && editable && showToolbar && _jsx(ToolbarPlugin, {}), isMaxLength && _jsx(MaxLengthPlugin, { maxLength: 30 }), hasNodes('image') && hasUploader && _jsx(DragDropPaste, {}), autoFocus && _jsx(AutoFocusPlugin, { defaultSelection: "rootEnd" }), _jsx(ClearEditorPlugin, {}), !!editable && _jsx(ComponentPickerPlugin, {}), !!editable && _jsx(EmojiPickerPlugin, {}), hasNodes('link') && _jsx(AutoEmbedPlugin, {}), !!editable && _jsx(MentionsPlugin, {}), hasNodes('emoji') && _jsx(EmojisPlugin, {}), hasNodes('hashtag') && _jsx(HashtagPlugin, {}), hasNodes('autolink') && _jsx(AutoLinkPlugin, {}), isRichText ? (_jsxs(_Fragment, { children: [_jsx(PasteSlackImagePlugin, {}), _jsx(HistoryPlugin, { externalHistoryState: historyState }), _jsx(EditorContent, { ref: onRef, className: cx('be-content', editable && 'editable'), children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: cx('be-editable', 'notranslate') }), placeholder: _jsx(Placeholder, { className: "be-placeholder", children: placeholder }), ErrorBoundary: LexicalErrorBoundary }) }), _jsx(MarkdownShortcutPlugin, {}), _jsx(TabIndentationPlugin, {}), hasNodes('code', 'code-highlight') && _jsx(CodeHighlightPlugin, {}), hasNodes('list', 'listitem') && _jsx(ListPlugin, {}), hasNodes('list', 'listitem') && _jsx(CheckListPlugin, {}), hasNodes('list', 'listitem') && _jsx(ListMaxIndentLevelPlugin, { maxDepth: 7 }), hasNodes('table', 'tablerow', 'tablecell') && editable && (_jsx(TablePlugin, { hasCellMerge: true, hasCellBackgroundColor: true, hasHorizontalScroll: true })), hasNodes('table', 'tablerow', 'tablecell') && _jsx(TableCellResizer, {}), hasNodes('image') && hasUploader && _jsx(ImagesPlugin, {}), hasNodes('video') && _jsx(VideoPlugin, {}), hasNodes('link') && _jsx(LinkPlugin, {}), hasNodes('tweet') && _jsx(TwitterPlugin, {}), hasNodes('youtube') && _jsx(YouTubePlugin, {}), hasNodes('figma') && _jsx(FigmaPlugin, {}), _jsx(BilibiliPlugin, {}), _jsx(BlockletEmbedPlugin, {}), _jsx(PostLinkEmbedPlugin, {}), _jsx(BookmarkPlugin, {}), _jsx(AidePlugin, {}), editable && _jsx(CustomOnChangePlugin, { placeholder: placeholder }), editable && _jsx(TemplatePlugin, {}), !editable && _jsx(BlurTextPlugin, {}), hasNodes('pdf') && _jsx(PdfPlugin, {}), hasNodes('file') && _jsx(FilePlugin, {}), hasNodes('link') && _jsx(ClickableLinkPlugin, {}), hasNodes('horizontalrule') && _jsx(HorizontalRulePlugin, {}), hasNodes('excalidraw') && _jsx(ExcalidrawPlugin, {}), hasNodes('alert') && _jsx(AlertPlugin, {}), hasNodes('pages-kit-component') && _jsx(PagesKitComponentPlugin, {}), _jsx(TabFocusPlugin, {}), hasNodes('collapsible-container', 'collapsible-content', 'collapsible-title') && _jsx(CollapsiblePlugin, {}), onChange && _jsx(OnChangePlugin, { onChange: onChange }), floatingAnchorElem && editable && (_jsxs(_Fragment, { children: [_jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), hasNodes('code') && _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem }), hasNodes('link') && _jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem }), hasNodes('table') && _jsx(TableCellActionMenuPlugin, { anchorElem: floatingAnchorElem, cellMerge: true }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem })] })), enableHeadingsIdPlugin && _jsx(HeadingsIdPlugin, {})] })) : (_jsxs(_Fragment, { children: [_jsx(PlainTextPlugin, { contentEditable: _jsx(ContentEditable, {}), placeholder: _jsx(Placeholder, { children: "placeholder" }), ErrorBoundary: LexicalErrorBoundary }), _jsx(HistoryPlugin, { externalHistoryState: historyState })] })), (isCharLimit || isCharLimitUtf8) && (_jsx(CharacterLimitPlugin, { charset: isCharLimit ? 'UTF-16' : 'UTF-8', maxLength: 5 })), _jsx("div", { children: showTableOfContents && _jsx(TableOfContentsPlugin, {}) }), _jsx(MarkdownHeadTextPlugin, {}), _jsx(AiImagePlugin, {}), _jsx(EditorHolderPlugin, {}), editorRef && _jsx(EditorRefPlugin, { editorRef: editorRef }), onReady && _jsx(EditorReadyPlugin, { onReady: onReady }), children] }));
114
+ return (_jsxs(_Fragment, { children: [prepend, isRichText && editable && showToolbar && _jsx(ToolbarPlugin, {}), isMaxLength && _jsx(MaxLengthPlugin, { maxLength: 30 }), hasNodes('image') && hasUploader && _jsx(DragDropPaste, {}), autoFocus && _jsx(AutoFocusPlugin, { defaultSelection: "rootEnd" }), _jsx(ClearEditorPlugin, {}), !!editable && _jsx(ComponentPickerPlugin, {}), !!editable && _jsx(EmojiPickerPlugin, {}), hasNodes('link') && _jsx(AutoEmbedPlugin, {}), !!editable && _jsx(MentionsPlugin, {}), hasNodes('emoji') && _jsx(EmojisPlugin, {}), hasNodes('hashtag') && _jsx(HashtagPlugin, {}), hasNodes('autolink') && _jsx(AutoLinkPlugin, {}), isRichText ? (_jsxs(_Fragment, { children: [_jsx(PasteSlackImagePlugin, {}), _jsx(HistoryPlugin, { externalHistoryState: historyState }), _jsx(StyledEditorContent, { ref: onRef, className: cx('be-content', editable && 'editable'), children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: cx('be-editable', 'notranslate') }), placeholder: _jsx(Placeholder, { className: "be-placeholder", children: placeholder }), ErrorBoundary: LexicalErrorBoundary }) }), _jsx(MarkdownShortcutPlugin, {}), _jsx(TabIndentationPlugin, {}), hasNodes('code', 'code-highlight') && _jsx(CodeHighlightPlugin, {}), hasNodes('list', 'listitem') && _jsx(ListPlugin, {}), hasNodes('list', 'listitem') && _jsx(CheckListPlugin, {}), hasNodes('list', 'listitem') && _jsx(ListMaxIndentLevelPlugin, { maxDepth: 7 }), hasNodes('table', 'tablerow', 'tablecell') && editable && (_jsx(TablePlugin, { hasCellMerge: true, hasCellBackgroundColor: true, hasHorizontalScroll: true })), hasNodes('table', 'tablerow', 'tablecell') && _jsx(TableCellResizer, {}), hasNodes('image') && hasUploader && _jsx(ImagesPlugin, {}), hasNodes('video') && _jsx(VideoPlugin, {}), hasNodes('link') && _jsx(LinkPlugin, {}), hasNodes('tweet') && _jsx(TwitterPlugin, {}), hasNodes('youtube') && _jsx(YouTubePlugin, {}), hasNodes('figma') && _jsx(FigmaPlugin, {}), _jsx(BilibiliPlugin, {}), _jsx(BlockletEmbedPlugin, {}), _jsx(PostLinkEmbedPlugin, {}), _jsx(BookmarkPlugin, {}), _jsx(AidePlugin, {}), editable && _jsx(CustomOnChangePlugin, { placeholder: placeholder }), editable && _jsx(TemplatePlugin, {}), !editable && _jsx(BlurTextPlugin, {}), hasNodes('pdf') && _jsx(PdfPlugin, {}), hasNodes('file') && _jsx(FilePlugin, {}), hasNodes('link') && _jsx(ClickableLinkPlugin, {}), hasNodes('horizontalrule') && _jsx(HorizontalRulePlugin, {}), hasNodes('excalidraw') && _jsx(ExcalidrawPlugin, {}), hasNodes('alert') && _jsx(AlertPlugin, {}), hasNodes('pages-kit-component') && _jsx(PagesKitComponentPlugin, {}), _jsx(TabFocusPlugin, {}), hasNodes('collapsible-container', 'collapsible-content', 'collapsible-title') && _jsx(CollapsiblePlugin, {}), onChange && _jsx(OnChangePlugin, { onChange: onChange }), floatingAnchorElem && editable && (_jsxs(_Fragment, { children: [_jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), hasNodes('code') && _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem }), hasNodes('link') && _jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem }), hasNodes('table') && _jsx(TableCellActionMenuPlugin, { anchorElem: floatingAnchorElem, cellMerge: true }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem })] })), enableHeadingsIdPlugin && _jsx(HeadingsIdPlugin, {})] })) : (_jsxs(_Fragment, { children: [_jsx(PlainTextPlugin, { contentEditable: _jsx(ContentEditable, {}), placeholder: _jsx(Placeholder, { children: "placeholder" }), ErrorBoundary: LexicalErrorBoundary }), _jsx(HistoryPlugin, { externalHistoryState: historyState })] })), (isCharLimit || isCharLimitUtf8) && (_jsx(CharacterLimitPlugin, { charset: isCharLimit ? 'UTF-16' : 'UTF-8', maxLength: 5 })), _jsx("div", { children: showTableOfContents && _jsx(TableOfContentsPlugin, {}) }), _jsx(MarkdownHeadTextPlugin, {}), _jsx(AiImagePlugin, {}), _jsx(EditorHolderPlugin, {}), editorRef && _jsx(EditorRefPlugin, { editorRef: editorRef }), onReady && _jsx(EditorReadyPlugin, { onReady: onReady }), children] }));
115
115
  }
116
- const EditorContent = styled(Box) `
117
- position: relative;
118
- color: ${({ theme }) => alpha(theme.palette.text.primary, 0.8)};
119
- .be-editable {
120
- transition: padding-bottom 0.2s;
121
- code {
122
- white-space: pre-wrap;
123
- }
124
- }
125
-
126
- &.editable {
127
- > .be-editable {
128
- padding: 8px 24px;
129
- }
130
- }
131
-
132
- > .be-editable {
133
- hr {
134
- height: 0;
135
- border: none;
136
- border-top: 1px solid ${({ theme }) => theme.palette.divider};
137
- margin: 1em 0;
138
- cursor: pointer;
139
- }
140
-
141
- hr:after {
142
- content: '';
143
- display: block;
144
- height: 2px;
145
- background-color: #ccc;
146
- line-height: 2px;
147
- }
148
-
149
- hr.selected {
150
- outline: 2px solid rgb(60, 132, 244);
151
- user-select: none;
152
- }
153
-
154
- // 增大最外层 list item 的 marginLeft, https://github.com/blocklet/discuss-kit/issues/2123
155
- > ol > li,
156
- > ul > li {
157
- margin-left: 32px;
158
- }
159
- }
160
- `;
@@ -5,7 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
-
9
8
  .editor-dev-button {
10
9
  position: relative;
11
10
  display: block;
@@ -1,6 +1,5 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cx } from '@emotion/css';
3
- import styled from '@emotion/styled';
4
3
  import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin';
5
4
  import { CheckListPlugin } from '@lexical/react/LexicalCheckListPlugin';
6
5
  import { ClearEditorPlugin } from '@lexical/react/LexicalClearEditorPlugin';
@@ -41,6 +40,7 @@ import { BlurTextPlugin } from '../../ext/BlurTextPlugin';
41
40
  import ToolbarPlugin from './plugins/ToolbarPlugin';
42
41
  import { TRANSFORMERS, IMAGE } from './transformers';
43
42
  import { MediaUrlFixerPlugin } from './plugins/MediaUrlFixerPlugin';
43
+ import { StyledEditorContent } from '../styled-editor-content';
44
44
  export default function Editor({ children, placeholder, onChange, autoFocus = true, showToolbar = true, editorRef, onReady, enableHeadingsIdPlugin, mediaUrlPrefix, }) {
45
45
  const [editor] = useLexicalComposerContext();
46
46
  const [editable, setEditable] = useState(false);
@@ -73,47 +73,5 @@ export default function Editor({ children, placeholder, onChange, autoFocus = tr
73
73
  });
74
74
  }
75
75
  };
76
- return (_jsxs(_Fragment, { children: [editable && showToolbar && _jsx(ToolbarPlugin, {}), hasNodes('image') && hasUploader && _jsx(DragDropPaste, {}), autoFocus && _jsx(AutoFocusPlugin, { defaultSelection: "rootEnd" }), _jsx(ClearEditorPlugin, {}), hasNodes('autolink') && _jsx(AutoLinkPlugin, {}), _jsx(EditorContent, { ref: onRef, className: cx('be-content', editable && 'editable'), children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: cx('be-editable', 'notranslate') }), placeholder: _jsx(Placeholder, { className: "be-placeholder", children: placeholder }), ErrorBoundary: LexicalErrorBoundary }) }), _jsx(MarkdownShortcutPlugin, {}), _jsx(TabIndentationPlugin, {}), hasNodes('code', 'code-highlight') && _jsx(CodeHighlightPlugin, {}), hasNodes('list', 'listitem') && _jsx(ListPlugin, {}), hasNodes('list', 'listitem') && _jsx(CheckListPlugin, {}), hasNodes('list', 'listitem') && _jsx(ListMaxIndentLevelPlugin, { maxDepth: 7 }), hasNodes('image') && hasUploader && _jsx(ImagesPlugin, {}), hasNodes('link') && _jsx(LinkPlugin, {}), !editable && _jsx(BlurTextPlugin, {}), hasNodes('link') && _jsx(ClickableLinkPlugin, {}), hasNodes('horizontalrule') && _jsx(HorizontalRulePlugin, {}), _jsx(TabFocusPlugin, {}), onChange && _jsx(OnChangePlugin, { onChange: handleOnChange }), floatingAnchorElem && editable && (_jsxs(_Fragment, { children: [_jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), hasNodes('code') && _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem }), hasNodes('link') && _jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem })] })), enableHeadingsIdPlugin && _jsx(HeadingsIdPlugin, {}), mediaUrlPrefix && _jsx(MediaUrlFixerPlugin, { mediaUrlPrefix: mediaUrlPrefix, transformers: [IMAGE] }), _jsx(SelectBlockPlugin, {}), _jsx(RemoveListPlugin, {}), _jsx(MarkdownHeadTextPlugin, {}), editorRef && _jsx(EditorRefPlugin, { editorRef: editorRef }), onReady && _jsx(EditorReadyPlugin, { onReady: onReady }), hasNodes('table', 'tablerow', 'tablecell') && editable && _jsx(TablePlugin, {}), children] }));
76
+ return (_jsxs(_Fragment, { children: [editable && showToolbar && _jsx(ToolbarPlugin, {}), hasNodes('image') && hasUploader && _jsx(DragDropPaste, {}), autoFocus && _jsx(AutoFocusPlugin, { defaultSelection: "rootEnd" }), _jsx(ClearEditorPlugin, {}), hasNodes('autolink') && _jsx(AutoLinkPlugin, {}), _jsx(StyledEditorContent, { ref: onRef, className: cx('be-content', editable && 'editable'), children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: cx('be-editable', 'notranslate') }), placeholder: _jsx(Placeholder, { className: "be-placeholder", children: placeholder }), ErrorBoundary: LexicalErrorBoundary }) }), _jsx(MarkdownShortcutPlugin, {}), _jsx(TabIndentationPlugin, {}), hasNodes('code', 'code-highlight') && _jsx(CodeHighlightPlugin, {}), hasNodes('list', 'listitem') && _jsx(ListPlugin, {}), hasNodes('list', 'listitem') && _jsx(CheckListPlugin, {}), hasNodes('list', 'listitem') && _jsx(ListMaxIndentLevelPlugin, { maxDepth: 7 }), hasNodes('image') && hasUploader && _jsx(ImagesPlugin, {}), hasNodes('link') && _jsx(LinkPlugin, {}), !editable && _jsx(BlurTextPlugin, {}), hasNodes('link') && _jsx(ClickableLinkPlugin, {}), hasNodes('horizontalrule') && _jsx(HorizontalRulePlugin, {}), _jsx(TabFocusPlugin, {}), onChange && _jsx(OnChangePlugin, { onChange: handleOnChange }), floatingAnchorElem && editable && (_jsxs(_Fragment, { children: [_jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), hasNodes('code') && _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem }), hasNodes('link') && _jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem })] })), enableHeadingsIdPlugin && _jsx(HeadingsIdPlugin, {}), mediaUrlPrefix && _jsx(MediaUrlFixerPlugin, { mediaUrlPrefix: mediaUrlPrefix, transformers: [IMAGE] }), _jsx(SelectBlockPlugin, {}), _jsx(RemoveListPlugin, {}), _jsx(MarkdownHeadTextPlugin, {}), editorRef && _jsx(EditorRefPlugin, { editorRef: editorRef }), onReady && _jsx(EditorReadyPlugin, { onReady: onReady }), hasNodes('table', 'tablerow', 'tablecell') && editable && _jsx(TablePlugin, {}), children] }));
77
77
  }
78
- const EditorContent = styled.div `
79
- position: relative;
80
- .be-editable {
81
- code {
82
- white-space: pre-wrap;
83
- }
84
- }
85
-
86
- &.editable {
87
- > .be-editable {
88
- padding: 8px 24px;
89
- }
90
- }
91
-
92
- > .be-editable {
93
- hr {
94
- padding: 2px 2px;
95
- border: none;
96
- margin: 1em 0;
97
- cursor: pointer;
98
- }
99
-
100
- hr:after {
101
- content: '';
102
- display: block;
103
- height: 2px;
104
- background-color: #ccc;
105
- line-height: 2px;
106
- }
107
-
108
- hr.selected {
109
- outline: 2px solid rgb(60, 132, 244);
110
- user-select: none;
111
- }
112
-
113
- // 增大最外层 list item 的 marginLeft, https://github.com/blocklet/discuss-kit/issues/2123
114
- > ol > li,
115
- > ul > li {
116
- margin-left: 32px;
117
- }
118
- }
119
- `;
@@ -8,8 +8,6 @@ import { useCallback, useEffect, useRef, useState } from 'react';
8
8
  import { createPortal } from 'react-dom';
9
9
  import { Box } from '@mui/material';
10
10
  import useModal from '../../hooks/useModal';
11
- import ColorPicker from '../../ui/ColorPicker';
12
- import DropDown, { DropDownItem } from '../../ui/DropDown';
13
11
  function computeSelectionCount(selection) {
14
12
  const selectionShape = selection.getShape();
15
13
  return {
@@ -331,13 +329,7 @@ function TableActionMenu({ onClose, tableCellNode: _tableCellNode, setIsMenuOpen
331
329
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions
332
330
  _jsxs("div", { className: "dropdown", ref: dropDownRef, onClick: (e) => {
333
331
  e.stopPropagation();
334
- }, children: [mergeCellButton, _jsx("button", { type: "button", className: "item", onClick: () => showColorPickerModal('Cell background color', () => (_jsx(ColorPicker, { color: backgroundColor, onChange: handleCellBackgroundColor, buttonClassName: "" }))), "data-test-id": "table-background-color", children: _jsx("span", { className: "text", children: "Background color" }) }), _jsx("button", { type: "button", className: "item", onClick: () => toggleRowStriping(), "data-test-id": "table-row-striping", children: _jsx("span", { className: "text", children: "Toggle Row Striping" }) }), _jsxs(DropDown, { buttonLabel: "Vertical Align", buttonClassName: "item", buttonAriaLabel: "Formatting options for vertical alignment", children: [_jsx(DropDownItem, { onClick: () => {
335
- formatVerticalAlign('top');
336
- }, className: "item wide", children: _jsxs("div", { className: "icon-text-container", children: [_jsx("i", { className: "icon vertical-top" }), _jsx("span", { className: "text", children: "Top Align" })] }) }), _jsx(DropDownItem, { onClick: () => {
337
- formatVerticalAlign('middle');
338
- }, className: "item wide", children: _jsxs("div", { className: "icon-text-container", children: [_jsx("i", { className: "icon vertical-middle" }), _jsx("span", { className: "text", children: "Middle Align" })] }) }), _jsx(DropDownItem, { onClick: () => {
339
- formatVerticalAlign('bottom');
340
- }, className: "item wide", children: _jsxs("div", { className: "icon-text-container", children: [_jsx("i", { className: "icon vertical-bottom" }), _jsx("span", { className: "text", children: "Bottom Align" })] }) })] }), _jsx("button", { type: "button", className: "item", onClick: () => toggleFirstRowFreeze(), "data-test-id": "table-freeze-first-row", children: _jsx("span", { className: "text", children: "Toggle First Row Freeze" }) }), _jsx("button", { type: "button", className: "item", onClick: () => toggleFirstColumnFreeze(), "data-test-id": "table-freeze-first-column", children: _jsx("span", { className: "text", children: "Toggle First Column Freeze" }) }), _jsx("hr", {}), _jsx("button", { type: "button", className: "item", onClick: () => insertTableRowAtSelection(false), "data-test-id": "table-insert-row-above", children: _jsxs("span", { className: "text", children: ["Insert ", selectionCounts.rows === 1 ? 'row' : `${selectionCounts.rows} rows`, " above"] }) }), _jsx("button", { type: "button", className: "item", onClick: () => insertTableRowAtSelection(true), "data-test-id": "table-insert-row-below", children: _jsxs("span", { className: "text", children: ["Insert ", selectionCounts.rows === 1 ? 'row' : `${selectionCounts.rows} rows`, " below"] }) }), _jsx("hr", {}), _jsx("button", { type: "button", className: "item", onClick: () => insertTableColumnAtSelection(false), "data-test-id": "table-insert-column-before", children: _jsxs("span", { className: "text", children: ["Insert ", selectionCounts.columns === 1 ? 'column' : `${selectionCounts.columns} columns`, " left"] }) }), _jsx("button", { type: "button", className: "item", onClick: () => insertTableColumnAtSelection(true), "data-test-id": "table-insert-column-after", children: _jsxs("span", { className: "text", children: ["Insert ", selectionCounts.columns === 1 ? 'column' : `${selectionCounts.columns} columns`, " right"] }) }), _jsx("hr", {}), _jsx("button", { type: "button", className: "item", onClick: () => deleteTableColumnAtSelection(), "data-test-id": "table-delete-columns", children: _jsx("span", { className: "text", children: "Delete column" }) }), _jsx("button", { type: "button", className: "item", onClick: () => deleteTableRowAtSelection(), "data-test-id": "table-delete-rows", children: _jsx("span", { className: "text", children: "Delete row" }) }), _jsx("button", { type: "button", className: "item", onClick: () => deleteTableAtSelection(), "data-test-id": "table-delete", children: _jsx("span", { className: "text", children: "Delete table" }) }), _jsx("hr", {}), _jsx("button", { type: "button", className: "item", onClick: () => toggleTableRowIsHeader(), "data-test-id": "table-row-header", children: _jsxs("span", { className: "text", children: [(tableCellNode.__headerState & TableCellHeaderStates.ROW) === TableCellHeaderStates.ROW ? 'Remove' : 'Add', ' ', "row header"] }) }), _jsx("button", { type: "button", className: "item", onClick: () => toggleTableColumnIsHeader(), "data-test-id": "table-column-header", children: _jsxs("span", { className: "text", children: [(tableCellNode.__headerState & TableCellHeaderStates.COLUMN) === TableCellHeaderStates.COLUMN
332
+ }, children: [mergeCellButton, _jsx("button", { type: "button", className: "item", onClick: () => toggleRowStriping(), "data-test-id": "table-row-striping", children: _jsx("span", { className: "text", children: "Toggle Row Striping" }) }), _jsx("button", { type: "button", className: "item", onClick: () => toggleFirstRowFreeze(), "data-test-id": "table-freeze-first-row", children: _jsx("span", { className: "text", children: "Toggle First Row Freeze" }) }), _jsx("button", { type: "button", className: "item", onClick: () => toggleFirstColumnFreeze(), "data-test-id": "table-freeze-first-column", children: _jsx("span", { className: "text", children: "Toggle First Column Freeze" }) }), _jsx("hr", {}), _jsx("button", { type: "button", className: "item", onClick: () => insertTableRowAtSelection(false), "data-test-id": "table-insert-row-above", children: _jsxs("span", { className: "text", children: ["Insert ", selectionCounts.rows === 1 ? 'row' : `${selectionCounts.rows} rows`, " above"] }) }), _jsx("button", { type: "button", className: "item", onClick: () => insertTableRowAtSelection(true), "data-test-id": "table-insert-row-below", children: _jsxs("span", { className: "text", children: ["Insert ", selectionCounts.rows === 1 ? 'row' : `${selectionCounts.rows} rows`, " below"] }) }), _jsx("hr", {}), _jsx("button", { type: "button", className: "item", onClick: () => insertTableColumnAtSelection(false), "data-test-id": "table-insert-column-before", children: _jsxs("span", { className: "text", children: ["Insert ", selectionCounts.columns === 1 ? 'column' : `${selectionCounts.columns} columns`, " left"] }) }), _jsx("button", { type: "button", className: "item", onClick: () => insertTableColumnAtSelection(true), "data-test-id": "table-insert-column-after", children: _jsxs("span", { className: "text", children: ["Insert ", selectionCounts.columns === 1 ? 'column' : `${selectionCounts.columns} columns`, " right"] }) }), _jsx("hr", {}), _jsx("button", { type: "button", className: "item", onClick: () => deleteTableColumnAtSelection(), "data-test-id": "table-delete-columns", children: _jsx("span", { className: "text", children: "Delete column" }) }), _jsx("button", { type: "button", className: "item", onClick: () => deleteTableRowAtSelection(), "data-test-id": "table-delete-rows", children: _jsx("span", { className: "text", children: "Delete row" }) }), _jsx("button", { type: "button", className: "item", onClick: () => deleteTableAtSelection(), "data-test-id": "table-delete", children: _jsx("span", { className: "text", children: "Delete table" }) }), _jsx("hr", {}), _jsx("button", { type: "button", className: "item", onClick: () => toggleTableRowIsHeader(), "data-test-id": "table-row-header", children: _jsxs("span", { className: "text", children: [(tableCellNode.__headerState & TableCellHeaderStates.ROW) === TableCellHeaderStates.ROW ? 'Remove' : 'Add', ' ', "row header"] }) }), _jsx("button", { type: "button", className: "item", onClick: () => toggleTableColumnIsHeader(), "data-test-id": "table-column-header", children: _jsxs("span", { className: "text", children: [(tableCellNode.__headerState & TableCellHeaderStates.COLUMN) === TableCellHeaderStates.COLUMN
341
333
  ? 'Remove'
342
334
  : 'Add', ' ', "column header"] }) })] }), document.body);
343
335
  }
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { BoxProps } from '@mui/material';
3
+ export declare const StyledEditorContent: import("react").ForwardRefExoticComponent<Omit<BoxProps<"div", {}>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,90 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, alpha, styled, GlobalStyles, useTheme } from '@mui/material';
3
+ import { forwardRef } from 'react';
4
+ const StyledEditorWrapper = styled(Box) `
5
+ position: relative;
6
+ color: ${({ theme }) => alpha(theme.palette.text.primary, 0.8)};
7
+ .be-editable {
8
+ transition: padding-bottom 0.2s;
9
+ code {
10
+ white-space: pre-wrap;
11
+ }
12
+ }
13
+
14
+ &.editable {
15
+ > .be-editable {
16
+ padding: 8px 24px;
17
+ }
18
+ }
19
+
20
+ > .be-editable {
21
+ hr {
22
+ height: 0;
23
+ border: none;
24
+ border-top: 1px solid ${({ theme }) => theme.palette.divider};
25
+ margin: 1em 0;
26
+ cursor: pointer;
27
+ }
28
+
29
+ hr:after {
30
+ content: '';
31
+ display: block;
32
+ height: 2px;
33
+ background-color: #ccc;
34
+ line-height: 2px;
35
+ }
36
+
37
+ hr.selected {
38
+ outline: 2px solid rgb(60, 132, 244);
39
+ user-select: none;
40
+ }
41
+
42
+ // 增大最外层 list item 的 marginLeft, https://github.com/blocklet/discuss-kit/issues/2123
43
+ > ol > li,
44
+ > ul > li {
45
+ margin-left: 32px;
46
+ }
47
+ }
48
+
49
+ /* fix: 自定义样式引起的 cell 高度偏大的问题 */
50
+ .PlaygroundEditorTheme__tableCell p {
51
+ margin: 0;
52
+ }
53
+ table th,
54
+ .PlaygroundEditorTheme__tableRowStriping tr:nth-child(even) {
55
+ background-color: ${({ theme }) => theme.palette.grey[100]} !important;
56
+ }
57
+ `;
58
+ export const StyledEditorContent = forwardRef(({ children, ...rest }, ref) => {
59
+ return (_jsxs(StyledEditorWrapper, { ref: ref, ...rest, children: [_jsx(EditorGlobalStyle, {}), children] }));
60
+ });
61
+ function EditorGlobalStyle() {
62
+ const theme = useTheme();
63
+ return (_jsx(GlobalStyles, { styles: {
64
+ '.dropdown': {
65
+ border: `1px solid ${theme.palette.divider}`,
66
+ backgroundColor: theme.palette.background.default,
67
+ '.item': {
68
+ display: 'flex',
69
+ alignItems: 'center',
70
+ gap: 1,
71
+ /* fix: safari dropdown menu item 右侧溢出问题 */
72
+ width: '-webkit-fill-available',
73
+ color: theme.palette.text.primary,
74
+ backgroundColor: theme.palette.background.default,
75
+ '.iconify': {
76
+ flexShrink: 0,
77
+ fontSize: '1.4em',
78
+ },
79
+ '&:hover': {
80
+ backgroundColor: theme.palette.action.hover,
81
+ },
82
+ },
83
+ hr: {
84
+ height: 0,
85
+ border: 'none',
86
+ borderTop: `1px solid ${theme.palette.divider}`,
87
+ },
88
+ },
89
+ } }));
90
+ }
@@ -12,7 +12,7 @@ const createCustomTheme = (theme) => {
12
12
  const paragraph = css(
13
13
  // use default theme's paragraph style
14
14
  defaultTheme.paragraph,
15
- // p wrapper table style
15
+ // 兼容旧 table 水平滚动条问题 (与 useResponsiveTable 配合使用)
16
16
  `
17
17
  &:has(table) {
18
18
  overflow-x: auto;
@@ -289,11 +289,6 @@ const createCustomTheme = (theme) => {
289
289
  },
290
290
  image: `${defaultTheme.image} ${image}`,
291
291
  code,
292
- ...(palette.mode === 'dark' && {
293
- tableCellHeader: css(defaultTheme.tableCellHeader, `
294
- background-color: ${palette.grey[100]};
295
- `),
296
- }),
297
292
  };
298
293
  return customTheme;
299
294
  };
@@ -6,6 +6,7 @@
6
6
  *
7
7
  */
8
8
  import { css } from '@emotion/css';
9
+ import { tableClasses } from './table';
9
10
  const ltr = css `
10
11
  text-align: left;
11
12
  `;
@@ -139,174 +140,6 @@ const code = css `
139
140
  min-width: 25px;
140
141
  }
141
142
  `;
142
- const table = css `
143
- border-collapse: collapse;
144
- border-spacing: 0;
145
- table-layout: fixed;
146
- width: fit-content;
147
-
148
- p {
149
- margin: 0;
150
- }
151
- `;
152
- const tableSelection = css `
153
- *::selection {
154
- background-color: transparent;
155
- }
156
- `;
157
- const tableSelected = css `
158
- outline: 2px solid rgb(60, 132, 244);
159
- `;
160
- const tableScrollableWrapper = css ``;
161
- const tableCell = css `
162
- border: 1px solid #bbb;
163
- min-width: 75px;
164
- vertical-align: top;
165
- text-align: start;
166
- padding: 6px 8px;
167
- position: relative;
168
- outline: none;
169
- `;
170
- const tableCellSortedIndicator = css `
171
- display: block;
172
- opacity: 0.5;
173
- position: absolute;
174
- bottom: 0;
175
- left: 0;
176
- width: 100%;
177
- height: 4px;
178
- background-color: #999;
179
- `;
180
- const tableCellResizer = css `
181
- position: absolute;
182
- right: -4px;
183
- height: 100%;
184
- width: 8px;
185
- cursor: ew-resize;
186
- z-index: 10;
187
- top: 0;
188
- `;
189
- const tableCellHeader = css `
190
- background-color: #f2f3f5;
191
- text-align: start;
192
- `;
193
- const tableCellSelected = css `
194
- background-color: #c9dbf0;
195
- `;
196
- const tableCellPrimarySelected = css `
197
- border: 2px solid rgb(60, 132, 244);
198
- display: block;
199
- height: calc(100% - 2px);
200
- position: absolute;
201
- width: calc(100% - 2px);
202
- left: -1px;
203
- top: -1px;
204
- z-index: 2;
205
- `;
206
- const tableCellEditing = css `
207
- box-shadow: 0 0 5px rgba(0, 0, 0, 0.4);
208
- border-radius: 3px;
209
- `;
210
- const tableAddColumns = css `
211
- position: absolute;
212
- top: 0;
213
- width: 20px;
214
- background-color: #eee;
215
- height: 100%;
216
- right: -25px;
217
- animation: table-controls 0.2s ease;
218
- border: 0;
219
- cursor: pointer;
220
-
221
- @keyframes table-controls {
222
- 0% {
223
- opacity: 0;
224
- }
225
- 100% {
226
- opacity: 1;
227
- }
228
- }
229
-
230
- &:after {
231
- background-image: url(../images/icons/plus.svg);
232
- background-size: contain;
233
- background-position: center;
234
- background-repeat: no-repeat;
235
- display: block;
236
- content: ' ';
237
- position: absolute;
238
- top: 0;
239
- left: 0;
240
- width: 100%;
241
- height: 100%;
242
- opacity: 0.4;
243
- }
244
-
245
- &:hover {
246
- background-color: #c9dbf0;
247
- }
248
- `;
249
- const tableAddRows = css `
250
- position: absolute;
251
- bottom: -25px;
252
- width: calc(100% - 25px);
253
- background-color: #eee;
254
- height: 20px;
255
- left: 0;
256
- animation: table-controls 0.2s ease;
257
- border: 0;
258
- cursor: pointer;
259
-
260
- &:after {
261
- background-image: url(../images/icons/plus.svg);
262
- background-size: contain;
263
- background-position: center;
264
- background-repeat: no-repeat;
265
- display: block;
266
- content: ' ';
267
- position: absolute;
268
- top: 0;
269
- left: 0;
270
- width: 100%;
271
- height: 100%;
272
- opacity: 0.4;
273
- }
274
-
275
- :hover {
276
- background-color: #c9dbf0;
277
- }
278
- `;
279
- const tableResizeRuler = css `
280
- display: block;
281
- position: absolute;
282
- width: 1px;
283
- background-color: rgb(60, 132, 244);
284
- height: 100%;
285
- top: 0;
286
- `;
287
- const tableCellActionButtonContainer = css `
288
- display: block;
289
- right: 5px;
290
- top: 6px;
291
- position: absolute;
292
- z-index: 4;
293
- width: 20px;
294
- height: 20px;
295
- `;
296
- const tableCellActionButton = css `
297
- background-color: #eee;
298
- display: block;
299
- border: 0;
300
- border-radius: 20px;
301
- width: 20px;
302
- height: 20px;
303
- color: #222;
304
- cursor: pointer;
305
-
306
- :hover {
307
- background-color: #ddd;
308
- }
309
- `;
310
143
  const characterLimit = css `
311
144
  display: inline;
312
145
  background-color: #ffbbbb !important;
@@ -662,22 +495,7 @@ const defaultTheme = {
662
495
  hashtag,
663
496
  link,
664
497
  code,
665
- table,
666
- tableSelection,
667
- tableAddColumns,
668
- tableAddRows,
669
- tableCell,
670
- tableCellActionButton,
671
- tableCellActionButtonContainer,
672
- tableCellEditing,
673
- tableCellHeader,
674
- tableCellPrimarySelected,
675
- tableCellResizer,
676
- tableCellSelected,
677
- tableCellSortedIndicator,
678
- tableResizeRuler,
679
- tableSelected,
680
- tableScrollableWrapper,
498
+ ...tableClasses,
681
499
  characterLimit,
682
500
  list: {
683
501
  listitem: listItem,
@@ -0,0 +1,3 @@
1
+ import { EditorThemeClasses } from 'lexical';
2
+ import './table.css';
3
+ export declare const tableClasses: EditorThemeClasses;
@@ -0,0 +1,20 @@
1
+ import './table.css';
2
+ export const tableClasses = {
3
+ table: 'PlaygroundEditorTheme__table',
4
+ tableAddColumns: 'PlaygroundEditorTheme__tableAddColumns',
5
+ tableAddRows: 'PlaygroundEditorTheme__tableAddRows',
6
+ center: 'PlaygroundEditorTheme__tableAlignmentCenter',
7
+ right: 'PlaygroundEditorTheme__tableAlignmentRight',
8
+ tableCell: 'PlaygroundEditorTheme__tableCell',
9
+ tableCellActionButton: 'PlaygroundEditorTheme__tableCellActionButton',
10
+ tableCellActionButtonContainer: 'PlaygroundEditorTheme__tableCellActionButtonContainer',
11
+ tableCellHeader: 'PlaygroundEditorTheme__tableCellHeader',
12
+ tableCellResizer: 'PlaygroundEditorTheme__tableCellResizer',
13
+ tableCellSelected: 'PlaygroundEditorTheme__tableCellSelected',
14
+ tableFrozenColumn: 'PlaygroundEditorTheme__tableFrozenColumn',
15
+ tableFrozenRow: 'PlaygroundEditorTheme__tableFrozenRow',
16
+ tableRowStriping: 'PlaygroundEditorTheme__tableRowStriping',
17
+ tableScrollableWrapper: 'PlaygroundEditorTheme__tableScrollableWrapper',
18
+ tableSelected: 'PlaygroundEditorTheme__tableSelected',
19
+ tableSelection: 'PlaygroundEditorTheme__tableSelection',
20
+ };
@@ -0,0 +1,214 @@
1
+ .PlaygroundEditorTheme__tableScrollableWrapper {
2
+ overflow-x: auto;
3
+ margin: 0px 25px 30px 0px;
4
+ }
5
+ .PlaygroundEditorTheme__tableScrollableWrapper > .PlaygroundEditorTheme__table {
6
+ /* Remove the table's vertical margin and put it on the wrapper */
7
+ margin-top: 0;
8
+ margin-bottom: 0;
9
+ }
10
+ .PlaygroundEditorTheme__tableAlignmentCenter {
11
+ margin-left: auto;
12
+ margin-right: auto;
13
+ }
14
+ .PlaygroundEditorTheme__tableAlignmentRight {
15
+ margin-left: auto;
16
+ }
17
+ .PlaygroundEditorTheme__table {
18
+ border-collapse: collapse;
19
+ border-spacing: 0;
20
+ overflow-y: scroll;
21
+ overflow-x: scroll;
22
+ table-layout: fixed;
23
+ width: fit-content;
24
+ margin-top: 25px;
25
+ margin-bottom: 30px;
26
+ }
27
+ .PlaygroundEditorTheme__tableScrollableWrapper.PlaygroundEditorTheme__tableFrozenRow {
28
+ /* position:sticky needs overflow:clip or visible
29
+ https://github.com/w3c/csswg-drafts/issues/865#issuecomment-350585274 */
30
+ overflow-x: clip;
31
+ }
32
+ .PlaygroundEditorTheme__tableFrozenRow tr:nth-of-type(1) > td {
33
+ overflow: clip;
34
+ background-color: #ffffff;
35
+ position: sticky;
36
+ z-index: 2;
37
+ top: 44px;
38
+ }
39
+ .PlaygroundEditorTheme__tableFrozenRow tr:nth-of-type(1) > th {
40
+ overflow: clip;
41
+ background-color: #f2f3f5;
42
+ position: sticky;
43
+ z-index: 2;
44
+ top: 44px;
45
+ }
46
+ .PlaygroundEditorTheme__tableFrozenRow tr:nth-of-type(1) > th:after,
47
+ .PlaygroundEditorTheme__tableFrozenRow tr:nth-of-type(1) > td:after {
48
+ content: '';
49
+ position: absolute;
50
+ left: 0;
51
+ bottom: 0;
52
+ width: 100%;
53
+ border-bottom: 1px solid #bbb;
54
+ }
55
+ .PlaygroundEditorTheme__tableFrozenColumn tr > td:first-child {
56
+ background-color: #ffffff;
57
+ position: sticky;
58
+ z-index: 2;
59
+ left: 0;
60
+ }
61
+ .PlaygroundEditorTheme__tableFrozenColumn tr > th:first-child {
62
+ background-color: #f2f3f5;
63
+ position: sticky;
64
+ z-index: 2;
65
+ left: 0;
66
+ }
67
+ .PlaygroundEditorTheme__tableFrozenColumn tr > :first-child::after {
68
+ content: '';
69
+ position: absolute;
70
+ left: 0;
71
+ top: 0;
72
+ right: 0;
73
+ height: 100%;
74
+ border-right: 1px solid #bbb;
75
+ }
76
+ .PlaygroundEditorTheme__tableRowStriping tr:nth-child(even) {
77
+ background-color: #f2f5fb;
78
+ }
79
+ .PlaygroundEditorTheme__tableSelection *::selection {
80
+ background-color: transparent;
81
+ }
82
+ .PlaygroundEditorTheme__tableSelected {
83
+ outline: 2px solid rgb(60, 132, 244);
84
+ }
85
+ .PlaygroundEditorTheme__tableCell {
86
+ border: 1px solid #bbb;
87
+ width: 75px;
88
+ vertical-align: top;
89
+ text-align: start;
90
+ padding: 6px 8px;
91
+ position: relative;
92
+ outline: none;
93
+ overflow: auto;
94
+ }
95
+ /*
96
+ A firefox workaround to allow scrolling of overflowing table cell
97
+ ref: https://bugzilla.mozilla.org/show_bug.cgi?id=1904159
98
+ */
99
+ .PlaygroundEditorTheme__tableCell > * {
100
+ overflow: inherit;
101
+ }
102
+ .PlaygroundEditorTheme__tableCellResizer {
103
+ position: absolute;
104
+ right: -4px;
105
+ height: 100%;
106
+ width: 8px;
107
+ cursor: ew-resize;
108
+ z-index: 10;
109
+ top: 0;
110
+ }
111
+ .PlaygroundEditorTheme__tableCellHeader {
112
+ background-color: #f2f3f5;
113
+ text-align: start;
114
+ }
115
+ .PlaygroundEditorTheme__tableCellSelected {
116
+ caret-color: transparent;
117
+ }
118
+ .PlaygroundEditorTheme__tableCellSelected::after {
119
+ position: absolute;
120
+ left: 0;
121
+ right: 0;
122
+ bottom: 0;
123
+ top: 0;
124
+ background-color: highlight;
125
+ mix-blend-mode: multiply;
126
+ content: '';
127
+ pointer-events: none;
128
+ }
129
+ .PlaygroundEditorTheme__tableAddColumns {
130
+ position: absolute;
131
+ background-color: #eee;
132
+ height: 100%;
133
+ animation: table-controls 0.2s ease;
134
+ border: 0;
135
+ cursor: pointer;
136
+ }
137
+ .PlaygroundEditorTheme__tableAddColumns:after {
138
+ background-image: url(../images/icons/plus.svg);
139
+ background-size: contain;
140
+ background-position: center;
141
+ background-repeat: no-repeat;
142
+ display: block;
143
+ content: ' ';
144
+ position: absolute;
145
+ top: 0;
146
+ left: 0;
147
+ width: 100%;
148
+ height: 100%;
149
+ opacity: 0.4;
150
+ }
151
+ .PlaygroundEditorTheme__tableAddColumns:hover,
152
+ .PlaygroundEditorTheme__tableAddRows:hover {
153
+ background-color: #c9dbf0;
154
+ }
155
+ .PlaygroundEditorTheme__tableAddRows {
156
+ position: absolute;
157
+ width: calc(100% - 25px);
158
+ background-color: #eee;
159
+ animation: table-controls 0.2s ease;
160
+ border: 0;
161
+ cursor: pointer;
162
+ }
163
+ .PlaygroundEditorTheme__tableAddRows:after {
164
+ background-image: url(../images/icons/plus.svg);
165
+ background-size: contain;
166
+ background-position: center;
167
+ background-repeat: no-repeat;
168
+ display: block;
169
+ content: ' ';
170
+ position: absolute;
171
+ top: 0;
172
+ left: 0;
173
+ width: 100%;
174
+ height: 100%;
175
+ opacity: 0.4;
176
+ }
177
+ @keyframes table-controls {
178
+ 0% {
179
+ opacity: 0;
180
+ }
181
+ 100% {
182
+ opacity: 1;
183
+ }
184
+ }
185
+ .PlaygroundEditorTheme__tableCellResizeRuler {
186
+ display: block;
187
+ position: absolute;
188
+ width: 1px;
189
+ background-color: rgb(60, 132, 244);
190
+ height: 100%;
191
+ top: 0;
192
+ }
193
+ .PlaygroundEditorTheme__tableCellActionButtonContainer {
194
+ display: block;
195
+ right: 5px;
196
+ top: 6px;
197
+ position: absolute;
198
+ z-index: 4;
199
+ width: 20px;
200
+ height: 20px;
201
+ }
202
+ .PlaygroundEditorTheme__tableCellActionButton {
203
+ background-color: #eee;
204
+ display: block;
205
+ border: 0;
206
+ border-radius: 20px;
207
+ width: 20px;
208
+ height: 20px;
209
+ color: #222;
210
+ cursor: pointer;
211
+ }
212
+ .PlaygroundEditorTheme__tableCellActionButton:hover {
213
+ background-color: #ddd;
214
+ }
@@ -69,27 +69,7 @@ function DropDownItems({ children, dropDownRef, onClose, }) {
69
69
  highlightedItem.current.focus();
70
70
  }
71
71
  }, [items, highlightedItem]);
72
- return (_jsx(DropDownContext.Provider, { value: contextValue, children: _jsx(Box, { className: "dropdown", ref: dropDownRef, onKeyDown: handleKeyDown, sx: {
73
- border: 1,
74
- borderColor: 'divider',
75
- bgcolor: 'background.default',
76
- '.item': {
77
- display: 'flex',
78
- alignItems: 'center',
79
- gap: 1,
80
- /* fix: safari dropdown menu item 右侧溢出问题 */
81
- width: '-webkit-fill-available',
82
- color: 'text.primary',
83
- bgcolor: 'background.default',
84
- '.iconify': {
85
- flexShrink: 0,
86
- fontSize: '1.4em',
87
- },
88
- '&:hover': {
89
- bgcolor: 'action.hover',
90
- },
91
- },
92
- }, children: children }) }));
72
+ return (_jsx(DropDownContext.Provider, { value: contextValue, children: _jsx(Box, { className: "dropdown", ref: dropDownRef, onKeyDown: handleKeyDown, children: children }) }));
93
73
  }
94
74
  export default function DropDown({ disabled = false, buttonLabel, buttonAriaLabel, buttonClassName, buttonIconClassName, buttonIconData, children, stopCloseOnClickSelf, }) {
95
75
  const dropDownRef = useRef(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/editor",
3
- "version": "2.3.47",
3
+ "version": "2.3.49",
4
4
  "main": "lib/index.js",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -68,7 +68,7 @@
68
68
  "ufo": "^1.5.4",
69
69
  "url-join": "^4.0.1",
70
70
  "zustand": "^4.5.5",
71
- "@blocklet/pdf": "^2.3.47"
71
+ "@blocklet/pdf": "^2.3.49"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@babel/core": "^7.25.2",