@blocksuite/affine-components
Advanced tools
# @blocksuite/affine-components | ||
## 0.17.16 | ||
### Patch Changes | ||
- ce9a242: Fix bugs and improve experience: | ||
- fix slash menu and @ menu issues with IME [#8444](https://github.com/toeverything/blocksuite/pull/8444) | ||
- improve trigger way of latex editor [#8445](https://github.com/toeverything/blocksuite/pull/8445) | ||
- support in-app link jump [#8499](https://github.com/toeverything/blocksuite/pull/8449) | ||
- some ui improvements [#8446](https://github.com/toeverything/blocksuite/pull/8446), [#8450](https://github.com/toeverything/blocksuite/pull/8450) | ||
- Updated dependencies [ce9a242] | ||
- @blocksuite/affine-model@0.17.16 | ||
- @blocksuite/affine-shared@0.17.16 | ||
- @blocksuite/block-std@0.17.16 | ||
- @blocksuite/global@0.17.16 | ||
- @blocksuite/inline@0.17.16 | ||
- @blocksuite/store@0.17.16 | ||
## 0.17.15 | ||
@@ -4,0 +23,0 @@ |
@@ -430,3 +430,3 @@ /* eslint-disable no-useless-escape */ | ||
index: startIndex, | ||
length: 2 + content.length + 2, | ||
length: 2 + content.length + 2 + 1, | ||
}); | ||
@@ -433,0 +433,0 @@ inlineEditor.insertText({ |
import { ShadowlessElement } from '@blocksuite/block-std'; | ||
import { type DeltaInsert } from '@blocksuite/inline'; | ||
import { type StyleInfo, styleMap } from 'lit/directives/style-map.js'; | ||
import { type StyleInfo } from 'lit/directives/style-map.js'; | ||
import type { AffineTextAttributes } from '../../../extension/index.js'; | ||
export declare function affineTextStyles(props: AffineTextAttributes, override?: Readonly<StyleInfo>): ReturnType<typeof styleMap>; | ||
export declare function affineTextStyles(props: AffineTextAttributes, override?: Readonly<StyleInfo>): StyleInfo; | ||
export declare class AffineText extends ShadowlessElement { | ||
@@ -7,0 +7,0 @@ render(): import("lit-html").TemplateResult<1>; |
@@ -60,3 +60,3 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { | ||
} | ||
return styleMap({ | ||
return { | ||
'font-weight': props.bold ? 'bolder' : 'inherit', | ||
@@ -69,3 +69,3 @@ 'font-style': props.italic ? 'italic' : 'normal', | ||
...override, | ||
}); | ||
}; | ||
} | ||
@@ -87,7 +87,7 @@ let AffineText = (() => { | ||
? affineTextStyles(this.delta.attributes) | ||
: styleMap({}); | ||
: {}; | ||
// we need to avoid \n appearing before and after the span element, which will | ||
// cause the unexpected space | ||
if (this.delta.attributes?.code) { | ||
return html `<code style=${style} | ||
return html `<code style=${styleMap(style)} | ||
><v-text .str=${this.delta.insert}></v-text | ||
@@ -98,3 +98,3 @@ ></code>`; | ||
// cause the unexpected space | ||
return html `<span style=${style} | ||
return html `<span style=${styleMap(style)} | ||
><v-text .str=${this.delta.insert}></v-text | ||
@@ -101,0 +101,0 @@ ></span>`; |
import type { BlockComponent } from '@blocksuite/block-std'; | ||
import { ShadowlessElement } from '@blocksuite/block-std'; | ||
import { type DeltaInsert } from '@blocksuite/inline'; | ||
import type { AffineTextAttributes } from '../../../../extension/index.js'; | ||
import { type AffineTextAttributes } from '../../../../extension/index.js'; | ||
export declare class AffineLink extends ShadowlessElement { | ||
static styles: import("lit").CSSResult; | ||
private _identified; | ||
private _onClick; | ||
private _onMouseUp; | ||
private _referenceInfo; | ||
private _whenHover; | ||
@@ -13,3 +17,4 @@ get block(): BlockComponent<import("@blocksuite/store").BlockModel<object, object & {}>, import("@blocksuite/block-std").BlockService, string> | null | undefined; | ||
get std(): import("@blocksuite/block-std").BlockStdScope | undefined; | ||
private _onMouseUp; | ||
private _identify; | ||
private _renderLink; | ||
render(): import("lit-html").TemplateResult<1>; | ||
@@ -16,0 +21,0 @@ accessor delta: DeltaInsert<AffineTextAttributes>; |
@@ -35,2 +35,3 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { | ||
}; | ||
import { ParseDocUrlProvider } from '@blocksuite/affine-shared/services'; | ||
import { BLOCK_ID_ATTR, ShadowlessElement } from '@blocksuite/block-std'; | ||
@@ -43,2 +44,3 @@ import { INLINE_ROOT_ATTR, ZERO_WIDTH_SPACE, } from '@blocksuite/inline'; | ||
import { HoverController } from '../../../../../hover/index.js'; | ||
import { RefNodeSlotsProvider, } from '../../../../extension/index.js'; | ||
import { affineTextStyles } from '../affine-text.js'; | ||
@@ -79,7 +81,3 @@ import { toggleLinkPopup } from './link-popup/toggle-link-popup.js'; | ||
get link() { | ||
const link = this.delta.attributes?.link; | ||
if (!link) { | ||
return ''; | ||
} | ||
return link; | ||
return this.delta.attributes?.link ?? ''; | ||
} | ||
@@ -94,14 +92,33 @@ get selfInlineRange() { | ||
} | ||
// see https://github.com/toeverything/AFFiNE/issues/1540 | ||
_onMouseUp() { | ||
const anchorElement = this.querySelector('a'); | ||
if (!anchorElement || !anchorElement.isContentEditable) | ||
// Identify if url is an in-app link | ||
_identify() { | ||
const link = this.link; | ||
if (!link) | ||
return; | ||
anchorElement.contentEditable = 'false'; | ||
setTimeout(() => { | ||
anchorElement.removeAttribute('contenteditable'); | ||
}, 0); | ||
const result = this.std | ||
?.getOptional(ParseDocUrlProvider) | ||
?.parseDocUrl(link); | ||
if (!result) | ||
return; | ||
const { docId: pageId, mode, blockIds, elementIds } = result; | ||
let params = undefined; | ||
if (mode || blockIds?.length || elementIds?.length) { | ||
params = { mode, blockIds, elementIds }; | ||
} | ||
this._referenceInfo = { pageId, params }; | ||
} | ||
_renderLink(style) { | ||
return html `<a | ||
${ref(this._whenHover.setReference)} | ||
href=${this.link} | ||
rel="noopener noreferrer" | ||
target="_blank" | ||
style=${styleMap(style)} | ||
@click=${this._onClick} | ||
@mouseup=${this._onMouseUp} | ||
><v-text .str=${this.delta.insert}></v-text | ||
></a>`; | ||
} | ||
render() { | ||
const linkStyles = { | ||
const linkStyle = { | ||
color: 'var(--affine-link-color)', | ||
@@ -114,25 +131,10 @@ fill: 'var(--affine-link-color)', | ||
const codeStyle = affineTextStyles(this.delta.attributes); | ||
return html `<code style=${codeStyle} | ||
><a | ||
${ref(this._whenHover.setReference)} | ||
href=${this.link} | ||
style=${styleMap(linkStyles)} | ||
rel="noopener noreferrer" | ||
target="_blank" | ||
@mouseup=${this._onMouseUp} | ||
><v-text .str=${this.delta.insert}></v-text | ||
></a></v-text></code>`; | ||
return html `<code style=${styleMap(codeStyle)}> | ||
${this._renderLink(linkStyle)} | ||
</code>`; | ||
} | ||
const styles = this.delta.attributes | ||
? affineTextStyles(this.delta.attributes, linkStyles) | ||
: styleMap({}); | ||
return html `<a | ||
${ref(this._whenHover.setReference)} | ||
href=${this.link} | ||
rel="noopener noreferrer" | ||
target="_blank" | ||
style=${styles} | ||
@mouseup=${this._onMouseUp} | ||
><v-text .str=${this.delta.insert}></v-text | ||
></a>`; | ||
const style = this.delta.attributes | ||
? affineTextStyles(this.delta.attributes, linkStyle) | ||
: {}; | ||
return this._renderLink(style); | ||
} | ||
@@ -144,2 +146,29 @@ #delta_accessor_storage; | ||
super(...arguments); | ||
// The link has been identified. | ||
this._identified = false; | ||
this._onClick = (e) => { | ||
if (!this._identified) { | ||
this._identified = true; | ||
this._identify(); | ||
} | ||
const referenceInfo = this._referenceInfo; | ||
if (!referenceInfo) | ||
return; | ||
const refNodeSlotsProvider = this.std?.getOptional(RefNodeSlotsProvider); | ||
if (!refNodeSlotsProvider) | ||
return; | ||
e.preventDefault(); | ||
refNodeSlotsProvider.docLinkClicked.emit(referenceInfo); | ||
}; | ||
// see https://github.com/toeverything/AFFiNE/issues/1540 | ||
this._onMouseUp = () => { | ||
const anchorElement = this.querySelector('a'); | ||
if (!anchorElement || !anchorElement.isContentEditable) | ||
return; | ||
anchorElement.contentEditable = 'false'; | ||
setTimeout(() => { | ||
anchorElement.removeAttribute('contenteditable'); | ||
}, 0); | ||
}; | ||
this._referenceInfo = null; | ||
this._whenHover = new HoverController(this, ({ abortController }) => { | ||
@@ -146,0 +175,0 @@ if (this.block?.doc.readonly) { |
@@ -305,3 +305,5 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { | ||
const link = this.linkInput?.value.trim(); | ||
this.confirmButton.disabled = !(link && isValidUrl(link)); | ||
const disabled = !(link && isValidUrl(link)); | ||
this.confirmButton.disabled = disabled; | ||
this.confirmButton.active = !disabled; | ||
this.confirmButton.requestUpdate(); | ||
@@ -499,2 +501,3 @@ } | ||
placeholder="Paste or type a link" | ||
@paste=${this._updateConfirmBtn} | ||
@input=${this._updateConfirmBtn} | ||
@@ -501,0 +504,0 @@ /> |
@@ -11,3 +11,2 @@ import type { ReferenceInfo } from '@blocksuite/affine-model'; | ||
static styles: import("lit").CSSResult; | ||
private _refAttribute; | ||
private _updateRefMeta; | ||
@@ -14,0 +13,0 @@ private _whenHover; |
@@ -35,3 +35,2 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { | ||
}; | ||
import { getModelByElement } from '@blocksuite/affine-shared/utils'; | ||
import { BLOCK_ID_ATTR, ShadowlessElement, } from '@blocksuite/block-std'; | ||
@@ -45,2 +44,3 @@ import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions'; | ||
import { ref } from 'lit/directives/ref.js'; | ||
import { styleMap } from 'lit/directives/style-map.js'; | ||
import { HoverController } from '../../../../../hover/index.js'; | ||
@@ -139,5 +139,5 @@ import { BlockLinkIcon, FontDocIcon, FontLinkedDocIcon, } from '../../../../../icons/index.js'; | ||
const reference = this.delta.attributes?.reference; | ||
const id = this.doc?.id; | ||
const id = this.doc?.id ?? ''; | ||
if (!reference) | ||
return { pageId: id ?? '' }; | ||
return { pageId: id }; | ||
const { pageId, params } = reference; | ||
@@ -171,17 +171,5 @@ const info = { pageId }; | ||
return; | ||
const refMeta = this.refMeta; | ||
const model = getModelByElement(this); | ||
if (!refMeta) { | ||
// The doc is deleted | ||
console.warn('The doc is deleted', this._refAttribute.pageId); | ||
return; | ||
} | ||
if (!model || refMeta.id === model.doc.id) { | ||
// the doc is the current doc. | ||
return; | ||
} | ||
const targetDocId = refMeta.id; | ||
this.std | ||
.getOptional(RefNodeSlotsProvider) | ||
?.docLinkClicked.emit({ pageId: targetDocId }); | ||
?.docLinkClicked.emit(this.referenceInfo); | ||
} | ||
@@ -212,13 +200,3 @@ connectedCallback() { | ||
isLinkedNode() { | ||
const reference = this.delta.attributes?.reference; | ||
if (!reference?.params) | ||
return false; | ||
const { mode, blockIds, elementIds } = reference.params; | ||
if (!mode) | ||
return false; | ||
if (blockIds && blockIds.length > 0) | ||
return true; | ||
if (elementIds && elementIds.length > 0) | ||
return true; | ||
return false; | ||
return Boolean(this.referenceInfo.params && Object.keys(this.referenceInfo.params).length); | ||
} | ||
@@ -265,3 +243,3 @@ render() { | ||
class="affine-reference" | ||
style=${style} | ||
style=${styleMap(style)} | ||
@click=${this._onClick} | ||
@@ -293,6 +271,2 @@ >${content}<v-text .str=${ZERO_WIDTH_NON_JOINER}></v-text | ||
super(...arguments); | ||
this._refAttribute = { | ||
type: 'LinkedPage', | ||
pageId: '0', | ||
}; | ||
this._updateRefMeta = (doc) => { | ||
@@ -303,3 +277,2 @@ const refAttribute = this.delta.attributes?.reference; | ||
} | ||
this._refAttribute = refAttribute; | ||
const refMeta = doc.collection.meta.docMetas.find(doc => doc.id === refAttribute.pageId); | ||
@@ -306,0 +279,0 @@ this.refMeta = refMeta |
@@ -185,6 +185,2 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { | ||
_openDoc() { | ||
const pageId = this.referenceDocId; | ||
const block = this.block; | ||
if (pageId === block.doc.id) | ||
return; | ||
this.std | ||
@@ -191,0 +187,0 @@ .getOptional(RefNodeSlotsProvider) |
{ | ||
"name": "@blocksuite/affine-components", | ||
"version": "0.17.15", | ||
"version": "0.17.16", | ||
"description": "Default BlockSuite editable blocks.", | ||
@@ -22,9 +22,9 @@ "type": "module", | ||
"dependencies": { | ||
"@blocksuite/affine-model": "0.17.15", | ||
"@blocksuite/affine-shared": "0.17.15", | ||
"@blocksuite/block-std": "0.17.15", | ||
"@blocksuite/global": "0.17.15", | ||
"@blocksuite/affine-model": "0.17.16", | ||
"@blocksuite/affine-shared": "0.17.16", | ||
"@blocksuite/block-std": "0.17.16", | ||
"@blocksuite/global": "0.17.16", | ||
"@blocksuite/icons": "^2.1.67", | ||
"@blocksuite/inline": "0.17.15", | ||
"@blocksuite/store": "0.17.15", | ||
"@blocksuite/inline": "0.17.16", | ||
"@blocksuite/store": "0.17.16", | ||
"@floating-ui/dom": "^1.6.10", | ||
@@ -31,0 +31,0 @@ "@lit/context": "^1.1.2", |
@@ -573,3 +573,3 @@ /* eslint-disable no-useless-escape */ | ||
index: startIndex, | ||
length: 2 + content.length + 2, | ||
length: 2 + content.length + 2 + 1, | ||
}); | ||
@@ -576,0 +576,0 @@ inlineEditor.insertText( |
@@ -12,3 +12,3 @@ import { ShadowlessElement } from '@blocksuite/block-std'; | ||
override?: Readonly<StyleInfo> | ||
): ReturnType<typeof styleMap> { | ||
): StyleInfo { | ||
let textDecorations = ''; | ||
@@ -35,3 +35,3 @@ if (props.underline) { | ||
return styleMap({ | ||
return { | ||
'font-weight': props.bold ? 'bolder' : 'inherit', | ||
@@ -44,3 +44,3 @@ 'font-style': props.italic ? 'italic' : 'normal', | ||
...override, | ||
}); | ||
}; | ||
} | ||
@@ -52,3 +52,3 @@ | ||
? affineTextStyles(this.delta.attributes) | ||
: styleMap({}); | ||
: {}; | ||
@@ -58,3 +58,3 @@ // we need to avoid \n appearing before and after the span element, which will | ||
if (this.delta.attributes?.code) { | ||
return html`<code style=${style} | ||
return html`<code style=${styleMap(style)} | ||
><v-text .str=${this.delta.insert}></v-text | ||
@@ -66,3 +66,3 @@ ></code>`; | ||
// cause the unexpected space | ||
return html`<span style=${style} | ||
return html`<span style=${styleMap(style)} | ||
><v-text .str=${this.delta.insert}></v-text | ||
@@ -69,0 +69,0 @@ ></span>`; |
@@ -0,3 +1,5 @@ | ||
import type { ReferenceInfo, ReferenceParams } from '@blocksuite/affine-model'; | ||
import type { BlockComponent } from '@blocksuite/block-std'; | ||
import { ParseDocUrlProvider } from '@blocksuite/affine-shared/services'; | ||
import { BLOCK_ID_ATTR, ShadowlessElement } from '@blocksuite/block-std'; | ||
@@ -13,7 +15,9 @@ import { | ||
import { ref } from 'lit/directives/ref.js'; | ||
import { styleMap } from 'lit/directives/style-map.js'; | ||
import { type StyleInfo, styleMap } from 'lit/directives/style-map.js'; | ||
import type { AffineTextAttributes } from '../../../../extension/index.js'; | ||
import { HoverController } from '../../../../../hover/index.js'; | ||
import { | ||
type AffineTextAttributes, | ||
RefNodeSlotsProvider, | ||
} from '../../../../extension/index.js'; | ||
import { affineTextStyles } from '../affine-text.js'; | ||
@@ -29,2 +33,34 @@ import { toggleLinkPopup } from './link-popup/toggle-link-popup.js'; | ||
// The link has been identified. | ||
private _identified: boolean = false; | ||
private _onClick = (e: MouseEvent) => { | ||
if (!this._identified) { | ||
this._identified = true; | ||
this._identify(); | ||
} | ||
const referenceInfo = this._referenceInfo; | ||
if (!referenceInfo) return; | ||
const refNodeSlotsProvider = this.std?.getOptional(RefNodeSlotsProvider); | ||
if (!refNodeSlotsProvider) return; | ||
e.preventDefault(); | ||
refNodeSlotsProvider.docLinkClicked.emit(referenceInfo); | ||
}; | ||
// see https://github.com/toeverything/AFFiNE/issues/1540 | ||
private _onMouseUp = () => { | ||
const anchorElement = this.querySelector('a'); | ||
if (!anchorElement || !anchorElement.isContentEditable) return; | ||
anchorElement.contentEditable = 'false'; | ||
setTimeout(() => { | ||
anchorElement.removeAttribute('contenteditable'); | ||
}, 0); | ||
}; | ||
private _referenceInfo: ReferenceInfo | null = null; | ||
private _whenHover = new HoverController( | ||
@@ -85,7 +121,3 @@ this, | ||
get link() { | ||
const link = this.delta.attributes?.link; | ||
if (!link) { | ||
return ''; | ||
} | ||
return link; | ||
return this.delta.attributes?.link ?? ''; | ||
} | ||
@@ -103,14 +135,37 @@ | ||
// see https://github.com/toeverything/AFFiNE/issues/1540 | ||
private _onMouseUp() { | ||
const anchorElement = this.querySelector('a'); | ||
if (!anchorElement || !anchorElement.isContentEditable) return; | ||
anchorElement.contentEditable = 'false'; | ||
setTimeout(() => { | ||
anchorElement.removeAttribute('contenteditable'); | ||
}, 0); | ||
// Identify if url is an in-app link | ||
private _identify() { | ||
const link = this.link; | ||
if (!link) return; | ||
const result = this.std | ||
?.getOptional(ParseDocUrlProvider) | ||
?.parseDocUrl(link); | ||
if (!result) return; | ||
const { docId: pageId, mode, blockIds, elementIds } = result; | ||
let params: ReferenceParams | undefined = undefined; | ||
if (mode || blockIds?.length || elementIds?.length) { | ||
params = { mode, blockIds, elementIds }; | ||
} | ||
this._referenceInfo = { pageId, params }; | ||
} | ||
private _renderLink(style: StyleInfo) { | ||
return html`<a | ||
${ref(this._whenHover.setReference)} | ||
href=${this.link} | ||
rel="noopener noreferrer" | ||
target="_blank" | ||
style=${styleMap(style)} | ||
@click=${this._onClick} | ||
@mouseup=${this._onMouseUp} | ||
><v-text .str=${this.delta.insert}></v-text | ||
></a>`; | ||
} | ||
override render() { | ||
const linkStyles = { | ||
const linkStyle = { | ||
color: 'var(--affine-link-color)', | ||
@@ -121,29 +176,15 @@ fill: 'var(--affine-link-color)', | ||
}; | ||
if (this.delta.attributes && this.delta.attributes?.code) { | ||
const codeStyle = affineTextStyles(this.delta.attributes); | ||
return html`<code style=${codeStyle} | ||
><a | ||
${ref(this._whenHover.setReference)} | ||
href=${this.link} | ||
style=${styleMap(linkStyles)} | ||
rel="noopener noreferrer" | ||
target="_blank" | ||
@mouseup=${this._onMouseUp} | ||
><v-text .str=${this.delta.insert}></v-text | ||
></a></v-text></code>`; | ||
return html`<code style=${styleMap(codeStyle)}> | ||
${this._renderLink(linkStyle)} | ||
</code>`; | ||
} | ||
const styles = this.delta.attributes | ||
? affineTextStyles(this.delta.attributes, linkStyles) | ||
: styleMap({}); | ||
const style = this.delta.attributes | ||
? affineTextStyles(this.delta.attributes, linkStyle) | ||
: {}; | ||
return html`<a | ||
${ref(this._whenHover.setReference)} | ||
href=${this.link} | ||
rel="noopener noreferrer" | ||
target="_blank" | ||
style=${styles} | ||
@mouseup=${this._onMouseUp} | ||
><v-text .str=${this.delta.insert}></v-text | ||
></a>`; | ||
return this._renderLink(style); | ||
} | ||
@@ -150,0 +191,0 @@ |
@@ -61,2 +61,3 @@ import type { EmbedOptions } from '@blocksuite/affine-shared/types'; | ||
placeholder="Paste or type a link" | ||
@paste=${this._updateConfirmBtn} | ||
@input=${this._updateConfirmBtn} | ||
@@ -438,3 +439,5 @@ /> | ||
const link = this.linkInput?.value.trim(); | ||
this.confirmButton.disabled = !(link && isValidUrl(link)); | ||
const disabled = !(link && isValidUrl(link)); | ||
this.confirmButton.disabled = disabled; | ||
this.confirmButton.active = !disabled; | ||
this.confirmButton.requestUpdate(); | ||
@@ -441,0 +444,0 @@ } |
import type { ReferenceInfo } from '@blocksuite/affine-model'; | ||
import type { Doc, DocMeta } from '@blocksuite/store'; | ||
import { getModelByElement } from '@blocksuite/affine-shared/utils'; | ||
import { | ||
@@ -23,2 +22,3 @@ BLOCK_ID_ATTR, | ||
import { ref } from 'lit/directives/ref.js'; | ||
import { styleMap } from 'lit/directives/style-map.js'; | ||
@@ -74,7 +74,2 @@ import type { ReferenceNodeConfigProvider } from './reference-config.js'; | ||
private _refAttribute: NonNullable<AffineTextAttributes['reference']> = { | ||
type: 'LinkedPage', | ||
pageId: '0', | ||
}; | ||
private _updateRefMeta = (doc: Doc) => { | ||
@@ -86,3 +81,2 @@ const refAttribute = this.delta.attributes?.reference; | ||
this._refAttribute = refAttribute; | ||
const refMeta = doc.collection.meta.docMetas.find( | ||
@@ -172,4 +166,4 @@ doc => doc.id === refAttribute.pageId | ||
const reference = this.delta.attributes?.reference; | ||
const id = this.doc?.id; | ||
if (!reference) return { pageId: id ?? '' }; | ||
const id = this.doc?.id ?? ''; | ||
if (!reference) return { pageId: id }; | ||
@@ -206,18 +200,5 @@ const { pageId, params } = reference; | ||
if (!this.config.interactable) return; | ||
const refMeta = this.refMeta; | ||
const model = getModelByElement(this); | ||
if (!refMeta) { | ||
// The doc is deleted | ||
console.warn('The doc is deleted', this._refAttribute.pageId); | ||
return; | ||
} | ||
if (!model || refMeta.id === model.doc.id) { | ||
// the doc is the current doc. | ||
return; | ||
} | ||
const targetDocId = refMeta.id; | ||
this.std | ||
.getOptional(RefNodeSlotsProvider) | ||
?.docLinkClicked.emit({ pageId: targetDocId }); | ||
?.docLinkClicked.emit(this.referenceInfo); | ||
} | ||
@@ -260,9 +241,5 @@ | ||
isLinkedNode() { | ||
const reference = this.delta.attributes?.reference; | ||
if (!reference?.params) return false; | ||
const { mode, blockIds, elementIds } = reference.params; | ||
if (!mode) return false; | ||
if (blockIds && blockIds.length > 0) return true; | ||
if (elementIds && elementIds.length > 0) return true; | ||
return false; | ||
return Boolean( | ||
this.referenceInfo.params && Object.keys(this.referenceInfo.params).length | ||
); | ||
} | ||
@@ -323,3 +300,3 @@ | ||
class="affine-reference" | ||
style=${style} | ||
style=${styleMap(style)} | ||
@click=${this._onClick} | ||
@@ -326,0 +303,0 @@ >${content}<v-text .str=${ZERO_WIDTH_NON_JOINER}></v-text |
@@ -159,6 +159,2 @@ import type { ReferenceInfo } from '@blocksuite/affine-model'; | ||
private _openDoc() { | ||
const pageId = this.referenceDocId; | ||
const block = this.block; | ||
if (pageId === block.doc.id) return; | ||
this.std | ||
@@ -165,0 +161,0 @@ .getOptional(RefNodeSlotsProvider) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2252085
0.1%30638
0.04%