nodebb-plugin-markdown 13.2.1 → 13.2.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-markdown",
3
- "version": "13.2.1",
3
+ "version": "13.2.3",
4
4
  "description": "A Markdown parser for NodeBB",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -219,16 +219,23 @@ export function markExternalLinks() {
219
219
 
220
220
  const anchorEls = document.querySelectorAll('[component="post/content"] a');
221
221
  anchorEls.forEach((anchorEl) => {
222
- // Do nothing if the anchor contains only an image
223
- if (anchorEl.childElementCount === 1 && anchorEl.querySelector('img') && !anchorEl.text) {
222
+ const imageOnly = anchorEl.childElementCount === 1 && anchorEl.querySelector('img') && !anchorEl.text;
223
+ const iconAlreadyAdded = anchorEl.querySelector('.external-link-icon');
224
+ if (imageOnly || iconAlreadyAdded) {
224
225
  return;
225
226
  }
226
227
 
227
228
  // Otherwise, mark external links with icon
228
- const parsed = new URL(anchorEl.href, document.location.href);
229
+ let parsed;
230
+ try {
231
+ parsed = new URL(anchorEl.href, document.location.href);
232
+ } catch (err) {
233
+ return;
234
+ }
235
+
229
236
  if (parsed.host != document.location.host) {
230
237
  const iconEl = document.createElement('i');
231
- iconEl.classList.add('fa', 'fa-external-link', 'small');
238
+ iconEl.classList.add('fa', 'fa-external-link', 'small', 'external-link-icon');
232
239
  anchorEl.append(' ', iconEl);
233
240
  }
234
241
  });
@@ -1,11 +1,13 @@
1
- {
2
- "bold": "粗体字",
3
- "italic": "斜体字",
4
- "list-item": "列表",
5
- "strikethrough-text": "删除线",
6
- "link-text": "链接文本",
7
- "link-url": "链接地址",
8
- "picture-text": "替代文字",
9
- "picture-url": "图片地址",
10
- "help-text": "该论坛使用 Markdown 语法。[点此查看](http://commonmark.org/help/) 语法说明。"
11
- }
1
+ {
2
+ "bold": "粗体字",
3
+ "italic": "斜体字",
4
+ "list-item": "列表",
5
+ "heading": "标题",
6
+ "strikethrough-text": "删除线",
7
+ "code-text": "代码文本",
8
+ "link-text": "链接文本",
9
+ "link-url": "链接地址",
10
+ "picture-text": "替代文字",
11
+ "picture-url": "图片地址",
12
+ "help-text": "该论坛使用 Markdown 语法。<a href=\"https://commonmark.org/help/\" class=\"text-decoration-underline\">点此查看</a> 语法说明。"
13
+ }