@metamorph-labs/polymorph-vue-ui 1.0.16 → 1.0.17

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.
Files changed (143) hide show
  1. package/CHANGELOG.md +134 -0
  2. package/dist/ai/ArtifactPane.js.map +1 -1
  3. package/dist/ai/ArtifactPane.vue_vue_type_script_setup_true_lang.js.map +1 -1
  4. package/dist/archetypes/MasterDetailPage.js.map +1 -1
  5. package/dist/archetypes/MasterDetailPage.vue_vue_type_script_setup_true_lang.js +1 -1
  6. package/dist/archetypes/MasterDetailPage.vue_vue_type_script_setup_true_lang.js.map +1 -1
  7. package/dist/archetypes/app-shell.css +1 -1
  8. package/dist/archetypes/app-shell.module.js +2 -2
  9. package/dist/archetypes/app-shell.module.js.map +1 -1
  10. package/dist/controls/RichTextInput.js +7 -0
  11. package/dist/controls/RichTextInput.js.map +1 -0
  12. package/dist/controls/RichTextInput.vue_vue_type_script_setup_true_lang.js +1123 -0
  13. package/dist/controls/RichTextInput.vue_vue_type_script_setup_true_lang.js.map +1 -0
  14. package/dist/controls/rich-text-input.css +1 -0
  15. package/dist/controls/rich-text-input.module.js +47 -0
  16. package/dist/controls/rich-text-input.module.js.map +1 -0
  17. package/dist/controls/selection-bar.css +1 -0
  18. package/dist/controls/selection-bar.module.js +11 -0
  19. package/dist/controls/selection-bar.module.js.map +1 -0
  20. package/dist/index.js +41 -39
  21. package/dist/index.js.map +1 -1
  22. package/dist/node/ai/ArtifactPane.js.map +1 -1
  23. package/dist/node/ai/ArtifactPane.vue_vue_type_script_setup_true_lang.js.map +1 -1
  24. package/dist/node/archetypes/MasterDetailPage.js.map +1 -1
  25. package/dist/node/archetypes/MasterDetailPage.vue_vue_type_script_setup_true_lang.js +1 -1
  26. package/dist/node/archetypes/MasterDetailPage.vue_vue_type_script_setup_true_lang.js.map +1 -1
  27. package/dist/node/archetypes/app-shell.module.js +2 -2
  28. package/dist/node/archetypes/app-shell.module.js.map +1 -1
  29. package/dist/node/controls/RichTextInput.js +7 -0
  30. package/dist/node/controls/RichTextInput.js.map +1 -0
  31. package/dist/node/controls/RichTextInput.vue_vue_type_script_setup_true_lang.js +1123 -0
  32. package/dist/node/controls/RichTextInput.vue_vue_type_script_setup_true_lang.js.map +1 -0
  33. package/dist/node/controls/rich-text-input.module.js +46 -0
  34. package/dist/node/controls/rich-text-input.module.js.map +1 -0
  35. package/dist/node/controls/selection-bar.module.js +10 -0
  36. package/dist/node/controls/selection-bar.module.js.map +1 -0
  37. package/dist/node/index.js +41 -39
  38. package/dist/node/index.js.map +1 -1
  39. package/dist/node/overlays/Toast.js.map +1 -1
  40. package/dist/node/overlays/Toast.vue_vue_type_script_setup_true_lang.js +27 -27
  41. package/dist/node/overlays/Toast.vue_vue_type_script_setup_true_lang.js.map +1 -1
  42. package/dist/node/structure/Accordion.js.map +1 -1
  43. package/dist/node/structure/Accordion.vue_vue_type_script_setup_true_lang.js +4 -0
  44. package/dist/node/structure/Accordion.vue_vue_type_script_setup_true_lang.js.map +1 -1
  45. package/dist/node/structure/Collapsible.js.map +1 -1
  46. package/dist/node/structure/Collapsible.vue_vue_type_script_setup_true_lang.js +4 -0
  47. package/dist/node/structure/Collapsible.vue_vue_type_script_setup_true_lang.js.map +1 -1
  48. package/dist/node/structure/CursorPagination.js.map +1 -1
  49. package/dist/node/structure/CursorPagination.vue_vue_type_script_setup_true_lang.js +140 -93
  50. package/dist/node/structure/CursorPagination.vue_vue_type_script_setup_true_lang.js.map +1 -1
  51. package/dist/node/structure/Image.js.map +1 -1
  52. package/dist/node/structure/Image.vue_vue_type_script_setup_true_lang.js +30 -18
  53. package/dist/node/structure/Image.vue_vue_type_script_setup_true_lang.js.map +1 -1
  54. package/dist/node/structure/Pagination.js.map +1 -1
  55. package/dist/node/structure/Pagination.vue_vue_type_script_setup_true_lang.js +124 -71
  56. package/dist/node/structure/Pagination.vue_vue_type_script_setup_true_lang.js.map +1 -1
  57. package/dist/node/structure/RichTextContent.js +7 -0
  58. package/dist/node/structure/RichTextContent.js.map +1 -0
  59. package/dist/node/structure/RichTextContent.vue_vue_type_script_setup_true_lang.js +298 -0
  60. package/dist/node/structure/RichTextContent.vue_vue_type_script_setup_true_lang.js.map +1 -0
  61. package/dist/node/structure/RichTextContentBlocks.js +7 -0
  62. package/dist/node/structure/RichTextContentBlocks.js.map +1 -0
  63. package/dist/node/structure/RichTextContentBlocks.vue_vue_type_script_setup_true_lang.js +94 -0
  64. package/dist/node/structure/RichTextContentBlocks.vue_vue_type_script_setup_true_lang.js.map +1 -0
  65. package/dist/node/structure/RichTextContentInlines.js +7 -0
  66. package/dist/node/structure/RichTextContentInlines.js.map +1 -0
  67. package/dist/node/structure/RichTextContentInlines.vue_vue_type_script_setup_true_lang.js +69 -0
  68. package/dist/node/structure/RichTextContentInlines.vue_vue_type_script_setup_true_lang.js.map +1 -0
  69. package/dist/node/structure/RichTextContentItem.js +7 -0
  70. package/dist/node/structure/RichTextContentItem.js.map +1 -0
  71. package/dist/node/structure/RichTextContentItem.vue_vue_type_script_setup_true_lang.js +94 -0
  72. package/dist/node/structure/RichTextContentItem.vue_vue_type_script_setup_true_lang.js.map +1 -0
  73. package/dist/node/structure/code-block.module.js +2 -2
  74. package/dist/node/structure/code-block.module.js.map +1 -1
  75. package/dist/node/structure/cursor-pagination.module.js +6 -3
  76. package/dist/node/structure/cursor-pagination.module.js.map +1 -1
  77. package/dist/node/structure/pagination.module.js +6 -3
  78. package/dist/node/structure/pagination.module.js.map +1 -1
  79. package/dist/node/structure/rich-text-content.module.js +18 -0
  80. package/dist/node/structure/rich-text-content.module.js.map +1 -0
  81. package/dist/overlays/Toast.js.map +1 -1
  82. package/dist/overlays/Toast.vue_vue_type_script_setup_true_lang.js +27 -27
  83. package/dist/overlays/Toast.vue_vue_type_script_setup_true_lang.js.map +1 -1
  84. package/dist/structure/Accordion.js.map +1 -1
  85. package/dist/structure/Accordion.vue_vue_type_script_setup_true_lang.js +4 -0
  86. package/dist/structure/Accordion.vue_vue_type_script_setup_true_lang.js.map +1 -1
  87. package/dist/structure/Collapsible.js.map +1 -1
  88. package/dist/structure/Collapsible.vue_vue_type_script_setup_true_lang.js +4 -0
  89. package/dist/structure/Collapsible.vue_vue_type_script_setup_true_lang.js.map +1 -1
  90. package/dist/structure/CursorPagination.js.map +1 -1
  91. package/dist/structure/CursorPagination.vue_vue_type_script_setup_true_lang.js +140 -93
  92. package/dist/structure/CursorPagination.vue_vue_type_script_setup_true_lang.js.map +1 -1
  93. package/dist/structure/Image.js.map +1 -1
  94. package/dist/structure/Image.vue_vue_type_script_setup_true_lang.js +30 -18
  95. package/dist/structure/Image.vue_vue_type_script_setup_true_lang.js.map +1 -1
  96. package/dist/structure/Pagination.js.map +1 -1
  97. package/dist/structure/Pagination.vue_vue_type_script_setup_true_lang.js +124 -71
  98. package/dist/structure/Pagination.vue_vue_type_script_setup_true_lang.js.map +1 -1
  99. package/dist/structure/RichTextContent.js +7 -0
  100. package/dist/structure/RichTextContent.js.map +1 -0
  101. package/dist/structure/RichTextContent.vue_vue_type_script_setup_true_lang.js +298 -0
  102. package/dist/structure/RichTextContent.vue_vue_type_script_setup_true_lang.js.map +1 -0
  103. package/dist/structure/RichTextContentBlocks.js +7 -0
  104. package/dist/structure/RichTextContentBlocks.js.map +1 -0
  105. package/dist/structure/RichTextContentBlocks.vue_vue_type_script_setup_true_lang.js +94 -0
  106. package/dist/structure/RichTextContentBlocks.vue_vue_type_script_setup_true_lang.js.map +1 -0
  107. package/dist/structure/RichTextContentInlines.js +7 -0
  108. package/dist/structure/RichTextContentInlines.js.map +1 -0
  109. package/dist/structure/RichTextContentInlines.vue_vue_type_script_setup_true_lang.js +69 -0
  110. package/dist/structure/RichTextContentInlines.vue_vue_type_script_setup_true_lang.js.map +1 -0
  111. package/dist/structure/RichTextContentItem.js +7 -0
  112. package/dist/structure/RichTextContentItem.js.map +1 -0
  113. package/dist/structure/RichTextContentItem.vue_vue_type_script_setup_true_lang.js +94 -0
  114. package/dist/structure/RichTextContentItem.vue_vue_type_script_setup_true_lang.js.map +1 -0
  115. package/dist/structure/code-block.css +1 -1
  116. package/dist/structure/code-block.module.js +2 -2
  117. package/dist/structure/code-block.module.js.map +1 -1
  118. package/dist/structure/cursor-pagination.css +1 -1
  119. package/dist/structure/cursor-pagination.module.js +6 -3
  120. package/dist/structure/cursor-pagination.module.js.map +1 -1
  121. package/dist/structure/pagination.css +1 -1
  122. package/dist/structure/pagination.module.js +6 -3
  123. package/dist/structure/pagination.module.js.map +1 -1
  124. package/dist/structure/rich-text-content.css +1 -0
  125. package/dist/structure/rich-text-content.module.js +19 -0
  126. package/dist/structure/rich-text-content.module.js.map +1 -0
  127. package/dist/types/ai/ArtifactPane.vue.d.ts +1 -1
  128. package/dist/types/ai/AttachmentChip.vue.d.ts +1 -1
  129. package/dist/types/ai/ToolCall.vue.d.ts +1 -1
  130. package/dist/types/controls/RichTextInput.vue.d.ts +210 -0
  131. package/dist/types/index.d.ts +4 -0
  132. package/dist/types/overlays/CommandPanel.vue.d.ts +2 -2
  133. package/dist/types/structure/Accordion.vue.d.ts +7 -0
  134. package/dist/types/structure/Collapsible.vue.d.ts +7 -0
  135. package/dist/types/structure/CursorPagination.vue.d.ts +13 -0
  136. package/dist/types/structure/EmptyState.vue.d.ts +1 -1
  137. package/dist/types/structure/Image.vue.d.ts +13 -0
  138. package/dist/types/structure/Pagination.vue.d.ts +8 -0
  139. package/dist/types/structure/RichTextContent.vue.d.ts +59 -0
  140. package/dist/types/structure/RichTextContentBlocks.vue.d.ts +7 -0
  141. package/dist/types/structure/RichTextContentInlines.vue.d.ts +7 -0
  142. package/dist/types/structure/RichTextContentItem.vue.d.ts +7 -0
  143. package/package.json +17 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RichTextInput.js","names":[],"sources":["../../../src/controls/RichTextInput.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * A field that holds a rich-text document: a comment, an issue's description, a note (`design/components/rich-text-input.md`).\n *\n * Generated by `pnpm shells` from `packages/shells/src/members/rich-text-input.ts`, the member's\n * framework-neutral description. Never edit it by hand: change the description and\n * run `pnpm shells`.\n */\nimport {\n computed,\n onBeforeUnmount,\n onMounted,\n ref,\n useId,\n useTemplateRef,\n watch,\n type Ref,\n type VNode,\n} from 'vue'\n\nimport {\n Icon,\n RICH_TEXT_FORMATS,\n agentMember,\n createRichTextEditor,\n emptyRichText,\n enterToolbar,\n focusOnLabelPress,\n followFieldFocus,\n followFormReset,\n followSelectionBar,\n holdToolbarEscape,\n idPart,\n isRichTextEmpty,\n isRichTextNewer,\n placeSelectionBar,\n placeTokenList,\n richTextFromText,\n richTextHref,\n richTextLength,\n richTextPlainText,\n serializeRichText,\n syncToolbarStop,\n toolbarFocusIn,\n toolbarFocusOut,\n toolbarKeydown,\n toolbarLosesFocus,\n toolbarPress,\n toolbarStop,\n useControlRef,\n useListening,\n useTrackedSlots,\n type IconRole,\n type RichTextDocument,\n type RichTextEditor,\n type RichTextEditorEvent,\n type RichTextEditorState,\n type RichTextFormat,\n type RichTextRange,\n type RichTextSuggestionKey,\n} from '@polymorph/vue'\nimport { usePresence } from '@polymorph/vue/motion'\nimport styles from '@polymorph/recipes/controls/rich-text-input.module.css'\nimport selectionBar from '@polymorph/recipes/controls/selection-bar.module.css'\nimport Button from './Button.vue'\nimport FormField from './FormField.vue'\nimport Input from './Input.vue'\nimport Menu from '../overlays/Menu.vue'\nimport Popover from '../overlays/Popover.vue'\nimport Separator from '../structure/Separator.vue'\nimport Skeleton from '../structure/Skeleton.vue'\n\nexport type RichTextInputMinRows = NonNullable<RichTextInputProps['minRows']>\n\nexport type RichTextInputMaxRows = NonNullable<RichTextInputProps['maxRows']>\n\nexport type RichTextToolbarPlacement = NonNullable<RichTextInputProps['toolbarPlacement']>\n\nexport interface RichTextEntityOption {\n id: string\n label: string\n description?: string\n icon?: IconRole\n leading?: VNode\n entityLabel?: string\n}\n\nexport interface RichTextEntitySource {\n kind: string\n trigger: string\n label: string\n options: RichTextEntityOption[]\n filter?: 'contains' | 'startsWith' | false\n loading?: boolean\n error?: string\n onQueryChange?: (query: string) => void\n}\n\nexport interface RichTextInputSelection {\n empty: boolean\n text: string\n range: RichTextRange\n}\n\nexport interface RichTextInputEditor {\n focus(): void\n clear(): void\n insertText(text: string): void\n insertEntity(entity: { kind: string; id: string; label: string }): void\n annotate(id: string): boolean\n removeAnnotation(id: string): boolean\n readonly value: RichTextDocument\n readonly empty: boolean\n readonly length: number\n readonly overLimit: boolean\n readonly disabled: boolean\n readonly selection: RichTextInputSelection\n}\n\nexport interface RichTextInputMessages {\n toolbar?: string\n selectionBar?: string\n selectionBarReady?: string\n bold?: string\n italic?: string\n strike?: string\n code?: string\n link?: string\n textStyle?: string\n paragraph?: string\n heading?: (level: 1 | 2 | 3) => string\n bulletList?: string\n orderedList?: string\n blockquote?: string\n codeBlock?: string\n undo?: string\n redo?: string\n linkForm?: string\n linkAddress?: string\n linkApply?: string\n linkRemove?: string\n linkInvalid?: string\n formatOn?: (format: string) => string\n formatOff?: (format: string) => string\n linkAdded?: string\n linkRemoved?: string\n inserted?: (label: string) => string\n undone?: string\n redone?: string\n count?: (length: number, maxLength: number) => string\n overLimit?: (over: number) => string\n withinLimit?: string\n submitEmpty?: string\n submitOverLimit?: (over: number) => string\n submitPending?: string\n suggestions?: (count: number) => string\n loadingSuggestions?: string\n noSuggestions?: string\n}\n\nexport interface RichTextInputProps {\n /**\n * The drawn annotation that is active, such as the thread the app shows.\n */\n activeAnnotation?: string\n /**\n * The annotations drawn. Default: every one the document holds.\n */\n annotations?: string[]\n ariaDescribedby?: string\n ariaLabel?: string\n ariaLabelledby?: string\n ariaRequired?: boolean\n /**\n * Focus at mount, with the caret at the end. For a surface that has already moved the person\n * here.\n */\n autoFocus?: boolean\n /**\n * Draws the default footer's cancel Button; needs `onCancel`.\n */\n cancelLabel?: string\n /**\n * The editable element.\n */\n controlRef?: Ref<HTMLDivElement | null>\n defaultValue?: RichTextDocument\n disabled?: boolean\n /**\n * The kinds of entity the field suggests, each with its trigger.\n */\n entities?: RichTextEntitySource[]\n /**\n * What the field allows. Default: all ten.\n */\n formats?: RichTextFormat[]\n id?: string\n invalid?: boolean\n /**\n * A soft limit in code points (`richTextLength`): draws the count, and marks the field invalid\n * past it.\n */\n maxLength?: number\n /**\n * How tall the text grows before it scrolls, in body lines. Default 12.\n */\n maxRows?: 6 | 12 | 'none' | 24\n /**\n * Every label and announcement, in the app's words.\n */\n messages?: RichTextInputMessages\n /**\n * The surface's minimum height, in body lines. Default 3.\n */\n minRows?: 1 | 3 | 6 | 12\n /**\n * Adds a hidden input holding `serializeRichText(value)`.\n */\n name?: string\n /**\n * The app is saving: the submit shows loading, the field is read-only, and a submit is\n * refused.\n */\n pending?: boolean\n placeholder?: string\n readOnly?: boolean\n /**\n * Draws the default footer's submit Button; needs `onSubmit`.\n */\n submitLabel?: string\n /**\n * Where the format controls are: a fixed row over the text, or a bar at the selected text.\n */\n toolbarPlacement?: 'fixed' | 'selection'\n value?: RichTextDocument\n}\n\ndefineOptions({ name: 'RichTextInput', inheritAttrs: false, controlKind: 'group' })\n\nconst props = withDefaults(defineProps<RichTextInputProps>(), {\n ariaRequired: undefined,\n autoFocus: false,\n disabled: false,\n entities: () => [],\n invalid: false,\n maxRows: 12,\n minRows: 3,\n pending: false,\n readOnly: false,\n toolbarPlacement: 'fixed',\n})\nconst emit = defineEmits<{\n annotationSelect: [id: string]\n blur: []\n cancel: []\n change: [value: RichTextDocument]\n files: [files: File[]]\n focus: []\n submit: [value: RichTextDocument, editor: RichTextInputEditor]\n}>()\nconst callerSlots = defineSlots<{\n footer?: (props: RichTextInputEditor) => unknown\n selectionActions?: (props: RichTextInputEditor) => unknown\n toolbar?: (props: RichTextInputEditor) => unknown\n}>()\nconst slots = useTrackedSlots(callerSlots)\nconst uid = useId()\nconst listening = useListening()\nconst own = ref(props.defaultValue ?? emptyRichText())\nconst initial = ref(props.defaultValue ?? emptyRichText())\nconst editorState = ref(null as RichTextEditorState | null)\nconst said = ref({ text: '', at: 0 })\nconst highlight = ref({ key: '', index: 0 })\nconst reported = ref(null as string | null)\nconst caretAnnotation = ref(null as string | null)\nconst press = ref(null as { entered: string | null } | null)\nconst linkOpen = ref(false)\nconst linkDraft = ref('')\nconst linkError = ref(undefined as string | undefined)\nconst linkTarget = ref(null as string | null)\nconst headingOpen = ref(false)\nconst headingByPointer = ref(false)\nconst byPointer = ref(false)\nconst textFocused = ref(false)\nconst barFocus = ref(false)\nconst selecting = ref(false)\nconst barDismissed = ref(null as string | null)\nconst barHeard = ref(false)\nconst actions = useTemplateRef<HTMLElement>('actions')\nconst bar = useTemplateRef<HTMLElement>('bar')\nconst controls = useTemplateRef<HTMLElement>('controls')\nconst linkForm = useTemplateRef<HTMLElement>('linkForm')\nconst panel = useTemplateRef<HTMLElement>('panel')\nconst root = useTemplateRef<HTMLElement>('root')\nconst toolbarRow = useTemplateRef<HTMLElement>('toolbarRow')\nconst [surface, attachSurface] = useControlRef(() => props.controlRef)\nconst held = computed(() => ({\n editor: null as RichTextEditor | null,\n handle: null as RichTextInputEditor | null,\n lastValue: undefined as RichTextDocument | undefined,\n saidNow: false,\n}))\nconst say = computed(\n () =>\n ({\n ...{\n toolbar: 'Formatting',\n selectionBar: 'Selection',\n selectionBarReady: 'Controls for the selection are available: Alt+F10',\n bold: 'Bold',\n italic: 'Italic',\n strike: 'Strikethrough',\n code: 'Code',\n link: 'Link',\n textStyle: 'Text style',\n paragraph: 'Paragraph',\n heading: (level: 1 | 2 | 3) => `Heading ${level}`,\n bulletList: 'Bulleted list',\n orderedList: 'Numbered list',\n blockquote: 'Quote',\n codeBlock: 'Code block',\n undo: 'Undo',\n redo: 'Redo',\n linkForm: 'Link',\n linkAddress: 'Address',\n linkApply: 'Apply',\n linkRemove: 'Remove link',\n linkInvalid: 'Enter a web address, an email address or a phone number.',\n formatOn: (format: string) => `${format} on`,\n formatOff: (format: string) => `${format} off`,\n linkAdded: 'Link added',\n linkRemoved: 'Link removed',\n inserted: (label: string) => `${label} inserted`,\n undone: 'Undone',\n redone: 'Redone',\n count: (length: number, maxLength: number) => `${length} / ${maxLength}`,\n overLimit: (over: number) =>\n `${over} ${over === 1 ? 'character' : 'characters'} over the limit`,\n withinLimit: 'Within the limit',\n submitEmpty: 'There is nothing to submit yet.',\n submitOverLimit: (over: number) =>\n `Remove ${over} ${over === 1 ? 'character' : 'characters'} to submit.`,\n submitPending: 'Still saving.',\n suggestions: (count: number) => (count === 1 ? '1 suggestion' : `${count} suggestions`),\n loadingSuggestions: 'Loading suggestions…',\n noSuggestions: 'No results',\n },\n ...(props.messages === undefined\n ? {}\n : Object.fromEntries(\n Object.entries(props.messages).filter(([, words]) => words !== undefined),\n )),\n }) as Required<RichTextInputMessages>,\n)\nconst doc = computed(() => props.value ?? own.value)\nconst empty = computed(() => isRichTextEmpty(doc.value))\nconst length = computed(() => richTextLength(doc.value))\nconst over = computed(() =>\n props.maxLength === undefined ? 0 : Math.max(0, length.value - props.maxLength),\n)\nconst overLimit = computed(() => over.value > 0)\nconst newer = computed(() => isRichTextNewer(doc.value))\nconst unwritable = computed(() => props.readOnly || props.pending || newer.value)\nconst locked = computed(() => props.disabled || unwritable.value)\nconst editable = computed(() => !locked.value)\nconst allowed = computed(() =>\n RICH_TEXT_FORMATS.filter((format) => (props.formats ?? RICH_TEXT_FORMATS).includes(format)),\n)\nconst has = computed(() => (format: RichTextFormat) => allowed.value.includes(format))\nconst kinds = computed(() =>\n props.entities.map((entry) => ({ kind: entry.kind, trigger: entry.trigger })),\n)\nconst marks = computed(() =>\n (\n [\n ['bold', 'bold'],\n ['italic', 'italic'],\n ['strike', 'strikethrough'],\n ['code', 'code'],\n ] as const\n )\n .filter(([format]) => has.value(format))\n .map(([format, icon]) => ({ format, icon })),\n)\nconst blocks = computed(() =>\n (\n [\n ['bulletList', 'list-bulleted'],\n ['orderedList', 'list-numbered'],\n ['blockquote', 'quote'],\n ['codeBlock', 'code-block'],\n ] as const\n )\n .filter(([format]) => has.value(format))\n .map(([format, icon]) => ({ format, icon })),\n)\nconst surfaceId = computed(() => props.id ?? `${uid}-surface`)\nconst listId = computed(() => `${uid}-suggestions`)\nconst countId = computed(() => `${uid}-count`)\nconst active = computed(() => editorState.value?.active)\nconst can = computed(() => editorState.value?.can)\nconst selection = computed(() => ({\n empty: editorState.value?.collapsed ?? true,\n text: editorState.value?.selectedText ?? '',\n range: editorState.value?.range ?? { start: 0, end: 0 },\n}))\nconst focusText = computed(() => () => held.value.editor?.focus())\nconst announce = computed(() => (words: string) => {\n said.value = { text: words, at: said.value.at + 1 }\n held.value.saidNow = true\n queueMicrotask(() => {\n held.value.saidNow = false\n })\n})\nconst formatName = computed(\n () =>\n (format: Exclude<RichTextFormat, 'link'>): string =>\n format === 'heading' ? say.value.textStyle : say.value[format],\n)\nconst heard = computed(() => (event: RichTextEditorEvent) => {\n if (event.type === 'format')\n announce.value(\n (event.active ? say.value.formatOn : say.value.formatOff)(formatName.value(event.format)),\n )\n else if (event.type === 'heading')\n announce.value(event.level === 0 ? say.value.paragraph : say.value.heading(event.level))\n else if (event.type === 'link')\n announce.value(event.active ? say.value.linkAdded : say.value.linkRemoved)\n else if (event.type === 'entity') announce.value(say.value.inserted(event.entity.label))\n else if (event.type === 'undo') announce.value(say.value.undone)\n else announce.value(say.value.redone)\n})\nconst changed = computed(() => (next: RichTextDocument) => {\n if (newer.value) return\n if (props.maxLength !== undefined) {\n const was = richTextLength(doc.value) > props.maxLength\n const nextOver = Math.max(0, richTextLength(next) - props.maxLength)\n if (!was && nextOver > 0) announce.value(say.value.overLimit(nextOver))\n else if (was && nextOver === 0) announce.value(say.value.withinLimit)\n }\n own.value = next\n emit('change', next)\n})\nconst replace = computed(() => (editor: RichTextEditor, next: RichTextDocument) => {\n editor.setValue(next)\n changed.value(editor.getValue())\n})\nconst reset = computed(() => () => {\n const editor = held.value.editor\n if (editor === null || serializeRichText(editor.getValue()) === serializeRichText(initial.value))\n return\n replace.value(editor, initial.value)\n})\nconst followValue = computed(() => () => {\n if (props.value === undefined && held.value.lastValue !== undefined)\n own.value = held.value.lastValue\n held.value.lastValue = props.value\n})\nconst collator = computed(\n () => new Intl.Collator(undefined, { usage: 'search', sensitivity: 'base' }),\n)\nconst suggestion = computed(() => (editable.value ? (editorState.value?.suggestion ?? null) : null))\nconst source = computed(() =>\n ((token) =>\n token === null ? undefined : props.entities.find((entry) => entry.kind === token.kind))(\n suggestion.value,\n ),\n)\nconst open = computed(() => suggestion.value !== null && source.value !== undefined)\nconst query = computed(() => suggestion.value?.query ?? '')\nconst needle = computed(() => query.value.normalize('NFC'))\nconst matches = computed(\n () => (label: string) =>\n ((candidate: string) =>\n needle.value === '' ||\n (source.value?.filter === 'startsWith'\n ? collator.value.compare(candidate.slice(0, needle.value.length), needle.value) === 0\n : Array.from({ length: Math.max(0, candidate.length - needle.value.length + 1) }, (_, at) =>\n candidate.slice(at, at + needle.value.length),\n ).some((part) => collator.value.compare(part, needle.value) === 0)))(\n label.normalize('NFC'),\n ),\n)\nconst loading = computed(() => open.value && source.value?.loading === true)\nconst failed = computed(\n () =>\n open.value && !loading.value && source.value?.error !== undefined && source.value.error !== '',\n)\nconst shown = computed(() =>\n !open.value || failed.value || source.value === undefined\n ? []\n : source.value.filter === false\n ? source.value.options\n : source.value.options.filter((option) => matches.value(option.label)),\n)\nconst listKey = computed(() =>\n open.value && suggestion.value !== null ? `${suggestion.value.key}:${query.value}` : '',\n)\nconst activeOption = computed(() =>\n shown.value.length === 0\n ? -1\n : highlight.value.key === listKey.value\n ? Math.min(highlight.value.index, shown.value.length - 1)\n : 0,\n)\nconst listStatus = computed(() =>\n !open.value\n ? null\n : loading.value\n ? say.value.loadingSuggestions\n : failed.value\n ? (source.value?.error ?? '')\n : shown.value.length === 0\n ? say.value.noSuggestions\n : say.value.suggestions(shown.value.length),\n)\nconst pick = computed(() => (index: number) => {\n const option = shown.value[index]\n const editor = held.value.editor\n const from = source.value\n if (option === undefined || from === undefined || editor === null) return\n reported.value = null\n editor.insertEntity({\n kind: from.kind,\n id: option.id,\n label: option.entityLabel ?? from.trigger + option.label,\n })\n})\nconst suggestionKey = computed(() => (key: RichTextSuggestionKey): boolean => {\n if (!open.value) return false\n if (key === 'ArrowDown' || key === 'ArrowUp') {\n if (shown.value.length === 0) return false\n highlight.value = {\n key: listKey.value,\n index:\n key === 'ArrowDown'\n ? Math.min(activeOption.value + 1, shown.value.length - 1)\n : Math.max(activeOption.value - 1, 0),\n }\n return true\n }\n if (key === 'Enter') {\n if (activeOption.value === -1) return loading.value\n pick.value(activeOption.value)\n return true\n }\n if (key === 'Tab') {\n if (activeOption.value === -1) return false\n pick.value(activeOption.value)\n return true\n }\n held.value.editor?.dismissSuggestion()\n return true\n})\nconst drawn = computed(\n () => (annotation: string) =>\n props.annotations === undefined || props.annotations.includes(annotation),\n)\nconst stated = computed(() => (next: RichTextEditorState) => {\n editorState.value = next\n const token = next.suggestion\n const nextSource =\n token === null ? undefined : props.entities.find((entry) => entry.kind === token.kind)\n const key = token === null || nextSource === undefined ? null : token.key + ':' + token.query\n if (key !== reported.value) {\n reported.value = key\n if (token !== null && key !== null) nextSource?.onQueryChange?.(token.query)\n }\n const at = next.collapsed\n ? (next.annotations.find((annotation) => drawn.value(annotation)) ?? null)\n : null\n if (at !== null && at !== caretAnnotation.value) {\n if (press.value !== null) press.value = { entered: at }\n emit('annotationSelect', at)\n }\n caretAnnotation.value = at\n})\nconst handle = computed(() =>\n ((next: RichTextInputEditor): RichTextInputEditor => {\n const last = held.value.handle\n if (\n last !== null &&\n last.value === next.value &&\n last.empty === next.empty &&\n last.length === next.length &&\n last.overLimit === next.overLimit &&\n last.disabled === next.disabled &&\n last.selection.empty === next.selection.empty &&\n last.selection.text === next.selection.text &&\n last.selection.range.start === next.selection.range.start &&\n last.selection.range.end === next.selection.range.end\n )\n return last\n held.value.handle = next\n return next\n })({\n focus: () => held.value.editor?.focus(),\n clear: () => held.value.editor?.clear(),\n insertText: (words: string) => held.value.editor?.insertText(words),\n insertEntity: (entity: { kind: string; id: string; label: string }) =>\n held.value.editor?.insertEntity(entity),\n annotate: (annotation: string) => held.value.editor?.annotate(annotation) ?? false,\n removeAnnotation: (annotation: string) =>\n held.value.editor?.removeAnnotation(annotation) ?? false,\n value: doc.value,\n empty: empty.value,\n length: length.value,\n overLimit: overLimit.value,\n disabled: locked.value,\n selection: selection.value,\n }),\n)\nconst submit = computed(() => () => {\n if (!listening.submit || props.disabled) return\n if (props.pending) return announce.value(say.value.submitPending)\n if (empty.value) return announce.value(say.value.submitEmpty)\n if (overLimit.value) return announce.value(say.value.submitOverLimit(over.value))\n emit('submit', held.value.editor?.getValue() ?? doc.value, handle.value)\n})\nconst openLink = computed(() => (next: boolean) => {\n if (next) {\n const target = held.value.editor?.getState().active.link ?? null\n linkDraft.value = target ?? ''\n linkError.value = undefined\n linkTarget.value = target\n }\n linkOpen.value = next\n})\nconst applyLink = computed(() => (event: Event) => {\n event.preventDefault()\n event.stopPropagation()\n const raw = linkDraft.value.trim()\n const editor = held.value.editor\n if (\n raw === '' ||\n richTextHref(raw, { typed: true }) === null ||\n editor === null ||\n !editor.setLink(raw)\n ) {\n linkError.value = say.value.linkInvalid\n return\n }\n linkOpen.value = false\n})\nconst removeLink = computed(() => () => {\n held.value.editor?.setLink(null)\n linkOpen.value = false\n})\nconst requestLink = computed(() => () => {\n const editor = held.value.editor\n const anchored = props.toolbarPlacement === 'fixed' || barOpen.value\n if (editor === null || !editable.value || !editor.getState().can.link || !anchored) return\n openLink.value(true)\n})\nconst level = computed(() =>\n active.value === undefined ? 0 : active.value.codeBlock ? -1 : active.value.heading,\n)\nconst headingItems = computed(() =>\n ([0, 1, 2, 3] as const).map((choice) => ({\n kind: 'checkbox' as const,\n label: choice === 0 ? say.value.paragraph : say.value.heading(choice),\n checked: level.value === choice,\n onCheckedChange: () => chooseHeading.value(choice),\n })),\n)\nconst openHeading = computed(() => (next: boolean) => {\n if (next) headingByPointer.value = byPointer.value\n headingOpen.value = next\n})\nconst chooseHeading = computed(() => (choice: 0 | 1 | 2 | 3) => {\n held.value.editor?.setHeading(choice)\n headingOpen.value = false\n})\nconst afterPopup = computed(() => (then: () => void) => {\n const view = root.value?.ownerDocument.defaultView\n view?.requestAnimationFrame(() => view.requestAnimationFrame(then))\n})\nconst linkClosed = computed(() => () => {\n const popover = linkForm.value?.closest('[data-member=\"popover\"]') ?? null\n afterPopup.value(() => {\n const owner = root.value?.ownerDocument\n const at = owner?.activeElement ?? null\n if (\n at === null ||\n at === owner?.body ||\n root.value?.contains(at) === true ||\n popover?.contains(at) === true\n )\n held.value.editor?.focus()\n })\n})\nconst headingClosed = computed(() => () => {\n if (headingByPointer.value) afterPopup.value(() => held.value.editor?.focus())\n})\nconst formatsInBar = computed(\n () => props.toolbarPlacement === 'selection' && editable.value && allowed.value.length > 0,\n)\nconst actionsInBar = computed(() => !!slots.selectionActions && !props.disabled)\nconst rangeKey = computed(() => `${selection.value.range.start}:${selection.value.range.end}`)\nconst barPopup = computed(() => formatsInBar.value && (linkOpen.value || headingOpen.value))\nconst barOpen = computed(\n () =>\n (formatsInBar.value || actionsInBar.value) &&\n editorState.value !== null &&\n !editorState.value.collapsed &&\n (textFocused.value || barFocus.value || barPopup.value) &&\n !selecting.value &&\n barDismissed.value !== rangeKey.value,\n)\nconst escape = computed(() => (): boolean => {\n if (open.value) {\n held.value.editor?.dismissSuggestion()\n return true\n }\n if (barOpen.value) {\n barDismissed.value = rangeKey.value\n return true\n }\n return false\n})\nconst holdSurfaceEscape = computed(() => (element: HTMLElement) => {\n const view = element.ownerDocument.defaultView\n const hold = (event: KeyboardEvent) => {\n if (event.key !== 'Escape' || event.isComposing || event.target !== element) return\n if (escape.value()) event.preventDefault()\n }\n view?.addEventListener('keydown', hold, true)\n return () => view?.removeEventListener('keydown', hold, true)\n})\nconst holdEscapeIn = computed(\n () => (element: HTMLElement, now: () => HTMLElement | null | undefined) => {\n const view = element.ownerDocument.defaultView\n return view === null ? () => {} : holdToolbarEscape(view, now)\n },\n)\nconst releaseSelecting = computed(() => (element: HTMLElement) => {\n const view = element.ownerDocument.defaultView\n const release = () => {\n selecting.value = false\n }\n view?.addEventListener('pointerup', release, true)\n view?.addEventListener('pointercancel', release, true)\n return () => {\n view?.removeEventListener('pointerup', release, true)\n view?.removeEventListener('pointercancel', release, true)\n }\n})\nconst holding = computed(() => open.value || barOpen.value)\nconst toolbarStops = computed(() => toolbarStop())\nconst barStops = computed(() => toolbarStop())\nconst placeBar = computed(\n () => () => placeSelectionBar(bar.value, held.value.editor?.selectionRect(), surface.value),\n)\nconst barLeft = computed(() => () => {\n if (toolbarLosesFocus(bar.value, barStops.value)) held.value.editor?.focus()\n})\nconst placeList = computed(\n () => () =>\n placeTokenList(\n panel.value,\n root.value,\n held.value.editor?.tokenRect() ?? suggestion.value?.rect,\n ),\n)\nconst optionId = computed(\n () => (option: RichTextEntityOption) => `${uid}-suggestion-${idPart(option.id)}`,\n)\nconst describedByAll = computed(\n () =>\n [props.ariaDescribedby, props.maxLength === undefined ? undefined : countId.value]\n .filter((part) => part !== undefined)\n .join(' ') || undefined,\n)\nconst suggesting = computed(() => props.entities.length > 0)\nconst attributes = computed(\n () =>\n ({\n id: surfaceId.value,\n role: 'textbox',\n 'aria-multiline': 'true',\n 'aria-label': props.ariaLabel,\n 'aria-labelledby': props.ariaLabelledby,\n 'aria-describedby': describedByAll.value,\n 'aria-required': props.ariaRequired === true ? 'true' : undefined,\n 'aria-invalid': props.invalid || overLimit.value ? 'true' : undefined,\n 'aria-disabled': props.disabled ? 'true' : undefined,\n 'aria-readonly': !props.disabled && unwritable.value ? 'true' : undefined,\n tabindex: props.disabled ? undefined : '0',\n 'aria-autocomplete': suggesting.value ? 'list' : undefined,\n 'aria-haspopup': suggesting.value ? 'listbox' : undefined,\n 'aria-controls': open.value && shown.value.length > 0 ? listId.value : undefined,\n 'aria-activedescendant': ((entry: RichTextEntityOption | undefined) =>\n open.value && entry !== undefined ? optionId.value(entry) : undefined)(\n activeOption.value === -1 ? undefined : shown.value[activeOption.value],\n ),\n }) as Record<string, string | undefined>,\n)\nconst options = computed(() =>\n JSON.stringify([\n allowed.value,\n kinds.value,\n editable.value,\n !props.disabled && unwritable.value,\n attributes.value,\n props.placeholder ?? null,\n props.annotations ?? null,\n props.activeAnnotation ?? null,\n listening.submit,\n listening.files,\n ]),\n)\nconst editorUpdate = computed(() => () => ({\n formats: allowed.value,\n entities: kinds.value,\n editable: editable.value,\n readOnly: !props.disabled && unwritable.value,\n attributes: attributes.value,\n placeholder: props.placeholder,\n annotations: props.annotations,\n activeAnnotation: props.activeAnnotation,\n onSubmit: listening.submit ? () => submit.value() : undefined,\n onFiles: listening.files ? (files: File[]) => emit('files', files) : undefined,\n}))\nconst mountEditor = computed(() => (element: HTMLElement) => {\n const editor = createRichTextEditor({\n element,\n value: doc.value,\n formats: allowed.value,\n entities: kinds.value,\n classes: {\n paragraph: styles.paragraph ?? '',\n heading: [styles.heading1 ?? '', styles.heading2 ?? '', styles.heading3 ?? ''] as const,\n bulletList: styles.list ?? '',\n orderedList: styles.list ?? '',\n listItem: styles.item ?? '',\n blockquote: styles.quote ?? '',\n codeBlock: styles.codeBlock ?? '',\n codeBlockText: '',\n bold: '',\n italic: '',\n strike: '',\n code: styles.code ?? '',\n link: styles.link ?? '',\n entity: styles.entity ?? '',\n annotation: styles.annotation ?? '',\n unknown: styles.unknown ?? '',\n },\n editable: editable.value,\n readOnly: !props.disabled && unwritable.value,\n attributes: attributes.value,\n placeholder: props.placeholder,\n annotations: props.annotations,\n activeAnnotation: props.activeAnnotation,\n onChange: (next) => changed.value(next),\n onState: (next) => stated.value(next),\n onEvent: (event) => heard.value(event),\n onSubmit: listening.submit ? () => submit.value() : undefined,\n onLinkRequest: () => requestLink.value(),\n onSuggestionKey: (key) => suggestionKey.value(key),\n onFiles: listening.files ? (files) => emit('files', files) : undefined,\n })\n held.value.editor = editor\n // The editor publishes its state after a change, and not at mount.\n stated.value(editor.getState())\n if (props.autoFocus) editor.focus('end')\n return () => {\n editor.destroy()\n held.value.editor = null\n }\n})\nconst command = computed(() => (event: MouseEvent, act: (live: RichTextEditor) => unknown) => {\n const live = held.value.editor\n if (live === null) return\n act(live)\n if (event.detail > 0) live.focus()\n})\nconst surfaceKey = computed(() => (event: KeyboardEvent) => {\n if (!event.altKey || event.key !== 'F10') return\n event.preventDefault()\n if (barOpen.value) enterToolbar(bar.value, barStops.value)\n else if (toolbarDrawn.value) enterToolbar(toolbarRow.value, toolbarStops.value)\n})\nconst surfacePress = computed(() => () => {\n press.value = { entered: null }\n if (slots.selectionActions || formatsInBar.value) selecting.value = true\n})\nconst surfaceClick = computed(() => (event: MouseEvent) => {\n const pressed = press.value\n press.value = null\n const target = event.target instanceof Element ? event.target : null\n const annotation = target?.closest('[data-annotation-id]')?.getAttribute('data-annotation-id')\n if (annotation === null || annotation === undefined || !drawn.value(annotation)) return\n if (held.value.editor?.getState().collapsed === false || props.disabled) return\n caretAnnotation.value = annotation\n if (pressed?.entered !== annotation) emit('annotationSelect', annotation)\n})\nconst surfaceLeave = computed(() => (event: FocusEvent) => {\n const to = event.relatedTarget\n if (to instanceof Node && bar.value?.contains(to) === true) barFocus.value = true\n textFocused.value = false\n})\nconst barLeave = computed(() => (event: FocusEvent) => {\n const to = event.relatedTarget\n if (to instanceof Node && surface.value?.contains(to) === true) textFocused.value = true\n if (!(to instanceof Node) || !(event.currentTarget as HTMLElement).contains(to))\n barFocus.value = false\n // A browser that moves focus off the leaving, inert bar to the page does so here.\n if (to === null && !barOpen.value) barLeft.value()\n})\nconst followFocus = computed(\n () => (element: HTMLElement) =>\n followFieldFocus(element, {\n panels: () => [linkForm.value?.closest('[data-member=\"popover\"]') ?? null],\n entered: () => {\n barHeard.value = false\n emit('focus')\n },\n left: () => emit('blur'),\n }),\n)\nconst fixed = computed(() => props.toolbarPlacement === 'fixed')\nconst toolbarDrawn = computed(() => fixed.value || !!slots.toolbar)\nconst defaultFooter = computed(\n () => !slots.footer && props.submitLabel !== undefined && listening.submit,\n)\nconst footerDrawn = computed(() => !!slots.footer || defaultFooter.value)\nconst barPresent = usePresence(() => barOpen.value, bar)\nlet release1: (() => void) | undefined\nconst effect1 = () => {\n release1?.()\n const ran = root.value ? followFocus.value(root.value) : () => {}\n release1 = () => {\n ran()\n }\n}\nonMounted(effect1)\nonBeforeUnmount(() => release1?.())\nlet release2: (() => void) | undefined\nconst effect2 = () => {\n release2?.()\n const ran = surface.value ? mountEditor.value(surface.value) : () => {}\n release2 = () => {\n ran()\n }\n}\nonMounted(effect2)\nonBeforeUnmount(() => release2?.())\nlet release3: (() => void) | undefined\nconst effect3 = () => {\n release3?.()\n const ran = root.value ? followFormReset(root.value, () => reset.value()) : () => {}\n release3 = () => {\n ran()\n }\n}\nonMounted(effect3)\nonBeforeUnmount(() => release3?.())\nlet release4: (() => void) | undefined\nconst effect4 = () => {\n release4?.()\n const ran = surface.value\n ? focusOnLabelPress(\n surface.value,\n () => held.value.editor?.focus(),\n () => !props.disabled,\n )\n : () => {}\n release4 = () => {\n ran()\n }\n}\nonMounted(effect4)\nwatch(() => props.ariaLabelledby, effect4, { flush: 'post' })\nonBeforeUnmount(() => release4?.())\nconst effect5 = () => {\n followValue.value()\n}\nonMounted(effect5)\nwatch(() => props.value, effect5, { flush: 'post' })\nconst effect6 = () => {\n held.value.editor?.update(editorUpdate.value())\n}\nwatch(() => options.value, effect6, { flush: 'post' })\nconst effect7 = () => {\n props.value === undefined || held.value.editor?.setValue(props.value)\n}\nwatch(() => [props.value, own.value], effect7, { flush: 'post' })\nconst effect8 = () => {\n listStatus.value === null || announce.value(listStatus.value)\n}\nonMounted(effect8)\nwatch(() => listStatus.value, effect8, { flush: 'post' })\nconst effect9 = () => {\n placeList.value()\n}\nonMounted(effect9)\nwatch(() => [suggestion.value, shown.value.length, loading.value, failed.value], effect9, {\n flush: 'post',\n})\nlet release10: (() => void) | undefined\nconst effect10 = () => {\n release10?.()\n const ran =\n open.value && panel.value ? followSelectionBar(panel.value, placeList.value) : () => {}\n release10 = () => {\n ran()\n }\n}\nonMounted(effect10)\nwatch(() => open.value, effect10, { flush: 'post' })\nonBeforeUnmount(() => release10?.())\nlet release11: (() => void) | undefined\nconst effect11 = () => {\n release11?.()\n const ran = holding.value && surface.value ? holdSurfaceEscape.value(surface.value) : () => {}\n release11 = () => {\n ran()\n }\n}\nonMounted(effect11)\nwatch(() => holding.value, effect11, { flush: 'post' })\nonBeforeUnmount(() => release11?.())\nlet release12: (() => void) | undefined\nconst effect12 = () => {\n release12?.()\n const ran = selecting.value && root.value ? releaseSelecting.value(root.value) : () => {}\n release12 = () => {\n ran()\n }\n}\nonMounted(effect12)\nwatch(() => selecting.value, effect12, { flush: 'post' })\nonBeforeUnmount(() => release12?.())\nlet release13: (() => void) | undefined\nconst effect13 = () => {\n release13?.()\n const run = () => {\n syncToolbarStop(toolbarRow.value, toolbarStops.value)\n }\n const mutation = typeof MutationObserver === 'undefined' ? undefined : new MutationObserver(run)\n for (const element of [toolbarRow.value])\n if (element)\n mutation?.observe(element, {\n childList: true,\n characterData: true,\n subtree: true,\n attributeFilter: ['disabled', 'aria-disabled', 'hidden', 'inert'],\n })\n release13 = () => {\n mutation?.disconnect()\n }\n run()\n}\nonMounted(effect13)\nwatch(() => toolbarDrawn.value, effect13, { flush: 'post' })\nonBeforeUnmount(() => release13?.())\nlet release14: (() => void) | undefined\nconst effect14 = () => {\n release14?.()\n const ran =\n toolbarDrawn.value && toolbarRow.value\n ? holdEscapeIn.value(toolbarRow.value, () => toolbarRow.value)\n : () => {}\n release14 = () => {\n ran()\n }\n}\nonMounted(effect14)\nwatch(() => toolbarDrawn.value, effect14, { flush: 'post' })\nonBeforeUnmount(() => release14?.())\nlet release15: (() => void) | undefined\nconst effect15 = () => {\n release15?.()\n const run = () => {\n syncToolbarStop(bar.value, barStops.value)\n }\n const mutation = typeof MutationObserver === 'undefined' ? undefined : new MutationObserver(run)\n for (const element of [bar.value])\n if (element)\n mutation?.observe(element, {\n childList: true,\n characterData: true,\n subtree: true,\n attributeFilter: ['disabled', 'aria-disabled', 'hidden', 'inert'],\n })\n release15 = () => {\n mutation?.disconnect()\n }\n run()\n}\nonMounted(effect15)\nwatch(() => barPresent.value, effect15, { flush: 'post' })\nonBeforeUnmount(() => release15?.())\nlet release16: (() => void) | undefined\nconst effect16 = () => {\n release16?.()\n const ran =\n barPresent.value && bar.value ? holdEscapeIn.value(bar.value, () => bar.value) : () => {}\n release16 = () => {\n ran()\n }\n}\nonMounted(effect16)\nwatch(() => barPresent.value, effect16, { flush: 'post' })\nonBeforeUnmount(() => release16?.())\nconst effect17 = () => {\n barOpen.value && placeBar.value()\n}\nonMounted(effect17)\nwatch(() => [barOpen.value, editorState.value], effect17, { flush: 'post' })\nlet release18: (() => void) | undefined\nconst effect18 = () => {\n release18?.()\n const ran = barOpen.value && bar.value ? followSelectionBar(bar.value, placeBar.value) : () => {}\n release18 = () => {\n ran()\n }\n}\nonMounted(effect18)\nwatch(() => barOpen.value, effect18, { flush: 'post' })\nonBeforeUnmount(() => release18?.())\nconst effect19 = () => {\n barOpen.value || barLeft.value()\n}\nwatch(() => barOpen.value, effect19, { flush: 'post' })\nconst effect20 = () => {\n barOpen.value &&\n !barHeard.value &&\n ((barHeard.value = true), held.value.saidNow || announce.value(say.value.selectionBarReady))\n}\nonMounted(effect20)\nwatch(() => barOpen.value, effect20, { flush: 'post' })\nconst effect21 = () => {\n barDismissed.value !== null &&\n (selection.value.empty || barDismissed.value !== rangeKey.value) &&\n (barDismissed.value = null)\n}\nwatch(() => [rangeKey.value, selection.value.empty], effect21, { flush: 'post' })\nconst effect22 = () => {\n linkOpen.value || linkClosed.value()\n}\nwatch(() => linkOpen.value, effect22, { flush: 'post' })\nconst effect23 = () => {\n headingOpen.value || headingClosed.value()\n}\nwatch(() => headingOpen.value, effect23, { flush: 'post' })\nlet release24: (() => void) | undefined\nconst effect24 = () => {\n release24?.()\n const ran = agentMember({\n member: 'RichTextInput',\n element: () => surface.value,\n state: () => ({\n value: richTextPlainText(doc.value),\n disabled: props.disabled,\n invalid: props.invalid || overLimit.value,\n readonly: unwritable.value,\n empty: empty.value,\n }),\n actions: {\n fill: {\n argument: 'text',\n run: (value) =>\n (() => {\n if (newer.value)\n throw new Error('The document is of a later format than this field writes.')\n if (unwritable.value) throw new Error('The field is read-only.')\n const editor = held.value.editor\n if (editor === null) throw new Error('The field is not ready.')\n replace.value(editor, richTextFromText(value))\n })(),\n },\n clear: () =>\n (() => {\n if (newer.value)\n throw new Error('The document is of a later format than this field writes.')\n if (unwritable.value) throw new Error('The field is read-only.')\n const editor = held.value.editor\n if (editor === null) throw new Error('The field is not ready.')\n editor.clear()\n })(),\n submit: () =>\n (() => {\n if (!listening.submit) throw new Error('The field has no submit.')\n if (props.pending) throw new Error('The app is saving; wait for it to finish.')\n if (empty.value)\n throw new Error('The field is empty, and an empty field is not submitted.')\n if (overLimit.value)\n throw new Error(`The text is ${over.value} characters over the limit.`)\n emit('submit', held.value.editor?.getValue() ?? doc.value, handle.value)\n })(),\n },\n withholds: () => [\n controls.value,\n actions.value,\n bar.value,\n linkForm.value?.closest('[data-member=\"popover\"]') ?? null,\n ],\n })\n release24 = () => {\n ran()\n }\n}\nonMounted(effect24)\nonBeforeUnmount(() => release24?.())\n</script>\n\n<template>\n <div\n ref=\"root\"\n :class=\"styles.root\"\n :data-min-rows=\"String(minRows)\"\n :data-max-rows=\"String(maxRows)\"\n :data-empty=\"empty ? '' : undefined\"\n :data-disabled=\"disabled ? '' : undefined\"\n :data-readonly=\"!disabled && unwritable ? '' : undefined\"\n :data-invalid=\"invalid || overLimit ? '' : undefined\"\n data-member=\"rich-text-input\"\n >\n <!-- frame -->\n <div :class=\"styles.frame\">\n <!-- toolbar -->\n <div\n v-if=\"toolbarDrawn\"\n ref=\"toolbarRow\"\n :class=\"styles.toolbar\"\n role=\"toolbar\"\n :aria-label=\"say.toolbar\"\n :aria-controls=\"surfaceId\"\n data-rich-text-input-part=\"toolbar\"\n @keydown=\"\n toolbarKeydown($event.currentTarget as HTMLElement, $event, toolbarStops, focusText)\n \"\n @focusin=\"toolbarFocusIn($event.currentTarget as HTMLElement, $event, toolbarStops)\"\n @focusout=\"toolbarFocusOut($event.currentTarget as HTMLElement, $event, toolbarStops)\"\n @mousedown=\"toolbarPress($event.currentTarget as HTMLElement, $event)\"\n @click.capture=\"byPointer = $event.detail > 0\"\n @keydown.capture=\"byPointer = false\"\n >\n <!-- controls -->\n <div v-if=\"fixed\" ref=\"controls\" :class=\"styles.controls\">\n <div v-if=\"marks.length > 0 || has('link')\" :class=\"styles.group\">\n <template v-for=\"mark in marks\" :key=\"mark.format\">\n <Button\n variant=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n :iconOnly=\"true\"\n :icon=\"mark.icon\"\n :label=\"say[mark.format]\"\n :pressed=\"active?.[mark.format] ?? false\"\n :disabled=\"locked || can?.[mark.format] === false\"\n @click=\"command($event, (live) => live.toggle(mark.format))\"\n />\n </template>\n <Popover\n v-if=\"has('link')\"\n :label=\"say.linkForm\"\n :open=\"linkOpen\"\n @openChange=\"openLink($event)\"\n >\n <template #trigger>\n <Button\n variant=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n :iconOnly=\"true\"\n icon=\"link\"\n :label=\"say.link\"\n :pressed=\"(active?.link ?? null) !== null\"\n :disabled=\"locked || can?.link === false\"\n />\n </template>\n <template #default>\n <!-- link form -->\n <form\n ref=\"linkForm\"\n :class=\"styles.linkForm\"\n :novalidate=\"true\"\n @submit=\"applyLink($event)\"\n >\n <FormField :label=\"say.linkAddress\" :error=\"linkError\">\n <Input\n :value=\"linkDraft\"\n autoComplete=\"off\"\n @change=\"((linkDraft = $event), (linkError = undefined))\"\n />\n </FormField>\n <div :class=\"styles.linkActions\">\n <Button\n v-if=\"linkTarget !== null\"\n variant=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n :label=\"say.linkRemove\"\n @click=\"removeLink()\"\n />\n <Button\n type=\"submit\"\n variant=\"solid\"\n tone=\"accent\"\n size=\"sm\"\n :label=\"say.linkApply\"\n />\n </div>\n </form>\n </template>\n </Popover>\n </div>\n <template v-if=\"has('heading')\">\n <Separator v-if=\"marks.length > 0 || has('link')\" orientation=\"vertical\" />\n <div :class=\"styles.group\">\n <Menu :open=\"headingOpen\" :items=\"headingItems\" @openChange=\"openHeading($event)\">\n <template #trigger>\n <Button\n variant=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n :iconOnly=\"true\"\n icon=\"heading\"\n :label=\"say.textStyle\"\n :disabled=\"locked || can?.heading === false\"\n />\n </template>\n </Menu>\n </div>\n </template>\n <template v-if=\"blocks.length > 0\">\n <Separator\n v-if=\"marks.length > 0 || has('link') || has('heading')\"\n orientation=\"vertical\"\n />\n <div :class=\"styles.group\">\n <template v-for=\"block in blocks\" :key=\"block.format\">\n <Button\n variant=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n :iconOnly=\"true\"\n :icon=\"block.icon\"\n :label=\"say[block.format]\"\n :pressed=\"active?.[block.format] ?? false\"\n :disabled=\"locked || can?.[block.format] === false\"\n @click=\"command($event, (live) => live.toggle(block.format))\"\n />\n </template>\n </div>\n </template>\n <Separator\n v-if=\"marks.length > 0 || has('link') || has('heading') || blocks.length > 0\"\n orientation=\"vertical\"\n />\n <div :class=\"styles.group\">\n <Button\n variant=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n :iconOnly=\"true\"\n icon=\"undo\"\n :label=\"say.undo\"\n :disabled=\"locked || can?.undo !== true\"\n @click=\"command($event, (live) => live.undo())\"\n />\n <Button\n variant=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n :iconOnly=\"true\"\n icon=\"redo\"\n :label=\"say.redo\"\n :disabled=\"locked || can?.redo !== true\"\n @click=\"command($event, (live) => live.redo())\"\n />\n </div>\n </div>\n <!-- slot -->\n <div v-if=\"$slots.toolbar\" :class=\"styles.slot\">\n <slot\n name=\"toolbar\"\n :focus=\"handle.focus\"\n :clear=\"handle.clear\"\n :insertText=\"handle.insertText\"\n :insertEntity=\"handle.insertEntity\"\n :annotate=\"handle.annotate\"\n :removeAnnotation=\"handle.removeAnnotation\"\n :value=\"handle.value\"\n :empty=\"handle.empty\"\n :length=\"handle.length\"\n :overLimit=\"handle.overLimit\"\n :disabled=\"handle.disabled\"\n :selection=\"handle.selection\"\n />\n </div>\n </div>\n <!-- viewport -->\n <div :class=\"styles.viewport\">\n <!-- surface -->\n <div\n :ref=\"attachSurface\"\n :class=\"styles.surface\"\n data-rich-text-input-part=\"surface\"\n :id=\"surfaceId\"\n role=\"textbox\"\n aria-multiline=\"true\"\n :aria-label=\"ariaLabel\"\n :aria-labelledby=\"ariaLabelledby\"\n :aria-describedby=\"describedByAll\"\n :aria-required=\"ariaRequired === true ? 'true' : undefined\"\n :aria-invalid=\"invalid || overLimit ? 'true' : undefined\"\n :aria-disabled=\"disabled ? 'true' : undefined\"\n :aria-readonly=\"!disabled && unwritable ? 'true' : undefined\"\n :tabindex=\"!disabled ? '0' : undefined\"\n :aria-autocomplete=\"suggesting ? 'list' : undefined\"\n :aria-haspopup=\"suggesting ? 'listbox' : undefined\"\n :aria-controls=\"attributes['aria-controls']\"\n :aria-activedescendant=\"attributes['aria-activedescendant']\"\n @keydown=\"surfaceKey($event)\"\n @pointerdown=\"surfacePress()\"\n @click=\"surfaceClick($event)\"\n @focusin=\"textFocused = true\"\n @focusout=\"surfaceLeave($event)\"\n />\n </div>\n <!-- selection bar -->\n <div\n v-if=\"barPresent\"\n ref=\"bar\"\n :class=\"selectionBar.bar\"\n role=\"toolbar\"\n :aria-label=\"say.selectionBar\"\n :data-state=\"!barOpen ? 'closed' : undefined\"\n :inert=\"!barOpen ? true : undefined\"\n @keydown=\"toolbarKeydown($event.currentTarget as HTMLElement, $event, barStops, focusText)\"\n @focusin=\"\n (toolbarFocusIn($event.currentTarget as HTMLElement, $event, barStops), (barFocus = true))\n \"\n @focusout=\"\n (toolbarFocusOut($event.currentTarget as HTMLElement, $event, barStops), barLeave($event))\n \"\n @mousedown=\"toolbarPress($event.currentTarget as HTMLElement, $event)\"\n >\n <div\n :class=\"styles.controls\"\n @click.capture=\"byPointer = $event.detail > 0\"\n @keydown.capture=\"byPointer = false\"\n >\n <div v-if=\"actionsInBar\" :class=\"styles.group\">\n <slot\n name=\"selectionActions\"\n :focus=\"handle.focus\"\n :clear=\"handle.clear\"\n :insertText=\"handle.insertText\"\n :insertEntity=\"handle.insertEntity\"\n :annotate=\"handle.annotate\"\n :removeAnnotation=\"handle.removeAnnotation\"\n :value=\"handle.value\"\n :empty=\"handle.empty\"\n :length=\"handle.length\"\n :overLimit=\"handle.overLimit\"\n :disabled=\"handle.disabled\"\n :selection=\"handle.selection\"\n />\n </div>\n <template v-if=\"formatsInBar && (marks.length > 0 || has('link'))\">\n <Separator v-if=\"actionsInBar\" orientation=\"vertical\" />\n <div :class=\"styles.group\">\n <template v-for=\"mark in marks\" :key=\"mark.format\">\n <Button\n variant=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n :iconOnly=\"true\"\n :icon=\"mark.icon\"\n :label=\"say[mark.format]\"\n :pressed=\"active?.[mark.format] ?? false\"\n :disabled=\"locked || can?.[mark.format] === false\"\n @click=\"command($event, (live) => live.toggle(mark.format))\"\n />\n </template>\n <Popover\n v-if=\"has('link')\"\n :label=\"say.linkForm\"\n :open=\"linkOpen\"\n @openChange=\"openLink($event)\"\n >\n <template #trigger>\n <Button\n variant=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n :iconOnly=\"true\"\n icon=\"link\"\n :label=\"say.link\"\n :pressed=\"(active?.link ?? null) !== null\"\n :disabled=\"locked || can?.link === false\"\n />\n </template>\n <template #default>\n <!-- link form -->\n <form\n ref=\"linkForm\"\n :class=\"styles.linkForm\"\n :novalidate=\"true\"\n @submit=\"applyLink($event)\"\n >\n <FormField :label=\"say.linkAddress\" :error=\"linkError\">\n <Input\n :value=\"linkDraft\"\n autoComplete=\"off\"\n @change=\"((linkDraft = $event), (linkError = undefined))\"\n />\n </FormField>\n <div :class=\"styles.linkActions\">\n <Button\n v-if=\"linkTarget !== null\"\n variant=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n :label=\"say.linkRemove\"\n @click=\"removeLink()\"\n />\n <Button\n type=\"submit\"\n variant=\"solid\"\n tone=\"accent\"\n size=\"sm\"\n :label=\"say.linkApply\"\n />\n </div>\n </form>\n </template>\n </Popover>\n </div>\n </template>\n <template v-if=\"formatsInBar && has('heading')\">\n <Separator\n v-if=\"actionsInBar || (formatsInBar && (marks.length > 0 || has('link')))\"\n orientation=\"vertical\"\n />\n <div :class=\"styles.group\">\n <Menu :open=\"headingOpen\" :items=\"headingItems\" @openChange=\"openHeading($event)\">\n <template #trigger>\n <Button\n variant=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n :iconOnly=\"true\"\n icon=\"heading\"\n :label=\"say.textStyle\"\n :disabled=\"locked || can?.heading === false\"\n />\n </template>\n </Menu>\n </div>\n </template>\n <template v-if=\"formatsInBar && blocks.length > 0\">\n <Separator\n v-if=\"\n actionsInBar ||\n (formatsInBar && (marks.length > 0 || has('link'))) ||\n (formatsInBar && has('heading'))\n \"\n orientation=\"vertical\"\n />\n <div :class=\"styles.group\">\n <template v-for=\"block in blocks\" :key=\"block.format\">\n <Button\n variant=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n :iconOnly=\"true\"\n :icon=\"block.icon\"\n :label=\"say[block.format]\"\n :pressed=\"active?.[block.format] ?? false\"\n :disabled=\"locked || can?.[block.format] === false\"\n @click=\"command($event, (live) => live.toggle(block.format))\"\n />\n </template>\n </div>\n </template>\n </div>\n </div>\n <!-- footer -->\n <div v-if=\"footerDrawn\" :class=\"styles.footer\">\n <!-- count -->\n <p\n v-if=\"maxLength !== undefined\"\n :class=\"styles.count\"\n :id=\"countId\"\n :data-state=\"overLimit ? 'over' : undefined\"\n >\n {{ overLimit ? say.overLimit(over) : say.count(length, maxLength) }}\n </p>\n <template v-if=\"$slots.footer\">\n <slot\n name=\"footer\"\n :focus=\"handle.focus\"\n :clear=\"handle.clear\"\n :insertText=\"handle.insertText\"\n :insertEntity=\"handle.insertEntity\"\n :annotate=\"handle.annotate\"\n :removeAnnotation=\"handle.removeAnnotation\"\n :value=\"handle.value\"\n :empty=\"handle.empty\"\n :length=\"handle.length\"\n :overLimit=\"handle.overLimit\"\n :disabled=\"handle.disabled\"\n :selection=\"handle.selection\"\n />\n </template>\n <!-- actions -->\n <div v-else ref=\"actions\" :class=\"styles.actions\">\n <Button\n v-if=\"cancelLabel !== undefined && listening.cancel\"\n variant=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n :label=\"cancelLabel\"\n :disabled=\"disabled\"\n @click=\"emit('cancel')\"\n />\n <Button\n variant=\"solid\"\n tone=\"accent\"\n size=\"sm\"\n :label=\"submitLabel ?? ''\"\n :disabled=\"disabled || empty || overLimit\"\n :loading=\"pending\"\n @click=\"submit()\"\n />\n </div>\n </div>\n </div>\n <template v-if=\"!footerDrawn\">\n <!-- count -->\n <p\n v-if=\"maxLength !== undefined\"\n :class=\"styles.count\"\n :id=\"countId\"\n :data-state=\"overLimit ? 'over' : undefined\"\n >\n {{ overLimit ? say.overLimit(over) : say.count(length, maxLength) }}\n </p>\n </template>\n <!-- suggestions -->\n <div\n v-if=\"open && source !== undefined\"\n ref=\"panel\"\n :class=\"styles.suggestions\"\n data-rich-text-input-part=\"suggestions\"\n @mousedown=\"$event.preventDefault()\"\n >\n <!-- list -->\n <ul\n v-if=\"shown.length > 0\"\n :class=\"styles.listbox\"\n :id=\"listId\"\n role=\"listbox\"\n :aria-label=\"source?.label\"\n >\n <template v-for=\"(option, index) in shown\" :key=\"option.id\">\n <!-- option -->\n <li\n :class=\"styles.option\"\n :id=\"optionId(option)\"\n role=\"option\"\n :aria-selected=\"index === activeOption ? 'true' : 'false'\"\n :data-highlighted=\"index === activeOption ? '' : undefined\"\n @pointermove=\"index !== activeOption && (highlight = { key: listKey, index })\"\n @click=\"pick(index)\"\n >\n <span v-if=\"option.leading !== undefined\" :class=\"styles.leading\" aria-hidden=\"true\">\n <component :is=\"option.leading\" />\n </span>\n <span v-else-if=\"option.icon !== undefined\" :class=\"styles.glyph\">\n <Icon :name=\"option.icon\" size=\"sm\" />\n </span>\n <span :class=\"styles.text\">\n <span :class=\"styles.label\">\n {{ option.label }}\n </span>\n <span v-if=\"option.description !== undefined\" :class=\"styles.description\">\n {{ option.description }}\n </span>\n </span>\n </li>\n </template>\n </ul>\n <div v-if=\"loading\" :class=\"styles.rows\" aria-hidden=\"true\">\n <template v-for=\"row in [0, 1, 2]\" :key=\"row\">\n <div :class=\"styles.row\">\n <Skeleton textStep=\"sm\" />\n </div>\n </template>\n </div>\n <div v-if=\"failed\" :class=\"styles.error\" aria-hidden=\"true\">\n {{ source?.error }}\n </div>\n <div\n v-if=\"!loading && !failed && shown.length === 0\"\n :class=\"styles.empty\"\n aria-hidden=\"true\"\n >\n {{ say.noSuggestions }}\n </div>\n </div>\n <!-- status -->\n <div :class=\"styles.status\" role=\"status\" aria-live=\"polite\">\n <span v-if=\"said.text !== ''\" :key=\"said.at\">\n {{ said.text }}\n </span>\n </div>\n <input\n v-if=\"name !== undefined\"\n type=\"hidden\"\n :name=\"name\"\n :value=\"serializeRichText(doc)\"\n :disabled=\"disabled\"\n />\n </div>\n</template>\n"],"mappings":""}