@getguru/import-engine 0.1.3 → 0.1.5
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/docx-import-cli.js +50 -9
- package/package.json +1 -1
package/docx-import-cli.js
CHANGED
|
@@ -101996,8 +101996,8 @@ function capFolderDepth(path3) {
|
|
|
101996
101996
|
function buildFolderTree(docs2) {
|
|
101997
101997
|
let nextFolderId = 0;
|
|
101998
101998
|
const makeFolderId = () => `folder${nextFolderId++}`;
|
|
101999
|
-
function getOrCreateChild(childrenMap, segment, parentPathSegments) {
|
|
102000
|
-
let child = childrenMap.get(
|
|
101999
|
+
function getOrCreateChild(childrenMap, segment, parentPathSegments, lookupKey = segment) {
|
|
102000
|
+
let child = childrenMap.get(lookupKey);
|
|
102001
102001
|
if (!child) {
|
|
102002
102002
|
child = {
|
|
102003
102003
|
id: makeFolderId(),
|
|
@@ -102006,19 +102006,20 @@ function buildFolderTree(docs2) {
|
|
|
102006
102006
|
cardIds: [],
|
|
102007
102007
|
pathSegments: [...parentPathSegments, segment]
|
|
102008
102008
|
};
|
|
102009
|
-
childrenMap.set(
|
|
102009
|
+
childrenMap.set(lookupKey, child);
|
|
102010
102010
|
}
|
|
102011
102011
|
return child;
|
|
102012
102012
|
}
|
|
102013
102013
|
const roots = /* @__PURE__ */ new Map();
|
|
102014
102014
|
const collectionLevelCardIds = [];
|
|
102015
|
-
function attachCardToPath(docId, rawPath) {
|
|
102015
|
+
function attachCardToPath(docId, rawPath, scope) {
|
|
102016
102016
|
const path3 = capFolderDepth(rawPath);
|
|
102017
102017
|
let childrenMap = roots;
|
|
102018
102018
|
let node;
|
|
102019
102019
|
let pathSegments = [];
|
|
102020
102020
|
for (const segment of path3) {
|
|
102021
|
-
|
|
102021
|
+
const lookupKey = childrenMap === roots && scope != null ? `${scope}\0${segment}` : segment;
|
|
102022
|
+
node = getOrCreateChild(childrenMap, segment, pathSegments, lookupKey);
|
|
102022
102023
|
childrenMap = node.children;
|
|
102023
102024
|
pathSegments = node.pathSegments;
|
|
102024
102025
|
}
|
|
@@ -102051,7 +102052,11 @@ function buildFolderTree(docs2) {
|
|
|
102051
102052
|
collectionLevelCardIds.push(doc.id);
|
|
102052
102053
|
continue;
|
|
102053
102054
|
}
|
|
102054
|
-
attachCardToPath(
|
|
102055
|
+
attachCardToPath(
|
|
102056
|
+
doc.id,
|
|
102057
|
+
path3,
|
|
102058
|
+
Array.isArray(doc.guruFolder) ? doc.guruFolderScope : void 0
|
|
102059
|
+
);
|
|
102055
102060
|
}
|
|
102056
102061
|
return { roots: Array.from(roots.values()), collectionLevelCardIds };
|
|
102057
102062
|
}
|
|
@@ -108512,6 +108517,12 @@ var card_schema_default = {
|
|
|
108512
108517
|
strikethrough: {
|
|
108513
108518
|
type: "boolean"
|
|
108514
108519
|
},
|
|
108520
|
+
superscript: {
|
|
108521
|
+
type: "boolean"
|
|
108522
|
+
},
|
|
108523
|
+
subscript: {
|
|
108524
|
+
type: "boolean"
|
|
108525
|
+
},
|
|
108515
108526
|
underline: {
|
|
108516
108527
|
type: "boolean"
|
|
108517
108528
|
},
|
|
@@ -110990,6 +111001,9 @@ function processConfluenceDoc(div, doc) {
|
|
|
110990
111001
|
tryStep(doc, "resolving the page's folder", div, () => {
|
|
110991
111002
|
const breadcrumbs = Array.from(div.querySelectorAll("#breadcrumbs a"));
|
|
110992
111003
|
doc.guruFolder = breadcrumbs.slice(2).map((breadcrumb) => breadcrumb.textContent.trim());
|
|
111004
|
+
if (doc.folder) {
|
|
111005
|
+
doc.guruFolderScope = doc.folder;
|
|
111006
|
+
}
|
|
110993
111007
|
});
|
|
110994
111008
|
removeAll(div, "#main-header, #content > .page-metadata, #footer, input");
|
|
110995
111009
|
tryStep(doc, "converting panels to guru callouts", div, () => {
|
|
@@ -111208,7 +111222,7 @@ function buildConfluencePageIndex(allDocs, zip) {
|
|
|
111208
111222
|
if (pageId && !byId.has(pageId)) {
|
|
111209
111223
|
byId.set(pageId, doc);
|
|
111210
111224
|
}
|
|
111211
|
-
const space = normalizeConfluenceKey((doc.folder || "").split("/")
|
|
111225
|
+
const space = normalizeConfluenceKey((doc.folder || "").split("/").pop());
|
|
111212
111226
|
const title = normalizeConfluenceKey(doc.title);
|
|
111213
111227
|
if (space && title) {
|
|
111214
111228
|
if (!byTitle.has(space)) {
|
|
@@ -111525,6 +111539,32 @@ var STYLE_ATTRIBUTES_TO_KEEP = [
|
|
|
111525
111539
|
"text-align",
|
|
111526
111540
|
"text-decoration"
|
|
111527
111541
|
];
|
|
111542
|
+
var VERTICAL_ALIGN_BLOCK_SELECTOR = "p, div, h1, h2, h3, h4, h5, h6, ul, ol, li, table, blockquote, pre";
|
|
111543
|
+
function convertVerticalAlignToTags(root2) {
|
|
111544
|
+
Array.from(root2.querySelectorAll("[style]")).forEach(function(el) {
|
|
111545
|
+
if (el.closest(".ghq-card-content__markdown")) {
|
|
111546
|
+
return;
|
|
111547
|
+
}
|
|
111548
|
+
const values2 = parseStyleString(el.getAttribute("style"));
|
|
111549
|
+
const key = Object.keys(values2).find((k) => k.toLowerCase() === "vertical-align");
|
|
111550
|
+
if (!key) {
|
|
111551
|
+
return;
|
|
111552
|
+
}
|
|
111553
|
+
const value = values2[key].replace(/!\s*important\s*$/i, "").trim().toLowerCase();
|
|
111554
|
+
if (value !== "super" && value !== "sub") {
|
|
111555
|
+
return;
|
|
111556
|
+
}
|
|
111557
|
+
const tagName = value === "super" ? "sup" : "sub";
|
|
111558
|
+
if (el.closest(tagName) || !el.textContent.trim() && !el.firstElementChild || el.querySelector(VERTICAL_ALIGN_BLOCK_SELECTOR)) {
|
|
111559
|
+
return;
|
|
111560
|
+
}
|
|
111561
|
+
const tag = el.ownerDocument.createElement(tagName);
|
|
111562
|
+
while (el.firstChild) {
|
|
111563
|
+
tag.appendChild(el.firstChild);
|
|
111564
|
+
}
|
|
111565
|
+
el.appendChild(tag);
|
|
111566
|
+
});
|
|
111567
|
+
}
|
|
111528
111568
|
function parseStyleString(text2) {
|
|
111529
111569
|
const result3 = {};
|
|
111530
111570
|
const pairs3 = text2.split(";");
|
|
@@ -112110,6 +112150,7 @@ function cleanUpHtml(element, doc = {}) {
|
|
|
112110
112150
|
);
|
|
112111
112151
|
}
|
|
112112
112152
|
});
|
|
112153
|
+
convertVerticalAlignToTags(element);
|
|
112113
112154
|
Array.from(element.querySelectorAll("[style]")).forEach(function(element2) {
|
|
112114
112155
|
if (element2.closest(".ghq-card-content__markdown")) {
|
|
112115
112156
|
return;
|
|
@@ -114400,7 +114441,7 @@ var import_jszip5 = __toESM(require_lib3());
|
|
|
114400
114441
|
var import_url_join6 = __toESM(require_url_join());
|
|
114401
114442
|
|
|
114402
114443
|
// packages/import-engine/package.json
|
|
114403
|
-
var version = "0.1.
|
|
114444
|
+
var version = "0.1.5";
|
|
114404
114445
|
|
|
114405
114446
|
// src/docx-import/detectors.js
|
|
114406
114447
|
function isGoogleSitesDoc(div) {
|
|
@@ -114424,7 +114465,7 @@ var showError;
|
|
|
114424
114465
|
var updateLoader;
|
|
114425
114466
|
var showReport;
|
|
114426
114467
|
var docLinkIndex = /* @__PURE__ */ new Map();
|
|
114427
|
-
var toolVersion = true ? `${version}+${"
|
|
114468
|
+
var toolVersion = true ? `${version}+${"8c32bd5"}` : version;
|
|
114428
114469
|
var pendingUpload = null;
|
|
114429
114470
|
function confirmPendingUpload() {
|
|
114430
114471
|
const upload = pendingUpload;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getguru/import-engine",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Command-line engine that turns Notion, Confluence, Google, Word, PDF, Markdown and spreadsheet exports into Guru import zips.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"guru-import-engine": "docx-import-cli.js"
|