Skip to content

Commit

Permalink
Continued cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminleonard committed Dec 17, 2024
1 parent 8fd2114 commit cea30e3
Show file tree
Hide file tree
Showing 18 changed files with 329 additions and 359 deletions.
8 changes: 3 additions & 5 deletions app/components/AsciidocBlocks/Document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ import { useDelegatedReactRouterLinks } from '@oxide/design-system/components/di
import { Content, type DocumentBlock } from '@oxide/react-asciidoc'
import { useRef } from 'react'

// add styles for main
// max-w-full flex-shrink overflow-hidden 800:overflow-visible 800:pr-10 1200:w-[calc(100%-var(--toc-width))] 1200:pr-16 print:p-0
const CustomDocument = ({ document }: { document: DocumentBlock }) => {
let ref = useRef<HTMLDivElement>(null)
useDelegatedReactRouterLinks(ref, document.title)

return (
<div
id="content"
className="asciidoc-body max-w-full flex-shrink overflow-hidden 800:overflow-visible 800:pr-10 1200:w-[calc(100%-var(--toc-width))] 1200:pr-16 print:p-0"
ref={ref}
>
<div id="content" className="asciidoc-body" ref={ref}>
<Content blocks={document.blocks} />
</div>
)
Expand Down
73 changes: 12 additions & 61 deletions app/components/note/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const EditorWrapper = ({
onChange,
}: {
body: string
onChange: (string) => void
onChange: (string: string | undefined) => void
}) => {
const monaco = useMonaco()

Expand All @@ -37,69 +37,20 @@ const EditorWrapper = ({
<Editor
value={body}
onChange={onChange}
theme="vs-dark"
theme="oxide-dark"
language="asciidoc"
options={{ minimap: { enabled: false }, fontFamily: 'GT America Mono', fontSize: 13 }}
options={{
minimap: { enabled: false },
fontFamily: 'GT America Mono',
fontSize: 13,
wordWrap: 'on',
quickSuggestions: false,
suggestOnTriggerCharacters: false,
acceptSuggestionOnEnter: 'off',
snippetSuggestions: 'none',
}}
/>
)
}

export default EditorWrapper

// import loader from '@monaco-editor/loader'
// import { shikiToMonaco } from '@shikijs/monaco'
// import { type editor } from 'monaco-editor'
// import type * as Monaco from 'monaco-editor/esm/vs/editor/editor.api'
// import { useCallback, useEffect, useRef, useState } from 'react'
// import { getHighlighter } from 'shiki'

// const Editor = () => {
// const containerRef = useRef<HTMLDivElement>(null)
// const monacoRef = useRef<typeof Monaco | null>(null)
// const [isMonacoMounting, setIsMonacoMounting] = useState(true)
// const editorRef = useRef<editor.IStandaloneCodeEditor | null>(null)
// const preventCreation = useRef(false)
// const [isEditorReady, setIsEditorReady] = useState(false)

// useEffect(() => {
// const cancelable = loader.init()

// cancelable
// .then((monaco) => (monacoRef.current = monaco) && setIsMonacoMounting(false))
// .catch(
// (error) =>
// error?.type !== 'cancelation' &&
// console.error('Monaco initialization: error:', error),
// )

// return () => (editorRef.current ? editorRef.current!.dispose() : cancelable.cancel())
// }, [containerRef])

// const createEditor = useCallback(() => {
// if (!containerRef.current || !monacoRef.current) return
// if (!preventCreation.current) {
// editorRef.current = monacoRef.current?.editor.create(containerRef.current, {
// automaticLayout: true,
// })

// monacoRef.current.editor.setTheme('vs-dark')

// setIsEditorReady(true)
// preventCreation.current = true
// }
// }, [])

// useEffect(() => {
// !isMonacoMounting && !isEditorReady && createEditor()
// }, [isMonacoMounting, isEditorReady, createEditor])

// console.log(monacoRef, containerRef)

// return (
// <div className="h-full w-full">
// <div ref={containerRef} className="h-full w-full" />
// </div>
// )
// }

// export default Editor
Loading

0 comments on commit cea30e3

Please sign in to comment.