mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-06-29 02:03:10 -04:00
* feat: inline sub page mention * fix: disable editing documents in trash * fix: duplicate block behavior * refactor: clean up code * feat: use formatText function instead of modify delta manually * fix: paste behavior format mention * fix: default icon for mentioned pages * fix: view new parent turn into page reference * test: add base test * chore: add feature flag * chore: default flag to on * fix: minor fixes to behavior * fix: review and code cleanup * fix: dart linter * fix: content is required * test: use doc title to rename page * test: add test coverage * test: fix wrong expect --------- Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io>
46 lines
1 KiB
Dart
46 lines
1 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
|
|
/// Class to hold the state of the Clipboard.
|
|
///
|
|
/// Essentially for document in-app json paste, we need to be able
|
|
/// to differentiate between a cut-paste and a copy-paste.
|
|
///
|
|
/// When a cut-pase has occurred, the next paste operation should be
|
|
/// seen as a copy-paste.
|
|
///
|
|
class ClipboardState {
|
|
ClipboardState();
|
|
|
|
bool _isCut = false;
|
|
|
|
bool get isCut => _isCut;
|
|
|
|
final ValueNotifier<bool> isHandlingPasteNotifier = ValueNotifier(false);
|
|
bool get isHandlingPaste => isHandlingPasteNotifier.value;
|
|
|
|
final Set<String> _handlingPasteIds = {};
|
|
|
|
void dispose() {
|
|
isHandlingPasteNotifier.dispose();
|
|
}
|
|
|
|
void didCut() {
|
|
_isCut = true;
|
|
}
|
|
|
|
void didPaste() {
|
|
_isCut = false;
|
|
}
|
|
|
|
void startHandlingPaste(String id) {
|
|
_handlingPasteIds.add(id);
|
|
isHandlingPasteNotifier.value = true;
|
|
}
|
|
|
|
void endHandlingPaste(String id) {
|
|
_handlingPasteIds.remove(id);
|
|
if (_handlingPasteIds.isEmpty) {
|
|
isHandlingPasteNotifier.value = false;
|
|
}
|
|
}
|
|
}
|