@blocklet/editor 2.3.106 → 2.4.1

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.
Files changed (108) hide show
  1. package/lib/components/createPortal.d.ts +1 -1
  2. package/lib/ext/Aide/Delayed.d.ts +1 -1
  3. package/lib/ext/Aide/Input.js +3 -1
  4. package/lib/ext/Aide/Templates.js +6 -2
  5. package/lib/ext/Aide/external-templates/parameter-field.js +19 -13
  6. package/lib/ext/Alert/AlertComponent.d.ts +1 -1
  7. package/lib/ext/Alert/AlertComponent.js +1 -1
  8. package/lib/ext/Alert/AlertNode.d.ts +1 -1
  9. package/lib/ext/Alert/AlertPlugin.d.ts +1 -1
  10. package/lib/ext/BilibiliPlugin/BilibiliNode.d.ts +1 -1
  11. package/lib/ext/BilibiliPlugin/index.d.ts +1 -1
  12. package/lib/ext/BlockletEmbedPlugin/BlockletEmbed.d.ts +1 -1
  13. package/lib/ext/BlockletEmbedPlugin/BlockletEmbedNode.d.ts +1 -1
  14. package/lib/ext/BlockletEmbedPlugin/index.d.ts +1 -1
  15. package/lib/ext/BookmarkPlugin/Bookmark.d.ts +1 -1
  16. package/lib/ext/BookmarkPlugin/BookmarkNode.d.ts +1 -1
  17. package/lib/ext/BookmarkPlugin/index.d.ts +1 -1
  18. package/lib/ext/CharacterLimitPlugin/index.d.ts +1 -1
  19. package/lib/ext/FilePlugin/FileNode.d.ts +1 -1
  20. package/lib/ext/FilePlugin/FilePlugin.d.ts +1 -1
  21. package/lib/ext/InlineTranslationPlugin/InlineTranslationPlugin.js +7 -3
  22. package/lib/ext/InlineTranslationPlugin/store.d.ts +1 -1
  23. package/lib/ext/OnContentChangePlugin.js +1 -1
  24. package/lib/ext/PagesKitComponent/PagesKitComponentNode.d.ts +1 -1
  25. package/lib/ext/PagesKitComponent/PagesKitComponentPlugin.d.ts +1 -1
  26. package/lib/ext/PasteMarkdownPlugin/index.d.ts +1 -1
  27. package/lib/ext/PasteSlackImagePlugin/index.d.ts +1 -1
  28. package/lib/ext/PdfPlugin/PdfNode.d.ts +1 -1
  29. package/lib/ext/PdfPlugin/PdfPlugin.d.ts +1 -1
  30. package/lib/ext/PostLinkEmbedPlugin/PostLinkNode.d.ts +1 -1
  31. package/lib/ext/PostLinkEmbedPlugin/index.d.ts +1 -1
  32. package/lib/ext/SafeAreaPlugin.js +2 -2
  33. package/lib/ext/ShortcutPlugin/CtrlsShortcutPlugin.d.ts +1 -1
  34. package/lib/ext/SubpageListingPlugin/SubpageListingComponent.d.ts +1 -1
  35. package/lib/ext/SubpageListingPlugin/SubpageListingNode.d.ts +1 -1
  36. package/lib/ext/SubpageListingPlugin/SubpageListingPlugin.d.ts +1 -1
  37. package/lib/ext/TemplatePlugin.d.ts +1 -1
  38. package/lib/ext/TemplatePlugin.js +5 -2
  39. package/lib/ext/VideoPlugin/VideoNode.d.ts +1 -1
  40. package/lib/ext/VideoPlugin/VideoPlugin.d.ts +1 -1
  41. package/lib/ext/common.d.ts +3 -1
  42. package/lib/ext/common.js +3 -3
  43. package/lib/ext/nodes/GithubNode.d.ts +1 -1
  44. package/lib/main/Settings.d.ts +1 -1
  45. package/lib/main/context/SettingsContext.d.ts +1 -1
  46. package/lib/main/context/SharedAutocompleteContext.d.ts +1 -1
  47. package/lib/main/context/SharedHistoryContext.d.ts +1 -1
  48. package/lib/main/editor.d.ts +1 -1
  49. package/lib/main/hooks/medium-zoom.d.ts +1 -1
  50. package/lib/main/hooks/useHasNodes.js +3 -1
  51. package/lib/main/hooks/useModal.d.ts +1 -1
  52. package/lib/main/index.d.ts +1 -1
  53. package/lib/main/markdown-editor/editor.d.ts +1 -1
  54. package/lib/main/markdown-editor/index.d.ts +1 -1
  55. package/lib/main/nodes/EquationNode.d.ts +1 -1
  56. package/lib/main/nodes/ExcalidrawNode/ExcalidrawComponent.d.ts +1 -1
  57. package/lib/main/nodes/ExcalidrawNode/ExcalidrawImage.d.ts +3 -2
  58. package/lib/main/nodes/ExcalidrawNode/ExcalidrawModal.d.ts +2 -1
  59. package/lib/main/nodes/ExcalidrawNode/ExcalidrawModal.js +1 -0
  60. package/lib/main/nodes/ExcalidrawNode/index.d.ts +1 -1
  61. package/lib/main/nodes/FigmaNode.d.ts +1 -1
  62. package/lib/main/nodes/ImageComponent.d.ts +1 -1
  63. package/lib/main/nodes/ImageNode.d.ts +1 -1
  64. package/lib/main/nodes/MermaidNode.d.ts +1 -1
  65. package/lib/main/nodes/StickyComponent.d.ts +1 -1
  66. package/lib/main/nodes/StickyNode.d.ts +1 -1
  67. package/lib/main/nodes/TweetNode.d.ts +1 -1
  68. package/lib/main/nodes/YouTubeNode.d.ts +1 -1
  69. package/lib/main/plugins/AutoEmbedPlugin/index.d.ts +1 -1
  70. package/lib/main/plugins/AutoLinkPlugin/index.d.ts +1 -1
  71. package/lib/main/plugins/CodeHighlightPlugin/index.d.ts +1 -1
  72. package/lib/main/plugins/ComponentPickerPlugin/index.d.ts +1 -1
  73. package/lib/main/plugins/DraggableBlockPlugin/index.d.ts +1 -1
  74. package/lib/main/plugins/EmojisPlugin/index.d.ts +1 -1
  75. package/lib/main/plugins/FigmaPlugin/index.d.ts +1 -1
  76. package/lib/main/plugins/FloatingLinkEditorPlugin/index.d.ts +1 -1
  77. package/lib/main/plugins/FloatingTextFormatToolbarPlugin/ColorPickerButton.d.ts +1 -1
  78. package/lib/main/plugins/FloatingTextFormatToolbarPlugin/index.d.ts +1 -1
  79. package/lib/main/plugins/ImagesPlugin/index.d.ts +1 -1
  80. package/lib/main/plugins/KeywordsPlugin/index.d.ts +1 -1
  81. package/lib/main/plugins/LexicalTypeaheadMenuPlugin/index.d.ts +1 -1
  82. package/lib/main/plugins/MarkdownShortcutPlugin/index.d.ts +1 -1
  83. package/lib/main/plugins/MentionsPlugin/HighlightStyle.d.ts +1 -1
  84. package/lib/main/plugins/MentionsPlugin/index.d.ts +1 -1
  85. package/lib/main/plugins/PasteLogPlugin/index.d.ts +1 -1
  86. package/lib/main/plugins/StickyPlugin/index.d.ts +1 -1
  87. package/lib/main/plugins/TestRecorderPlugin/index.d.ts +1 -1
  88. package/lib/main/plugins/TreeViewPlugin/index.d.ts +1 -1
  89. package/lib/main/plugins/TwitterPlugin/index.d.ts +1 -1
  90. package/lib/main/plugins/TypingPerfPlugin/index.d.ts +1 -1
  91. package/lib/main/plugins/YouTubePlugin/index.d.ts +1 -1
  92. package/lib/main/styled-editor-content.d.ts +3 -1
  93. package/lib/main/styled-editor-content.js +2 -3
  94. package/lib/main/ui/Button.d.ts +1 -1
  95. package/lib/main/ui/ColorPicker.d.ts +1 -1
  96. package/lib/main/ui/Dialog.d.ts +1 -1
  97. package/lib/main/ui/DropDown.d.ts +1 -1
  98. package/lib/main/ui/FileInput.d.ts +1 -1
  99. package/lib/main/ui/FileInput.js +0 -7
  100. package/lib/main/ui/FrameMockup/index.d.ts +1 -2
  101. package/lib/main/ui/FrameMockup/index.js +2 -3
  102. package/lib/main/ui/ImageResizer.d.ts +1 -1
  103. package/lib/main/ui/Modal.d.ts +1 -1
  104. package/lib/main/ui/Placeholder.d.ts +3 -2
  105. package/lib/main/ui/Placeholder.js +2 -3
  106. package/lib/main/ui/Switch.d.ts +1 -0
  107. package/lib/stories/Dialog.js +4 -1
  108. package/package.json +22 -22
