1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-13 00:10:37 +02:00

Server: Do not make checkboxes in published notes clickable

This commit is contained in:
Laurent Cozic
2022-04-05 15:42:06 +01:00
parent 27198a16a4
commit cb637e817b
3 changed files with 5 additions and 2 deletions

View File

@ -148,6 +148,7 @@ export interface RuleOptions {
// Used by checkboxes to specify how it should be rendered
checkboxRenderingType?: number;
checkboxDisabled?: boolean;
// Used by the keyword highlighting plugin (mobile only)
highlightedKeywords?: any[];

View File

@ -53,7 +53,7 @@ function pluginAssets(theme: any) {
];
}
function createPrefixTokens(Token: any, id: string, checked: boolean, label: string, postMessageSyntax: string, sourceToken: any): any[] {
function createPrefixTokens(Token: any, id: string, checked: boolean, label: string, postMessageSyntax: string, sourceToken: any, disabled: boolean): any[] {
let token = null;
const tokens = [];
@ -89,6 +89,7 @@ function createPrefixTokens(Token: any, id: string, checked: boolean, label: str
token = new Token('checkbox_input', 'input', 0);
token.attrs = [['type', 'checkbox'], ['id', id], ['onclick', js]];
if (disabled) token.attrs.push(['disabled', 'disabled']);
if (checked) token.attrs.push(['checked', 'checked']);
tokens.push(token);
@ -169,7 +170,7 @@ function checkboxPlugin(markdownIt: any, options: RuleOptions) {
// Prepend the text content with the checkbox markup and the opening <label> tag
// then append the </label> tag at the end of the text content.
const prefix = createPrefixTokens(Token, id, checked, label, options.postMessageSyntax, token);
const prefix = createPrefixTokens(Token, id, checked, label, options.postMessageSyntax, token, !!options.checkboxDisabled);
const suffix = createSuffixTokens(Token);
token.children = markdownIt.utils.arrayReplaceAt(token.children, 0, prefix);

View File

@ -203,6 +203,7 @@ async function renderNote(share: Share, note: NoteEntity, resourceInfos: Resourc
audioPlayerEnabled: false,
videoPlayerEnabled: false,
pdfViewerEnabled: false,
checkboxDisabled: true,
linkRenderingType: 2,
};