You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-29 22:48:10 +02:00
Desktop: WYSIWYG: Getting links to work
This commit is contained in:
@@ -5,6 +5,8 @@ const urlUtils = require('../../urlUtils.js');
|
||||
const { getClassNameForMimeType } = require('font-awesome-filetypes');
|
||||
|
||||
function installRule(markdownIt, mdOptions, ruleOptions) {
|
||||
const pluginOptions = { linkRenderingType: 1, ...ruleOptions.plugins['link_open'] };
|
||||
|
||||
markdownIt.renderer.rules.link_open = function(tokens, idx) {
|
||||
const token = tokens[idx];
|
||||
let href = utils.getAttr(token.attrs, 'href');
|
||||
@@ -58,7 +60,7 @@ function installRule(markdownIt, mdOptions, ruleOptions) {
|
||||
let js = `${ruleOptions.postMessageSyntax}(${JSON.stringify(href)}); return false;`;
|
||||
if (hrefAttr.indexOf('#') === 0 && href.indexOf('#') === 0) js = ''; // If it's an internal anchor, don't add any JS since the webview is going to handle navigating to the right place
|
||||
|
||||
if (ruleOptions.plainResourceRendering) {
|
||||
if (ruleOptions.plainResourceRendering || pluginOptions.linkRenderingType === 2) {
|
||||
return `<a data-from-md ${resourceIdAttr} title='${htmlentities(title)}' href='${hrefAttr}' type='${htmlentities(mime)}'>`;
|
||||
} else {
|
||||
return `<a data-from-md ${resourceIdAttr} title='${htmlentities(title)}' href='${hrefAttr}' onclick='${js}' type='${htmlentities(mime)}'>${icon}`;
|
||||
|
||||
@@ -4,4 +4,5 @@ module.exports = {
|
||||
HtmlToHtml: require('./HtmlToHtml'),
|
||||
setupLinkify: require('./MdToHtml/setupLinkify'),
|
||||
assetsToHeaders: require('./assetsToHeaders'),
|
||||
utils: require('./utils'),
|
||||
};
|
||||
|
||||
@@ -271,9 +271,13 @@ module.exports = function(theme) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* =============================================== */
|
||||
/* For TinyMCE */
|
||||
/* =============================================== */
|
||||
|
||||
.mce-content-body {
|
||||
padding: 5px 10px 10px 10px;
|
||||
/* Note: we give a bit more padding at the bottom, to allow scrolling past the end of the document */
|
||||
padding: 5px 10px 10em 10px;
|
||||
}
|
||||
|
||||
.mce-content-body code {
|
||||
@@ -292,6 +296,10 @@ module.exports = function(theme) {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
/* =============================================== */
|
||||
/* For TinyMCE */
|
||||
/* =============================================== */
|
||||
|
||||
@media print {
|
||||
body {
|
||||
height: auto !important;
|
||||
|
||||
Reference in New Issue
Block a user