@@ -1,2 +1,2 @@
1
- declare const createPortal: (portalElement: React.ReactElement, parentElement: HTMLElement) => React.ReactElement;
1
+ declare const createPortal: (portalElement: React.ReactElement<any>, parentElement: HTMLElement) => React.ReactElement<any>;
2
2
  export default createPortal;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  interface Props {
3
- children: React.ReactElement;
3
+ children: React.ReactElement<any>;
4
4
  delay: number;
5
5
  }
6
6
  export default function Delayed({ children, delay }: Props): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
@@ -29,7 +29,9 @@ export default function Input({ prepend, ...rest }) {
29
29
  justifyContent: 'center',
30
30
  alighItems: 'center',
31
31
  width: 36,
32
- }, children: _jsx(Box, { component: "i", className: "iconify", "data-icon": "bi:stars", "data-height": "16px", sx: { color: 'grey.600' } }) }), prepend, status === 'activated' && (_jsxs(_Fragment, { children: [_jsx(Box, { component: "input", type: "text", value: input, onChange: (e) => setInput(e.target.value), onKeyDown: handleOnKeyDown, ref: (ref) => ref && ref.focus({ preventScroll: true }), sx: {
32
+ }, children: _jsx(Box, { component: "i", className: "iconify", "data-icon": "bi:stars", "data-height": "16px", sx: { color: 'grey.600' } }) }), prepend, status === 'activated' && (_jsxs(_Fragment, { children: [_jsx(Box, { component: "input", type: "text", value: input, onChange: (e) => setInput(e.target.value), onKeyDown: handleOnKeyDown, ref: (ref) => {
33
+ ref?.focus({ preventScroll: true });
34
+ }, sx: {
33
35
  flex: '1 1 auto',
34
36
  height: '100%',
35
37
  border: 0,
@@ -23,8 +23,12 @@ export default function Templates({ ...rest }) {
23
23
  overflowY: 'auto',
24
24
  }, ...rest, children: _jsx(MenuList, { children: filteredTemplates.map((template) => {
25
25
  if (template.hasOptions()) {
26
- return (_jsxs(NestedMenuItem, { subMenu: _jsx(Card, { sx: { minWidth: 200, maxHeight: 240, overflowY: 'auto' }, children: _jsx(TemplateOptions, { template: template, onSelect: selectOption }) }), children: [_jsx(ListItemIcon, { children: _jsx(Box, { component: "i", className: "iconify", "data-icon": template.icon, "data-height": "16px" }) }), _jsx(ListItemText, { children: _jsx(Typography, { variant: "inherit", noWrap: true, lineHeight: 1.2, children: template.name }) })] }, template.id));
26
+ return (_jsxs(NestedMenuItem, { subMenu: _jsx(Card, { sx: { minWidth: 200, maxHeight: 240, overflowY: 'auto' }, children: _jsx(TemplateOptions, { template: template, onSelect: selectOption }) }), children: [_jsx(ListItemIcon, { children: _jsx(Box, { component: "i", className: "iconify", "data-icon": template.icon, "data-height": "16px" }) }), _jsx(ListItemText, { children: _jsx(Typography, { variant: "inherit", noWrap: true, sx: {
27
+ lineHeight: 1.2,
28
+ }, children: template.name }) })] }, template.id));
27
29
  }
28
- return (_jsxs(MenuItem, { onClick: () => sendToAI(template), selected: activeBuiltinTemplate?.id === template.id, sx: { '&:hover .aide-templates-item': { display: 'inline-block' } }, children: [_jsx(ListItemIcon, { children: _jsx(Box, { component: "i", className: "iconify", "data-icon": template.icon, "data-height": "16px" }) }), _jsx(ListItemText, { children: _jsx(Typography, { variant: "inherit", noWrap: true, lineHeight: 1.2, children: template.name }) }), _jsx(Box, { component: "i", className: "iconify aide-templates-item", "data-icon": "fluent:arrow-enter-24-regular", "data-height": "14px", sx: { display: 'none', color: 'grey.500' } })] }, template.id));
30
+ return (_jsxs(MenuItem, { onClick: () => sendToAI(template), selected: activeBuiltinTemplate?.id === template.id, sx: { '&:hover .aide-templates-item': { display: 'inline-block' } }, children: [_jsx(ListItemIcon, { children: _jsx(Box, { component: "i", className: "iconify", "data-icon": template.icon, "data-height": "16px" }) }), _jsx(ListItemText, { children: _jsx(Typography, { variant: "inherit", noWrap: true, sx: {
31
+ lineHeight: 1.2,
32
+ }, children: template.name }) }), _jsx(Box, { component: "i", className: "iconify aide-templates-item", "data-icon": "fluent:arrow-enter-24-regular", "data-height": "14px", sx: { display: 'none', color: 'grey.500' } })] }, template.id));
29
33
  }) }) }));
30
34
  }
@@ -10,17 +10,21 @@ export default function ParameterField({ parameter, ...props }) {
10
10
  return _jsx(Field, { ...{ parameter }, ...props });
11
11
  }
12
12
  function StringParameterField({ parameter, onChange, ...props }) {
13
- return (_jsx(TextField, { required: parameter.required, label: parameter.label, placeholder: parameter.placeholder, helperText: parameter.helper, multiline: parameter.multiline, minRows: parameter.multiline ? 2 : undefined, inputProps: { maxLength: parameter.maxLength }, onChange: (e) => onChange(e.target.value), ...props }));
13
+ return (_jsx(TextField, { required: parameter.required, label: parameter.label, placeholder: parameter.placeholder, helperText: parameter.helper, multiline: parameter.multiline, minRows: parameter.multiline ? 2 : undefined, onChange: (e) => onChange(e.target.value), ...props, slotProps: {
14
+ htmlInput: { maxLength: parameter.maxLength },
15
+ } }));
14
16
  }
15
17
  function NumberParameterField({ parameter, ...props }) {
16
18
  return (_jsx(NumberField, { required: parameter.required, label: parameter.label, placeholder: parameter.placeholder, helperText: parameter.helper, min: parameter.min, max: parameter.max, ...props }));
17
19
  }
18
20
  function SelectParameterField({ parameter, onChange, ...props }) {
19
- return (_jsxs(TextField, { required: parameter.required, label: parameter.label, placeholder: parameter.placeholder, helperText: parameter.helper, select: true, SelectProps: {
20
- MenuProps: { disablePortal: true },
21
- },
21
+ return (_jsxs(TextField, { required: parameter.required, label: parameter.label, placeholder: parameter.placeholder, helperText: parameter.helper, select: true,
22
22
  // SelectProps={{ MenuProps: { keepMounted: false, disablePortal: false } }}
23
- onChange: (e) => onChange(e.target.value), ...props, children: [_jsx(MenuItem, { value: "", children: _jsx("em", { children: "None" }) }), (parameter.options ?? []).map((option) => (_jsx(MenuItem, { value: option.value, children: option.label }, option.id)))] }));
23
+ onChange: (e) => onChange(e.target.value), ...props, slotProps: {
24
+ select: {
25
+ MenuProps: { disablePortal: true },
26
+ },
27
+ }, children: [_jsx(MenuItem, { value: "", children: _jsx("em", { children: "None" }) }), (parameter.options ?? []).map((option) => (_jsx(MenuItem, { value: option.value, children: option.label }, option.id)))] }));
24
28
  }
25
29
  const languages = [
26
30
  { en: 'English', cn: '英语' },
@@ -75,12 +79,14 @@ function NumberField({ min, max, default: def, onChange, ...props }) {
75
79
  }
76
80
  return num;
77
81
  };
78
- return (_jsx(TextField, { onChange: (e) => onChange?.(correctValue(e)), inputProps: {
79
- type: 'number',
80
- inputMode: 'numeric',
81
- pattern: '[0-9]*',
82
- min,
83
- max,
84
- ...props.inputProps,
85
- }, ...props }));
82
+ return (_jsx(TextField, { onChange: (e) => onChange?.(correctValue(e)), ...props, slotProps: {
83
+ htmlInput: {
84
+ type: 'number',
85
+ inputMode: 'numeric',
86
+ pattern: '[0-9]*',
87
+ min,
88
+ max,
89
+ ...props.inputProps,
90
+ },
91
+ } }));
86
92
  }
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
2
1
  import { AlertColor } from '@mui/material';
3
2
  import { RangeSelection } from 'lexical';
3
+ import { type JSX } from 'react';
4
4
  type AlertComponentProps = {
5
5
  text: string;
6
6
  severity: AlertColor;
@@ -7,7 +7,7 @@ export default function AlertComponent({ text, severity, onChange }) {
7
7
  const [editor] = useLexicalComposerContext();
8
8
  const [editing, setEditing] = useState(false);
9
9
  const [value, setValue] = useState(text);
10
- const selectionRef = useRef();
10
+ const selectionRef = useRef(undefined);
11
11
  // 初始化时若 text 为空则自动进入 editing 状态
12
12
  useEffect(() => {
13
13
  if (!text) {
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
2
1
  import { type DOMConversionMap, type DOMExportOutput, type EditorConfig, type ElementFormatType, type LexicalEditor, type LexicalNode, type NodeKey, type Spread } from 'lexical';
3
2
  import { DecoratorBlockNode, SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
4
3
  import { AlertColor } from '@mui/material/Alert';
4
+ import type { JSX } from 'react';
5
5
  export type SerializedAlertNode = Spread<{
6
6
  type: 'alert';
7
7
  text: string;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { LexicalCommand, LexicalEditor } from 'lexical';
2
+ import { type JSX } from 'react';
3
3
  import { AlertColor } from '@mui/material/Alert';
4
4
  type CommandPayload = {
5
5
  text: string;
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
2
1
  import type { DOMConversionMap, DOMExportOutput, EditorConfig, ElementFormatType, LexicalEditor, LexicalNode, NodeKey, Spread } from 'lexical';
3
2
  import { DecoratorBlockNode, SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
3
+ import type { JSX } from 'react';
4
4
  export interface BilibiliVideoPayload {
5
5
  id: string;
6
6
  page: string | undefined;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { LexicalCommand } from 'lexical';
2
+ import { type JSX } from 'react';
3
3
  import { BilibiliVideoPayload } from './BilibiliNode';
4
4
  export declare const INSERT_BILIBILI_COMMAND: LexicalCommand<BilibiliVideoPayload>;
5
5
  export default function BilibiliPlugin(): JSX.Element | null;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import { type JSX } from 'react';
2
2
  declare function BlockletEmbed({ title, url, originalUrl }: {
3
3
  title: string;
4
4
  url: string;
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
2
1
  import type { DOMConversionMap, DOMExportOutput, EditorConfig, ElementFormatType, LexicalEditor, LexicalNode, NodeKey, Spread } from 'lexical';
3
2
  import { DecoratorBlockNode, SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
3
+ import type { JSX } from 'react';
4
4
  export interface Embed {
5
5
  title: string;
6
6
  url: string;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { LexicalCommand } from 'lexical';
2
+ import { type JSX } from 'react';
3
3
  import type { LexicalEditor } from 'lexical';
4
4
  import { AutoEmbedOption } from '@lexical/react/LexicalAutoEmbedPlugin';
5
5
  import { Embed } from './BlockletEmbedNode';
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import type { JSX } from 'react';
2
2
  import type { BookmarkInfo } from './BookmarkNode';
3
3
  export declare function Bookmark({ url, title, description, image, favicon, loading }: BookmarkInfo): JSX.Element;
4
4
  export declare function BookmarkLoader({ url, onLoaded }: {
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
2
1
  import type { DOMConversionMap, DOMExportOutput, EditorConfig, ElementFormatType, LexicalEditor, LexicalNode, NodeKey, Spread } from 'lexical';
3
2
  import { DecoratorBlockNode, SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
3
+ import type { JSX } from 'react';
4
4
  export interface BookmarkInfo {
5
5
  url: string;
6
6
  title: string;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { LexicalCommand, LexicalEditor } from 'lexical';
2
+ import { type JSX } from 'react';
3
3
  import { AutoEmbedOption } from '@lexical/react/LexicalAutoEmbedPlugin';
4
4
  import { BookmarkInfo } from './BookmarkNode';
5
5
  import { EditorConfig } from '../../config';
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { SxProps } from '@mui/material';
2
+ import { type JSX } from 'react';
3
3
  interface CharacterLimitPluginProps {
4
4
  maxLength?: number;
5
5
  charLimitIndicatorStyle?: SxProps;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
1
  import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
2
+ import { type JSX } from 'react';
3
3
  import { DecoratorNode } from 'lexical';
4
4
  export declare const getAbsoluteUrl: ({ fileUrl, name }: {
5
5
  fileUrl: string;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { LexicalCommand } from 'lexical';
2
+ import { type JSX } from 'react';
3
3
  import { FilePayload } from './FileNode';
4
4
  export type InsertFilePayload = Readonly<FilePayload>;
5
5
  export declare const INSERT_FILE_COMMAND: LexicalCommand<InsertFilePayload>;
@@ -7,7 +7,7 @@ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
7
7
  import { usePopper } from 'react-popper';
8
8
  import { createPortal } from 'react-dom';
9
9
  import { css, Global } from '@emotion/react';
10
- import blue from '@mui/material/colors/blue';
10
+ import { blue } from '@mui/material/colors';
11
11
  import { useInlineTranslationStore, useStatus, useTargetLanguage } from './store';
12
12
  import { useEditorTranslator } from './EditorTranslator';
13
13
  import { NODE_TYPE } from './TranslationNode';
@@ -217,12 +217,16 @@ function TranslationElementPopper({ editorTranslator }) {
217
217
  }, children: [_jsxs(Box, { children: [_jsx(Box, { sx: { color: 'text.secondary', fontWeight: 'medium' }, children: translations.original[locale] || translations.original.en }), _jsx(Box, { dangerouslySetInnerHTML: { __html: originalText } })] }), _jsxs(Box, { sx: { mt: 1.5 }, children: [_jsx(Box, { sx: { color: 'text.secondary', fontWeight: 'medium' }, children: translations.translation[locale] ||
218
218
  translations.translation.en }), _jsx(Box, { dangerouslySetInnerHTML: {
219
219
  __html: editorTranslator.getTranslationText(hoveringTranslationElement.dataset.sid) || '',
220
- } })] })] }) })] })), _jsx(Box, { ref: setPopperElement, style: hoveringTranslationElementPopper.styles.popper, ...hoveringTranslationElementPopper.attributes.popper, sx: { zIndex: 'modal' }, onMouseLeave: reset, children: !originalText && (_jsx(Stack, { direction: "row", alignItems: hoveringTranslationElement.clientHeight > 100 ? 'center' : 'flex-start', sx: {
220
+ } })] })] }) })] })), _jsx(Box, { ref: setPopperElement, style: hoveringTranslationElementPopper.styles.popper, ...hoveringTranslationElementPopper.attributes.popper, sx: { zIndex: 'modal' }, onMouseLeave: reset, children: !originalText && (_jsx(Stack, { direction: "row", onClick: () => setOriginalText(originalText ? null : editorTranslator.getOriginalText(hoveringTranslationElement.dataset.sid) || ''), sx: {
221
+ alignItems: hoveringTranslationElement.clientHeight > 100 ? 'center' : 'flex-start',
221
222
  pr: 1,
222
223
  pt: 0.5,
223
224
  color: 'text.secondary',
224
225
  fontSize: 12,
225
226
  cursor: 'pointer',
226
227
  height: hoveringTranslationElement.clientHeight,
227
- }, onClick: () => setOriginalText(originalText ? null : editorTranslator.getOriginalText(hoveringTranslationElement.dataset.sid) || ''), children: _jsxs(Stack, { direction: "row", alignItems: "center", gap: 0.25, children: [_jsx("i", { className: "iconify", "data-icon": "tabler:tooltip", "data-height": 16 }), translations.original[locale] || translations.original.en] }) })) })] }), document.body);
228
+ }, children: _jsxs(Stack, { direction: "row", sx: {
229
+ alignItems: 'center',
230
+ gap: 0.25,
231
+ }, children: [_jsx("i", { className: "iconify", "data-icon": "tabler:tooltip", "data-height": 16 }), translations.original[locale] || translations.original.en] }) })) })] }), document.body);
228
232
  }
