@dxos/react-ui-editor 0.3.9-next.7522f7a → 0.3.9

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 (148) hide show
  1. package/dist/lib/browser/index.mjs +930 -811
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/types/src/automerge/automerge-plugin/PatchSemaphore.d.ts +2 -2
  5. package/dist/types/src/automerge/automerge-plugin/PatchSemaphore.d.ts.map +1 -1
  6. package/dist/types/src/automerge/automerge-plugin/codeMirrorToAm.d.ts +2 -2
  7. package/dist/types/src/automerge/automerge-plugin/codeMirrorToAm.d.ts.map +1 -1
  8. package/dist/types/src/automerge/automerge-plugin/handle.d.ts +9 -0
  9. package/dist/types/src/automerge/automerge-plugin/handle.d.ts.map +1 -0
  10. package/dist/types/src/automerge/automerge-plugin/index.d.ts +2 -2
  11. package/dist/types/src/automerge/automerge-plugin/index.d.ts.map +1 -1
  12. package/dist/types/src/automerge/automerge-plugin/plugin.d.ts +6 -5
  13. package/dist/types/src/automerge/automerge-plugin/plugin.d.ts.map +1 -1
  14. package/dist/types/src/automerge/automerge.stories.d.ts +2 -1
  15. package/dist/types/src/automerge/automerge.stories.d.ts.map +1 -1
  16. package/dist/types/src/components/TextEditor/TextEditor.d.ts +24 -20
  17. package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
  18. package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +7 -10
  19. package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
  20. package/dist/types/{stories/html/code-mirror.stories.d.ts → src/components/TextEditor/codemirror.stories.d.ts} +2 -2
  21. package/dist/types/src/components/TextEditor/codemirror.stories.d.ts.map +1 -0
  22. package/dist/types/src/components/TextEditor/extensions/basic/bundle.d.ts +8 -0
  23. package/dist/types/src/components/TextEditor/extensions/basic/bundle.d.ts.map +1 -0
  24. package/dist/types/src/components/TextEditor/extensions/basic/index.d.ts +3 -0
  25. package/dist/types/src/components/TextEditor/extensions/basic/index.d.ts.map +1 -0
  26. package/dist/types/src/components/TextEditor/{theme.d.ts → extensions/basic/theme.d.ts} +2 -1
  27. package/dist/types/src/components/TextEditor/extensions/basic/theme.d.ts.map +1 -0
  28. package/dist/types/src/components/TextEditor/extensions/change.d.ts +7 -0
  29. package/dist/types/src/components/TextEditor/extensions/change.d.ts.map +1 -0
  30. package/dist/types/src/components/TextEditor/extensions/hyperlink/hyperlinkDecoration.d.ts.map +1 -0
  31. package/dist/types/src/components/TextEditor/extensions/hyperlink/hyperlinkTooltip.d.ts.map +1 -0
  32. package/dist/types/src/components/TextEditor/extensions/hyperlink/hyperlinkWidget.d.ts.map +1 -0
  33. package/dist/types/src/components/TextEditor/extensions/hyperlink/index.d.ts +4 -0
  34. package/dist/types/src/components/TextEditor/extensions/hyperlink/index.d.ts.map +1 -0
  35. package/dist/types/src/components/TextEditor/extensions/index.d.ts +4 -3
  36. package/dist/types/src/components/TextEditor/extensions/index.d.ts.map +1 -1
  37. package/dist/types/src/components/TextEditor/extensions/markdown/bundle.d.ts +8 -0
  38. package/dist/types/src/components/TextEditor/extensions/markdown/bundle.d.ts.map +1 -0
  39. package/dist/types/src/components/TextEditor/extensions/markdown/index.d.ts +3 -0
  40. package/dist/types/src/components/TextEditor/extensions/markdown/index.d.ts.map +1 -0
  41. package/dist/types/src/components/{Markdown/markdownTags.d.ts → TextEditor/extensions/markdown/tags.d.ts} +1 -1
  42. package/dist/types/src/components/TextEditor/extensions/markdown/tags.d.ts.map +1 -0
  43. package/dist/types/src/components/TextEditor/extensions/markdown/theme.d.ts +21 -0
  44. package/dist/types/src/components/TextEditor/extensions/markdown/theme.d.ts.map +1 -0
  45. package/dist/types/src/components/TextEditor/index.d.ts +1 -3
  46. package/dist/types/src/components/TextEditor/index.d.ts.map +1 -1
  47. package/dist/types/src/components/TextEditor/yjs.stories.d.ts +11 -0
  48. package/dist/types/src/components/TextEditor/yjs.stories.d.ts.map +1 -0
  49. package/dist/types/src/components/index.d.ts +0 -3
  50. package/dist/types/src/components/index.d.ts.map +1 -1
  51. package/dist/types/src/hooks/index.d.ts +4 -0
  52. package/dist/types/src/hooks/index.d.ts.map +1 -0
  53. package/dist/types/src/hooks/useCollaboration.d.ts +9 -0
  54. package/dist/types/src/hooks/useCollaboration.d.ts.map +1 -0
  55. package/dist/types/src/{model.d.ts → hooks/useTextModel.d.ts} +3 -15
  56. package/dist/types/src/hooks/useTextModel.d.ts.map +1 -0
  57. package/dist/types/src/hooks/yjs/cursors.d.ts.map +1 -0
  58. package/dist/types/src/hooks/yjs/index.d.ts.map +1 -0
  59. package/dist/types/src/hooks/yjs/space-provider.d.ts.map +1 -0
  60. package/dist/types/src/index.d.ts +2 -2
  61. package/dist/types/src/index.d.ts.map +1 -1
  62. package/dist/types/src/styles/tokens.d.ts +4 -0
  63. package/dist/types/src/styles/tokens.d.ts.map +1 -1
  64. package/dist/types/src/testing/replicator.d.ts +1 -1
  65. package/dist/types/src/testing/replicator.d.ts.map +1 -1
  66. package/package.json +30 -27
  67. package/src/automerge/automerge-plugin/PatchSemaphore.ts +5 -5
  68. package/src/automerge/automerge-plugin/codeMirrorToAm.ts +10 -7
  69. package/src/automerge/automerge-plugin/handle.ts +14 -0
  70. package/src/automerge/automerge-plugin/index.ts +2 -2
  71. package/src/automerge/automerge-plugin/plugin.ts +39 -10
  72. package/src/automerge/automerge.stories.tsx +32 -47
  73. package/src/components/TextEditor/TextEditor.stories.tsx +10 -3
  74. package/src/components/TextEditor/TextEditor.tsx +113 -56
  75. package/src/components/TextEditor/codemirror.stories.ts +114 -0
  76. package/src/components/TextEditor/extensions/basic/bundle.ts +28 -0
  77. package/src/components/TextEditor/extensions/basic/index.ts +6 -0
  78. package/src/components/TextEditor/{theme.ts → extensions/basic/theme.ts} +22 -8
  79. package/src/components/TextEditor/extensions/change.ts +22 -0
  80. package/src/components/TextEditor/extensions/hyperlink/index.ts +7 -0
  81. package/src/components/TextEditor/extensions/index.ts +4 -3
  82. package/src/components/TextEditor/extensions/markdown/bundle.ts +99 -0
  83. package/src/components/TextEditor/extensions/markdown/index.ts +6 -0
  84. package/src/components/{Markdown/markdownTheme.ts → TextEditor/extensions/markdown/theme.ts} +16 -16
  85. package/src/components/TextEditor/index.ts +1 -4
  86. package/src/components/TextEditor/yjs.stories.tsx +55 -0
  87. package/src/components/index.ts +0 -3
  88. package/src/hooks/index.ts +7 -0
  89. package/src/hooks/useCollaboration.ts +45 -0
  90. package/src/{model.ts → hooks/useTextModel.ts} +42 -17
  91. package/src/index.ts +3 -3
  92. package/src/styles/tokens.ts +6 -0
  93. package/src/testing/replicator.ts +1 -2
  94. package/dist/types/src/automerge/demo.d.ts +0 -25
  95. package/dist/types/src/automerge/demo.d.ts.map +0 -1
  96. package/dist/types/src/components/Editor/Editor.d.ts +0 -14
  97. package/dist/types/src/components/Editor/Editor.d.ts.map +0 -1
  98. package/dist/types/src/components/Editor/Editor.stories.d.ts +0 -29
  99. package/dist/types/src/components/Editor/Editor.stories.d.ts.map +0 -1
  100. package/dist/types/src/components/Editor/index.d.ts +0 -2
  101. package/dist/types/src/components/Editor/index.d.ts.map +0 -1
  102. package/dist/types/src/components/Markdown/Markdown.d.ts +0 -21
  103. package/dist/types/src/components/Markdown/Markdown.d.ts.map +0 -1
  104. package/dist/types/src/components/Markdown/Markdown.stories.d.ts +0 -20
  105. package/dist/types/src/components/Markdown/Markdown.stories.d.ts.map +0 -1
  106. package/dist/types/src/components/Markdown/index.d.ts +0 -2
  107. package/dist/types/src/components/Markdown/index.d.ts.map +0 -1
  108. package/dist/types/src/components/Markdown/markdownTags.d.ts.map +0 -1
  109. package/dist/types/src/components/Markdown/markdownTheme.d.ts +0 -100
  110. package/dist/types/src/components/Markdown/markdownTheme.d.ts.map +0 -1
  111. package/dist/types/src/components/RichText/RichText.d.ts +0 -20
  112. package/dist/types/src/components/RichText/RichText.d.ts.map +0 -1
  113. package/dist/types/src/components/RichText/RichText.stories.d.ts +0 -27
  114. package/dist/types/src/components/RichText/RichText.stories.d.ts.map +0 -1
  115. package/dist/types/src/components/RichText/index.d.ts +0 -2
  116. package/dist/types/src/components/RichText/index.d.ts.map +0 -1
  117. package/dist/types/src/components/TextEditor/extensions/hyperlinkDecoration.d.ts.map +0 -1
  118. package/dist/types/src/components/TextEditor/extensions/hyperlinkTooltip.d.ts.map +0 -1
  119. package/dist/types/src/components/TextEditor/extensions/hyperlinkWidget.d.ts.map +0 -1
  120. package/dist/types/src/components/TextEditor/theme.d.ts.map +0 -1
  121. package/dist/types/src/model.d.ts.map +0 -1
  122. package/dist/types/src/yjs/cursors.d.ts.map +0 -1
  123. package/dist/types/src/yjs/index.d.ts.map +0 -1
  124. package/dist/types/src/yjs/space-provider.d.ts.map +0 -1
  125. package/dist/types/stories/html/code-mirror.stories.d.ts.map +0 -1
  126. package/src/automerge/demo.ts +0 -106
  127. package/src/components/Editor/Editor.stories.tsx +0 -82
  128. package/src/components/Editor/Editor.tsx +0 -36
  129. package/src/components/Editor/index.ts +0 -5
  130. package/src/components/Markdown/Markdown.stories.tsx +0 -70
  131. package/src/components/Markdown/Markdown.tsx +0 -239
  132. package/src/components/Markdown/index.ts +0 -5
  133. package/src/components/RichText/RichText.stories.tsx +0 -70
  134. package/src/components/RichText/RichText.tsx +0 -181
  135. package/src/components/RichText/index.ts +0 -5
  136. /package/dist/types/src/components/TextEditor/extensions/{hyperlinkDecoration.d.ts → hyperlink/hyperlinkDecoration.d.ts} +0 -0
  137. /package/dist/types/src/components/TextEditor/extensions/{hyperlinkTooltip.d.ts → hyperlink/hyperlinkTooltip.d.ts} +0 -0
  138. /package/dist/types/src/components/TextEditor/extensions/{hyperlinkWidget.d.ts → hyperlink/hyperlinkWidget.d.ts} +0 -0
  139. /package/dist/types/src/{yjs → hooks/yjs}/cursors.d.ts +0 -0
  140. /package/dist/types/src/{yjs → hooks/yjs}/index.d.ts +0 -0
  141. /package/dist/types/src/{yjs → hooks/yjs}/space-provider.d.ts +0 -0
  142. /package/src/components/TextEditor/extensions/{hyperlinkDecoration.ts → hyperlink/hyperlinkDecoration.ts} +0 -0
  143. /package/src/components/TextEditor/extensions/{hyperlinkTooltip.tsx → hyperlink/hyperlinkTooltip.tsx} +0 -0
  144. /package/src/components/TextEditor/extensions/{hyperlinkWidget.tsx → hyperlink/hyperlinkWidget.tsx} +0 -0
  145. /package/src/components/{Markdown/markdownTags.ts → TextEditor/extensions/markdown/tags.ts} +0 -0
  146. /package/src/{yjs → hooks/yjs}/cursors.ts +0 -0
  147. /package/src/{yjs → hooks/yjs}/index.ts +0 -0
  148. /package/src/{yjs → hooks/yjs}/space-provider.ts +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/components/Editor/Editor.tsx", "../../../src/model.ts", "../../../src/yjs/cursors.ts", "../../../src/yjs/space-provider.ts", "../../../src/components/Markdown/Markdown.tsx", "../../../src/components/Markdown/markdownTags.ts", "../../../src/components/Markdown/markdownTheme.ts", "../../../src/styles/markdown.ts", "../../../src/styles/tokens.ts", "../../../src/components/RichText/RichText.tsx", "../../../src/components/TextEditor/index.ts", "../../../src/components/TextEditor/TextEditor.tsx", "../../../src/components/TextEditor/theme.ts", "../../../src/components/TextEditor/extensions/hyperlinkDecoration.ts", "../../../src/components/TextEditor/extensions/hyperlinkTooltip.tsx", "../../../src/components/TextEditor/extensions/hyperlinkWidget.tsx", "../../../src/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { forwardRef, memo, type Ref } from 'react';\n\nimport { YXmlFragment } from '@dxos/text-model';\n\nimport { type EditorSlots, useTextModel, type UseTextModelOptions } from '../../model';\nimport { MarkdownEditor, type MarkdownEditorRef } from '../Markdown';\nimport { RichTextEditor, type TipTapEditor } from '../RichText';\n\nexport type EditorProps = UseTextModelOptions & {\n slots?: EditorSlots;\n};\n\n/**\n * Memoized editor which depends on DXOS platform.\n * Determines which editor to render based on the kind of text.\n */\n// NOTE: Without `memo`, if parent component uses `observer` the editor re-renders excessively.\n// TODO(wittjosiah): Factor out?\nexport const Editor = memo(\n forwardRef<TipTapEditor | MarkdownEditorRef, EditorProps>(({ slots, ...params }, forwardedRef) => {\n const model = useTextModel(params);\n if (!model) {\n return null;\n }\n\n if (model?.content instanceof YXmlFragment) {\n return <RichTextEditor ref={forwardedRef as Ref<TipTapEditor>} model={model} slots={slots} />;\n } else {\n return <MarkdownEditor ref={forwardedRef as Ref<MarkdownEditorRef>} model={model} slots={slots} />;\n }\n }),\n);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type EditorView } from '@codemirror/view';\nimport { type ComponentProps, useMemo } from 'react';\nimport type * as awarenessProtocol from 'y-protocols/awareness';\n\nimport { type Space, type TextObject } from '@dxos/react-client/echo';\nimport { type Identity } from '@dxos/react-client/halo';\nimport type { YText, YXmlFragment } from '@dxos/text-model';\n\nimport { SpaceAwarenessProvider } from './yjs';\n\nexport type EditorSlots = {\n root?: Omit<ComponentProps<'div'>, 'ref'>;\n editor?: {\n className?: string;\n placeholder?: string;\n spellCheck?: boolean;\n tabIndex?: number;\n markdownTheme?: Parameters<typeof EditorView.theme>[0];\n };\n};\n\ntype Awareness = awarenessProtocol.Awareness;\ntype Provider = { awareness: Awareness };\n\n// TODO(wittjosiah): Factor out to common package? @dxos/react-client?\nexport type EditorModel = {\n id: string;\n content: string | YText | YXmlFragment;\n provider?: Provider;\n peer?: {\n id: string;\n name?: string;\n };\n};\n\nexport type UseTextModelOptions = {\n identity?: Identity | null;\n space?: Space;\n text?: TextObject;\n};\n\n// TODO(wittjosiah): Factor out to common package? @dxos/react-client?\n// TODO(burdon): Decouple space (make Editor less dependent on entire stack)?\nexport const useTextModel = ({ identity, space, text }: UseTextModelOptions): EditorModel | undefined => {\n const provider = useMemo(() => {\n if (!space || !text?.doc) {\n return undefined;\n }\n\n return new SpaceAwarenessProvider({ space, doc: text.doc, channel: `yjs.awareness.${text.id}` });\n }, [identity, space, text?.doc]);\n\n if (!text?.doc || !text?.content) {\n return undefined;\n }\n\n return {\n id: text.doc.guid,\n content: text.content,\n provider,\n peer: identity\n ? {\n id: identity.identityKey.toHex(),\n name: identity.profile?.displayName,\n }\n : undefined,\n };\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// Copied from https://github.com/yjs/y-codemirror.next#example.\n\nimport * as random from 'lib0/random';\n\nconst cursorColors = [\n { color: '#30bced', light: '#30bced33' },\n { color: '#6eeb83', light: '#6eeb8333' },\n { color: '#ffbc42', light: '#ffbc4233' },\n { color: '#ecd444', light: '#ecd44433' },\n { color: '#ee6352', light: '#ee635233' },\n { color: '#9ac2c9', light: '#9ac2c933' },\n { color: '#8acb88', light: '#8acb8833' },\n { color: '#1be7ff', light: '#1be7ff33' },\n];\n\n// Select a random color for this user.\nexport const cursorColor = cursorColors[random.uint32() % cursorColors.length];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport * as decoding from 'lib0/decoding';\nimport * as encoding from 'lib0/encoding';\nimport { Observable } from 'lib0/observable';\nimport * as awarenessProtocol from 'y-protocols/awareness';\nimport { type Doc } from 'yjs';\n\nimport { log } from '@dxos/log';\nimport { type Space } from '@dxos/react-client/echo';\nimport { type GossipMessage } from '@dxos/react-client/mesh';\n\ntype Awareness = awarenessProtocol.Awareness;\n\n// Based on https://github.com/yjs/y-webrtc/blob/88baab2/src/y-webrtc.js.\n\nconst messageAwareness = 1;\nconst messageQueryAwareness = 3;\n\n/**\n * Yjs awareness provider on top of a DXOS space.\n */\nexport class SpaceAwarenessProvider extends Observable<any> {\n private readonly _space: Space;\n private readonly _awareness: Awareness;\n private readonly _clientId: number;\n private readonly _channel: string;\n\n constructor({ space, doc, channel, awareness }: { space: Space; doc: Doc; channel: string; awareness?: Awareness }) {\n super();\n this._space = space;\n this._awareness = awareness ?? new awarenessProtocol.Awareness(doc);\n this._channel = channel;\n this._clientId = doc.clientID;\n\n this._awareness.on('update', this._handleAwarenessUpdate.bind(this));\n this._space.listen(this._channel, this._handleSpaceMessage.bind(this));\n\n if (typeof window !== 'undefined') {\n window.addEventListener('beforeunload', this._handleBeforeUnload.bind(this));\n } else if (typeof process !== 'undefined') {\n process.on('exit', this._handleBeforeUnload.bind(this));\n }\n\n // Post queryAwareness.\n const encoderAwarenessQuery = encoding.createEncoder();\n encoding.writeVarUint(encoderAwarenessQuery, messageQueryAwareness);\n void this._space.postMessage(this._channel, encoding.toUint8Array(encoderAwarenessQuery));\n\n // Post local awareness state.\n const encoderAwarenessState = encoding.createEncoder();\n encoding.writeVarUint(encoderAwarenessState, messageAwareness);\n encoding.writeVarUint8Array(\n encoderAwarenessState,\n awarenessProtocol.encodeAwarenessUpdate(this.awareness, [this._clientId]),\n );\n void this._space.postMessage(this._channel, encoding.toUint8Array(encoderAwarenessState));\n }\n\n get awareness(): Awareness {\n return this._awareness;\n }\n\n private _handleAwarenessUpdate({ added, updated, removed }: any, origin: any) {\n log('awareness update', { added, updated, removed, origin });\n const changedClients = added.concat(updated).concat(removed);\n const encoderAwareness = encoding.createEncoder();\n encoding.writeVarUint(encoderAwareness, messageAwareness);\n encoding.writeVarUint8Array(\n encoderAwareness,\n awarenessProtocol.encodeAwarenessUpdate(this._awareness, changedClients),\n );\n void this._space.postMessage(this._channel, encoding.toUint8Array(encoderAwareness));\n }\n\n private _handleSpaceMessage({ payload }: GossipMessage) {\n log('space message', payload);\n const data = new Uint8Array(Array.from(Object.values(payload)));\n const encoder = this._readMessage(data);\n if (encoder) {\n void this._space.postMessage(this._channel, encoding.toUint8Array(encoder));\n }\n }\n\n private _readMessage(message: Uint8Array) {\n const decoder = decoding.createDecoder(message);\n const encoder = encoding.createEncoder();\n const messageType = decoding.readVarUint(decoder);\n\n let sendReply = false;\n switch (messageType) {\n case messageAwareness: {\n awarenessProtocol.applyAwarenessUpdate(this._awareness, decoding.readVarUint8Array(decoder), this);\n break;\n }\n\n case messageQueryAwareness: {\n encoding.writeVarUint(encoder, messageAwareness);\n encoding.writeVarUint8Array(\n encoder,\n awarenessProtocol.encodeAwarenessUpdate(this._awareness, Array.from(this._awareness.getStates().keys())),\n );\n sendReply = true;\n break;\n }\n\n default: {\n console.error('Invalid message:', messageType);\n return encoder;\n }\n }\n\n if (!sendReply) {\n // Nothing has been written, no answer created.\n return null;\n }\n\n return encoder;\n }\n\n private _handleBeforeUnload() {\n awarenessProtocol.removeAwarenessStates(this._awareness, [this._clientId], 'window unload');\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { autocompletion, completionKeymap, closeBrackets, closeBracketsKeymap } from '@codemirror/autocomplete';\nimport { defaultKeymap, history, historyKeymap, indentWithTab } from '@codemirror/commands';\nimport { markdown, markdownLanguage } from '@codemirror/lang-markdown';\nimport {\n bracketMatching,\n defaultHighlightStyle,\n foldKeymap,\n indentOnInput,\n syntaxHighlighting,\n} from '@codemirror/language';\nimport { languages } from '@codemirror/language-data';\nimport { lintKeymap } from '@codemirror/lint';\nimport { searchKeymap, highlightSelectionMatches } from '@codemirror/search';\nimport { EditorState, type Extension, StateField, type Text } from '@codemirror/state';\nimport { oneDarkHighlightStyle } from '@codemirror/theme-one-dark';\nimport {\n keymap,\n crosshairCursor,\n drawSelection,\n dropCursor,\n highlightActiveLine,\n highlightActiveLineGutter,\n highlightSpecialChars,\n placeholder,\n rectangularSelection,\n EditorView,\n} from '@codemirror/view';\nimport { useFocusableGroup } from '@fluentui/react-tabster';\n// import { GFM } from '@lezer/markdown';\nimport { vim } from '@replit/codemirror-vim';\nimport React, {\n type KeyboardEvent,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useState,\n useMemo,\n useCallback,\n} from 'react';\nimport { yCollab } from 'y-codemirror.next';\n\nimport { generateName } from '@dxos/display-name';\nimport { useThemeContext } from '@dxos/react-ui';\nimport { getColorForValue } from '@dxos/react-ui-theme';\nimport { YText } from '@dxos/text-model';\n\nimport { markdownTagsExtension } from './markdownTags';\nimport { markdownHighlightStyle, markdownTheme } from './markdownTheme';\nimport { type EditorModel, type EditorSlots } from '../../model';\n\nexport const EditorModes = ['default', 'vim'] as const;\nexport type EditorMode = (typeof EditorModes)[number];\n\nexport type MarkdownEditorProps = {\n model: EditorModel;\n slots?: EditorSlots;\n editorMode?: EditorMode;\n showWidgets?: boolean;\n extensions?: Extension[];\n onChange?: (content: string | Text) => void;\n};\n\nexport type MarkdownEditorRef = {\n editor: HTMLDivElement | null;\n state?: EditorState;\n view?: EditorView;\n};\n\nexport const MarkdownEditor = forwardRef<MarkdownEditorRef, MarkdownEditorProps>(\n ({ model, slots = {}, editorMode, extensions = [], onChange }, forwardedRef) => {\n const { id, content, provider, peer } = model ?? {};\n const { themeMode } = useThemeContext();\n const tabsterDOMAttribute = useFocusableGroup({ tabBehavior: 'limited' });\n\n const [parent, setParent] = useState<HTMLDivElement | null>(null);\n const [state, setState] = useState<EditorState>();\n const [view, setView] = useState<EditorView>();\n\n useImperativeHandle(forwardedRef, () => ({\n editor: parent,\n state,\n view,\n }));\n\n const listenChangesExtension = useMemo(\n () =>\n StateField.define({\n create: () => null,\n update: (_value, transaction) => {\n if (transaction.docChanged && onChange) {\n onChange(transaction.newDoc);\n }\n return null;\n },\n }),\n [onChange],\n );\n\n useEffect(() => {\n if (provider && peer) {\n provider.awareness.setLocalStateField('user', {\n name: peer.name ?? generateName(peer.id),\n color: getColorForValue({ value: peer.id, type: 'color' }),\n colorLight: getColorForValue({ value: peer.id, themeMode, type: 'highlight' }),\n });\n }\n }, [provider, peer, themeMode]);\n\n useEffect(() => {\n if (!parent) {\n return;\n }\n\n const state = EditorState.create({\n doc: content?.toString(),\n extensions: [\n // Based on https://github.com/codemirror/dev/issues/44#issuecomment-789093799\n listenChangesExtension,\n\n // TODO(burdon): Create custom bundle to make this class more reusable and retire simpler TextEditor component.\n // All of https://github.com/codemirror/basic-setup minus line numbers and fold gutter.\n // https://codemirror.net/docs/ref/#codemirror.basicSetup\n autocompletion(),\n bracketMatching(),\n closeBrackets(),\n crosshairCursor(),\n dropCursor(),\n drawSelection(),\n highlightActiveLine(),\n highlightActiveLineGutter(),\n highlightSelectionMatches(),\n highlightSpecialChars(),\n history(),\n indentOnInput(),\n placeholder(slots.editor?.placeholder ?? ''), // TODO(burdon): Needs consistent styling.\n rectangularSelection(),\n syntaxHighlighting(defaultHighlightStyle, { fallback: true }),\n EditorState.allowMultipleSelections.of(true),\n EditorView.lineWrapping,\n\n keymap.of([\n ...closeBracketsKeymap,\n ...completionKeymap,\n ...defaultKeymap,\n ...foldKeymap,\n ...historyKeymap,\n ...lintKeymap,\n ...searchKeymap,\n indentWithTab,\n ]),\n\n // Main extension.\n // https://github.com/codemirror/lang-markdown\n markdown({\n base: markdownLanguage,\n codeLanguages: languages,\n extensions: [\n // TODO(burdon): This seems to upgrade the parser.\n // GitHub flavored markdown bundle: Table, TaskList, Strikethrough, and Autolink.\n // https://github.com/lezer-parser/markdown?tab=readme-ov-file#github-flavored-markdown\n // https://github.github.com/gfm\n // GFM,\n\n // Custom styling.\n markdownTagsExtension,\n ],\n }),\n\n // Theme.\n EditorView.theme({ ...markdownTheme, ...slots.editor?.markdownTheme }),\n ...(themeMode === 'dark'\n ? [syntaxHighlighting(oneDarkHighlightStyle)]\n : [syntaxHighlighting(defaultHighlightStyle)]),\n\n // TODO(thure): All but one rule here apply to both themes; rename or refactor.\n syntaxHighlighting(markdownHighlightStyle),\n\n // Settings.\n ...(editorMode === 'vim' ? [vim()] : []),\n\n // TODO(burdon): Move to extensions.\n // Replication and awareness (incl. remote selection).\n // https://codemirror.net/docs/ref/#collab\n ...(content instanceof YText ? [yCollab(content, provider?.awareness)] : []),\n\n // Custom.\n ...extensions,\n ],\n });\n\n setState(state);\n\n // NOTE: This repaints the editor.\n // If the new state is derived from the old state, it will likely not be visible other than the cursor resetting.\n // Ideally this should not be hit except when changing between text objects.\n view?.destroy();\n setView(new EditorView({ state, parent }));\n\n return () => {\n view?.destroy();\n setView(undefined);\n setState(undefined);\n };\n }, [parent, content, provider?.awareness, themeMode, editorMode]);\n\n const handleKeyUp = useCallback(\n (event: KeyboardEvent) => {\n const { key, altKey, shiftKey, metaKey, ctrlKey } = event;\n switch (key) {\n case 'Enter': {\n view?.contentDOM.focus();\n break;\n }\n\n case 'Escape': {\n editorMode === 'vim' && (altKey || shiftKey || metaKey || ctrlKey) && parent?.focus();\n break;\n }\n }\n },\n [view, editorMode],\n );\n\n return (\n <div\n tabIndex={0}\n ref={setParent}\n key={id}\n {...slots.root}\n {...(editorMode !== 'vim' ? tabsterDOMAttribute : {})}\n onKeyUp={handleKeyUp}\n />\n );\n },\n);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { styleTags, Tag } from '@lezer/highlight';\nimport { type MarkdownConfig } from '@lezer/markdown';\n\nexport const markdownTags = {\n headingMark: Tag.define(),\n quoteMark: Tag.define(),\n listMark: Tag.define(),\n linkMark: Tag.define(),\n emphasisMark: Tag.define(),\n codeMark: Tag.define(),\n codeText: Tag.define(),\n inlineCode: Tag.define(),\n url: Tag.define(),\n linkReference: Tag.define(),\n linkLabel: Tag.define(),\n};\n\nexport const markdownTagsExtension: MarkdownConfig = {\n props: [\n styleTags({\n HeaderMark: markdownTags.headingMark,\n QuoteMark: markdownTags.quoteMark,\n ListMark: markdownTags.listMark,\n LinkMark: markdownTags.linkMark,\n EmphasisMark: markdownTags.emphasisMark,\n CodeMark: markdownTags.codeMark,\n CodeText: markdownTags.codeText,\n InlineCode: markdownTags.inlineCode,\n URL: markdownTags.url,\n LinkReference: markdownTags.linkReference,\n LinkLabel: markdownTags.linkLabel,\n }),\n ],\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { markdownLanguage } from '@codemirror/lang-markdown';\nimport { HighlightStyle } from '@codemirror/language';\nimport { tags } from '@lezer/highlight';\nimport get from 'lodash.get';\n\nimport { markdownTags } from './markdownTags';\nimport { bold, heading, italic, mark, strikethrough, tokens } from '../../styles';\n\n// TODO(burdon): Use theme colors.\n// TODO(burdon): Light mode.\n\nexport const chalky = '#e5c07b';\nexport const coral = '#e06c75';\nexport const cyan = '#56b6c2';\nexport const invalid = '#ffffff';\nexport const ivory = '#abb2bf';\nexport const stone = '#7d8799';\nexport const malibu = '#61afef';\nexport const sage = '#98c379';\nexport const whiskey = '#d19a66';\nexport const violet = '#c678dd';\nconst _darkBackground = '#21252b';\nexport const highlightBackground = '#2c313a';\nconst _background = '#282c34';\nexport const tooltipBackground = '#353a42';\nconst _selection = '#3E4451';\nexport const cursor = '#ffffff';\n\nconst monospace = get(tokens, 'fontFamily.mono', ['monospace']).join(',');\n\n// TODO(burdon): Subtle difference in layout for documents and stacks.\n// TODO(burdon): On first character, height of editor changes by a few pixels.\n// TODO(burdon): Is the '&' prefix required? If so, document.\n\nexport const markdownTheme = {\n // TODO(thure): consider whether these commented-out rules from one-dark-theme should be integrated.\n // '&': {\n // color: ivory,\n // backgroundColor: background\n // },\n // '.cm-cursor, .cm-dropCursor': { borderLeftColor: cursor },\n // '&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection': {\n // backgroundColor: selection\n // },\n // '.cm-panels': { backgroundColor: darkBackground, color: ivory },\n // '.cm-panels.cm-panels-top': { borderBottom: '2px solid black' },\n // '.cm-panels.cm-panels-bottom': { borderTop: '2px solid black' },\n // '.cm-searchMatch': {\n // backgroundColor: '#72a1ff59',\n // outline: '1px solid #457dff'\n // },\n // '.cm-searchMatch.cm-searchMatch-selected': {\n // backgroundColor: '#6199ff2f'\n // },\n // '.cm-activeLine': { backgroundColor: '#6699ff0b' },\n // '.cm-selectionMatch': { backgroundColor: '#aafe661a' },\n // '&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket': {\n // backgroundColor: '#bad0f847'\n // },\n // '.cm-gutters': {\n // backgroundColor: background,\n // color: stone,\n // border: 'none'\n // },\n // '.cm-activeLineGutter': {\n // backgroundColor: highlightBackground\n // },\n // '.cm-foldPlaceholder': {\n // backgroundColor: 'transparent',\n // border: 'none',\n // color: '#ddd'\n // },\n\n '.cm-tooltip': {\n backgroundColor: 'transparent',\n border: 'none',\n },\n // '.dark & .cm-tooltip': {\n // border: 'none',\n // backgroundColor: tooltipBackground,\n // },\n // '.dark & .cm-tooltip .cm-tooltip-arrow:before': {\n // borderTopColor: 'transparent',\n // borderBottomColor: 'transparent',\n // },\n // '.dark & .cm-tooltip .cm-tooltip-arrow:after': {\n // borderTopColor: tooltipBackground,\n // borderBottomColor: tooltipBackground,\n // },\n // '.dark & .cm-tooltip-autocomplete': {\n // '& > ul > li[aria-selected]': {\n // backgroundColor: highlightBackground,\n // color: ivory,\n // },\n // },\n '&.cm-focused': {\n outline: 'none',\n },\n '& .cm-line': {\n paddingInline: 0,\n minBlockSize: '1.6em',\n },\n '& .cm-line *': {\n lineHeight: 1.6,\n },\n '&.cm-focused .cm-selectionBackground, & .cm-selectionBackground': {\n background: get(tokens, 'extend.colors.primary.150', '#00ffff'),\n },\n '.dark & .cm-selectionBackground, .dark &.cm-focused .cm-selectionBackground': {\n background: get(tokens, 'extend.colors.primary.850', '#00ffff'),\n },\n '& .cm-selectionMatch': {\n background: get(tokens, 'extend.colors.primary.250', '#00ffff') + '44',\n },\n '.dark & .cm-selectionMatch': {\n background: get(tokens, 'extend.colors.primary.600', '#00ffff') + '44',\n },\n '& .cm-content': {\n caretColor: 'black',\n },\n '.dark & .cm-content': {\n caretColor: cursor,\n },\n '& .cm-cursor': {\n borderLeftColor: 'black',\n },\n '.dark & .cm-cursor': {\n borderLeftColor: cursor,\n },\n '.cm-placeholder': {\n fontFamily: get(tokens, 'fontFamily.body', []).join(','),\n },\n '& .cm-scroller': {\n fontFamily: get(tokens, 'fontFamily.mono', []).join(','),\n overflow: 'visible',\n },\n '& .cm-activeLine': {\n backgroundColor: 'transparent',\n },\n '.dark & .cm-activeLine': {\n backgroundColor: 'transparent',\n },\n '& .cm-ySelectionInfo': {\n fontFamily: get(tokens, 'fontFamily.body', []).join(','),\n padding: '2px 4px',\n marginBlockStart: '-4px',\n },\n '& .cm-ySelection, & .cm-selectionMatch': {\n paddingBlockStart: '.15em',\n paddingBlockEnd: '.15em',\n },\n '& .cm-ySelection, & .cm-yLineSelection': {\n mixBlendMode: 'multiply',\n },\n '.dark & .cm-ySelection, .dark & .cm-yLineSelection': {\n mixBlendMode: 'screen',\n },\n '& .cm-ySelectionCaret': {\n display: 'inline-block',\n insetBlockStart: '.1em',\n blockSize: '1.4em',\n verticalAlign: 'top',\n },\n '& .cm-yLineSelection': {\n margin: '0',\n },\n '.cm-link': {\n color: 'rgb(20 89 208)',\n textDecorationLine: 'underline',\n textDecorationThickness: '1px',\n textUnderlineOffset: '2px',\n borderRadius: '.125rem',\n },\n ...Object.keys(get(tokens, 'extend.fontSize', {})).reduce((acc: Record<string, any>, fontSize) => {\n const height = get(tokens, ['extend', 'fontSize', fontSize, 1, 'lineHeight']);\n // TODO(thure): This appears to be the best or only way to set selection caret heights, but it's far more verbose than it needs to be.\n acc[`& .text-${fontSize} + .cm-ySelectionCaret`] = { height };\n acc[`& .text-${fontSize} + .cm-ySelection + .cm-ySelectionCaret`] = { height };\n acc[`& .text-${fontSize} + .cm-widgetBuffer + .cm-ySelectionCaret`] = { height };\n return acc;\n }, {}),\n};\n\nexport const markdownHighlightStyle = HighlightStyle.define(\n [\n {\n tag: [\n tags.keyword,\n tags.name,\n tags.deleted,\n tags.character,\n tags.propertyName,\n tags.macroName,\n tags.color,\n tags.constant(tags.name),\n tags.standard(tags.name),\n tags.definition(tags.name),\n tags.separator,\n tags.typeName,\n tags.className,\n tags.number,\n tags.changed,\n tags.annotation,\n tags.modifier,\n tags.self,\n tags.namespace,\n tags.operator,\n tags.operatorKeyword,\n tags.escape,\n tags.regexp,\n tags.special(tags.string),\n tags.meta,\n tags.comment,\n tags.atom,\n tags.bool,\n tags.special(tags.variableName),\n tags.processingInstruction,\n tags.string,\n tags.inserted,\n tags.invalid,\n ],\n color: 'inherit !important',\n },\n {\n tag: [tags.link, tags.url],\n color: 'inherit !important',\n textDecoration: 'none !important',\n },\n {\n tag: [tags.function(tags.variableName), tags.labelName],\n color: malibu,\n fontFamily: monospace,\n },\n {\n tag: [\n markdownTags.codeMark,\n markdownTags.emphasisMark,\n markdownTags.headingMark,\n markdownTags.linkLabel,\n markdownTags.linkReference,\n markdownTags.listMark,\n markdownTags.quoteMark,\n markdownTags.url,\n tags.meta,\n tags.processingInstruction,\n ],\n class: mark,\n },\n { tag: [markdownTags.codeText, markdownTags.inlineCode], class: 'font-mono' },\n { tag: tags.emphasis, class: italic },\n { tag: tags.heading1, class: heading[1] },\n { tag: tags.heading2, class: heading[2] },\n { tag: tags.heading3, class: heading[3] },\n { tag: tags.heading4, class: heading[4] },\n { tag: tags.heading5, class: heading[5] },\n { tag: tags.heading6, class: heading[6] },\n { tag: tags.strikethrough, class: strikethrough },\n { tag: tags.strong, class: bold },\n ],\n { scope: markdownLanguage, all: { fontFamily: get(tokens, 'fontFamily.body', []).join(',') } },\n);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { mx } from '@dxos/react-ui-theme';\n\nexport type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;\n\nexport const heading: Record<HeadingLevel, string> = {\n 1: 'mbs-4 mbe-2 text-4xl font-semibold text-inherit no-underline',\n 2: 'mbs-4 mbe-2 text-3xl font-bold text-inherit no-underline',\n 3: 'mbs-4 mbe-2 text-2xl font-bold text-inherit no-underline',\n 4: 'mbs-4 mbe-2 text-xl font-extrabold text-inherit no-underline',\n 5: 'mbs-4 mbe-2 text-lg font-extrabold text-inherit no-underline',\n 6: 'mbs-4 mbe-2 font-black text-inherit no-underline',\n};\n\nexport const blockquote = 'mlb-2 border-is-4 border-neutral-500/50 pis-5';\n\n// TODO(thure): Tailwind was not seeing `[&>li:before]:content-[\"•\"]` as a utility class, but it would work if instead of `\"•\"` it was `\"X\"`… why?\nexport const unorderedList =\n 'mlb-2 grid grid-cols-[min-content_1fr] [&>li:before]:content-[attr(marker)] [&>li:before]:mlb-1 [&>li:before]:mie-2';\nexport const orderedList =\n 'mlb-2 grid grid-cols-[min-content_1fr] [&>li:before]:content-[counters(section,_\".\")_\"._\"] [counter-reset:section] [&>li:before]:mlb-1';\n\nexport const listItem = 'contents before:[counter-increment:section]';\n\nexport const codeBlock = 'mlb-2 font-mono bg-neutral-500/10 p-3 rounded';\n\nexport const horizontalRule = 'mlb-4 border-neutral-500/50';\n\nexport const paragraph = 'mlb-1';\n\nexport const bold = 'font-bold';\n\nexport const code = 'font-mono bg-neutral-500/10 rounded pli-0.5 plb-0.5 -mlb-0.5';\n\nexport const placeholder = 'font-mono';\n\nexport const codeWithoutMarks = mx(code, 'pli-1.5 mli-0.5');\n\nexport const italic = 'italic';\n\nexport const strikethrough = 'line-through';\n\nexport const mark = '!font-normal !no-underline !text-inherit opacity-40';\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { tailwindConfig, type TailwindConfig } from '@dxos/react-ui-theme';\n\n// TODO(thure): Why export the whole theme? Can this be done differently?\nexport const tokens: TailwindConfig['theme'] = tailwindConfig({}).theme;\n", "//\n// Copyright 2022 DXOS.org\n//\nimport { mergeAttributes } from '@tiptap/core';\nimport Collaboration from '@tiptap/extension-collaboration';\nimport CollaborationCursor from '@tiptap/extension-collaboration-cursor';\nimport Heading from '@tiptap/extension-heading';\nimport ListItem from '@tiptap/extension-list-item';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport { type Editor, EditorContent, useEditor as useNaturalEditor } from '@tiptap/react';\nimport StarterKit from '@tiptap/starter-kit';\nimport React, { forwardRef, useImperativeHandle, useMemo } from 'react';\n\nimport { generateName } from '@dxos/display-name';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { type EditorModel, type EditorSlots } from '../../model';\nimport {\n blockquote,\n bold,\n codeBlock,\n heading,\n type HeadingLevel,\n horizontalRule,\n italic,\n listItem,\n orderedList,\n paragraph,\n strikethrough,\n unorderedList,\n codeWithoutMarks,\n} from '../../styles';\nimport { cursorColor } from '../../yjs';\n\nexport type TipTapEditor = Editor;\n\ntype UseEditorOptions = {\n model?: EditorModel;\n placeholder?: string;\n slots?: Pick<EditorSlots, 'editor'>;\n};\n\nconst useEditor = ({ model, placeholder = 'Enter text…', slots = {} }: UseEditorOptions) => {\n const extensions = useMemo(\n () => [\n StarterKit.configure({\n // Extensions\n history: false,\n // Nodes\n blockquote: {\n HTMLAttributes: {\n class: blockquote,\n },\n },\n bulletList: {\n HTMLAttributes: {\n class: unorderedList,\n },\n },\n codeBlock: {\n HTMLAttributes: {\n class: codeBlock,\n },\n },\n heading: false, // (thure): `StarterKit` doesn’t let you configure how headings are rendered, see `Heading` below.\n horizontalRule: {\n HTMLAttributes: {\n class: horizontalRule,\n },\n },\n listItem: false, // (thure): `StarterKit` doesn’t let you configure how list items are rendered, see `ListItem` below.\n orderedList: {\n HTMLAttributes: {\n class: orderedList,\n },\n },\n paragraph: {\n HTMLAttributes: {\n class: paragraph,\n },\n },\n // Marks\n bold: {\n HTMLAttributes: {\n class: bold,\n },\n },\n code: {\n HTMLAttributes: {\n class: codeWithoutMarks,\n },\n },\n italic: {\n HTMLAttributes: {\n class: italic,\n },\n },\n strike: {\n HTMLAttributes: {\n class: strikethrough,\n },\n },\n }),\n Heading.extend({\n renderHTML({ node, HTMLAttributes }) {\n const hasLevel = this.options.levels.includes(node.attrs.level);\n const level: HeadingLevel = hasLevel ? node.attrs.level : this.options.levels[0];\n\n return [\n `h${level}`,\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {\n class: heading[level],\n }),\n 0,\n ];\n },\n }),\n ListItem.extend({\n renderHTML: ({ HTMLAttributes }) => [\n 'li',\n mergeAttributes(HTMLAttributes, {\n marker: '• ',\n class: listItem,\n }),\n ['div', { role: 'none' }, 0],\n ],\n }),\n // https://github.com/ueberdosis/tiptap/tree/main/packages/extension-collaboration\n ...(model && typeof model.content !== 'string' ? [Collaboration.configure({ fragment: model.content })] : []),\n ...(model?.provider\n ? [\n CollaborationCursor.configure({\n provider: model.provider,\n user: model.peer && {\n name: model.peer.name ?? generateName(model.peer.id),\n color: cursorColor.color,\n },\n }),\n ]\n : []),\n Placeholder.configure({\n placeholder,\n emptyEditorClass: 'before:content-[attr(data-placeholder)] before:absolute opacity-50 cursor-text',\n }),\n ],\n [model?.id],\n );\n\n return useNaturalEditor(\n {\n extensions,\n editorProps: {\n attributes: {\n class: mx('focus:outline-none focus-visible:outline-none', slots.editor?.className),\n spellcheck: slots.editor?.spellCheck === false ? 'false' : 'true',\n tabindex: slots.editor?.tabIndex ? String(slots.editor?.tabIndex) : '0',\n },\n },\n },\n [extensions],\n );\n};\n\nexport type RichTextEditorProps = UseEditorOptions & {\n slots?: EditorSlots;\n};\n\n/**\n * @deprecated\n */\n// TODO(burdon): Currently broken.\nexport const RichTextEditor = forwardRef<Editor | null, RichTextEditorProps>((props, ref) => {\n const editor = useEditor(props);\n useImperativeHandle<Editor | null, Editor | null>(ref, () => editor, [editor]);\n\n // Reference:\n // https://tiptap.dev/installation/react\n // https://github.com/ueberdosis/tiptap\n // https://tiptap.dev/guide/output/#option-3-yjs\n return <EditorContent {...props.slots?.root} editor={editor} />;\n});\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport { type StyleSpec } from 'style-mod';\nexport { tags } from '@lezer/highlight';\n\nexport * from './TextEditor';\n\nexport * from './extensions';\nexport * from './theme';\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { closeBrackets } from '@codemirror/autocomplete';\nimport { bracketMatching, defaultHighlightStyle, syntaxHighlighting } from '@codemirror/language';\nimport { EditorState, type Extension } from '@codemirror/state';\nimport { oneDarkHighlightStyle } from '@codemirror/theme-one-dark';\nimport { EditorView, placeholder } from '@codemirror/view';\nimport React, {\n type KeyboardEvent,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useState,\n useCallback,\n type HTMLAttributes,\n} from 'react';\nimport { type StyleSpec } from 'style-mod';\nimport { yCollab } from 'y-codemirror.next';\n\nimport { useThemeContext } from '@dxos/react-ui';\nimport { YText } from '@dxos/text-model';\n\nimport { defaultStyles } from './theme';\nimport { type EditorModel, type EditorSlots } from '../../model';\n\nexport type CursorInfo = {\n from: number;\n to: number;\n line: number;\n lines: number;\n after?: string;\n};\n\nexport type TextEditorRef = {\n editor: HTMLDivElement | null;\n state?: EditorState;\n view?: EditorView;\n};\n\nexport type TextEditorProps = {\n model?: EditorModel;\n extensions?: Extension[];\n theme?: {\n [selector: string]: StyleSpec;\n };\n slots?: EditorSlots;\n onKeyDown?: (event: KeyboardEvent, info: CursorInfo) => void;\n} & Pick<HTMLAttributes<HTMLDivElement>, 'onBlur' | 'onFocus'>;\n\n/**\n * Simple text editor.\n */\nexport const TextEditor = forwardRef<TextEditorRef, TextEditorProps>(\n ({ model, extensions = [], theme = defaultStyles, slots = {}, onKeyDown, ...props }, forwardedRef) => {\n const { id, content } = model ?? {};\n const { themeMode } = useThemeContext();\n\n const [parent, setParent] = useState<HTMLDivElement | null>(null);\n const [state, setState] = useState<EditorState>();\n const [view, setView] = useState<EditorView>();\n\n // TODO(burdon): The ref may be instantiated before the view is created.\n useImperativeHandle(\n forwardedRef,\n () => {\n return {\n editor: parent,\n state,\n view,\n };\n },\n [view],\n );\n\n useEffect(() => {\n if (!parent) {\n return;\n }\n\n view?.destroy();\n\n const state = EditorState.create({\n doc: content?.toString(),\n extensions: [\n bracketMatching(),\n closeBrackets(),\n placeholder(slots.editor?.placeholder ?? ''),\n EditorView.lineWrapping,\n\n // Themes.\n EditorView.theme(theme),\n ...(themeMode === 'dark'\n ? [syntaxHighlighting(oneDarkHighlightStyle)]\n : [syntaxHighlighting(defaultHighlightStyle)]),\n\n // Replication.\n // TODO(burdon): Move to default extensions.\n ...(content instanceof YText ? [yCollab(content, undefined)] : []),\n\n // Custom.\n ...extensions,\n ],\n });\n\n setState(state);\n setView(new EditorView({ state, parent }));\n\n return () => {\n view?.destroy();\n setView(undefined);\n setState(undefined);\n };\n }, [parent, content, themeMode]);\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (view) {\n const { head, from, to } = view.state.selection.ranges[0];\n const { number } = view.state.doc.lineAt(head);\n const after = view.state.sliceDoc(from);\n onKeyDown?.(event, { from, to, line: number, lines: view.state.doc.lines, after });\n }\n },\n [view],\n );\n\n return <div key={id} ref={setParent} {...slots.root} onKeyDown={handleKeyDown} {...props} />;\n },\n);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport get from 'lodash.get';\nimport { type StyleSpec } from 'style-mod';\n\nimport { tailwindConfig, type TailwindConfig } from '@dxos/react-ui-theme';\n\nconst tokens: TailwindConfig['theme'] = tailwindConfig({}).theme;\n\n/**\n * Minimal styles.\n * https://codemirror.net/examples/styling\n */\n// TODO(burdon): If given a \"theme\" suffix, `__docgen` properties are added to the object.\nexport const defaultStyles: {\n [selector: string]: StyleSpec;\n} = {\n '&.cm-focused': {\n outline: 'none',\n },\n '.cm-scroller': {\n fontFamily: get(tokens, 'fontFamily.body', []).join(','),\n overflow: 'visible',\n },\n '.cm-tooltip': {\n backgroundColor: 'transparent',\n border: 'none',\n },\n '.cm-link': {\n color: get(tokens, 'extend.colors.primary.500'),\n textDecoration: 'underline',\n },\n};\n", "//\n// Copyright 2023 DXOS.org\n// Copyright CodeMirror\n//\n\nimport { syntaxTree } from '@codemirror/language';\nimport { type EditorState, type RangeSet, RangeSetBuilder, StateField, type Transaction } from '@codemirror/state';\nimport { Decoration, EditorView, WidgetType } from '@codemirror/view';\n\n// Adapted from:\n// https://codemirror.net/try/?c=aW1wb3J0IHsgYmFzaWNTZXR1cCwgRWRpdG9yVmlldyB9IGZyb20gImNvZGVtaXJyb3IiCmltcG9ydCB7IG1hcmtkb3duIH0gZnJvbSAiQGNvZGVtaXJyb3IvbGFuZy1tYXJrZG93biIKaW1wb3J0IHsgc3ludGF4VHJlZSB9IGZyb20gIkBjb2RlbWlycm9yL2xhbmd1YWdlIjsKaW1wb3J0IHsgRWRpdG9yU3RhdGUsIFJhbmdlU2V0QnVpbGRlciwgU3RhdGVGaWVsZCB9IGZyb20gIkBjb2RlbWlycm9yL3N0YXRlIjsKaW1wb3J0IHsgRG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NbMV0uZnJvbSkgOiAiIgoKICAgICAgICAgIGxldCB1cmxOb2RlID0gbm9kZS5ub2RlLmdldENoaWxkKCJVUkwiKTsKICAgICAgICAgIGxldCB1cmwgPSB1cmxOb2RlID8gdHIuc3RhdGUuc2xpY2VEb2ModXJsTm9kZS5mcm9tLCB1cmxOb2RlLnRvKSA6ICIiCiAgICAgICAgICBidWlsZGVyLmFkZChub2RlLmZyb20sIG5vZGUudG8sIERlY29yYXRpb24ucmVwbGFjZSh7CiAgICAgICAgICAgIHdpZGdldDogbmV3IExpbmsodGV4dCwgdXJsKSwKICAgICAgICAgIH0pLAogICAgICAgICAgICAgICAgICAgICApOwogICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfSwKICAgIH0pOwogICAgcmV0dXJuIGJ1aWxkZXIuZmluaXNoKCk7CiAgfSwKICBwcm92aWRlOiAoZikgPT4gRWRpdG9yVmlldy5kZWNvcmF0aW9ucy5mcm9tKGYpLAp9KTsKCmxldCB2aWV3ID0gbmV3IEVkaXRvclZpZXcoewogIGRvYzogIiMgSGVsbG8gV29ybGRcblxuW1Rlc3RdKGh0dHBzOi8vZXhhbXBsZS5jb20pXG5cblxuIiwKICBleHRlbnNpb25zOiBbZGVjb3JhdGlvbnNGaWVsZCwgbWFya2Rvd24oKV0sCiAgcGFyZW50OiBkb2N1bWVudC5ib2R5LAp9KTsKCnZpZXcuZm9jdXMoKTs=\n// https://discuss.codemirror.net/t/link-widget-is-clicked-only-if-editor-is-out-of-focus/7433\n\n// TODO(burdon): Adapt to make all markdown editable?\n\n// TODO(burdon): Research overlays.\n// https://stackoverflow.com/questions/26933344/codemirror-detect-and-create-links-inside-editor\n// https://codemirror.net/5/doc/manual.html#addOverlay\n// https://codemirror.net/5/demo/simplemode.html\n// https://codemirror.net/5/demo/search.html (Search dialog).\n\nclass Link extends WidgetType {\n constructor(private readonly _anchor: number, private readonly _text: string, private readonly _url?: string) {\n super();\n }\n\n override eq(other: any) {\n return this._text === other.text && this._url === other.url;\n }\n\n toDOM(view: EditorView) {\n const link = document.createElement('a');\n link.setAttribute('class', 'cm-link');\n link.textContent = this._text;\n if (this._url) {\n link.setAttribute('target', '_blank');\n link.href = this._url;\n } else {\n link.onclick = () => {\n view.dispatch({\n selection: {\n anchor: this._anchor,\n },\n });\n };\n }\n\n return link;\n }\n}\n\ntype HyperlinkDecorationConfig = {\n link?: boolean;\n};\n\n/**\n * Creates a state field to replace AST elements with a hyperlink widget.\n * https://codemirror.net/docs/ref/#state.StateField\n */\nexport const hyperlinkDecoration = ({ link }: HyperlinkDecorationConfig = {}) => {\n return StateField.define<RangeSet<any>>({\n create: (state) => update(state, link),\n update: (_: RangeSet<any>, tr: Transaction) => update(tr.state, link),\n provide: (field) => EditorView.decorations.from(field),\n });\n};\n\nconst update = (state: EditorState, link?: boolean) => {\n const builder = new RangeSetBuilder();\n const cursor = state.selection.main.head;\n syntaxTree(state).iterate({\n enter: (node) => {\n // Check if cursor is inside text.\n if (cursor < node.from || cursor > node.to) {\n if (node.name === 'Link') {\n const marks = node.node.getChildren('LinkMark');\n const text = marks.length >= 2 ? state.sliceDoc(marks[0].to, marks[1].from) : '';\n\n const urlNode = node.node.getChild('URL');\n const url = urlNode ? state.sliceDoc(urlNode.from, urlNode.to) : '';\n\n builder.add(\n node.from,\n node.to,\n Decoration.replace({\n widget: new Link(node.from, text, link ? url : undefined),\n }),\n );\n\n return false;\n }\n }\n\n return true;\n },\n });\n\n return builder.finish();\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { hoverTooltip } from '@codemirror/view';\n\nimport { tooltipContent } from '@dxos/react-ui-theme';\n\nconst markdownLinkRegexp = /\\[([^\\]]+)]\\(([^)]+)\\)/;\n\nexport type OnHyperlinkHover = (el: Element, url: string) => void;\n\n/**\n * https://codemirror.net/examples/tooltip\n * https://codemirror.net/docs/ref/#view.hoverTooltip\n * https://github.com/codemirror/view/blob/main/src/tooltip.ts\n */\n// TODO(burdon): Create config object.\nexport const createHyperlinkTooltip = (onHover: OnHyperlinkHover, regexp = markdownLinkRegexp) =>\n hoverTooltip((view, pos) => {\n const { from, text } = view.state.doc.lineAt(pos);\n const p = pos - from;\n\n let idx = 0;\n let match;\n do {\n match = text.substring(idx).match(regexp);\n if (!match) {\n match = undefined;\n break;\n }\n\n idx = text.indexOf(match[0]);\n if (p >= idx && p < idx + match[0].length) {\n break;\n }\n\n idx += match[0].length;\n } while (true);\n\n if (!match) {\n return null;\n }\n\n const [, , url] = match ?? [];\n\n return {\n pos: idx + from,\n end: idx + from + match[0].length,\n above: true,\n create: () => {\n const el = document.createElement('a');\n el.innerText = '_'; // Required so doesn't collapse.\n el.className = tooltipContent({}, 'mb-2 p-1');\n el.setAttribute('target', '_blank');\n el.setAttribute('href', url);\n onHover(el, url);\n return { dom: el };\n },\n };\n });\n", "//\n// Copyright 2023 DXOS.org\n// Adapted from: https://github.com/uiwjs/react-codemirror/blob/master/extensions/hyper-link/src/index.ts\n//\n\nimport { type Extension } from '@codemirror/state';\nimport {\n Decoration,\n type DecorationSet,\n EditorView,\n MatchDecorator,\n ViewPlugin,\n type ViewUpdate,\n} from '@codemirror/view';\n\n// Notes: Can't edit widget content (or cursor nav through them).\n// - https://discuss.codemirror.net/t/focusing-inputs-within-widgets/5178/7\n// Widgets intentionally always get set to contenteditable=false,\n// or they would become part of CodeMirror’s editable content element.\n// You should be able to introduce new contenteditable=true child elements inside of them.\n\nconst markdownLinkRegexp = /\\[([^\\]]+)]\\(([^)]+)\\)(!?)/gi;\n\n/**\n * Custom link decorator.\n * NOTE: The default markdown extension formats links by default.\n * @deprecated\n */\nconst linkDecorator = () =>\n new MatchDecorator({\n regexp: markdownLinkRegexp,\n decorate: (add, from, to, match, view) => {\n const [_, label, url] = match;\n const p0 = {\n start: from,\n end: from + 1,\n };\n\n const p1 = {\n start: from + 1,\n end: from + 1 + label.length,\n };\n\n const p2 = {\n start: p1.end,\n end: p1.end + 1,\n };\n\n const p3 = {\n start: p1.end + 1,\n end: p1.end + 1 + url.length + 2,\n };\n\n add(\n p0.start,\n p0.end,\n Decoration.mark({ class: 'cm-hyperlink-bracket', _attributes: { style: 'display: none' } }),\n );\n add(p1.start, p1.end, Decoration.mark({ class: 'cm-hyperlink-label' }));\n add(\n p2.start,\n p2.end,\n Decoration.mark({ class: 'cm-hyperlink-bracket', _attributes: { style: 'display: none' } }),\n );\n add(p3.start, p3.end, Decoration.mark({ class: 'cm-hyperlink-url', _attributes: { style: 'display: none' } }));\n },\n });\n\nexport function hyperLinkExtension() {\n return ViewPlugin.fromClass(\n class HyperLinkView {\n readonly decorator: MatchDecorator;\n decorations: DecorationSet;\n constructor(view: EditorView) {\n this.decorator = linkDecorator();\n this.decorations = this.decorator.createDeco(view);\n }\n\n update(update: ViewUpdate) {\n if (update.docChanged || update.viewportChanged) {\n this.decorations = this.decorator.updateDeco(update, this.decorations);\n }\n }\n },\n {\n decorations: (view) => view.decorations,\n eventHandlers: {\n // TODO(burdon): CLick to expand link.\n // https://discuss.codemirror.net/t/decorator-iteration-on-click-event/4226/2\n mousedown: function (event, view) {\n const pos = view.posAtDOM(event.target as Node);\n if (pos !== 0) {\n console.log(this);\n }\n },\n // TODO(burdon): Hide when cursor moves away.\n keydown: (event, view) => {\n view.update([]);\n },\n },\n },\n );\n}\n\nexport const hyperlinkStyle = EditorView.baseTheme({\n '.cm-hyperlink-label': {\n cursor: 'pointer',\n textDecoration: 'underline',\n },\n '.cm-hyperlink-bracket': {\n opacity: 0.2,\n },\n '.cm-hyperlink-url': {\n opacity: 0.5,\n fontFamily: 'monospace',\n },\n});\n\nexport const hyperlinkWidget: Extension = [hyperLinkExtension(), hyperlinkStyle];\n", "//\n// Copyright 2022 DXOS.org\n//\n\nexport * from './components';\nexport * from './model';\n\nexport { TextKind } from '@dxos/protocols/proto/dxos/echo/model/text';\nexport { Doc, YText, YXmlFragment } from '@dxos/text-model';\n"],
