@d4gger/design-system 4.0.1 → 4.0.2
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/_internal/props/propDef.cjs +2 -1
- package/dist/_internal/props/propDef.cjs.map +2 -2
- package/dist/_internal/props/propDef.d.cts.map +1 -1
- package/dist/_internal/props/propDef.d.mts.map +1 -1
- package/dist/_internal/props/propDef.d.ts.map +1 -1
- package/dist/_internal/props/propDef.js +2 -1
- package/dist/_internal/props/propDef.js.map +2 -2
- package/dist/components/alert.css +12 -0
- package/dist/components/box.css +0 -12
- package/dist/components/config-drawer.css +9 -1
- package/dist/components/configDrawer/ConfigDrawer.cjs +1 -0
- package/dist/components/configDrawer/ConfigDrawer.cjs.map +2 -2
- package/dist/components/configDrawer/ConfigDrawer.d.cts.map +1 -1
- package/dist/components/configDrawer/ConfigDrawer.d.mts.map +1 -1
- package/dist/components/configDrawer/ConfigDrawer.d.ts.map +1 -1
- package/dist/components/configDrawer/ConfigDrawer.js +1 -0
- package/dist/components/configDrawer/ConfigDrawer.js.map +2 -2
- package/dist/components/drawer.css +4 -2
- package/dist/components/flex/Flex.cjs +5 -4
- package/dist/components/flex/Flex.cjs.map +2 -2
- package/dist/components/flex/Flex.d.cts.map +1 -1
- package/dist/components/flex/Flex.d.mts.map +1 -1
- package/dist/components/flex/Flex.d.ts.map +1 -1
- package/dist/components/flex/Flex.js +5 -4
- package/dist/components/flex/Flex.js.map +2 -2
- package/dist/components/grid/Grid.cjs +5 -5
- package/dist/components/grid/Grid.cjs.map +2 -2
- package/dist/components/grid/Grid.d.cts.map +1 -1
- package/dist/components/grid/Grid.d.mts.map +1 -1
- package/dist/components/grid/Grid.d.ts.map +1 -1
- package/dist/components/grid/Grid.js +5 -5
- package/dist/components/grid/Grid.js.map +2 -2
- package/dist/components/input-otp.css +24 -0
- package/dist/components/inputOtp/InputOtp.cjs +2 -1
- package/dist/components/inputOtp/InputOtp.cjs.map +2 -2
- package/dist/components/inputOtp/InputOtp.d.cts +8 -0
- package/dist/components/inputOtp/InputOtp.d.cts.map +1 -1
- package/dist/components/inputOtp/InputOtp.d.mts +8 -0
- package/dist/components/inputOtp/InputOtp.d.mts.map +1 -1
- package/dist/components/inputOtp/InputOtp.d.ts +8 -0
- package/dist/components/inputOtp/InputOtp.d.ts.map +1 -1
- package/dist/components/inputOtp/InputOtp.js +2 -1
- package/dist/components/inputOtp/InputOtp.js.map +2 -2
- package/dist/components/inputOtp/inputOtp.props.cjs +4 -0
- package/dist/components/inputOtp/inputOtp.props.cjs.map +2 -2
- package/dist/components/inputOtp/inputOtp.props.d.cts +4 -0
- package/dist/components/inputOtp/inputOtp.props.d.cts.map +1 -1
- package/dist/components/inputOtp/inputOtp.props.d.mts +4 -0
- package/dist/components/inputOtp/inputOtp.props.d.mts.map +1 -1
- package/dist/components/inputOtp/inputOtp.props.d.ts +4 -0
- package/dist/components/inputOtp/inputOtp.props.d.ts.map +1 -1
- package/dist/components/inputOtp/inputOtp.props.js +4 -0
- package/dist/components/inputOtp/inputOtp.props.js.map +2 -2
- package/dist/components/link.css +21 -0
- package/dist/components/rich-text-editor.css +2 -0
- package/dist/components/richTextEditor/EditorTools.cjs +98 -44
- package/dist/components/richTextEditor/EditorTools.cjs.map +2 -2
- package/dist/components/richTextEditor/EditorTools.d.cts +51 -1
- package/dist/components/richTextEditor/EditorTools.d.cts.map +1 -1
- package/dist/components/richTextEditor/EditorTools.d.mts +51 -1
- package/dist/components/richTextEditor/EditorTools.d.mts.map +1 -1
- package/dist/components/richTextEditor/EditorTools.d.ts +51 -1
- package/dist/components/richTextEditor/EditorTools.d.ts.map +1 -1
- package/dist/components/richTextEditor/EditorTools.js +98 -44
- package/dist/components/richTextEditor/EditorTools.js.map +2 -2
- package/dist/components/richTextEditor/MentionSuggestions.cjs +6 -7
- package/dist/components/richTextEditor/MentionSuggestions.cjs.map +2 -2
- package/dist/components/richTextEditor/MentionSuggestions.d.cts +3 -1
- package/dist/components/richTextEditor/MentionSuggestions.d.cts.map +1 -1
- package/dist/components/richTextEditor/MentionSuggestions.d.mts +3 -1
- package/dist/components/richTextEditor/MentionSuggestions.d.mts.map +1 -1
- package/dist/components/richTextEditor/MentionSuggestions.d.ts +3 -1
- package/dist/components/richTextEditor/MentionSuggestions.d.ts.map +1 -1
- package/dist/components/richTextEditor/MentionSuggestions.js +6 -7
- package/dist/components/richTextEditor/MentionSuggestions.js.map +2 -2
- package/dist/components/richTextEditor/RichTextEditor.cjs +17 -10
- package/dist/components/richTextEditor/RichTextEditor.cjs.map +3 -3
- package/dist/components/richTextEditor/RichTextEditor.d.cts +2 -1
- package/dist/components/richTextEditor/RichTextEditor.d.cts.map +1 -1
- package/dist/components/richTextEditor/RichTextEditor.d.mts +2 -1
- package/dist/components/richTextEditor/RichTextEditor.d.mts.map +1 -1
- package/dist/components/richTextEditor/RichTextEditor.d.ts +2 -1
- package/dist/components/richTextEditor/RichTextEditor.d.ts.map +1 -1
- package/dist/components/richTextEditor/RichTextEditor.js +17 -10
- package/dist/components/richTextEditor/RichTextEditor.js.map +3 -3
- package/dist/components/segmented-control.css +14 -5
- package/dist/docs/component-index.json +1 -1
- package/dist/docs/components/alert.md +4 -0
- package/dist/docs/components/box.md +3 -1
- package/dist/docs/components/config-drawer.md +3 -1
- package/dist/docs/components/grid.md +2 -0
- package/dist/docs/components/input-otp.md +10 -2
- package/dist/docs/components/layout-props.md +4 -1
- package/dist/docs/components/link.md +4 -0
- package/dist/docs/components/rich-text-editor.md +6 -1
- package/dist/docs/components/segmented-control.md +3 -2
- package/dist/layout/Layout.cjs +13 -9
- package/dist/layout/Layout.cjs.map +2 -2
- package/dist/layout/Layout.d.cts.map +1 -1
- package/dist/layout/Layout.d.mts.map +1 -1
- package/dist/layout/Layout.d.ts.map +1 -1
- package/dist/layout/Layout.js +13 -9
- package/dist/layout/Layout.js.map +2 -2
- package/dist/layout/grid-area.cjs +32 -0
- package/dist/layout/grid-area.cjs.map +7 -0
- package/dist/layout/grid-area.d.cts +12 -0
- package/dist/layout/grid-area.d.cts.map +1 -0
- package/dist/layout/grid-area.d.mts +12 -0
- package/dist/layout/grid-area.d.mts.map +1 -0
- package/dist/layout/grid-area.d.ts +12 -0
- package/dist/layout/grid-area.d.ts.map +1 -0
- package/dist/layout/grid-area.js +12 -0
- package/dist/layout/grid-area.js.map +7 -0
- package/dist/styles.css +11366 -12134
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/richTextEditor/EditorTools.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react'\nimport { NodeSelection, TextSelection } from '@tiptap/pm/state'\nimport type { Editor } from '@tiptap/react'\ntype Level = 1 | 2 | 3 | 4 | 5 | 6\nimport { Button } from '../button/Button'\nimport { Icon } from '../icon/Icon'\nimport { Toolbar } from '../toolbar/Toolbar'\nimport { DropdownMenu } from '../dropdownMenu/DropdownMenu'\nimport { Popover } from '../popover/Popover'\nimport { TextField } from '../textField/TextField'\nimport { VisuallyHidden } from '../visuallyHidden/VisuallyHidden'\nimport { MentionSuggestions } from './MentionSuggestions'\nimport type { EditorVariable, EditorMention } from './editorTokens'\n\nexport type EditorTool = 'style' | 'bold' | 'italic' | 'strike' | 'code' | 'bulletList' | 'orderedList' | 'blockquote' | 'codeBlock' | 'link' | 'clear' | 'history'\nexport interface EditorInsertItem { id: string; label: string; insert: (editor: Editor) => void }\nexport interface EditorToolsOptions {\n tools?: readonly EditorTool[]\n headingLevels?: readonly Level[]\n insertItems?: readonly EditorInsertItem[]\n variables?: readonly EditorVariable[]\n mentions?: readonly EditorMention[]\n}\nconst defaults: EditorTool[] = ['style', 'bold', 'italic', 'strike', 'code', 'bulletList', 'orderedList', 'blockquote', 'codeBlock', 'link', 'clear', 'history']\nfunction Control({ children, ...props }: React.ComponentProps<typeof Button>) {\n return <Toolbar.Button asChild disabled={props.disabled}><Button type=\"button\" size=\"sm\" variant=\"ghost\" className=\"dsx-rich-text-editor__toolbar-button\" {...props}>{children}</Button></Toolbar.Button>\n}\nfunction TokenPicker({ editor, disabled, records, kind }: { editor: Editor; disabled: boolean; records: readonly (EditorVariable | EditorMention)[]; kind: 'variable' | 'mention' }) {\n const [open, setOpen] = React.useState(false)\n const [query, setQuery] = React.useState('')\n const [active, setActive] = React.useState(0)\n const listId = React.useId()\n const matches = records.filter(record => `${record.label} ${'key' in record ? record.key : record.id}`.toLowerCase().includes(query.toLowerCase()))\n const insert = (index: number) => {\n const record = matches[index]\n if (!record) return\n editor.chain().focus().insertContent({ type: kind === 'variable' ? 'dsxVariable' : 'dsxMention', attrs: 'key' in record ? { key: record.key } : { userId: record.id } }).run()\n setOpen(false)\n }\n return <Popover open={open} onOpenChange={next => { setOpen(next); setQuery(''); setActive(0) }}>\n <Popover.Trigger asChild><Control disabled={disabled}>{kind === 'variable' ? 'Variable' : 'Mention'}</Control></Popover.Trigger>\n <Popover.Content className=\"dsx-editor-tools__popover\" align=\"start\" onCloseAutoFocus={event => { event.preventDefault(); editor.commands.focus() }}>\n <Popover.Title>{kind === 'variable' ? 'Insert variable' : 'Mention someone'}</Popover.Title>\n <Popover.Description>{kind === 'variable' ? 'Insert a key. Its value is resolved by your application.' : 'Select a person to insert their stable identity.'}</Popover.Description>\n <TextField><TextField.Input aria-label={kind === 'variable' ? 'Search variables' : 'Search people'} role=\"combobox\" aria-expanded=\"true\" aria-controls={listId} aria-activedescendant={matches.length ? `${listId}-${active}` : undefined} value={query} onChange={event => { setQuery(event.target.value); setActive(0) }} onKeyDown={event => {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') { event.preventDefault(); setActive(index => Math.max(0, Math.min(matches.length - 1, index + (event.key === 'ArrowDown' ? 1 : -1)))) }\n if (event.key === 'Enter') { event.preventDefault(); insert(active) }\n }} /></TextField>\n <div id={listId} role=\"listbox\" aria-label={kind === 'variable' ? 'Variables' : 'People'} className=\"dsx-editor-tools__choices\">\n {matches.map((record, index) => <Button id={`${listId}-${index}`} key={'key' in record ? record.key : record.id} role=\"option\" aria-selected={active === index} type=\"button\" variant={active === index ? 'secondary' : 'ghost'} size=\"lg\" onClick={() => insert(index)} onPointerMove={() => setActive(index)}>\n <span>{record.label}{'sensitive' in record && record.sensitive ? ' \u00B7 Sensitive' : ''}<small>{'key' in record ? record.key : record.id}</small></span>\n </Button>)}\n {!matches.length ? <span role=\"status\">No matches</span> : null}\n </div>\n </Popover.Content>\n </Popover>\n}\nfunction LinkControl({ editor, disabled }: { editor: Editor; disabled: boolean }) {\n const [open, setOpen] = React.useState(false)\n const [url, setUrl] = React.useState('')\n const [error, setError] = React.useState('')\n const urlId = React.useId()\n const selection = React.useRef({ from: 1, to: 1 })\n const save = () => {\n let href: string\n try { const parsed = new URL(url); if (!['https:', 'http:', 'mailto:', 'tel:'].includes(parsed.protocol)) throw new Error(); href = parsed.href } catch { setError('Enter a valid https, http, mailto or tel URL.'); return }\n const chain = editor.chain().focus().setTextSelection(selection.current)\n if (selection.current.from === selection.current.to && !editor.isActive('link')) chain.insertContent({ type: 'text', text: href, marks: [{ type: 'link', attrs: { href } }] }).run()\n else chain.extendMarkRange('link').setLink({ href }).run()\n setOpen(false)\n }\n return <Popover open={open} onOpenChange={next => { if (next) { selection.current = { from: editor.state.selection.from, to: editor.state.selection.to }; setUrl(editor.getAttributes('link').href ?? ''); setError('') }; setOpen(next) }}>\n <Popover.Trigger asChild><Control disabled={disabled} aria-label=\"Link\" aria-pressed={editor.isActive('link')}><Icon name=\"link\" size=\"sm\" /></Control></Popover.Trigger>\n <Popover.Content className=\"dsx-editor-tools__popover dsx-editor-tools__link\" align=\"start\" onCloseAutoFocus={event => { event.preventDefault(); editor.commands.focus() }}>\n <Popover.Title>Edit link</Popover.Title><VisuallyHidden asChild><Popover.Description>Link the selected text or insert a URL at the caret.</Popover.Description></VisuallyHidden>\n <TextField id={urlId} label=\"URL\" errorText={error || undefined} invalid={Boolean(error)}><TextField.Input value={url} onChange={event => { setUrl(event.target.value); setError('') }} onKeyDown={event => { if (event.key === 'Enter') { event.preventDefault(); save() } }} /></TextField>\n <div className=\"dsx-editor-tools__actions\"><Button type=\"button\" size=\"md\" onClick={save}>Save link</Button><Button type=\"button\" size=\"md\" variant=\"outline\" disabled={!editor.isActive('link')} onClick={() => { editor.chain().focus().setTextSelection(selection.current).extendMarkRange('link').unsetLink().run(); setOpen(false) }}>Remove link</Button></div>\n </Popover.Content>\n </Popover>\n}\nexport function EditorTools({ editor, disabled, tools = defaults, headingLevels, insertItems = [], variables = [], mentions = [] }: EditorToolsOptions & { editor: Editor | null; disabled: boolean }) {\n const [, refresh] = React.useReducer(value => value + 1, 0)\n React.useEffect(() => { if (!editor) return; editor.on('transaction', refresh); return () => { editor.off('transaction', refresh) } }, [editor])\n const available = (tool: EditorTool, name?: string) => tools.includes(tool) && (!name || Boolean(editor?.schema.nodes[name] || editor?.schema.marks[name]))\n const levels = headingLevels ?? editor?.extensionManager.extensions.find(extension => extension.name === 'heading')?.options.levels ?? [1, 2, 3]\n const format = (label: string, icon: React.ComponentProps<typeof Icon>['name'], name: string, run: () => void) => <Control key={name} disabled={disabled} aria-label={label} aria-pressed={editor?.isActive(name)} onMouseDown={event => event.preventDefault()} onClick={run}><Icon name={icon} size=\"sm\" /></Control>\n return <>\n {available('style') ? <div className=\"dsx-rich-text-editor__toolbar-group\" role=\"group\" aria-label=\"Block style\"><DropdownMenu><DropdownMenu.Trigger asChild><Control disabled={disabled}>Text style <Icon name=\"chevron-down\" size=\"sm\" /></Control></DropdownMenu.Trigger><DropdownMenu.Content onCloseAutoFocus={event => { event.preventDefault(); editor?.commands.focus() }}>\n <DropdownMenu.Item onSelect={() => editor?.chain().focus().setParagraph().run()}>Paragraph</DropdownMenu.Item>\n {editor?.schema.nodes.heading ? (levels as Level[]).map(level => <DropdownMenu.Item key={level} onSelect={() => editor.chain().focus().toggleHeading({ level }).run()}>Heading {level}</DropdownMenu.Item>) : null}\n {available('blockquote', 'blockquote') ? <DropdownMenu.Item onSelect={() => editor?.chain().focus().toggleBlockquote().run()}>Quote block</DropdownMenu.Item> : null}\n {available('codeBlock', 'codeBlock') ? <DropdownMenu.Item onSelect={() => editor?.chain().focus().toggleCodeBlock().run()}>Code block</DropdownMenu.Item> : null}\n </DropdownMenu.Content></DropdownMenu></div> : null}\n <div className=\"dsx-rich-text-editor__toolbar-group\" role=\"group\" aria-label=\"Text style\">\n {available('bold', 'bold') ? format('Bold', 'bold', 'bold', () => editor?.chain().focus().toggleBold().run()) : null}\n {available('italic', 'italic') ? format('Italic', 'italic', 'italic', () => editor?.chain().focus().toggleItalic().run()) : null}\n {available('strike', 'strike') ? format('Strikethrough', 'strikethrough', 'strike', () => editor?.chain().focus().toggleStrike().run()) : null}\n {available('code', 'code') ? format('Inline code', 'code', 'code', () => editor?.chain().focus().toggleCode().run()) : null}\n {available('bulletList', 'bulletList') ? format('Bulleted list', 'list', 'bulletList', () => editor?.chain().focus().toggleBulletList().run()) : null}\n {available('orderedList', 'orderedList') ? format('Numbered list', 'list-ordered', 'orderedList', () => editor?.chain().focus().toggleOrderedList().run()) : null}\n </div>\n {editor ? <div className=\"dsx-rich-text-editor__toolbar-group\" role=\"group\" aria-label=\"Insert\">\n {available('link', 'link') ? <LinkControl editor={editor} disabled={disabled} /> : null}\n {insertItems.length ? <DropdownMenu><DropdownMenu.Trigger asChild><Control disabled={disabled}>Insert <Icon name=\"plus\" size=\"sm\" /></Control></DropdownMenu.Trigger><DropdownMenu.Content onCloseAutoFocus={event => { event.preventDefault(); editor.commands.focus() }}>{insertItems.map(item => <DropdownMenu.Item key={item.id} onSelect={() => {\n if (editor.state.selection instanceof NodeSelection) editor.commands.command(({ tr }) => {\n const paragraph = editor.schema.nodes.paragraph\n if (!paragraph) return false\n let point = tr.doc.resolve(tr.selection.to)\n while (point.depth > 0 && !point.parent.canReplaceWith(point.index(), point.index(), paragraph)) point = tr.doc.resolve(point.after())\n tr.insert(point.pos, paragraph.create())\n tr.setSelection(TextSelection.create(tr.doc, point.pos + 1))\n return true\n })\n item.insert(editor)\n }}>{item.label}</DropdownMenu.Item>)}</DropdownMenu.Content></DropdownMenu> : null}\n {variables.length && editor.schema.nodes.dsxVariable ? <TokenPicker editor={editor} disabled={disabled} kind=\"variable\" records={variables} /> : null}\n {mentions.length && editor.schema.nodes.dsxMention ? <TokenPicker editor={editor} disabled={disabled} kind=\"mention\" records={mentions} /> : null}\n {available('clear') ? format('Clear formatting', 'eraser', '', () => editor.chain().focus().clearNodes().unsetAllMarks().run()) : null}\n </div> : null}\n {available('history') ? <div className=\"dsx-rich-text-editor__toolbar-group\" role=\"group\" aria-label=\"History\"><Control disabled={disabled || !editor?.can().undo()} aria-label=\"Undo\" onMouseDown={event => event.preventDefault()} onClick={() => editor?.chain().focus().undo().run()}><Icon name=\"undo\" size=\"sm\" /></Control><Control disabled={disabled || !editor?.can().redo()} aria-label=\"Redo\" onMouseDown={event => event.preventDefault()} onClick={() => editor?.chain().focus().redo().run()}><Icon name=\"redo\" size=\"sm\" /></Control></div> : null}\n {editor && mentions.length && editor.schema.nodes.dsxMention ? <MentionSuggestions editor={editor} mentions={mentions} /> : null}\n </>\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,mBAA6C;AAG7C,oBAAuB;AACvB,kBAAqB;AACrB,qBAAwB;AACxB,0BAA6B;AAC7B,qBAAwB;AACxB,uBAA0B;AAC1B,4BAA+B;AAC/B,gCAAmC;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react'\nimport { NodeSelection, TextSelection } from '@tiptap/pm/state'\nimport type { Editor } from '@tiptap/react'\ntype Level = 1 | 2 | 3 | 4 | 5 | 6\nimport { Button } from '../button/Button'\nimport { Icon } from '../icon/Icon'\nimport { Toolbar } from '../toolbar/Toolbar'\nimport { DropdownMenu } from '../dropdownMenu/DropdownMenu'\nimport { Popover } from '../popover/Popover'\nimport { TextField } from '../textField/TextField'\nimport { VisuallyHidden } from '../visuallyHidden/VisuallyHidden'\nimport { MentionSuggestions } from './MentionSuggestions'\nimport type { EditorVariable, EditorMention } from './editorTokens'\n\nexport type EditorTool = 'style' | 'bold' | 'italic' | 'strike' | 'code' | 'bulletList' | 'orderedList' | 'blockquote' | 'codeBlock' | 'link' | 'clear' | 'history'\nexport interface EditorInsertItem { id: string; label: string; insert: (editor: Editor) => void }\nexport interface EditorToolsOptions {\n tools?: readonly EditorTool[]\n headingLevels?: readonly Level[]\n insertItems?: readonly EditorInsertItem[]\n variables?: readonly EditorVariable[]\n mentions?: readonly EditorMention[]\n localeText?: Partial<RichTextEditorLocaleText>\n}\nexport interface RichTextEditorLocaleText {\n loading: string\n empty: string\n characterCount: (count: number) => string\n toolbarLabel: string\n blockStyleGroup: string\n textStyleGroup: string\n insertGroup: string\n historyGroup: string\n textStyle: string\n paragraph: string\n heading: (level: number) => string\n quoteBlock: string\n codeBlock: string\n insert: string\n bold: string\n italic: string\n strikethrough: string\n inlineCode: string\n bulletList: string\n orderedList: string\n link: string\n clearFormatting: string\n undo: string\n redo: string\n variable: string\n mention: string\n insertVariable: string\n mentionSomeone: string\n variableDescription: string\n mentionDescription: string\n searchVariables: string\n searchPeople: string\n variables: string\n people: string\n noMatches: string\n sensitiveSuffix: string\n editLink: string\n linkDescription: string\n urlLabel: string\n urlInvalid: string\n saveLink: string\n removeLink: string\n mentionSuggestions: string\n peopleMatching: (query: string) => string\n noMatchingPeople: string\n}\nexport const defaultRichTextEditorLocaleText: RichTextEditorLocaleText = {\n loading: 'Editor loading',\n empty: 'Ready to write',\n characterCount: (count) => `${count} characters`,\n toolbarLabel: 'Formatting toolbar',\n blockStyleGroup: 'Block style',\n textStyleGroup: 'Text style',\n insertGroup: 'Insert',\n historyGroup: 'History',\n textStyle: 'Text style',\n paragraph: 'Paragraph',\n heading: (level) => `Heading ${level}`,\n quoteBlock: 'Quote block',\n codeBlock: 'Code block',\n insert: 'Insert',\n bold: 'Bold',\n italic: 'Italic',\n strikethrough: 'Strikethrough',\n inlineCode: 'Inline code',\n bulletList: 'Bulleted list',\n orderedList: 'Numbered list',\n link: 'Link',\n clearFormatting: 'Clear formatting',\n undo: 'Undo',\n redo: 'Redo',\n variable: 'Variable',\n mention: 'Mention',\n insertVariable: 'Insert variable',\n mentionSomeone: 'Mention someone',\n variableDescription: 'Insert a key. Its value is resolved by your application.',\n mentionDescription: 'Select a person to insert their stable identity.',\n searchVariables: 'Search variables',\n searchPeople: 'Search people',\n variables: 'Variables',\n people: 'People',\n noMatches: 'No matches',\n sensitiveSuffix: ' \u00B7 Sensitive',\n editLink: 'Edit link',\n linkDescription: 'Link the selected text or insert a URL at the caret.',\n urlLabel: 'URL',\n urlInvalid: 'Enter a valid https, http, mailto or tel URL.',\n saveLink: 'Save link',\n removeLink: 'Remove link',\n mentionSuggestions: 'Mention suggestions',\n peopleMatching: (query) => `People matching @${query}`,\n noMatchingPeople: 'No matching people',\n}\nexport function resolveRichTextEditorLocaleText(localeText?: Partial<RichTextEditorLocaleText>): RichTextEditorLocaleText {\n return { ...defaultRichTextEditorLocaleText, ...localeText }\n}\nconst defaults: EditorTool[] = ['style', 'bold', 'italic', 'strike', 'code', 'bulletList', 'orderedList', 'blockquote', 'codeBlock', 'link', 'clear', 'history']\nfunction Control({ children, ...props }: React.ComponentProps<typeof Button>) {\n return <Toolbar.Button asChild disabled={props.disabled}><Button type=\"button\" size=\"sm\" variant=\"ghost\" className=\"dsx-rich-text-editor__toolbar-button\" {...props}>{children}</Button></Toolbar.Button>\n}\nfunction TokenPicker({ editor, disabled, records, kind, localeText }: { editor: Editor; disabled: boolean; records: readonly (EditorVariable | EditorMention)[]; kind: 'variable' | 'mention'; localeText?: Partial<RichTextEditorLocaleText> }) {\n const locale = resolveRichTextEditorLocaleText(localeText)\n const [open, setOpen] = React.useState(false)\n const [query, setQuery] = React.useState('')\n const [active, setActive] = React.useState(0)\n const listId = React.useId()\n const matches = records.filter(record => `${record.label} ${'key' in record ? record.key : record.id}`.toLowerCase().includes(query.toLowerCase()))\n const insert = (index: number) => {\n const record = matches[index]\n if (!record) return\n editor.chain().focus().insertContent({ type: kind === 'variable' ? 'dsxVariable' : 'dsxMention', attrs: 'key' in record ? { key: record.key } : { userId: record.id } }).run()\n setOpen(false)\n }\n return <Popover open={open} onOpenChange={next => { setOpen(next); setQuery(''); setActive(0) }}>\n <Popover.Trigger asChild><Control disabled={disabled}>{kind === 'variable' ? locale.variable : locale.mention}</Control></Popover.Trigger>\n <Popover.Content className=\"dsx-editor-tools__popover\" align=\"start\" onCloseAutoFocus={event => { event.preventDefault(); editor.commands.focus() }}>\n <Popover.Title>{kind === 'variable' ? locale.insertVariable : locale.mentionSomeone}</Popover.Title>\n <Popover.Description>{kind === 'variable' ? locale.variableDescription : locale.mentionDescription}</Popover.Description>\n <TextField><TextField.Input aria-label={kind === 'variable' ? locale.searchVariables : locale.searchPeople} role=\"combobox\" aria-expanded=\"true\" aria-controls={listId} aria-activedescendant={matches.length ? `${listId}-${active}` : undefined} value={query} onChange={event => { setQuery(event.target.value); setActive(0) }} onKeyDown={event => {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') { event.preventDefault(); setActive(index => Math.max(0, Math.min(matches.length - 1, index + (event.key === 'ArrowDown' ? 1 : -1)))) }\n if (event.key === 'Enter') { event.preventDefault(); insert(active) }\n }} /></TextField>\n <div id={listId} role=\"listbox\" aria-label={kind === 'variable' ? locale.variables : locale.people} className=\"dsx-editor-tools__choices\">\n {matches.map((record, index) => <Button id={`${listId}-${index}`} key={'key' in record ? record.key : record.id} role=\"option\" aria-selected={active === index} type=\"button\" variant={active === index ? 'secondary' : 'ghost'} size=\"lg\" onClick={() => insert(index)} onPointerMove={() => setActive(index)}>\n <span>{record.label}{'sensitive' in record && record.sensitive ? locale.sensitiveSuffix : ''}<small>{'key' in record ? record.key : record.id}</small></span>\n </Button>)}\n {!matches.length ? <span role=\"status\">{locale.noMatches}</span> : null}\n </div>\n </Popover.Content>\n </Popover>\n}\nfunction LinkControl({ editor, disabled, localeText }: { editor: Editor; disabled: boolean; localeText?: Partial<RichTextEditorLocaleText> }) {\n const locale = resolveRichTextEditorLocaleText(localeText)\n const [open, setOpen] = React.useState(false)\n const [url, setUrl] = React.useState('')\n const [error, setError] = React.useState('')\n const urlId = React.useId()\n const selection = React.useRef({ from: 1, to: 1 })\n const save = () => {\n let href: string\n try { const parsed = new URL(url); if (!['https:', 'http:', 'mailto:', 'tel:'].includes(parsed.protocol)) throw new Error(); href = parsed.href } catch { setError(locale.urlInvalid); return }\n const chain = editor.chain().focus().setTextSelection(selection.current)\n if (selection.current.from === selection.current.to && !editor.isActive('link')) chain.insertContent({ type: 'text', text: href, marks: [{ type: 'link', attrs: { href } }] }).run()\n else chain.extendMarkRange('link').setLink({ href }).run()\n setOpen(false)\n }\n return <Popover open={open} onOpenChange={next => { if (next) { selection.current = { from: editor.state.selection.from, to: editor.state.selection.to }; setUrl(editor.getAttributes('link').href ?? ''); setError('') }; setOpen(next) }}>\n <Popover.Trigger asChild><Control disabled={disabled} aria-label={locale.link} aria-pressed={editor.isActive('link')}><Icon name=\"link\" size=\"sm\" /></Control></Popover.Trigger>\n <Popover.Content className=\"dsx-editor-tools__popover dsx-editor-tools__link\" align=\"start\" onCloseAutoFocus={event => { event.preventDefault(); editor.commands.focus() }}>\n <Popover.Title>{locale.editLink}</Popover.Title><VisuallyHidden asChild><Popover.Description>{locale.linkDescription}</Popover.Description></VisuallyHidden>\n <TextField id={urlId} label={locale.urlLabel} errorText={error || undefined} invalid={Boolean(error)}><TextField.Input value={url} onChange={event => { setUrl(event.target.value); setError('') }} onKeyDown={event => { if (event.key === 'Enter') { event.preventDefault(); save() } }} /></TextField>\n <div className=\"dsx-editor-tools__actions\"><Button type=\"button\" size=\"md\" onClick={save}>{locale.saveLink}</Button><Button type=\"button\" size=\"md\" variant=\"outline\" disabled={!editor.isActive('link')} onClick={() => { editor.chain().focus().setTextSelection(selection.current).extendMarkRange('link').unsetLink().run(); setOpen(false) }}>{locale.removeLink}</Button></div>\n </Popover.Content>\n </Popover>\n}\nexport function EditorTools({ editor, disabled, tools = defaults, headingLevels, insertItems = [], variables = [], mentions = [], localeText }: EditorToolsOptions & { editor: Editor | null; disabled: boolean }) {\n const locale = resolveRichTextEditorLocaleText(localeText)\n const [, refresh] = React.useReducer(value => value + 1, 0)\n React.useEffect(() => { if (!editor) return; editor.on('transaction', refresh); return () => { editor.off('transaction', refresh) } }, [editor])\n const available = (tool: EditorTool, name?: string) => tools.includes(tool) && (!name || Boolean(editor?.schema.nodes[name] || editor?.schema.marks[name]))\n const levels = headingLevels ?? editor?.extensionManager.extensions.find(extension => extension.name === 'heading')?.options.levels ?? [1, 2, 3]\n const format = (label: string, icon: React.ComponentProps<typeof Icon>['name'], name: string, run: () => void) => <Control key={name} disabled={disabled} aria-label={label} aria-pressed={editor?.isActive(name)} onMouseDown={event => event.preventDefault()} onClick={run}><Icon name={icon} size=\"sm\" /></Control>\n return <>\n {available('style') ? <div className=\"dsx-rich-text-editor__toolbar-group\" role=\"group\" aria-label={locale.blockStyleGroup}><DropdownMenu><DropdownMenu.Trigger asChild><Control disabled={disabled}>{locale.textStyle} <Icon name=\"chevron-down\" size=\"sm\" /></Control></DropdownMenu.Trigger><DropdownMenu.Content onCloseAutoFocus={event => { event.preventDefault(); editor?.commands.focus() }}>\n <DropdownMenu.Item onSelect={() => editor?.chain().focus().setParagraph().run()}>{locale.paragraph}</DropdownMenu.Item>\n {editor?.schema.nodes.heading ? (levels as Level[]).map(level => <DropdownMenu.Item key={level} onSelect={() => editor.chain().focus().toggleHeading({ level }).run()}>{locale.heading(level)}</DropdownMenu.Item>) : null}\n {available('blockquote', 'blockquote') ? <DropdownMenu.Item onSelect={() => editor?.chain().focus().toggleBlockquote().run()}>{locale.quoteBlock}</DropdownMenu.Item> : null}\n {available('codeBlock', 'codeBlock') ? <DropdownMenu.Item onSelect={() => editor?.chain().focus().toggleCodeBlock().run()}>{locale.codeBlock}</DropdownMenu.Item> : null}\n </DropdownMenu.Content></DropdownMenu></div> : null}\n <div className=\"dsx-rich-text-editor__toolbar-group\" role=\"group\" aria-label={locale.textStyleGroup}>\n {available('bold', 'bold') ? format(locale.bold, 'bold', 'bold', () => editor?.chain().focus().toggleBold().run()) : null}\n {available('italic', 'italic') ? format(locale.italic, 'italic', 'italic', () => editor?.chain().focus().toggleItalic().run()) : null}\n {available('strike', 'strike') ? format(locale.strikethrough, 'strikethrough', 'strike', () => editor?.chain().focus().toggleStrike().run()) : null}\n {available('code', 'code') ? format(locale.inlineCode, 'code', 'code', () => editor?.chain().focus().toggleCode().run()) : null}\n {available('bulletList', 'bulletList') ? format(locale.bulletList, 'list', 'bulletList', () => editor?.chain().focus().toggleBulletList().run()) : null}\n {available('orderedList', 'orderedList') ? format(locale.orderedList, 'list-ordered', 'orderedList', () => editor?.chain().focus().toggleOrderedList().run()) : null}\n </div>\n {editor ? <div className=\"dsx-rich-text-editor__toolbar-group\" role=\"group\" aria-label={locale.insertGroup}>\n {available('link', 'link') ? <LinkControl editor={editor} disabled={disabled} localeText={localeText} /> : null}\n {insertItems.length ? <DropdownMenu><DropdownMenu.Trigger asChild><Control disabled={disabled}>{locale.insert} <Icon name=\"plus\" size=\"sm\" /></Control></DropdownMenu.Trigger><DropdownMenu.Content onCloseAutoFocus={event => { event.preventDefault(); editor.commands.focus() }}>{insertItems.map(item => <DropdownMenu.Item key={item.id} onSelect={() => {\n if (editor.state.selection instanceof NodeSelection) editor.commands.command(({ tr }) => {\n const paragraph = editor.schema.nodes.paragraph\n if (!paragraph) return false\n let point = tr.doc.resolve(tr.selection.to)\n while (point.depth > 0 && !point.parent.canReplaceWith(point.index(), point.index(), paragraph)) point = tr.doc.resolve(point.after())\n tr.insert(point.pos, paragraph.create())\n tr.setSelection(TextSelection.create(tr.doc, point.pos + 1))\n return true\n })\n item.insert(editor)\n }}>{item.label}</DropdownMenu.Item>)}</DropdownMenu.Content></DropdownMenu> : null}\n {variables.length && editor.schema.nodes.dsxVariable ? <TokenPicker editor={editor} disabled={disabled} kind=\"variable\" records={variables} localeText={localeText} /> : null}\n {mentions.length && editor.schema.nodes.dsxMention ? <TokenPicker editor={editor} disabled={disabled} kind=\"mention\" records={mentions} localeText={localeText} /> : null}\n {available('clear') ? format(locale.clearFormatting, 'eraser', '', () => editor.chain().focus().clearNodes().unsetAllMarks().run()) : null}\n </div> : null}\n {available('history') ? <div className=\"dsx-rich-text-editor__toolbar-group\" role=\"group\" aria-label={locale.historyGroup}><Control disabled={disabled || !editor?.can().undo()} aria-label={locale.undo} onMouseDown={event => event.preventDefault()} onClick={() => editor?.chain().focus().undo().run()}><Icon name=\"undo\" size=\"sm\" /></Control><Control disabled={disabled || !editor?.can().redo()} aria-label={locale.redo} onMouseDown={event => event.preventDefault()} onClick={() => editor?.chain().focus().redo().run()}><Icon name=\"redo\" size=\"sm\" /></Control></div> : null}\n {editor && mentions.length && editor.schema.nodes.dsxMention ? <MentionSuggestions editor={editor} mentions={mentions} localeText={localeText} /> : null}\n </>\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,mBAA6C;AAG7C,oBAAuB;AACvB,kBAAqB;AACrB,qBAAwB;AACxB,0BAA6B;AAC7B,qBAAwB;AACxB,uBAA0B;AAC1B,4BAA+B;AAC/B,gCAAmC;AAgHwB;AApDpD,MAAM,kCAA4D;AAAA,EACvE,SAAS;AAAA,EACT,OAAO;AAAA,EACP,gBAAgB,CAAC,UAAU,GAAG,KAAK;AAAA,EACnC,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,cAAc;AAAA,EACd,WAAW;AAAA,EACX,WAAW;AAAA,EACX,SAAS,CAAC,UAAU,WAAW,KAAK;AAAA,EACpC,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,QAAQ;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;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -13,8 +13,58 @@ export interface EditorToolsOptions {
|
|
|
13
13
|
insertItems?: readonly EditorInsertItem[];
|
|
14
14
|
variables?: readonly EditorVariable[];
|
|
15
15
|
mentions?: readonly EditorMention[];
|
|
16
|
+
localeText?: Partial<RichTextEditorLocaleText>;
|
|
16
17
|
}
|
|
17
|
-
export
|
|
18
|
+
export interface RichTextEditorLocaleText {
|
|
19
|
+
loading: string;
|
|
20
|
+
empty: string;
|
|
21
|
+
characterCount: (count: number) => string;
|
|
22
|
+
toolbarLabel: string;
|
|
23
|
+
blockStyleGroup: string;
|
|
24
|
+
textStyleGroup: string;
|
|
25
|
+
insertGroup: string;
|
|
26
|
+
historyGroup: string;
|
|
27
|
+
textStyle: string;
|
|
28
|
+
paragraph: string;
|
|
29
|
+
heading: (level: number) => string;
|
|
30
|
+
quoteBlock: string;
|
|
31
|
+
codeBlock: string;
|
|
32
|
+
insert: string;
|
|
33
|
+
bold: string;
|
|
34
|
+
italic: string;
|
|
35
|
+
strikethrough: string;
|
|
36
|
+
inlineCode: string;
|
|
37
|
+
bulletList: string;
|
|
38
|
+
orderedList: string;
|
|
39
|
+
link: string;
|
|
40
|
+
clearFormatting: string;
|
|
41
|
+
undo: string;
|
|
42
|
+
redo: string;
|
|
43
|
+
variable: string;
|
|
44
|
+
mention: string;
|
|
45
|
+
insertVariable: string;
|
|
46
|
+
mentionSomeone: string;
|
|
47
|
+
variableDescription: string;
|
|
48
|
+
mentionDescription: string;
|
|
49
|
+
searchVariables: string;
|
|
50
|
+
searchPeople: string;
|
|
51
|
+
variables: string;
|
|
52
|
+
people: string;
|
|
53
|
+
noMatches: string;
|
|
54
|
+
sensitiveSuffix: string;
|
|
55
|
+
editLink: string;
|
|
56
|
+
linkDescription: string;
|
|
57
|
+
urlLabel: string;
|
|
58
|
+
urlInvalid: string;
|
|
59
|
+
saveLink: string;
|
|
60
|
+
removeLink: string;
|
|
61
|
+
mentionSuggestions: string;
|
|
62
|
+
peopleMatching: (query: string) => string;
|
|
63
|
+
noMatchingPeople: string;
|
|
64
|
+
}
|
|
65
|
+
export declare const defaultRichTextEditorLocaleText: RichTextEditorLocaleText;
|
|
66
|
+
export declare function resolveRichTextEditorLocaleText(localeText?: Partial<RichTextEditorLocaleText>): RichTextEditorLocaleText;
|
|
67
|
+
export declare function EditorTools({ editor, disabled, tools, headingLevels, insertItems, variables, mentions, localeText }: EditorToolsOptions & {
|
|
18
68
|
editor: Editor | null;
|
|
19
69
|
disabled: boolean;
|
|
20
70
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorTools.d.cts","sourceRoot":"","sources":["../../../src/components/richTextEditor/EditorTools.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,KAAK,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AASlC,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnE,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,YAAY,GAAG,aAAa,GAAG,YAAY,GAAG,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;AACnK,MAAM,WAAW,gBAAgB;IAAG,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE;AACjG,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,SAAS,UAAU,EAAE,CAAA;IAC7B,aAAa,CAAC,EAAE,SAAS,KAAK,EAAE,CAAA;IAChC,WAAW,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAA;IACzC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AC1B,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IACzC,gBAAgB,EAAE,MAAM,CAAA;CACzB;AACD,eAAO,MAAM,+BAA+B,EAAE,wBA8C7C,CAAA;AACD,wBAAgB,+BAA+B,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,GAAG,wBAAwB,CAExH;AA4DD,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAgB,EAAE,aAAa,EAAE,WAAgB,EAAE,SAAc,EAAE,QAAa,EAAE,UAAU,EAAE,EAAE,kBAAkB,GAAG;IAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,2CA2ChN"}
|
|
@@ -13,8 +13,58 @@ export interface EditorToolsOptions {
|
|
|
13
13
|
insertItems?: readonly EditorInsertItem[];
|
|
14
14
|
variables?: readonly EditorVariable[];
|
|
15
15
|
mentions?: readonly EditorMention[];
|
|
16
|
+
localeText?: Partial<RichTextEditorLocaleText>;
|
|
16
17
|
}
|
|
17
|
-
export
|
|
18
|
+
export interface RichTextEditorLocaleText {
|
|
19
|
+
loading: string;
|
|
20
|
+
empty: string;
|
|
21
|
+
characterCount: (count: number) => string;
|
|
22
|
+
toolbarLabel: string;
|
|
23
|
+
blockStyleGroup: string;
|
|
24
|
+
textStyleGroup: string;
|
|
25
|
+
insertGroup: string;
|
|
26
|
+
historyGroup: string;
|
|
27
|
+
textStyle: string;
|
|
28
|
+
paragraph: string;
|
|
29
|
+
heading: (level: number) => string;
|
|
30
|
+
quoteBlock: string;
|
|
31
|
+
codeBlock: string;
|
|
32
|
+
insert: string;
|
|
33
|
+
bold: string;
|
|
34
|
+
italic: string;
|
|
35
|
+
strikethrough: string;
|
|
36
|
+
inlineCode: string;
|
|
37
|
+
bulletList: string;
|
|
38
|
+
orderedList: string;
|
|
39
|
+
link: string;
|
|
40
|
+
clearFormatting: string;
|
|
41
|
+
undo: string;
|
|
42
|
+
redo: string;
|
|
43
|
+
variable: string;
|
|
44
|
+
mention: string;
|
|
45
|
+
insertVariable: string;
|
|
46
|
+
mentionSomeone: string;
|
|
47
|
+
variableDescription: string;
|
|
48
|
+
mentionDescription: string;
|
|
49
|
+
searchVariables: string;
|
|
50
|
+
searchPeople: string;
|
|
51
|
+
variables: string;
|
|
52
|
+
people: string;
|
|
53
|
+
noMatches: string;
|
|
54
|
+
sensitiveSuffix: string;
|
|
55
|
+
editLink: string;
|
|
56
|
+
linkDescription: string;
|
|
57
|
+
urlLabel: string;
|
|
58
|
+
urlInvalid: string;
|
|
59
|
+
saveLink: string;
|
|
60
|
+
removeLink: string;
|
|
61
|
+
mentionSuggestions: string;
|
|
62
|
+
peopleMatching: (query: string) => string;
|
|
63
|
+
noMatchingPeople: string;
|
|
64
|
+
}
|
|
65
|
+
export declare const defaultRichTextEditorLocaleText: RichTextEditorLocaleText;
|
|
66
|
+
export declare function resolveRichTextEditorLocaleText(localeText?: Partial<RichTextEditorLocaleText>): RichTextEditorLocaleText;
|
|
67
|
+
export declare function EditorTools({ editor, disabled, tools, headingLevels, insertItems, variables, mentions, localeText }: EditorToolsOptions & {
|
|
18
68
|
editor: Editor | null;
|
|
19
69
|
disabled: boolean;
|
|
20
70
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorTools.d.mts","sourceRoot":"","sources":["../../../src/components/richTextEditor/EditorTools.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,KAAK,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AASlC,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnE,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG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AAM,CAAA;IAC3B,kBAAkB,EAAE,MAAM,CAAA;IAC1B,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,MAAM,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,eAAe,EAAE,MAAM,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IACzC,gBAAgB,EAAE,MAAM,CAAA;CACzB;AACD,eAAO,MAAM,+BAA+B,EAAE,wBA8C7C,CAAA;AACD,wBAAgB,+BAA+B,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,GAAG,wBAAwB,CAExH;AA4DD,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAgB,EAAE,aAAa,EAAE,WAAgB,EAAE,SAAc,EAAE,QAAa,EAAE,UAAU,EAAE,EAAE,kBAAkB,GAAG;IAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,2CA2ChN"}
|
|
@@ -13,8 +13,58 @@ export interface EditorToolsOptions {
|
|
|
13
13
|
insertItems?: readonly EditorInsertItem[];
|
|
14
14
|
variables?: readonly EditorVariable[];
|
|
15
15
|
mentions?: readonly EditorMention[];
|
|
16
|
+
localeText?: Partial<RichTextEditorLocaleText>;
|
|
16
17
|
}
|
|
17
|
-
export
|
|
18
|
+
export interface RichTextEditorLocaleText {
|
|
19
|
+
loading: string;
|
|
20
|
+
empty: string;
|
|
21
|
+
characterCount: (count: number) => string;
|
|
22
|
+
toolbarLabel: string;
|
|
23
|
+
blockStyleGroup: string;
|
|
24
|
+
textStyleGroup: string;
|
|
25
|
+
insertGroup: string;
|
|
26
|
+
historyGroup: string;
|
|
27
|
+
textStyle: string;
|
|
28
|
+
paragraph: string;
|
|
29
|
+
heading: (level: number) => string;
|
|
30
|
+
quoteBlock: string;
|
|
31
|
+
codeBlock: string;
|
|
32
|
+
insert: string;
|
|
33
|
+
bold: string;
|
|
34
|
+
italic: string;
|
|
35
|
+
strikethrough: string;
|
|
36
|
+
inlineCode: string;
|
|
37
|
+
bulletList: string;
|
|
38
|
+
orderedList: string;
|
|
39
|
+
link: string;
|
|
40
|
+
clearFormatting: string;
|
|
41
|
+
undo: string;
|
|
42
|
+
redo: string;
|
|
43
|
+
variable: string;
|
|
44
|
+
mention: string;
|
|
45
|
+
insertVariable: string;
|
|
46
|
+
mentionSomeone: string;
|
|
47
|
+
variableDescription: string;
|
|
48
|
+
mentionDescription: string;
|
|
49
|
+
searchVariables: string;
|
|
50
|
+
searchPeople: string;
|
|
51
|
+
variables: string;
|
|
52
|
+
people: string;
|
|
53
|
+
noMatches: string;
|
|
54
|
+
sensitiveSuffix: string;
|
|
55
|
+
editLink: string;
|
|
56
|
+
linkDescription: string;
|
|
57
|
+
urlLabel: string;
|
|
58
|
+
urlInvalid: string;
|
|
59
|
+
saveLink: string;
|
|
60
|
+
removeLink: string;
|
|
61
|
+
mentionSuggestions: string;
|
|
62
|
+
peopleMatching: (query: string) => string;
|
|
63
|
+
noMatchingPeople: string;
|
|
64
|
+
}
|
|
65
|
+
export declare const defaultRichTextEditorLocaleText: RichTextEditorLocaleText;
|
|
66
|
+
export declare function resolveRichTextEditorLocaleText(localeText?: Partial<RichTextEditorLocaleText>): RichTextEditorLocaleText;
|
|
67
|
+
export declare function EditorTools({ editor, disabled, tools, headingLevels, insertItems, variables, mentions, localeText }: EditorToolsOptions & {
|
|
18
68
|
editor: Editor | null;
|
|
19
69
|
disabled: boolean;
|
|
20
70
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorTools.d.ts","sourceRoot":"","sources":["../../../src/components/richTextEditor/EditorTools.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,KAAK,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AASlC,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnE,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,YAAY,GAAG,aAAa,GAAG,YAAY,GAAG,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;AACnK,MAAM,WAAW,gBAAgB;IAAG,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE;AACjG,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,SAAS,UAAU,EAAE,CAAA;IAC7B,aAAa,CAAC,EAAE,SAAS,KAAK,EAAE,CAAA;IAChC,WAAW,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAA;IACzC,SAAS,CAAC,EAAE,SAAS,cAAc,EAAE,CAAA;IACrC,QAAQ,CAAC,EAAE,SAAS,aAAa,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"EditorTools.d.ts","sourceRoot":"","sources":["../../../src/components/richTextEditor/EditorTools.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,KAAK,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AASlC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,QAAa,EAAE,UAAU,EAAE,EAAE,kBAAkB,GAAG;IAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,2CA2ChN"}
|
|
@@ -9,11 +9,62 @@ import { TextField } from "../textField/TextField.js";
|
|
|
9
9
|
import { VisuallyHidden } from "../visuallyHidden/VisuallyHidden.js";
|
|
10
10
|
import { MentionSuggestions } from "./MentionSuggestions.js";
|
|
11
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
const defaultRichTextEditorLocaleText = {
|
|
13
|
+
loading: "Editor loading",
|
|
14
|
+
empty: "Ready to write",
|
|
15
|
+
characterCount: (count) => `${count} characters`,
|
|
16
|
+
toolbarLabel: "Formatting toolbar",
|
|
17
|
+
blockStyleGroup: "Block style",
|
|
18
|
+
textStyleGroup: "Text style",
|
|
19
|
+
insertGroup: "Insert",
|
|
20
|
+
historyGroup: "History",
|
|
21
|
+
textStyle: "Text style",
|
|
22
|
+
paragraph: "Paragraph",
|
|
23
|
+
heading: (level) => `Heading ${level}`,
|
|
24
|
+
quoteBlock: "Quote block",
|
|
25
|
+
codeBlock: "Code block",
|
|
26
|
+
insert: "Insert",
|
|
27
|
+
bold: "Bold",
|
|
28
|
+
italic: "Italic",
|
|
29
|
+
strikethrough: "Strikethrough",
|
|
30
|
+
inlineCode: "Inline code",
|
|
31
|
+
bulletList: "Bulleted list",
|
|
32
|
+
orderedList: "Numbered list",
|
|
33
|
+
link: "Link",
|
|
34
|
+
clearFormatting: "Clear formatting",
|
|
35
|
+
undo: "Undo",
|
|
36
|
+
redo: "Redo",
|
|
37
|
+
variable: "Variable",
|
|
38
|
+
mention: "Mention",
|
|
39
|
+
insertVariable: "Insert variable",
|
|
40
|
+
mentionSomeone: "Mention someone",
|
|
41
|
+
variableDescription: "Insert a key. Its value is resolved by your application.",
|
|
42
|
+
mentionDescription: "Select a person to insert their stable identity.",
|
|
43
|
+
searchVariables: "Search variables",
|
|
44
|
+
searchPeople: "Search people",
|
|
45
|
+
variables: "Variables",
|
|
46
|
+
people: "People",
|
|
47
|
+
noMatches: "No matches",
|
|
48
|
+
sensitiveSuffix: " \xB7 Sensitive",
|
|
49
|
+
editLink: "Edit link",
|
|
50
|
+
linkDescription: "Link the selected text or insert a URL at the caret.",
|
|
51
|
+
urlLabel: "URL",
|
|
52
|
+
urlInvalid: "Enter a valid https, http, mailto or tel URL.",
|
|
53
|
+
saveLink: "Save link",
|
|
54
|
+
removeLink: "Remove link",
|
|
55
|
+
mentionSuggestions: "Mention suggestions",
|
|
56
|
+
peopleMatching: (query) => `People matching @${query}`,
|
|
57
|
+
noMatchingPeople: "No matching people"
|
|
58
|
+
};
|
|
59
|
+
function resolveRichTextEditorLocaleText(localeText) {
|
|
60
|
+
return { ...defaultRichTextEditorLocaleText, ...localeText };
|
|
61
|
+
}
|
|
12
62
|
const defaults = ["style", "bold", "italic", "strike", "code", "bulletList", "orderedList", "blockquote", "codeBlock", "link", "clear", "history"];
|
|
13
63
|
function Control({ children, ...props }) {
|
|
14
64
|
return /* @__PURE__ */ jsx(Toolbar.Button, { asChild: true, disabled: props.disabled, children: /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "ghost", className: "dsx-rich-text-editor__toolbar-button", ...props, children }) });
|
|
15
65
|
}
|
|
16
|
-
function TokenPicker({ editor, disabled, records, kind }) {
|
|
66
|
+
function TokenPicker({ editor, disabled, records, kind, localeText }) {
|
|
67
|
+
const locale = resolveRichTextEditorLocaleText(localeText);
|
|
17
68
|
const [open, setOpen] = React.useState(false);
|
|
18
69
|
const [query, setQuery] = React.useState("");
|
|
19
70
|
const [active, setActive] = React.useState(0);
|
|
@@ -30,14 +81,14 @@ function TokenPicker({ editor, disabled, records, kind }) {
|
|
|
30
81
|
setQuery("");
|
|
31
82
|
setActive(0);
|
|
32
83
|
}, children: [
|
|
33
|
-
/* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(Control, { disabled, children: kind === "variable" ?
|
|
84
|
+
/* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(Control, { disabled, children: kind === "variable" ? locale.variable : locale.mention }) }),
|
|
34
85
|
/* @__PURE__ */ jsxs(Popover.Content, { className: "dsx-editor-tools__popover", align: "start", onCloseAutoFocus: (event) => {
|
|
35
86
|
event.preventDefault();
|
|
36
87
|
editor.commands.focus();
|
|
37
88
|
}, children: [
|
|
38
|
-
/* @__PURE__ */ jsx(Popover.Title, { children: kind === "variable" ?
|
|
39
|
-
/* @__PURE__ */ jsx(Popover.Description, { children: kind === "variable" ?
|
|
40
|
-
/* @__PURE__ */ jsx(TextField, { children: /* @__PURE__ */ jsx(TextField.Input, { "aria-label": kind === "variable" ?
|
|
89
|
+
/* @__PURE__ */ jsx(Popover.Title, { children: kind === "variable" ? locale.insertVariable : locale.mentionSomeone }),
|
|
90
|
+
/* @__PURE__ */ jsx(Popover.Description, { children: kind === "variable" ? locale.variableDescription : locale.mentionDescription }),
|
|
91
|
+
/* @__PURE__ */ jsx(TextField, { children: /* @__PURE__ */ jsx(TextField.Input, { "aria-label": kind === "variable" ? locale.searchVariables : locale.searchPeople, role: "combobox", "aria-expanded": "true", "aria-controls": listId, "aria-activedescendant": matches.length ? `${listId}-${active}` : void 0, value: query, onChange: (event) => {
|
|
41
92
|
setQuery(event.target.value);
|
|
42
93
|
setActive(0);
|
|
43
94
|
}, onKeyDown: (event) => {
|
|
@@ -50,18 +101,19 @@ function TokenPicker({ editor, disabled, records, kind }) {
|
|
|
50
101
|
insert(active);
|
|
51
102
|
}
|
|
52
103
|
} }) }),
|
|
53
|
-
/* @__PURE__ */ jsxs("div", { id: listId, role: "listbox", "aria-label": kind === "variable" ?
|
|
104
|
+
/* @__PURE__ */ jsxs("div", { id: listId, role: "listbox", "aria-label": kind === "variable" ? locale.variables : locale.people, className: "dsx-editor-tools__choices", children: [
|
|
54
105
|
matches.map((record, index) => /* @__PURE__ */ jsx(Button, { id: `${listId}-${index}`, role: "option", "aria-selected": active === index, type: "button", variant: active === index ? "secondary" : "ghost", size: "lg", onClick: () => insert(index), onPointerMove: () => setActive(index), children: /* @__PURE__ */ jsxs("span", { children: [
|
|
55
106
|
record.label,
|
|
56
|
-
"sensitive" in record && record.sensitive ?
|
|
107
|
+
"sensitive" in record && record.sensitive ? locale.sensitiveSuffix : "",
|
|
57
108
|
/* @__PURE__ */ jsx("small", { children: "key" in record ? record.key : record.id })
|
|
58
109
|
] }) }, "key" in record ? record.key : record.id)),
|
|
59
|
-
!matches.length ? /* @__PURE__ */ jsx("span", { role: "status", children:
|
|
110
|
+
!matches.length ? /* @__PURE__ */ jsx("span", { role: "status", children: locale.noMatches }) : null
|
|
60
111
|
] })
|
|
61
112
|
] })
|
|
62
113
|
] });
|
|
63
114
|
}
|
|
64
|
-
function LinkControl({ editor, disabled }) {
|
|
115
|
+
function LinkControl({ editor, disabled, localeText }) {
|
|
116
|
+
const locale = resolveRichTextEditorLocaleText(localeText);
|
|
65
117
|
const [open, setOpen] = React.useState(false);
|
|
66
118
|
const [url, setUrl] = React.useState("");
|
|
67
119
|
const [error, setError] = React.useState("");
|
|
@@ -74,7 +126,7 @@ function LinkControl({ editor, disabled }) {
|
|
|
74
126
|
if (!["https:", "http:", "mailto:", "tel:"].includes(parsed.protocol)) throw new Error();
|
|
75
127
|
href = parsed.href;
|
|
76
128
|
} catch {
|
|
77
|
-
setError(
|
|
129
|
+
setError(locale.urlInvalid);
|
|
78
130
|
return;
|
|
79
131
|
}
|
|
80
132
|
const chain = editor.chain().focus().setTextSelection(selection.current);
|
|
@@ -91,14 +143,14 @@ function LinkControl({ editor, disabled }) {
|
|
|
91
143
|
;
|
|
92
144
|
setOpen(next);
|
|
93
145
|
}, children: [
|
|
94
|
-
/* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(Control, { disabled, "aria-label":
|
|
146
|
+
/* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(Control, { disabled, "aria-label": locale.link, "aria-pressed": editor.isActive("link"), children: /* @__PURE__ */ jsx(Icon, { name: "link", size: "sm" }) }) }),
|
|
95
147
|
/* @__PURE__ */ jsxs(Popover.Content, { className: "dsx-editor-tools__popover dsx-editor-tools__link", align: "start", onCloseAutoFocus: (event) => {
|
|
96
148
|
event.preventDefault();
|
|
97
149
|
editor.commands.focus();
|
|
98
150
|
}, children: [
|
|
99
|
-
/* @__PURE__ */ jsx(Popover.Title, { children:
|
|
100
|
-
/* @__PURE__ */ jsx(VisuallyHidden, { asChild: true, children: /* @__PURE__ */ jsx(Popover.Description, { children:
|
|
101
|
-
/* @__PURE__ */ jsx(TextField, { id: urlId, label:
|
|
151
|
+
/* @__PURE__ */ jsx(Popover.Title, { children: locale.editLink }),
|
|
152
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { asChild: true, children: /* @__PURE__ */ jsx(Popover.Description, { children: locale.linkDescription }) }),
|
|
153
|
+
/* @__PURE__ */ jsx(TextField, { id: urlId, label: locale.urlLabel, errorText: error || void 0, invalid: Boolean(error), children: /* @__PURE__ */ jsx(TextField.Input, { value: url, onChange: (event) => {
|
|
102
154
|
setUrl(event.target.value);
|
|
103
155
|
setError("");
|
|
104
156
|
}, onKeyDown: (event) => {
|
|
@@ -108,16 +160,17 @@ function LinkControl({ editor, disabled }) {
|
|
|
108
160
|
}
|
|
109
161
|
} }) }),
|
|
110
162
|
/* @__PURE__ */ jsxs("div", { className: "dsx-editor-tools__actions", children: [
|
|
111
|
-
/* @__PURE__ */ jsx(Button, { type: "button", size: "md", onClick: save, children:
|
|
163
|
+
/* @__PURE__ */ jsx(Button, { type: "button", size: "md", onClick: save, children: locale.saveLink }),
|
|
112
164
|
/* @__PURE__ */ jsx(Button, { type: "button", size: "md", variant: "outline", disabled: !editor.isActive("link"), onClick: () => {
|
|
113
165
|
editor.chain().focus().setTextSelection(selection.current).extendMarkRange("link").unsetLink().run();
|
|
114
166
|
setOpen(false);
|
|
115
|
-
}, children:
|
|
167
|
+
}, children: locale.removeLink })
|
|
116
168
|
] })
|
|
117
169
|
] })
|
|
118
170
|
] });
|
|
119
171
|
}
|
|
120
|
-
function EditorTools({ editor, disabled, tools = defaults, headingLevels, insertItems = [], variables = [], mentions = [] }) {
|
|
172
|
+
function EditorTools({ editor, disabled, tools = defaults, headingLevels, insertItems = [], variables = [], mentions = [], localeText }) {
|
|
173
|
+
const locale = resolveRichTextEditorLocaleText(localeText);
|
|
121
174
|
const [, refresh] = React.useReducer((value) => value + 1, 0);
|
|
122
175
|
React.useEffect(() => {
|
|
123
176
|
if (!editor) return;
|
|
@@ -130,37 +183,36 @@ function EditorTools({ editor, disabled, tools = defaults, headingLevels, insert
|
|
|
130
183
|
const levels = headingLevels ?? editor?.extensionManager.extensions.find((extension) => extension.name === "heading")?.options.levels ?? [1, 2, 3];
|
|
131
184
|
const format = (label, icon, name, run) => /* @__PURE__ */ jsx(Control, { disabled, "aria-label": label, "aria-pressed": editor?.isActive(name), onMouseDown: (event) => event.preventDefault(), onClick: run, children: /* @__PURE__ */ jsx(Icon, { name: icon, size: "sm" }) }, name);
|
|
132
185
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
133
|
-
available("style") ? /* @__PURE__ */ jsx("div", { className: "dsx-rich-text-editor__toolbar-group", role: "group", "aria-label":
|
|
186
|
+
available("style") ? /* @__PURE__ */ jsx("div", { className: "dsx-rich-text-editor__toolbar-group", role: "group", "aria-label": locale.blockStyleGroup, children: /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
134
187
|
/* @__PURE__ */ jsx(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs(Control, { disabled, children: [
|
|
135
|
-
|
|
188
|
+
locale.textStyle,
|
|
189
|
+
" ",
|
|
136
190
|
/* @__PURE__ */ jsx(Icon, { name: "chevron-down", size: "sm" })
|
|
137
191
|
] }) }),
|
|
138
192
|
/* @__PURE__ */ jsxs(DropdownMenu.Content, { onCloseAutoFocus: (event) => {
|
|
139
193
|
event.preventDefault();
|
|
140
194
|
editor?.commands.focus();
|
|
141
195
|
}, children: [
|
|
142
|
-
/* @__PURE__ */ jsx(DropdownMenu.Item, { onSelect: () => editor?.chain().focus().setParagraph().run(), children:
|
|
143
|
-
editor?.schema.nodes.heading ? levels.map((level) => /* @__PURE__ */
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
] }, level)) : null,
|
|
147
|
-
available("blockquote", "blockquote") ? /* @__PURE__ */ jsx(DropdownMenu.Item, { onSelect: () => editor?.chain().focus().toggleBlockquote().run(), children: "Quote block" }) : null,
|
|
148
|
-
available("codeBlock", "codeBlock") ? /* @__PURE__ */ jsx(DropdownMenu.Item, { onSelect: () => editor?.chain().focus().toggleCodeBlock().run(), children: "Code block" }) : null
|
|
196
|
+
/* @__PURE__ */ jsx(DropdownMenu.Item, { onSelect: () => editor?.chain().focus().setParagraph().run(), children: locale.paragraph }),
|
|
197
|
+
editor?.schema.nodes.heading ? levels.map((level) => /* @__PURE__ */ jsx(DropdownMenu.Item, { onSelect: () => editor.chain().focus().toggleHeading({ level }).run(), children: locale.heading(level) }, level)) : null,
|
|
198
|
+
available("blockquote", "blockquote") ? /* @__PURE__ */ jsx(DropdownMenu.Item, { onSelect: () => editor?.chain().focus().toggleBlockquote().run(), children: locale.quoteBlock }) : null,
|
|
199
|
+
available("codeBlock", "codeBlock") ? /* @__PURE__ */ jsx(DropdownMenu.Item, { onSelect: () => editor?.chain().focus().toggleCodeBlock().run(), children: locale.codeBlock }) : null
|
|
149
200
|
] })
|
|
150
201
|
] }) }) : null,
|
|
151
|
-
/* @__PURE__ */ jsxs("div", { className: "dsx-rich-text-editor__toolbar-group", role: "group", "aria-label":
|
|
152
|
-
available("bold", "bold") ? format(
|
|
153
|
-
available("italic", "italic") ? format(
|
|
154
|
-
available("strike", "strike") ? format(
|
|
155
|
-
available("code", "code") ? format(
|
|
156
|
-
available("bulletList", "bulletList") ? format(
|
|
157
|
-
available("orderedList", "orderedList") ? format(
|
|
202
|
+
/* @__PURE__ */ jsxs("div", { className: "dsx-rich-text-editor__toolbar-group", role: "group", "aria-label": locale.textStyleGroup, children: [
|
|
203
|
+
available("bold", "bold") ? format(locale.bold, "bold", "bold", () => editor?.chain().focus().toggleBold().run()) : null,
|
|
204
|
+
available("italic", "italic") ? format(locale.italic, "italic", "italic", () => editor?.chain().focus().toggleItalic().run()) : null,
|
|
205
|
+
available("strike", "strike") ? format(locale.strikethrough, "strikethrough", "strike", () => editor?.chain().focus().toggleStrike().run()) : null,
|
|
206
|
+
available("code", "code") ? format(locale.inlineCode, "code", "code", () => editor?.chain().focus().toggleCode().run()) : null,
|
|
207
|
+
available("bulletList", "bulletList") ? format(locale.bulletList, "list", "bulletList", () => editor?.chain().focus().toggleBulletList().run()) : null,
|
|
208
|
+
available("orderedList", "orderedList") ? format(locale.orderedList, "list-ordered", "orderedList", () => editor?.chain().focus().toggleOrderedList().run()) : null
|
|
158
209
|
] }),
|
|
159
|
-
editor ? /* @__PURE__ */ jsxs("div", { className: "dsx-rich-text-editor__toolbar-group", role: "group", "aria-label":
|
|
160
|
-
available("link", "link") ? /* @__PURE__ */ jsx(LinkControl, { editor, disabled }) : null,
|
|
210
|
+
editor ? /* @__PURE__ */ jsxs("div", { className: "dsx-rich-text-editor__toolbar-group", role: "group", "aria-label": locale.insertGroup, children: [
|
|
211
|
+
available("link", "link") ? /* @__PURE__ */ jsx(LinkControl, { editor, disabled, localeText }) : null,
|
|
161
212
|
insertItems.length ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
162
213
|
/* @__PURE__ */ jsx(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs(Control, { disabled, children: [
|
|
163
|
-
|
|
214
|
+
locale.insert,
|
|
215
|
+
" ",
|
|
164
216
|
/* @__PURE__ */ jsx(Icon, { name: "plus", size: "sm" })
|
|
165
217
|
] }) }),
|
|
166
218
|
/* @__PURE__ */ jsx(DropdownMenu.Content, { onCloseAutoFocus: (event) => {
|
|
@@ -179,18 +231,20 @@ function EditorTools({ editor, disabled, tools = defaults, headingLevels, insert
|
|
|
179
231
|
item.insert(editor);
|
|
180
232
|
}, children: item.label }, item.id)) })
|
|
181
233
|
] }) : null,
|
|
182
|
-
variables.length && editor.schema.nodes.dsxVariable ? /* @__PURE__ */ jsx(TokenPicker, { editor, disabled, kind: "variable", records: variables }) : null,
|
|
183
|
-
mentions.length && editor.schema.nodes.dsxMention ? /* @__PURE__ */ jsx(TokenPicker, { editor, disabled, kind: "mention", records: mentions }) : null,
|
|
184
|
-
available("clear") ? format(
|
|
234
|
+
variables.length && editor.schema.nodes.dsxVariable ? /* @__PURE__ */ jsx(TokenPicker, { editor, disabled, kind: "variable", records: variables, localeText }) : null,
|
|
235
|
+
mentions.length && editor.schema.nodes.dsxMention ? /* @__PURE__ */ jsx(TokenPicker, { editor, disabled, kind: "mention", records: mentions, localeText }) : null,
|
|
236
|
+
available("clear") ? format(locale.clearFormatting, "eraser", "", () => editor.chain().focus().clearNodes().unsetAllMarks().run()) : null
|
|
185
237
|
] }) : null,
|
|
186
|
-
available("history") ? /* @__PURE__ */ jsxs("div", { className: "dsx-rich-text-editor__toolbar-group", role: "group", "aria-label":
|
|
187
|
-
/* @__PURE__ */ jsx(Control, { disabled: disabled || !editor?.can().undo(), "aria-label":
|
|
188
|
-
/* @__PURE__ */ jsx(Control, { disabled: disabled || !editor?.can().redo(), "aria-label":
|
|
238
|
+
available("history") ? /* @__PURE__ */ jsxs("div", { className: "dsx-rich-text-editor__toolbar-group", role: "group", "aria-label": locale.historyGroup, children: [
|
|
239
|
+
/* @__PURE__ */ jsx(Control, { disabled: disabled || !editor?.can().undo(), "aria-label": locale.undo, onMouseDown: (event) => event.preventDefault(), onClick: () => editor?.chain().focus().undo().run(), children: /* @__PURE__ */ jsx(Icon, { name: "undo", size: "sm" }) }),
|
|
240
|
+
/* @__PURE__ */ jsx(Control, { disabled: disabled || !editor?.can().redo(), "aria-label": locale.redo, onMouseDown: (event) => event.preventDefault(), onClick: () => editor?.chain().focus().redo().run(), children: /* @__PURE__ */ jsx(Icon, { name: "redo", size: "sm" }) })
|
|
189
241
|
] }) : null,
|
|
190
|
-
editor && mentions.length && editor.schema.nodes.dsxMention ? /* @__PURE__ */ jsx(MentionSuggestions, { editor, mentions }) : null
|
|
242
|
+
editor && mentions.length && editor.schema.nodes.dsxMention ? /* @__PURE__ */ jsx(MentionSuggestions, { editor, mentions, localeText }) : null
|
|
191
243
|
] });
|
|
192
244
|
}
|
|
193
245
|
export {
|
|
194
|
-
EditorTools
|
|
246
|
+
EditorTools,
|
|
247
|
+
defaultRichTextEditorLocaleText,
|
|
248
|
+
resolveRichTextEditorLocaleText
|
|
195
249
|
};
|
|
196
250
|
//# sourceMappingURL=EditorTools.js.map
|