From 7eb889b584f4319168c92a6c3ab9bf7af1adb7a8 Mon Sep 17 00:00:00 2001 From: LeeJongBeom <52884648+devleejb@users.noreply.github.com> Date: Sat, 16 Nov 2024 00:06:31 +0900 Subject: [PATCH] Change to open url in new tab (#409) --- frontend/package.json | 1 + frontend/src/components/editor/Preview.tsx | 7 +++++++ frontend/src/global.d.ts | 1 + pnpm-lock.yaml | 8 ++++++++ 4 files changed, 17 insertions(+) diff --git a/frontend/package.json b/frontend/package.json index 0a061f57..12d491d0 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -56,6 +56,7 @@ "lodash": "^4.17.21", "markdown-it": "^14.1.0", "markdown-it-incremental-dom": "^2.1.0", + "markdown-it-link-attributes": "^4.0.1", "markdown-it-prism": "^2.3.0", "markdown-it-sanitizer": "^0.4.3", "markdown-it-task-checkbox": "^1.0.6", diff --git a/frontend/src/components/editor/Preview.tsx b/frontend/src/components/editor/Preview.tsx index fc92c807..51ccd315 100644 --- a/frontend/src/components/editor/Preview.tsx +++ b/frontend/src/components/editor/Preview.tsx @@ -11,6 +11,7 @@ import { refractor } from "refractor"; import markdownItIncrementalDOM from "markdown-it-incremental-dom"; import markdownItSanitizer from "markdown-it-sanitizer"; import markdownItTaskCheckbox from "markdown-it-task-checkbox"; +import mila from "markdown-it-link-attributes"; import * as IncrementalDOM from "incremental-dom"; import "./editor.css"; import "./preview.css"; @@ -36,6 +37,12 @@ const md = new MarkdownIt({ }, }) .use(markdownItTaskCheckbox) + .use(mila, { + attrs: { + target: "_blank", + rel: "noopener noreferrer", + }, + }) .use(markdownItIncrementalDOM, IncrementalDOM, { incrementalizeDefaultRules: false, }) diff --git a/frontend/src/global.d.ts b/frontend/src/global.d.ts index 53f7cf53..66e4d068 100644 --- a/frontend/src/global.d.ts +++ b/frontend/src/global.d.ts @@ -1,3 +1,4 @@ declare module "markdown-it-incremental-dom"; declare module "markdown-it-sanitizer"; declare module "markdown-it-task-checkbox"; +declare module "markdown-it-link-attributes"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9eb44ce5..b37fde4f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -270,6 +270,9 @@ importers: markdown-it-incremental-dom: specifier: ^2.1.0 version: 2.1.0(incremental-dom@0.6.0)(markdown-it@14.1.0) + markdown-it-link-attributes: + specifier: ^4.0.1 + version: 4.0.1 markdown-it-prism: specifier: ^2.3.0 version: 2.3.0 @@ -5260,6 +5263,9 @@ packages: incremental-dom: '>=0.5.0' markdown-it: '>=4.0.0' + markdown-it-link-attributes@4.0.1: + resolution: {integrity: sha512-pg5OK0jPLg62H4k7M9mRJLT61gUp9nvG0XveKYHMOOluASo9OEF13WlXrpAp2aj35LbedAy3QOCgQCw0tkLKAQ==} + markdown-it-prism@2.3.0: resolution: {integrity: sha512-ePtHY80gZyeje4bn3R3SL0jpd1C9HFaYffJW2Ma0YD+tspqa2v9TuVwUyFwboFu4jnFNcO8oPQROgbcYJbmBvw==} engines: {node: '>=6.0.0'} @@ -12764,6 +12770,8 @@ snapshots: incremental-dom: 0.6.0 markdown-it: 14.1.0 + markdown-it-link-attributes@4.0.1: {} + markdown-it-prism@2.3.0: dependencies: prismjs: 1.29.0