@blocklet/editor 2.3.35 → 2.3.36
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.
- package/lib/main/index.css +1 -25
- package/lib/main/plugins/ComponentPickerPlugin/index.js +12 -1
- package/lib/main/plugins/FloatingLinkEditorPlugin/index.css +0 -1
- package/lib/main/plugins/FloatingLinkEditorPlugin/index.js +15 -1
- package/lib/main/plugins/FloatingTextFormatToolbarPlugin/index.css +0 -12
- package/lib/main/plugins/FloatingTextFormatToolbarPlugin/index.js +30 -27
- package/lib/main/plugins/MentionsPlugin/index.js +13 -1
- package/lib/main/ui/DropDown.js +22 -16
- package/lib/main/ui/ImageEnhancer.js +1 -1
- package/package.json +2 -2
package/lib/main/index.css
CHANGED
|
@@ -127,7 +127,6 @@
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
.typeahead-popover {
|
|
130
|
-
background: #fff;
|
|
131
130
|
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.3);
|
|
132
131
|
border-radius: 8px;
|
|
133
132
|
z-index: 1;
|
|
@@ -160,14 +159,9 @@
|
|
|
160
159
|
cursor: pointer;
|
|
161
160
|
}
|
|
162
161
|
|
|
163
|
-
.typeahead-popover ul li.selected {
|
|
164
|
-
background: #eee;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
162
|
.typeahead-popover li {
|
|
168
163
|
margin: 0 8px 0 8px;
|
|
169
164
|
padding: 8px;
|
|
170
|
-
color: #050505;
|
|
171
165
|
cursor: pointer;
|
|
172
166
|
line-height: 16px;
|
|
173
167
|
font-size: 15px;
|
|
@@ -175,7 +169,6 @@
|
|
|
175
169
|
align-content: center;
|
|
176
170
|
flex-direction: row;
|
|
177
171
|
flex-shrink: 0;
|
|
178
|
-
background-color: #fff;
|
|
179
172
|
border: 0;
|
|
180
173
|
}
|
|
181
174
|
|
|
@@ -186,10 +179,6 @@
|
|
|
186
179
|
background-size: contain;
|
|
187
180
|
}
|
|
188
181
|
|
|
189
|
-
.typeahead-popover li:hover {
|
|
190
|
-
background-color: #eee;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
182
|
.typeahead-popover li .text {
|
|
194
183
|
display: flex;
|
|
195
184
|
line-height: 20px;
|
|
@@ -279,9 +268,7 @@ i.prettier-error {
|
|
|
279
268
|
margin: 8px 12px;
|
|
280
269
|
padding: 8px 12px;
|
|
281
270
|
border-radius: 15px;
|
|
282
|
-
background-color: #eee;
|
|
283
271
|
font-size: 15px;
|
|
284
|
-
color: rgb(5, 5, 5);
|
|
285
272
|
border: 0;
|
|
286
273
|
outline: 0;
|
|
287
274
|
position: relative;
|
|
@@ -303,7 +290,6 @@ i.prettier-error {
|
|
|
303
290
|
}
|
|
304
291
|
|
|
305
292
|
.link-editor .link-input a {
|
|
306
|
-
color: rgb(33, 111, 219);
|
|
307
293
|
text-decoration: none;
|
|
308
294
|
display: block;
|
|
309
295
|
white-space: nowrap;
|
|
@@ -453,18 +439,13 @@ i.prettier-error {
|
|
|
453
439
|
z-index: 10001;
|
|
454
440
|
display: block;
|
|
455
441
|
position: fixed;
|
|
456
|
-
box-shadow:
|
|
457
|
-
0 12px 28px 0 rgba(0, 0, 0, 0.2),
|
|
458
|
-
0 2px 4px 0 rgba(0, 0, 0, 0.1),
|
|
459
|
-
inset 0 0 0 1px rgba(255, 255, 255, 0.5);
|
|
442
|
+
box-shadow: 0 1px rgb(0 0 0 / 0.05);
|
|
460
443
|
border-radius: 8px;
|
|
461
444
|
min-height: 40px;
|
|
462
|
-
background-color: #fff;
|
|
463
445
|
}
|
|
464
446
|
|
|
465
447
|
.dropdown .item {
|
|
466
448
|
padding: 8px;
|
|
467
|
-
color: #050505;
|
|
468
449
|
cursor: pointer;
|
|
469
450
|
line-height: 16px;
|
|
470
451
|
font-size: 15px;
|
|
@@ -473,7 +454,6 @@ i.prettier-error {
|
|
|
473
454
|
flex-direction: row;
|
|
474
455
|
flex-shrink: 0;
|
|
475
456
|
justify-content: space-between;
|
|
476
|
-
background-color: #fff;
|
|
477
457
|
border: 0;
|
|
478
458
|
max-width: 250px;
|
|
479
459
|
min-width: 100px;
|
|
@@ -499,10 +479,6 @@ i.prettier-error {
|
|
|
499
479
|
margin-bottom: 8px;
|
|
500
480
|
}
|
|
501
481
|
|
|
502
|
-
.dropdown .item:hover {
|
|
503
|
-
background-color: #eee;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
482
|
.dropdown .item .text {
|
|
507
483
|
display: flex;
|
|
508
484
|
line-height: 20px;
|
|
@@ -373,7 +373,18 @@ export default function ComponentPickerMenuPlugin() {
|
|
|
373
373
|
}, [editor]);
|
|
374
374
|
return (_jsxs(_Fragment, { children: [modal, _jsx(LexicalTypeaheadMenuPlugin, { onQueryChange: setQueryString, onSelectOption: onSelectOption, triggerFn: checkForTriggerMatch, options: options, menuRenderFn: (anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => {
|
|
375
375
|
return anchorElementRef.current && options.length
|
|
376
|
-
? createPortal(_jsx(
|
|
376
|
+
? createPortal(_jsx(Box, { className: "typeahead-popover component-picker-menu", sx: {
|
|
377
|
+
border: 1,
|
|
378
|
+
borderColor: 'divider',
|
|
379
|
+
color: 'text.primary',
|
|
380
|
+
bgcolor: 'background.default',
|
|
381
|
+
'li.selected': {
|
|
382
|
+
bgcolor: 'action.selected',
|
|
383
|
+
},
|
|
384
|
+
'li:hover': {
|
|
385
|
+
bgcolor: 'action.hover',
|
|
386
|
+
},
|
|
387
|
+
}, children: _jsx("ul", { children: options.map((option, i) => (_jsx(ComponentPickerMenuItem, { index: i, isSelected: selectedIndex === i, onClick: () => {
|
|
377
388
|
setHighlightedIndex(i);
|
|
378
389
|
selectOptionAndCleanUp(option);
|
|
379
390
|
}, onMouseEnter: () => {
|
|
@@ -13,6 +13,7 @@ import { $findMatchingParent, mergeRegister } from '@lexical/utils';
|
|
|
13
13
|
import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_LOW, SELECTION_CHANGE_COMMAND, } from 'lexical';
|
|
14
14
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
15
15
|
import { createPortal } from 'react-dom';
|
|
16
|
+
import { Box } from '@mui/material';
|
|
16
17
|
import { getSelectedNode } from '../../utils/getSelectedNode';
|
|
17
18
|
import { sanitizeUrl } from '../../utils/sanitizeUrl';
|
|
18
19
|
import { setFloatingElemPosition } from '../../utils/setFloatingElemPosition';
|
|
@@ -111,7 +112,20 @@ function FloatingLinkEditor({ editor, anchorElem }) {
|
|
|
111
112
|
inputRef.current.focus();
|
|
112
113
|
}
|
|
113
114
|
}, [isEditMode]);
|
|
114
|
-
return (_jsx(
|
|
115
|
+
return (_jsx(Box, { ref: editorRef, className: "link-editor", sx: {
|
|
116
|
+
bgcolor: 'background.default',
|
|
117
|
+
color: 'text.primary',
|
|
118
|
+
border: 1,
|
|
119
|
+
borderColor: 'divider',
|
|
120
|
+
'& .link-input': {
|
|
121
|
+
minHeight: 32,
|
|
122
|
+
color: 'text.primary',
|
|
123
|
+
bgcolor: 'grey.100',
|
|
124
|
+
'& a': {
|
|
125
|
+
color: 'primary.main',
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
}, children: isEditMode ? (_jsx("input", { ref: inputRef, className: "link-input", value: linkUrl, onChange: (event) => {
|
|
115
129
|
setLinkUrl(event.target.value);
|
|
116
130
|
}, onKeyDown: (event) => {
|
|
117
131
|
if (event.key === 'Enter') {
|
|
@@ -9,18 +9,15 @@
|
|
|
9
9
|
|
|
10
10
|
.floating-text-format-popup {
|
|
11
11
|
display: flex;
|
|
12
|
-
background: #fff;
|
|
13
12
|
padding: 4px;
|
|
14
13
|
vertical-align: middle;
|
|
15
14
|
position: absolute;
|
|
16
15
|
top: 0;
|
|
17
16
|
left: 0;
|
|
18
17
|
opacity: 0;
|
|
19
|
-
background-color: #fff;
|
|
20
18
|
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.3);
|
|
21
19
|
border-radius: 8px;
|
|
22
20
|
transition: opacity 0.5s;
|
|
23
|
-
height: 35px;
|
|
24
21
|
will-change: transform;
|
|
25
22
|
z-index: 1201;
|
|
26
23
|
}
|
|
@@ -33,7 +30,6 @@
|
|
|
33
30
|
padding: 8px;
|
|
34
31
|
cursor: pointer;
|
|
35
32
|
vertical-align: middle;
|
|
36
|
-
color: #4b5563;
|
|
37
33
|
}
|
|
38
34
|
|
|
39
35
|
.floating-text-format-popup button.popup-item:disabled {
|
|
@@ -59,18 +55,10 @@
|
|
|
59
55
|
opacity: 0.2;
|
|
60
56
|
}
|
|
61
57
|
|
|
62
|
-
.floating-text-format-popup button.popup-item.active {
|
|
63
|
-
background-color: rgba(223, 232, 250, 0.3);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
58
|
.floating-text-format-popup button.popup-item.active i {
|
|
67
59
|
opacity: 1;
|
|
68
60
|
}
|
|
69
61
|
|
|
70
|
-
.floating-text-format-popup .popup-item:hover:not([disabled]) {
|
|
71
|
-
background-color: #eee;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
62
|
.floating-text-format-popup select.popup-item {
|
|
75
63
|
border: 0;
|
|
76
64
|
display: flex;
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
import styled from '@emotion/styled';
|
|
10
2
|
import { $isCodeHighlightNode } from '@lexical/code';
|
|
11
3
|
import { $isLinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link';
|
|
12
4
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
@@ -14,6 +6,7 @@ import { mergeRegister } from '@lexical/utils';
|
|
|
14
6
|
import { $getSelection, $isRangeSelection, $isTextNode, COMMAND_PRIORITY_LOW, FORMAT_TEXT_COMMAND, SELECTION_CHANGE_COMMAND, } from 'lexical';
|
|
15
7
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
16
8
|
import { createPortal } from 'react-dom';
|
|
9
|
+
import { Box } from '@mui/material';
|
|
17
10
|
import { getDOMRangeRect } from '../../utils/getDOMRangeRect';
|
|
18
11
|
import { getSelectedNode } from '../../utils/getSelectedNode';
|
|
19
12
|
import { setFloatingElemPosition } from '../../utils/setFloatingElemPosition';
|
|
@@ -98,7 +91,35 @@ function TextFormatFloatingToolbar({ editor, anchorElem, isLink, isBold, isItali
|
|
|
98
91
|
return false;
|
|
99
92
|
}, COMMAND_PRIORITY_LOW));
|
|
100
93
|
}, [editor, updateTextFormatFloatingToolbar]);
|
|
101
|
-
return (_jsx(
|
|
94
|
+
return (_jsx(Box, { ref: popupCharStylesEditorRef, className: "floating-text-format-popup", sx: {
|
|
95
|
+
border: 1,
|
|
96
|
+
borderColor: 'divider',
|
|
97
|
+
bgcolor: 'background.default',
|
|
98
|
+
'button.popup-item': {
|
|
99
|
+
height: 28,
|
|
100
|
+
color: 'text.primary',
|
|
101
|
+
},
|
|
102
|
+
'button.popup-item.active': {
|
|
103
|
+
bgcolor: 'action.selected',
|
|
104
|
+
},
|
|
105
|
+
'.popup-item:hover:not([disabled])': {
|
|
106
|
+
bgcolor: 'action.hover',
|
|
107
|
+
},
|
|
108
|
+
'> button': {
|
|
109
|
+
display: 'flex',
|
|
110
|
+
alignItems: 'center',
|
|
111
|
+
justifyContent: 'center',
|
|
112
|
+
'& .iconify': {
|
|
113
|
+
fontSize: 16,
|
|
114
|
+
opacity: 0.6,
|
|
115
|
+
},
|
|
116
|
+
'&.active': {
|
|
117
|
+
'& .iconify': {
|
|
118
|
+
opacity: 1,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
}, children: editor.isEditable() && (_jsxs(_Fragment, { children: [_jsx(AideFloatingToolbarButton, {}), _jsx("button", { onClick: () => {
|
|
102
123
|
editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'bold');
|
|
103
124
|
}, className: `popup-item spaced ${isBold ? 'active' : ''}`, "aria-label": "Format text as bold", children: _jsx("i", { className: "iconify", "data-icon": "mdi:format-bold" }) }), _jsx("button", { onClick: () => {
|
|
104
125
|
editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'italic');
|
|
@@ -190,21 +211,3 @@ export default function FloatingTextFormatToolbarPlugin({ anchorElem = document.
|
|
|
190
211
|
const [editor] = useLexicalComposerContext();
|
|
191
212
|
return useFloatingTextFormatToolbar(editor, anchorElem);
|
|
192
213
|
}
|
|
193
|
-
const Menus = styled.div `
|
|
194
|
-
> button {
|
|
195
|
-
display: flex;
|
|
196
|
-
align-items: center;
|
|
197
|
-
justify-content: center;
|
|
198
|
-
|
|
199
|
-
> .iconify {
|
|
200
|
-
font-size: 16px;
|
|
201
|
-
opacity: 0.6;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
&.active {
|
|
205
|
-
> .iconify {
|
|
206
|
-
opacity: 1;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
`;
|
|
@@ -12,6 +12,7 @@ import { LexicalTypeaheadMenuPlugin, useBasicTypeaheadTriggerMatch, } from '@lex
|
|
|
12
12
|
import { $createTextNode, $insertNodes } from 'lexical';
|
|
13
13
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
14
14
|
import debounce from 'lodash/debounce';
|
|
15
|
+
import { Box } from '@mui/material';
|
|
15
16
|
import { $createMentionNode } from '../../nodes/MentionNode';
|
|
16
17
|
import { useEditorConfig } from '../../../config';
|
|
17
18
|
import HighlightStyle from './HighlightStyle';
|
|
@@ -148,7 +149,18 @@ export default function NewMentionsPlugin() {
|
|
|
148
149
|
}, [checkForSlashTriggerMatch, editor]);
|
|
149
150
|
return (_jsxs(_Fragment, { children: [_jsx(LexicalTypeaheadMenuPlugin, { onQueryChange: setQueryString, onSelectOption: onSelectOption, triggerFn: checkForMentionMatch, options: options, menuRenderFn: (anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => {
|
|
150
151
|
return anchorElementRef.current && results.length
|
|
151
|
-
? createPortal(_jsx(
|
|
152
|
+
? createPortal(_jsx(Box, { className: "typeahead-popover mentions-menu", sx: {
|
|
153
|
+
border: 1,
|
|
154
|
+
borderColor: 'divider',
|
|
155
|
+
color: 'text.primary',
|
|
156
|
+
bgcolor: 'background.default',
|
|
157
|
+
'li.selected': {
|
|
158
|
+
bgcolor: 'action.selected',
|
|
159
|
+
},
|
|
160
|
+
'li:hover': {
|
|
161
|
+
bgcolor: 'action.hover',
|
|
162
|
+
},
|
|
163
|
+
}, children: _jsx("ul", { children: options.map((option, i) => (_jsx(MentionsTypeaheadMenuItem, { index: i, isSelected: selectedIndex === i, onClick: () => {
|
|
152
164
|
setHighlightedIndex(i);
|
|
153
165
|
selectOptionAndCleanUp(option);
|
|
154
166
|
}, onMouseEnter: () => {
|
package/lib/main/ui/DropDown.js
CHANGED
|
@@ -10,6 +10,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
10
10
|
import * as React from 'react';
|
|
11
11
|
import { createPortal } from 'react-dom';
|
|
12
12
|
import styled from '@emotion/styled';
|
|
13
|
+
import { Box } from '@mui/material';
|
|
13
14
|
const DropDownContext = React.createContext(null);
|
|
14
15
|
export function DropDownItem({ children, className, onClick, title, }) {
|
|
15
16
|
const ref = useRef(null);
|
|
@@ -68,23 +69,28 @@ function DropDownItems({ children, dropDownRef, onClose, }) {
|
|
|
68
69
|
highlightedItem.current.focus();
|
|
69
70
|
}
|
|
70
71
|
}, [items, highlightedItem]);
|
|
71
|
-
return (_jsx(DropDownContext.Provider, { value: contextValue, children: _jsx(
|
|
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
93
|
}
|
|
73
|
-
const DropdownItems = styled.div `
|
|
74
|
-
.item {
|
|
75
|
-
display: flex;
|
|
76
|
-
align-items: center;
|
|
77
|
-
gap: 8px;
|
|
78
|
-
/* fix: safari dropdown menu item 右侧溢出问题 */
|
|
79
|
-
width: -webkit-fill-available;
|
|
80
|
-
|
|
81
|
-
.iconify {
|
|
82
|
-
flex-shrink: 0;
|
|
83
|
-
font-size: 1.4em;
|
|
84
|
-
color: gray;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
`;
|
|
88
94
|
export default function DropDown({ disabled = false, buttonLabel, buttonAriaLabel, buttonClassName, buttonIconClassName, buttonIconData, children, stopCloseOnClickSelf, }) {
|
|
89
95
|
const dropDownRef = useRef(null);
|
|
90
96
|
const buttonRef = useRef(null);
|
|
@@ -107,7 +107,7 @@ export function ImageEnhancer({ sizeMode, frame, onSizeModeChange, onFrameChange
|
|
|
107
107
|
alignItems: 'center',
|
|
108
108
|
gap: 1,
|
|
109
109
|
...(size?.width && { width: size.width - 36 }),
|
|
110
|
-
}, children: [_jsxs(ToggleButtonGroup, { color: "standard", value: sizeMode, size: "small", exclusive: true, onChange: (_, v) => onSizeModeChange(v), sx: { bgcolor: '
|
|
110
|
+
}, children: [_jsxs(ToggleButtonGroup, { color: "standard", value: sizeMode, size: "small", exclusive: true, onChange: (_, v) => onSizeModeChange(v), sx: { bgcolor: 'background.default' }, children: [_jsx(ToggleButton, { value: "small", children: "Small" }), _jsx(ToggleButton, { value: "best-fit", children: "Best fit" }), _jsx(ToggleButton, { value: "original", children: "Original size" })] }), _jsxs(Select, { value: frame ?? 'none', onChange: (e) => handleFrameChange(e.target.value), sx: { width: { xs: 100, sm: 'auto' } }, MenuProps: { sx: { '.MuiPaper-root': { maxHeight: 400 } }, disablePortal: false }, children: [_jsx(MenuItem, { value: "none", children: "Select frame mockup" }), frames.map((x) => {
|
|
111
111
|
return (_jsx(MenuItem, { value: x.id, children: x.name }, x.id));
|
|
112
112
|
})] }), children] }) }));
|
|
113
113
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/editor",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.36",
|
|
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.
|
|
71
|
+
"@blocklet/pdf": "^2.3.36"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/core": "^7.25.2",
|