mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Desktop: Add support for higlighting text from Rich Text editor
This commit is contained in:
parent
35063ac05c
commit
f3b2ca4752
1
packages/app-cli/tests/html_to_md/mark.html
Normal file
1
packages/app-cli/tests/html_to_md/mark.html
Normal file
@ -0,0 +1 @@
|
||||
Here: <mark>Highlight this</mark>, but not this.
|
1
packages/app-cli/tests/html_to_md/mark.md
Normal file
1
packages/app-cli/tests/html_to_md/mark.md
Normal file
@ -0,0 +1 @@
|
||||
Here: ==Highlight this==, but not this.
|
@ -543,7 +543,7 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
|
||||
const toolbarPluginButtons = pluginCommandNames.length ? ` | ${pluginCommandNames.join(' ')}` : '';
|
||||
|
||||
const toolbar = [
|
||||
'bold', 'italic', '|',
|
||||
'bold', 'italic', 'joplinHighlight', '|',
|
||||
'link', 'joplinInlineCode', 'joplinCodeBlock', 'joplinAttach', '|',
|
||||
'bullist', 'numlist', 'joplinChecklist', '|',
|
||||
'h1', 'h2', 'h3', 'hr', 'blockquote', 'table', `joplinInsertDateTime${toolbarPluginButtons}`,
|
||||
@ -571,6 +571,9 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
|
||||
localization_function: _,
|
||||
contextmenu: false,
|
||||
browser_spellcheck: true,
|
||||
formats: {
|
||||
'joplin-highlight': { inline: 'mark', remove: 'all' },
|
||||
},
|
||||
setup: (editor: any) => {
|
||||
|
||||
function openEditDialog(editable: any) {
|
||||
@ -644,6 +647,19 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
|
||||
},
|
||||
});
|
||||
|
||||
editor.ui.registry.addToggleButton('joplinHighlight', {
|
||||
tooltip: _('Highlight'),
|
||||
icon: 'highlight-bg-color',
|
||||
onAction: async function() {
|
||||
editor.execCommand('mceToggleFormat', false, 'joplin-highlight');
|
||||
},
|
||||
onSetup: function(api: any) {
|
||||
editor.formatter.formatChanged('joplin-highlight', function(state: boolean) {
|
||||
api.setActive(state);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
editor.ui.registry.addButton('joplinCodeBlock', {
|
||||
tooltip: _('Code Block'),
|
||||
icon: 'code-sample',
|
||||
|
@ -26,11 +26,6 @@
|
||||
padding-bottom: 400px;
|
||||
}
|
||||
|
||||
mark {
|
||||
background: #F7D26E;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.mark-selected {
|
||||
background: #CF3F00;
|
||||
color: white;
|
||||
|
@ -785,7 +785,7 @@ class Setting extends BaseModel {
|
||||
'markdown.plugin.audioPlayer': { storage: SettingStorage.File, value: true, type: SettingItemType.Bool, section: 'markdownPlugins', public: true, appTypes: ['mobile', 'desktop'], label: () => `${_('Enable audio player')}${wysiwygNo}` },
|
||||
'markdown.plugin.videoPlayer': { storage: SettingStorage.File, value: true, type: SettingItemType.Bool, section: 'markdownPlugins', public: true, appTypes: ['mobile', 'desktop'], label: () => `${_('Enable video player')}${wysiwygNo}` },
|
||||
'markdown.plugin.pdfViewer': { storage: SettingStorage.File, value: !mobilePlatform, type: SettingItemType.Bool, section: 'markdownPlugins', public: true, appTypes: ['desktop'], label: () => `${_('Enable PDF viewer')}${wysiwygNo}` },
|
||||
'markdown.plugin.mark': { storage: SettingStorage.File, value: true, type: SettingItemType.Bool, section: 'markdownPlugins', public: true, appTypes: ['mobile', 'desktop'], label: () => `${_('Enable ==mark== syntax')}${wysiwygNo}` },
|
||||
'markdown.plugin.mark': { storage: SettingStorage.File, value: true, type: SettingItemType.Bool, section: 'markdownPlugins', public: true, appTypes: ['mobile', 'desktop'], label: () => `${_('Enable ==mark== syntax')}${wysiwygYes}` },
|
||||
'markdown.plugin.footnote': { storage: SettingStorage.File, value: true, type: SettingItemType.Bool, section: 'markdownPlugins', public: true, appTypes: ['mobile', 'desktop'], label: () => `${_('Enable footnotes')}${wysiwygNo}` },
|
||||
'markdown.plugin.toc': { storage: SettingStorage.File, value: true, type: SettingItemType.Bool, section: 'markdownPlugins', public: true, appTypes: ['mobile', 'desktop'], label: () => `${_('Enable table of contents extension')}${wysiwygNo}` },
|
||||
'markdown.plugin.sub': { storage: SettingStorage.File, value: false, type: SettingItemType.Bool, section: 'markdownPlugins', public: true, appTypes: ['mobile', 'desktop'], label: () => `${_('Enable ~sub~ syntax')}${wysiwygNo}` },
|
||||
|
@ -302,6 +302,11 @@ export default function(theme: any) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
mark {
|
||||
background: #F7D26E;
|
||||
color: black;
|
||||
}
|
||||
|
||||
/* =============================================== */
|
||||
/* For TinyMCE */
|
||||
/* =============================================== */
|
||||
|
@ -54,6 +54,22 @@ rules.heading = {
|
||||
}
|
||||
}
|
||||
|
||||
// ==============================
|
||||
// Joplin format support
|
||||
// ==============================
|
||||
|
||||
rules.highlight = {
|
||||
filter: 'mark',
|
||||
|
||||
replacement: function (content, node, options) {
|
||||
return '==' + content + '=='
|
||||
}
|
||||
}
|
||||
|
||||
// ==============================
|
||||
// END Joplin format support
|
||||
// ==============================
|
||||
|
||||
rules.blockquote = {
|
||||
filter: 'blockquote',
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user