mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
chore: bump up @blocksuite/affine version to v0.18.6 (#9113)
This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@blocksuite/affine](https://redirect.github.com/toeverything/blocksuite) ([source](https://redirect.github.com/toeverything/blocksuite/tree/HEAD/packages/affine/all), [changelog](https://redirect.github.com/toeverything/blocksuite/blob/master/packages/blocks/CHANGELOG.md)) | [`0.18.5` -> `0.18.6`](https://renovatebot.com/diffs/npm/@blocksuite%2faffine/0.18.5/0.18.6) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>toeverything/blocksuite (@​blocksuite/affine)</summary> ### [`v0.18.6`](https://redirect.github.com/toeverything/blocksuite/blob/HEAD/packages/affine/all/CHANGELOG.md#0186) [Compare Source](https://redirect.github.com/toeverything/blocksuite/compare/v0.18.5...v0.18.6) ##### Patch Changes - [`d925364`](https://redirect.github.com/toeverything/blocksuite/commit/d925364): Blocksuite patch release. </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/toeverything/AFFiNE). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS41OC4xIiwidXBkYXRlZEluVmVyIjoiMzkuNTguMSIsInRhcmdldEJyYW5jaCI6ImNhbmFyeSIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=-->
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
"@affine/component": "workspace:*",
|
||||
"@affine/core": "workspace:*",
|
||||
"@affine/i18n": "workspace:*",
|
||||
"@blocksuite/affine": "0.18.5",
|
||||
"@blocksuite/affine": "0.18.7",
|
||||
"@blocksuite/icons": "2.1.75",
|
||||
"@capacitor/android": "^6.1.2",
|
||||
"@capacitor/core": "^6.1.2",
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
"@affine/core": "workspace:*",
|
||||
"@affine/i18n": "workspace:*",
|
||||
"@affine/native": "workspace:*",
|
||||
"@blocksuite/affine": "0.18.5",
|
||||
"@blocksuite/affine": "0.18.7",
|
||||
"@electron-forge/cli": "^7.3.0",
|
||||
"@electron-forge/core": "^7.3.0",
|
||||
"@electron-forge/core-utils": "^7.3.0",
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"@affine/component": "workspace:*",
|
||||
"@affine/core": "workspace:*",
|
||||
"@affine/i18n": "workspace:*",
|
||||
"@blocksuite/affine": "0.18.5",
|
||||
"@blocksuite/affine": "0.18.7",
|
||||
"@blocksuite/icons": "2.1.75",
|
||||
"@capacitor/app": "^6.0.1",
|
||||
"@capacitor/browser": "^6.0.3",
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"@affine/component": "workspace:*",
|
||||
"@affine/core": "workspace:*",
|
||||
"@affine/i18n": "workspace:*",
|
||||
"@blocksuite/affine": "0.18.5",
|
||||
"@blocksuite/affine": "0.18.7",
|
||||
"@blocksuite/icons": "2.1.75",
|
||||
"@sentry/react": "^8.0.0",
|
||||
"react": "^19.0.0",
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
"zod": "^3.22.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blocksuite/affine": "0.18.5",
|
||||
"@blocksuite/affine": "0.18.7",
|
||||
"@blocksuite/icons": "2.1.75",
|
||||
"@chromatic-com/storybook": "^3.0.0",
|
||||
"@storybook/addon-essentials": "^8.4.7",
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"@affine/i18n": "workspace:*",
|
||||
"@affine/templates": "workspace:*",
|
||||
"@affine/track": "workspace:*",
|
||||
"@blocksuite/affine": "0.18.5",
|
||||
"@blocksuite/affine": "0.18.7",
|
||||
"@blocksuite/icons": "2.1.75",
|
||||
"@capacitor/app": "^6.0.1",
|
||||
"@capacitor/browser": "^6.0.3",
|
||||
|
||||
@@ -80,7 +80,7 @@ export async function getContentFromSlice(
|
||||
collection: host.std.doc.collection,
|
||||
middlewares: [titleMiddleware, embedSyncedDocMiddleware('content')],
|
||||
});
|
||||
const snapshot = await job.sliceToSnapshot(slice);
|
||||
const snapshot = job.sliceToSnapshot(slice);
|
||||
if (!snapshot) {
|
||||
return '';
|
||||
}
|
||||
@@ -99,7 +99,7 @@ export async function getPlainTextFromSlice(host: EditorHost, slice: Slice) {
|
||||
collection: host.std.doc.collection,
|
||||
middlewares: [titleMiddleware],
|
||||
});
|
||||
const snapshot = await job.sliceToSnapshot(slice);
|
||||
const snapshot = job.sliceToSnapshot(slice);
|
||||
if (!snapshot) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { fetchImage } from '@blocksuite/affine/blocks';
|
||||
import { assertExists } from '@blocksuite/affine/global/utils';
|
||||
import { FetchUtils } from '@blocksuite/affine-shared/adapters';
|
||||
|
||||
export async function fetchImageToFile(
|
||||
url: string,
|
||||
@@ -7,7 +7,7 @@ export async function fetchImageToFile(
|
||||
imageProxy?: string
|
||||
): Promise<File | void> {
|
||||
try {
|
||||
const res = await fetchImage(url, undefined, imageProxy);
|
||||
const res = await FetchUtils.fetchImage(url, undefined, imageProxy);
|
||||
if (res && res.ok) {
|
||||
let blob = await res.blob();
|
||||
if (!blob.type || !blob.type.startsWith('image/')) {
|
||||
|
||||
@@ -6,14 +6,11 @@ import {
|
||||
import { createPageModeSpecs } from '@affine/core/components/blocksuite/block-suite-editor/specs/page';
|
||||
import type { AffineDNDData } from '@affine/core/types/dnd';
|
||||
import { BlockStdScope } from '@blocksuite/affine/block-std';
|
||||
import type { DNDAPIExtension } from '@blocksuite/affine/blocks';
|
||||
import { DndApiExtensionIdentifier } from '@blocksuite/affine/blocks';
|
||||
import {
|
||||
DocCollection,
|
||||
nanoid,
|
||||
type SliceSnapshot,
|
||||
} from '@blocksuite/affine/store';
|
||||
import { type SliceSnapshot } from '@blocksuite/affine/store';
|
||||
import type { DocsService, WorkspaceService } from '@toeverything/infra';
|
||||
import { getAFFiNEWorkspaceSchema, Service } from '@toeverything/infra';
|
||||
import { Service } from '@toeverything/infra';
|
||||
|
||||
import { resolveLinkToDoc } from '../../navigation';
|
||||
|
||||
@@ -54,21 +51,23 @@ export class DndService extends Service {
|
||||
source: ExternalDragPayload
|
||||
) => Entity | null)[] = [];
|
||||
|
||||
readonly blocksuiteDndAPI = (() => {
|
||||
const collection = new DocCollection({
|
||||
schema: getAFFiNEWorkspaceSchema(),
|
||||
});
|
||||
collection.meta.initialize();
|
||||
private _blocksuiteDndAPI: DNDAPIExtension | null = null;
|
||||
|
||||
get blocksuiteDndAPI() {
|
||||
if (this._blocksuiteDndAPI) {
|
||||
return this._blocksuiteDndAPI;
|
||||
}
|
||||
|
||||
const collection = this.workspaceService.workspace.docCollection;
|
||||
const doc = collection.createDoc();
|
||||
const std = new BlockStdScope({
|
||||
doc,
|
||||
extensions: createPageModeSpecs(this.framework),
|
||||
});
|
||||
this.disposables.push(() => {
|
||||
collection.dispose();
|
||||
});
|
||||
return std.get(DndApiExtensionIdentifier);
|
||||
})();
|
||||
const dndAPI = std.get(DndApiExtensionIdentifier);
|
||||
this._blocksuiteDndAPI = dndAPI;
|
||||
return dndAPI;
|
||||
}
|
||||
|
||||
fromExternalData: fromExternalData<AffineDNDData> = (
|
||||
args: ExternalGetDataFeedbackArgs,
|
||||
@@ -114,32 +113,19 @@ export class DndService extends Service {
|
||||
return {};
|
||||
}
|
||||
|
||||
// todo: use blocksuite provided api to generate snapshot
|
||||
const snapshotSlice: SliceSnapshot = {
|
||||
content: [
|
||||
{
|
||||
children: [],
|
||||
flavour: 'affine:embed-linked-doc',
|
||||
type: 'block',
|
||||
id: nanoid(),
|
||||
props: {
|
||||
pageId: normalData.entity.id,
|
||||
},
|
||||
},
|
||||
],
|
||||
type: 'slice',
|
||||
pageId: nanoid(),
|
||||
pageVersion: 1,
|
||||
workspaceId: this.workspaceService.workspace.id,
|
||||
workspaceVersion: 2,
|
||||
};
|
||||
const snapshotSlice = this.blocksuiteDndAPI.fromEntity({
|
||||
docId: normalData.entity.id,
|
||||
flavour: 'affine:embed-linked-doc',
|
||||
});
|
||||
|
||||
const serialized = JSON.stringify(snapshotSlice);
|
||||
if (!snapshotSlice) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const html = `<div data-blocksuite-snapshot="${encodeURIComponent(serialized)}"></div>`;
|
||||
const encoded = this.blocksuiteDndAPI.encodeSnapshot(snapshotSlice);
|
||||
|
||||
return {
|
||||
'text/html': html,
|
||||
[this.blocksuiteDndAPI.mimeType]: encoded,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -171,15 +157,11 @@ export class DndService extends Service {
|
||||
private readonly resolveBlocksuiteExternalData = (
|
||||
source: ExternalDragPayload
|
||||
): Entity | null => {
|
||||
const fakeDataTransfer = new Proxy(new DataTransfer(), {
|
||||
get(target, prop) {
|
||||
if (prop === 'getData') {
|
||||
return (type: string) => source.getStringData(type);
|
||||
}
|
||||
return target[prop as keyof DataTransfer];
|
||||
},
|
||||
});
|
||||
const snapshot = this.blocksuiteDndAPI.decodeSnapshot(fakeDataTransfer);
|
||||
const encoded = source.getStringData(this.blocksuiteDndAPI.mimeType);
|
||||
if (!encoded) {
|
||||
return null;
|
||||
}
|
||||
const snapshot = this.blocksuiteDndAPI.decodeSnapshot(encoded);
|
||||
if (!snapshot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user