mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Disable undo/redo in detached formula editor
Summary: Undo and redo were causing errors to be thrown while the editor was detached. In the interest of time, we'll disable undo/redo until we have a chance to look at whether we can support it in the editor. Test Plan: Manual. Reviewers: JakubSerafin Reviewed By: JakubSerafin Differential Revision: https://phab.getgrist.com/D3959
This commit is contained in:
@@ -70,6 +70,14 @@ export function createTopBarDoc(owner: MultiHolder, appModel: AppModel, pageMode
|
||||
return module.SearchModelImpl.create(use.owner, gristDoc);
|
||||
});
|
||||
|
||||
const isUndoRedoAvailable = Computed.create(owner, use => {
|
||||
const gristDoc = use(pageModel.gristDoc);
|
||||
if (!gristDoc) { return false; }
|
||||
|
||||
const undoStack = gristDoc.getUndoStack();
|
||||
return !use(undoStack.isDisabled);
|
||||
});
|
||||
|
||||
return [
|
||||
// TODO Before gristDoc is loaded, we could show doc-name without the page. For now, we delay
|
||||
// showing of breadcrumbs until gristDoc is loaded.
|
||||
@@ -98,14 +106,14 @@ export function createTopBarDoc(owner: MultiHolder, appModel: AppModel, pageMode
|
||||
topBarUndoBtn('Undo',
|
||||
dom.on('click', () => state.isUndoDisabled.get() || allCommands.undo.run()),
|
||||
hoverTooltip('Undo', {key: 'topBarBtnTooltip'}),
|
||||
cssHoverCircle.cls('-disabled', state.isUndoDisabled),
|
||||
testId('undo')
|
||||
cssHoverCircle.cls('-disabled', use => use(state.isUndoDisabled) || !use(isUndoRedoAvailable)),
|
||||
testId('undo'),
|
||||
),
|
||||
topBarUndoBtn('Redo',
|
||||
dom.on('click', () => state.isRedoDisabled.get() || allCommands.redo.run()),
|
||||
hoverTooltip('Redo', {key: 'topBarBtnTooltip'}),
|
||||
cssHoverCircle.cls('-disabled', state.isRedoDisabled),
|
||||
testId('redo')
|
||||
cssHoverCircle.cls('-disabled', use => use(state.isRedoDisabled) || !use(isUndoRedoAvailable)),
|
||||
testId('redo'),
|
||||
),
|
||||
cssSpacer(),
|
||||
]),
|
||||
|
||||
Reference in New Issue
Block a user