+
{props.children}
)
diff --git a/src/components/Editor/components/ProseMirror.tsx b/src/components/Editor/components/ProseMirror.tsx
new file mode 100644
index 00000000..632055c0
--- /dev/null
+++ b/src/components/Editor/components/ProseMirror.tsx
@@ -0,0 +1,71 @@
+import { EditorState, type Transaction } from 'prosemirror-state'
+import { EditorView } from 'prosemirror-view'
+import { unwrap } from 'solid-js/store'
+import { createEffect, untrack } from 'solid-js'
+import { createEditorState } from '../prosemirror'
+import type { ProseMirrorState, ProseMirrorExtension } from '../prosemirror/helpers'
+
+interface Props {
+ style?: string
+ className?: string
+ text?: ProseMirrorState
+ editorView?: EditorView
+ extensions?: ProseMirrorExtension[]
+ onInit: (s: EditorState, v: EditorView) => void
+ onReconfigure: (s: EditorState) => void
+ onChange: (s: EditorState) => void
+}
+
+export const ProseMirror = (props: Props) => {
+ let editorRef: HTMLDivElement
+ const editorView = () => untrack(() => unwrap(props.editorView))
+ const dispatchTransaction = (tr: Transaction) => {
+ if (!editorView()) return
+ const newState = editorView().state.apply(tr)
+ editorView().updateState(newState)
+ if (!tr.docChanged) return
+ props.onChange(newState)
+ }
+
+ createEffect(
+ (state: [EditorState, ProseMirrorExtension[]]) => {
+ const [prevText, prevExtensions] = state
+ const text = unwrap(props.text)
+ const extensions = unwrap(props.extensions)
+ if (!text || !extensions?.length) {
+ return [text, extensions]
+ }
+
+ if (!props.editorView) {
+ const { editorState, nodeViews } = createEditorState(text, extensions)
+ const view = new EditorView(editorRef, { state: editorState, nodeViews, dispatchTransaction })
+ view.focus()
+ props.onInit(editorState, view)
+ return [editorState, extensions]
+ }
+
+ if (extensions !== prevExtensions || (!(text instanceof EditorState) && text !== prevText)) {
+ const { editorState, nodeViews } = createEditorState(text, extensions, prevText)
+ if (!editorState) return
+ editorView().updateState(editorState)
+ editorView().setProps({ nodeViews, dispatchTransaction })
+ props.onReconfigure(editorState)
+ editorView().focus()
+ return [editorState, extensions]
+ }
+
+ return [text, extensions]
+ },
+ [props.text, props.extensions]
+ )
+
+ return (
+
+ )
+}
diff --git a/src/components/Editor/components/Sidebar.tsx b/src/components/Editor/components/Sidebar.tsx
index e2a73f5f..7966d4a6 100644
--- a/src/components/Editor/components/Sidebar.tsx
+++ b/src/components/Editor/components/Sidebar.tsx
@@ -1,27 +1,19 @@
-import { Show, createEffect, createSignal, onCleanup, For } from 'solid-js'
+import { Show, createEffect, createSignal, onCleanup } from 'solid-js'
import { unwrap } from 'solid-js/store'
import { undo, redo } from 'prosemirror-history'
-import { Draft, useState } from '../store/context'
-import { clsx } from 'clsx'
+import { useState } from '../store'
import type { Styled } from './Layout'
-import { t } from '../../../utils/intl'
-
-// import type { EditorState } from 'prosemirror-state'
-// import { serialize } from './prosemirror/markdown'
-// import { baseUrl } from '../../graphql/client'
-// import { isServer } from 'solid-js/web'
-
-// const copy = async (text: string): Promise
=> navigator.clipboard.writeText(text)
-// const copyAllAsMarkdown = async (state: EditorState): Promise =>
-// navigator.clipboard.writeText(serialize(state)) && !isServer
+import '../styles/Sidebar.scss'
const Off = (props) =>
+
const Label = (props: Styled) =>
+
const Link = (
props: Styled & { withMargin?: boolean; disabled?: boolean; title?: string; className?: string }
) => (