mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: disable apply operation when setting editable = false
This commit is contained in:
parent
6230d0ad9f
commit
ab0131c19c
@ -72,6 +72,8 @@ class EditorState {
|
|||||||
// TODO: only for testing.
|
// TODO: only for testing.
|
||||||
bool disableSealTimer = false;
|
bool disableSealTimer = false;
|
||||||
|
|
||||||
|
bool editable = true;
|
||||||
|
|
||||||
Selection? get cursorSelection {
|
Selection? get cursorSelection {
|
||||||
return _cursorSelection;
|
return _cursorSelection;
|
||||||
}
|
}
|
||||||
@ -112,6 +114,9 @@ class EditorState {
|
|||||||
/// should record the transaction in undo/redo stack.
|
/// should record the transaction in undo/redo stack.
|
||||||
apply(Transaction transaction,
|
apply(Transaction transaction,
|
||||||
[ApplyOptions options = const ApplyOptions()]) {
|
[ApplyOptions options = const ApplyOptions()]) {
|
||||||
|
if (!editable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// TODO: validate the transation.
|
// TODO: validate the transation.
|
||||||
for (final op in transaction.operations) {
|
for (final op in transaction.operations) {
|
||||||
_applyOperation(op);
|
_applyOperation(op);
|
||||||
|
@ -72,6 +72,7 @@ class _AppFlowyEditorState extends State<AppFlowyEditor> {
|
|||||||
editorState.selectionMenuItems = widget.selectionMenuItems;
|
editorState.selectionMenuItems = widget.selectionMenuItems;
|
||||||
editorState.editorStyle = widget.editorStyle;
|
editorState.editorStyle = widget.editorStyle;
|
||||||
editorState.service.renderPluginService = _createRenderPlugin();
|
editorState.service.renderPluginService = _createRenderPlugin();
|
||||||
|
editorState.editable = widget.editable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -84,6 +85,7 @@ class _AppFlowyEditorState extends State<AppFlowyEditor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
editorState.editorStyle = widget.editorStyle;
|
editorState.editorStyle = widget.editorStyle;
|
||||||
|
editorState.editable = widget.editable;
|
||||||
services = null;
|
services = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user