@riebeckite/plugin-attachment 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/README_ja.md +2 -1
- package/dist/index.js +11 -5
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -67,5 +67,6 @@ Styles ship in `style.css` (inline attachment links also get a `↓` suffix).
|
|
|
67
67
|
|
|
68
68
|
## See also
|
|
69
69
|
|
|
70
|
-
- [Plugin guide](../../../docs/en/reference/plugin-api.md)
|
|
70
|
+
- [Plugin guide](../../../docs/en/docs/reference/plugin-api.md)
|
|
71
71
|
- [`@riebeckite/plugin-obsidian-markdown`](../obsidian-markdown/README.md)
|
|
72
|
+
|
package/README_ja.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -3,13 +3,17 @@ import {
|
|
|
3
3
|
definePlugin,
|
|
4
4
|
escapeHtml,
|
|
5
5
|
escapeHtmlAttribute,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
getExtension,
|
|
7
|
+
readContentSourceEntry
|
|
8
8
|
} from "@riebeckite/core";
|
|
9
9
|
var PLUGIN_NAME = "attachment";
|
|
10
10
|
function attachment(options = {}) {
|
|
11
11
|
return definePlugin({
|
|
12
12
|
name: PLUGIN_NAME,
|
|
13
|
+
processedContentCache: {
|
|
14
|
+
version: "attachment-v2",
|
|
15
|
+
dependencyMode: "tracked"
|
|
16
|
+
},
|
|
13
17
|
options,
|
|
14
18
|
renderers: [
|
|
15
19
|
{
|
|
@@ -42,16 +46,18 @@ async function renderAttachment(context, options) {
|
|
|
42
46
|
${sizeHtml}
|
|
43
47
|
</div>
|
|
44
48
|
<div class="attachment-card__name">${escapeHtml(fileName)}</div>
|
|
45
|
-
<a class="attachment-card__download" href="${escapeHtmlAttribute(context.url)}" download>${escapeHtml(context.label || "
|
|
49
|
+
<a class="attachment-card__download" href="${escapeHtmlAttribute(context.url)}" download>${escapeHtml(context.label || "Download")}</a>
|
|
46
50
|
</aside>`;
|
|
47
51
|
}
|
|
48
52
|
async function getAttachmentSize(context) {
|
|
49
53
|
if (!context.contentSource) return null;
|
|
50
|
-
const
|
|
54
|
+
const content = await readContentSourceEntry(
|
|
51
55
|
context.contentSource,
|
|
52
56
|
context.path
|
|
53
57
|
);
|
|
54
|
-
|
|
58
|
+
if (content === null) return null;
|
|
59
|
+
const bytes = typeof content === "string" ? new TextEncoder().encode(content).byteLength : content.byteLength;
|
|
60
|
+
return formatBytes(bytes);
|
|
55
61
|
}
|
|
56
62
|
function getFileName(contentPath) {
|
|
57
63
|
return contentPath.split("/").at(-1) ?? contentPath;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-attachment",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
"./style.css": "./style.css"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@riebeckite/core": "0.0.
|
|
18
|
+
"@riebeckite/core": "0.0.15"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"tsx": "^4.22.4"
|
|
19
22
|
},
|
|
20
23
|
"publishConfig": {
|
|
21
24
|
"access": "public"
|
|
@@ -50,6 +53,7 @@
|
|
|
50
53
|
"./style.css"
|
|
51
54
|
],
|
|
52
55
|
"scripts": {
|
|
53
|
-
"build": "node ../../../scripts/build_package.mjs"
|
|
56
|
+
"build": "node ../../../scripts/build_package.mjs",
|
|
57
|
+
"test": "node --import tsx --test \"test/*.test.ts\""
|
|
54
58
|
}
|
|
55
59
|
}
|