@sveltia/ui 0.89.2 → 0.89.3
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/dist/components/checkbox/checkbox.svelte +5 -8
- package/dist/components/emoji/emoji-suggestions.svelte +7 -7
- package/dist/components/grid/grid-col-header.svelte +4 -0
- package/dist/components/grid/grid-head.svelte +1 -1
- package/dist/components/grid/grid-head.svelte.d.ts +1 -1
- package/dist/components/radio/radio.svelte +9 -9
- package/dist/components/resizable-pane/resizable-pane-group.svelte +5 -20
- package/dist/components/resizable-pane/sizing.d.ts +6 -0
- package/dist/components/resizable-pane/sizing.js +31 -0
- package/dist/components/text-editor/code-editor.svelte +22 -39
- package/dist/components/text-editor/constants.js +3 -3
- package/dist/components/text-editor/conversion/editor-components.d.ts +5 -0
- package/dist/components/text-editor/conversion/editor-components.js +228 -0
- package/dist/components/text-editor/{html.d.ts → conversion/html.d.ts} +1 -1
- package/dist/components/text-editor/{html.js → conversion/html.js} +2 -2
- package/dist/components/text-editor/conversion/import.d.ts +12 -0
- package/dist/components/text-editor/conversion/import.js +327 -0
- package/dist/components/text-editor/conversion/paste.d.ts +4 -0
- package/dist/components/text-editor/conversion/paste.js +166 -0
- package/dist/components/text-editor/{transformers → conversion/transformers}/raw-syntax.js +4 -4
- package/dist/components/text-editor/conversion/transformers/table.js +342 -0
- package/dist/components/text-editor/conversion/update.d.ts +6 -0
- package/dist/components/text-editor/conversion/update.js +125 -0
- package/dist/components/text-editor/core.d.ts +50 -26
- package/dist/components/text-editor/core.js +133 -1694
- package/dist/components/text-editor/editing/caret.d.ts +4 -0
- package/dist/components/text-editor/editing/caret.js +248 -0
- package/dist/components/text-editor/editing/commands.d.ts +5 -0
- package/dist/components/text-editor/editing/commands.js +205 -0
- package/dist/components/text-editor/editing/link.d.ts +19 -0
- package/dist/components/text-editor/editing/link.js +222 -0
- package/dist/components/text-editor/{raw-markdown.d.ts → editing/raw-markdown.d.ts} +3 -3
- package/dist/components/text-editor/{raw-markdown.js → editing/raw-markdown.js} +2 -2
- package/dist/components/text-editor/editing/selection.d.ts +5 -0
- package/dist/components/text-editor/editing/selection.js +122 -0
- package/dist/components/text-editor/editing/single-line.d.ts +8 -0
- package/dist/components/text-editor/editing/single-line.js +190 -0
- package/dist/components/text-editor/{table.js → editing/table.js} +1 -1
- package/dist/components/text-editor/lexical-root.svelte +61 -10
- package/dist/components/text-editor/shiki/preload.d.ts +1 -0
- package/dist/components/text-editor/shiki/preload.js +30 -0
- package/dist/components/text-editor/shiki/version.d.ts +1 -1
- package/dist/components/text-editor/shiki/version.js +1 -1
- package/dist/components/text-editor/store.svelte.d.ts +5 -0
- package/dist/components/text-editor/store.svelte.js +55 -1
- package/dist/components/text-editor/text-editor.svelte +29 -41
- package/dist/components/text-editor/toolbar/align-menu-button.svelte +1 -1
- package/dist/components/text-editor/toolbar/code-language-switcher.svelte +2 -1
- package/dist/components/text-editor/toolbar/format-text-button.svelte +6 -2
- package/dist/components/text-editor/toolbar/insert-component.js +1 -1
- package/dist/components/text-editor/toolbar/insert-horizontal-rule-button.svelte +4 -4
- package/dist/components/text-editor/toolbar/insert-link-button.svelte +3 -2
- package/dist/components/text-editor/toolbar/insert-table-button.svelte +7 -3
- package/dist/components/text-editor/toolbar/table-action-menu.svelte +3 -3
- package/dist/components/text-editor/toolbar/text-editor-toolbar.svelte +1 -1
- package/dist/components/text-editor/toolbar/toggle-block-menu-item.svelte +2 -2
- package/dist/components/text-editor/utils.d.ts +1 -0
- package/dist/components/text-editor/utils.js +17 -0
- package/dist/components/text-editor/{emoji-autocomplete.svelte → widgets/emoji-autocomplete.svelte} +3 -3
- package/dist/components/text-editor/{floating-link-editor.svelte → widgets/floating-link-editor.svelte} +36 -79
- package/dist/components/text-editor/{table-cell-menu-button.svelte → widgets/table-cell-menu-button.svelte} +15 -5
- package/dist/components/text-field/date-time-input.svelte +8 -8
- package/dist/components/text-field/text-area.svelte +10 -10
- package/dist/components/text-field/text-input.svelte +7 -7
- package/dist/components/util/popup.svelte +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/services/label.d.ts +8 -0
- package/dist/services/label.js +15 -0
- package/dist/services/popup-position.d.ts +9 -0
- package/dist/services/popup-position.js +52 -55
- package/dist/styles/mixins.scss +69 -0
- package/package.json +5 -3
- package/dist/components/text-editor/transformers/table.js +0 -296
- /package/dist/components/text-editor/{markdown.d.ts → conversion/markdown.d.ts} +0 -0
- /package/dist/components/text-editor/{markdown.js → conversion/markdown.js} +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/block-escape.d.ts +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/block-escape.js +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/code.d.ts +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/code.js +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/formatted-code.d.ts +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/formatted-code.js +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/hr.d.ts +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/hr.js +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/inline-code.d.ts +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/inline-code.js +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/link.d.ts +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/link.js +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/raw-syntax.d.ts +0 -0
- /package/dist/components/text-editor/{transformers → conversion/transformers}/table.d.ts +0 -0
- /package/dist/components/text-editor/{alignment.d.ts → editing/alignment.d.ts} +0 -0
- /package/dist/components/text-editor/{alignment.js → editing/alignment.js} +0 -0
- /package/dist/components/text-editor/{block.d.ts → editing/block.d.ts} +0 -0
- /package/dist/components/text-editor/{block.js → editing/block.js} +0 -0
- /package/dist/components/text-editor/{table.d.ts → editing/table.d.ts} +0 -0
- /package/dist/components/text-editor/{emoji-autocomplete.svelte.d.ts → widgets/emoji-autocomplete.svelte.d.ts} +0 -0
- /package/dist/components/text-editor/{floating-link-editor.svelte.d.ts → widgets/floating-link-editor.svelte.d.ts} +0 -0
- /package/dist/components/text-editor/{table-cell-menu-button.svelte.d.ts → widgets/table-cell-menu-button.svelte.d.ts} +0 -0
|
@@ -9,15 +9,19 @@
|
|
|
9
9
|
import TextArea from '../text-field/text-area.svelte';
|
|
10
10
|
import Toast from '../toast/toast.svelte';
|
|
11
11
|
import { BLOCK_BUTTON_TYPES, INLINE_BUTTON_TYPES } from './constants.js';
|
|
12
|
-
import { loadCodeHighlighter } from './
|
|
13
|
-
import EmojiAutocomplete from './emoji-autocomplete.svelte';
|
|
14
|
-
import FloatingLinkEditor from './floating-link-editor.svelte';
|
|
12
|
+
import { loadCodeHighlighter } from './shiki/preload.js';
|
|
13
|
+
import EmojiAutocomplete from './widgets/emoji-autocomplete.svelte';
|
|
14
|
+
import FloatingLinkEditor from './widgets/floating-link-editor.svelte';
|
|
15
15
|
import LexicalRoot from './lexical-root.svelte';
|
|
16
|
-
import TableCellMenuButton from './table-cell-menu-button.svelte';
|
|
17
|
-
import {
|
|
16
|
+
import TableCellMenuButton from './widgets/table-cell-menu-button.svelte';
|
|
17
|
+
import {
|
|
18
|
+
getBlockType,
|
|
19
|
+
getRawTextState,
|
|
20
|
+
registerRawTextSingleLine,
|
|
21
|
+
} from './editing/raw-markdown.js';
|
|
18
22
|
import { highlightCodeToTokens } from './shiki/facade.js';
|
|
19
23
|
import { getCodeTheme, onCodeThemeChange } from './shiki/theme.js';
|
|
20
|
-
import { createEditorStore } from './store.svelte.js';
|
|
24
|
+
import { createEditorStore, syncEditorProps } from './store.svelte.js';
|
|
21
25
|
import TextEditorToolbar from './toolbar/text-editor-toolbar.svelte';
|
|
22
26
|
|
|
23
27
|
/**
|
|
@@ -284,44 +288,28 @@
|
|
|
284
288
|
return registerRawTextSingleLine(textArea);
|
|
285
289
|
});
|
|
286
290
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
// The root initializes the editor before these effects first run, and stays initialized
|
|
299
|
-
/* v8 ignore next */
|
|
300
|
-
if (!editorStore.initialized) {
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
const newValue = value;
|
|
305
|
-
|
|
306
|
-
untrack(() => {
|
|
307
|
-
editorStore.inputValue = newValue;
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
$effect(() => {
|
|
312
|
-
// The root initializes the editor before these effects first run, and stays initialized
|
|
313
|
-
/* v8 ignore next */
|
|
314
|
-
if (!editorStore.initialized) {
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
const newValue = editorStore.inputValue;
|
|
319
|
-
|
|
320
|
-
untrack(() => {
|
|
291
|
+
syncEditorProps(editorStore, {
|
|
292
|
+
/**
|
|
293
|
+
* Pass the value to the editor.
|
|
294
|
+
* @returns {string} Value.
|
|
295
|
+
*/
|
|
296
|
+
getInputValue: () => value,
|
|
297
|
+
/**
|
|
298
|
+
* Update the value with the editor’s.
|
|
299
|
+
* @param {string} newValue New value.
|
|
300
|
+
*/
|
|
301
|
+
setValue: (newValue) => {
|
|
321
302
|
if (value !== newValue) {
|
|
322
303
|
value = newValue;
|
|
323
304
|
}
|
|
324
|
-
}
|
|
305
|
+
},
|
|
306
|
+
/**
|
|
307
|
+
* Update the `pending` prop.
|
|
308
|
+
* @param {boolean} newValue New value.
|
|
309
|
+
*/
|
|
310
|
+
setPending: (newValue) => {
|
|
311
|
+
pending = newValue;
|
|
312
|
+
},
|
|
325
313
|
});
|
|
326
314
|
</script>
|
|
327
315
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import MenuItemRadio from '../../menu/menu-item-radio.svelte';
|
|
13
13
|
import Menu from '../../menu/menu.svelte';
|
|
14
14
|
import { ALIGNMENT_OPTIONS } from '../constants.js';
|
|
15
|
-
import { focusEditor } from '../
|
|
15
|
+
import { focusEditor } from '../editing/caret.js';
|
|
16
16
|
import { waitForMenuToClose } from './menu.js';
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
import Option from '../../listbox/option.svelte';
|
|
7
7
|
import Select from '../../select/select.svelte';
|
|
8
8
|
import { getBackgroundUpdateTags } from '../background-update.js';
|
|
9
|
-
import { focusEditor
|
|
9
|
+
import { focusEditor } from '../editing/caret.js';
|
|
10
|
+
import { loadCodeHighlighter } from '../shiki/preload.js';
|
|
10
11
|
import { LANGUAGES } from '../shiki/generated.js';
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -5,8 +5,12 @@
|
|
|
5
5
|
import Button from '../../button/button.svelte';
|
|
6
6
|
import Icon from '../../icon/icon.svelte';
|
|
7
7
|
import { AVAILABLE_BUTTONS } from '../constants.js';
|
|
8
|
-
import { focusEditor } from '../
|
|
9
|
-
import {
|
|
8
|
+
import { focusEditor } from '../editing/caret.js';
|
|
9
|
+
import {
|
|
10
|
+
editRawText,
|
|
11
|
+
registerRawTextShortcut,
|
|
12
|
+
toggleInlineFormat,
|
|
13
|
+
} from '../editing/raw-markdown.js';
|
|
10
14
|
|
|
11
15
|
/**
|
|
12
16
|
* @import { TextEditorFormatType, TextEditorStore } from '../../../typedefs.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { $createParagraphNode as createParagraphNode, $insertNodes as insertNodes } from 'lexical';
|
|
2
|
-
import { insertComponent } from '../raw-markdown.js';
|
|
2
|
+
import { insertComponent } from '../editing/raw-markdown.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @import { TextEditorComponent, TextEditorStore } from '../../../typedefs.js';
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
import { getContext } from 'svelte';
|
|
9
9
|
import Button from '../../button/button.svelte';
|
|
10
10
|
import Icon from '../../icon/icon.svelte';
|
|
11
|
-
import { $insertHorizontalRule as insertHorizontalRule } from '../block.js';
|
|
11
|
+
import { $insertHorizontalRule as insertHorizontalRule } from '../editing/block.js';
|
|
12
12
|
import { AVAILABLE_BUTTONS } from '../constants.js';
|
|
13
|
-
import { focusEditor } from '../
|
|
14
|
-
import { editRawText, insertMarkdown } from '../raw-markdown.js';
|
|
15
|
-
import { HORIZONTAL_RULE_MARKDOWN } from '../transformers/hr.js';
|
|
13
|
+
import { focusEditor } from '../editing/caret.js';
|
|
14
|
+
import { editRawText, insertMarkdown } from '../editing/raw-markdown.js';
|
|
15
|
+
import { HORIZONTAL_RULE_MARKDOWN } from '../conversion/transformers/hr.js';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @import { TextEditorStore } from '../../../typedefs.js';
|
|
@@ -22,13 +22,14 @@
|
|
|
22
22
|
import Icon from '../../icon/icon.svelte';
|
|
23
23
|
import TextInput from '../../text-field/text-input.svelte';
|
|
24
24
|
import { AVAILABLE_BUTTONS, OPEN_LINK_EDITOR_COMMAND } from '../constants.js';
|
|
25
|
-
import { focusEditor
|
|
25
|
+
import { focusEditor } from '../editing/caret.js';
|
|
26
|
+
import { isSafeLinkURL } from '../editing/link.js';
|
|
26
27
|
import {
|
|
27
28
|
editRawText,
|
|
28
29
|
getRawTextState,
|
|
29
30
|
insertLink,
|
|
30
31
|
registerRawTextShortcut,
|
|
31
|
-
} from '../raw-markdown.js';
|
|
32
|
+
} from '../editing/raw-markdown.js';
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* @import { TextEditorStore } from '../../../typedefs.js';
|
|
@@ -13,9 +13,13 @@
|
|
|
13
13
|
import Icon from '../../icon/icon.svelte';
|
|
14
14
|
import NumberInput from '../../text-field/number-input.svelte';
|
|
15
15
|
import { AVAILABLE_BUTTONS, DEFAULT_TABLE_SIZE, MAX_TABLE_SIZE } from '../constants.js';
|
|
16
|
-
import { focusEditor } from '../
|
|
17
|
-
import { editRawText, insertMarkdown } from '../raw-markdown.js';
|
|
18
|
-
import {
|
|
16
|
+
import { focusEditor } from '../editing/caret.js';
|
|
17
|
+
import { editRawText, insertMarkdown } from '../editing/raw-markdown.js';
|
|
18
|
+
import {
|
|
19
|
+
$insertTable as insertTable,
|
|
20
|
+
createTableMarkdown,
|
|
21
|
+
parseTableSize,
|
|
22
|
+
} from '../editing/table.js';
|
|
19
23
|
|
|
20
24
|
/**
|
|
21
25
|
* @import { TextEditorStore } from '../../../typedefs.js';
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
import Divider from '../../divider/divider.svelte';
|
|
10
10
|
import MenuItem from '../../menu/menu-item.svelte';
|
|
11
11
|
import Menu from '../../menu/menu.svelte';
|
|
12
|
-
import { focusEditor } from '../
|
|
13
|
-
import { isRightToLeftTable, $runTableAction as runTableAction } from '../table.js';
|
|
12
|
+
import { focusEditor } from '../editing/caret.js';
|
|
13
|
+
import { isRightToLeftTable, $runTableAction as runTableAction } from '../editing/table.js';
|
|
14
14
|
import { waitForMenuToClose } from './menu.js';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* @import { TextEditorStore } from '../../../typedefs.js';
|
|
18
|
-
* @import { TableAction } from '../table.js';
|
|
18
|
+
* @import { TableAction } from '../editing/table.js';
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import MenuButton from '../../menu/menu-button.svelte';
|
|
11
11
|
import Menu from '../../menu/menu.svelte';
|
|
12
12
|
import { AVAILABLE_BUTTONS, BLOCK_BUTTON_TYPES, INLINE_BUTTON_TYPES } from '../constants.js';
|
|
13
|
-
import { isInlineComponent } from '../
|
|
13
|
+
import { isInlineComponent } from '../conversion/editor-components.js';
|
|
14
14
|
import CodeLanguageSwitcher from './code-language-switcher.svelte';
|
|
15
15
|
import AlignMenuButton from './align-menu-button.svelte';
|
|
16
16
|
import FormatTextButton from './format-text-button.svelte';
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
import Icon from '../../icon/icon.svelte';
|
|
16
16
|
import MenuItemCheckbox from '../../menu/menu-item-checkbox.svelte';
|
|
17
17
|
import { AVAILABLE_BUTTONS } from '../constants.js';
|
|
18
|
-
import { focusEditor } from '../
|
|
19
|
-
import { editRawText, setBlockType } from '../raw-markdown.js';
|
|
18
|
+
import { focusEditor } from '../editing/caret.js';
|
|
19
|
+
import { editRawText, setBlockType } from '../editing/raw-markdown.js';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* @import { TextEditorBlockType, TextEditorStore } from '../../../typedefs.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function mergeUnregisters(...unregisters: ((() => void) | undefined | null)[]): () => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers shared by the editor modules.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Combine the given cleanup handlers into one, which calls them in the given order. Missing
|
|
7
|
+
* handlers, like those of the features that are not enabled, are skipped.
|
|
8
|
+
* @param {...((() => void) | undefined | null)} unregisters Cleanup handlers.
|
|
9
|
+
* @returns {() => void} Combined cleanup handler.
|
|
10
|
+
*/
|
|
11
|
+
export const mergeUnregisters = (...unregisters) => {
|
|
12
|
+
const handlers = unregisters.filter((unregister) => typeof unregister === 'function');
|
|
13
|
+
|
|
14
|
+
return () => {
|
|
15
|
+
handlers.forEach((unregister) => unregister());
|
|
16
|
+
};
|
|
17
|
+
};
|
package/dist/components/text-editor/{emoji-autocomplete.svelte → widgets/emoji-autocomplete.svelte}
RENAMED
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
KEY_TAB_COMMAND,
|
|
21
21
|
} from 'lexical';
|
|
22
22
|
import { getContext } from 'svelte';
|
|
23
|
-
import { detectEmojiTrigger, getEmojiInsertText } from '
|
|
24
|
-
import EmojiSuggestions from '
|
|
23
|
+
import { detectEmojiTrigger, getEmojiInsertText } from '../../emoji/emoji.js';
|
|
24
|
+
import EmojiSuggestions from '../../emoji/emoji-suggestions.svelte';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* @import { EmojiAnchorRect, EmojiEntry, EmojiTrigger, TextEditorStore } from '
|
|
27
|
+
* @import { EmojiAnchorRect, EmojiEntry, EmojiTrigger, TextEditorStore } from '../../../typedefs.js';
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
/**
|
|
@@ -12,8 +12,6 @@
|
|
|
12
12
|
-->
|
|
13
13
|
<script>
|
|
14
14
|
import { $isLinkNode as isLinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link';
|
|
15
|
-
import { createDOMRange } from '@lexical/selection';
|
|
16
|
-
import { $findMatchingParent as findMatchingParent } from '@lexical/utils';
|
|
17
15
|
import { _, isRTL } from '@sveltia/i18n';
|
|
18
16
|
import { matchesShortcuts } from '@sveltia/utils/events';
|
|
19
17
|
import { isURL } from '@sveltia/utils/string';
|
|
@@ -28,16 +26,21 @@
|
|
|
28
26
|
$setSelection as setSelection,
|
|
29
27
|
} from 'lexical';
|
|
30
28
|
import { getContext, onMount, tick, untrack } from 'svelte';
|
|
31
|
-
import Button from '
|
|
32
|
-
import { getSuggestionListPosition } from '
|
|
33
|
-
import Icon from '
|
|
34
|
-
import TextInput from '
|
|
35
|
-
import { OPEN_LINK_EDITOR_COMMAND } from '
|
|
36
|
-
import { focusEditor
|
|
29
|
+
import Button from '../../button/button.svelte';
|
|
30
|
+
import { getSuggestionListPosition } from '../../emoji/position.js';
|
|
31
|
+
import Icon from '../../icon/icon.svelte';
|
|
32
|
+
import TextInput from '../../text-field/text-input.svelte';
|
|
33
|
+
import { OPEN_LINK_EDITOR_COMMAND } from '../constants.js';
|
|
34
|
+
import { focusEditor } from '../editing/caret.js';
|
|
35
|
+
import {
|
|
36
|
+
$findSelectedLink as findSelectedLink,
|
|
37
|
+
getLinkAnchorRect,
|
|
38
|
+
isSafeLinkURL,
|
|
39
|
+
} from '../editing/link.js';
|
|
37
40
|
|
|
38
41
|
/**
|
|
39
42
|
* @import { LexicalEditor, RangeSelection } from 'lexical';
|
|
40
|
-
* @import { EmojiAnchorRect, TextEditorStore } from '
|
|
43
|
+
* @import { EmojiAnchorRect, TextEditorStore } from '../../../typedefs.js';
|
|
41
44
|
*/
|
|
42
45
|
|
|
43
46
|
/**
|
|
@@ -137,71 +140,21 @@
|
|
|
137
140
|
: undefined,
|
|
138
141
|
);
|
|
139
142
|
|
|
140
|
-
/**
|
|
141
|
-
* Find the link that contains the whole selection. This must be called within an editor state
|
|
142
|
-
* read.
|
|
143
|
-
* @returns {import('@lexical/link').LinkNode | null} Link, if any.
|
|
144
|
-
*/
|
|
145
|
-
const findLink = () => {
|
|
146
|
-
const selection = getSelection();
|
|
147
|
-
|
|
148
|
-
if (!isRangeSelection(selection)) {
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const link = findMatchingParent(selection.anchor.getNode(), isLinkNode);
|
|
153
|
-
|
|
154
|
-
return link && findMatchingParent(selection.focus.getNode(), isLinkNode) === link
|
|
155
|
-
? /** @type {import('@lexical/link').LinkNode} */ (link)
|
|
156
|
-
: null;
|
|
157
|
-
};
|
|
158
|
-
|
|
159
143
|
/**
|
|
160
144
|
* Get the viewport-relative bounds of what the popup is anchored to: the text being linked in the
|
|
161
145
|
* edit mode for a new link, or the link otherwise.
|
|
162
146
|
* @param {LexicalEditor} editor Editor instance.
|
|
163
147
|
* @returns {EmojiAnchorRect | undefined} Bounds, or `undefined` if they can’t be determined.
|
|
164
148
|
*/
|
|
165
|
-
const getAnchorRect = (editor) =>
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
? [selection.focus, selection.anchor]
|
|
175
|
-
: [selection.anchor, selection.focus];
|
|
176
|
-
|
|
177
|
-
// The selected nodes may be gone, e.g. after an undo
|
|
178
|
-
/* v8 ignore else */
|
|
179
|
-
if (start.getNode().isAttached() && end.getNode().isAttached()) {
|
|
180
|
-
rect = createDOMRange(
|
|
181
|
-
editor,
|
|
182
|
-
start.getNode(),
|
|
183
|
-
start.offset,
|
|
184
|
-
end.getNode(),
|
|
185
|
-
end.offset,
|
|
186
|
-
)?.getBoundingClientRect();
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
} else {
|
|
190
|
-
const key = editTarget && 'linkKey' in editTarget ? editTarget.linkKey : currentLink?.key;
|
|
191
|
-
|
|
192
|
-
rect = key ? editor.getElementByKey(key)?.getBoundingClientRect() : undefined;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// The link or text may not be laid out, e.g. while the editor is hidden
|
|
196
|
-
/* v8 ignore next */
|
|
197
|
-
if (!rect || !(rect.top || rect.bottom || rect.left || rect.width || rect.height)) {
|
|
198
|
-
return undefined;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const { top, bottom, left, right } = rect;
|
|
202
|
-
|
|
203
|
-
return { top, bottom, left, right };
|
|
204
|
-
};
|
|
149
|
+
const getAnchorRect = (editor) =>
|
|
150
|
+
getLinkAnchorRect(
|
|
151
|
+
editor,
|
|
152
|
+
editTarget && 'selection' in editTarget
|
|
153
|
+
? editTarget
|
|
154
|
+
: {
|
|
155
|
+
linkKey: editTarget && 'linkKey' in editTarget ? editTarget.linkKey : currentLink?.key,
|
|
156
|
+
},
|
|
157
|
+
);
|
|
205
158
|
|
|
206
159
|
/**
|
|
207
160
|
* Follow the link when the page or an ancestor is scrolled, the window is resized, or the
|
|
@@ -265,7 +218,7 @@
|
|
|
265
218
|
let newTab = false;
|
|
266
219
|
|
|
267
220
|
editorStore.editor?.getEditorState().read(() => {
|
|
268
|
-
const link =
|
|
221
|
+
const link = findSelectedLink();
|
|
269
222
|
|
|
270
223
|
if (link) {
|
|
271
224
|
target = { linkKey: link.getKey() };
|
|
@@ -446,7 +399,7 @@
|
|
|
446
399
|
|
|
447
400
|
const unregisterUpdateListener = editor.registerUpdateListener(({ editorState }) => {
|
|
448
401
|
editorState.read(() => {
|
|
449
|
-
const link =
|
|
402
|
+
const link = findSelectedLink();
|
|
450
403
|
|
|
451
404
|
currentLink = link
|
|
452
405
|
? { key: link.getKey(), url: link.getURL(), target: link.getTarget() }
|
|
@@ -580,7 +533,7 @@
|
|
|
580
533
|
{#if open && position}
|
|
581
534
|
<!--
|
|
582
535
|
The `mousedown` listener isn’t an interaction with the group: it only keeps the focus where it
|
|
583
|
-
is when the popup
|
|
536
|
+
is when the popup is pressed, as the controls in it take the interactions.
|
|
584
537
|
-->
|
|
585
538
|
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
586
539
|
<div
|
|
@@ -593,9 +546,13 @@
|
|
|
593
546
|
style:bottom={position.bottom}
|
|
594
547
|
style:left={position.left}
|
|
595
548
|
onmousedown={(event) => {
|
|
596
|
-
// Keep the focus where it is when the popup’s background is pressed,
|
|
597
|
-
//
|
|
598
|
-
|
|
549
|
+
// Keep the focus where it is when the popup’s background or a button is pressed, except for
|
|
550
|
+
// the URL field, which takes it. Otherwise, the focus would move to the page, hiding the
|
|
551
|
+
// popup or blurring the URL field. Safari doesn’t focus a button on click, and moves the
|
|
552
|
+
// focus to the closest focusable ancestor instead, which ends the edit mode before the click
|
|
553
|
+
// can apply the URL
|
|
554
|
+
// @see https://github.com/sveltia/sveltia-cms/issues/1148
|
|
555
|
+
if (!(/** @type {Element} */ (event.target).closest('input'))) {
|
|
599
556
|
event.preventDefault();
|
|
600
557
|
}
|
|
601
558
|
}}
|
|
@@ -707,20 +664,20 @@
|
|
|
707
664
|
align-items: center;
|
|
708
665
|
gap: 4px;
|
|
709
666
|
margin: 0;
|
|
667
|
+
padding: 4px;
|
|
668
|
+
width: min(400px, 100vw - 16px);
|
|
669
|
+
font-family: var(--sui-control-font-family);
|
|
670
|
+
font-size: var(--sui-control-font-size);
|
|
671
|
+
line-height: var(--sui-control-line-height);
|
|
710
672
|
border-width: var(--sui-listbox-border-width, 1px);
|
|
711
673
|
border-style: var(--sui-listbox-border-style, solid);
|
|
712
674
|
border-color: var(--sui-listbox-border-color, var(--sui-secondary-border-color));
|
|
713
675
|
border-radius: var(--sui-listbox-border-radius, 4px);
|
|
714
|
-
padding: 4px;
|
|
715
|
-
width: min(400px, 100vw - 16px);
|
|
716
676
|
color: var(--sui-primary-foreground-color);
|
|
717
677
|
background-color: var(--sui-secondary-background-color-translucent);
|
|
718
678
|
box-shadow: 0 8px 16px var(--sui-popup-shadow-color);
|
|
719
679
|
-webkit-backdrop-filter: blur(16px);
|
|
720
680
|
backdrop-filter: blur(16px);
|
|
721
|
-
font-family: var(--sui-control-font-family);
|
|
722
|
-
font-size: var(--sui-control-font-size);
|
|
723
|
-
line-height: var(--sui-control-line-height);
|
|
724
681
|
}
|
|
725
682
|
.floating-link-editor :global(.sui.text-input) {
|
|
726
683
|
flex: auto;
|
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
<script>
|
|
9
9
|
import { _ } from '@sveltia/i18n';
|
|
10
10
|
import { getContext, onMount } from 'svelte';
|
|
11
|
-
import Icon from '
|
|
12
|
-
import MenuButton from '
|
|
11
|
+
import Icon from '../../icon/icon.svelte';
|
|
12
|
+
import MenuButton from '../../menu/menu-button.svelte';
|
|
13
13
|
import {
|
|
14
14
|
$getSelectedTableCellKey as getSelectedTableCellKey,
|
|
15
15
|
isRightToLeftTable,
|
|
16
|
-
} from '
|
|
17
|
-
import TableActionMenu from '
|
|
16
|
+
} from '../editing/table.js';
|
|
17
|
+
import TableActionMenu from '../toolbar/table-action-menu.svelte';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* @import { PopupPosition, TextEditorStore } from '
|
|
20
|
+
* @import { PopupPosition, TextEditorStore } from '../../../typedefs.js';
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -182,6 +182,13 @@
|
|
|
182
182
|
});
|
|
183
183
|
</script>
|
|
184
184
|
|
|
185
|
+
<!--
|
|
186
|
+
The `mousedown` listener isn’t an interaction with the element: it only keeps the focus in the
|
|
187
|
+
editor when the button is pressed. Safari doesn’t focus a button on click, and moves the focus to
|
|
188
|
+
`<body>` instead, which would hide the button before the click could open the menu.
|
|
189
|
+
@see https://github.com/sveltia/sveltia-cms/issues/1148
|
|
190
|
+
-->
|
|
191
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
185
192
|
<div
|
|
186
193
|
role="none"
|
|
187
194
|
class="table-cell-menu-button"
|
|
@@ -189,6 +196,9 @@
|
|
|
189
196
|
hidden={!show}
|
|
190
197
|
{style}
|
|
191
198
|
bind:this={container}
|
|
199
|
+
onmousedown={(event) => {
|
|
200
|
+
event.preventDefault();
|
|
201
|
+
}}
|
|
192
202
|
>
|
|
193
203
|
{#if show && cellKey}
|
|
194
204
|
{@const key = cellKey}
|
|
@@ -91,28 +91,31 @@
|
|
|
91
91
|
<style>.date-time-input {
|
|
92
92
|
display: inline-block;
|
|
93
93
|
margin: var(--sui-focus-ring-width);
|
|
94
|
+
width: auto;
|
|
95
|
+
min-width: 0;
|
|
96
|
+
height: var(--sui-textbox-height);
|
|
97
|
+
text-transform: var(--sui-date-time-input-text-transform, uppercase);
|
|
98
|
+
font-variant-numeric: tabular-nums;
|
|
94
99
|
border-width: var(--sui-textbox-border-width, 1px);
|
|
95
100
|
border-color: var(--sui-textbox-border-color);
|
|
96
101
|
border-radius: var(--sui-textbox-border-radius);
|
|
97
102
|
padding: var(--sui-textbox-singleline-padding);
|
|
98
|
-
width: auto;
|
|
99
|
-
min-width: 0;
|
|
100
|
-
height: var(--sui-textbox-height);
|
|
101
103
|
color: var(--sui-textbox-foreground-color);
|
|
102
104
|
background-color: var(--sui-textbox-background-color);
|
|
103
105
|
font-family: var(--sui-textbox-font-family);
|
|
104
106
|
font-size: var(--sui-textbox-font-size);
|
|
105
107
|
line-height: var(--sui-textbox-singleline-line-height);
|
|
106
108
|
font-weight: var(--sui-textbox-font-weight, var(--sui-font-weight-normal, normal));
|
|
107
|
-
text-transform: var(--sui-date-time-input-text-transform, uppercase);
|
|
108
109
|
letter-spacing: var(--sui-textbox-letter-spacing, normal);
|
|
109
|
-
font-variant-numeric: tabular-nums;
|
|
110
110
|
transition: all 200ms;
|
|
111
111
|
}
|
|
112
112
|
.date-time-input:focus {
|
|
113
113
|
color: var(--sui-textbox-foreground-color-focus, var(--sui-textbox-foreground-color));
|
|
114
114
|
background-color: var(--sui-textbox-background-color-focus, var(--sui-textbox-background-color));
|
|
115
115
|
}
|
|
116
|
+
.date-time-input[aria-invalid=true] {
|
|
117
|
+
border-color: var(--sui-error-border-color);
|
|
118
|
+
}
|
|
116
119
|
.date-time-input:read-only {
|
|
117
120
|
color: var(--sui-secondary-foreground-color);
|
|
118
121
|
border-color: var(--sui-textbox-border-color) !important;
|
|
@@ -120,9 +123,6 @@
|
|
|
120
123
|
.date-time-input:is(:disabled, :read-only) {
|
|
121
124
|
background-color: var(--sui-disabled-background-color);
|
|
122
125
|
}
|
|
123
|
-
.date-time-input[aria-invalid=true] {
|
|
124
|
-
border-color: var(--sui-error-border-color);
|
|
125
|
-
}
|
|
126
126
|
.date-time-input::-webkit-calendar-picker-indicator {
|
|
127
127
|
cursor: pointer;
|
|
128
128
|
}
|
|
@@ -188,32 +188,35 @@
|
|
|
188
188
|
grid-area: 1/1/2/2;
|
|
189
189
|
display: block;
|
|
190
190
|
margin: 0;
|
|
191
|
+
width: 100%;
|
|
192
|
+
min-height: 8em;
|
|
191
193
|
border-width: var(--sui-textbox-border-width, 1px);
|
|
192
194
|
border-color: var(--sui-textbox-border-color);
|
|
193
195
|
border-radius: var(--sui-textbox-border-radius);
|
|
194
196
|
padding: var(--sui-textbox-multiline-padding);
|
|
195
|
-
width: 100%;
|
|
196
|
-
min-height: 8em;
|
|
197
197
|
color: var(--sui-textbox-foreground-color);
|
|
198
198
|
background-color: var(--sui-textbox-background-color);
|
|
199
199
|
font-family: var(--sui-textbox-font-family);
|
|
200
200
|
font-size: var(--sui-textbox-font-size);
|
|
201
201
|
line-height: var(--sui-textbox-multiline-line-height);
|
|
202
202
|
font-weight: var(--sui-textbox-font-weight, var(--sui-font-weight-normal, normal));
|
|
203
|
+
letter-spacing: var(--sui-textbox-letter-spacing, normal);
|
|
204
|
+
transition: all 200ms;
|
|
203
205
|
text-align: var(--sui-textbox-text-align, start);
|
|
204
206
|
text-indent: var(--sui-textbox-text-indent, 0);
|
|
205
207
|
text-transform: var(--sui-textbox-text-transform, none);
|
|
206
|
-
letter-spacing: var(--sui-textbox-letter-spacing, normal);
|
|
207
208
|
word-spacing: var(--sui-word-spacing-normal, normal);
|
|
208
|
-
transition: all 200ms;
|
|
209
|
-
}
|
|
210
|
-
:is(textarea, .clone).resizing {
|
|
211
|
-
transition-duration: 0ms;
|
|
212
209
|
}
|
|
213
210
|
:is(textarea, .clone):focus {
|
|
214
211
|
color: var(--sui-textbox-foreground-color-focus, var(--sui-textbox-foreground-color));
|
|
215
212
|
background-color: var(--sui-textbox-background-color-focus, var(--sui-textbox-background-color));
|
|
216
213
|
}
|
|
214
|
+
:is(textarea, .clone)[aria-invalid=true] {
|
|
215
|
+
border-color: var(--sui-error-border-color);
|
|
216
|
+
}
|
|
217
|
+
:is(textarea, .clone).resizing {
|
|
218
|
+
transition-duration: 0ms;
|
|
219
|
+
}
|
|
217
220
|
:is(textarea, .clone):is(:disabled, :read-only):not(.clone) {
|
|
218
221
|
background-color: var(--sui-disabled-background-color);
|
|
219
222
|
}
|
|
@@ -225,9 +228,6 @@ textarea.auto-resize {
|
|
|
225
228
|
overflow: hidden;
|
|
226
229
|
resize: none;
|
|
227
230
|
}
|
|
228
|
-
textarea[aria-invalid=true] {
|
|
229
|
-
border-color: var(--sui-error-border-color);
|
|
230
|
-
}
|
|
231
231
|
|
|
232
232
|
.clone {
|
|
233
233
|
overflow: hidden;
|
|
@@ -165,29 +165,32 @@ input:is(:-webkit-autofill, :-webkit-autofill:focus) {
|
|
|
165
165
|
input {
|
|
166
166
|
display: inline-block;
|
|
167
167
|
flex: auto;
|
|
168
|
+
min-width: 0;
|
|
169
|
+
height: var(--sui-textbox-height);
|
|
168
170
|
border-width: var(--sui-textbox-border-width, 1px);
|
|
169
171
|
border-color: var(--sui-textbox-border-color);
|
|
170
172
|
border-radius: var(--sui-textbox-border-radius);
|
|
171
173
|
padding: var(--sui-textbox-singleline-padding);
|
|
172
|
-
min-width: 0;
|
|
173
|
-
height: var(--sui-textbox-height);
|
|
174
174
|
color: var(--sui-textbox-foreground-color);
|
|
175
175
|
background-color: var(--sui-textbox-background-color);
|
|
176
176
|
font-family: var(--sui-textbox-font-family);
|
|
177
177
|
font-size: var(--sui-textbox-font-size);
|
|
178
178
|
line-height: var(--sui-textbox-singleline-line-height);
|
|
179
179
|
font-weight: var(--sui-textbox-font-weight, var(--sui-font-weight-normal, normal));
|
|
180
|
+
letter-spacing: var(--sui-textbox-letter-spacing, normal);
|
|
181
|
+
transition: all 200ms;
|
|
180
182
|
text-align: var(--sui-textbox-text-align, start);
|
|
181
183
|
text-indent: var(--sui-textbox-text-indent, 0);
|
|
182
184
|
text-transform: var(--sui-textbox-text-transform, none);
|
|
183
|
-
letter-spacing: var(--sui-textbox-letter-spacing, normal);
|
|
184
185
|
word-spacing: var(--sui-word-spacing-normal, normal);
|
|
185
|
-
transition: all 200ms;
|
|
186
186
|
}
|
|
187
187
|
input:focus {
|
|
188
188
|
color: var(--sui-textbox-foreground-color-focus, var(--sui-textbox-foreground-color));
|
|
189
189
|
background-color: var(--sui-textbox-background-color-focus, var(--sui-textbox-background-color));
|
|
190
190
|
}
|
|
191
|
+
input[aria-invalid=true] {
|
|
192
|
+
border-color: var(--sui-error-border-color);
|
|
193
|
+
}
|
|
191
194
|
input:read-only {
|
|
192
195
|
color: var(--sui-secondary-foreground-color);
|
|
193
196
|
border-color: var(--sui-textbox-border-color) !important;
|
|
@@ -195,9 +198,6 @@ input:read-only {
|
|
|
195
198
|
input:is(:disabled, :read-only) {
|
|
196
199
|
background-color: var(--sui-disabled-background-color);
|
|
197
200
|
}
|
|
198
|
-
input[aria-invalid=true] {
|
|
199
|
-
border-color: var(--sui-error-border-color);
|
|
200
|
-
}
|
|
201
201
|
input ~ :global(button) {
|
|
202
202
|
flex: none;
|
|
203
203
|
margin-inline-start: -1px;
|
|
@@ -259,12 +259,12 @@
|
|
|
259
259
|
overflow-y: auto;
|
|
260
260
|
outline-width: 0 !important;
|
|
261
261
|
width: auto;
|
|
262
|
+
transition-property: opacity, transform;
|
|
262
263
|
color: var(--sui-primary-foreground-color);
|
|
263
264
|
background-color: var(--sui-secondary-background-color-translucent);
|
|
264
265
|
box-shadow: 0 8px 16px var(--sui-popup-shadow-color);
|
|
265
266
|
-webkit-backdrop-filter: blur(16px);
|
|
266
267
|
backdrop-filter: blur(16px);
|
|
267
|
-
transition-property: opacity, transform;
|
|
268
268
|
}
|
|
269
269
|
.content.menu {
|
|
270
270
|
border-width: var(--sui-menu-border-width, 1px);
|