Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
Merge pull request #749 from AppFlowy-IO/feat/transaction-to-json
Vincent Chan9b764731e78e
diff --cc frontend/app_flowy/packages/flowy_editor/lib/operation/transaction_builder.dartindex e70dfc411a,2877e62588..3b88ed1627--- a/frontend/app_flowy/packages/flowy_editor/lib/operation/transaction_builder.dart+++ b/frontend/app_flowy/packages/flowy_editor/lib/operation/transaction_builder.dart@@@ -45,13 -44,9 +44,13 @@@ class TransactionBuilderdeleteNode(Node node) {beforeSelection = state.cursorSelection;- add(DeleteOperation(path: node.path, removedValue: node));+ add(DeleteOperation(node.path, node));}+ deleteNodes(List<Node> nodes) {+ nodes.forEach(deleteNode);+ }+textEdit(TextNode node, Delta Function() f) {beforeSelection = state.cursorSelection;final path = node.path;@@@ -60,31 -55,11 +59,31 @@@final inverted = delta.invert(node.delta);- add(TextEditOperation(path: path, delta: delta, inverted: inverted));+ add(TextEditOperation(path, delta, inverted));}- insertText(TextNode node, int index, String content) {- textEdit(node, () => Delta().retain(index).insert(content));+ mergeText(TextNode firstNode, TextNode secondNode,+ {int? firstOffset, int secondOffset = 0}) {+ final firstLength = firstNode.delta.length;+ final secondLength = secondNode.delta.length;+ textEdit(+ firstNode,+ () => Delta()+ ..retain(firstOffset ?? firstLength)+ ..delete(firstLength - (firstOffset ?? firstLength))+ ..addAll(secondNode.delta.slice(secondOffset, secondLength).operations),+ );+ afterSelection = Selection.collapsed(+ Position(+ path: firstNode.path,+ offset: firstOffset ?? firstLength,+ ),+ );+ }++ insertText(TextNode node, int index, String content,+ [Attributes? attributes]) {+ textEdit(node, () => Delta().retain(index).insert(content, attributes));afterSelection = Selection.collapsed(Position(path: node.path, offset: index + content.length));}