Skip to content

Commit 8a5b1ad

Browse files
committed
remove backlinks and writing assistant placeholder text
1 parent cb7c28d commit 8a5b1ad

File tree

2 files changed

+1
-73
lines changed

2 files changed

+1
-73
lines changed

src/components/Editor/EditorManager.tsx

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ const EditorManager: React.FC = () => {
1111
const [contextMenuVisible, setContextMenuVisible] = useState(false)
1212
const [menuPosition, setMenuPosition] = useState({ x: 0, y: 0 })
1313
const [editorFlex, setEditorFlex] = useState(true)
14-
const [showPlaceholder, setShowPlaceholder] = useState(false)
15-
const [writingAssistantTextPosition, setWritingAssistantTextPosition] = useState({ top: 0, left: 0 })
1614

17-
const { editor, suggestionsState, vaultFilesFlattened, currentlyOpenFilePath } = useFileContext()
15+
const { editor, suggestionsState, vaultFilesFlattened } = useFileContext()
1816
const [showDocumentStats, setShowDocumentStats] = useState(false)
1917
const { openContent } = useContentContext()
2018

@@ -69,65 +67,6 @@ const EditorManager: React.FC = () => {
6967
window.ipcRenderer.on('show-doc-stats-changed', handleDocStatsChange)
7068
}, [])
7169

72-
useEffect(() => {
73-
if (!editor) return
74-
75-
const handleUpdate = () => {
76-
try {
77-
const { state } = editor
78-
const { from, to } = state.selection
79-
80-
const $from = state.doc.resolve(from)
81-
const $to = state.doc.resolve(to)
82-
const start = $from.before()
83-
const end = $to.after()
84-
85-
const currentLineText = state.doc.textBetween(start, end, '\n', ' ').trim()
86-
87-
if (currentLineText === '') {
88-
const { node } = editor.view.domAtPos(from)
89-
const rect = (node as HTMLElement).getBoundingClientRect()
90-
const editorRect = editor.view.dom.getBoundingClientRect()
91-
setWritingAssistantTextPosition({ top: rect.top - editorRect.top, left: rect.left - editorRect.left })
92-
setShowPlaceholder(true)
93-
} else {
94-
setShowPlaceholder(false)
95-
}
96-
} catch (error) {
97-
setShowPlaceholder(false)
98-
}
99-
}
100-
101-
editor.on('update', handleUpdate)
102-
editor.on('selectionUpdate', handleUpdate)
103-
104-
// eslint-disable-next-line consistent-return
105-
return () => {
106-
editor.off('update', handleUpdate)
107-
editor.off('selectionUpdate', handleUpdate)
108-
}
109-
}, [editor])
110-
111-
const handleInput = () => {
112-
if (editor) {
113-
const { state } = editor
114-
const { from, to } = state.selection
115-
116-
const $from = state.doc.resolve(from)
117-
const $to = state.doc.resolve(to)
118-
const start = $from.before()
119-
const end = $to.after()
120-
121-
const currentLineText = state.doc.textBetween(start, end, '\n', ' ').trim()
122-
setShowPlaceholder(currentLineText === '')
123-
}
124-
}
125-
useEffect(() => {
126-
if (editor) {
127-
editor.commands.focus()
128-
}
129-
}, [editor, currentlyOpenFilePath])
130-
13170
return (
13271
<div
13372
className="relative size-full cursor-text overflow-hidden bg-dark-gray-c-eleven py-4 text-slate-400 opacity-80"
@@ -154,17 +93,8 @@ const EditorManager: React.FC = () => {
15493
}}
15594
onContextMenu={handleContextMenu}
15695
onClick={handleClick}
157-
onInput={handleInput}
15896
editor={editor}
15997
/>
160-
{showPlaceholder && (
161-
<div
162-
className="pointer-events-none absolute text-gray-500"
163-
style={{ top: writingAssistantTextPosition.top, left: writingAssistantTextPosition.left }}
164-
>
165-
Press &apos;space&apos; for AI writing assistant
166-
</div>
167-
)}
16898
</div>
16999
</div>
170100
{suggestionsState && (

src/contexts/FileContext.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import {
2828
getNextAvailableFileNameGivenBaseName,
2929
sortFilesAndDirectories,
3030
} from '@/lib/file'
31-
import { BacklinkExtension } from '@/components/Editor/BacklinkExtension'
3231
import { SuggestionsState } from '@/components/Editor/BacklinkSuggestionsDisplay'
3332
import HighlightExtension, { HighlightData } from '@/components/Editor/HighlightExtension'
3433
import { RichTextLink } from '@/components/Editor/RichTextLink'
@@ -194,7 +193,6 @@ export const FileProvider: React.FC<{ children: ReactNode }> = ({ children }) =>
194193
linkOnPaste: true,
195194
openOnClick: true,
196195
}),
197-
BacklinkExtension(setSuggestionsState),
198196
CharacterCount,
199197
],
200198
})

0 commit comments

Comments
 (0)