Skip to content

Commit

Permalink
Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
R1c4rdCo5t4 committed Apr 14, 2024
1 parent 37c6c18 commit 1ce9845
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 7 deletions.
2 changes: 2 additions & 0 deletions code/client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
import SlateEditor from '@editor/slate/SlateEditor';
import Header from '@src/components/header/Header';
import './App.scss';

function App() {
return (
<div className="app">
<Header />
<Router>
<Routes>
<Route path={'/'} element={<SlateEditor />} />
Expand Down
2 changes: 0 additions & 2 deletions code/client/src/editor/slate/SlateEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import useCommunication from '@editor/hooks/useCommunication';
import { withMarkdown } from '@editor/slate/plugins/markdown/withMarkdown';
import markdownHandlers from '@editor/domain/markdown/handlers';
import './SlateEditor.scss';
import Header from '@src/components/header/Header';

// for testing purposes, we need to be able to pass in an editor
type SlateEditorProps = {
Expand All @@ -40,7 +39,6 @@ function SlateEditor({ editor: _editor }: SlateEditorProps) {

return (
<div className="editor">
<Header />
<div className="container">
<Slate editor={editor} initialValue={initialValue}>
{/*<Cursors />*/}
Expand Down
3 changes: 2 additions & 1 deletion code/client/src/editor/slate/events/inputEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default (editor: Editor, fugue: Fugue, communication: Communication) => {
onEnter(cursor);
break;
case 'Backspace':
if (isSelected(editor)) break;
onBackspace(cursor);
break;
case 'Delete':
Expand Down Expand Up @@ -68,7 +69,7 @@ export default (editor: Editor, fugue: Fugue, communication: Communication) => {
function onEnter(cursor: Cursor) {
const operations = fugue.insertLocal(cursor, '\n');
const styleOperation = fugue.updateBlockStyleLocal('paragraph', cursor.line, true);
communication.emitChunked('operation', [...operations, styleOperation]);
communication.emitChunked('operation', [styleOperation, ...operations]);
}

/**
Expand Down
1 change: 0 additions & 1 deletion code/client/src/editor/slate/utils/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ function pointToCursor(editor: Editor, point: Point): Cursor {
const line = point.path[0];
const children = Node.children(editor, [line]);
const cursor: Cursor = { line, column: point.offset };

for (const entry of children) {
if (Path.equals(entry[1], point.path)) break;
cursor.column += first(entry).text.length;
Expand Down
3 changes: 0 additions & 3 deletions code/client/tests/editor/slate/SlateEditor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ describe('SlateEditor', () => {
});

it('should render the editor', async () => {
const h1Title = screen.getByText('NoteSpace');
const documentTitle = screen.getByPlaceholderText('Untitled');

expect(h1Title).toBeInTheDocument();
expect(documentTitle).toBeInTheDocument();
expect(editor).toHaveTextContent(EDITOR_PLACEHOLDER);
});
Expand Down

0 comments on commit 1ce9845

Please sign in to comment.