diff --git a/shared/editor/components/Styles.ts b/shared/editor/components/Styles.ts index 4518168a4..8bf52f8d1 100644 --- a/shared/editor/components/Styles.ts +++ b/shared/editor/components/Styles.ts @@ -268,6 +268,11 @@ width: 100%; padding: ${props.editorStyle?.padding ?? "initial"}; margin: ${props.editorStyle?.margin ?? "initial"}; + .ProseMirror { + padding: 0; + margin: 0; + } + & > .ProseMirror-yjs-cursor { display: none; } diff --git a/shared/editor/nodes/MathBlock.ts b/shared/editor/nodes/MathBlock.ts index 948e82d91..fe1b618f6 100644 --- a/shared/editor/nodes/MathBlock.ts +++ b/shared/editor/nodes/MathBlock.ts @@ -4,7 +4,7 @@ import { } from "@benrbray/prosemirror-math"; import { PluginSimple } from "markdown-it"; import { NodeSpec, NodeType, Node as ProsemirrorNode } from "prosemirror-model"; -import { Command } from "prosemirror-state"; +import { Command, TextSelection } from "prosemirror-state"; import { MarkdownSerializerState } from "../lib/markdown/serializer"; import mathRule, { REGEX_BLOCK_MATH_DOLLARS } from "../rules/math"; import Node from "./Node"; @@ -24,7 +24,14 @@ export default class MathBlock extends Node { commands({ type }: { type: NodeType }) { return (): Command => (state, dispatch) => { - dispatch?.(state.tr.replaceSelectionWith(type.create()).scrollIntoView()); + const tr = state.tr.replaceSelectionWith(type.create()); + dispatch?.( + tr + .setSelection( + TextSelection.near(tr.doc.resolve(state.selection.from - 1)) + ) + .scrollIntoView() + ); return true; }; }