From 8a5b1ad8f98d18a699ef90fb68db0031380e5fd3 Mon Sep 17 00:00:00 2001 From: samlhuillier Date: Sun, 3 Nov 2024 12:03:31 +0000 Subject: [PATCH] remove backlinks and writing assistant placeholder text --- src/components/Editor/EditorManager.tsx | 72 +------------------------ src/contexts/FileContext.tsx | 2 - 2 files changed, 1 insertion(+), 73 deletions(-) diff --git a/src/components/Editor/EditorManager.tsx b/src/components/Editor/EditorManager.tsx index c3681d59..e47db2ef 100644 --- a/src/components/Editor/EditorManager.tsx +++ b/src/components/Editor/EditorManager.tsx @@ -11,10 +11,8 @@ const EditorManager: React.FC = () => { const [contextMenuVisible, setContextMenuVisible] = useState(false) const [menuPosition, setMenuPosition] = useState({ x: 0, y: 0 }) const [editorFlex, setEditorFlex] = useState(true) - const [showPlaceholder, setShowPlaceholder] = useState(false) - const [writingAssistantTextPosition, setWritingAssistantTextPosition] = useState({ top: 0, left: 0 }) - const { editor, suggestionsState, vaultFilesFlattened, currentlyOpenFilePath } = useFileContext() + const { editor, suggestionsState, vaultFilesFlattened } = useFileContext() const [showDocumentStats, setShowDocumentStats] = useState(false) const { openContent } = useContentContext() @@ -69,65 +67,6 @@ const EditorManager: React.FC = () => { window.ipcRenderer.on('show-doc-stats-changed', handleDocStatsChange) }, []) - useEffect(() => { - if (!editor) return - - const handleUpdate = () => { - try { - const { state } = editor - const { from, to } = state.selection - - const $from = state.doc.resolve(from) - const $to = state.doc.resolve(to) - const start = $from.before() - const end = $to.after() - - const currentLineText = state.doc.textBetween(start, end, '\n', ' ').trim() - - if (currentLineText === '') { - const { node } = editor.view.domAtPos(from) - const rect = (node as HTMLElement).getBoundingClientRect() - const editorRect = editor.view.dom.getBoundingClientRect() - setWritingAssistantTextPosition({ top: rect.top - editorRect.top, left: rect.left - editorRect.left }) - setShowPlaceholder(true) - } else { - setShowPlaceholder(false) - } - } catch (error) { - setShowPlaceholder(false) - } - } - - editor.on('update', handleUpdate) - editor.on('selectionUpdate', handleUpdate) - - // eslint-disable-next-line consistent-return - return () => { - editor.off('update', handleUpdate) - editor.off('selectionUpdate', handleUpdate) - } - }, [editor]) - - const handleInput = () => { - if (editor) { - const { state } = editor - const { from, to } = state.selection - - const $from = state.doc.resolve(from) - const $to = state.doc.resolve(to) - const start = $from.before() - const end = $to.after() - - const currentLineText = state.doc.textBetween(start, end, '\n', ' ').trim() - setShowPlaceholder(currentLineText === '') - } - } - useEffect(() => { - if (editor) { - editor.commands.focus() - } - }, [editor, currentlyOpenFilePath]) - return (
{ }} onContextMenu={handleContextMenu} onClick={handleClick} - onInput={handleInput} editor={editor} /> - {showPlaceholder && ( -
- Press 'space' for AI writing assistant -
- )}
{suggestionsState && ( diff --git a/src/contexts/FileContext.tsx b/src/contexts/FileContext.tsx index 63877b1c..3480dc77 100644 --- a/src/contexts/FileContext.tsx +++ b/src/contexts/FileContext.tsx @@ -28,7 +28,6 @@ import { getNextAvailableFileNameGivenBaseName, sortFilesAndDirectories, } from '@/lib/file' -import { BacklinkExtension } from '@/components/Editor/BacklinkExtension' import { SuggestionsState } from '@/components/Editor/BacklinkSuggestionsDisplay' import HighlightExtension, { HighlightData } from '@/components/Editor/HighlightExtension' import { RichTextLink } from '@/components/Editor/RichTextLink' @@ -194,7 +193,6 @@ export const FileProvider: React.FC<{ children: ReactNode }> = ({ children }) => linkOnPaste: true, openOnClick: true, }), - BacklinkExtension(setSuggestionsState), CharacterCount, ], })