Skip to content

Commit

Permalink
Desktop: Fixes #9950: Link pased in RTE editor is not underlined unti…
Browse files Browse the repository at this point in the history
…l switch to another note (#10202)
  • Loading branch information
danimnunes authored Apr 3, 2024
1 parent 29daec2 commit 8630c8e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { focus } from '@joplin/lib/utils/focusHandler';
const md5 = require('md5');
const { clipboard } = require('electron');
const supportedLocales = require('./supportedLocales');
import { isLink } from '@joplin/utils/url';

const logger = Logger.create('TinyMCE');

Expand Down Expand Up @@ -1172,7 +1173,7 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
editor.insertContent(result.html);
}
} else {
if (BaseItem.isMarkdownTag(pastedText)) { // Paste a link to a note
if (BaseItem.isMarkdownTag(pastedText) || isLink(pastedText)) { // Paste a link to a note
logger.info('onPaste: pasting as a Markdown tag');
const result = await markupToHtml.current(MarkupToHtml.MARKUP_LANGUAGE_MARKDOWN, pastedText, markupRenderOptions({ bodyOnly: true }));
editor.insertContent(result.html);
Expand Down
7 changes: 7 additions & 0 deletions packages/utils/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,10 @@ export const fileUriToPath = (path: string, platform = 'linux') => {
export const isDataUrl = (path: string) => {
return path.startsWith('data:');
};

export const isLink = (text: string) => {
if (!text) return false;
const linkRegex = /^(https?|file|joplin):\/\/[^)\s]+$/;
return !!text.match(linkRegex);
};

0 comments on commit 8630c8e

Please sign in to comment.