@vev/silke 1.1.10 → 1.2.0
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/.turbo/turbo-build.log +163 -78
- package/CHANGELOG.md +31 -0
- package/dist/index.js +44 -41
- package/dist/index.js.LEGAL.txt +1 -1
- package/dist/index.js.map +7 -0
- package/dist/styles.css +1597 -1014
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/components/silke-autocomplete-field/autocomplete-item.d.ts +1 -1
- package/dist/types/components/silke-autocomplete-field/silke-autocomplete-field-native.d.ts +5 -0
- package/dist/types/components/silke-box/silke-box.d.ts +2 -0
- package/dist/types/components/silke-button/silke-dropdown-button.d.ts +3 -1
- package/dist/types/components/silke-card/silke-card-grid.d.ts +1 -0
- package/dist/types/components/silke-card/silke-card.d.ts +1 -0
- package/dist/types/components/silke-command-text-field/index.d.ts +1 -1
- package/dist/types/components/silke-command-text-field/silke-command-text-field.d.ts +16 -0
- package/dist/types/components/silke-command-text-field/utils.d.ts +25 -0
- package/dist/types/components/silke-css-number-field/silke-css-number-field.spec.d.ts +1 -0
- package/dist/types/components/silke-expression-input/index.d.ts +3 -0
- package/dist/types/components/silke-expression-input/silke-expression-input-tag.d.ts +6 -0
- package/dist/types/components/silke-expression-input/silke-expression-input.d.ts +29 -0
- package/dist/types/components/silke-expression-input/utils.d.ts +18 -0
- package/dist/types/components/silke-form-schema/fields/array-field-inline.d.ts +2 -1
- package/dist/types/components/silke-form-schema/fields/array-field-modal.d.ts +2 -1
- package/dist/types/components/silke-form-schema/fields/array-field.d.ts +1 -1
- package/dist/types/components/silke-form-schema/fields/group-field.d.ts +1 -1
- package/dist/types/components/silke-form-schema/fields/layout-field.d.ts +1 -1
- package/dist/types/components/silke-form-schema/fields/object-field.d.ts +1 -1
- package/dist/types/components/silke-form-schema/fields/popover-field.d.ts +1 -1
- package/dist/types/components/silke-form-schema/fields/string-field.d.ts +1 -1
- package/dist/types/components/silke-form-schema/index.d.ts +1 -0
- package/dist/types/components/silke-form-schema/silke-form-schema.d.ts +4 -1
- package/dist/types/components/silke-form-schema/silke-schema-decorator.d.ts +17 -0
- package/dist/types/components/silke-form-schema/silke-schema-field.d.ts +2 -1
- package/dist/types/components/silke-form-schema/silke-schema-fields.d.ts +2 -0
- package/dist/types/components/silke-form-schema/silke-schema-path.spec.d.ts +1 -0
- package/dist/types/components/silke-gradient-picker/silke-gradient-utils.d.ts +2 -0
- package/dist/types/components/silke-icon-picker/color-swatch-section.d.ts +6 -0
- package/dist/types/components/silke-icon-picker/emoji-tab.d.ts +1 -1
- package/dist/types/components/silke-icon-picker/icons-tab.d.ts +1 -1
- package/dist/types/components/silke-icon-picker/silke-icon-picker.d.ts +2 -0
- package/dist/types/components/silke-icon-picker/utils.d.ts +2 -0
- package/dist/types/components/silke-list/silke-list-item.d.ts +5 -1
- package/dist/types/components/silke-list/types.d.ts +1 -0
- package/dist/types/components/silke-navigation-link/silke-navigation-link.d.ts +15 -0
- package/dist/types/components/silke-popover/popover-context.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/blockquote.d.ts +21 -0
- package/dist/types/components/silke-rich-text-field/blockquote.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/dropcap.d.ts +27 -0
- package/dist/types/components/silke-rich-text-field/dropcap.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/floating-layer.d.ts +12 -0
- package/dist/types/components/silke-rich-text-field/font-size.d.ts +2 -0
- package/dist/types/components/silke-rich-text-field/formatting-toolbar.d.ts +9 -0
- package/dist/types/components/silke-rich-text-field/index.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/jsdom-rects.d.ts +10 -0
- package/dist/types/components/silke-rich-text-field/link-menu.d.ts +26 -0
- package/dist/types/components/silke-rich-text-field/link-menu.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/link-suggestions.d.ts +48 -0
- package/dist/types/components/silke-rich-text-field/link-suggestions.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/link-tooltip.d.ts +15 -0
- package/dist/types/components/silke-rich-text-field/list-item.d.ts +15 -0
- package/dist/types/components/silke-rich-text-field/list-link-fontsize.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/lorem-ipsum.d.ts +10 -0
- package/dist/types/components/silke-rich-text-field/lorem-ipsum.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/paste.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/paste.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/plugins.d.ts +18 -0
- package/dist/types/components/silke-rich-text-field/plugins.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/silke-rich-text-field.d.ts +60 -0
- package/dist/types/components/silke-rich-text-field/slash-menu-items.d.ts +10 -0
- package/dist/types/components/silke-rich-text-field/slash-menu.d.ts +11 -0
- package/dist/types/components/silke-rich-text-field/table-content-sync.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/table-toolbar.d.ts +17 -0
- package/dist/types/components/silke-rich-text-field/table-toolbar.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/table.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/use-link-hover.d.ts +15 -0
- package/dist/types/components/silke-rich-text-field/use-slash-menu.d.ts +13 -0
- package/dist/types/components/silke-rich-text-field/utils.d.ts +13 -0
- package/dist/types/components/silke-sortable-list/index.d.ts +1 -1
- package/dist/types/components/silke-sortable-list/silke-nested-sortable-list.d.ts +8 -1
- package/dist/types/components/silke-theme-card/silke-theme-card.d.ts +13 -6
- package/dist/types/components/silke-theme-swatch/silke-theme-swatch.d.ts +6 -1
- package/dist/types/icons.d.ts +16 -0
- package/esbuild.config.mjs +9 -4
- package/package.json +22 -9
- package/src/components/index.ts +2 -0
- package/src/components/silke-alert-banner/silke-alert-banner.tsx +1 -1
- package/src/components/silke-autocomplete-field/autocomplete-item.tsx +47 -61
- package/src/components/silke-autocomplete-field/silke-autocomplete-field-native.tsx +13 -2
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.tsx +8 -5
- package/src/components/silke-autocomplete-field/silke-autocomplete-popup-native.tsx +2 -1
- package/src/components/silke-box/silke-box.scss +4 -0
- package/src/components/silke-box/silke-box.tsx +4 -0
- package/src/components/silke-button/silke-dropdown-button.tsx +4 -1
- package/src/components/silke-card/silke-card.scss +4 -0
- package/src/components/silke-card/silke-card.tsx +3 -0
- package/src/components/silke-command-text-field/index.ts +1 -0
- package/src/components/silke-command-text-field/silke-command-parser.spec.ts +55 -0
- package/src/components/silke-command-text-field/silke-command-parser.ts +33 -2
- package/src/components/silke-command-text-field/silke-command-text-field.module.scss +3 -0
- package/src/components/silke-command-text-field/silke-command-text-field.tsx +53 -48
- package/src/components/silke-command-text-field/utils.spec.ts +192 -0
- package/src/components/silke-command-text-field/utils.ts +99 -16
- package/src/components/silke-css-number-field/silke-css-number-field.spec.tsx +115 -0
- package/src/components/silke-css-number-field/silke-css-number-field.tsx +33 -0
- package/src/components/silke-expression-input/index.ts +3 -0
- package/src/components/silke-expression-input/silke-expression-input-tag.tsx +37 -0
- package/src/components/silke-expression-input/silke-expression-input.mdx +40 -0
- package/src/components/silke-expression-input/silke-expression-input.scss +24 -0
- package/src/components/silke-expression-input/silke-expression-input.tsx +343 -0
- package/src/components/silke-expression-input/utils.ts +144 -0
- package/src/components/silke-form-schema/fields/array-field-inline.tsx +4 -0
- package/src/components/silke-form-schema/fields/array-field-modal.tsx +4 -0
- package/src/components/silke-form-schema/fields/array-field.tsx +6 -11
- package/src/components/silke-form-schema/fields/group-field.tsx +2 -0
- package/src/components/silke-form-schema/fields/layout-field.tsx +2 -0
- package/src/components/silke-form-schema/fields/object-field.tsx +2 -0
- package/src/components/silke-form-schema/fields/popover-field.tsx +2 -0
- package/src/components/silke-form-schema/fields/string-field.tsx +27 -1
- package/src/components/silke-form-schema/index.ts +1 -0
- package/src/components/silke-form-schema/silke-form-schema.mdx +30 -1
- package/src/components/silke-form-schema/silke-form-schema.tsx +12 -6
- package/src/components/silke-form-schema/silke-schema-decorator.tsx +32 -0
- package/src/components/silke-form-schema/silke-schema-field.tsx +19 -2
- package/src/components/silke-form-schema/silke-schema-fields.tsx +30 -4
- package/src/components/silke-form-schema/silke-schema-path.spec.tsx +160 -0
- package/src/components/silke-gradient-picker/silke-gradient-picker.tsx +3 -1
- package/src/components/silke-gradient-picker/silke-gradient-utils.ts +23 -3
- package/src/components/silke-icon/silke-shape.tsx +1 -1
- package/src/components/silke-icon-picker/color-swatch-section.tsx +61 -0
- package/src/components/silke-icon-picker/emoji-tab.tsx +8 -6
- package/src/components/silke-icon-picker/icons-tab.tsx +8 -7
- package/src/components/silke-icon-picker/silke-icon-picker.tsx +52 -25
- package/src/components/silke-icon-picker/styles.scss +66 -1
- package/src/components/silke-icon-picker/utils.ts +2 -0
- package/src/components/silke-list/silke-list-item.scss +10 -0
- package/src/components/silke-list/silke-list-item.tsx +16 -3
- package/src/components/silke-list/silke-list.mdx +18 -0
- package/src/components/silke-list/types.ts +1 -0
- package/src/components/silke-navigation-link/silke-navigation-link.scss +162 -42
- package/src/components/silke-navigation-link/silke-navigation-link.tsx +99 -21
- package/src/components/silke-popover/popover-context.spec.tsx +44 -0
- package/src/components/silke-popover-native/silke-popover-native.scss +5 -3
- package/src/components/silke-rich-text-field/blockquote.spec.ts +151 -0
- package/src/components/silke-rich-text-field/blockquote.ts +90 -0
- package/src/components/silke-rich-text-field/dropcap.spec.ts +67 -0
- package/src/components/silke-rich-text-field/dropcap.ts +59 -0
- package/src/components/silke-rich-text-field/floating-layer.tsx +15 -0
- package/src/components/silke-rich-text-field/font-size.ts +62 -0
- package/src/components/silke-rich-text-field/formatting-toolbar.tsx +145 -0
- package/src/components/silke-rich-text-field/index.ts +1 -0
- package/src/components/silke-rich-text-field/jsdom-rects.ts +15 -0
- package/src/components/silke-rich-text-field/link-menu.spec.tsx +502 -0
- package/src/components/silke-rich-text-field/link-menu.tsx +553 -0
- package/src/components/silke-rich-text-field/link-suggestions.spec.ts +203 -0
- package/src/components/silke-rich-text-field/link-suggestions.ts +188 -0
- package/src/components/silke-rich-text-field/link-tooltip.tsx +60 -0
- package/src/components/silke-rich-text-field/list-item.ts +64 -0
- package/src/components/silke-rich-text-field/list-link-fontsize.spec.ts +135 -0
- package/src/components/silke-rich-text-field/lorem-ipsum.spec.ts +131 -0
- package/src/components/silke-rich-text-field/lorem-ipsum.ts +51 -0
- package/src/components/silke-rich-text-field/paste.spec.ts +93 -0
- package/src/components/silke-rich-text-field/paste.ts +39 -0
- package/src/components/silke-rich-text-field/plugins.spec.ts +143 -0
- package/src/components/silke-rich-text-field/plugins.ts +230 -0
- package/src/components/silke-rich-text-field/silke-rich-text-field.mdx +180 -0
- package/src/components/silke-rich-text-field/silke-rich-text-field.scss +343 -0
- package/src/components/silke-rich-text-field/silke-rich-text-field.tsx +505 -0
- package/src/components/silke-rich-text-field/slash-menu-items.ts +112 -0
- package/src/components/silke-rich-text-field/slash-menu.tsx +50 -0
- package/src/components/silke-rich-text-field/table-content-sync.spec.tsx +61 -0
- package/src/components/silke-rich-text-field/table-toolbar.spec.tsx +168 -0
- package/src/components/silke-rich-text-field/table-toolbar.tsx +121 -0
- package/src/components/silke-rich-text-field/table.spec.ts +87 -0
- package/src/components/silke-rich-text-field/use-link-hover.ts +63 -0
- package/src/components/silke-rich-text-field/use-slash-menu.ts +130 -0
- package/src/components/silke-rich-text-field/utils.ts +55 -0
- package/src/components/silke-sortable-list/index.ts +1 -1
- package/src/components/silke-sortable-list/silke-nested-sortable-list.scss +11 -1
- package/src/components/silke-sortable-list/silke-nested-sortable-list.tsx +9 -0
- package/src/components/silke-sortable-list/silke-sortable-list.mdx +13 -0
- package/src/components/silke-tag/silke-tag.scss +12 -3
- package/src/components/silke-theme-card/silke-theme-card.module.scss +141 -45
- package/src/components/silke-theme-card/silke-theme-card.tsx +76 -47
- package/src/components/silke-theme-swatch/silke-theme-swatch.mdx +56 -0
- package/src/components/silke-theme-swatch/silke-theme-swatch.module.scss +53 -63
- package/src/components/silke-theme-swatch/silke-theme-swatch.tsx +99 -14
- package/src/icons.tsx +51 -5
- package/tsconfig.build.tsbuildinfo +0 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Mark, mergeAttributes } from '@tiptap/core';
|
|
2
|
+
import { stripPastedInlineStyles } from './paste';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Inline font-size, same job as Dropcap: ProseMirror unwraps elements it has
|
|
6
|
+
* no mark for. The old plate editor stored size on `<span style="font-size: …">`
|
|
7
|
+
* or on the `<a>` itself. Without this mark those sizes parsed away, and the
|
|
8
|
+
* first link edit saved the stripped HTML — list items then fell through to the
|
|
9
|
+
* theme heading size (~48px) while the properties panel still showed the
|
|
10
|
+
* element's set size (E-1228).
|
|
11
|
+
*
|
|
12
|
+
* Content that is *pasted* is the other way round: the size belongs to whatever
|
|
13
|
+
* the user copied from, and keeping it makes the element deaf to its own text
|
|
14
|
+
* styles (E-1235). Pasted markup loses its inline styles on the way in — see
|
|
15
|
+
* transformPastedHTML.
|
|
16
|
+
*
|
|
17
|
+
* Only `font-size` is kept. Other inline styles are out of scope.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function readFontSize(element: HTMLElement): string | null {
|
|
21
|
+
const fontSize = element.style?.fontSize?.trim();
|
|
22
|
+
return fontSize || null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const FontSize = Mark.create({
|
|
26
|
+
name: 'fontSize',
|
|
27
|
+
|
|
28
|
+
// TipTap chains this hook across extensions (and after editorProps'), so the
|
|
29
|
+
// mark that makes inline sizes stick is also the one that keeps them out of a
|
|
30
|
+
// paste. See paste.ts — the whole style attribute goes, not only the size.
|
|
31
|
+
transformPastedHTML: stripPastedInlineStyles,
|
|
32
|
+
|
|
33
|
+
addAttributes() {
|
|
34
|
+
return {
|
|
35
|
+
fontSize: {
|
|
36
|
+
default: null,
|
|
37
|
+
parseHTML: (element) => readFontSize(element),
|
|
38
|
+
renderHTML: (attributes) =>
|
|
39
|
+
attributes.fontSize ? { style: `font-size: ${attributes.fontSize}` } : {},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
parseHTML() {
|
|
45
|
+
return [
|
|
46
|
+
{
|
|
47
|
+
tag: 'span',
|
|
48
|
+
getAttrs: (node) => {
|
|
49
|
+
if (!(node instanceof HTMLElement)) return false;
|
|
50
|
+
// Dropcap owns `span.dropcap` — do not steal those.
|
|
51
|
+
if (node.classList.contains('dropcap')) return false;
|
|
52
|
+
const fontSize = readFontSize(node);
|
|
53
|
+
return fontSize ? { fontSize } : false;
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
renderHTML({ HTMLAttributes }) {
|
|
60
|
+
return ['span', mergeAttributes(HTMLAttributes), 0];
|
|
61
|
+
},
|
|
62
|
+
});
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
|
2
|
+
import type { Editor } from '@tiptap/react';
|
|
3
|
+
import { BubbleMenu } from '@tiptap/react/menus';
|
|
4
|
+
import { SilkeBox } from '../silke-box';
|
|
5
|
+
import { SilkeButton } from '../silke-button';
|
|
6
|
+
import { SilkeDivider } from '../silke-divider';
|
|
7
|
+
import type { SilkeIcons } from '../silke-icon';
|
|
8
|
+
|
|
9
|
+
interface FormattingToolbarProps {
|
|
10
|
+
editor: Editor;
|
|
11
|
+
onLinkClick: () => void;
|
|
12
|
+
onBlockTypeClick: () => void;
|
|
13
|
+
onAIClick?: () => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getBlockTypeIcon(editor: Editor): SilkeIcons {
|
|
17
|
+
if (editor.isActive('heading', { level: 1 })) return 'text.h1';
|
|
18
|
+
if (editor.isActive('heading', { level: 2 })) return 'text.h2';
|
|
19
|
+
if (editor.isActive('heading', { level: 3 })) return 'text.h3';
|
|
20
|
+
if (editor.isActive('heading', { level: 4 })) return 'text.h4';
|
|
21
|
+
if (editor.isActive('heading', { level: 5 })) return 'text.h5';
|
|
22
|
+
if (editor.isActive('heading', { level: 6 })) return 'text.h6';
|
|
23
|
+
if (editor.isActive('bulletList')) return 'list.check';
|
|
24
|
+
if (editor.isActive('orderedList')) return 'list.ol';
|
|
25
|
+
if (editor.isActive('blockquote')) return 'text.blockquote';
|
|
26
|
+
return 'text.p';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function FormattingToolbar({
|
|
30
|
+
editor,
|
|
31
|
+
onLinkClick,
|
|
32
|
+
onBlockTypeClick,
|
|
33
|
+
onAIClick,
|
|
34
|
+
}: FormattingToolbarProps) {
|
|
35
|
+
// Both are dependencies of BubbleMenu's "update plugin options" effect, which ends in
|
|
36
|
+
// view.dispatch(). Inline literals are a new identity on every render, so the toolbar
|
|
37
|
+
// dispatched a transaction per render — feeding every transaction listener on the
|
|
38
|
+
// editor, and looping outright against any listener that sets state.
|
|
39
|
+
const appendTo = useCallback(() => document.body, []);
|
|
40
|
+
const bubbleOptions = useMemo(() => ({ strategy: 'fixed' as const }), []);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
// Appended to the body and fixed to the viewport so the toolbar is not trapped
|
|
44
|
+
// under panels by whatever stacking context the host puts the editor in.
|
|
45
|
+
<BubbleMenu editor={editor} appendTo={appendTo} options={bubbleOptions} style={{ zIndex: 999 }}>
|
|
46
|
+
<SilkeBox
|
|
47
|
+
data-rich-text-menu
|
|
48
|
+
gap="xxs"
|
|
49
|
+
vAlign="center"
|
|
50
|
+
bg="neutral-10"
|
|
51
|
+
rounded="small"
|
|
52
|
+
shadow="level3"
|
|
53
|
+
border
|
|
54
|
+
pad="xxs"
|
|
55
|
+
>
|
|
56
|
+
{onAIClick && (
|
|
57
|
+
<SilkeButton kind="ghost" size="base" onClick={onAIClick} icon="ai.gradient" title="AI" />
|
|
58
|
+
)}
|
|
59
|
+
<SilkeButton
|
|
60
|
+
kind="ghost"
|
|
61
|
+
size="base"
|
|
62
|
+
icon={getBlockTypeIcon(editor)}
|
|
63
|
+
onClick={onBlockTypeClick}
|
|
64
|
+
title="Change block type"
|
|
65
|
+
/>
|
|
66
|
+
<SilkeDivider vertical />
|
|
67
|
+
<SilkeButton
|
|
68
|
+
kind="ghost"
|
|
69
|
+
size="base"
|
|
70
|
+
selected={editor.isActive('bold')}
|
|
71
|
+
onClick={() => editor.chain().focus().toggleBold().run()}
|
|
72
|
+
icon="text.bold"
|
|
73
|
+
title="Bold"
|
|
74
|
+
/>
|
|
75
|
+
<SilkeButton
|
|
76
|
+
kind="ghost"
|
|
77
|
+
size="base"
|
|
78
|
+
selected={editor.isActive('italic')}
|
|
79
|
+
onClick={() => editor.chain().focus().toggleItalic().run()}
|
|
80
|
+
icon="text.italic"
|
|
81
|
+
title="Italic"
|
|
82
|
+
/>
|
|
83
|
+
<SilkeButton
|
|
84
|
+
kind="ghost"
|
|
85
|
+
size="base"
|
|
86
|
+
selected={editor.isActive('underline')}
|
|
87
|
+
onClick={() => editor.chain().focus().toggleUnderline().run()}
|
|
88
|
+
icon="text.underline"
|
|
89
|
+
title="Underline"
|
|
90
|
+
/>
|
|
91
|
+
<SilkeButton
|
|
92
|
+
kind="ghost"
|
|
93
|
+
size="base"
|
|
94
|
+
selected={editor.isActive('strike')}
|
|
95
|
+
onClick={() => editor.chain().focus().toggleStrike().run()}
|
|
96
|
+
label={<s>S</s>}
|
|
97
|
+
title="Strikethrough"
|
|
98
|
+
/>
|
|
99
|
+
<SilkeDivider vertical dark />
|
|
100
|
+
<SilkeButton
|
|
101
|
+
kind="ghost"
|
|
102
|
+
size="base"
|
|
103
|
+
selected={editor.isActive('superscript')}
|
|
104
|
+
onClick={() => editor.chain().focus().toggleSuperscript().run()}
|
|
105
|
+
icon="text.superscript"
|
|
106
|
+
title="Superscript"
|
|
107
|
+
/>
|
|
108
|
+
<SilkeButton
|
|
109
|
+
kind="ghost"
|
|
110
|
+
size="base"
|
|
111
|
+
selected={editor.isActive('subscript')}
|
|
112
|
+
onClick={() => editor.chain().focus().toggleSubscript().run()}
|
|
113
|
+
icon="text.subscript"
|
|
114
|
+
title="Subscript"
|
|
115
|
+
/>
|
|
116
|
+
<SilkeButton
|
|
117
|
+
kind="ghost"
|
|
118
|
+
size="base"
|
|
119
|
+
selected={editor.isActive('dropcap')}
|
|
120
|
+
onClick={() => editor.chain().focus().toggleDropcap().run()}
|
|
121
|
+
icon="text.dropcap"
|
|
122
|
+
title="Dropcap"
|
|
123
|
+
/>
|
|
124
|
+
<SilkeDivider vertical dark />
|
|
125
|
+
<SilkeButton
|
|
126
|
+
kind="ghost"
|
|
127
|
+
size="base"
|
|
128
|
+
selected={editor.isActive('code')}
|
|
129
|
+
onClick={() => editor.chain().focus().toggleCode().run()}
|
|
130
|
+
icon="editor.code"
|
|
131
|
+
title="Inline code"
|
|
132
|
+
/>
|
|
133
|
+
<SilkeButton
|
|
134
|
+
kind="ghost"
|
|
135
|
+
size="base"
|
|
136
|
+
selected={editor.isActive('link')}
|
|
137
|
+
onClick={onLinkClick}
|
|
138
|
+
icon="link.external"
|
|
139
|
+
title="Link"
|
|
140
|
+
data-cy="rich-text-link"
|
|
141
|
+
/>
|
|
142
|
+
</SilkeBox>
|
|
143
|
+
</BubbleMenu>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './silke-rich-text-field';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* jsdom implements neither `getClientRects` nor `Range.getBoundingClientRect`, and
|
|
3
|
+
* ProseMirror calls them via `coordsAtPos` — on every focus, and on mount as soon as a
|
|
4
|
+
* BubbleMenu is present, since it positions against the caret rect. Any spec that renders
|
|
5
|
+
* SilkeRichTextField needs these or it throws "target.getClientRects is not a function".
|
|
6
|
+
*
|
|
7
|
+
* They return empty rects: enough to get through the call, not enough to assert position
|
|
8
|
+
* against. Placement has to be checked in a browser.
|
|
9
|
+
*/
|
|
10
|
+
export function stubProseMirrorRects() {
|
|
11
|
+
const emptyRectList = { length: 0, item: () => null } as unknown as DOMRectList;
|
|
12
|
+
Range.prototype.getClientRects = () => emptyRectList;
|
|
13
|
+
Range.prototype.getBoundingClientRect = () => new DOMRect();
|
|
14
|
+
Element.prototype.getClientRects = () => emptyRectList;
|
|
15
|
+
}
|