@@ -46,5 +46,5 @@ export declare const useStatus: (editor: LexicalEditor) => TranslateStatus | und
46
46
  export declare const useIsIdle: () => boolean;
47
47
  export declare const useIsTranslating: () => boolean;
48
48
  export declare const useIsTranslated: () => boolean;
49
- export declare const useTargetLanguage: () => string;
49
+ export declare const useTargetLanguage: () => any;
50
50
  export {};
@@ -11,7 +11,7 @@ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext
11
11
  */
12
12
  export function OnContentChangePlugin({ onChange, ignoreInitialChange = true, }) {
13
13
  const [editor] = useLexicalComposerContext();
14
- const initialContentRef = useRef();
14
+ const initialContentRef = useRef(undefined);
15
15
  const changedRef = useRef(false);
16
16
  useLayoutEffect(() => {
17
17
  if (initialContentRef.current === undefined) {
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
2
1
  import type { DOMConversionMap, DOMExportOutput, EditorConfig, ElementFormatType, LexicalEditor, LexicalNode, NodeKey, Spread } from 'lexical';
3
2
  import { DecoratorBlockNode, SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
3
+ import type { JSX } from 'react';
4
4
  import type { Properties } from './utils';
5
5
  export interface ComponentData {
6
6
  id: string;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { LexicalCommand } from 'lexical';
2
+ import { type JSX } from 'react';
3
3
  type CommandPayload = {
4
4
  id: string;
5
5
  name: string;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import { type JSX } from 'react';
2
2
  export declare function isMarkdownText(text: string): boolean;
3
3
  /**
4
4
  *
@@ -1,2 +1,2 @@
1
- /// <reference types="react" />
1
+ import { type JSX } from 'react';
2
2
  export default function PasteSlackImagePlugin(): JSX.Element | null;
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
2
1
  import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
3
2
  import { DecoratorNode } from 'lexical';
3
+ import { type JSX } from 'react';
4
4
  export declare const getAbsoluteUrl: (imageUrl: string) => any;
5
5
  export interface PdfPayload {
6
6
  key?: NodeKey;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { LexicalCommand } from 'lexical';
2
+ import { type JSX } from 'react';
3
3
  import { PdfPayload } from './PdfNode';
4
4
  export type InsertPdfPayload = Readonly<PdfPayload>;
5
5
  export declare const INSERT_PDF_COMMAND: LexicalCommand<InsertPdfPayload>;
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
2
1
  import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
3
2
  import { DecoratorNode } from 'lexical';
3
+ import { type JSX } from 'react';
4
4
  export interface PostInfo {
5
5
  id: string;
6
6
  title: string;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { LexicalCommand, LexicalEditor } from 'lexical';
2
+ import { type JSX } from 'react';
3
3
  import { AutoEmbedOption } from '@lexical/react/LexicalAutoEmbedPlugin';
4
4
  import { EditorConfig } from '../../config';
5
5
  type PostType = 'post' | 'blog' | 'doc';
@@ -13,7 +13,7 @@ const normalizeCssSize = (size) => {
13
13
  */
14
14
  export function SafeAreaPlugin({ size = '30vh' }) {
15
15
  const [editor] = useLexicalComposerContext();
16
- const originalValue = useRef();
16
+ const originalValue = useRef(undefined);
17
17
  // TODO: editable true->false 时恢复原值
18
18
  // const restore = () => {
19
19
  // const rootElement = editor.getRootElement();
@@ -35,7 +35,7 @@ export function SafeAreaPlugin({ size = '30vh' }) {
35
35
  }
36
36
  export function useSafeArea({ enabled, size = '30vh' }) {
37
37
  const [editor] = useLexicalComposerContext();
38
- const originalValue = useRef();
38
+ const originalValue = useRef(undefined);
39
39
  useEffect(() => {
40
40
  const cleanup = editor.registerRootListener((rootElement, prevRootElement) => {
41
41
  if (rootElement !== null && editor.isEditable() && enabled) {
@@ -2,5 +2,5 @@
2
2
  interface Props {
3
3
  callback: () => void;
4
4
  }
5
- export declare function CtrlsShortcutPlugin({ callback }: Props): React.ReactElement | null;
5
+ export declare function CtrlsShortcutPlugin({ callback }: Props): React.ReactElement<any> | null;
6
6
  export default CtrlsShortcutPlugin;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import { type JSX } from 'react';
2
2
  import { Mode } from './types';
3
3
  type SubpageListingComponentProps = {
4
4
  docPostId: string;
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
2
1
  import { type DOMConversionMap, type DOMExportOutput, type EditorConfig, type ElementFormatType, type LexicalEditor, type LexicalNode, type NodeKey, type Spread } from 'lexical';
3
2
  import { DecoratorBlockNode, SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
3
+ import type { JSX } from 'react';
4
4
  import { Mode } from './types';
5
5
  interface Data {
6
6
  docPostId: string;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { LexicalCommand, LexicalEditor } from 'lexical';
2
+ import { type JSX } from 'react';
3
3
  import { Mode } from './types';
4
4
  type CommandPayload = {
5
5
  mode?: Mode;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import { type JSX } from 'react';
2
2
  export declare const INSERT_TEMPLATE_COMMAND: import("lexical").LexicalCommand<unknown>;
3
3
  export declare function TemplatePlugin(): JSX.Element | null;
4
4
  export declare function TemplateSelect({ onSelect, onHover, templateList, }: {
@@ -155,13 +155,16 @@ export function TemplateSelect({ onSelect, onHover, templateList = [], }) {
155
155
  if (template.options) {
156
156
  return (_jsxs(NestedMenuItem, { subMenu: _jsx(Card, { sx: { minWidth: 200, maxHeight: 240, overflowY: 'auto' }, children: _jsx(MenuList, { children: template.options.map((option) => {
157
157
  return (_jsx(MenuItem, { onClick: () => onSelect?.(option), onMouseEnter: () => onHover?.(option), children: option.title }, option.title));
158
- }) }) }), children: [_jsx(ListItemIcon, { sx: { mr: 0.75 }, children: _jsx(BlockletLogo, { did: template.did }) }), _jsx(ListItemText, { children: _jsx(Typography, { variant: "inherit", noWrap: true, lineHeight: 1, children: template.title }) })] }, template.title));
158
+ }) }) }), children: [_jsx(ListItemIcon, { sx: { mr: 0.75 }, children: _jsx(BlockletLogo, { did: template.did }) }), _jsx(ListItemText, { children: _jsx(Typography, { variant: "inherit", noWrap: true, sx: {
159
+ lineHeight: 1,
160
+ }, children: template.title }) })] }, template.title));
159
161
  }
160
162
  // not any options
161
163
  return null;
162
164
  }) })) : (_jsxs(MenuItem, { children: [_jsx(ListItemIcon, { sx: { mr: 0.75 }, children: _jsx(Box, { component: "i", className: "iconify", "data-icon": "material-symbols:info-outline", "data-height": "24px", "data-width": "24px" }) }), _jsx(ListItemText, { sx: {
163
165
  whiteSpace: 'pre-wrap',
164
- }, children: _jsx(Typography, { variant: "inherit", lineHeight: 1.4, sx: {
166
+ }, children: _jsx(Typography, { variant: "inherit", sx: {
167
+ lineHeight: 1.4,
165
168
  whiteSpace: 'pre-wrap',
166
169
  }, children: "There is no templates available, please contact the owner or admin to import it" }) })] })) }));
167
170
  }
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
2
1
  import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
3
2
  import { DecoratorNode } from 'lexical';
3
+ import { type JSX } from 'react';
4
4
  export interface VideoPayload {
5
5
  key?: NodeKey;
6
6
  src: string;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { LexicalCommand } from 'lexical';
2
+ import { type JSX } from 'react';
3
3
  import { VideoPayload } from './VideoNode';
4
4
  export type InsertVideoPayload = Readonly<VideoPayload>;
5
5
  export declare const INSERT_VIDEO_COMMAND: LexicalCommand<InsertVideoPayload>;
@@ -4,7 +4,9 @@ type Props = {
4
4
  children: React.ReactNode;
5
5
  sx?: SxProps;
6
6
  } & BoxProps;
7
- export declare const Card: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
7
+ export declare function Card({ ref, children, sx, ...rest }: Props & {
8
+ ref?: React.RefObject<HTMLDivElement | null>;
9
+ }): import("react/jsx-runtime").JSX.Element;
8
10
  export declare const MenuWrapper: React.FC<BoxProps>;
9
11
  export declare const GradientButton: React.FC<ButtonProps>;
10
12
  export declare function NestedMenuItem({ children, subMenu, ...rest }: MenuItemProps & {
package/lib/ext/common.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Button, MenuItem, styled } from '@mui/material';
3
- import { forwardRef, useRef, useState } from 'react';
3
+ import { useRef, useState } from 'react';
4
4
  import { usePopper } from 'react-popper';
5
- export const Card = forwardRef(({ children, sx, ...rest }, ref) => {
5
+ export function Card({ ref = undefined, children, sx, ...rest }) {
6
6
  const mergedSx = [
7
7
  {
8
8
  maxWidth: '100%',
@@ -16,7 +16,7 @@ export const Card = forwardRef(({ children, sx, ...rest }, ref) => {
16
16
  ...(Array.isArray(sx) ? sx : [sx]),
17
17
  ];
18
18
  return (_jsx(Box, { ref: ref, sx: mergedSx, ...rest, children: children }));
19
- });
19
+ }
20
20
  export const MenuWrapper = styled(Box) `
21
21
  .MuiMenuItem-root {
22
22
  min-height: 32px;
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
2
1
  import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
3
2
  import { DecoratorNode } from 'lexical';
3
+ import { type JSX } from 'react';
4
4
  import { GithubInfoType } from './util';
5
5
  export type SerializedGithubNode = Spread<{
6
6
  title: string;
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- /// <reference types="react" />
8
+ import { type JSX } from 'react';
9
9
  export default function Settings(): JSX.Element;
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import { ReactNode } from 'react';
8
+ import { ReactNode, type JSX } from 'react';
9
9
  import type { SettingName } from '../appSettings';
10
10
  type SettingsContextShape = {
11
11
  setOption: (name: SettingName, value: boolean) => void;
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import { ReactNode } from 'react';
8
+ import { ReactNode, type JSX } from 'react';
9
9
  type Suggestion = null | string;
10
10
  type PublishFn = (newSuggestion: Suggestion) => void;
11
11
  type HookShape = [suggestion: Suggestion, setSuggestion: PublishFn];
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
  import type { HistoryState } from '@lexical/react/LexicalHistoryPlugin';
9
- import { ReactNode } from 'react';
9
+ import { ReactNode, type JSX } from 'react';
10
10
  type ContextShape = {
11
11
  historyState?: HistoryState;
12
12
  };
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import { MutableRefObject, ReactNode } from 'react';
8
+ import { MutableRefObject, ReactNode, type JSX } from 'react';
9
9
  import { EditorState, LexicalEditor } from 'lexical';
10
10
  export interface EditorProps {
11
11
  children?: ReactNode;
@@ -2,7 +2,7 @@ import 'medium-zoom/dist/style.css';
2
2
  interface MediumZoomOption {
3
3
  enabled?: boolean;
4
4
  }
5
- export declare const useMediumZoom: (imageRef: React.RefObject<HTMLImageElement>, options?: MediumZoomOption) => {
5
+ export declare const useMediumZoom: (imageRef: React.RefObject<HTMLImageElement | null>, options?: MediumZoomOption) => {
6
6
  zoomOpened: boolean;
7
7
  openedImageRef: import("react").MutableRefObject<HTMLImageElement | null>;
8
8
  };
@@ -2,5 +2,7 @@ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext
2
2
  import { useCallback } from 'react';
3
3
  export default function useHasNodes() {
4
4
  const [editor] = useLexicalComposerContext();
5
- return useCallback((...types) => editor.hasNodes(types.map((type) => ({ getType: () => type }))), [editor]);
5
+ return useCallback((...types) => editor.hasNodes(types.map((type) => ({
6
+ getType: () => type,
7
+ }))), [editor]);
6
8
  }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- /// <reference types="react" />
8
+ import { type JSX } from 'react';
9
9
  export default function useModal(): [
10
10
  JSX.Element | null,
11
11
  (title: string, showModal: (onClose: () => void) => JSX.Element) => void
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
  import { EditorState, Klass, LexicalEditor, LexicalNode } from 'lexical';
9
- import React, { MutableRefObject, ReactNode } from 'react';
9
+ import React, { MutableRefObject, ReactNode, type JSX } from 'react';
10
10
  export interface BlockletEditorProps extends Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'placeholder' | 'onChange'> {
11
11
  placeholder?: ReactNode;
12
12
  editable?: boolean;
@@ -1,4 +1,4 @@
1
- import { MutableRefObject, ReactNode } from 'react';
1
+ import { MutableRefObject, ReactNode, type JSX } from 'react';
2
2
  import { LexicalEditor } from 'lexical';
3
3
  export interface EditorProps {
4
4
  children?: ReactNode;
@@ -1,5 +1,5 @@
1
1
  import { LexicalEditor } from 'lexical';
2
- import React, { MutableRefObject, ReactNode } from 'react';
2
+ import React, { MutableRefObject, ReactNode, type JSX } from 'react';
3
3
  export interface MarkdownEditorProps extends Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'placeholder' | 'onChange'> {
4
4
  placeholder?: ReactNode;
5
5
  editable?: boolean;
@@ -5,9 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- /// <reference types="react" />
9
8
  import type { EditorConfig, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
10
9
  import { DecoratorNode } from 'lexical';
10
+ import { type JSX } from 'react';
11
11
  export type SerializedEquationNode = Spread<{
12
12
  type: 'equation';
13
13
  equation: string;
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- /// <reference types="react" />
9
8
  import type { NodeKey } from 'lexical';
9
+ import { type JSX } from 'react';
10
10
  export default function ExcalidrawComponent({ nodeKey, data }: {
11
11
  data: string;
12
12
  nodeKey: NodeKey;