@blocklet/editor 2.4.90 → 2.4.92

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.
@@ -5,6 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
+ import '@iconify/iconify';
9
+ import './index.css';
10
+ import './style/editable.css';
8
11
  import { EditorState, Klass, LexicalEditor, LexicalNode } from 'lexical';
9
12
  import React, { MutableRefObject, ReactNode, type JSX } from 'react';
10
13
  export interface BlockletEditorProps extends Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'placeholder' | 'onChange'> {
package/lib/main/index.js CHANGED
@@ -6,6 +6,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  */
9
+ import '@iconify/iconify';
10
+ import './index.css';
11
+ import './style/editable.css';
9
12
  import { cx } from '@emotion/css';
10
13
  import { LexicalComposer } from '@lexical/react/LexicalComposer';
11
14
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
@@ -23,7 +23,6 @@ import { ExcalidrawNode } from './ExcalidrawNode';
23
23
  import { FigmaNode } from './FigmaNode';
24
24
  import { ImageNode } from './ImageNode';
25
25
  import { MermaidNode } from './MermaidNode';
26
- import { KeywordNode } from './KeywordNode';
27
26
  import { MentionNode } from './MentionNode';
28
27
  import { TweetNode } from './TweetNode';
29
28
  import { YouTubeNode } from './YouTubeNode';
@@ -60,7 +59,6 @@ const PlaygroundNodes = [
60
59
  EmojiNode,
61
60
  ExcalidrawNode,
62
61
  EquationNode,
63
- KeywordNode,
64
62
  HorizontalRuleNode,
65
63
  TweetNode,
66
64
  YouTubeNode,
@@ -0,0 +1,476 @@
1
+ /* ============================== toolbar ============================== */
2
+ @container toolbar (max-width: 700px) {
3
+ .toolbar-item.font-size,
4
+ .toolbar-item.code,
5
+ .toolbar-item.alignment,
6
+ .toolbar-item.link,
7
+ .toolbar-item.aide,
8
+ .toolbar-item.color-picker,
9
+ .toolbar-item.text-format-additional {
10
+ display: none !important;
11
+ }
12
+ }
13
+
14
+ .toolbar {
15
+ display: flex;
16
+ margin-bottom: 1px;
17
+ padding: 4px;
18
+ border-top-left-radius: 4px;
19
+ border-top-right-radius: 4px;
20
+ vertical-align: middle;
21
+ overflow: auto;
22
+ container: toolbar / inline-size;
23
+ }
24
+
25
+ .toolbar button.toolbar-item {
26
+ border: 0;
27
+ display: flex;
28
+ background: none;
29
+ border-radius: 8px;
30
+ padding: 8px;
31
+ cursor: pointer;
32
+ vertical-align: middle;
33
+ flex-shrink: 0;
34
+ align-items: center;
35
+ }
36
+
37
+ .toolbar button.toolbar-item:disabled {
38
+ cursor: not-allowed;
39
+ }
40
+
41
+ .toolbar button.toolbar-item.spaced {
42
+ margin-right: 4px;
43
+ }
44
+
45
+ .toolbar button.toolbar-item i.format {
46
+ background-size: contain;
47
+ display: inline-block;
48
+ height: 18px;
49
+ width: 18px;
50
+ vertical-align: -0.25em;
51
+ display: flex;
52
+ opacity: 0.6;
53
+ }
54
+
55
+ .toolbar button.toolbar-item:disabled .icon,
56
+ .toolbar button.toolbar-item:disabled .text,
57
+ .toolbar button.toolbar-item:disabled i.format,
58
+ .toolbar button.toolbar-item:disabled .chevron-down {
59
+ opacity: 0.2;
60
+ }
61
+
62
+ .toolbar button.toolbar-item.active i {
63
+ opacity: 1;
64
+ }
65
+
66
+ .toolbar .toolbar-item.font-family .text {
67
+ display: block;
68
+ max-width: 40px;
69
+ }
70
+
71
+ .toolbar .code-language {
72
+ width: 150px;
73
+ }
74
+
75
+ .toolbar .toolbar-item .text {
76
+ display: flex;
77
+ line-height: 20px;
78
+ vertical-align: middle;
79
+ font-size: 14px;
80
+ color: #777;
81
+ text-overflow: ellipsis;
82
+ overflow: hidden;
83
+ height: 20px;
84
+ text-align: left;
85
+ }
86
+
87
+ .toolbar .toolbar-item .icon {
88
+ display: flex;
89
+ width: 20px;
90
+ height: 20px;
91
+ user-select: none;
92
+ line-height: 16px;
93
+ background-size: contain;
94
+ }
95
+
96
+ .toolbar .toolbar-item .iconify {
97
+ display: flex;
98
+ width: 20px;
99
+ height: 20px;
100
+ }
101
+
102
+ .toolbar i.chevron-down {
103
+ margin-top: 3px;
104
+ margin-left: auto;
105
+ width: 16px;
106
+ height: 16px;
107
+ display: flex;
108
+ user-select: none;
109
+ }
110
+
111
+ .toolbar i.chevron-down.inside {
112
+ width: 16px;
113
+ height: 16px;
114
+ display: flex;
115
+ margin-left: -25px;
116
+ margin-top: 11px;
117
+ margin-right: 10px;
118
+ pointer-events: none;
119
+ }
120
+
121
+ .toolbar .divider {
122
+ width: 1px;
123
+ background-color: #eee;
124
+ margin: 0 4px;
125
+ }
126
+
127
+ /* ============================== typeahead & menu ============================== */
128
+ .typeahead-popover {
129
+ box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.3);
130
+ border-radius: 8px;
131
+ z-index: 1;
132
+ }
133
+
134
+ .typeahead-popover ul {
135
+ padding: 0;
136
+ list-style: none;
137
+ margin: 0;
138
+ border-radius: 8px;
139
+ max-height: 280px;
140
+ overflow-y: scroll;
141
+ }
142
+
143
+ .typeahead-popover ul::-webkit-scrollbar {
144
+ display: none;
145
+ }
146
+
147
+ .typeahead-popover ul {
148
+ -ms-overflow-style: none;
149
+ scrollbar-width: none;
150
+ padding: 8px 0;
151
+ }
152
+
153
+ .typeahead-popover ul li {
154
+ margin: 0;
155
+ min-width: 180px;
156
+ font-size: 14px;
157
+ outline: none;
158
+ cursor: pointer;
159
+ }
160
+
161
+ .typeahead-popover li {
162
+ margin: 0 8px 0 8px;
163
+ padding: 8px;
164
+ cursor: pointer;
165
+ line-height: 16px;
166
+ font-size: 15px;
167
+ display: flex;
168
+ align-content: center;
169
+ flex-direction: row;
170
+ flex-shrink: 0;
171
+ border: 0;
172
+ }
173
+
174
+ .typeahead-popover li.active {
175
+ display: flex;
176
+ width: 20px;
177
+ height: 20px;
178
+ background-size: contain;
179
+ }
180
+
181
+ .typeahead-popover li .text {
182
+ display: flex;
183
+ line-height: 20px;
184
+ flex-grow: 1;
185
+ min-width: 150px;
186
+ }
187
+
188
+ .typeahead-popover li .icon {
189
+ display: flex;
190
+ width: 20px;
191
+ height: 20px;
192
+ user-select: none;
193
+ margin-right: 8px;
194
+ line-height: 16px;
195
+ background-size: contain;
196
+ }
197
+
198
+ /* blocklet embed option - disabled 样式 */
199
+ .typeahead-popover ul li.embed-option-disabled {
200
+ color: #999;
201
+ cursor: default;
202
+ }
203
+
204
+ #typeahead-menu {
205
+ pointer-events: none;
206
+ z-index: 10001;
207
+ }
208
+
209
+ #typeahead-menu > * {
210
+ pointer-events: auto;
211
+ }
212
+
213
+ .component-picker-menu {
214
+ width: 200px;
215
+ }
216
+
217
+ .mentions-menu {
218
+ width: 250px;
219
+ }
220
+
221
+ .auto-embed-menu {
222
+ width: 200px;
223
+ }
224
+
225
+ .emoji-menu {
226
+ width: 200px;
227
+ }
228
+
229
+ /* ============================== link-editor ============================== */
230
+ .link-editor .button.active,
231
+ .toolbar .button.active {
232
+ background-color: rgb(223, 232, 250);
233
+ }
234
+
235
+ .link-editor .link-input {
236
+ display: block;
237
+ width: calc(100% - 24px);
238
+ box-sizing: border-box;
239
+ margin: 8px 12px;
240
+ padding: 8px 12px;
241
+ border-radius: 15px;
242
+ font-size: 15px;
243
+ border: 0;
244
+ outline: 0;
245
+ position: relative;
246
+ font-family: inherit;
247
+ }
248
+
249
+ .link-editor div.link-edit {
250
+ width: 35px;
251
+ vertical-align: -0.25em;
252
+ position: absolute;
253
+ right: 0;
254
+ top: 0;
255
+ bottom: 0;
256
+ cursor: pointer;
257
+ font-size: 20px;
258
+ display: flex;
259
+ align-items: center;
260
+ justify-content: center;
261
+ }
262
+
263
+ .link-editor .link-input a {
264
+ text-decoration: none;
265
+ display: block;
266
+ white-space: nowrap;
267
+ overflow: hidden;
268
+ margin-right: 30px;
269
+ text-overflow: ellipsis;
270
+ }
271
+
272
+ .link-editor .link-input a:hover {
273
+ text-decoration: underline;
274
+ }
275
+
276
+ .link-editor .font-size-wrapper,
277
+ .link-editor .font-family-wrapper {
278
+ display: flex;
279
+ margin: 0 4px;
280
+ }
281
+
282
+ .link-editor select {
283
+ padding: 6px;
284
+ border: none;
285
+ background-color: rgba(0, 0, 0, 0.075);
286
+ border-radius: 4px;
287
+ }
288
+
289
+ /* ============================== dropdown ============================== */
290
+ .mention {
291
+ color: #666;
292
+ }
293
+
294
+ .mention:hover {
295
+ text-decoration: underline;
296
+ }
297
+
298
+ .mention:before {
299
+ display: inline-block;
300
+ content: '@';
301
+ }
302
+
303
+ .mention-typeahead-item-avatar {
304
+ width: 24px;
305
+ height: 24px;
306
+ border-radius: 15px;
307
+ background-size: cover;
308
+ }
309
+
310
+ .dropdown {
311
+ z-index: 10001;
312
+ display: block;
313
+ position: fixed;
314
+ border-radius: 8px;
315
+ min-height: 40px;
316
+ }
317
+
318
+ .dropdown .item {
319
+ padding: 8px;
320
+ cursor: pointer;
321
+ line-height: 16px;
322
+ font-size: 15px;
323
+ display: flex;
324
+ align-content: center;
325
+ flex-direction: row;
326
+ flex-shrink: 0;
327
+ justify-content: space-between;
328
+ border: 0;
329
+ max-width: 250px;
330
+ min-width: 100px;
331
+ }
332
+
333
+ .dropdown .item.fontsize-item,
334
+ .dropdown .item.fontsize-item .text {
335
+ min-width: unset;
336
+ }
337
+
338
+ .dropdown .item .active {
339
+ display: flex;
340
+ width: 20px;
341
+ height: 20px;
342
+ background-size: contain;
343
+ }
344
+
345
+ .dropdown .item:first-child {
346
+ margin-top: 8px;
347
+ }
348
+
349
+ .dropdown .item:last-child {
350
+ margin-bottom: 8px;
351
+ }
352
+
353
+ .dropdown .item .text {
354
+ display: flex;
355
+ line-height: 20px;
356
+ flex-grow: 1;
357
+ min-width: 150px;
358
+ }
359
+
360
+ .dropdown .item .icon {
361
+ display: flex;
362
+ width: 20px;
363
+ height: 20px;
364
+ user-select: none;
365
+ margin-right: 12px;
366
+ line-height: 16px;
367
+ background-size: contain;
368
+ background-position: center;
369
+ background-repeat: no-repeat;
370
+ }
371
+
372
+ .dropdown .divider {
373
+ width: auto;
374
+ margin: 4px 8px;
375
+ height: 1px;
376
+ }
377
+
378
+ .dropdown-button-text {
379
+ margin-left: 8px;
380
+ }
381
+
382
+ @media screen and (max-width: 1100px) {
383
+ .dropdown-button-text {
384
+ display: none !important;
385
+ }
386
+ .font-size .dropdown-button-text {
387
+ display: flex !important;
388
+ }
389
+ .code-language .dropdown-button-text {
390
+ display: flex !important;
391
+ }
392
+ }
393
+
394
+ /* ============================== actions & table-cell-action ============================== */
395
+
396
+ .actions {
397
+ position: absolute;
398
+ text-align: right;
399
+ padding: 10px;
400
+ bottom: 0;
401
+ right: 0;
402
+ }
403
+
404
+ .actions.tree-view {
405
+ border-bottom-left-radius: 0;
406
+ border-bottom-right-radius: 0;
407
+ }
408
+
409
+ .actions i {
410
+ background-size: contain;
411
+ display: inline-block;
412
+ height: 15px;
413
+ width: 15px;
414
+ vertical-align: -0.25em;
415
+ }
416
+
417
+ .action-button {
418
+ background-color: #eee;
419
+ border: 0;
420
+ padding: 8px 12px;
421
+ position: relative;
422
+ margin-left: 5px;
423
+ border-radius: 15px;
424
+ color: #222;
425
+ cursor: pointer;
426
+ display: flex;
427
+ }
428
+
429
+ .action-button .MuiLoadingButton-loadingIndicator {
430
+ position: relative;
431
+ left: 0;
432
+ margin-right: 8px;
433
+ }
434
+
435
+ .action-button:hover {
436
+ background-color: #ddd;
437
+ color: #000;
438
+ }
439
+
440
+ .action-button-mic.active {
441
+ animation: mic-pulsate-color 3s infinite;
442
+ }
443
+ button.action-button:disabled {
444
+ cursor: not-allowed;
445
+ }
446
+
447
+ .table-cell-action-button-container {
448
+ position: absolute;
449
+ z-index: 3;
450
+ top: 0;
451
+ left: 0;
452
+ will-change: transform;
453
+ }
454
+ .table-cell-action-button-container.table-cell-action-button-container--active {
455
+ pointer-events: auto;
456
+ opacity: 1;
457
+ }
458
+ .table-cell-action-button-container.table-cell-action-button-container--inactive {
459
+ pointer-events: none;
460
+ opacity: 0;
461
+ }
462
+
463
+ .table-cell-action-button {
464
+ display: flex;
465
+ justify-content: center;
466
+ align-items: center;
467
+ border: 0;
468
+ position: absolute;
469
+ top: 10px;
470
+ right: 10px;
471
+ border-radius: 15px;
472
+ color: #222;
473
+ display: inline-block;
474
+ cursor: pointer;
475
+ opacity: 0.75;
476
+ }
@@ -0,0 +1,5 @@
1
+ import '../index.css';
2
+ import { type JSX } from 'react';
3
+ import { EditorViewerProps } from './types';
4
+ export declare function BlockletEditorViewer({ editorState, markdown, ...props }: EditorViewerProps): JSX.Element;
5
+ export type { EditorViewerProps };
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import '../index.css';
3
+ import { cx } from '@emotion/css';
4
+ import { LexicalComposer } from '@lexical/react/LexicalComposer';
5
+ import { $convertFromMarkdownString } from '@lexical/markdown';
6
+ import { useTheme } from '@mui/material';
7
+ import PlaygroundNodes from '../nodes/PlaygroundNodes';
8
+ import { useCustomTheme } from '../themes/customTheme';
9
+ import { PLAYGROUND_TRANSFORMERS } from '../plugins/MarkdownTransformers';
10
+ import { EditorViewer } from './viewer';
11
+ import { EditorRoot } from '../editor-root';
12
+ export function BlockletEditorViewer({ editorState, markdown, ...props }) {
13
+ const muiTheme = useTheme();
14
+ const theme = useCustomTheme();
15
+ const initialConfig = {
16
+ namespace: 'Playground',
17
+ editorState: markdown && editorState ? () => $convertFromMarkdownString(editorState, PLAYGROUND_TRANSFORMERS) : editorState,
18
+ nodes: PlaygroundNodes,
19
+ editable: false,
20
+ onError: (error) => {
21
+ throw error;
22
+ },
23
+ theme,
24
+ };
25
+ return (_jsx(LexicalComposer, { initialConfig: initialConfig, children: _jsx(EditorRoot, { className: cx(props.className, 'be-shell'), "data-mode": muiTheme.palette.mode, children: _jsx(EditorViewer, { ...props }) }) }, muiTheme.palette.mode));
26
+ }
@@ -0,0 +1,14 @@
1
+ import { EditorState, LexicalEditor } from 'lexical';
2
+ import { MutableRefObject, ReactNode } from 'react';
3
+ export interface EditorViewerProps {
4
+ editorState?: string;
5
+ markdown?: boolean;
6
+ children?: ReactNode;
7
+ prepend?: ReactNode;
8
+ onChange?: (editorState: EditorState, editor: LexicalEditor) => void;
9
+ editorRef?: React.RefCallback<LexicalEditor> | MutableRefObject<LexicalEditor | null>;
10
+ onReady?: () => void;
11
+ enableHeadingsIdPlugin?: boolean;
12
+ onCheckboxChange?: (content: string) => Promise<any>;
13
+ className?: string;
14
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { type JSX } from 'react';
2
+ import { EditorViewerProps } from './types';
3
+ export declare function EditorViewer({ children, prepend, onChange, editorRef, onReady, enableHeadingsIdPlugin, onCheckboxChange, }: EditorViewerProps): JSX.Element;
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx } from '@emotion/css';
3
+ import { CheckListPlugin } from '@lexical/react/LexicalCheckListPlugin';
4
+ import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
5
+ import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
6
+ import { ListPlugin } from '@lexical/react/LexicalListPlugin';
7
+ import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';
8
+ import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
9
+ import useHasNodes from '../hooks/useHasNodes';
10
+ import ClickableLinkPlugin from '../plugins/ClickableLinkPlugin';
11
+ import CodeHighlightPlugin from '../plugins/CodeHighlightPlugin';
12
+ import CollapsiblePlugin from '../plugins/CollapsiblePlugin';
13
+ import ListMaxIndentLevelPlugin from '../plugins/ListMaxIndentLevelPlugin';
14
+ import MarkdownShortcutPlugin from '../plugins/MarkdownShortcutPlugin';
15
+ import TabFocusPlugin from '../plugins/TabFocusPlugin';
16
+ import ContentEditable from '../ui/ContentEditable';
17
+ import { EditorRefPlugin } from '../../ext/LexicalEditorRefPlugin';
18
+ import { HeadingsIdPlugin } from '../../ext/HeadingsIdPlugin';
19
+ import { EditorReadyPlugin } from '../../ext/EditorReadyPlugin';
20
+ import { BlurTextPlugin } from '../../ext/BlurTextPlugin';
21
+ import { useResponsiveTable } from '../hooks/useResponsiveTable';
22
+ import { EditorHolderPlugin } from '../../ext/EditorHolderPlugin';
23
+ import { StyledEditorContent } from '../styled-editor-content';
24
+ import { CodeCopyPlugin } from '../../ext/CodeCopyPlugin';
25
+ import CheckboxPlugin from '../../ext/CheckboxPlugin';
26
+ export function EditorViewer({ children, prepend, onChange, editorRef, onReady, enableHeadingsIdPlugin, onCheckboxChange, }) {
27
+ useResponsiveTable();
28
+ const hasNodes = useHasNodes();
29
+ return (_jsxs(_Fragment, { children: [prepend, _jsx(StyledEditorContent, { className: "be-content", children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: cx('be-editable', 'notranslate') }), ErrorBoundary: LexicalErrorBoundary }) }), _jsx(MarkdownShortcutPlugin, {}), hasNodes('code', 'code-highlight') && _jsx(CodeHighlightPlugin, {}), hasNodes('code') && _jsx(CodeCopyPlugin, {}), hasNodes('list', 'listitem') && _jsx(ListPlugin, {}), hasNodes('list', 'listitem') && _jsx(CheckListPlugin, {}), hasNodes('list', 'listitem') && _jsx(ListMaxIndentLevelPlugin, { maxDepth: 7 }), hasNodes('link') && _jsx(LinkPlugin, {}), _jsx(BlurTextPlugin, {}), hasNodes('link') && _jsx(ClickableLinkPlugin, {}), _jsx(TabFocusPlugin, {}), hasNodes('collapsible-container', 'collapsible-content', 'collapsible-title') && _jsx(CollapsiblePlugin, {}), onChange && _jsx(OnChangePlugin, { onChange: onChange }), enableHeadingsIdPlugin && _jsx(HeadingsIdPlugin, {}), _jsx(EditorHolderPlugin, {}), editorRef && _jsx(EditorRefPlugin, { editorRef: editorRef }), onReady && _jsx(EditorReadyPlugin, { onReady: onReady }), _jsx(CheckboxPlugin, { send: onCheckboxChange }), children] }));
30
+ }
package/lib/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { Completions, FetchTemplateTags, FetchTemplates } from './ext/Aide/types';
1
+ import type { Completions, FetchTemplateTags, FetchTemplates } from './ext/Aide/types';
2
+ export type { EditorState } from 'lexical';
2
3
  export * from './ext/Aide/types';
