feat: Initial clean release of CHM
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
这个提交包含在:
@@ -0,0 +1,46 @@
|
||||
import { RuleOptions } from '../../MdToHtml';
|
||||
import { attributesHtml } from '../../htmlUtils';
|
||||
import * as utils from '../../utils';
|
||||
import createEventHandlingAttrs from '../createEventHandlingAttrs';
|
||||
import type * as MarkdownIt from 'markdown-it';
|
||||
import type Token = require('markdown-it/lib/token');
|
||||
import type Renderer = require('markdown-it/lib/renderer');
|
||||
|
||||
function plugin(markdownIt: MarkdownIt, ruleOptions: RuleOptions) {
|
||||
const defaultRender = markdownIt.renderer.rules.image;
|
||||
|
||||
markdownIt.renderer.rules.image = (tokens: Token[], idx: number, options: MarkdownIt.Options, env: unknown, self: Renderer) => {
|
||||
const Resource = ruleOptions.ResourceModel;
|
||||
|
||||
const token = tokens[idx];
|
||||
const src = utils.getAttr(token.attrs, 'src');
|
||||
const title = utils.getAttr(token.attrs, 'title');
|
||||
|
||||
if (!Resource.isResourceUrl(src) || ruleOptions.plainResourceRendering) return defaultRender(tokens, idx, options, env, self);
|
||||
|
||||
const alt = token.content;
|
||||
const r = utils.imageReplacement(ruleOptions.ResourceModel, { src, alt, title }, ruleOptions.resources, ruleOptions.resourceBaseUrl, ruleOptions.itemIdToUrl);
|
||||
if (typeof r === 'string') return r;
|
||||
if (r) {
|
||||
const id = r['data-resource-id'];
|
||||
|
||||
// Show the edit popup if any MIME type matches that in editPopupFiletypes
|
||||
const mimeType = ruleOptions.resources[id]?.item?.mime?.toLowerCase();
|
||||
const enableEditPopup = ruleOptions.editPopupFiletypes?.some(showForMime => mimeType === showForMime);
|
||||
|
||||
const js = createEventHandlingAttrs(id, {
|
||||
enableLongPress: ruleOptions.enableLongPress ?? false,
|
||||
postMessageSyntax: ruleOptions.postMessageSyntax ?? 'void',
|
||||
|
||||
enableEditPopup,
|
||||
createEditPopupSyntax: ruleOptions.createEditPopupSyntax,
|
||||
destroyEditPopupSyntax: ruleOptions.destroyEditPopupSyntax,
|
||||
}, null);
|
||||
|
||||
return `<img data-from-md ${attributesHtml({ ...r, title: title, alt })} ${js}/>`;
|
||||
}
|
||||
return defaultRender(tokens, idx, options, env, self);
|
||||
};
|
||||
}
|
||||
|
||||
export default { plugin };
|
||||
在新工单中引用
屏蔽一个用户