1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Desktop: Fixes #9950: Link pased in RTE editor is not underlined until switch to another note (#10202)

This commit is contained in:
Daniel Nunes 2024-04-03 18:43:30 +01:00 committed by GitHub
parent 29daec2c07
commit 8630c8e630
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -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');
@ -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);

View File

@ -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);
};