You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-30 23:44:55 +02:00
Desktop, Mobile: Added link resource icon (#2035)
* Add forkawesome icons * Add resource icon for specific filetypes * Ignore resource link styling on mobile * whtiespace * render txt icons and adjust icon sizes * Replace fork-awesome font with inline svg so icons work on mobile * Add comment describing the source of resource icons
This commit is contained in:
committed by
Laurent Cozic
parent
c9f6ce7496
commit
c05bc899eb
@ -2,6 +2,7 @@ const Entities = require('html-entities').AllHtmlEntities;
|
||||
const htmlentities = new Entities().encode;
|
||||
const utils = require('../../utils');
|
||||
const urlUtils = require('lib/urlUtils.js');
|
||||
const { getClassNameForMimeType } = require('font-awesome-filetypes');
|
||||
|
||||
function installRule(markdownIt, mdOptions, ruleOptions) {
|
||||
markdownIt.renderer.rules.link_open = function(tokens, idx) {
|
||||
@ -33,7 +34,15 @@ function installRule(markdownIt, mdOptions, ruleOptions) {
|
||||
href = `joplin://${resourceId}`;
|
||||
if (resourceHrefInfo.hash) href += `#${resourceHrefInfo.hash}`;
|
||||
resourceIdAttr = `data-resource-id='${resourceId}'`;
|
||||
icon = '<span class="resource-icon"></span>';
|
||||
|
||||
let iconType = getClassNameForMimeType(mime);
|
||||
if (!mime) {
|
||||
iconType = 'fa-joplin';
|
||||
}
|
||||
// Icons are defined in lib/renderers/noteStyle.js using inline svg
|
||||
// The icons are taken from fork-awesome but use the font-awesome naming scheme in order
|
||||
// to be more compatible with the getClass library
|
||||
icon = `<span class="resource-icon ${iconType}"></span>`;
|
||||
}
|
||||
} else {
|
||||
// If the link is a plain URL (as opposed to a resource link), set the href to the actual
|
||||
@ -48,6 +57,7 @@ function installRule(markdownIt, mdOptions, ruleOptions) {
|
||||
}
|
||||
|
||||
module.exports = function(context, ruleOptions) {
|
||||
|
||||
return function(md, mdOptions) {
|
||||
installRule(md, mdOptions, ruleOptions);
|
||||
};
|
||||
|
Reference in New Issue
Block a user