There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(core): load fonts from selfhost url (#5789)
LongYinan899528dcfddc
diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs.ts b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs.tsindex ab2eb8b2e7..0c9f49c4a7 100644--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs.ts+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs.ts@@ -1,9 +1,10 @@-import type { BlockSpec } from '@blocksuite/block-std';+import type { BlockServiceOptions, BlockSpec } from '@blocksuite/block-std';import type { ParagraphService } from '@blocksuite/blocks';import {AttachmentService,DocEditorBlockSpecs,EdgelessEditorBlockSpecs,+ PageService,} from '@blocksuite/blocks';import bytes from 'bytes';import { html, unsafeStatic } from 'lit/static-html.js';@@ -17,6 +18,26 @@ class CustomAttachmentService extends AttachmentService {}}+class CustomPageService extends PageService {+ constructor(opt: BlockServiceOptions) {+ super(opt);+ const officialDomains = new Set(['affine.pro', 'affine.fail']);+ const load = this.fontLoader.load.bind(this.fontLoader);+ this.fontLoader.load = function (fonts) {+ if (!officialDomains.has(window.location.host)) {+ return load(+ fonts.map(f => ({+ ...f,+ // self-hosted fonts are served from /assets+ url: '/assets' + new URL(f.url).pathname.split('/').pop(),+ }))+ );+ }+ return load(fonts);+ };+ }+}+type AffineReference = HTMLElementTagNameMap['affine-reference'];type PageReferenceRenderer = (reference: AffineReference) => React.ReactElement;@@ -76,6 +97,12 @@ export const docModeSpecs = DocEditorBlockSpecs.map(spec => {service: CustomAttachmentService,};}+ if (spec.schema.model.flavour === 'affine:page') {+ return {+ ...spec,+ service: CustomPageService,+ };+ }return spec;});export const edgelessModeSpecs = EdgelessEditorBlockSpecs.map(spec => {