Skip to content

Commit

Permalink
added Highlight possebility
Browse files Browse the repository at this point in the history
  • Loading branch information
Reocin committed Jun 13, 2021
1 parent b1533b9 commit d3f1472
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 10 deletions.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ All saved colors can be sorted via drop a catch.

To delete a saved or last used color just click it with the right mouse button.

### Additonal Formats

For a even easier handling you can select additional options to what should be added to the color.

#### Options

- Add "color: {your color}"
- ex. `color: #ffffff`
- Add "background-color: {your color}
- ex. `background-color: #ffffff`
- Add tag: "style={your color}
- This option is only helpful, if you also select one of both of the other options like:
- ex. `style="background-color: #ff0000"`

![](assets/Color_Picker.png)

## Settings
Expand All @@ -88,10 +102,13 @@ To delete a saved or last used color just click it with the right mouse button.

## Changelog

- Version: 0.3.2
- Aditional options for the color picker
- New Higlight Button in the Text Edit section and commandline
- Version 0.3.1
- Changeable order of the sections
- Expandable sections
- Corrected the latex `\$\$` and `\$\$\$\$` buttons as they was switched
- Corrected the latex `\$\$` and `\$\$\$\$` buttons as they were switched
- Version 0.3.0
- added a Latex and Greek Letters section
- Version 0.2.2
Expand Down
Binary file modified assets/Color_Picker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion build/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-markdown-formatting-assistant-plugin",
"name": "Markdown Formatting Assistant",
"version": "0.3.1",
"version": "0.3.2",
"minAppVersion": "0.10.9",
"description": "This Plugin provides a simple Editor for Markdown, HTML and Colors and in addition a command line interface. The command line interface facilitate a faster workflow.",
"author": "Reocin",
Expand Down
3 changes: 2 additions & 1 deletion build/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"0.2.1": "0.10.9",
"0.2.2": "0.10.9",
"0.3.0": "0.10.9",
"0.3.1": "0.10.9"
"0.3.1": "0.10.9",
"0.3.2": "0.10.9"
}
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-markdown-formatting-assistant-plugin",
"name": "Markdown Formatting Assistant",
"version": "0.3.1",
"version": "0.3.2",
"minAppVersion": "0.10.9",
"description": "This Plugin provides a simple Editor for Markdown, HTML and Colors and in addition a command line interface. The command line interface facilitate a faster workflow.",
"author": "Reocin",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-markdown-formatting-assistant-plugin",
"version": "0.3.1",
"version": "0.3.2",
"description": "This plugin improves the writing of MarkDown files",
"homepage": "https://github.com/Reocin/obsidian-markdown-formatting-assistant-plugin",
"main": "main.js",
Expand Down
47 changes: 46 additions & 1 deletion src/SidePanelControlView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,18 +387,27 @@ export class SidePanelControlView extends ItemView {
let button = row.createDiv({ cls: 'nav-action-button' });
addClickEvent(button, 'bold');
button.appendChild(svgToElement('bold'));
button.id = 'obsidianMarkdownFormattingAssistantPluginButtonBold';

button = row.createDiv({ cls: 'nav-action-button' });
addClickEvent(button, 'italic');
button.appendChild(svgToElement('italic'));
button.id = 'obsidianMarkdownFormattingAssistantPluginButtonItalic';

button = row.createDiv({ cls: 'nav-action-button' });
addClickEvent(button, 'strikethrough');
button.appendChild(svgToElement('strikethrough'));
button.id = 'obsidianMarkdownFormattingAssistantPluginButtonStrikethrough';

button = row.createDiv({ cls: 'nav-action-button' });
addClickEvent(button, 'underline');
button.appendChild(svgToElement('underline'));
button.id = 'obsidianMarkdownFormattingAssistantPluginButtonUnderline';

button = row.createDiv({ cls: 'nav-action-button' });
addClickEvent(button, 'highlight');
button.appendChild(svgToElement('highlight'));
button.id = 'obsidianMarkdownFormattingAssistantPluginButtonHighlight';

row = mainDiv.createDiv({ cls: 'nav-buttons-container' });
button = row.createDiv({ cls: 'nav-action-button' });
Expand Down Expand Up @@ -448,9 +457,26 @@ export class SidePanelControlView extends ItemView {
const leaf = this.app.workspace.activeLeaf;
let editor = null;
if (checkIfMarkdownSource(leaf)) {
const addColor =
// @ts-ignore
document.getElementById('inputColorTagCheckBox').checked;

const addBackgroundColor =
// @ts-ignore
document.getElementById('inputBackgroundColorTagCheckBox').checked;
const addStyle =
// @ts-ignore
document.getElementById('inputStyleTagCheckBox').checked;

let res = color;
if (addColor) res = `color: ${color}`;
if (addBackgroundColor) res = `background-color: ${color}`;
if (addColor && addBackgroundColor)
res = `color: ${color}; background-color: ${color}`;
if (addStyle) res = `style="${res}"`;
// @ts-ignore
editor = leaf.view.sourceMode.cmEditor;
colorFormatter(editor, color);
colorFormatter(editor, res);
editor.focus();
}
};
Expand Down Expand Up @@ -618,6 +644,25 @@ export class SidePanelControlView extends ItemView {
drawLastSavedColorIcons();
await this.plugin.saveSettings();
});
colorSaveButton.style.marginBottom = '20px';

