Skip to content

Commit

Permalink
Outlaw undo / redo (#83)
Browse files Browse the repository at this point in the history
* Outlaw undo / redo

might not actually work

* Actually prevent undo/redo
  • Loading branch information
lukejacksonn authored Jan 27, 2025
1 parent b6e8ad2 commit 599af2b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { vim } from '@replit/codemirror-vim';
import { highlightExtension } from '@strudel/codemirror';
import { EditorView, minimalSetup } from 'codemirror';
import { yCollab } from 'y-codemirror.next';
import { UndoManager } from 'yjs';
import './style.css';
import theme from './themes/strudel-theme.js';
import { highlightMiniLocations, updateMiniLocations } from '@strudel/codemirror';
Expand Down Expand Up @@ -64,6 +63,10 @@ export class PastaMirror {
...initialSettings,
Prec.highest(
keymap.of([
// Disable Undo/Redo
{ key: 'Mod-z', preventDefault: true, run: () => true }, // Disable Undo (Ctrl+Z / Cmd+Z)
{ key: 'Mod-Shift-z', preventDefault: true, run: () => true }, // Disable Redo (Ctrl+Shift+Z / Cmd+Shift+Z)
{ key: 'Mod-y', preventDefault: true, run: () => true }, // Disable Redo (Ctrl+Y)
// stop pane
...['Ctrl-.', 'Alt-.'].map((key) => ({
key,
Expand Down Expand Up @@ -240,15 +243,13 @@ export class PastaMirror {
flokBasicSetup(doc) {
doc.collabCompartment = new Compartment(); // yeah this is dirty
const text = doc.getText();
const undoManager = new UndoManager(text);
const web = true;

// TODO: automatically set scrollIntoView, based on mode
// set to true in boxed mode, but only when boxed mode is actually visible
// we don't want cursor tracking on mobile!
const scrollIntoView = getSettings().trackRemoteCursors;
const collab = yCollab(text, doc.session.awareness, {
undoManager,
showLocalCaret: true,
scrollIntoView,
});
Expand Down

0 comments on commit 599af2b

Please sign in to comment.