3
4
  export interface User {
4
5
  did: string;
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@blocklet/editor",
3
- "version": "2.4.90",
3
+ "version": "2.4.92",
4
4
  "main": "lib/index.js",
5
+ "sideEffects": false,
5
6
  "publishConfig": {
6
7
  "access": "public"
7
8
  },
@@ -64,6 +65,7 @@
64
65
  "mermaid": "^11.6.0",
65
66
  "path-parser": "^6.1.0",
66
67
  "react-error-boundary": "^3.1.4",
68
+ "react-lazy-with-preload": "^2.2.1",
67
69
  "react-player": "^2.16.0",
68
70
  "react-popper": "^2.3.0",
69
71
  "shiki": "1.14.1",
@@ -71,7 +73,7 @@
71
73
  "ufo": "^1.5.4",
72
74
  "url-join": "^4.0.1",
73
75
  "zustand": "^4.5.5",
74
- "@blocklet/pdf": "2.4.90"
76
+ "@blocklet/pdf": "2.4.92"
75
77
  },
76
78
  "devDependencies": {
77
79
  "@babel/core": "^7.25.2",
@@ -1,9 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
- import { type JSX } from 'react';
9
- export default function Settings(): JSX.Element;
@@ -1,39 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- // eslint-disable-next-line unicorn/filename-case
3
- /**
4
- * Copyright (c) Meta Platforms, Inc. and affiliates.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- *
9
- */
10
- import { useMemo, useState } from 'react';
11
- import { isDevPlayground } from './appSettings';
12
- import { useSettings } from './context/SettingsContext';
13
- import Switch from './ui/Switch';
14
- export default function Settings() {
15
- const windowLocation = window.location;
16
- const { setOption, settings: { measureTypingPerf, isRichText, isMaxLength, isCharLimit, isCharLimitUtf8, isAutocomplete, disableBeforeInput, showTableOfContents, }, } = useSettings();
17
- const [showSettings, setShowSettings] = useState(false);
18
- const [isSplitScreen, search] = useMemo(() => {
19
- const parentWindow = window.parent;
20
- const _search = windowLocation.search;
21
- const _isSplitScreen = parentWindow && parentWindow.location.pathname === '/split/';
22
- return [_isSplitScreen, _search];
23
- }, [windowLocation]);
24
- return (_jsxs(_Fragment, { children: [_jsx("span", { id: "options-button", className: `editor-dev-button ${showSettings ? 'active' : ''}`, onClick: () => setShowSettings(!showSettings) }), showSettings ? (_jsxs("div", { className: "switches", children: [isDevPlayground && (_jsx(Switch, { onClick: () => {
25
- if (isSplitScreen) {
26
- window.parent.location.href = `/${search}`;
27
- }
28
- else {
29
- window.location.href = `/split/${search}`;
30
- }
31
- }, checked: isSplitScreen, text: "Split Screen" })), _jsx(Switch, { onClick: () => setOption('measureTypingPerf', !measureTypingPerf), checked: measureTypingPerf, text: "Measure Perf" }), _jsx(Switch, { onClick: () => {
32
- setOption('isRichText', !isRichText);
33
- }, checked: isRichText, text: "Rich Text" }), _jsx(Switch, { onClick: () => setOption('isCharLimit', !isCharLimit), checked: isCharLimit, text: "Char Limit" }), _jsx(Switch, { onClick: () => setOption('isCharLimitUtf8', !isCharLimitUtf8), checked: isCharLimitUtf8, text: "Char Limit (UTF-8)" }), _jsx(Switch, { onClick: () => setOption('isMaxLength', !isMaxLength), checked: isMaxLength, text: "Max Length" }), _jsx(Switch, { onClick: () => setOption('isAutocomplete', !isAutocomplete), checked: isAutocomplete, text: "Autocomplete" }), _jsx(Switch, { onClick: () => {
34
- setOption('disableBeforeInput', !disableBeforeInput);
35
- setTimeout(() => window.location.reload(), 500);
36
- }, checked: disableBeforeInput, text: "Legacy Events" }), _jsx(Switch, { onClick: () => {
37
- setOption('showTableOfContents', !showTableOfContents);
38
- }, checked: showTableOfContents, text: "Table Of Contents" })] })) : null] }));
39
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
- import { type JSX } from 'react';
9
- export default function KeywordsPlugin(): JSX.Element | null;