const addCheckbox = (id: string, text: string) => {
const div = colorSection.createEl('div');
let input = div.createEl('input');
input.id = id;
input.type = 'checkbox';
input.name = id;
let label = div.createEl('label');
label.appendText(text);
label.style.fontSize = '12px';
};

addCheckbox('inputColorTagCheckBox', ' Add "color: {your color}"');
addCheckbox(
'inputBackgroundColorTagCheckBox',
' Add "background-color: {your color}"',
);
addCheckbox('inputStyleTagCheckBox', ' Add tag: "style={your color}"');

const lastSelectedColorsTitle = colorSection.createEl('p');
lastSelectedColorsTitle.appendText('Last used colors:');
Expand Down
10 changes: 10 additions & 0 deletions src/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ export const formatSettings = {
newLine: false,
enclose: false,
},
highlight: {
des: 'highlight',
icon: 'highlight',
symbol: '<mark></mark>',
shift: 6,
selectionInput: 6,
newLine: false,
enclose: false,
},
codeBlock: {
des: 'code_block',
icon: 'codeBlock',
Expand Down Expand Up @@ -237,6 +246,7 @@ export function iconFormatter(
'internal_link',
'image',
'underline',
'highlight',
].contains(item.des)
) {
if (isSelection) {
Expand Down
1 change: 1 addition & 0 deletions src/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const icons: Record<string, string> = {
menu: pathToSvg(mdiIcons.mdiMenu),
expandArrowDown: pathToSvg(mdiIcons.mdiChevronDown),
expandArrowUp: pathToSvg(mdiIcons.mdiChevronUp),
highlight: pathToSvg(mdiIcons.mdiMarker)
};

export const addIcons = (): void => {
Expand Down
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ export default class MarkdownAutocompletePlugin extends Plugin {
this.addCommand({
id: 'open-sample-modal',
name: 'Open Sample Modal',
// callback: () => {
// console.log('Simple Callback');
// },
callback: () => {
console.log('Simple Callback');
},
checkCallback: (checking: boolean) => {
let leaf = this.app.workspace.activeLeaf;
if (leaf) {
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"0.2.1": "0.10.9",
"0.2.2": "0.10.9",
"0.3.0": "0.10.9",
"0.3.1": "0.10.9"
"0.3.1": "0.10.9",
"0.3.2": "0.10.9"
}

0 comments on commit d3f1472

Please sign in to comment.