-
-
Notifications
You must be signed in to change notification settings - Fork 396
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(blocks): file drop manager supports files from other apps
- Loading branch information
Showing
10 changed files
with
422 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import type { | ||
BlockSnapshot, | ||
DocSnapshot, | ||
FromBlockSnapshotPayload, | ||
FromBlockSnapshotResult, | ||
FromDocSnapshotPayload, | ||
FromDocSnapshotResult, | ||
FromSliceSnapshotPayload, | ||
FromSliceSnapshotResult, | ||
SliceSnapshot, | ||
ToBlockSnapshotPayload, | ||
ToDocSnapshotPayload, | ||
ToSliceSnapshotPayload, | ||
} from '@blocksuite/store'; | ||
import { BaseAdapter } from '@blocksuite/store'; | ||
|
||
export type UriList = string; | ||
|
||
// https://www.iana.org/assignments/media-types/text/uri-list | ||
export class UriListAdapter extends BaseAdapter<UriList> { | ||
override fromDocSnapshot( | ||
_payload: FromDocSnapshotPayload | ||
): Promise<FromDocSnapshotResult<UriList>> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
override fromBlockSnapshot( | ||
_payload: FromBlockSnapshotPayload | ||
): Promise<FromBlockSnapshotResult<UriList>> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
override fromSliceSnapshot( | ||
_payload: FromSliceSnapshotPayload | ||
): Promise<FromSliceSnapshotResult<UriList>> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
override toDocSnapshot( | ||
_payload: ToDocSnapshotPayload<UriList> | ||
): Promise<DocSnapshot> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
override toSliceSnapshot( | ||
_payload: ToSliceSnapshotPayload<UriList> | ||
): SliceSnapshot | Promise<SliceSnapshot | null> | null { | ||
throw new Error('Method not implemented.'); | ||
} | ||
override toBlockSnapshot( | ||
_payload: ToBlockSnapshotPayload<UriList> | ||
): BlockSnapshot { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
parse(input: UriList) { | ||
return input | ||
.split('\n') | ||
.map(line => line.trim()) | ||
.filter(line => line.length >= 3) | ||
.filter(line => line.at(0) !== '#') | ||
.filter(line => URL.canParse(line)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.