mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
Merge pull request #787 from AppFlowy-IO/feat/add-default-impl-for-image
Feat: add default impl for image
This commit is contained in:
commit
0bf4a79ec9
@ -55,26 +55,22 @@ class _ImageNodeWidgetState extends State<ImageNodeWidget> with Selectable {
|
||||
|
||||
@override
|
||||
Position end() {
|
||||
// TODO: implement end
|
||||
throw UnimplementedError();
|
||||
return Position(path: node.path, offset: 0);
|
||||
}
|
||||
|
||||
@override
|
||||
Position start() {
|
||||
// TODO: implement start
|
||||
throw UnimplementedError();
|
||||
return Position(path: node.path, offset: 0);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Rect> getRectsInSelection(Selection selection) {
|
||||
// TODO: implement getRectsInSelection
|
||||
throw UnimplementedError();
|
||||
return [];
|
||||
}
|
||||
|
||||
@override
|
||||
Selection getSelectionInRange(Offset start, Offset end) {
|
||||
// TODO: implement getSelectionInRange
|
||||
throw UnimplementedError();
|
||||
return Selection.collapsed(Position(path: node.path, offset: 0));
|
||||
}
|
||||
|
||||
@override
|
||||
@ -82,12 +78,6 @@ class _ImageNodeWidgetState extends State<ImageNodeWidget> with Selectable {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Rect getCursorRectInPosition(Position position) {
|
||||
// TODO: implement getCursorRectInPosition
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Position getPositionInOffset(Offset start) {
|
||||
return Position(path: node.path, offset: 0);
|
||||
|
@ -32,7 +32,8 @@ class LinkNodeWidget extends StatefulWidget {
|
||||
State<LinkNodeWidget> createState() => _YouTubeLinkNodeWidgetState();
|
||||
}
|
||||
|
||||
class _YouTubeLinkNodeWidgetState extends State<LinkNodeWidget> with Selectable {
|
||||
class _YouTubeLinkNodeWidgetState extends State<LinkNodeWidget>
|
||||
with Selectable {
|
||||
Node get node => widget.node;
|
||||
EditorState get editorState => widget.editorState;
|
||||
String get src => widget.node.attributes['youtube_link'] as String;
|
||||
@ -66,12 +67,6 @@ class _YouTubeLinkNodeWidgetState extends State<LinkNodeWidget> with Selectable
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Rect getCursorRectInPosition(Position position) {
|
||||
// TODO: implement getCursorRectInPosition
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Position getPositionInOffset(Offset start) {
|
||||
// TODO: implement getPositionInOffset
|
||||
@ -85,16 +80,16 @@ class _YouTubeLinkNodeWidgetState extends State<LinkNodeWidget> with Selectable
|
||||
|
||||
late final PodPlayerController controller;
|
||||
|
||||
@override
|
||||
@override
|
||||
void initState() {
|
||||
controller = PodPlayerController(
|
||||
playVideoFrom: PlayVideoFrom.network(
|
||||
src,
|
||||
src,
|
||||
),
|
||||
)..initialise();
|
||||
super.initState();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
||||
Widget _build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
|
@ -11,8 +11,8 @@ mixin DefaultSelectable {
|
||||
Position getPositionInOffset(Offset start) =>
|
||||
forward.getPositionInOffset(start);
|
||||
|
||||
Rect getCursorRectInPosition(Position position) =>
|
||||
forward.getCursorRectInPosition(position).shift(baseOffset);
|
||||
Rect? getCursorRectInPosition(Position position) =>
|
||||
forward.getCursorRectInPosition(position)?.shift(baseOffset);
|
||||
|
||||
List<Rect> getRectsInSelection(Selection selection) => forward
|
||||
.getRectsInSelection(selection)
|
||||
|
@ -76,7 +76,7 @@ class _FlowyRichTextState extends State<FlowyRichText> with Selectable {
|
||||
path: widget.textNode.path, offset: widget.textNode.toRawString().length);
|
||||
|
||||
@override
|
||||
Rect getCursorRectInPosition(Position position) {
|
||||
Rect? getCursorRectInPosition(Position position) {
|
||||
final textPosition = TextPosition(offset: position.offset);
|
||||
final cursorOffset =
|
||||
_renderParagraph.getOffsetForCaret(textPosition, Rect.zero);
|
||||
|
@ -25,7 +25,9 @@ mixin Selectable<T extends StatefulWidget> on State<T> {
|
||||
return null;
|
||||
}
|
||||
|
||||
Rect getCursorRectInPosition(Position position);
|
||||
Rect? getCursorRectInPosition(Position position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Offset localToGlobal(Offset offset);
|
||||
|
||||
|
@ -246,9 +246,11 @@ class _FlowyInputState extends State<FlowyInput>
|
||||
final size = renderBox.size;
|
||||
final transform = renderBox.getTransformTo(null);
|
||||
final rect = selectable.getCursorRectInPosition(selection.end);
|
||||
_textInputConnection
|
||||
?..setEditableSizeAndTransform(size, transform)
|
||||
..setCaretRect(rect);
|
||||
if (rect != null) {
|
||||
_textInputConnection
|
||||
?..setEditableSizeAndTransform(size, transform)
|
||||
..setCaretRect(rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,6 +71,9 @@ FlowyKeyEventHandler slashShortcutHandler = (editorState, event) {
|
||||
}
|
||||
|
||||
final rect = selectable.getCursorRectInPosition(selection.start);
|
||||
if (rect == null) {
|
||||
return KeyEventResult.ignored;
|
||||
}
|
||||
final offset = selectable.localToGlobal(rect.topLeft);
|
||||
|
||||
TransactionBuilder(editorState)
|
||||
|
Loading…
Reference in New Issue
Block a user