@sillsdev/docu-notion 0.14.0-alpha.11 → 0.14.0-alpha.12
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
CHANGED
|
@@ -148,3 +148,12 @@ To map Notion callouts to Docusaurus admonitions, ensure the icon is for the typ
|
|
|
148
148
|
- 🔥➜ danger
|
|
149
149
|
|
|
150
150
|
The default admonition type, if no matching icon is found, is "note".
|
|
151
|
+
|
|
152
|
+
# Known Workarounds
|
|
153
|
+
|
|
154
|
+
### Start a numbered list at a number other than 1
|
|
155
|
+
In Notion, make sure the block is "Text," not "Numbered List".
|
|
156
|
+
- But make sure the number does NOT have a space in front of it. This can/will cause issues with sub-list items.
|
|
157
|
+
- One way to get Notion to let you do this:
|
|
158
|
+
- Create a numbered list item where the text duplicates the number you want. Convert that numbered list item to "Text."
|
|
159
|
+
- i.e. Type "1. 1. Item one." Notion makes the first "1." into a number in a list. When you convert back to "Text," you're left with plain text "1. Item one."
|
|
@@ -29,33 +29,36 @@ const log_1 = require("./log");
|
|
|
29
29
|
const process_1 = require("process");
|
|
30
30
|
function makeImagePersistencePlan(imageSet, imageOutputRootPath, imagePrefix) {
|
|
31
31
|
var _a, _b;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const urlBeforeQuery = imageSet.primaryUrl.split("?")[0];
|
|
40
|
-
const thingToHash = (_b = findLastUuid(urlBeforeQuery)) !== null && _b !== void 0 ? _b : urlBeforeQuery;
|
|
41
|
-
const hash = hashOfString(thingToHash);
|
|
42
|
-
imageSet.outputFileName = `${hash}.${imageSet.fileType.ext}`;
|
|
43
|
-
imageSet.primaryFileOutputPath = Path.posix.join((imageOutputRootPath === null || imageOutputRootPath === void 0 ? void 0 : imageOutputRootPath.length) > 0
|
|
44
|
-
? imageOutputRootPath
|
|
45
|
-
: imageSet.pathToParentDocument, imageSet.outputFileName);
|
|
46
|
-
if (imageOutputRootPath && imageSet.localizedUrls.length) {
|
|
47
|
-
(0, log_1.error)("imageOutputPath was declared, but one or more localizedUrls were found too. If you are going to localize screenshots, then you can't declare an imageOutputPath.");
|
|
32
|
+
const urlBeforeQuery = imageSet.primaryUrl.split("?")[0];
|
|
33
|
+
let imageFileExtension = (_a = imageSet.fileType) === null || _a === void 0 ? void 0 : _a.ext;
|
|
34
|
+
if (!imageFileExtension) {
|
|
35
|
+
// Try to get the extension from the url
|
|
36
|
+
imageFileExtension = urlBeforeQuery.split(".").pop();
|
|
37
|
+
if (!imageFileExtension) {
|
|
38
|
+
(0, log_1.error)(`Something wrong with the filetype extension on the blob we got from ${imageSet.primaryUrl}`);
|
|
48
39
|
(0, process_1.exit)(1);
|
|
49
40
|
}
|
|
50
|
-
imageSet.filePathToUseInMarkdown =
|
|
51
|
-
((imagePrefix === null || imagePrefix === void 0 ? void 0 : imagePrefix.length) > 0 ? imagePrefix : ".") +
|
|
52
|
-
"/" +
|
|
53
|
-
imageSet.outputFileName;
|
|
54
41
|
}
|
|
55
|
-
|
|
56
|
-
|
|
42
|
+
// Since most images come from pasting screenshots, there isn't normally a filename. That's fine, we just make a hash of the url
|
|
43
|
+
// Images that are stored by notion come to us with a complex url that changes over time, so we pick out the UUID that doesn't change. Example:
|
|
44
|
+
// https://s3.us-west-2.amazonaws.com/secure.notion-static.com/d1058f46-4d2f-4292-8388-4ad393383439/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45EIPT3X45%2F20220516%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20220516T233630Z&X-Amz-Expires=3600&X-Amz-Signature=f215704094fcc884d37073b0b108cf6d1c9da9b7d57a898da38bc30c30b4c4b5&X-Amz-SignedHeaders=host&x-id=GetObject
|
|
45
|
+
// But around Sept 2023, they changed the url to be something like:
|
|
46
|
+
// https://prod-files-secure.s3.us-west-2.amazonaws.com/d9a2b712-cf69-4bd6-9d65-87a4ceeacca2/d1bcdc8c-b065-4e40-9a11-392aabeb220e/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45EIPT3X45%2F20230915%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20230915T161258Z&X-Amz-Expires=3600&X-Amz-Signature=28fca48e65fba86d539c3c4b7676fce1fa0857aa194f7b33dd4a468ecca6ab24&X-Amz-SignedHeaders=host&x-id=GetObject
|
|
47
|
+
// The thing we want is the last UUID before the ?
|
|
48
|
+
const thingToHash = (_b = findLastUuid(urlBeforeQuery)) !== null && _b !== void 0 ? _b : urlBeforeQuery;
|
|
49
|
+
const hash = hashOfString(thingToHash);
|
|
50
|
+
imageSet.outputFileName = `${hash}.${imageFileExtension}`;
|
|
51
|
+
imageSet.primaryFileOutputPath = Path.posix.join((imageOutputRootPath === null || imageOutputRootPath === void 0 ? void 0 : imageOutputRootPath.length) > 0
|
|
52
|
+
? imageOutputRootPath
|
|
53
|
+
: imageSet.pathToParentDocument, imageSet.outputFileName);
|
|
54
|
+
if (imageOutputRootPath && imageSet.localizedUrls.length) {
|
|
55
|
+
(0, log_1.error)("imageOutputPath was declared, but one or more localizedUrls were found too. If you are going to localize screenshots, then you can't declare an imageOutputPath.");
|
|
57
56
|
(0, process_1.exit)(1);
|
|
58
57
|
}
|
|
58
|
+
imageSet.filePathToUseInMarkdown =
|
|
59
|
+
((imagePrefix === null || imagePrefix === void 0 ? void 0 : imagePrefix.length) > 0 ? imagePrefix : ".") +
|
|
60
|
+
"/" +
|
|
61
|
+
imageSet.outputFileName;
|
|
59
62
|
}
|
|
60
63
|
exports.makeImagePersistencePlan = makeImagePersistencePlan;
|
|
61
64
|
function findLastUuid(url) {
|
|
@@ -28,6 +28,16 @@ test("primary file with defaults for image output path and prefix", () => {
|
|
|
28
28
|
expect(imageSet.primaryFileOutputPath).toBe(`/pathToParentSomewhere/${expectedHash}.png`);
|
|
29
29
|
expect(imageSet.filePathToUseInMarkdown).toBe(`./${expectedHash}.png`);
|
|
30
30
|
});
|
|
31
|
+
test("falls back to getting file extension from url if not in fileType", () => {
|
|
32
|
+
const imageSet = {
|
|
33
|
+
primaryUrl: "https://s3.us-west-2.amazonaws.com/primaryImage.png",
|
|
34
|
+
localizedUrls: [],
|
|
35
|
+
pathToParentDocument: "/pathToParentSomewhere/",
|
|
36
|
+
};
|
|
37
|
+
(0, MakeImagePersistencePlan_1.makeImagePersistencePlan)(imageSet, "", "");
|
|
38
|
+
const expectedHash = (0, MakeImagePersistencePlan_1.hashOfString)("https://s3.us-west-2.amazonaws.com/primaryImage.png");
|
|
39
|
+
expect(imageSet.outputFileName).toBe(`${expectedHash}.png`);
|
|
40
|
+
});
|
|
31
41
|
test("properly extract UUID from old-style notion image url", () => {
|
|
32
42
|
const imageSet = {
|
|
33
43
|
primaryUrl: "https://s3.us-west-2.amazonaws.com/secure.notion-static.com/e1058f46-4d2f-4292-8388-4ad393383439/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45EIPT3X45%2F20220516%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20220516T233630Z&X-Amz-Expires=3600&X-Amz-Signature=f215704094fcc884d37073b0b108cf6d1c9da9b7d57a898da38bc30c30b4c4b5&X-Amz-SignedHeaders=host&x-id=GetObject",
|
package/package.json
CHANGED