@talogic/editor 0.0.0-stage → 0.1.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/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_jsx","_jsxs","_jsx","_jsx","_jsxs","_jsxs","_jsx","_jsx","_jsxs","_jsxs","_jsx","_jsx","_jsxs","_jsx","Button","DropdownMenu","DropdownMenuContent","DropdownMenuItem","DropdownMenuRadioGroup","DropdownMenuRadioItem","DropdownMenuSeparator","DropdownMenuTrigger","Input","Popover","PopoverContent","PopoverTrigger","Separator","Tooltip","TooltipContent","TooltipTrigger","cn","EditorContent","useEditor","useEditorState","useEffect","useState","AlignCenterIcon","AlignJustifyIcon","AlignLeftIcon","AlignRightIcon","BlockquoteIcon","BoldIcon","ClearFormattingIcon","CodeBlockIcon","CodeInlineIcon","Heading1Icon","Heading2Icon","Heading3Icon","Heading4Icon","Heading5Icon","Heading6Icon","HighlightIcon","HorizontalRuleIcon","IndentIcon","ItalicIcon","LinkIcon","ListChecksIcon","ListIcon","ListOrderedIcon","OutdentIcon","ParagraphIcon","RedoIcon","StrikethroughIcon","SubscriptIcon","SuperscriptIcon","TableCellsMergeIcon","TableCellsSplitIcon","TableColumnDeleteIcon","TableColumnInsertLeftIcon","TableColumnInsertRightIcon","TableDeleteIcon","TableHeaderColumnIcon","TableHeaderRowIcon","TableIcon","TablePlusIcon","TableRowDeleteIcon","TableRowInsertAboveIcon","TableRowInsertBelowIcon","TextColorIcon","UnderlineIcon","UndoIcon","jsx","jsxs","Highlight","ListKit","Subscript","Superscript","TableKit","TextAlign","TextStyleKit","Placeholder","Markdown","StarterKit","chain","editor","moveListItem","direction","dryRun","command","type","BUTTON_TOOLS","IS_APPLE","MOD_KEY","ALT_KEY","MOD_ARIA","ToolbarButton","label","icon","shortcut","pressed","props","keys","event","LEVELS","HeadingMenu","level","labels","current","entry","choose","value","next","LinkPopover","href","open","setOpen","draft","setDraft","apply","address","TABLE_ACTIONS","TableMenu","inTable","group","action","COLORS","hue","TextColorMenu","color","swatch","MENU_TOOLS","moveFocus","buttons","index","forward","EditorToolbar","items","state","item","tool","key","button","DEFAULT_RICH_TEXT_LABELS","RICH_TEXT_PRESETS","[\n\t\t\"undo\",\n\t\t\"redo\",\n\t\t\"|\",\n\t\t\"heading\",\n\t\t\"|\",\n\t\t\"bold\",\n\t\t\"italic\",\n\t\t\"underline\",\n\t\t\"strike\",\n\t\t\"code\",\n\t\t\"subscript\",\n\t\t\"superscript\",\n\t\t\"highlight\",\n\t\t\"textColor\",\n\t\t\"clearFormatting\",\n\t\t\"|\",\n\t\t\"bulletList\",\n\t\t\"orderedList\",\n\t\t\"taskList\",\n\t\t\"outdent\",\n\t\t\"indent\",\n\t\t\"|\",\n\t\t\"alignLeft\",\n\t\t\"alignCenter\",\n\t\t\"alignRight\",\n\t\t\"alignJustify\",\n\t\t\"|\",\n\t\t\"blockquote\",\n\t\t\"codeBlock\",\n\t\t\"horizontalRule\",\n\t\t\"link\",\n\t\t\"table\"\n\t]","createEditorExtensions","placeholder","editorContentClassName","RichTextEditor","tools","defaultValue","format","onChange","editable","extensions","onEditorReady","className","contentClassName","\"role\"","created","changed","readContent","words"],"sources":["../src/toolbar/button-tools.config.tsx","../src/toolbar/toolbar-button.component.tsx","../src/toolbar/heading-menu.component.tsx","../src/toolbar/link-popover.component.tsx","../src/toolbar/table-menu.component.tsx","../src/toolbar/text-color-menu.component.tsx","../src/toolbar/editor-toolbar.component.tsx","../src/toolbar/rich-text-labels.content.ts","../src/toolbar/rich-text-presets.content.ts","../src/rich-text-editor/editor-extensions.config.ts","../src/rich-text-editor/editor-content.recipe.ts","../src/rich-text-editor/rich-text-editor.component.tsx"],"sourcesContent":["import { AlignCenterIcon, AlignJustifyIcon, AlignLeftIcon, AlignRightIcon, BlockquoteIcon, BoldIcon, ClearFormattingIcon, CodeBlockIcon, CodeInlineIcon, HighlightIcon, HorizontalRuleIcon, IndentIcon, ItalicIcon, ListChecksIcon, ListIcon, ListOrderedIcon, OutdentIcon, RedoIcon, StrikethroughIcon, SubscriptIcon, SuperscriptIcon, UnderlineIcon, UndoIcon } from '@talogic/icons'\nimport type { Editor } from '@tiptap/react'\nimport type { ReactNode } from 'react'\nimport type { RichTextTool } from './rich-text-tool.contract'\n\n/** A toolbar tool that is one button: it runs a command, and may show as pressed. */\nexport interface ButtonTool {\n icon: ReactNode\n /** The key chord, shown in the tooltip, such as `Mod-B`. */\n shortcut?: string\n run: (editor: Editor) => void\n canRun: (editor: Editor) => boolean\n isActive?: (editor: Editor) => boolean\n}\n\n/** The tools that open a menu or a popover instead of running one command. */\nexport type MenuTool = 'heading' | 'link' | 'table' | 'textColor'\n\nconst chain = (editor: Editor) => editor.chain().focus()\n\n/**\n * Moves a list item in or out, for a bulleted, numbered or check list.\n *\n * @param editor - The editor.\n * @param direction - `in` to indent, `out` to outdent.\n * @param dryRun - True to only check that the move can run.\n * @returns Whether the move ran, or can run.\n */\nfunction moveListItem (editor: Editor, direction: 'in' | 'out', dryRun: boolean): boolean {\n const command = direction === 'in' ? 'sinkListItem' : 'liftListItem'\n\n return ['listItem', 'taskItem'].some((type) => (dryRun ? editor.can()[command](type) : chain(editor)[command](type).run()))\n}\n\n/** The button tools, by tool. */\nexport const BUTTON_TOOLS: Readonly<Record<Exclude<RichTextTool, MenuTool>, ButtonTool>> = {\n undo: { icon: <UndoIcon />, shortcut: 'Mod-Z', run: (editor) => chain(editor).undo().run(), canRun: (editor) => editor.can().undo() },\n redo: { icon: <RedoIcon />, shortcut: 'Mod-Shift-Z', run: (editor) => chain(editor).redo().run(), canRun: (editor) => editor.can().redo() },\n bold: { icon: <BoldIcon />, shortcut: 'Mod-B', run: (editor) => chain(editor).toggleBold().run(), canRun: (editor) => editor.can().toggleBold(), isActive: (editor) => editor.isActive('bold') },\n italic: { icon: <ItalicIcon />, shortcut: 'Mod-I', run: (editor) => chain(editor).toggleItalic().run(), canRun: (editor) => editor.can().toggleItalic(), isActive: (editor) => editor.isActive('italic') },\n underline: { icon: <UnderlineIcon />, shortcut: 'Mod-U', run: (editor) => chain(editor).toggleUnderline().run(), canRun: (editor) => editor.can().toggleUnderline(), isActive: (editor) => editor.isActive('underline') },\n strike: { icon: <StrikethroughIcon />, shortcut: 'Mod-Shift-S', run: (editor) => chain(editor).toggleStrike().run(), canRun: (editor) => editor.can().toggleStrike(), isActive: (editor) => editor.isActive('strike') },\n code: { icon: <CodeInlineIcon />, shortcut: 'Mod-E', run: (editor) => chain(editor).toggleCode().run(), canRun: (editor) => editor.can().toggleCode(), isActive: (editor) => editor.isActive('code') },\n subscript: { icon: <SubscriptIcon />, shortcut: 'Mod-,', run: (editor) => chain(editor).toggleSubscript().run(), canRun: (editor) => editor.can().toggleSubscript(), isActive: (editor) => editor.isActive('subscript') },\n superscript: { icon: <SuperscriptIcon />, shortcut: 'Mod-.', run: (editor) => chain(editor).toggleSuperscript().run(), canRun: (editor) => editor.can().toggleSuperscript(), isActive: (editor) => editor.isActive('superscript') },\n highlight: { icon: <HighlightIcon />, shortcut: 'Mod-Shift-H', run: (editor) => chain(editor).toggleHighlight().run(), canRun: (editor) => editor.can().toggleHighlight(), isActive: (editor) => editor.isActive('highlight') },\n clearFormatting: { icon: <ClearFormattingIcon />, run: (editor) => chain(editor).unsetAllMarks().clearNodes().run(), canRun: (editor) => editor.can().unsetAllMarks() },\n bulletList: { icon: <ListIcon />, shortcut: 'Mod-Shift-8', run: (editor) => chain(editor).toggleBulletList().run(), canRun: (editor) => editor.can().toggleBulletList(), isActive: (editor) => editor.isActive('bulletList') },\n orderedList: { icon: <ListOrderedIcon />, shortcut: 'Mod-Shift-7', run: (editor) => chain(editor).toggleOrderedList().run(), canRun: (editor) => editor.can().toggleOrderedList(), isActive: (editor) => editor.isActive('orderedList') },\n taskList: { icon: <ListChecksIcon />, shortcut: 'Mod-Shift-9', run: (editor) => chain(editor).toggleTaskList().run(), canRun: (editor) => editor.can().toggleTaskList(), isActive: (editor) => editor.isActive('taskList') },\n indent: { icon: <IndentIcon />, shortcut: 'Tab', run: (editor) => { moveListItem(editor, 'in', false) }, canRun: (editor) => moveListItem(editor, 'in', true) },\n outdent: { icon: <OutdentIcon />, shortcut: 'Shift-Tab', run: (editor) => { moveListItem(editor, 'out', false) }, canRun: (editor) => moveListItem(editor, 'out', true) },\n blockquote: { icon: <BlockquoteIcon />, shortcut: 'Mod-Shift-B', run: (editor) => chain(editor).toggleBlockquote().run(), canRun: (editor) => editor.can().toggleBlockquote(), isActive: (editor) => editor.isActive('blockquote') },\n codeBlock: { icon: <CodeBlockIcon />, shortcut: 'Mod-Alt-C', run: (editor) => chain(editor).toggleCodeBlock().run(), canRun: (editor) => editor.can().toggleCodeBlock(), isActive: (editor) => editor.isActive('codeBlock') },\n horizontalRule: { icon: <HorizontalRuleIcon />, run: (editor) => chain(editor).setHorizontalRule().run(), canRun: (editor) => editor.can().setHorizontalRule() },\n alignLeft: { icon: <AlignLeftIcon />, shortcut: 'Mod-Shift-L', run: (editor) => chain(editor).setTextAlign('left').run(), canRun: (editor) => editor.can().setTextAlign('left'), isActive: (editor) => editor.isActive({ textAlign: 'left' }) },\n alignCenter: { icon: <AlignCenterIcon />, shortcut: 'Mod-Shift-E', run: (editor) => chain(editor).setTextAlign('center').run(), canRun: (editor) => editor.can().setTextAlign('center'), isActive: (editor) => editor.isActive({ textAlign: 'center' }) },\n alignRight: { icon: <AlignRightIcon />, shortcut: 'Mod-Shift-R', run: (editor) => chain(editor).setTextAlign('right').run(), canRun: (editor) => editor.can().setTextAlign('right'), isActive: (editor) => editor.isActive({ textAlign: 'right' }) },\n alignJustify: { icon: <AlignJustifyIcon />, shortcut: 'Mod-Shift-J', run: (editor) => chain(editor).setTextAlign('justify').run(), canRun: (editor) => editor.can().setTextAlign('justify'), isActive: (editor) => editor.isActive({ textAlign: 'justify' }) },\n}\n","import { Button, Tooltip, TooltipContent, TooltipTrigger } from '@talogic/react'\nimport type { ComponentProps, ReactNode } from 'react'\n\n/** Props of {@link ToolbarButton}. */\nexport interface ToolbarButtonProps extends Omit<ComponentProps<typeof Button>, 'children'> {\n /** The name of the action. It names the button and shows in its tooltip. */\n label: string\n icon: ReactNode\n /** The key chord, such as `Mod-B`. */\n shortcut?: string\n /** Whether the format is on where the cursor is. Undefined for a button that is never pressed. */\n pressed?: boolean\n}\n\nconst IS_APPLE = typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.userAgent)\nconst MOD_KEY = IS_APPLE ? '⌘' : 'Ctrl'\nconst ALT_KEY = IS_APPLE ? '⌥' : 'Alt'\nconst MOD_ARIA = IS_APPLE ? 'Meta' : 'Control'\n\n/**\n * A toolbar icon button with a tooltip that names it and shows its shortcut.\n *\n * @param props - `label`, `icon`, `shortcut`, `pressed` and any button props.\n * @returns The button in its tooltip.\n */\nexport function ToolbarButton ({ label, icon, shortcut, pressed, ...props }: ToolbarButtonProps) {\n const keys = shortcut?.replace('Mod', () => MOD_KEY).replace('Alt', () => ALT_KEY).replaceAll('-', '+')\n\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n type='button'\n variant='ghost'\n size='icon-sm'\n aria-label={label}\n aria-pressed={pressed}\n aria-keyshortcuts={shortcut?.replace('Mod', () => MOD_ARIA).replaceAll('-', '+')}\n data-active={pressed || undefined}\n className='data-active:bg-brand-soft data-active:text-brand-text [&_svg]:size-[18px]'\n onMouseDown={(event) => { event.preventDefault() }}\n {...props}\n >\n {icon}\n </Button>\n </TooltipTrigger>\n <TooltipContent>{label}{keys && <span className='ms-2 opacity-70'>{keys}</span>}</TooltipContent>\n </Tooltip>\n )\n}\n","import { Heading1Icon, Heading2Icon, Heading3Icon, Heading4Icon, Heading5Icon, Heading6Icon, ParagraphIcon } from '@talogic/icons'\nimport { DropdownMenu, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger } from '@talogic/react'\nimport type { Editor } from '@tiptap/react'\nimport type { ReactNode } from 'react'\nimport type { RichTextLabels } from './rich-text-labels.content'\nimport { ToolbarButton } from './toolbar-button.component'\n\ntype Level = 1 | 2 | 3 | 4 | 5 | 6\n\nconst LEVELS: readonly { level: 0 | Level, icon: ReactNode, label: keyof RichTextLabels, text: string }[] = [\n { level: 0, icon: <ParagraphIcon />, label: 'paragraph', text: 'text-sm' },\n { level: 1, icon: <Heading1Icon />, label: 'heading1', text: 'text-xl font-semibold' },\n { level: 2, icon: <Heading2Icon />, label: 'heading2', text: 'text-lg font-semibold' },\n { level: 3, icon: <Heading3Icon />, label: 'heading3', text: 'text-base font-semibold' },\n { level: 4, icon: <Heading4Icon />, label: 'heading4', text: 'text-sm font-semibold' },\n { level: 5, icon: <Heading5Icon />, label: 'heading5', text: 'text-sm font-medium' },\n { level: 6, icon: <Heading6Icon />, label: 'heading6', text: 'text-xs font-medium uppercase' },\n]\n\n/** Props of {@link HeadingMenu}. */\nexport interface HeadingMenuProps {\n editor: Editor\n /** The heading level where the cursor is, or 0 for a paragraph. */\n level: number\n labels: RichTextLabels\n}\n\n/**\n * The text style menu: paragraph or heading 1 to 6. Its button shows the style where the cursor is.\n *\n * @param props - The editor, the current level and the labels.\n * @returns The menu.\n */\nexport function HeadingMenu ({ editor, level, labels }: HeadingMenuProps) {\n const current = LEVELS.find((entry) => entry.level === level) ?? LEVELS[0]\n\n function choose (value: string): void {\n const next = Number(value)\n if (next === 0) editor.chain().focus().setParagraph().run()\n else editor.chain().focus().setHeading({ level: next as Level }).run()\n }\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <ToolbarButton label={`${labels.heading}: ${labels[current?.label ?? 'paragraph']}`} icon={current?.icon} />\n </DropdownMenuTrigger>\n <DropdownMenuContent align='start'>\n <DropdownMenuRadioGroup value={String(level)} onValueChange={choose}>\n {LEVELS.map((entry) => (\n <DropdownMenuRadioItem key={entry.level} value={String(entry.level)} className={entry.text}>{labels[entry.label]}</DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuContent>\n </DropdownMenu>\n )\n}\n","import { LinkIcon } from '@talogic/icons'\nimport { Button, Input, Popover, PopoverContent, PopoverTrigger } from '@talogic/react'\nimport type { Editor } from '@tiptap/react'\nimport { type FormEvent, useState } from 'react'\nimport type { RichTextLabels } from './rich-text-labels.content'\nimport { ToolbarButton } from './toolbar-button.component'\n\n/** Props of {@link LinkPopover}. */\nexport interface LinkPopoverProps {\n editor: Editor\n /** The address of the link where the cursor is, or undefined outside a link. */\n href: string | undefined\n labels: RichTextLabels\n}\n\n/**\n * The link button and its popover: type an address to link the selected text, or remove the link under the cursor.\n *\n * @param props - The editor, the current link address and the labels.\n * @returns The button with its popover.\n */\nexport function LinkPopover ({ editor, href, labels }: LinkPopoverProps) {\n const [open, setOpen] = useState(false)\n const [draft, setDraft] = useState('')\n\n function apply (event: FormEvent): void {\n event.preventDefault()\n const address = draft.trim()\n const chain = editor.chain().focus().extendMarkRange('link')\n if (address) chain.setLink({ href: address }).run()\n else chain.unsetLink().run()\n setOpen(false)\n }\n\n return (\n <Popover open={open} onOpenChange={(next) => { setOpen(next); if (next) setDraft(href ?? '') }}>\n <PopoverTrigger asChild>\n <ToolbarButton label={labels.link} icon={<LinkIcon />} shortcut='Mod-K' pressed={href !== undefined} />\n </PopoverTrigger>\n <PopoverContent align='start' className='w-80'>\n <form className='flex flex-col gap-2' onSubmit={apply}>\n <Input aria-label={labels.linkUrl} type='url' inputMode='url' placeholder='https://' value={draft} onChange={(event) => { setDraft(event.target.value) }} />\n <div className='flex justify-end gap-2'>\n {href !== undefined && (\n <Button type='button' variant='ghost' size='sm' onClick={() => { editor.chain().focus().extendMarkRange('link').unsetLink().run(); setOpen(false) }}>{labels.linkRemove}</Button>\n )}\n <Button type='submit' size='sm'>{labels.linkApply}</Button>\n </div>\n </form>\n </PopoverContent>\n </Popover>\n )\n}\n","import { TableCellsMergeIcon, TableCellsSplitIcon, TableColumnDeleteIcon, TableColumnInsertLeftIcon, TableColumnInsertRightIcon, TableDeleteIcon, TableHeaderColumnIcon, TableHeaderRowIcon, TableIcon, TablePlusIcon, TableRowDeleteIcon, TableRowInsertAboveIcon, TableRowInsertBelowIcon } from '@talogic/icons'\nimport { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from '@talogic/react'\nimport type { ChainedCommands, Editor } from '@tiptap/react'\nimport type { ReactNode } from 'react'\nimport type { RichTextLabels } from './rich-text-labels.content'\nimport { ToolbarButton } from './toolbar-button.component'\n\ninterface TableAction {\n label: keyof RichTextLabels\n icon: ReactNode\n command: (chain: ChainedCommands) => ChainedCommands\n}\n\n/** The actions inside a table, in groups. */\nconst TABLE_ACTIONS: readonly (readonly TableAction[])[] = [\n [\n { label: 'tableRowAbove', icon: <TableRowInsertAboveIcon />, command: (chain) => chain.addRowBefore() },\n { label: 'tableRowBelow', icon: <TableRowInsertBelowIcon />, command: (chain) => chain.addRowAfter() },\n { label: 'tableRowDelete', icon: <TableRowDeleteIcon />, command: (chain) => chain.deleteRow() },\n ],\n [\n { label: 'tableColumnLeft', icon: <TableColumnInsertLeftIcon />, command: (chain) => chain.addColumnBefore() },\n { label: 'tableColumnRight', icon: <TableColumnInsertRightIcon />, command: (chain) => chain.addColumnAfter() },\n { label: 'tableColumnDelete', icon: <TableColumnDeleteIcon />, command: (chain) => chain.deleteColumn() },\n ],\n [\n { label: 'tableMergeCells', icon: <TableCellsMergeIcon />, command: (chain) => chain.mergeCells() },\n { label: 'tableSplitCell', icon: <TableCellsSplitIcon />, command: (chain) => chain.splitCell() },\n { label: 'tableHeaderRow', icon: <TableHeaderRowIcon />, command: (chain) => chain.toggleHeaderRow() },\n { label: 'tableHeaderColumn', icon: <TableHeaderColumnIcon />, command: (chain) => chain.toggleHeaderColumn() },\n ],\n [{ label: 'tableDelete', icon: <TableDeleteIcon />, command: (chain) => chain.deleteTable() }],\n]\n\n/** Props of {@link TableMenu}. */\nexport interface TableMenuProps {\n editor: Editor\n /** Whether the cursor is in a table. Outside one, the menu only inserts a table. */\n inTable: boolean\n labels: RichTextLabels\n}\n\n/**\n * The table menu: insert a 3 × 3 table with a header row, or, inside a table, add and delete rows and columns, merge\n * and split cells, switch the header row and column, and delete the table. Actions that cannot run are disabled.\n *\n * @param props - The editor, whether the cursor is in a table, and the labels.\n * @returns The menu.\n */\nexport function TableMenu ({ editor, inTable, labels }: TableMenuProps) {\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <ToolbarButton label={labels.table} icon={<TableIcon />} pressed={inTable} />\n </DropdownMenuTrigger>\n <DropdownMenuContent align='start'>\n <DropdownMenuItem disabled={inTable} onSelect={() => editor.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run()}>\n <TablePlusIcon />{labels.tableInsert}\n </DropdownMenuItem>\n {TABLE_ACTIONS.map((group) => (\n <div key={group[0]?.label} role='none'>\n <DropdownMenuSeparator />\n {group.map((action) => (\n <DropdownMenuItem key={action.label} disabled={!inTable || !action.command(editor.can().chain()).run()} onSelect={() => action.command(editor.chain().focus()).run()}>\n {action.icon}{labels[action.label]}\n </DropdownMenuItem>\n ))}\n </div>\n ))}\n </DropdownMenuContent>\n </DropdownMenu>\n )\n}\n","import { TextColorIcon } from '@talogic/icons'\nimport { cn, Popover, PopoverContent, PopoverTrigger } from '@talogic/react'\nimport type { Editor } from '@tiptap/react'\nimport { useState } from 'react'\nimport type { RichTextLabels } from './rich-text-labels.content'\nimport { ToolbarButton } from './toolbar-button.component'\n\n/** The text colours: talogic palette tokens, so they follow the light and dark themes. */\nconst COLORS: readonly string[] = ['red', 'orange', 'amber', 'green', 'teal', 'blue', 'violet', 'pink'].map((hue) => `var(--color-${hue}-600)`)\n\n/** Props of {@link TextColorMenu}. */\nexport interface TextColorMenuProps {\n editor: Editor\n /** The colour of the text where the cursor is, or undefined for the default colour. */\n color: string | undefined\n labels: RichTextLabels\n}\n\n/**\n * The text colour button and its swatches. The first swatch takes the colour away. HTML keeps the colour, Markdown\n * has no colour and drops it.\n *\n * @param props - The editor, the current colour and the labels.\n * @returns The button with its swatches.\n */\nexport function TextColorMenu ({ editor, color, labels }: TextColorMenuProps) {\n const [open, setOpen] = useState(false)\n\n function choose (next: string | undefined): void {\n if (next) editor.chain().focus().setColor(next).run()\n else editor.chain().focus().unsetColor().run()\n setOpen(false)\n }\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <ToolbarButton label={labels.textColor} icon={<TextColorIcon />} style={color ? { color } : undefined} />\n </PopoverTrigger>\n <PopoverContent align='start' className='w-auto p-2'>\n <div role='group' aria-label={labels.textColor} className='grid grid-cols-5 gap-1.5'>\n <button type='button' aria-label={labels.colorDefault} aria-pressed={color === undefined} className='size-7 cursor-pointer rounded-md border border-border bg-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring aria-pressed:ring-2 aria-pressed:ring-ring' onClick={() => { choose(undefined) }} />\n {COLORS.map((swatch) => (\n <button key={swatch} type='button' aria-label={swatch.slice(14, -5)} aria-pressed={color === swatch} className={cn('size-7 cursor-pointer rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring aria-pressed:ring-2 aria-pressed:ring-ring')} style={{ background: swatch }} onClick={() => { choose(swatch) }} />\n ))}\n </div>\n </PopoverContent>\n </Popover>\n )\n}\n","import { Separator } from '@talogic/react'\nimport { type Editor, useEditorState } from '@tiptap/react'\nimport type { KeyboardEvent } from 'react'\nimport { BUTTON_TOOLS, type MenuTool } from './button-tools.config'\nimport { HeadingMenu } from './heading-menu.component'\nimport { LinkPopover } from './link-popover.component'\nimport type { RichTextLabels } from './rich-text-labels.content'\nimport type { RichTextTool, RichTextToolbarItem } from './rich-text-tool.contract'\nimport { TableMenu } from './table-menu.component'\nimport { TextColorMenu } from './text-color-menu.component'\nimport { ToolbarButton } from './toolbar-button.component'\n\n/** Props of {@link EditorToolbar}. */\nexport interface EditorToolbarProps {\n editor: Editor\n /** The tools, in order, with `|` between groups. */\n items: readonly RichTextToolbarItem[]\n labels: RichTextLabels\n}\n\nconst MENU_TOOLS = new Set<RichTextTool>(['heading', 'link', 'table', 'textColor'] satisfies MenuTool[])\n\n/**\n * Moves the focus between the toolbar buttons with the arrow keys, Home and End.\n *\n * @param event - The key event on the toolbar.\n */\nfunction moveFocus (event: KeyboardEvent<HTMLDivElement>): void {\n const keys = ['ArrowLeft', 'ArrowRight', 'Home', 'End']\n if (!keys.includes(event.key)) return\n const buttons = [...event.currentTarget.querySelectorAll<HTMLButtonElement>('button:not(:disabled)')]\n const index = buttons.indexOf(document.activeElement as HTMLButtonElement)\n const forward = (event.key === 'ArrowRight') !== (getComputedStyle(event.currentTarget).direction === 'rtl')\n const next = { Home: 0, End: buttons.length - 1 }[event.key] ?? (index + (forward ? 1 : -1) + buttons.length) % buttons.length\n event.preventDefault()\n buttons[next]?.focus()\n}\n\n/**\n * The toolbar of the rich-text editor: the chosen tools, each showing whether its format is on where the cursor is.\n * It follows the ARIA toolbar pattern: the left and right arrow keys move between its buttons, Home and End jump.\n *\n * @param props - The editor, the toolbar items and the labels.\n * @returns The toolbar.\n */\nexport function EditorToolbar ({ editor, items, labels }: EditorToolbarProps) {\n const state = useEditorState({\n editor,\n selector: ({ editor: current }) => ({\n buttons: Object.fromEntries(items.filter((item) => item !== '|' && !MENU_TOOLS.has(item)).map((item) => {\n const tool = BUTTON_TOOLS[item as Exclude<RichTextTool, MenuTool>]\n\n return [item, { enabled: current.isEditable && tool.canRun(current), active: tool.isActive?.(current) }]\n })),\n level: ([1, 2, 3, 4, 5, 6] as const).find((level) => current.isActive('heading', { level })) ?? 0,\n href: current.isActive('link') ? String(current.getAttributes('link').href) : undefined,\n color: current.getAttributes('textStyle').color as string | undefined,\n inTable: current.isActive('table'),\n }),\n })\n\n return (\n <div role='toolbar' aria-label={labels.toolbar} data-slot='editor-toolbar' className='flex flex-wrap items-center gap-0.5 border-b border-border p-1' onKeyDown={moveFocus}>\n {items.map((item, index) => {\n const key = `${item}-${String(index)}`\n if (item === '|') return <Separator key={key} orientation='vertical' className='mx-1 h-5' />\n if (item === 'heading') return <HeadingMenu key={key} editor={editor} level={state.level} labels={labels} />\n if (item === 'link') return <LinkPopover key={key} editor={editor} href={state.href} labels={labels} />\n if (item === 'table') return <TableMenu key={key} editor={editor} inTable={state.inTable} labels={labels} />\n if (item === 'textColor') return <TextColorMenu key={key} editor={editor} color={state.color} labels={labels} />\n const tool = BUTTON_TOOLS[item]\n const button = state.buttons[item]\n\n return <ToolbarButton key={key} label={labels[item]} icon={tool.icon} shortcut={tool.shortcut} pressed={button?.active} disabled={!button?.enabled} onClick={() => { tool.run(editor) }} />\n })}\n </div>\n )\n}\n","import type { RichTextTool } from './rich-text-tool.contract'\n\n/** The words of the toolbar: a name for each tool, and for the actions inside its menus and popovers. */\nexport type RichTextLabels = Record<RichTextTool, string> & {\n toolbar: string\n paragraph: string\n heading1: string\n heading2: string\n heading3: string\n heading4: string\n heading5: string\n heading6: string\n linkUrl: string\n linkApply: string\n linkRemove: string\n colorDefault: string\n tableInsert: string\n tableRowAbove: string\n tableRowBelow: string\n tableRowDelete: string\n tableColumnLeft: string\n tableColumnRight: string\n tableColumnDelete: string\n tableMergeCells: string\n tableSplitCell: string\n tableHeaderRow: string\n tableHeaderColumn: string\n tableDelete: string\n}\n\n/** The English words of the toolbar. Pass `labels` to the editor to translate any of them. */\nexport const DEFAULT_RICH_TEXT_LABELS: RichTextLabels = {\n toolbar: 'Formatting',\n undo: 'Undo',\n redo: 'Redo',\n heading: 'Text style',\n bold: 'Bold',\n italic: 'Italic',\n underline: 'Underline',\n strike: 'Strikethrough',\n code: 'Inline code',\n subscript: 'Subscript',\n superscript: 'Superscript',\n highlight: 'Highlight',\n textColor: 'Text colour',\n clearFormatting: 'Clear formatting',\n bulletList: 'Bulleted list',\n orderedList: 'Numbered list',\n taskList: 'Checklist',\n indent: 'Indent',\n outdent: 'Outdent',\n blockquote: 'Quote',\n codeBlock: 'Code block',\n horizontalRule: 'Divider',\n link: 'Link',\n table: 'Table',\n alignLeft: 'Align left',\n alignCenter: 'Align centre',\n alignRight: 'Align right',\n alignJustify: 'Justify',\n paragraph: 'Paragraph',\n heading1: 'Heading 1',\n heading2: 'Heading 2',\n heading3: 'Heading 3',\n heading4: 'Heading 4',\n heading5: 'Heading 5',\n heading6: 'Heading 6',\n linkUrl: 'Link address',\n linkApply: 'Apply',\n linkRemove: 'Remove link',\n colorDefault: 'Default colour',\n tableInsert: 'Insert table',\n tableRowAbove: 'Insert row above',\n tableRowBelow: 'Insert row below',\n tableRowDelete: 'Delete row',\n tableColumnLeft: 'Insert column left',\n tableColumnRight: 'Insert column right',\n tableColumnDelete: 'Delete column',\n tableMergeCells: 'Merge cells',\n tableSplitCell: 'Split cell',\n tableHeaderRow: 'Header row',\n tableHeaderColumn: 'Header column',\n tableDelete: 'Delete table',\n}\n","import type { RichTextToolbarItem } from './rich-text-tool.contract'\n\n/**\n * Ready-made toolbars. `minimal` suits a comment box, `standard` a notes app and `full` a document editor. Pass\n * one as `tools`, or spread it and add or drop tools.\n */\nexport const RICH_TEXT_PRESETS = {\n minimal: ['bold', 'italic', 'link', '|', 'bulletList', 'orderedList'],\n standard: ['undo', 'redo', '|', 'heading', '|', 'bold', 'italic', 'underline', 'strike', 'code', '|', 'bulletList', 'orderedList', 'taskList', '|', 'blockquote', 'codeBlock', 'link'],\n full: [\n 'undo', 'redo', '|', 'heading', '|',\n 'bold', 'italic', 'underline', 'strike', 'code', 'subscript', 'superscript', 'highlight', 'textColor', 'clearFormatting', '|',\n 'bulletList', 'orderedList', 'taskList', 'outdent', 'indent', '|',\n 'alignLeft', 'alignCenter', 'alignRight', 'alignJustify', '|',\n 'blockquote', 'codeBlock', 'horizontalRule', 'link', 'table',\n ],\n} as const satisfies Record<string, readonly RichTextToolbarItem[]>\n","import Highlight from '@tiptap/extension-highlight'\nimport { ListKit } from '@tiptap/extension-list'\nimport Subscript from '@tiptap/extension-subscript'\nimport Superscript from '@tiptap/extension-superscript'\nimport { TableKit } from '@tiptap/extension-table'\nimport TextAlign from '@tiptap/extension-text-align'\nimport { TextStyleKit } from '@tiptap/extension-text-style'\nimport { Placeholder } from '@tiptap/extensions'\nimport { Markdown } from '@tiptap/markdown'\nimport type { Extensions } from '@tiptap/react'\nimport StarterKit from '@tiptap/starter-kit'\n\n/**\n * The TipTap extensions behind every toolbar tool, so content keeps its formats whatever toolbar shows. StarterKit's\n * own lists give way to ListKit, which adds check lists.\n *\n * @param placeholder - The text shown while the editor is empty. Default: none.\n * @returns The extensions.\n */\nexport function createEditorExtensions (placeholder = ''): Extensions {\n return [\n StarterKit.configure({ bulletList: false, orderedList: false, listItem: false, listKeymap: false, link: { openOnClick: false, autolink: true, defaultProtocol: 'https' } }),\n ListKit.configure({ taskItem: { nested: true } }),\n TableKit.configure({ table: { resizable: false } }),\n TextAlign.configure({ types: ['heading', 'paragraph'] }),\n TextStyleKit.configure({ backgroundColor: false, fontFamily: false, fontSize: false, lineHeight: false }),\n Highlight,\n Subscript,\n Superscript,\n Placeholder.configure({ placeholder }),\n Markdown,\n ]\n}\n","/**\n * The look of the text inside the editor: headings, lists, check lists, quotes, code, tables, links and the\n * placeholder, from the talogic tokens. ProseMirror renders plain elements, so the classes target them from the\n * content box.\n */\nexport const editorContentClassName = [\n '[&_.ProseMirror]:min-h-40 [&_.ProseMirror]:px-4 [&_.ProseMirror]:py-3 [&_.ProseMirror]:outline-none [&_.ProseMirror]:text-sm [&_.ProseMirror]:leading-relaxed',\n '[&_.ProseMirror>*+*]:mt-3 [&_h1]:text-2xl [&_h1]:font-semibold [&_h2]:text-xl [&_h2]:font-semibold [&_h3]:text-lg [&_h3]:font-semibold',\n '[&_h4]:text-base [&_h4]:font-semibold [&_h5]:text-sm [&_h5]:font-semibold [&_h6]:text-xs [&_h6]:font-semibold [&_h6]:uppercase',\n '[&_ul]:list-disc [&_ul]:ps-6 [&_ol]:list-decimal [&_ol]:ps-6 [&_li>p]:my-0.5',\n '[&_ul[data-type=taskList]]:list-none [&_ul[data-type=taskList]]:ps-1 [&_ul[data-type=taskList]>li]:flex [&_ul[data-type=taskList]>li]:gap-2',\n '[&_ul[data-type=taskList]>li>label]:mt-0.5 [&_ul[data-type=taskList]>li>label]:flex-none [&_ul[data-type=taskList]>li>label>input]:size-4 [&_ul[data-type=taskList]>li>label>input]:accent-(--color-brand) [&_ul[data-type=taskList]>li>div]:flex-1',\n '[&_li[data-checked=true]>div]:text-muted-foreground [&_li[data-checked=true]>div]:line-through',\n '[&_blockquote]:border-s-4 [&_blockquote]:border-brand-soft [&_blockquote]:ps-4 [&_blockquote]:text-muted-foreground',\n '[&_:not(pre)>code]:rounded-sm [&_:not(pre)>code]:bg-muted [&_:not(pre)>code]:px-1 [&_:not(pre)>code]:font-mono [&_:not(pre)>code]:text-[0.9em]',\n '[&_pre]:overflow-x-auto [&_pre]:rounded-md [&_pre]:bg-muted [&_pre]:p-3 [&_pre]:font-mono [&_pre]:text-[13px]',\n '[&_hr]:my-4 [&_hr]:border-border [&_a]:text-brand-text [&_a]:underline [&_a]:underline-offset-2 [&_mark]:rounded-sm [&_mark]:bg-warning-soft [&_mark]:px-0.5',\n '[&_table]:w-full [&_table]:border-collapse [&_table]:table-fixed [&_td]:border [&_td]:border-border [&_td]:p-2 [&_td]:align-top',\n '[&_th]:border [&_th]:border-border [&_th]:bg-muted [&_th]:p-2 [&_th]:text-start [&_th]:font-semibold [&_.selectedCell]:bg-brand-soft',\n '[&_.is-editor-empty:first-child]:before:pointer-events-none [&_.is-editor-empty:first-child]:before:float-start [&_.is-editor-empty:first-child]:before:h-0',\n '[&_.is-editor-empty:first-child]:before:text-muted-foreground [&_.is-editor-empty:first-child]:before:content-[attr(data-placeholder)]',\n].join(' ')\n","import { cn } from '@talogic/react'\nimport { type Editor, EditorContent, type Extensions, useEditor } from '@tiptap/react'\nimport { useEffect } from 'react'\nimport { DEFAULT_RICH_TEXT_LABELS, EditorToolbar, RICH_TEXT_PRESETS, type RichTextLabels, type RichTextToolbarItem } from '../toolbar'\nimport { createEditorExtensions } from './editor-extensions.config'\nimport { editorContentClassName } from './editor-content.recipe'\n\n/** The text format the editor reads and writes. */\nexport type RichTextFormat = 'markdown' | 'html'\n\n/** Props of {@link RichTextEditor}. */\nexport interface RichTextEditorProps {\n /** The toolbar tools, in order, with `|` between groups. Default: `RICH_TEXT_PRESETS.standard`. An empty list hides the toolbar. */\n 'tools'?: readonly RichTextToolbarItem[]\n /** The content, for a controlled editor. A new value replaces the content when it differs from what the editor holds. */\n 'value'?: string\n /** The first content, for an uncontrolled editor. */\n 'defaultValue'?: string\n /** The format of `value`, `defaultValue` and `onChange`. Default `markdown`. */\n 'format'?: RichTextFormat\n /** Called with the content, in `format`, after each change. */\n 'onChange'?: (value: string) => void\n /** The text shown while the editor is empty. */\n 'placeholder'?: string\n /** False to show the content read-only, without the toolbar. Default true. */\n 'editable'?: boolean\n /** Words to replace in the toolbar, such as a translation. */\n 'labels'?: Partial<RichTextLabels>\n /** Extra TipTap extensions, such as mentions or wiki links. */\n 'extensions'?: Extensions\n /** Called once the TipTap editor exists, for an app that needs its commands, such as a word count. */\n 'onEditorReady'?: (editor: Editor) => void\n /** The accessible name of the text box. */\n 'aria-label'?: string\n 'className'?: string\n /** The class of the scrolling text area, such as a height. */\n 'contentClassName'?: string\n}\n\n/**\n * The talogic rich-text editor, on TipTap: a toolbar with the tools you choose and the text under it. It reads and\n * writes Markdown (default) or HTML. Every format the full toolbar offers is always loaded, so content keeps its\n * formats whatever tools show: pick tools for the task, not for the content.\n *\n * @param props - `tools`, `value` or `defaultValue`, `format`, `onChange`, `placeholder`, `editable`, `labels`,\n * `extensions`, `onEditorReady` and an `aria-label`.\n * @returns The editor.\n */\nexport function RichTextEditor ({ tools = RICH_TEXT_PRESETS.standard, value, defaultValue, format = 'markdown', onChange, placeholder, editable = true, labels, extensions = [], onEditorReady, 'aria-label': label, className, contentClassName }: RichTextEditorProps) {\n const editor = useEditor({\n extensions: [...createEditorExtensions(placeholder), ...extensions],\n content: value ?? defaultValue ?? '',\n contentType: format,\n editable,\n immediatelyRender: true,\n shouldRerenderOnTransaction: false,\n editorProps: { attributes: { 'role': 'textbox', 'aria-multiline': 'true', ...(label && { 'aria-label': label }) } },\n onCreate: ({ editor: created }) => onEditorReady?.(created),\n onUpdate: ({ editor: changed }) => onChange?.(readContent(changed, format)),\n })\n\n useEffect(() => {\n if (value === undefined || value === readContent(editor, format)) return\n editor.commands.setContent(value, { contentType: format, emitUpdate: false })\n }, [editor, value, format])\n\n useEffect(() => { editor.setEditable(editable) }, [editor, editable])\n\n const words = { ...DEFAULT_RICH_TEXT_LABELS, ...labels }\n\n return (\n <div data-slot='rich-text-editor' className={cn('flex flex-col overflow-hidden rounded-md border border-input bg-background focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/25', className)}>\n {editable && tools.length > 0 && <EditorToolbar editor={editor} items={tools} labels={words} />}\n <EditorContent editor={editor} className={cn('flex-1 overflow-y-auto', editorContentClassName, contentClassName)} />\n </div>\n )\n}\n\n/**\n * The editor's content in a format.\n *\n * @param editor - The editor.\n * @param format - `markdown` or `html`.\n * @returns The content.\n */\nfunction readContent (editor: Editor, format: RichTextFormat): string {\n return format === 'markdown' ? editor.getMarkdown() : editor.getHTML()\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,IAAM6F,KAASC,MAAmBA,EAAO,MAAM,CAAC,CAAC,MAAM;AAUvD,SAASC,EAAcD,GAAgBE,GAAyBC,GAA0B;CACxF,IAAMC,IAAUF,MAAc,OAAO,iBAAiB;CAEtD,OAAO,CAAC,YAAY,UAAU,CAAC,CAAC,MAAMG,MAAUF,IAASH,EAAO,IAAI,CAAC,CAACI,EAAQ,CAACC,CAAI,IAAIN,EAAMC,CAAM,CAAC,CAACI,EAAQ,CAACC,CAAI,CAAC,CAAC,IAAI,CAAE;AAC5H;AAGA,IAAaC,IAA8E;CACzF,MAAiB;EAAE,MAAMpG,kBAACgF,IAAD,CAAW,CAAA;EAAG,UAAU;EAAS,MAAMc,MAAWD,EAAMC,CAAM,CAAC,CAAC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CAAQ,CAAC;CAEpE,IAAMS,IAAQ;EAAE,GAAGpB;EAA0B,GAAGpC;CAAO;CAEvD,OACExG,kBAAC,OAAD;EAAK,aAAU;EAAmB,WAAWkB,EAAG,qJAAqJwI,CAAS;EAA9M,UAAA,CACGH,KAAYJ,EAAM,SAAS,KAAKlJ,kBAACoI,IAAD;GAAuBnD;GAAQ,OAAOiE;GAAO,QAAQa;EAAQ,CAAA,GAC9F/J,kBAACkB,IAAD;GAAuB+D;GAAQ,WAAWhE,EAAG,0BAA0B+H,IAAwBU,CAAgB;EAAI,CAAA,CAChH;;AAET;AASA,SAASI,EAAa7E,GAAgBmE,GAAgC;CACpE,OAAOA,MAAW,aAAanE,EAAO,YAAY,IAAIA,EAAO,QAAQ;AACvE"}
package/package.json CHANGED
@@ -1,6 +1,76 @@
1
1
  {
2
2
  "name": "@talogic/editor",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "The talogic rich-text editor for React: TipTap with a toolbar you choose tool by tool, talogic icons and Markdown or HTML in and out.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "smith": {
8
+ "kind": "package",
9
+ "stack": "node-jest"
10
+ },
11
+ "main": "./index.js",
12
+ "types": "./index.d.ts",
13
+ "exports": {
14
+ "./package.json": "./package.json",
15
+ ".": {
16
+ "source": "./src/index.ts",
17
+ "types": "./index.d.ts",
18
+ "import": "./index.js",
19
+ "default": "./index.js"
20
+ }
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "dependencies": {
26
+ "@tiptap/extension-highlight": "^3.35.1",
27
+ "@tiptap/extension-list": "^3.35.1",
28
+ "@tiptap/extension-subscript": "^3.35.1",
29
+ "@tiptap/extension-superscript": "^3.35.1",
30
+ "@tiptap/extension-table": "^3.35.1",
31
+ "@tiptap/extension-text-align": "^3.35.1",
32
+ "@tiptap/extension-text-style": "^3.35.1",
33
+ "@tiptap/extensions": "^3.35.1",
34
+ "@tiptap/markdown": "^3.35.1",
35
+ "@tiptap/pm": "^3.35.1",
36
+ "@tiptap/react": "^3.35.1",
37
+ "@tiptap/starter-kit": "^3.35.1"
38
+ },
39
+ "keywords": [
40
+ "talogic",
41
+ "editor",
42
+ "rich-text",
43
+ "tiptap",
44
+ "markdown",
45
+ "react"
46
+ ],
47
+ "sideEffects": false,
48
+ "module": "./index.js",
49
+ "peerDependencies": {
50
+ "@talogic/icons": "*",
51
+ "@talogic/react": "*",
52
+ "react": "^19.0.0",
53
+ "react-dom": "^19.0.0"
54
+ },
55
+ "devDependencies": {
56
+ "@babel/core": "^7.29.13",
57
+ "@babel/preset-env": "^7.29.14",
58
+ "@babel/preset-react": "^7.29.7",
59
+ "@babel/preset-typescript": "^7.29.7",
60
+ "@testing-library/dom": "^10.4.2",
61
+ "@testing-library/jest-dom": "^6.9.1",
62
+ "@testing-library/react": "^16.3.3",
63
+ "@testing-library/user-event": "^14.6.13",
64
+ "@vitejs/plugin-react": "^6.3.0",
65
+ "react": "^19.3.1",
66
+ "react-dom": "^19.3.1",
67
+ "vite": "^8.4.0",
68
+ "@talogic/icons": "^0.2.0",
69
+ "@talogic/react": "^0.16.0"
70
+ },
71
+ "repository": {
72
+ "type": "git",
73
+ "url": "git+https://github.com/talogic-automation/talogic.git",
74
+ "directory": "packages/editor"
75
+ }
76
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The look of the text inside the editor: headings, lists, check lists, quotes, code, tables, links and the
3
+ * placeholder, from the talogic tokens. ProseMirror renders plain elements, so the classes target them from the
4
+ * content box.
5
+ */
6
+ export declare const editorContentClassName: string;
@@ -0,0 +1,9 @@
1
+ import type { Extensions } from '@tiptap/react';
2
+ /**
3
+ * The TipTap extensions behind every toolbar tool, so content keeps its formats whatever toolbar shows. StarterKit's
4
+ * own lists give way to ListKit, which adds check lists.
5
+ *
6
+ * @param placeholder - The text shown while the editor is empty. Default: none.
7
+ * @returns The extensions.
8
+ */
9
+ export declare function createEditorExtensions(placeholder?: string): Extensions;
@@ -0,0 +1,2 @@
1
+ export { RichTextEditor } from './rich-text-editor.component';
2
+ export type { RichTextEditorProps, RichTextFormat } from './rich-text-editor.component';
@@ -0,0 +1,42 @@
1
+ import { type Editor, type Extensions } from '@tiptap/react';
2
+ import { type RichTextLabels, type RichTextToolbarItem } from '../toolbar';
3
+ /** The text format the editor reads and writes. */
4
+ export type RichTextFormat = 'markdown' | 'html';
5
+ /** Props of {@link RichTextEditor}. */
6
+ export interface RichTextEditorProps {
7
+ /** The toolbar tools, in order, with `|` between groups. Default: `RICH_TEXT_PRESETS.standard`. An empty list hides the toolbar. */
8
+ 'tools'?: readonly RichTextToolbarItem[];
9
+ /** The content, for a controlled editor. A new value replaces the content when it differs from what the editor holds. */
10
+ 'value'?: string;
11
+ /** The first content, for an uncontrolled editor. */
12
+ 'defaultValue'?: string;
13
+ /** The format of `value`, `defaultValue` and `onChange`. Default `markdown`. */
14
+ 'format'?: RichTextFormat;
15
+ /** Called with the content, in `format`, after each change. */
16
+ 'onChange'?: (value: string) => void;
17
+ /** The text shown while the editor is empty. */
18
+ 'placeholder'?: string;
19
+ /** False to show the content read-only, without the toolbar. Default true. */
20
+ 'editable'?: boolean;
21
+ /** Words to replace in the toolbar, such as a translation. */
22
+ 'labels'?: Partial<RichTextLabels>;
23
+ /** Extra TipTap extensions, such as mentions or wiki links. */
24
+ 'extensions'?: Extensions;
25
+ /** Called once the TipTap editor exists, for an app that needs its commands, such as a word count. */
26
+ 'onEditorReady'?: (editor: Editor) => void;
27
+ /** The accessible name of the text box. */
28
+ 'aria-label'?: string;
29
+ 'className'?: string;
30
+ /** The class of the scrolling text area, such as a height. */
31
+ 'contentClassName'?: string;
32
+ }
33
+ /**
34
+ * The talogic rich-text editor, on TipTap: a toolbar with the tools you choose and the text under it. It reads and
35
+ * writes Markdown (default) or HTML. Every format the full toolbar offers is always loaded, so content keeps its
36
+ * formats whatever tools show: pick tools for the task, not for the content.
37
+ *
38
+ * @param props - `tools`, `value` or `defaultValue`, `format`, `onChange`, `placeholder`, `editable`, `labels`,
39
+ * `extensions`, `onEditorReady` and an `aria-label`.
40
+ * @returns The editor.
41
+ */
42
+ export declare function RichTextEditor({ tools, value, defaultValue, format, onChange, placeholder, editable, labels, extensions, onEditorReady, 'aria-label': label, className, contentClassName }: RichTextEditorProps): import("react").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import type { Editor } from '@tiptap/react';
2
+ import type { ReactNode } from 'react';
3
+ import type { RichTextTool } from './rich-text-tool.contract';
4
+ /** A toolbar tool that is one button: it runs a command, and may show as pressed. */
5
+ export interface ButtonTool {
6
+ icon: ReactNode;
7
+ /** The key chord, shown in the tooltip, such as `Mod-B`. */
8
+ shortcut?: string;
9
+ run: (editor: Editor) => void;
10
+ canRun: (editor: Editor) => boolean;
11
+ isActive?: (editor: Editor) => boolean;
12
+ }
13
+ /** The tools that open a menu or a popover instead of running one command. */
14
+ export type MenuTool = 'heading' | 'link' | 'table' | 'textColor';
15
+ /** The button tools, by tool. */
16
+ export declare const BUTTON_TOOLS: Readonly<Record<Exclude<RichTextTool, MenuTool>, ButtonTool>>;
@@ -0,0 +1,18 @@
1
+ import { type Editor } from '@tiptap/react';
2
+ import type { RichTextLabels } from './rich-text-labels.content';
3
+ import type { RichTextToolbarItem } from './rich-text-tool.contract';
4
+ /** Props of {@link EditorToolbar}. */
5
+ export interface EditorToolbarProps {
6
+ editor: Editor;
7
+ /** The tools, in order, with `|` between groups. */
8
+ items: readonly RichTextToolbarItem[];
9
+ labels: RichTextLabels;
10
+ }
11
+ /**
12
+ * The toolbar of the rich-text editor: the chosen tools, each showing whether its format is on where the cursor is.
13
+ * It follows the ARIA toolbar pattern: the left and right arrow keys move between its buttons, Home and End jump.
14
+ *
15
+ * @param props - The editor, the toolbar items and the labels.
16
+ * @returns The toolbar.
17
+ */
18
+ export declare function EditorToolbar({ editor, items, labels }: EditorToolbarProps): import("react").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import type { Editor } from '@tiptap/react';
2
+ import type { RichTextLabels } from './rich-text-labels.content';
3
+ /** Props of {@link HeadingMenu}. */
4
+ export interface HeadingMenuProps {
5
+ editor: Editor;
6
+ /** The heading level where the cursor is, or 0 for a paragraph. */
7
+ level: number;
8
+ labels: RichTextLabels;
9
+ }
10
+ /**
11
+ * The text style menu: paragraph or heading 1 to 6. Its button shows the style where the cursor is.
12
+ *
13
+ * @param props - The editor, the current level and the labels.
14
+ * @returns The menu.
15
+ */
16
+ export declare function HeadingMenu({ editor, level, labels }: HeadingMenuProps): import("react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ export { EditorToolbar } from './editor-toolbar.component';
2
+ export type { EditorToolbarProps } from './editor-toolbar.component';
3
+ export { DEFAULT_RICH_TEXT_LABELS } from './rich-text-labels.content';
4
+ export type { RichTextLabels } from './rich-text-labels.content';
5
+ export { RICH_TEXT_PRESETS } from './rich-text-presets.content';
6
+ export type { RichTextTool, RichTextToolbarItem } from './rich-text-tool.contract';
@@ -0,0 +1,16 @@
1
+ import type { Editor } from '@tiptap/react';
2
+ import type { RichTextLabels } from './rich-text-labels.content';
3
+ /** Props of {@link LinkPopover}. */
4
+ export interface LinkPopoverProps {
5
+ editor: Editor;
6
+ /** The address of the link where the cursor is, or undefined outside a link. */
7
+ href: string | undefined;
8
+ labels: RichTextLabels;
9
+ }
10
+ /**
11
+ * The link button and its popover: type an address to link the selected text, or remove the link under the cursor.
12
+ *
13
+ * @param props - The editor, the current link address and the labels.
14
+ * @returns The button with its popover.
15
+ */
16
+ export declare function LinkPopover({ editor, href, labels }: LinkPopoverProps): import("react").JSX.Element;
@@ -0,0 +1,30 @@
1
+ import type { RichTextTool } from './rich-text-tool.contract';
2
+ /** The words of the toolbar: a name for each tool, and for the actions inside its menus and popovers. */
3
+ export type RichTextLabels = Record<RichTextTool, string> & {
4
+ toolbar: string;
5
+ paragraph: string;
6
+ heading1: string;
7
+ heading2: string;
8
+ heading3: string;
9
+ heading4: string;
10
+ heading5: string;
11
+ heading6: string;
12
+ linkUrl: string;
13
+ linkApply: string;
14
+ linkRemove: string;
15
+ colorDefault: string;
16
+ tableInsert: string;
17
+ tableRowAbove: string;
18
+ tableRowBelow: string;
19
+ tableRowDelete: string;
20
+ tableColumnLeft: string;
21
+ tableColumnRight: string;
22
+ tableColumnDelete: string;
23
+ tableMergeCells: string;
24
+ tableSplitCell: string;
25
+ tableHeaderRow: string;
26
+ tableHeaderColumn: string;
27
+ tableDelete: string;
28
+ };
29
+ /** The English words of the toolbar. Pass `labels` to the editor to translate any of them. */
30
+ export declare const DEFAULT_RICH_TEXT_LABELS: RichTextLabels;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Ready-made toolbars. `minimal` suits a comment box, `standard` a notes app and `full` a document editor. Pass
3
+ * one as `tools`, or spread it and add or drop tools.
4
+ */
5
+ export declare const RICH_TEXT_PRESETS: {
6
+ readonly minimal: readonly ["bold", "italic", "link", "|", "bulletList", "orderedList"];
7
+ readonly standard: readonly ["undo", "redo", "|", "heading", "|", "bold", "italic", "underline", "strike", "code", "|", "bulletList", "orderedList", "taskList", "|", "blockquote", "codeBlock", "link"];
8
+ readonly full: readonly ["undo", "redo", "|", "heading", "|", "bold", "italic", "underline", "strike", "code", "subscript", "superscript", "highlight", "textColor", "clearFormatting", "|", "bulletList", "orderedList", "taskList", "outdent", "indent", "|", "alignLeft", "alignCenter", "alignRight", "alignJustify", "|", "blockquote", "codeBlock", "horizontalRule", "link", "table"];
9
+ };
@@ -0,0 +1,4 @@
1
+ /** A tool of the rich-text toolbar. */
2
+ export type RichTextTool = 'undo' | 'redo' | 'heading' | 'bold' | 'italic' | 'underline' | 'strike' | 'code' | 'subscript' | 'superscript' | 'highlight' | 'textColor' | 'clearFormatting' | 'bulletList' | 'orderedList' | 'taskList' | 'indent' | 'outdent' | 'blockquote' | 'codeBlock' | 'horizontalRule' | 'link' | 'table' | 'alignLeft' | 'alignCenter' | 'alignRight' | 'alignJustify';
3
+ /** An item of the toolbar: a tool, or `|` for a separator between groups. */
4
+ export type RichTextToolbarItem = RichTextTool | '|';
@@ -0,0 +1,17 @@
1
+ import type { Editor } from '@tiptap/react';
2
+ import type { RichTextLabels } from './rich-text-labels.content';
3
+ /** Props of {@link TableMenu}. */
4
+ export interface TableMenuProps {
5
+ editor: Editor;
6
+ /** Whether the cursor is in a table. Outside one, the menu only inserts a table. */
7
+ inTable: boolean;
8
+ labels: RichTextLabels;
9
+ }
10
+ /**
11
+ * The table menu: insert a 3 × 3 table with a header row, or, inside a table, add and delete rows and columns, merge
12
+ * and split cells, switch the header row and column, and delete the table. Actions that cannot run are disabled.
13
+ *
14
+ * @param props - The editor, whether the cursor is in a table, and the labels.
15
+ * @returns The menu.
16
+ */
17
+ export declare function TableMenu({ editor, inTable, labels }: TableMenuProps): import("react").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import type { Editor } from '@tiptap/react';
2
+ import type { RichTextLabels } from './rich-text-labels.content';
3
+ /** Props of {@link TextColorMenu}. */
4
+ export interface TextColorMenuProps {
5
+ editor: Editor;
6
+ /** The colour of the text where the cursor is, or undefined for the default colour. */
7
+ color: string | undefined;
8
+ labels: RichTextLabels;
9
+ }
10
+ /**
11
+ * The text colour button and its swatches. The first swatch takes the colour away. HTML keeps the colour, Markdown
12
+ * has no colour and drops it.
13
+ *
14
+ * @param props - The editor, the current colour and the labels.
15
+ * @returns The button with its swatches.
16
+ */
17
+ export declare function TextColorMenu({ editor, color, labels }: TextColorMenuProps): import("react").JSX.Element;
@@ -0,0 +1,19 @@
1
+ import { Button } from '@talogic/react';
2
+ import type { ComponentProps, ReactNode } from 'react';
3
+ /** Props of {@link ToolbarButton}. */
4
+ export interface ToolbarButtonProps extends Omit<ComponentProps<typeof Button>, 'children'> {
5
+ /** The name of the action. It names the button and shows in its tooltip. */
6
+ label: string;
7
+ icon: ReactNode;
8
+ /** The key chord, such as `Mod-B`. */
9
+ shortcut?: string;
10
+ /** Whether the format is on where the cursor is. Undefined for a button that is never pressed. */
11
+ pressed?: boolean;
12
+ }
13
+ /**
14
+ * A toolbar icon button with a tooltip that names it and shows its shortcut.
15
+ *
16
+ * @param props - `label`, `icon`, `shortcut`, `pressed` and any button props.
17
+ * @returns The button in its tooltip.
18
+ */
19
+ export declare function ToolbarButton({ label, icon, shortcut, pressed, ...props }: ToolbarButtonProps): import("react").JSX.Element;