Links and focus
The link action and ⌘/Ctrl K call controller.linkRequestHandler. The typed DocumentEditor connects the shared LinkUrlDialog for you; with the runtime editor, connect it or your own popover.
dart
import 'package:flutter/material.dart';
import 'package:vyuh_document_editor/vyuh_document_editor.dart';
import 'package:vyuh_document_editor/document_editor_workspace.dart'
show LinkUrlDialog;
void connectLinkDialog(
BuildContext context,
DocumentEditorController controller,
FocusNode editorFocus,
) {
controller.linkRequestHandler = (request) async {
final edit = await showDialog<DocumentLinkEdit>(
context: context,
builder: (_) => LinkUrlDialog(
request: request,
bookmarks: controller.document.bookmarks,
),
);
if (context.mounted) editorFocus.requestFocus();
return edit; // null cancels; DocumentLinkEdit.remove() removes the link.
};
}
// Use the same host-owned FocusNode in DocumentEditor(focusNode: editorFocus).
// Call connectLinkDialog from your mounted host, before requesting a link.Request and result
The handler receives a DocumentLinkRequest and returns a DocumentLinkEdit:
| Outcome | Behavior |
|---|---|
| Apply an edit | Update the destination and editable text together. |
Return null | Cancel without changing content. |
DocumentLinkEdit.remove() | Remove the link while preserving its text label. |
Text links edit their label too; image links edit only the destination. controller.setLink applies a URL without asking your UI.
Return focus
Pass your own FocusNode to DocumentEditor(focusNode:) and return focus to it when your dialog closes. linkOpener is the separate binding that opens a destination.