Skip to content

Commit

Permalink
chore: configrable visibility of reference node popup (#8711)
Browse files Browse the repository at this point in the history
This PR make the visibility of reference node popup can be configure. Related to [BS-1730](https://linear.app/affine-design/issue/BS-1730/%E7%A6%81%E7%94%A8-block-yuan%E7%B4%A0%E7%9A%84-toolbar)
  • Loading branch information
L-Sun committed Nov 12, 2024
1 parent 91795b9 commit 217e2cd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ export const ReferenceInlineSpecExtension = InlineSpecExtension(
if (config.interactable !== undefined) {
configProvider.setInteractable(config.interactable);
}
if (config.hidePopup !== undefined) {
configProvider.setHidePopup(config.hidePopup);
}
return {
name: 'reference',
schema: z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface ReferenceNodeConfig {
customIcon?: ((reference: AffineReference) => TemplateResult) | null;
customTitle?: ((reference: AffineReference) => string) | null;
interactable?: boolean;
hidePopup?: boolean;
}

export const ReferenceNodeConfigIdentifier =
Expand All @@ -35,6 +36,8 @@ export class ReferenceNodeConfigProvider {

private _customTitle: ((reference: AffineReference) => string) | null = null;

private _hidePopup = false;

private _interactable = true;

get customContent() {
Expand All @@ -53,6 +56,10 @@ export class ReferenceNodeConfigProvider {
return this.std.doc;
}

get hidePopup() {
return this._hidePopup;
}

get interactable() {
return this._interactable;
}
Expand All @@ -71,6 +78,10 @@ export class ReferenceNodeConfigProvider {
this._customTitle = title;
}

setHidePopup(hidePopup: boolean) {
this._hidePopup = hidePopup;
}

setInteractable(interactable: boolean) {
this._interactable = interactable;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export class AffineReference extends WithDisposable(ShadowlessElement) {
this,
({ abortController }) => {
if (
this.config.hidePopup ||
this.doc?.readonly ||
this.closest('.prevent-reference-popup') ||
!this.selfInlineRange ||
Expand Down

0 comments on commit 217e2cd

Please sign in to comment.