|
@@ -73,6 +73,7 @@ class EditorState {
|
|
|
|
|
|
// TODO: only for testing.
|
|
// TODO: only for testing.
|
|
bool disableSealTimer = false;
|
|
bool disableSealTimer = false;
|
|
|
|
+ bool disbaleRules = false;
|
|
|
|
|
|
bool editable = true;
|
|
bool editable = true;
|
|
|
|
|
|
@@ -124,6 +125,7 @@ class EditorState {
|
|
Transaction transaction, {
|
|
Transaction transaction, {
|
|
ApplyOptions options = const ApplyOptions(recordUndo: true),
|
|
ApplyOptions options = const ApplyOptions(recordUndo: true),
|
|
ruleCount = 0,
|
|
ruleCount = 0,
|
|
|
|
+ withUpdateCursor = true,
|
|
}) {
|
|
}) {
|
|
if (!editable) {
|
|
if (!editable) {
|
|
return;
|
|
return;
|
|
@@ -137,7 +139,9 @@ class EditorState {
|
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
_applyRules(ruleCount);
|
|
_applyRules(ruleCount);
|
|
- updateCursorSelection(transaction.afterSelection);
|
|
|
|
|
|
+ if (withUpdateCursor) {
|
|
|
|
+ updateCursorSelection(transaction.afterSelection);
|
|
|
|
+ }
|
|
});
|
|
});
|
|
|
|
|
|
if (options.recordUndo) {
|
|
if (options.recordUndo) {
|
|
@@ -187,7 +191,7 @@ class EditorState {
|
|
|
|
|
|
void _applyRules(int ruleCount) {
|
|
void _applyRules(int ruleCount) {
|
|
// Set a maximum count to prevent a dead loop.
|
|
// Set a maximum count to prevent a dead loop.
|
|
- if (ruleCount >= 5) {
|
|
|
|
|
|
+ if (ruleCount >= 5 || disbaleRules) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -197,7 +201,7 @@ class EditorState {
|
|
_insureLastNodeEditable(tr);
|
|
_insureLastNodeEditable(tr);
|
|
|
|
|
|
if (tr.operations.isNotEmpty) {
|
|
if (tr.operations.isNotEmpty) {
|
|
- apply(tr, ruleCount: ruleCount + 1);
|
|
|
|
|
|
+ apply(tr, ruleCount: ruleCount + 1, withUpdateCursor: false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|