(() => store.error.message)
return (
diff --git a/src/components/Editor/index.tsx b/src/components/Editor/index.tsx
index 5950abcd..49841c3a 100644
--- a/src/components/Editor/index.tsx
+++ b/src/components/Editor/index.tsx
@@ -1,8 +1,8 @@
+import './Editor.scss'
import type { EditorView } from 'prosemirror-view'
import type { EditorState } from 'prosemirror-state'
-import { useState } from './prosemirror/context'
+import { useState } from './store'
import { ProseMirror } from './prosemirror'
-import './Editor.scss'
export default () => {
const [store, ctrl] = useState()
diff --git a/src/components/Editor/prosemirror/context.ts b/src/components/Editor/prosemirror/context.ts
deleted file mode 100644
index 4f151e6e..00000000
--- a/src/components/Editor/prosemirror/context.ts
+++ /dev/null
@@ -1,118 +0,0 @@
-import { createContext, useContext } from 'solid-js'
-import type { Store } from 'solid-js/store'
-import type { XmlFragment } from 'yjs'
-import type { WebrtcProvider } from 'y-webrtc'
-import type { ProseMirrorExtension, ProseMirrorState } from './state'
-import type { Reaction } from '../../../graphql/types.gen'
-
-export const isMac = true
-
-export const mod = isMac ? 'Cmd' : 'Ctrl'
-export const alt = isMac ? 'Cmd' : 'Alt'
-
-export interface Args {
- cwd?: string
- file?: string
- room?: string
- text?: any
-}
-
-export interface PrettierConfig {
- printWidth: number
- tabWidth: number
- useTabs: boolean
- semi: boolean
- singleQuote: boolean
-}
-
-export interface Config {
- theme: string
- // codeTheme: string;
- font: string
- fontSize: number
- contentWidth: number
- alwaysOnTop: boolean
- // typewriterMode: boolean;
- prettier: PrettierConfig
-}
-
-export interface ErrorObject {
- id: string
- props?: unknown
-}
-
-export interface YOptions {
- type: XmlFragment
- provider: WebrtcProvider
-}
-
-export interface Collab {
- started?: boolean
- error?: boolean
- room?: string
- y?: YOptions
-}
-
-export type LoadingType = 'loading' | 'initialized'
-
-export interface File {
- text?: { [key: string]: any }
- lastModified?: string
- path?: string
- markdown?: boolean
-}
-
-export interface State {
- text?: ProseMirrorState
- editorView?: any
- extensions?: ProseMirrorExtension[]
- markdown?: boolean
- lastModified?: Date
- files: File[]
- config: Config
- error?: ErrorObject
- loading: LoadingType
- fullscreen: boolean
- collab?: Collab
- path?: string
- args?: Args
-}
-
-export class ServiceError extends Error {
- public errorObject: ErrorObject
- constructor(id: string, props: unknown) {
- super(id)
- this.errorObject = { id, props }
- }
-}
-
-const DEFAULT_CONFIG = {
- theme: '',
- // codeTheme: 'material-light',
- font: 'muller',
- fontSize: 24,
- contentWidth: 800,
- alwaysOnTop: isMac,
- // typewriterMode: true,
- prettier: {
- printWidth: 80,
- tabWidth: 2,
- useTabs: false,
- semi: false,
- singleQuote: true
- }
-}
-
-export const StateContext = createContext<[Store, any]>([{} as Store, undefined])
-
-export const useState = () => useContext(StateContext)
-
-export const newState = (props: Partial = {}): State => ({
- extensions: [],
- files: [],
- loading: 'loading',
- fullscreen: false,
- markdown: false,
- config: DEFAULT_CONFIG,
- ...props
-})
diff --git a/src/components/Editor/prosemirror/extension/collab.ts b/src/components/Editor/prosemirror/extension/collab.ts
index ddb36b5c..a5444659 100644
--- a/src/components/Editor/prosemirror/extension/collab.ts
+++ b/src/components/Editor/prosemirror/extension/collab.ts
@@ -1,6 +1,6 @@
import { ySyncPlugin, yCursorPlugin, yUndoPlugin } from 'y-prosemirror'
import type { ProseMirrorExtension } from '../state'
-import type { YOptions } from '../context'
+import type { YOptions } from '../../store'
export const cursorBuilder = (user: any): HTMLElement => {
const cursor = document.createElement('span')
diff --git a/src/components/Editor/prosemirror/setup.ts b/src/components/Editor/prosemirror/setup.ts
index 269d9773..311ccd18 100644
--- a/src/components/Editor/prosemirror/setup.ts
+++ b/src/components/Editor/prosemirror/setup.ts
@@ -15,7 +15,7 @@ import dragHandle from './extension/drag-handle'
import pasteMarkdown from './extension/paste-markdown'
import table from './extension/table'
import collab from './extension/collab'
-import type { Config, YOptions } from './context'
+import type { Config, YOptions } from '../store'
import selectionMenu from './extension/selection'
interface Opts {
diff --git a/src/components/Editor/store/index.ts b/src/components/Editor/store/index.ts
index 0eeac64c..e6df1cea 100644
--- a/src/components/Editor/store/index.ts
+++ b/src/components/Editor/store/index.ts
@@ -3,7 +3,13 @@ import type { Store } from 'solid-js/store'
import type { XmlFragment } from 'yjs'
import type { WebrtcProvider } from 'y-webrtc'
import type { ProseMirrorExtension, ProseMirrorState } from '../prosemirror/state'
-import { isMac } from '../prosemirror/context'
+import type { Reaction } from '../../../graphql/types.gen'
+import type { EditorView } from 'prosemirror-view'
+
+export const isMac = true
+
+export const mod = isMac ? 'Cmd' : 'Ctrl'
+export const alt = isMac ? 'Cmd' : 'Alt'
export interface Args {
cwd?: string
@@ -32,8 +38,9 @@ export interface Config {
}
export interface ErrorObject {
+ message: string
id: string
- props?: unknown
+ props: unknown
}
export interface YOptions {
@@ -59,7 +66,7 @@ export interface File {
export interface State {
text?: ProseMirrorState
- editorView?: any
+ editorView?: EditorView
extensions?: ProseMirrorExtension[]
markdown?: boolean
lastModified?: Date
@@ -77,7 +84,24 @@ export class ServiceError extends Error {
public errorObject: ErrorObject
constructor(id: string, props: unknown) {
super(id)
- this.errorObject = { id, props }
+ this.errorObject = { id, props, message: '' }
+ }
+}
+
+const DEFAULT_CONFIG = {
+ theme: '',
+ // codeTheme: 'material-light',
+ font: 'muller',
+ fontSize: 24,
+ contentWidth: 800,
+ alwaysOnTop: isMac,
+ // typewriterMode: true,
+ prettier: {
+ printWidth: 80,
+ tabWidth: 2,
+ useTabs: false,
+ semi: false,
+ singleQuote: true
}
}
@@ -91,21 +115,6 @@ export const newState = (props: Partial = {}): State => ({
loading: 'loading',
fullscreen: false,
markdown: false,
- config: {
- theme: 'light',
- // codeTheme: 'material-light',
- font: 'muller',
- fontSize: 24,
- contentWidth: 800,
- alwaysOnTop: isMac,
- // typewriterMode: true,
- prettier: {
- printWidth: 80,
- tabWidth: 2,
- useTabs: false,
- semi: false,
- singleQuote: true
- }
- },
+ config: DEFAULT_CONFIG,
...props
})
diff --git a/src/components/Root.tsx b/src/components/Root.tsx
index 2bd69fa2..a770d97a 100644
--- a/src/components/Root.tsx
+++ b/src/components/Root.tsx
@@ -46,6 +46,7 @@ import { CreatePage } from './Pages/CreatePage'
// const ProjectsPage = lazy(() => import('./Pages/about/ProjectsPage'))
// const TermsOfUsePage = lazy(() => import('./Pages/about/TermsOfUsePage'))
// const ThanksPage = lazy(() => import('./Pages/about/ThanksPage'))
+// const CreatePage = lazy(() => import('./Pages/about/CreatePage'))
const log = getLogger('root')
diff --git a/src/components/Views/Create.tsx b/src/components/Views/Create.tsx
index 646c1b3b..5a24584d 100644
--- a/src/components/Views/Create.tsx
+++ b/src/components/Views/Create.tsx
@@ -1,12 +1,11 @@
import { Show, onCleanup, createEffect, onError, onMount, untrack } from 'solid-js'
import { createMutable, unwrap } from 'solid-js/store'
-import { State, StateContext } from '../Editor/prosemirror/context'
+import { State, StateContext, newState } from '../Editor/store'
import { createCtrl } from '../Editor/store/ctrl'
import { Layout } from '../Editor/Layout'
import Editor from '../Editor'
import { Sidebar } from '../Editor/Sidebar'
import ErrorView from '../Editor/Error'
-import { newState } from '../Editor/store'
import { getLogger } from '../../utils/logger'
const log = getLogger('CreateView')
@@ -15,7 +14,7 @@ export const CreateView = () => {
const [store, ctrl] = createCtrl(newState())
const mouseEnterCoords = createMutable({ x: 0, y: 0 })
- const onMouseEnter = (e: any) => {
+ const onMouseEnter = (e: MouseEvent) => {
mouseEnterCoords.x = e.pageX
mouseEnterCoords.y = e.pageY
}