Skip to content

Commit

Permalink
fix(blocks): should show original doc title when hovering title button (
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Dec 10, 2024
1 parent e0dfa75 commit ef4a773
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ export class ReferencePopup extends WithDisposable(LitElement) {
aria-label="Doc title"
.hover=${false}
.labelHeight=${'20px'}
.tooltip=${'Original linked doc title'}
.tooltip=${this.docTitle}
@click=${this._openDoc}
>
<span class="label">${this.docTitle}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,15 @@ export class EdgelessChangeEmbedCardButton extends WithDisposable(LitElement) {
return undefined;
}

get _originalDocTitle() {
const model = this.model;
const doc = isInternalEmbedModel(model)
? this.std.collection.getDoc(model.pageId)
: null;

return doc?.meta?.title || 'Untitled';
}

private get _viewType(): 'inline' | 'embed' | 'card' {
if (this._isCardView) {
return 'card';
Expand Down Expand Up @@ -706,13 +715,10 @@ export class EdgelessChangeEmbedCardButton extends WithDisposable(LitElement) {
aria-label="Doc title"
.hover=${false}
.labelHeight=${'20px'}
.tooltip=${'Original linked doc title'}
.tooltip=${this._originalDocTitle}
@click=${this._open}
>
<span class="label"
>${this.std.collection.getDoc(model.pageId)?.meta?.title ||
'Untitled'}</span
>
<span class="label">${this._originalDocTitle}</span>
</editor-icon-button>
`
: nothing,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,17 @@ export class EmbedCardToolbar extends WidgetComponent<
return undefined;
}

get _originalDocTitle() {
const model = this.focusModel;
if (!model) return undefined;

const doc = isInternalEmbedModel(model)
? this.std.collection.getDoc(model.pageId)
: null;

return doc?.meta?.title || 'Untitled';
}

private get _selection() {
return this.host.selection;
}
Expand Down Expand Up @@ -758,13 +769,10 @@ export class EmbedCardToolbar extends WidgetComponent<
aria-label="Doc title"
.hover=${false}
.labelHeight=${'20px'}
.tooltip=${'Original linked doc title'}
.tooltip=${this._originalDocTitle}
@click=${this.focusBlock?.open}
>
<span class="label"
>${this.std.collection.getDoc(model.pageId)?.meta?.title ||
'Untitled'}</span
>
<span class="label">${this._originalDocTitle}</span>
</editor-icon-button>
`
: nothing,
Expand Down

0 comments on commit ef4a773

Please sign in to comment.