mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-04-25 07:07:32 -04:00
fix: some UI issues
This commit is contained in:
parent
add9f16717
commit
05b0160b80
4 changed files with 39 additions and 32 deletions
|
@ -73,8 +73,10 @@ extension PasteFromPlainText on EditorState {
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkToShowPasteAsMenu(Node node) {
|
void checkToShowPasteAsMenu(Node node) {
|
||||||
|
if (selection == null || !selection!.isCollapsed) return;
|
||||||
|
if (UniversalPlatform.isMobile) return;
|
||||||
final href = _getLinkFromNode(node);
|
final href = _getLinkFromNode(node);
|
||||||
if (href != null && !UniversalPlatform.isMobile) {
|
if (href != null) {
|
||||||
final context = document.root.context;
|
final context = document.root.context;
|
||||||
if (context != null && context.mounted) {
|
if (context != null && context.mounted) {
|
||||||
PasteAsMenuService(context: context, editorState: this).show(href);
|
PasteAsMenuService(context: context, editorState: this).show(href);
|
||||||
|
|
|
@ -64,10 +64,10 @@ class LinkEmbedBlockComponentState extends State<LinkEmbedBlockComponent>
|
||||||
parser.addLinkInfoListener((v) {
|
parser.addLinkInfoListener((v) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
linkInfo = v;
|
if (v.isEmpty() && linkInfo.isEmpty()) {
|
||||||
if (v.isEmpty()) {
|
|
||||||
status = EmbedLoadingStatus.error;
|
status = EmbedLoadingStatus.error;
|
||||||
} else {
|
} else {
|
||||||
|
linkInfo = v;
|
||||||
status = EmbedLoadingStatus.idle;
|
status = EmbedLoadingStatus.idle;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -197,27 +197,29 @@ class LinkEmbedBlockComponentState extends State<LinkEmbedBlockComponent>
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
HSpace(12),
|
HSpace(12),
|
||||||
Column(
|
Expanded(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
mainAxisSize: MainAxisSize.min,
|
||||||
FlowyText(
|
children: [
|
||||||
linkInfo.siteName ?? '',
|
FlowyText(
|
||||||
color: textScheme.primary,
|
linkInfo.siteName ?? '',
|
||||||
fontSize: 14,
|
color: textScheme.primary,
|
||||||
figmaLineHeight: 20,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w600,
|
figmaLineHeight: 20,
|
||||||
overflow: TextOverflow.ellipsis,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
overflow: TextOverflow.ellipsis,
|
||||||
VSpace(4),
|
),
|
||||||
FlowyText.regular(
|
VSpace(4),
|
||||||
url,
|
FlowyText.regular(
|
||||||
color: textScheme.secondary,
|
url,
|
||||||
fontSize: 12,
|
color: textScheme.secondary,
|
||||||
figmaLineHeight: 16,
|
fontSize: 12,
|
||||||
overflow: TextOverflow.ellipsis,
|
figmaLineHeight: 16,
|
||||||
),
|
overflow: TextOverflow.ellipsis,
|
||||||
],
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -32,11 +32,12 @@ class LinkParser {
|
||||||
imageUrl: previewData.image?.url,
|
imageUrl: previewData.image?.url,
|
||||||
faviconUrl: favicon?.url,
|
faviconUrl: favicon?.url,
|
||||||
);
|
);
|
||||||
await _cache.set(url, linkInfo);
|
if (!linkInfo.isEmpty()) await _cache.set(url, linkInfo);
|
||||||
refreshLinkInfo(linkInfo);
|
refreshLinkInfo(linkInfo);
|
||||||
return linkInfo;
|
return linkInfo;
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
Log.error('get link info error: ', e, s);
|
Log.error('get link info error: ', e, s);
|
||||||
|
refreshLinkInfo(LinkInfo());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,6 +100,7 @@ class LinkInfo {
|
||||||
return FlowyNetworkSvg(
|
return FlowyNetworkSvg(
|
||||||
iconUrl,
|
iconUrl,
|
||||||
height: size.height,
|
height: size.height,
|
||||||
|
width: size.width,
|
||||||
errorWidget: const FlowySvg(FlowySvgs.toolbar_link_earth_m),
|
errorWidget: const FlowySvg(FlowySvgs.toolbar_link_earth_m),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -106,6 +108,7 @@ class LinkInfo {
|
||||||
url: iconUrl,
|
url: iconUrl,
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
height: size.height,
|
height: size.height,
|
||||||
|
width: size.width,
|
||||||
errorWidgetBuilder: (context, error, stackTrace) =>
|
errorWidgetBuilder: (context, error, stackTrace) =>
|
||||||
const FlowySvg(FlowySvgs.toolbar_link_earth_m),
|
const FlowySvg(FlowySvgs.toolbar_link_earth_m),
|
||||||
);
|
);
|
||||||
|
|
|
@ -43,7 +43,7 @@ class _MentionLinkBlockState extends State<MentionLinkBlock> {
|
||||||
final parser = LinkParser();
|
final parser = LinkParser();
|
||||||
_LoadingStatus status = _LoadingStatus.loading;
|
_LoadingStatus status = _LoadingStatus.loading;
|
||||||
final previewController = PopoverController();
|
final previewController = PopoverController();
|
||||||
LinkInfo? linkInfo;
|
LinkInfo linkInfo = LinkInfo();
|
||||||
bool isHovering = false;
|
bool isHovering = false;
|
||||||
int previewFocusNum = 0;
|
int previewFocusNum = 0;
|
||||||
bool isPreviewHovering = false;
|
bool isPreviewHovering = false;
|
||||||
|
@ -60,7 +60,7 @@ class _MentionLinkBlockState extends State<MentionLinkBlock> {
|
||||||
int get index => widget.index;
|
int get index => widget.index;
|
||||||
|
|
||||||
bool get readyForPreview =>
|
bool get readyForPreview =>
|
||||||
status == _LoadingStatus.idle && !(linkInfo?.isEmpty() ?? true);
|
status == _LoadingStatus.idle && !linkInfo.isEmpty();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
@ -69,10 +69,10 @@ class _MentionLinkBlockState extends State<MentionLinkBlock> {
|
||||||
parser.addLinkInfoListener((v) {
|
parser.addLinkInfoListener((v) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
linkInfo = v;
|
if (v.isEmpty() && linkInfo.isEmpty()) {
|
||||||
if (v.isEmpty()) {
|
|
||||||
status = _LoadingStatus.error;
|
status = _LoadingStatus.error;
|
||||||
} else {
|
} else {
|
||||||
|
linkInfo = v;
|
||||||
status = _LoadingStatus.idle;
|
status = _LoadingStatus.idle;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -112,7 +112,7 @@ class _MentionLinkBlockState extends State<MentionLinkBlock> {
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
popupBuilder: (context) => readyForPreview
|
popupBuilder: (context) => readyForPreview
|
||||||
? MentionLinkPreview(
|
? MentionLinkPreview(
|
||||||
linkInfo: linkInfo ?? LinkInfo(),
|
linkInfo: linkInfo,
|
||||||
showAtBottom: showAtBottom,
|
showAtBottom: showAtBottom,
|
||||||
triggerSize: getSizeFromKey(),
|
triggerSize: getSizeFromKey(),
|
||||||
onEnter: (e) {
|
onEnter: (e) {
|
||||||
|
@ -170,7 +170,7 @@ class _MentionLinkBlockState extends State<MentionLinkBlock> {
|
||||||
HSpace(4),
|
HSpace(4),
|
||||||
Flexible(
|
Flexible(
|
||||||
child: FlowyText(
|
child: FlowyText(
|
||||||
linkInfo?.siteName ?? url,
|
linkInfo.siteName ?? url,
|
||||||
color: theme.textColorScheme.primary,
|
color: theme.textColorScheme.primary,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
figmaLineHeight: 20,
|
figmaLineHeight: 20,
|
||||||
|
@ -194,7 +194,7 @@ class _MentionLinkBlockState extends State<MentionLinkBlock> {
|
||||||
child: const CircularProgressIndicator(strokeWidth: 1),
|
child: const CircularProgressIndicator(strokeWidth: 1),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
icon = linkInfo?.buildIconWidget() ?? defaultWidget;
|
icon = linkInfo.buildIconWidget();
|
||||||
}
|
}
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue