AppFlowy/frontend/appflowy_flutter/lib/shared/clipboard_state.dart
Mathias Mogensen 068500df84
feat: inline sub page mention (#6567)
* 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>
2024-10-21 16:34:30 +08:00

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;
}
}
}