5
- "mappings": ";AAIA,OAAOA,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L,OAAOK,GAAGJ,KAAKK,YAAWC,KAAK;MAAEC,OAAO;MAAoBC,aAAa;QAAEC,OAAO;MAAgB;IAAE,CAAA,CAAA;EAC7G;AACF,CAAA;AAEK,SAASC,qBAAAA;AACd,SAAOC,WAAWC,UAChB,MAAMC,cAAAA;IAGJC,YAAYpB,MAAkB;AAC5B,WAAKqB,YAAY7B,cAAAA;AACjB,WAAK8B,cAAc,KAAKD,UAAUE,WAAWvB,IAAAA;IAC/C;IAEAwB,OAAOA,SAAoB;AACzB,UAAIA,QAAOC,cAAcD,QAAOE,iBAAiB;AAC/C,aAAKJ,cAAc,KAAKD,UAAUM,WAAWH,SAAQ,KAAKF,WAAW;MACvE;IACF;EACF,GACA;IACEA,aAAa,CAACtB,SAASA,KAAKsB;IAC5BM,eAAe;;;MAGbC,WAAW,SAAUC,OAAO9B,MAAI;AAC9B,cAAM+B,MAAM/B,KAAKgC,SAASF,MAAMG,MAAM;AACtC,YAAIF,QAAQ,GAAG;AACbG,kBAAQC,IAAI,IAAI;QAClB;MACF;;MAEAC,SAAS,CAACN,OAAO9B,SAAAA;AACfA,aAAKwB,OAAO,CAAA,CAAE;MAChB;IACF;EACF,CAAA;AAEJ;AAEO,IAAMa,iBAAiBC,YAAWC,UAAU;EACjD,uBAAuB;IACrBC,QAAQ;IACRC,gBAAgB;EAClB;EACA,yBAAyB;IACvBC,SAAS;EACX;EACA,qBAAqB;IACnBA,SAAS;IACTC,YAAY;EACd;AACF,CAAA;AAEO,IAAMC,kBAA6B;EAAC5B,mBAAAA;EAAsBqB;;;;AC/GjE,SAASQ,gBAAgB;AACzB,SAASC,KAAKC,SAAAA,QAAOC,gBAAAA,qBAAoB;",
6
- "names": ["React", "forwardRef", "memo", "YXmlFragment", "useMemo", "random", "cursorColors", "color", "light", "cursorColor", "uint32", "length", "decoding", "encoding", "Observable", "awarenessProtocol", "log", "messageAwareness", "messageQueryAwareness", "SpaceAwarenessProvider", "constructor", "space", "doc", "channel", "awareness", "_space", "_awareness", "Awareness", "_channel", "_clientId", "clientID", "on", "_handleAwarenessUpdate", "bind", "listen", "_handleSpaceMessage", "window", "addEventListener", "_handleBeforeUnload", "process", "encoderAwarenessQuery", "createEncoder", "writeVarUint", "postMessage", "toUint8Array", "encoderAwarenessState", "writeVarUint8Array", "encodeAwarenessUpdate", "added", "updated", "removed", "origin", "changedClients", "concat", "encoderAwareness", "payload", "data", "Uint8Array", "Array", "from", "Object", "values", "encoder", "_readMessage", "message", "decoder", "createDecoder", "messageType", "readVarUint", "sendReply", "applyAwarenessUpdate", "readVarUint8Array", "getStates", "keys", "console", "error", "removeAwarenessStates", "useTextModel", "identity", "space", "text", "provider", "useMemo", "doc", "undefined", "SpaceAwarenessProvider", "channel", "id", "content", "guid", "peer", "identityKey", "toHex", "name", "profile", "displayName", "autocompletion", "completionKeymap", "closeBrackets", "closeBracketsKeymap", "defaultKeymap", "history", "historyKeymap", "indentWithTab", "markdown", "markdownLanguage", "bracketMatching", "defaultHighlightStyle", "foldKeymap", "indentOnInput", "syntaxHighlighting", "languages", "lintKeymap", "searchKeymap", "highlightSelectionMatches", "EditorState", "StateField", "oneDarkHighlightStyle", "keymap", "crosshairCursor", "drawSelection", "dropCursor", "highlightActiveLine", "highlightActiveLineGutter", "highlightSpecialChars", "placeholder", "rectangularSelection", "EditorView", "useFocusableGroup", "vim", "React", "forwardRef", "useEffect", "useImperativeHandle", "useState", "useMemo", "useCallback", "yCollab", "generateName", "useThemeContext", "getColorForValue", "YText", "styleTags", "Tag", "markdownTags", "headingMark", "Tag", "define", "quoteMark", "listMark", "linkMark", "emphasisMark", "codeMark", "codeText", "inlineCode", "url", "linkReference", "linkLabel", "markdownTagsExtension", "props", "styleTags", "HeaderMark", "QuoteMark", "ListMark", "LinkMark", "EmphasisMark", "CodeMark", "CodeText", "InlineCode", "URL", "LinkReference", "LinkLabel", "markdownLanguage", "HighlightStyle", "tags", "get", "mx", "heading", "blockquote", "unorderedList", "orderedList", "listItem", "codeBlock", "horizontalRule", "paragraph", "bold", "code", "codeWithoutMarks", "mx", "code", "italic", "strikethrough", "mark", "tailwindConfig", "tokens", "tailwindConfig", "theme", "malibu", "cursor", "monospace", "get", "tokens", "join", "markdownTheme", "backgroundColor", "border", "outline", "paddingInline", "minBlockSize", "lineHeight", "background", "caretColor", "borderLeftColor", "fontFamily", "overflow", "padding", "marginBlockStart", "paddingBlockStart", "paddingBlockEnd", "mixBlendMode", "display", "insetBlockStart", "blockSize", "verticalAlign", "margin", "color", "textDecorationLine", "textDecorationThickness", "textUnderlineOffset", "borderRadius", "Object", "keys", "reduce", "acc", "fontSize", "height", "markdownHighlightStyle", "HighlightStyle", "define", "tag", "tags", "keyword", "name", "deleted", "character", "propertyName", "macroName", "constant", "standard", "definition", "separator", "typeName", "className", "number", "changed", "annotation", "modifier", "self", "namespace", "operator", "operatorKeyword", "escape", "regexp", "special", "string", "meta", "comment", "atom", "bool", "variableName", "processingInstruction", "inserted", "invalid", "link", "url", "textDecoration", "function", "labelName", "malibu", "markdownTags", "codeMark", "emphasisMark", "headingMark", "linkLabel", "linkReference", "listMark", "quoteMark", "class", "mark", "codeText", "inlineCode", "emphasis", "italic", "heading1", "heading", "heading2", "heading3", "heading4", "heading5", "heading6", "strikethrough", "strong", "bold", "scope", "markdownLanguage", "all", "EditorModes", "MarkdownEditor", "forwardRef", "model", "slots", "editorMode", "extensions", "onChange", "forwardedRef", "id", "content", "provider", "peer", "themeMode", "useThemeContext", "tabsterDOMAttribute", "useFocusableGroup", "tabBehavior", "parent", "setParent", "useState", "state", "setState", "view", "setView", "useImperativeHandle", "editor", "listenChangesExtension", "useMemo", "StateField", "define", "create", "update", "_value", "transaction", "docChanged", "newDoc", "useEffect", "awareness", "setLocalStateField", "name", "generateName", "color", "getColorForValue", "value", "type", "colorLight", "EditorState", "doc", "toString", "autocompletion", "bracketMatching", "closeBrackets", "crosshairCursor", "dropCursor", "drawSelection", "highlightActiveLine", "highlightActiveLineGutter", "highlightSelectionMatches", "highlightSpecialChars", "history", "indentOnInput", "placeholder", "rectangularSelection", "syntaxHighlighting", "defaultHighlightStyle", "fallback", "allowMultipleSelections", "of", "EditorView", "lineWrapping", "keymap", "closeBracketsKeymap", "completionKeymap", "defaultKeymap", "foldKeymap", "historyKeymap", "lintKeymap", "searchKeymap", "indentWithTab", "markdown", "base", "markdownLanguage", "codeLanguages", "languages", "markdownTagsExtension", "theme", "markdownTheme", "oneDarkHighlightStyle", "markdownHighlightStyle", "vim", "YText", "yCollab", "destroy", "undefined", "handleKeyUp", "useCallback", "event", "key", "altKey", "shiftKey", "metaKey", "ctrlKey", "contentDOM", "focus", "div", "tabIndex", "ref", "root", "onKeyUp", "mergeAttributes", "Collaboration", "CollaborationCursor", "Heading", "ListItem", "Placeholder", "EditorContent", "useEditor", "useNaturalEditor", "StarterKit", "React", "forwardRef", "useImperativeHandle", "useMemo", "generateName", "mx", "useEditor", "model", "placeholder", "slots", "extensions", "useMemo", "StarterKit", "configure", "history", "blockquote", "HTMLAttributes", "class", "bulletList", "unorderedList", "codeBlock", "heading", "horizontalRule", "listItem", "orderedList", "paragraph", "bold", "code", "codeWithoutMarks", "italic", "strike", "strikethrough", "Heading", "extend", "renderHTML", "node", "hasLevel", "options", "levels", "includes", "attrs", "level", "mergeAttributes", "ListItem", "marker", "role", "content", "Collaboration", "fragment", "provider", "CollaborationCursor", "user", "peer", "name", "generateName", "id", "color", "cursorColor", "Placeholder", "emptyEditorClass", "useNaturalEditor", "editorProps", "attributes", "mx", "editor", "className", "spellcheck", "spellCheck", "tabindex", "tabIndex", "String", "RichTextEditor", "forwardRef", "props", "ref", "useImperativeHandle", "React", "EditorContent", "root", "Editor", "memo", "forwardRef", "slots", "params", "forwardedRef", "model", "useTextModel", "content", "YXmlFragment", "React", "RichTextEditor", "ref", "MarkdownEditor", "tags", "closeBrackets", "bracketMatching", "defaultHighlightStyle", "syntaxHighlighting", "EditorState", "oneDarkHighlightStyle", "EditorView", "placeholder", "React", "forwardRef", "useEffect", "useImperativeHandle", "useState", "useCallback", "yCollab", "useThemeContext", "YText", "get", "tailwindConfig", "tokens", "tailwindConfig", "theme", "defaultStyles", "outline", "fontFamily", "get", "join", "overflow", "backgroundColor", "border", "color", "textDecoration", "TextEditor", "forwardRef", "model", "extensions", "theme", "defaultStyles", "slots", "onKeyDown", "props", "forwardedRef", "id", "content", "themeMode", "useThemeContext", "parent", "setParent", "useState", "state", "setState", "view", "setView", "useImperativeHandle", "editor", "useEffect", "destroy", "EditorState", "create", "doc", "toString", "bracketMatching", "closeBrackets", "placeholder", "EditorView", "lineWrapping", "syntaxHighlighting", "oneDarkHighlightStyle", "defaultHighlightStyle", "YText", "yCollab", "undefined", "handleKeyDown", "useCallback", "event", "head", "from", "to", "selection", "ranges", "number", "lineAt", "after", "sliceDoc", "line", "lines", "React", "div", "key", "ref", "root", "syntaxTree", "RangeSetBuilder", "StateField", "Decoration", "EditorView", "WidgetType", "Link", "WidgetType", "constructor", "_anchor", "_text", "_url", "eq", "other", "text", "url", "toDOM", "view", "link", "document", "createElement", "setAttribute", "textContent", "href", "onclick", "dispatch", "selection", "anchor", "hyperlinkDecoration", "StateField", "define", "create", "state", "update", "_", "tr", "provide", "field", "EditorView", "decorations", "from", "builder", "RangeSetBuilder", "cursor", "main", "head", "syntaxTree", "iterate", "enter", "node", "to", "name", "marks", "getChildren", "length", "sliceDoc", "urlNode", "getChild", "add", "Decoration", "replace", "widget", "undefined", "finish", "hoverTooltip", "tooltipContent", "markdownLinkRegexp", "createHyperlinkTooltip", "onHover", "regexp", "hoverTooltip", "view", "pos", "from", "text", "state", "doc", "lineAt", "p", "idx", "match", "substring", "undefined", "indexOf", "length", "url", "end", "above", "create", "el", "document", "createElement", "innerText", "className", "tooltipContent", "setAttribute", "dom", "Decoration", "EditorView", "MatchDecorator", "ViewPlugin", "markdownLinkRegexp", "linkDecorator", "MatchDecorator", "regexp", "decorate", "add", "from", "to", "match", "view", "_", "label", "url", "p0", "start", "end", "p1", "length", "p2", "p3", "Decoration", "mark", "class", "_attributes", "style", "hyperLinkExtension", "ViewPlugin", "fromClass", "HyperLinkView", "constructor", "decorator", "decorations", "createDeco", "update", "docChanged", "viewportChanged", "updateDeco", "eventHandlers", "mousedown", "event", "pos", "posAtDOM", "target", "console", "log", "keydown", "hyperlinkStyle", "EditorView", "baseTheme", "cursor", "textDecoration", "opacity", "fontFamily", "hyperlinkWidget", "TextKind", "Doc", "YText", "YXmlFragment"]
3
+ "sources": ["../../../src/index.ts", "../../../src/components/TextEditor/index.ts", "../../../src/components/TextEditor/extensions/basic/bundle.ts", "../../../src/components/TextEditor/extensions/basic/theme.ts", "../../../src/styles/markdown.ts", "../../../src/styles/tokens.ts", "../../../src/components/TextEditor/extensions/change.ts", "../../../src/components/TextEditor/extensions/hyperlink/hyperlinkDecoration.ts", "../../../src/components/TextEditor/extensions/hyperlink/hyperlinkTooltip.tsx", "../../../src/components/TextEditor/extensions/hyperlink/hyperlinkWidget.tsx", "../../../src/components/TextEditor/extensions/markdown/bundle.ts", "../../../src/components/TextEditor/extensions/markdown/tags.ts", "../../../src/components/TextEditor/extensions/markdown/theme.ts", "../../../src/components/TextEditor/TextEditor.tsx", "../../../src/hooks/useCollaboration.ts", "../../../src/automerge/automerge-plugin/plugin.ts", "../../../src/automerge/automerge-plugin/PatchSemaphore.ts", "../../../src/automerge/automerge-plugin/amToCodemirror.ts", "../../../src/automerge/automerge-plugin/codeMirrorToAm.ts", "../../../src/hooks/useTextModel.ts", "../../../src/hooks/yjs/cursors.ts", "../../../src/hooks/yjs/space-provider.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nexport { TextKind } from '@dxos/protocols/proto/dxos/echo/model/text';\nexport { Doc, YText, YXmlFragment } from '@dxos/text-model';\n\nexport * from './components';\nexport * from './hooks';\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport { tags } from '@lezer/highlight';\n\nexport * from './extensions';\nexport * from './TextEditor';\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { closeBrackets } from '@codemirror/autocomplete';\nimport { bracketMatching, defaultHighlightStyle, syntaxHighlighting } from '@codemirror/language';\nimport { type Extension } from '@codemirror/state';\nimport { oneDarkHighlightStyle } from '@codemirror/theme-one-dark';\nimport { EditorView, placeholder } from '@codemirror/view';\n\nimport type { ThemeMode } from '@dxos/react-ui';\n\nexport type BasicBundleOptions = {\n themeMode?: ThemeMode;\n placeholder?: string;\n};\n\nexport const basicBundle = ({ themeMode, placeholder: _placeholder }: BasicBundleOptions): Extension[] =>\n [\n bracketMatching(),\n closeBrackets(),\n _placeholder && placeholder(_placeholder),\n\n EditorView.lineWrapping,\n\n // TODO(burdon): Is this required?\n themeMode === 'dark' ? syntaxHighlighting(oneDarkHighlightStyle) : syntaxHighlighting(defaultHighlightStyle),\n ].filter(Boolean) as Extension[];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport get from 'lodash.get';\nimport { type StyleSpec } from 'style-mod';\n\nimport { tokens } from '../../../../styles';\n\n/**\n * Minimal styles.\n * NOTE: The '&' prefix denotes the CM editor root.\n * https://codemirror.net/examples/styling\n */\n// TODO(burdon): Remove?\nexport const basicTheme: {\n [selector: string]: StyleSpec;\n} = {\n '&.cm-focused': {\n outline: 'none',\n },\n '& .cm-line': {\n paddingInline: 0,\n lineHeight: 1.6,\n minBlockSize: '1.6em',\n },\n '& .cm-line *': {\n lineHeight: 1.6,\n },\n '& .cm-scroller': {\n fontFamily: get(tokens, 'fontFamily.body', []).join(','),\n overflow: 'visible',\n },\n '& .cm-content': {\n padding: 0,\n caretColor: 'black',\n },\n '.dark & .cm-content': {\n caretColor: 'white',\n },\n '& .cm-tooltip': {\n backgroundColor: 'transparent',\n border: 'none',\n },\n '& .cm-link': {\n color: get(tokens, 'extend.colors.primary.500'),\n textDecoration: 'underline',\n },\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { mx } from '@dxos/react-ui-theme';\n\nexport type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;\n\nexport const heading: Record<HeadingLevel, string> = {\n 1: 'mbs-4 mbe-2 text-4xl font-semibold text-inherit no-underline',\n 2: 'mbs-4 mbe-2 text-3xl font-bold text-inherit no-underline',\n 3: 'mbs-4 mbe-2 text-2xl font-bold text-inherit no-underline',\n 4: 'mbs-4 mbe-2 text-xl font-extrabold text-inherit no-underline',\n 5: 'mbs-4 mbe-2 text-lg font-extrabold text-inherit no-underline',\n 6: 'mbs-4 mbe-2 font-black text-inherit no-underline',\n};\n\nexport const blockquote = 'mlb-2 border-is-4 border-neutral-500/50 pis-5';\n\n// TODO(thure): Tailwind was not seeing `[&>li:before]:content-[\"•\"]` as a utility class, but it would work if instead of `\"•\"` it was `\"X\"`… why?\nexport const unorderedList =\n 'mlb-2 grid grid-cols-[min-content_1fr] [&>li:before]:content-[attr(marker)] [&>li:before]:mlb-1 [&>li:before]:mie-2';\nexport const orderedList =\n 'mlb-2 grid grid-cols-[min-content_1fr] [&>li:before]:content-[counters(section,_\".\")_\"._\"] [counter-reset:section] [&>li:before]:mlb-1';\n\nexport const listItem = 'contents before:[counter-increment:section]';\n\nexport const codeBlock = 'mlb-2 font-mono bg-neutral-500/10 p-3 rounded';\n\nexport const horizontalRule = 'mlb-4 border-neutral-500/50';\n\nexport const paragraph = 'mlb-1';\n\nexport const bold = 'font-bold';\n\nexport const code = 'font-mono bg-neutral-500/10 rounded pli-0.5 plb-0.5 -mlb-0.5';\n\nexport const placeholder = 'font-mono';\n\nexport const codeWithoutMarks = mx(code, 'pli-1.5 mli-0.5');\n\nexport const italic = 'italic';\n\nexport const strikethrough = 'line-through';\n\nexport const mark = '!font-normal !no-underline !text-inherit opacity-40';\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type { StyleSpec } from 'style-mod';\n\nimport { tailwindConfig, type TailwindConfig } from '@dxos/react-ui-theme';\n\nexport type ThemeStyles = {\n [selector: string]: StyleSpec;\n};\n\n// TODO(thure): Why export the whole theme? Can this be done differently?\nexport const tokens: TailwindConfig['theme'] = tailwindConfig({}).theme;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { StateField } from '@codemirror/state';\n\n/**\n * Based on https://github.com/codemirror/dev/issues/44#issuecomment-789093799\n * @param onChange\n */\n// TODO(burdon): Name?\nexport const onChangeExtension = (onChange: (text: string) => void) =>\n StateField.define({\n create: () => null,\n update: (_value, transaction) => {\n if (transaction.docChanged && onChange) {\n onChange(transaction.newDoc.toString());\n }\n\n return null;\n },\n });\n", "//\n// Copyright 2023 DXOS.org\n// Copyright CodeMirror\n//\n\nimport { syntaxTree } from '@codemirror/language';\nimport { type EditorState, type RangeSet, RangeSetBuilder, StateField, type Transaction } from '@codemirror/state';\nimport { Decoration, EditorView, WidgetType } from '@codemirror/view';\n\n// Adapted from:\n// https://codemirror.net/try/?c=aW1wb3J0IHsgYmFzaWNTZXR1cCwgRWRpdG9yVmlldyB9IGZyb20gImNvZGVtaXJyb3IiCmltcG9ydCB7IG1hcmtkb3duIH0gZnJvbSAiQGNvZGVtaXJyb3IvbGFuZy1tYXJrZG93biIKaW1wb3J0IHsgc3ludGF4VHJlZSB9IGZyb20gIkBjb2RlbWlycm9yL2xhbmd1YWdlIjsKaW1wb3J0IHsgRWRpdG9yU3RhdGUsIFJhbmdlU2V0QnVpbGRlciwgU3RhdGVGaWVsZCB9IGZyb20gIkBjb2RlbWlycm9yL3N0YXRlIjsKaW1wb3J0IHsgRGVjb3JhdGlvbiwgV2lkZ2V0VHlwZSB9IGZyb20gIkBjb2RlbWlycm9yL3ZpZXciOwoKY2xhc3MgTGluayBleHRlbmRzIFdpZGdldFR5cGUgewogIGNvbnN0cnVjdG9yKHRleHQsIHVybCkgewogICAgc3VwZXIoKQogICAgdGhpcy50ZXh0ID0gdGV4dAogICAgdGhpcy51cmwgPSB1cmwKICB9CiAgZXEob3RoZXIpIHsgcmV0dXJuIHRoaXMudGV4dCA9PSBvdGhlci50ZXh0ICYmIHRoaXMudXJsID09IG90aGVyLnVybCB9CiAgdG9ET00oKSB7CiAgICBsZXQgbGluayA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImEiKQogICAgbGluay50ZXh0Q29udGVudCA9IHRoaXMudGV4dAogICAgbGluay5ocmVmID0gdGhpcy51cmwKICAgIHJldHVybiBsaW5rOwogIH0KfQoKbGV0IGRlY29yYXRpb25zRmllbGQgPSBTdGF0ZUZpZWxkLmRlZmluZSh7CiAgY3JlYXRlKCkgewogICAgcmV0dXJuIERlY29yYXRpb24ubm9uZTsKICB9LAogIHVwZGF0ZShfLCB0cikgewogICAgY29uc3QgYnVpbGRlciA9IG5ldyBSYW5nZVNldEJ1aWxkZXIoKTsKICAgIGxldCBjdXJzb3IgPSB0ci5zdGF0ZS5zZWxlY3Rpb24ubWFpbi5oZWFkOwogICAgc3ludGF4VHJlZSh0ci5zdGF0ZSkuaXRlcmF0ZSh7CiAgICAgIGVudGVyOiAobm9kZSkgPT4gewogICAgICAgIGlmICgoY3Vyc29yIDwgbm9kZS5mcm9tIHx8IGN1cnNvciA+IG5vZGUudG8pICYmIG5vZGUubmFtZSA9PSAiTGluayIpIHsKICAgICAgICAgIGxldCBtYXJrcyA9IG5vZGUubm9kZS5nZXRDaGlsZHJlbigiTGlua01hcmsiKTsKICAgICAgICAgIGxldCB0ZXh0ID0gbWFya3MubGVuZ3RoID49IDIgPyB0ci5zdGF0ZS5zbGljZURvYyhtYXJrc1swXS50bywgbWFya3NbMV0uZnJvbSkgOiAiIgoKICAgICAgICAgIGxldCB1cmxOb2RlID0gbm9kZS5ub2RlLmdldENoaWxkKCJVUkwiKTsKICAgICAgICAgIGxldCB1cmwgPSB1cmxOb2RlID8gdHIuc3RhdGUuc2xpY2VEb2ModXJsTm9kZS5mcm9tLCB1cmxOb2RlLnRvKSA6ICIiCiAgICAgICAgICBidWlsZGVyLmFkZChub2RlLmZyb20sIG5vZGUudG8sIERlY29yYXRpb24ucmVwbGFjZSh7CiAgICAgICAgICAgIHdpZGdldDogbmV3IExpbmsodGV4dCwgdXJsKSwKICAgICAgICAgIH0pLAogICAgICAgICAgICAgICAgICAgICApOwogICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfSwKICAgIH0pOwogICAgcmV0dXJuIGJ1aWxkZXIuZmluaXNoKCk7CiAgfSwKICBwcm92aWRlOiAoZikgPT4gRWRpdG9yVmlldy5kZWNvcmF0aW9ucy5mcm9tKGYpLAp9KTsKCmxldCB2aWV3ID0gbmV3IEVkaXRvclZpZXcoewogIGRvYzogIiMgSGVsbG8gV29ybGRcblxuW1Rlc3RdKGh0dHBzOi8vZXhhbXBsZS5jb20pXG5cblxuIiwKICBleHRlbnNpb25zOiBbZGVjb3JhdGlvbnNGaWVsZCwgbWFya2Rvd24oKV0sCiAgcGFyZW50OiBkb2N1bWVudC5ib2R5LAp9KTsKCnZpZXcuZm9jdXMoKTs=\n// https://discuss.codemirror.net/t/link-widget-is-clicked-only-if-editor-is-out-of-focus/7433\n\n// TODO(burdon): Adapt to make all markdown editable?\n\n// TODO(burdon): Research overlays.\n// https://stackoverflow.com/questions/26933344/codemirror-detect-and-create-links-inside-editor\n// https://codemirror.net/5/doc/manual.html#addOverlay\n// https://codemirror.net/5/demo/simplemode.html\n// https://codemirror.net/5/demo/search.html (Search dialog).\n\nclass Link extends WidgetType {\n constructor(private readonly _anchor: number, private readonly _text: string, private readonly _url?: string) {\n super();\n }\n\n override eq(other: any) {\n return this._text === other.text && this._url === other.url;\n }\n\n toDOM(view: EditorView) {\n const link = document.createElement('a');\n link.setAttribute('class', 'cm-link');\n link.textContent = this._text;\n if (this._url) {\n link.setAttribute('target', '_blank');\n link.href = this._url;\n } else {\n link.onclick = () => {\n view.dispatch({\n selection: {\n anchor: this._anchor,\n },\n });\n };\n }\n\n return link;\n }\n}\n\ntype HyperlinkDecorationConfig = {\n link?: boolean;\n};\n\n/**\n * Creates a state field to replace AST elements with a hyperlink widget.\n * https://codemirror.net/docs/ref/#state.StateField\n */\nexport const hyperlinkDecoration = ({ link }: HyperlinkDecorationConfig = {}) => {\n return StateField.define<RangeSet<any>>({\n create: (state) => update(state, link),\n update: (_: RangeSet<any>, tr: Transaction) => update(tr.state, link),\n provide: (field) => EditorView.decorations.from(field),\n });\n};\n\nconst update = (state: EditorState, link?: boolean) => {\n const builder = new RangeSetBuilder();\n const cursor = state.selection.main.head;\n syntaxTree(state).iterate({\n enter: (node) => {\n // Check if cursor is inside text.\n if (cursor < node.from || cursor > node.to) {\n if (node.name === 'Link') {\n const marks = node.node.getChildren('LinkMark');\n const text = marks.length >= 2 ? state.sliceDoc(marks[0].to, marks[1].from) : '';\n\n const urlNode = node.node.getChild('URL');\n const url = urlNode ? state.sliceDoc(urlNode.from, urlNode.to) : '';\n\n builder.add(\n node.from,\n node.to,\n Decoration.replace({\n widget: new Link(node.from, text, link ? url : undefined),\n }),\n );\n\n return false;\n }\n }\n\n return true;\n },\n });\n\n return builder.finish();\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { hoverTooltip } from '@codemirror/view';\n\nimport { tooltipContent } from '@dxos/react-ui-theme';\n\nconst markdownLinkRegexp = /\\[([^\\]]+)]\\(([^)]+)\\)/;\n\nexport type OnHyperlinkHover = (el: Element, url: string) => void;\n\n/**\n * https://codemirror.net/examples/tooltip\n * https://codemirror.net/docs/ref/#view.hoverTooltip\n * https://github.com/codemirror/view/blob/main/src/tooltip.ts\n */\n// TODO(burdon): Create config object.\nexport const createHyperlinkTooltip = (onHover: OnHyperlinkHover, regexp = markdownLinkRegexp) =>\n hoverTooltip((view, pos) => {\n const { from, text } = view.state.doc.lineAt(pos);\n const p = pos - from;\n\n let idx = 0;\n let match;\n do {\n match = text.substring(idx).match(regexp);\n if (!match) {\n match = undefined;\n break;\n }\n\n idx = text.indexOf(match[0]);\n if (p >= idx && p < idx + match[0].length) {\n break;\n }\n\n idx += match[0].length;\n } while (true);\n\n if (!match) {\n return null;\n }\n\n const [, , url] = match ?? [];\n\n return {\n pos: idx + from,\n end: idx + from + match[0].length,\n above: true,\n create: () => {\n const el = document.createElement('a');\n el.innerText = '_'; // Required so doesn't collapse.\n el.className = tooltipContent({}, 'mb-2 p-1');\n el.setAttribute('target', '_blank');\n el.setAttribute('href', url);\n onHover(el, url);\n return { dom: el };\n },\n };\n });\n", "//\n// Copyright 2023 DXOS.org\n// Adapted from: https://github.com/uiwjs/react-codemirror/blob/master/extensions/hyper-link/src/index.ts\n//\n\nimport { type Extension } from '@codemirror/state';\nimport {\n Decoration,\n type DecorationSet,\n EditorView,\n MatchDecorator,\n ViewPlugin,\n type ViewUpdate,\n} from '@codemirror/view';\n\n// Notes: Can't edit widget content (or cursor nav through them).\n// - https://discuss.codemirror.net/t/focusing-inputs-within-widgets/5178/7\n// Widgets intentionally always get set to contenteditable=false,\n// or they would become part of CodeMirror’s editable content element.\n// You should be able to introduce new contenteditable=true child elements inside of them.\n\nconst markdownLinkRegexp = /\\[([^\\]]+)]\\(([^)]+)\\)(!?)/gi;\n\n/**\n * Custom link decorator.\n * NOTE: The default markdown extension formats links by default.\n * @deprecated\n */\nconst linkDecorator = () =>\n new MatchDecorator({\n regexp: markdownLinkRegexp,\n decorate: (add, from, to, match, view) => {\n const [_, label, url] = match;\n const p0 = {\n start: from,\n end: from + 1,\n };\n\n const p1 = {\n start: from + 1,\n end: from + 1 + label.length,\n };\n\n const p2 = {\n start: p1.end,\n end: p1.end + 1,\n };\n\n const p3 = {\n start: p1.end + 1,\n end: p1.end + 1 + url.length + 2,\n };\n\n add(\n p0.start,\n p0.end,\n Decoration.mark({ class: 'cm-hyperlink-bracket', _attributes: { style: 'display: none' } }),\n );\n add(p1.start, p1.end, Decoration.mark({ class: 'cm-hyperlink-label' }));\n add(\n p2.start,\n p2.end,\n Decoration.mark({ class: 'cm-hyperlink-bracket', _attributes: { style: 'display: none' } }),\n );\n add(p3.start, p3.end, Decoration.mark({ class: 'cm-hyperlink-url', _attributes: { style: 'display: none' } }));\n },\n });\n\nexport function hyperLinkExtension() {\n return ViewPlugin.fromClass(\n class HyperLinkView {\n readonly decorator: MatchDecorator;\n decorations: DecorationSet;\n constructor(view: EditorView) {\n this.decorator = linkDecorator();\n this.decorations = this.decorator.createDeco(view);\n }\n\n update(update: ViewUpdate) {\n if (update.docChanged || update.viewportChanged) {\n this.decorations = this.decorator.updateDeco(update, this.decorations);\n }\n }\n },\n {\n decorations: (view) => view.decorations,\n eventHandlers: {\n // TODO(burdon): CLick to expand link.\n // https://discuss.codemirror.net/t/decorator-iteration-on-click-event/4226/2\n mousedown: function (event, view) {\n const pos = view.posAtDOM(event.target as Node);\n if (pos !== 0) {\n console.log(this);\n }\n },\n // TODO(burdon): Hide when cursor moves away.\n keydown: (event, view) => {\n view.update([]);\n },\n },\n },\n );\n}\n\nexport const hyperlinkStyle = EditorView.baseTheme({\n '.cm-hyperlink-label': {\n cursor: 'pointer',\n textDecoration: 'underline',\n },\n '.cm-hyperlink-bracket': {\n opacity: 0.2,\n },\n '.cm-hyperlink-url': {\n opacity: 0.5,\n fontFamily: 'monospace',\n },\n});\n\nexport const hyperlinkWidget: Extension = [hyperLinkExtension(), hyperlinkStyle];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { closeBrackets, closeBracketsKeymap } from '@codemirror/autocomplete';\nimport { defaultKeymap, history, historyKeymap, indentWithTab } from '@codemirror/commands';\nimport { markdownLanguage, markdown } from '@codemirror/lang-markdown';\nimport {\n bracketMatching,\n defaultHighlightStyle,\n foldKeymap,\n indentOnInput,\n syntaxHighlighting,\n} from '@codemirror/language';\nimport { languages } from '@codemirror/language-data';\nimport { lintKeymap } from '@codemirror/lint';\nimport { highlightSelectionMatches, searchKeymap } from '@codemirror/search';\nimport { EditorState, type Extension } from '@codemirror/state';\nimport { oneDarkHighlightStyle } from '@codemirror/theme-one-dark';\nimport {\n crosshairCursor,\n drawSelection,\n dropCursor,\n EditorView,\n highlightActiveLine,\n highlightActiveLineGutter,\n highlightSpecialChars,\n keymap,\n placeholder,\n rectangularSelection,\n} from '@codemirror/view';\n// import { GFM } from '@lezer/markdown';\n\nimport type { ThemeMode } from '@dxos/react-ui';\n\nimport { markdownTagsExtension } from './tags';\nimport { markdownHighlightStyle } from './theme';\n\nexport type MarkdownBundleOptions = {\n themeMode?: ThemeMode;\n placeholder?: string;\n};\n\nexport const markdownBundle = ({ themeMode, placeholder: _placeholder }: MarkdownBundleOptions): Extension[] => {\n // All of https://github.com/codemirror/basic-setup minus line numbers and fold gutter.\n // https://codemirror.net/docs/ref/#codemirror.basicSetup\n return [\n bracketMatching(),\n closeBrackets(),\n _placeholder && placeholder(_placeholder),\n\n EditorState.allowMultipleSelections.of(true),\n EditorView.lineWrapping,\n\n // autocompletion(),\n crosshairCursor(),\n dropCursor(),\n drawSelection(),\n highlightActiveLine(),\n highlightActiveLineGutter(),\n highlightSelectionMatches(),\n highlightSpecialChars(),\n history(),\n indentOnInput(),\n rectangularSelection(),\n\n keymap.of([\n ...closeBracketsKeymap,\n // ...completionKeymap,\n ...defaultKeymap,\n ...foldKeymap,\n ...historyKeymap,\n ...lintKeymap,\n ...searchKeymap,\n indentWithTab,\n ]),\n\n // Main extension.\n // https://github.com/codemirror/lang-markdown\n markdown({\n base: markdownLanguage,\n codeLanguages: languages,\n extensions: [\n // TODO(burdon): This seems to upgrade the parser.\n // GitHub flavored markdown bundle: Table, TaskList, Strikethrough, and Autolink.\n // https://github.com/lezer-parser/markdown?tab=readme-ov-file#github-flavored-markdown\n // https://github.github.com/gfm\n // GFM,\n\n // Custom styling.\n markdownTagsExtension,\n ],\n }),\n\n // TODO(thure): All but one rule here apply to both themes; rename or refactor.\n syntaxHighlighting(markdownHighlightStyle),\n themeMode === 'dark' ? syntaxHighlighting(oneDarkHighlightStyle) : syntaxHighlighting(defaultHighlightStyle),\n ].filter(Boolean) as Extension[];\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { styleTags, Tag } from '@lezer/highlight';\nimport { type MarkdownConfig } from '@lezer/markdown';\n\nexport const markdownTags = {\n headingMark: Tag.define(),\n quoteMark: Tag.define(),\n listMark: Tag.define(),\n linkMark: Tag.define(),\n emphasisMark: Tag.define(),\n codeMark: Tag.define(),\n codeText: Tag.define(),\n inlineCode: Tag.define(),\n url: Tag.define(),\n linkReference: Tag.define(),\n linkLabel: Tag.define(),\n};\n\nexport const markdownTagsExtension: MarkdownConfig = {\n props: [\n styleTags({\n HeaderMark: markdownTags.headingMark,\n QuoteMark: markdownTags.quoteMark,\n ListMark: markdownTags.listMark,\n LinkMark: markdownTags.linkMark,\n EmphasisMark: markdownTags.emphasisMark,\n CodeMark: markdownTags.codeMark,\n CodeText: markdownTags.codeText,\n InlineCode: markdownTags.inlineCode,\n URL: markdownTags.url,\n LinkReference: markdownTags.linkReference,\n LinkLabel: markdownTags.linkLabel,\n }),\n ],\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { markdownLanguage } from '@codemirror/lang-markdown';\nimport { HighlightStyle } from '@codemirror/language';\nimport { tags } from '@lezer/highlight';\nimport get from 'lodash.get';\n\nimport { markdownTags } from './tags';\nimport { bold, heading, italic, mark, strikethrough, tokens, type ThemeStyles } from '../../../../styles';\n\n// TODO(burdon): Rationalize theme/colors. Hoist onto single property object.\nexport const chalky = '#e5c07b';\nexport const coral = '#e06c75';\nexport const cyan = '#56b6c2';\nexport const invalid = '#ffffff';\nexport const ivory = '#abb2bf';\nexport const stone = '#7d8799';\nexport const malibu = '#61afef';\nexport const sage = '#98c379';\nexport const whiskey = '#d19a66';\nexport const violet = '#c678dd';\nconst _darkBackground = '#21252b';\nexport const highlightBackground = '#2c313a';\nconst _background = '#282c34';\nexport const tooltipBackground = '#353a42';\nconst _selection = '#3E4451';\n\nconst monospace = get(tokens, 'fontFamily.mono', ['monospace']).join(',');\n\n/**\n * NOTE: The '&' prefix denotes the CM editor root.\n * https://codemirror.net/examples/styling\n */\nexport const markdownTheme: ThemeStyles = {\n // TODO(thure): Consider whether these commented-out rules from one-dark-theme should be integrated.\n // '&': {\n // color: ivory,\n // backgroundColor: background\n // },\n // '.cm-cursor, .cm-dropCursor': { borderLeftColor: cursor },\n // '&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection': {\n // backgroundColor: selection\n // },\n // '.cm-panels': { backgroundColor: darkBackground, color: ivory },\n // '.cm-panels.cm-panels-top': { borderBottom: '2px solid black' },\n // '.cm-panels.cm-panels-bottom': { borderTop: '2px solid black' },\n // '.cm-searchMatch': {\n // backgroundColor: '#72a1ff59',\n // outline: '1px solid #457dff'\n // },\n // '.cm-searchMatch.cm-searchMatch-selected': {\n // backgroundColor: '#6199ff2f'\n // },\n // '.cm-activeLine': { backgroundColor: '#6699ff0b' },\n // '.cm-selectionMatch': { backgroundColor: '#aafe661a' },\n // '&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket': {\n // backgroundColor: '#bad0f847'\n // },\n // '.cm-gutters': {\n // backgroundColor: background,\n // color: stone,\n // border: 'none'\n // },\n // '.cm-activeLineGutter': {\n // backgroundColor: highlightBackground\n // },\n // '.cm-foldPlaceholder': {\n // backgroundColor: 'transparent',\n // border: 'none',\n // color: '#ddd'\n // },\n\n '& .cm-tooltip': {\n backgroundColor: 'transparent',\n border: 'none',\n },\n // '.dark & .cm-tooltip': {\n // border: 'none',\n // backgroundColor: tooltipBackground,\n // },\n // '.dark & .cm-tooltip .cm-tooltip-arrow:before': {\n // borderTopColor: 'transparent',\n // borderBottomColor: 'transparent',\n // },\n // '.dark & .cm-tooltip .cm-tooltip-arrow:after': {\n // borderTopColor: tooltipBackground,\n // borderBottomColor: tooltipBackground,\n // },\n // '.dark & .cm-tooltip-autocomplete': {\n // '& > ul > li[aria-selected]': {\n // backgroundColor: highlightBackground,\n // color: ivory,\n // },\n // },\n '&.cm-focused': {\n outline: 'none',\n },\n '& .cm-line': {\n paddingInline: 0,\n lineHeight: 1.6,\n minBlockSize: '1.6em',\n },\n '& .cm-line *': {\n lineHeight: 1.6,\n },\n '&.cm-focused .cm-selectionBackground, & .cm-selectionBackground': {\n background: get(tokens, 'extend.colors.primary.150', '#00ffff'),\n },\n '.dark & .cm-selectionBackground, .dark &.cm-focused .cm-selectionBackground': {\n background: get(tokens, 'extend.colors.primary.850', '#00ffff'),\n },\n '& .cm-selectionMatch': {\n background: get(tokens, 'extend.colors.primary.250', '#00ffff') + '44',\n },\n '.dark & .cm-selectionMatch': {\n background: get(tokens, 'extend.colors.primary.600', '#00ffff') + '44',\n },\n '& .cm-content': {\n padding: 0,\n caretColor: 'black',\n },\n '.dark & .cm-content': {\n caretColor: 'white',\n },\n '& .cm-cursor': {\n borderLeftColor: 'black',\n },\n '.dark & .cm-cursor': {\n borderLeftColor: 'white',\n },\n '.cm-placeholder': {\n fontFamily: get(tokens, 'fontFamily.body', []).join(','),\n },\n '& .cm-scroller': {\n fontFamily: get(tokens, 'fontFamily.mono', []).join(','),\n overflow: 'visible',\n },\n '& .cm-activeLine': {\n backgroundColor: 'transparent',\n },\n '.dark & .cm-activeLine': {\n backgroundColor: 'transparent',\n },\n '& .cm-ySelectionInfo': {\n fontFamily: get(tokens, 'fontFamily.body', []).join(','),\n padding: '2px 4px',\n marginBlockStart: '-4px',\n },\n '& .cm-ySelection, & .cm-selectionMatch': {\n paddingBlockStart: '.15em',\n paddingBlockEnd: '.15em',\n },\n '& .cm-ySelection, & .cm-yLineSelection': {\n mixBlendMode: 'multiply',\n },\n '.dark & .cm-ySelection, .dark & .cm-yLineSelection': {\n mixBlendMode: 'screen',\n },\n '& .cm-ySelectionCaret': {\n display: 'inline-block',\n insetBlockStart: '.1em',\n blockSize: '1.4em',\n verticalAlign: 'top',\n },\n '& .cm-yLineSelection': {\n margin: '0',\n },\n '.cm-link': {\n color: 'rgb(20 89 208)', // TODO(burdon): Rationalize.\n textDecorationLine: 'underline',\n textDecorationThickness: '1px',\n textUnderlineOffset: '2px',\n borderRadius: '.125rem',\n },\n // TODO(burdon): Document.\n ...Object.keys(get(tokens, 'extend.fontSize', {})).reduce((acc: Record<string, any>, fontSize) => {\n const height = get(tokens, ['extend', 'fontSize', fontSize, 1, 'lineHeight']);\n // TODO(thure): This appears to be the best or only way to set selection caret heights, but it's far more verbose than it needs to be.\n acc[`& .text-${fontSize} + .cm-ySelectionCaret`] = { height };\n acc[`& .text-${fontSize} + .cm-ySelection + .cm-ySelectionCaret`] = { height };\n acc[`& .text-${fontSize} + .cm-widgetBuffer + .cm-ySelectionCaret`] = { height };\n return acc;\n }, {}),\n};\n\nexport const markdownHighlightStyle = HighlightStyle.define(\n [\n {\n tag: [\n tags.keyword,\n tags.name,\n tags.deleted,\n tags.character,\n tags.propertyName,\n tags.macroName,\n tags.color,\n tags.constant(tags.name),\n tags.standard(tags.name),\n tags.definition(tags.name),\n tags.separator,\n tags.typeName,\n tags.className,\n tags.number,\n tags.changed,\n tags.annotation,\n tags.modifier,\n tags.self,\n tags.namespace,\n tags.operator,\n tags.operatorKeyword,\n tags.escape,\n tags.regexp,\n tags.special(tags.string),\n tags.meta,\n tags.comment,\n tags.atom,\n tags.bool,\n tags.special(tags.variableName),\n tags.processingInstruction,\n tags.string,\n tags.inserted,\n tags.invalid,\n ],\n color: 'inherit !important',\n },\n {\n tag: [tags.link, tags.url],\n color: 'inherit !important',\n textDecoration: 'none !important',\n },\n {\n tag: [tags.function(tags.variableName), tags.labelName],\n color: malibu,\n fontFamily: monospace,\n },\n {\n tag: [\n markdownTags.codeMark,\n markdownTags.emphasisMark,\n markdownTags.headingMark,\n markdownTags.linkLabel,\n markdownTags.linkReference,\n markdownTags.listMark,\n markdownTags.quoteMark,\n markdownTags.url,\n tags.meta,\n tags.processingInstruction,\n ],\n class: mark,\n },\n { tag: [markdownTags.codeText, markdownTags.inlineCode], class: 'font-mono' },\n { tag: tags.emphasis, class: italic },\n { tag: tags.heading1, class: heading[1] },\n { tag: tags.heading2, class: heading[2] },\n { tag: tags.heading3, class: heading[3] },\n { tag: tags.heading4, class: heading[4] },\n { tag: tags.heading5, class: heading[5] },\n { tag: tags.heading6, class: heading[6] },\n { tag: tags.strikethrough, class: strikethrough },\n { tag: tags.strong, class: bold },\n ],\n { scope: markdownLanguage, all: { fontFamily: get(tokens, 'fontFamily.body', []).join(',') } },\n);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { EditorState, type Extension } from '@codemirror/state';\nimport { EditorView } from '@codemirror/view';\nimport { useFocusableGroup } from '@fluentui/react-tabster';\nimport { vim } from '@replit/codemirror-vim';\nimport defaultsDeep from 'lodash.defaultsdeep';\nimport get from 'lodash.get';\nimport React, {\n type KeyboardEvent,\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useState,\n type ComponentProps,\n} from 'react';\n\nimport { isDocAccessor } from '@dxos/echo-schema';\nimport { useThemeContext } from '@dxos/react-ui';\n\nimport { basicBundle, basicTheme, markdownBundle, markdownTheme } from './extensions';\nimport { type EditorModel, useCollaboration } from '../../hooks';\nimport type { ThemeStyles } from '../../styles';\n\nexport const EditorModes = ['default', 'vim'] as const;\nexport type EditorMode = (typeof EditorModes)[number];\n\nexport type CursorInfo = {\n from: number;\n to: number;\n line: number;\n lines: number;\n after?: string;\n};\n\nexport type TextEditorRef = {\n editor: HTMLDivElement | null;\n state?: EditorState;\n view?: EditorView;\n};\n\nexport type TextEditorSlots = {\n root?: Omit<ComponentProps<'div'>, 'ref'>;\n editor?: {\n className?: string;\n placeholder?: string;\n spellCheck?: boolean;\n tabIndex?: number;\n theme?: ThemeStyles;\n };\n};\n\nexport type TextEditorProps = {\n model: EditorModel;\n extensions?: Extension[];\n slots?: TextEditorSlots;\n editorMode?: EditorMode;\n};\n\n/**\n * Base text editor.\n * NOTE: Rather than adding properties, try to create extensions that can be reused.\n */\nexport const BaseTextEditor = forwardRef<TextEditorRef, TextEditorProps>(\n ({ model, extensions = [], slots, editorMode }, forwardedRef) => {\n const { themeMode } = useThemeContext();\n const tabsterDOMAttribute = useFocusableGroup({ tabBehavior: 'limited' });\n\n const [parent, setParent] = useState<HTMLDivElement | null>(null);\n const [state, setState] = useState<EditorState>();\n const [view, setView] = useState<EditorView>();\n useImperativeHandle(\n forwardedRef,\n () => ({\n editor: parent,\n state,\n view,\n }),\n [view, state, parent],\n );\n\n // TODO(burdon): Pass in extension?\n const collaboration = useCollaboration(model, themeMode);\n\n useEffect(() => {\n if (!parent) {\n return;\n }\n\n const initialText = isDocAccessor(model.content)\n ? get(model.content.handle.docSync(), model.content.path)\n : model.content?.toString();\n\n const state = EditorState.create({\n doc: initialText,\n extensions: [\n // TODO(burdon): Factor out VIM mode?\n editorMode === 'vim' && vim(),\n\n // Replication.\n collaboration,\n\n // Theme.\n slots?.editor?.theme && EditorView.theme(slots?.editor?.theme),\n\n // Custom.\n ...extensions,\n ].filter(Boolean) as Extension[],\n });\n\n setState(state);\n\n // NOTE: This repaints the editor.\n // If the new state is derived from the old state, it will likely not be visible other than the cursor resetting.\n // Ideally this should not be hit except when changing between text objects.\n view?.destroy();\n setView(new EditorView({ state, parent }));\n\n return () => {\n view?.destroy();\n setView(undefined);\n setState(undefined);\n };\n }, [parent, model.content, themeMode, editorMode]);\n\n const handleKeyUp = useCallback(\n (event: KeyboardEvent) => {\n const { key, altKey, shiftKey, metaKey, ctrlKey } = event;\n switch (key) {\n case 'Enter': {\n view?.contentDOM.focus();\n break;\n }\n\n case 'Escape': {\n editorMode === 'vim' && (altKey || shiftKey || metaKey || ctrlKey) && parent?.focus();\n break;\n }\n }\n },\n [view, editorMode],\n );\n\n return (\n <div\n key={model.id}\n ref={setParent}\n tabIndex={0}\n {...slots?.root}\n {...(editorMode !== 'vim' && tabsterDOMAttribute)}\n onKeyUp={handleKeyUp}\n />\n );\n },\n);\n\nexport const TextEditor = forwardRef<TextEditorRef, TextEditorProps>(\n ({ extensions: _extensions, slots, ...props }, forwardedRef) => {\n const { themeMode } = useThemeContext();\n const extensions = [...(_extensions ?? []), basicBundle({ themeMode, placeholder: slots?.editor?.placeholder })];\n return (\n <BaseTextEditor\n ref={forwardedRef}\n extensions={extensions}\n slots={defaultsDeep({}, slots, { editor: { theme: basicTheme } })}\n {...props}\n />\n );\n },\n);\n\nexport const MarkdownEditor = forwardRef<TextEditorRef, TextEditorProps>(\n ({ extensions: _extensions, slots, ...props }, forwardedRef) => {\n const { themeMode } = useThemeContext();\n const extensions = [...(_extensions ?? []), markdownBundle({ themeMode })];\n return (\n <BaseTextEditor\n ref={forwardedRef}\n extensions={extensions}\n slots={defaultsDeep({}, slots, { editor: { theme: markdownTheme } })}\n {...props}\n />\n );\n },\n);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type { Extension } from '@codemirror/state';\nimport { useEffect, useMemo } from 'react';\nimport { yCollab } from 'y-codemirror.next';\n\nimport { generateName } from '@dxos/display-name';\nimport { isDocAccessor } from '@dxos/echo-schema';\nimport type { ThemeMode } from '@dxos/react-ui';\nimport { getColorForValue } from '@dxos/react-ui-theme';\nimport { YText } from '@dxos/text-model';\n\nimport type { EditorModel } from './useTextModel';\nimport { automergePlugin } from '../automerge/automerge-plugin';\n\n/**\n * Replication and awareness (incl. remote selection).\n * https://codemirror.net/docs/ref/#collab\n */\nexport const useCollaboration = (model: EditorModel, themeMode: ThemeMode): Extension | undefined => {\n const { provider, peer, content } = model;\n const extension = useMemo(() => {\n if (content instanceof YText) {\n return yCollab(content, provider?.awareness);\n } else if (isDocAccessor(content)) {\n return automergePlugin(content.handle, content.path);\n } else {\n return undefined;\n }\n }, []);\n\n useEffect(() => {\n if (provider && peer) {\n provider.awareness.setLocalStateField('user', {\n name: peer.name ?? generateName(peer.id),\n color: getColorForValue({ value: peer.id, type: 'color' }),\n colorLight: getColorForValue({ value: peer.id, themeMode, type: 'highlight' }),\n });\n }\n }, [provider, peer, themeMode]);\n\n return extension;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport {\n Annotation,\n type EditorState,\n type Extension,\n Facet,\n StateEffect,\n StateField,\n type Transaction,\n type TransactionSpec,\n} from '@codemirror/state';\nimport { ViewPlugin, type EditorView, type PluginValue, type ViewUpdate } from '@codemirror/view';\n\nimport * as automerge from '@dxos/automerge/automerge';\nimport { type Heads, type Prop } from '@dxos/automerge/automerge';\n\nimport { PatchSemaphore } from './PatchSemaphore';\nimport { type IDocHandle } from './handle';\n\nexport type Value = {\n lastHeads: Heads;\n path: Prop[];\n unreconciledTransactions: Transaction[];\n};\n\ntype UpdateHeads = {\n newHeads: Heads;\n};\n\nexport const effectType = StateEffect.define<UpdateHeads>({});\n\nexport const updateHeads = (newHeads: Heads): StateEffect<UpdateHeads> => effectType.of({ newHeads });\n\nexport const getLastHeads = (state: EditorState, field: Field): Heads => state.field(field).lastHeads;\n\nexport const getPath = (state: EditorState, field: Field): Prop[] => state.field(field).path;\n\nexport type Field = StateField<Value>;\n\nconst semaphoreFacet = Facet.define<PatchSemaphore, PatchSemaphore>({\n combine: (values) => values.at(-1)!, // Take last.\n});\n\nexport type AutomergePlugin = {\n extension: Extension;\n};\n\nexport const automergePlugin = (handle: IDocHandle, path: Prop[]): AutomergePlugin => {\n const stateField: StateField<Value> = StateField.define({\n create: () => ({\n lastHeads: automerge.getHeads(handle.docSync()!),\n unreconciledTransactions: [],\n path: path.slice(),\n }),\n update: (value: Value, tr: Transaction) => {\n const result: Value = {\n lastHeads: value.lastHeads,\n unreconciledTransactions: value.unreconciledTransactions.slice(),\n path: path.slice(),\n };\n let clearUnreconciled = false;\n for (const effect of tr.effects) {\n if (effect.is(effectType)) {\n result.lastHeads = effect.value.newHeads;\n clearUnreconciled = true;\n }\n }\n if (clearUnreconciled) {\n result.unreconciledTransactions = [];\n } else {\n if (!isReconcileTx(tr)) {\n result.unreconciledTransactions.push(tr);\n }\n }\n return result;\n },\n });\n const semaphore = new PatchSemaphore(stateField);\n\n const viewPlugin = ViewPlugin.fromClass(\n class AutomergeCodemirrorViewPlugin implements PluginValue {\n private _view: EditorView;\n\n constructor(view: EditorView) {\n this._view = view;\n handle.addListener('change', this._handleChange);\n }\n\n update(update: ViewUpdate) {\n if (update.transactions.length > 0 && update.transactions.some((t) => !isReconcileTx(t))) {\n queueMicrotask(() => {\n this._view.state.facet(semaphoreFacet).reconcile(handle, this._view);\n });\n }\n }\n\n destroy() {\n handle.addListener('change', this._handleChange);\n }\n\n private _handleChange = () => {\n this._view.state.facet(semaphoreFacet).reconcile(handle, this._view);\n };\n },\n );\n\n return {\n extension: [stateField, semaphoreFacet.of(semaphore), viewPlugin],\n };\n};\n\nexport const reconcileAnnotationType = Annotation.define<unknown>();\n\nexport const isReconcileTx = (tr: Transaction): boolean => !!tr.annotation(reconcileAnnotationType);\n\nexport const makeReconcile = (tr: TransactionSpec) => {\n if (tr.annotations != null) {\n if (tr.annotations instanceof Array) {\n tr.annotations = [...tr.annotations, reconcileAnnotationType.of({})];\n } else {\n tr.annotations = [tr.annotations, reconcileAnnotationType.of({})];\n }\n } else {\n tr.annotations = [reconcileAnnotationType.of({})];\n }\n // return {\n // ...tr,\n // annotations: reconcileAnnotationType.of({})\n // }\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type EditorView } from '@codemirror/view';\n\nimport { next as automerge } from '@dxos/automerge/automerge';\n\nimport amToCodemirror from './amToCodemirror';\nimport codeMirrorToAm from './codeMirrorToAm';\nimport { type IDocHandle } from './handle';\nimport { type Field, isReconcileTx, getPath, reconcileAnnotationType, updateHeads, getLastHeads } from './plugin';\n\ntype Doc<T> = automerge.Doc<T>;\ntype Heads = automerge.Heads;\n\ntype ChangeFn = (atHeads: Heads, change: (doc: Doc<unknown>) => void) => Heads | undefined;\n\nexport class PatchSemaphore {\n _field!: Field;\n _inReconcile = false;\n _queue: Array<ChangeFn> = [];\n\n constructor(field?: Field) {\n if (field !== undefined) {\n this._field = field;\n }\n }\n\n reconcile = (handle: IDocHandle, view: EditorView) => {\n if (this._inReconcile) {\n return;\n }\n this._inReconcile = true;\n\n const path = getPath(view.state, this._field);\n const oldHeads = getLastHeads(view.state, this._field);\n let selection = view.state.selection;\n\n const transactions = view.state.field(this._field).unreconciledTransactions.filter((tx) => !isReconcileTx(tx));\n\n // First undo all the unreconciled transactions\n const toInvert = transactions.slice().reverse();\n for (const tx of toInvert) {\n const inverted = tx.changes.invert(tx.startState.doc);\n selection = selection.map(inverted);\n view.dispatch({\n changes: inverted,\n annotations: reconcileAnnotationType.of(true),\n });\n }\n\n // now apply the unreconciled transactions to the document\n let newHeads = codeMirrorToAm(this._field, handle, transactions, view.state);\n\n // NOTE: null and undefined each come from automerge and repo respectively\n if (newHeads === null || newHeads === undefined) {\n // TODO: @alexjg this is the call that's resetting the editor state on click\n newHeads = automerge.getHeads(handle.docSync()!);\n }\n\n // now get the diff between the updated state of the document and the heads\n // and apply that to the codemirror doc\n const diff = automerge.equals(oldHeads, newHeads) ? [] : automerge.diff(handle.docSync()!, oldHeads, newHeads);\n amToCodemirror(view, selection, path, diff);\n\n view.dispatch({\n effects: updateHeads(newHeads),\n annotations: reconcileAnnotationType.of({}),\n });\n\n this._inReconcile = false;\n };\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { ChangeSet, type ChangeSpec, type EditorSelection, type EditorState } from '@codemirror/state';\nimport { type EditorView } from '@codemirror/view';\n\nimport {\n type DelPatch,\n type InsertPatch,\n type Patch,\n type Prop,\n type PutPatch,\n type SpliceTextPatch,\n} from '@dxos/automerge/automerge';\n\nimport { reconcileAnnotationType } from './plugin';\n\nexport default (view: EditorView, selection: EditorSelection, target: Prop[], patches: Patch[]) => {\n for (const patch of patches) {\n const changeSpec = handlePatch(patch, target, view.state);\n if (changeSpec != null) {\n const changeSet = ChangeSet.of(changeSpec, view.state.doc.length, '\\n');\n selection = selection.map(changeSet, 1);\n view.dispatch({\n changes: changeSet,\n annotations: reconcileAnnotationType.of({}),\n });\n }\n }\n view.dispatch({\n selection,\n annotations: reconcileAnnotationType.of({}),\n });\n};\n\nconst handlePatch = (patch: Patch, target: Prop[], state: EditorState): ChangeSpec | null => {\n if (patch.action === 'insert') {\n return handleInsert(target, patch);\n } else if (patch.action === 'splice') {\n return handleSplice(target, patch);\n } else if (patch.action === 'del') {\n return handleDel(target, patch);\n } else if (patch.action === 'put') {\n return handlePut(target, patch, state);\n } else {\n return null;\n }\n};\n\nconst handleInsert = (target: Prop[], patch: InsertPatch): Array<ChangeSpec> => {\n const index = charPath(target, patch.path);\n if (index == null) {\n return [];\n }\n const text = patch.values.map((v) => (v ? v.toString() : '')).join('');\n return [{ from: index, to: index, insert: text }];\n};\n\nconst handleSplice = (target: Prop[], patch: SpliceTextPatch): Array<ChangeSpec> => {\n const index = charPath(target, patch.path);\n if (index == null) {\n return [];\n }\n return [{ from: index, insert: patch.value }];\n};\n\nconst handleDel = (target: Prop[], patch: DelPatch): Array<ChangeSpec> => {\n const index = charPath(target, patch.path);\n if (index == null) {\n return [];\n }\n const length = patch.length || 1;\n return [{ from: index, to: index + length }];\n};\n\nconst handlePut = (target: Prop[], patch: PutPatch, state: EditorState): Array<ChangeSpec> => {\n const index = charPath(target, [...patch.path, 0]);\n if (index == null) {\n return [];\n }\n const length = state.doc.length;\n if (typeof patch.value !== 'string') {\n return []; // TODO(dmaretskyi): How to handle non string values?\n }\n return [{ from: 0, to: length, insert: patch.value as any }];\n};\n\n// If the path of the patch is of the form [path, <index>] then we know this is\n// a path to a character within the sequence given by path\nconst charPath = (textPath: Prop[], candidatePath: Prop[]): number | null => {\n if (candidatePath.length !== textPath.length + 1) {\n return null;\n }\n for (let i = 0; i < textPath.length; i++) {\n if (textPath[i] !== candidatePath[i]) {\n return null;\n }\n }\n const index = candidatePath[candidatePath.length - 1];\n if (typeof index === 'number') {\n return index;\n }\n return null;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type EditorState, type Text, type Transaction } from '@codemirror/state';\n\nimport { next as am, type Heads } from '@dxos/automerge/automerge';\n\nimport { type IDocHandle } from './handle';\nimport { type Field } from './plugin';\n\nexport default (\n field: Field,\n handle: IDocHandle,\n transactions: Transaction[],\n state: EditorState,\n): Heads | undefined => {\n const { lastHeads, path } = state.field(field);\n\n // We don't want to call `automerge.updateAt` if there are no changes.\n // Otherwise later on `automerge.diff` will return empty patches that result in a no-op but still mess up the selection.\n let hasChanges = false;\n for (const tr of transactions) {\n tr.changes.iterChanges(() => {\n hasChanges = true;\n });\n }\n\n if (!hasChanges) {\n return undefined;\n }\n\n const newHeads = handle.changeAt(lastHeads, (doc: am.Doc<unknown>) => {\n for (const tr of transactions) {\n tr.changes.iterChanges((fromA: number, toA: number, _fromB: number, _toB: number, inserted: Text) => {\n am.splice(doc, path, fromA, toA - fromA, inserted.toString());\n });\n }\n });\n return newHeads ?? undefined;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { useMemo } from 'react';\nimport type * as awarenessProtocol from 'y-protocols/awareness';\n\nimport {\n type DocAccessor,\n type Space,\n type TextObject,\n type AutomergeTextCompat,\n getRawDoc,\n isActualAutomergeObject,\n} from '@dxos/react-client/echo';\nimport { type Identity } from '@dxos/react-client/halo';\nimport type { YText, YXmlFragment } from '@dxos/text-model';\n\nimport { SpaceAwarenessProvider } from './yjs';\n\n// TODO(burdon): Move.\ntype Awareness = awarenessProtocol.Awareness;\ntype Provider = { awareness: Awareness };\n\n// TODO(wittjosiah): Factor out to common package? @dxos/react-client?\nexport type EditorModel = {\n id: string;\n content: string | YText | YXmlFragment | DocAccessor;\n provider?: Provider;\n peer?: {\n id: string;\n name?: string;\n };\n};\n\nexport type UseTextModelOptions = {\n identity?: Identity | null;\n space?: Space;\n text?: TextObject;\n};\n\n// TODO(burdon): Don't support returning undefined (and remove checks from calling code).\n// TODO(burdon): Decouple space (make Editor less dependent on entire stack)?\n// TODO(wittjosiah): Factor out to common package? @dxos/react-client?\nexport const useTextModel = ({ identity, space, text }: UseTextModelOptions): EditorModel | undefined => {\n const provider = useMemo(() => {\n if (isActualAutomergeObject(text)) {\n return undefined;\n }\n\n if (!space || !text?.doc) {\n return undefined;\n }\n\n return new SpaceAwarenessProvider({ space, doc: text.doc, channel: `yjs.awareness.${text.id}` });\n }, [identity, space, text, text?.doc]);\n\n const content = useMemo(() => {\n if (isActualAutomergeObject(text)) {\n const obj = text as any as AutomergeTextCompat;\n return getRawDoc(obj, [obj.field]);\n } else {\n return text?.content;\n }\n }, [text]);\n\n if (isActualAutomergeObject(text)) {\n const obj = text as any as AutomergeTextCompat;\n return {\n id: obj.id,\n content: content!,\n provider: undefined,\n peer: identity\n ? {\n id: identity.identityKey.toHex(),\n name: identity.profile?.displayName,\n }\n : undefined,\n };\n }\n\n if (!text?.doc || !text?.content) {\n return undefined;\n }\n\n return {\n id: text.doc.guid,\n content: text.content,\n provider,\n peer: identity\n ? {\n id: identity.identityKey.toHex(),\n name: identity.profile?.displayName,\n }\n : undefined,\n };\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// Copied from https://github.com/yjs/y-codemirror.next#example.\n\nimport * as random from 'lib0/random';\n\nconst cursorColors = [\n { color: '#30bced', light: '#30bced33' },\n { color: '#6eeb83', light: '#6eeb8333' },\n { color: '#ffbc42', light: '#ffbc4233' },\n { color: '#ecd444', light: '#ecd44433' },\n { color: '#ee6352', light: '#ee635233' },\n { color: '#9ac2c9', light: '#9ac2c933' },\n { color: '#8acb88', light: '#8acb8833' },\n { color: '#1be7ff', light: '#1be7ff33' },\n];\n\n// Select a random color for this user.\nexport const cursorColor = cursorColors[random.uint32() % cursorColors.length];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport * as decoding from 'lib0/decoding';\nimport * as encoding from 'lib0/encoding';\nimport { Observable } from 'lib0/observable';\nimport * as awarenessProtocol from 'y-protocols/awareness';\nimport { type Doc } from 'yjs';\n\nimport { log } from '@dxos/log';\nimport { type Space } from '@dxos/react-client/echo';\nimport { type GossipMessage } from '@dxos/react-client/mesh';\n\ntype Awareness = awarenessProtocol.Awareness;\n\n// Based on https://github.com/yjs/y-webrtc/blob/88baab2/src/y-webrtc.js.\n\nconst messageAwareness = 1;\nconst messageQueryAwareness = 3;\n\n/**\n * Yjs awareness provider on top of a DXOS space.\n */\nexport class SpaceAwarenessProvider extends Observable<any> {\n private readonly _space: Space;\n private readonly _awareness: Awareness;\n private readonly _clientId: number;\n private readonly _channel: string;\n\n constructor({ space, doc, channel, awareness }: { space: Space; doc: Doc; channel: string; awareness?: Awareness }) {\n super();\n this._space = space;\n this._awareness = awareness ?? new awarenessProtocol.Awareness(doc);\n this._channel = channel;\n this._clientId = doc.clientID;\n\n this._awareness.on('update', this._handleAwarenessUpdate.bind(this));\n this._space.listen(this._channel, this._handleSpaceMessage.bind(this));\n\n if (typeof window !== 'undefined') {\n window.addEventListener('beforeunload', this._handleBeforeUnload.bind(this));\n } else if (typeof process !== 'undefined') {\n process.on('exit', this._handleBeforeUnload.bind(this));\n }\n\n // Post queryAwareness.\n const encoderAwarenessQuery = encoding.createEncoder();\n encoding.writeVarUint(encoderAwarenessQuery, messageQueryAwareness);\n void this._space.postMessage(this._channel, encoding.toUint8Array(encoderAwarenessQuery));\n\n // Post local awareness state.\n const encoderAwarenessState = encoding.createEncoder();\n encoding.writeVarUint(encoderAwarenessState, messageAwareness);\n encoding.writeVarUint8Array(\n encoderAwarenessState,\n awarenessProtocol.encodeAwarenessUpdate(this.awareness, [this._clientId]),\n );\n void this._space.postMessage(this._channel, encoding.toUint8Array(encoderAwarenessState));\n }\n\n get awareness(): Awareness {\n return this._awareness;\n }\n\n private _handleAwarenessUpdate({ added, updated, removed }: any, origin: any) {\n log('awareness update', { added, updated, removed, origin });\n const changedClients = added.concat(updated).concat(removed);\n const encoderAwareness = encoding.createEncoder();\n encoding.writeVarUint(encoderAwareness, messageAwareness);\n encoding.writeVarUint8Array(\n encoderAwareness,\n awarenessProtocol.encodeAwarenessUpdate(this._awareness, changedClients),\n );\n void this._space.postMessage(this._channel, encoding.toUint8Array(encoderAwareness));\n }\n\n private _handleSpaceMessage({ payload }: GossipMessage) {\n log('space message', payload);\n const data = new Uint8Array(Array.from(Object.values(payload)));\n const encoder = this._readMessage(data);\n if (encoder) {\n void this._space.postMessage(this._channel, encoding.toUint8Array(encoder));\n }\n }\n\n private _readMessage(message: Uint8Array) {\n const decoder = decoding.createDecoder(message);\n const encoder = encoding.createEncoder();\n const messageType = decoding.readVarUint(decoder);\n\n let sendReply = false;\n switch (messageType) {\n case messageAwareness: {\n awarenessProtocol.applyAwarenessUpdate(this._awareness, decoding.readVarUint8Array(decoder), this);\n break;\n }\n\n case messageQueryAwareness: {\n encoding.writeVarUint(encoder, messageAwareness);\n encoding.writeVarUint8Array(\n encoder,\n awarenessProtocol.encodeAwarenessUpdate(this._awareness, Array.from(this._awareness.getStates().keys())),\n );\n sendReply = true;\n break;\n }\n\n default: {\n console.error('Invalid message:', messageType);\n return encoder;\n }\n }\n\n if (!sendReply) {\n // Nothing has been written, no answer created.\n return null;\n }\n\n return encoder;\n }\n\n private _handleBeforeUnload() {\n awarenessProtocol.removeAwarenessStates(this._awareness, [this._clientId], 'window unload');\n }\n}\n"],
5
+ "mappings": ";AAIA,SAASA,gBAAgB;AACzB,SAASC,KAAKC,SAAAA,QAAOC,oBAAoB;;;ACDzC,SAASC,QAAAA,aAAY;;;ACArB,SAASC,qBAAqB;AAC9B,SAASC,iBAAiBC,uBAAuBC,0BAA0B;AAE3E,SAASC,6BAA6B;AACtC,SAASC,YAAYC,mBAAmB;AASjC,IAAMC,cAAc,CAAC,EAAEC,WAAWC,aAAaC,aAAY,MAChE;EACEC,gBAAAA;EACAC,cAAAA;EACAF,gBAAgBD,YAAYC,YAAAA;EAE5BG,WAAWC;;EAGXN,cAAc,SAASO,mBAAmBC,qBAAAA,IAAyBD,mBAAmBE,qBAAAA;EACtFC,OAAOC,OAAAA;;;ACvBX,OAAOC,SAAS;;;ACAhB,SAASC,UAAU;AAIZ,IAAMC,UAAwC;EACnD,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;AACL;AAkBO,IAAMC,OAAO;AAEb,IAAMC,OAAO;AAIb,IAAMC,mBAAmBC,GAAGC,MAAM,iBAAA;AAElC,IAAMC,SAAS;AAEf,IAAMC,gBAAgB;AAEtB,IAAMC,OAAO;;;ACvCpB,SAASC,sBAA2C;AA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;AACvE,SACE,sBAAA,cAACP,gBAAAA;IACCsD,KAAKhD;IACLH;IACAC,OAAO2D,aAAa,CAAC,GAAG3D,OAAO;MAAEgB,QAAQ;QAAEgB,OAAO+B;MAAc;IAAE,CAAA;IACjE,GAAGP;;AAGV,CAAA;",
6
+ "names": ["TextKind", "Doc", "YText", "YXmlFragment", "tags", "closeBrackets", "bracketMatching", "defaultHighlightStyle", "syntaxHighlighting", "oneDarkHighlightStyle", "EditorView", "placeholder", "basicBundle", "themeMode", "placeholder", "_placeholder", "bracketMatching", "closeBrackets", "EditorView", "lineWrapping", "syntaxHighlighting", "oneDarkHighlightStyle", "defaultHighlightStyle", "filter", "Boolean", "get", "mx", "heading", "bold", "code", "codeWithoutMarks", "mx", "code", "italic", "strikethrough", "mark", "tailwindConfig", "tokens", "tailwindConfig", "theme", "basicTheme", "outline", "paddingInline", "lineHeight", "minBlockSize", "fontFamily", "get", "tokens", "join", "overflow", "padding", "caretColor", "backgroundColor", "border", "color", "textDecoration", "StateField", "onChangeExtension", "onChange", "StateField", "define", "create", "update", "_value", "transaction", "docChanged", "newDoc", "toString", "syntaxTree", "RangeSetBuilder", "StateField", "Decoration", "EditorView", "WidgetType", "Link", "WidgetType", "constructor", "_anchor", "_text", "_url", "eq", "other", "text", "url", "toDOM", "view", "link", "document", "createElement", "setAttribute", "textContent", "href", "onclick", "dispatch", "selection", "anchor", "hyperlinkDecoration", "StateField", "define", "create", "state", "update", "_", "tr", "provide", "field", "EditorView", "decorations", "from", "builder", "RangeSetBuilder", "cursor", "main", "head", "syntaxTree", "iterate", "enter", "node", "to", "name", "marks", "getChildren", "length", "sliceDoc", "urlNode", "getChild", "add", "Decoration", "replace", "widget", "undefined", "finish", "hoverTooltip", "tooltipContent", "markdownLinkRegexp", "createHyperlinkTooltip", "onHover", "regexp", "hoverTooltip", "view", "pos", "from", "text", "state", "doc", "lineAt", "p", "idx", "match", "substring", "undefined", "indexOf", "length", "url", "end", "above", "create", "el", "document", "createElement", "innerText", "className", "tooltipContent", "setAttribute", "dom", "Decoration", "EditorView", "MatchDecorator", "ViewPlugin", "markdownLinkRegexp", "linkDecorator", "MatchDecorator", "regexp", "decorate", "add", "from", "to", "match", "view", "_", "label", "url", "p0", "start", "end", "p1", "length", "p2", "p3", "Decoration", "mark", "class", "_attributes", "style", "hyperLinkExtension", "ViewPlugin", "fromClass", "HyperLinkView", "constructor", "decorator", "decorations", "createDeco", "update", "docChanged", "viewportChanged", "updateDeco", "eventHandlers", "mousedown", "event", "pos", "posAtDOM", "target", "console", "log", "keydown", "hyperlinkStyle", "EditorView", "baseTheme", "cursor", "textDecoration", "opacity", "fontFamily", "hyperlinkWidget", "closeBrackets", "closeBracketsKeymap", "defaultKeymap", "history", "historyKeymap", "indentWithTab", "markdownLanguage", "markdown", "bracketMatching", "defaultHighlightStyle", "foldKeymap", "indentOnInput", "syntaxHighlighting", "languages", "lintKeymap", "highlightSelectionMatches", "searchKeymap", "EditorState", "oneDarkHighlightStyle", "crosshairCursor", "drawSelection", "dropCursor", "EditorView", "highlightActiveLine", "highlightActiveLineGutter", "highlightSpecialChars", "keymap", "placeholder", "rectangularSelection", "styleTags", "Tag", "markdownTags", "headingMark", "Tag", "define", "quoteMark", "listMark", "linkMark", "emphasisMark", "codeMark", "codeText", "inlineCode", "url", "linkReference", "linkLabel", "markdownTagsExtension", "props", "styleTags", "HeaderMark", "QuoteMark", "ListMark", "LinkMark", "EmphasisMark", "CodeMark", "CodeText", "InlineCode", "URL", "LinkReference", "LinkLabel", "markdownLanguage", "HighlightStyle", "tags", "get", "chalky", "coral", "cyan", "invalid", "ivory", "stone", "malibu", "sage", "whiskey", "violet", "highlightBackground", "tooltipBackground", "monospace", "get", "tokens", "join", "markdownTheme", "backgroundColor", "border", "outline", "paddingInline", "lineHeight", "minBlockSize", "background", "padding", "caretColor", "borderLeftColor", "fontFamily", "overflow", "marginBlockStart", "paddingBlockStart", "paddingBlockEnd", "mixBlendMode", "display", "insetBlockStart", "blockSize", "verticalAlign", "margin", "color", "textDecorationLine", "textDecorationThickness", "textUnderlineOffset", "borderRadius", "Object", "keys", "reduce", "acc", "fontSize", "height", "markdownHighlightStyle", "HighlightStyle", "define", "tag", "tags", "keyword", "name", "deleted", "character", "propertyName", "macroName", "constant", "standard", "definition", "separator", "typeName", "className", "number", "changed", "annotation", "modifier", "self", "namespace", "operator", "operatorKeyword", "escape", "regexp", "special", "string", "meta", "comment", "atom", "bool", "variableName", "processingInstruction", "inserted", "invalid", "link", "url", "textDecoration", "function", "labelName", "malibu", "markdownTags", "codeMark", "emphasisMark", "headingMark", "linkLabel", "linkReference", "listMark", "quoteMark", "class", "mark", "codeText", "inlineCode", "emphasis", "italic", "heading1", "heading", "heading2", "heading3", "heading4", "heading5", "heading6", "strikethrough", "strong", "bold", "scope", "markdownLanguage", "all", "markdownBundle", "themeMode", "placeholder", "_placeholder", "bracketMatching", "closeBrackets", "EditorState", "allowMultipleSelections", "of", "EditorView", "lineWrapping", "crosshairCursor", "dropCursor", "drawSelection", "highlightActiveLine", "highlightActiveLineGutter", "highlightSelectionMatches", "highlightSpecialChars", "history", "indentOnInput", "rectangularSelection", "keymap", "closeBracketsKeymap", "defaultKeymap", "foldKeymap", "historyKeymap", "lintKeymap", "searchKeymap", "indentWithTab", "markdown", "base", "markdownLanguage", "codeLanguages", "languages", "extensions", "markdownTagsExtension", "syntaxHighlighting", "markdownHighlightStyle", "oneDarkHighlightStyle", "defaultHighlightStyle", "filter", "Boolean", "EditorState", "EditorView", "useFocusableGroup", "vim", "defaultsDeep", "get", "React", "forwardRef", "useCallback", "useEffect", "useImperativeHandle", "useState", "isDocAccessor", "useThemeContext", "useEffect", "useMemo", "yCollab", "generateName", "isDocAccessor", "getColorForValue", "YText", "Annotation", "Facet", "StateEffect", "StateField", "ViewPlugin", "automerge", "next", "automerge", "ChangeSet", "view", "selection", "target", "patches", "patch", "changeSpec", "handlePatch", "state", "changeSet", "ChangeSet", "of", "doc", "length", "map", "dispatch", "changes", "annotations", "reconcileAnnotationType", "action", "handleInsert", "handleSplice", "handleDel", "handlePut", "index", "charPath", "path", "text", "values", "v", "toString", "join", "from", "to", "insert", "value", "textPath", "candidatePath", "i", "next", "am", "field", "handle", "transactions", "state", "lastHeads", "path", "hasChanges", "tr", "changes", "iterChanges", "undefined", "newHeads", "changeAt", "doc", "fromA", "toA", "_fromB", "_toB", "inserted", "am", "splice", "toString", "PatchSemaphore", "constructor", "field", "_inReconcile", "_queue", "reconcile", "handle", "view", "path", "getPath", "state", "_field", "oldHeads", "getLastHeads", "selection", "transactions", "unreconciledTransactions", "filter", "tx", "isReconcileTx", "toInvert", "slice", "reverse", "inverted", "changes", "invert", "startState", "doc", "map", "dispatch", "annotations", "reconcileAnnotationType", "of", "newHeads", "codeMirrorToAm", "undefined", "automerge", "getHeads", "docSync", "diff", "equals", "amToCodemirror", "effects", "updateHeads", "effectType", "StateEffect", "define", "updateHeads", "newHeads", "of", "getLastHeads", "state", "field", "lastHeads", "getPath", "path", "semaphoreFacet", "Facet", "combine", "values", "at", "automergePlugin", "handle", "stateField", "StateField", "create", "getHeads", "docSync", "unreconciledTransactions", "slice", "update", "value", "tr", "result", "clearUnreconciled", "effect", "effects", "is", "isReconcileTx", "push", "semaphore", "PatchSemaphore", "viewPlugin", "ViewPlugin", "fromClass", "AutomergeCodemirrorViewPlugin", "constructor", "view", "_handleChange", "_view", "facet", "reconcile", "addListener", "transactions", "length", "some", "t", "queueMicrotask", "destroy", "extension", "reconcileAnnotationType", "Annotation", "annotation", "useCollaboration", "model", "themeMode", "provider", "peer", "content", "extension", "useMemo", "YText", "yCollab", "awareness", "isDocAccessor", "automergePlugin", "handle", "path", "undefined", "useEffect", "setLocalStateField", "name", "generateName", "id", "color", "getColorForValue", "value", "type", "colorLight", "useMemo", "getRawDoc", "isActualAutomergeObject", "random", "cursorColors", "color", "light", "cursorColor", "uint32", "length", "decoding", "encoding", "Observable", "awarenessProtocol", "log", "messageAwareness", "messageQueryAwareness", "SpaceAwarenessProvider", "constructor", "space", "doc", "channel", "awareness", "_space", "_awareness", "Awareness", "_channel", "_clientId", "clientID", "on", "_handleAwarenessUpdate", "bind", "listen", "_handleSpaceMessage", "window", "addEventListener", "_handleBeforeUnload", "process", "encoderAwarenessQuery", "createEncoder", "writeVarUint", "postMessage", "toUint8Array", "encoderAwarenessState", "writeVarUint8Array", "encodeAwarenessUpdate", "added", "updated", "removed", "origin", "changedClients", "concat", "encoderAwareness", "payload", "data", "Uint8Array", "Array", "from", "Object", "values", "encoder", "_readMessage", "message", "decoder", "createDecoder", "messageType", "readVarUint", "sendReply", "applyAwarenessUpdate", "readVarUint8Array", "getStates", "keys", "console", "error", "removeAwarenessStates", "useTextModel", "identity", "space", "text", "provider", "useMemo", "isActualAutomergeObject", "undefined", "doc", "SpaceAwarenessProvider", "channel", "id", "content", "obj", "getRawDoc", "field", "peer", "identityKey", "toHex", "name", "profile", "displayName", "guid", "EditorModes", "BaseTextEditor", "forwardRef", "model", "extensions", "slots", "editorMode", "forwardedRef", "themeMode", "useThemeContext", "tabsterDOMAttribute", "useFocusableGroup", "tabBehavior", "parent", "setParent", "useState", "state", "setState", "view", "setView", "useImperativeHandle", "editor", "collaboration", "useCollaboration", "useEffect", "initialText", "isDocAccessor", "content", "get", "handle", "docSync", "path", "toString", "EditorState", "create", "doc", "vim", "theme", "EditorView", "filter", "Boolean", "destroy", "undefined", "handleKeyUp", "useCallback", "event", "key", "altKey", "shiftKey", "metaKey", "ctrlKey", "contentDOM", "focus", "div", "id", "ref", "tabIndex", "root", "onKeyUp", "TextEditor", "_extensions", "props", "basicBundle", "placeholder", "defaultsDeep", "basicTheme", "MarkdownEditor", "markdownBundle", "markdownTheme"]
7
7
  }