1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! Pictures a document points at: where a pasted screenshot's bytes go.
//!
//! A document holds a URL, and bytes off the clipboard have no address
//! anywhere — so somewhere has to be picked before an image block can exist,
//! which is what `editor::set_image_store` asks the app. The answer is the
//! article's own directory: the directory *is* the article (see
//! [`crate::model::article`]), so a picture in it is carried by the document it
//! belongs to and deleted with it.
//!
//! The editor names which document is asking, but what it hands over is an
//! `Entity<Editor>` and the article behind one is the workspace's to know —
//! so which directory to write into is still noted by [`aim`] as a document
//! opens. One window and one document in front of it, so one target.
use ;
use ;
use ;
/// What a picture's file name begins with, beside the `cover-` it may sit next
/// to — see [`crate::model::cover`].
const MARK: &str = "media-";
/// Where the open document's pictures go. Nothing aimed is a paste the editor
/// lets go of, which is what a screenshot pasted with no document open is.
static TARGET: = new;
/// Install the store. Called once, beside the other `init`s.
///
/// `accepts` is left at the editor's own guess from the extension — cydonia
/// decodes nothing the default would turn away.
/// Point at the article a document was opened from — its `content.md`, which
/// is the file the pictures sit beside.
/// Take a picture into the open article's directory, and answer with what the
/// document is to point at.
///
/// Named for the bytes' own hash, so the same screenshot pasted twice is the
/// one file — and gpui, which caches a decoded picture against its path, is
/// handed the copy it already has.
///
/// An absolute path rather than a relative one: what paints the picture reads
/// the URL as a path off this process, whose working directory is not the
/// article's.