@sillsdev/docu-notion 0.14.0-alpha.15 → 0.14.0-alpha.16

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.
@@ -29,7 +29,8 @@ function convertInternalUrl(context, url) {
29
29
  exports.convertInternalUrl = convertInternalUrl;
30
30
  // handles the whole markdown link, including the label
31
31
  function convertInternalLink(context, markdownLink) {
32
- const linkRegExp = /\[([^\]]+)?\]\(\/?([^),^/]+)\)/g;
32
+ // match both [foo](/123) and [bar](https://www.notion.so/123) <-- the "mention" link style
33
+ const linkRegExp = /\[([^\]]+)?\]\((?:https?:\/\/www\.notion\.so\/|\/)?([^),^/]+)\)/g;
33
34
  const match = linkRegExp.exec(markdownLink);
34
35
  if (match === null) {
35
36
  (0, log_1.warning)(`[standardInternalLinkConversion] Could not parse link ${markdownLink}`);
@@ -96,7 +97,9 @@ exports.standardInternalLinkConversion = {
96
97
  // (has some other text that's been turned into a link) or "raw".
97
98
  // Raw links come in without a leading slash, e.g. [link_to_page](4a6de8c0-b90b-444b-8a7b-d534d6ec71a4)
98
99
  // Inline links come in with a leading slash, e.g. [pointer to the introduction](/4a6de8c0b90b444b8a7bd534d6ec71a4)
99
- match: /\[([^\]]+)?\]\((?!mailto:)(\/?[^),^/]+)\)/,
100
+ // "Mention" links come in as full URLs, e.g. [link_to_page](https://www.notion.so/62f1187010214b0883711a1abb277d31)
101
+ // YOu can create them either with @+the name of a page, or by pasting a URL and then selecting the "Mention" option.
102
+ match: /\[([^\]]+)?\]\((?!mailto:)(https:\/\/www\.notion\.so\/[^),^/]+|\/?[^),^/]+)\)/,
100
103
  convert: convertInternalLink,
101
104
  },
102
105
  };
@@ -38,6 +38,43 @@ test("urls that show up as raw text get left that way", () => __awaiter(void 0,
38
38
  });
39
39
  expect(results.trim()).toBe("https://github.com");
40
40
  }));
41
+ // See https://github.com/sillsdev/docu-notion/issues/97
42
+ test("mention-style link to an existing page", () => __awaiter(void 0, void 0, void 0, function* () {
43
+ const targetPageId = "123";
44
+ const targetPage = (0, pluginTestRun_1.makeSamplePageObject)({
45
+ slug: undefined,
46
+ name: "Hello World",
47
+ id: targetPageId,
48
+ });
49
+ const results = yield getMarkdown({
50
+ type: "paragraph",
51
+ paragraph: {
52
+ rich_text: [
53
+ {
54
+ type: "mention",
55
+ mention: {
56
+ type: "page",
57
+ page: {
58
+ id: `${targetPageId}`,
59
+ },
60
+ },
61
+ annotations: {
62
+ bold: false,
63
+ italic: false,
64
+ strikethrough: false,
65
+ underline: false,
66
+ code: false,
67
+ color: "default",
68
+ },
69
+ plain_text: "foo",
70
+ href: `https://www.notion.so/${targetPageId}`,
71
+ },
72
+ ],
73
+ color: "default",
74
+ },
75
+ }, targetPage);
76
+ expect(results.trim()).toBe(`[foo](/${targetPageId})`);
77
+ }));
41
78
  test("link to an existing page on this site that has no slug", () => __awaiter(void 0, void 0, void 0, function* () {
42
79
  const targetPageId = "123";
43
80
  const targetPage = (0, pluginTestRun_1.makeSamplePageObject)({
package/dist/pull.js CHANGED
@@ -163,7 +163,7 @@ function getPagesRecursively(options, incomingContext, pageIdOfThisParent, order
163
163
  if (!rootLevel &&
164
164
  pageInfo.hasParagraphs &&
165
165
  pageInfo.childPageIdsAndOrder.length) {
166
- (0, log_1.error)(`Skipping "${pageInTheOutline.nameOrTitle}" and its children. docu-notion does not support pages that are both levels and have content at the same time.`);
166
+ (0, log_1.error)(`Skipping "${pageInTheOutline.nameOrTitle}" and its children. docu-notion does not support pages that are both levels and have text content (paragraphs) at the same time. Normally outline pages should just be composed of 1) links to other pages and 2) child pages (other levels of the outline). Note that @-mention style links appear as text paragraphs to docu-notion so must not be used to form the outline.`);
167
167
  ++counts.skipped_because_level_cannot_have_content;
168
168
  return;
169
169
  }
package/package.json CHANGED
@@ -91,5 +91,5 @@
91
91
  "volta": {
92
92
  "node": "18.16.0"
93
93
  },
94
- "version": "0.14.0-alpha.15"
94
+ "version": "0.14.0-alpha.16"
95
95
  }