Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: search and replace support in editor

ammarahm-ed7ccaf8c7a8c6
diff --git a/apps/mobile/android/app/src/main/assets/constants.js b/apps/mobile/android/app/src/main/assets/constants.js
index 9b552aa93..ee6ac4aec 100644
--- a/apps/mobile/android/app/src/main/assets/constants.js
+++ b/apps/mobile/android/app/src/main/assets/constants.js
@@ -125,12 +125,91 @@ function setTheme() {
#titleInput::-webkit-input-placeholder {
color:${pageTheme.colors.icon}
}
+
.info-bar {
color:${pageTheme.colors.icon};
}
#titlebar {
display:flex !important;
}
+
+ .tox .tox-tbtn:hover {
+ background: ${pageTheme.colors.shade} !important;
+ }
+
+ .tox-textfield {
+ border-radius: 0px !important;
+ border-color: ${pageTheme.colors.nav} !important;
+ border-width: 0px 0px 2px 0px !important;
+ color: var(--text) !important;
+ padding: 10px !important;
+ font-size: 0.875rem !important;
+ line-height: 0.875rem !important;
+ }
+
+ .tox-textfield:focus {
+ outline: none !important;
+ border-color: ${pageTheme.colors.accent} !important;
+ border-width: 0px 0px 2px 0px !important;
+ border-radius: 0px !important;
+ }
+
+ .tox-textfield:hover {
+ border-color: ${pageTheme.colors.accent + '80'} !important;
+ }
+
+ .tox-button {
+ background-color: ${pageTheme.colors.accent} !important;
+ color: white;
+ transition: opacity 300ms linear;
+ border-width: 0px !important;
+ }
+
+ .tox-button:hover:not(.tox-button[disabled="disabled"]) {
+ opacity: 0.8;
+ }
+
+ .tox-button--secondary,
+ .tox-button--icon {
+ background-color: ${pageTheme.colors.nav} !important;
+ color: ${pageTheme.colors.icon} !important;
+ }
+ .tox-button[disabled="disabled"] {
+ background-color: ${pageTheme.colors.nav} !important;
+ color: ${pageTheme.colors.icon} !important;
+ }
+
+ tox-tbtn tox-tbtn--select {
+ border-radius: 5px !important;
+ }
+
+ .tox-dialog {
+ border-radius: 5px !important;
+ border-width: 0px !important;
+ box-shadow: 4px 5px 18px 2px #00000038;
+ padding: 0px !important;
+ width: calc(100vw - 22px) !important;
+ margin-right:-2px !important;
+ }
+
+ .tox-dialog__footer {
+ border-top: 0px !important;
+ }
+
+ .tox-dialog__title {
+ color: ${pageTheme.colors.pri} !important;
+ font-size: 1.2rem !important;
+ font-weight: bold !important;
+ }
+
+ .tox .tox-toolbar,
+ .tox .tox-toolbar__overflow,
+ .tox .tox-toolbar__primary {
+ background: none !important;
+ border-bottom: 1px solid ${pageTheme.colors.nav} !important;
+ }
+
+
`;
css.appendChild(document.createTextNode(node));
document.getElementsByTagName('head')[0].appendChild(css);
@@ -143,13 +222,13 @@ var minifyImg = function (
resolve,
imageArguments = 0.7,
) {
- fetch(dataUrl).then(async (res) => {
+ fetch(dataUrl).then(async res => {
let blob = await res.blob();
new Compressor(blob, {
quality: imageArguments,
width: newWidth,
- mimeType:imageType,
- success: (result) => {
+ mimeType: imageType,
+ success: result => {
let fileReader = new FileReader();
fileReader.onloadend = function () {
resolve(fileReader.result);
@@ -157,7 +236,7 @@ var minifyImg = function (
};
fileReader.readAsDataURL(result);
},
- error: (err) => {
+ error: err => {
console.log(err.message);
},
});
@@ -170,13 +249,13 @@ function loadImage() {
if (fileInput.files != null && fileInput.files[0] != null) {
let reader = new FileReader();
console.log(reader.readyState, 'READY STATE');
- let load = (e) => {
+ let load = e => {
console.log(e, 'loaded error');
minifyImg(
reader.result,
1024,
'image/jpeg',
- (r) => {
+ r => {
var content = `<img style="max-width:100% !important;" src="${r}">`;
editor.insertContent(content);
},
diff --git a/apps/mobile/html/Web.bundle/site/constants.js b/apps/mobile/html/Web.bundle/site/constants.js
index 40fca3813..1aedf9b47 100644
--- a/apps/mobile/html/Web.bundle/site/constants.js
+++ b/apps/mobile/html/Web.bundle/site/constants.js
@@ -132,6 +132,83 @@ function setTheme() {
#titlebar {
display:flex !important;
}
+
+ .tox .tox-tbtn:hover {
+ background: ${pageTheme.colors.shade} !important;
+ }
+
+ .tox-textfield {
+ border-radius: 0px !important;
+ border-color: ${pageTheme.colors.nav} !important;
+ border-width: 0px 0px 2px 0px !important;
+ color: var(--text) !important;
+ padding: 10px !important;
+ font-size: 0.875rem !important;
+ line-height: 0.875rem !important;
+ }
+
+ .tox-textfield:focus {
+ outline: none !important;
+ border-color: ${pageTheme.colors.accent} !important;
+ border-width: 0px 0px 2px 0px !important;
+ border-radius: 0px !important;
+ }
+
+ .tox-textfield:hover {
+ border-color: ${pageTheme.colors.accent + '80'} !important;
+ }
+
+ .tox-button {
+ background-color: ${pageTheme.colors.accent} !important;
+ color: white;
+ transition: opacity 300ms linear;
+ border-width: 0px !important;
+ }
+
+ .tox-button:hover:not(.tox-button[disabled="disabled"]) {
+ opacity: 0.8;
+ }
+
+ .tox-button--secondary,
+ .tox-button--icon {
+ background-color: ${pageTheme.colors.nav} !important;
+ color: ${pageTheme.colors.icon} !important;
+ }
+ .tox-button[disabled="disabled"] {
+ background-color: ${pageTheme.colors.nav} !important;
+ color: ${pageTheme.colors.icon} !important;
+ }
+
+ tox-tbtn tox-tbtn--select {
+ border-radius: 5px !important;
+ }
+
+ .tox-dialog {
+ border-radius: 5px !important;
+ border-width: 0px !important;
+ box-shadow: 4px 5px 18px 2px #00000038;
+ padding: 0px !important;
+ width: calc(100vw - 22px) !important;
+ margin-right:-2px !important;
+ }
+
+ .tox-dialog__footer {
+ border-top: 0px !important;
+ }
+
+ .tox-dialog__title {
+ color: ${pageTheme.colors.pri} !important;
+ font-size: 1.2rem !important;
+ font-weight: bold !important;
+ }
+
+ .tox .tox-toolbar,
+ .tox .tox-toolbar__overflow,
+ .tox .tox-toolbar__primary {
+ background: none !important;
+ border-bottom: 1px solid ${pageTheme.colors.nav} !important;
+ }
+
`;
css.appendChild(document.createTextNode(node));
document.getElementsByTagName('head')[0].appendChild(css);
diff --git a/apps/mobile/src/views/Editor/tiny/toolbar/commands.js b/apps/mobile/src/views/Editor/tiny/toolbar/commands.js
index 1820df4b9..fa579d3f7 100644
--- a/apps/mobile/src/views/Editor/tiny/toolbar/commands.js
+++ b/apps/mobile/src/views/Editor/tiny/toolbar/commands.js
@@ -55,6 +55,7 @@ export const execCommands = {
horizontal: `tinymce.activeEditor.execCommand('InsertHorizontalRule');`,
rtl: `tinymce.activeEditor.execCommand('mceDirectionRTL');`,
ltr: `tinymce.activeEditor.execCommand('mceDirectionLTR');`,
+ magnify:`tinymce.activeEditor.execCommand('SearchReplace');`,
table: (r, c) =>
`tinymce.activeEditor.execCommand('mceInsertTable', false, { rows: ${r}, columns: ${c} })`,
cl: `tinymce.activeEditor.execCommand('InsertCheckList')`,
diff --git a/apps/mobile/src/views/Editor/tiny/toolbar/config.js b/apps/mobile/src/views/Editor/tiny/toolbar/config.js
index f4303ac22..4b7122af8 100644
--- a/apps/mobile/src/views/Editor/tiny/toolbar/config.js
+++ b/apps/mobile/src/views/Editor/tiny/toolbar/config.js
@@ -315,6 +315,11 @@ export const TOOLBAR_CONFIG = [
type: 'format',
fullname: 'Remove Formatting',
},
+ {
+ format: 'magnify',
+ type: 'format',
+ fullname: 'Search & Replace',
+ },
/* {
format: 'settings',
type: 'settings',
diff --git a/apps/mobile/src/views/Editor/tiny/toolbar/constants.js b/apps/mobile/src/views/Editor/tiny/toolbar/constants.js
index 2390e1599..6a24c63fd 100644
--- a/apps/mobile/src/views/Editor/tiny/toolbar/constants.js
+++ b/apps/mobile/src/views/Editor/tiny/toolbar/constants.js
@@ -168,5 +168,6 @@ export const TOOLBAR_ICONS = {
removeformat: 'format-clear',
horizontal: 'border-horizontal',
table: 'table-plus',
- settings:'cog-outline'
+ settings:'cog-outline',
+ magnify:"magnify"
};