A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
update title input for mobile devices
ammarahm-ed50e0a5c76b63
diff --git a/apps/mobile/html/Web.bundle/site/constants.js b/apps/mobile/html/Web.bundle/site/constants.jsindex 190609f88..ea7fb300d 100644--- a/apps/mobile/html/Web.bundle/site/constants.js+++ b/apps/mobile/html/Web.bundle/site/constants.js@@ -1,34 +1,32 @@let requiring = null;const pageTheme = {- colors: {- accent: '#0560FF',- shade: '#0560FF12',- fg: '#0560FF',- normal: 'black',- icon: 'gray',- errorBg: '#FFD2D2',- errorText: '#D8000C',- successBg: '#DFF2BF',- successText: '#4F8A10',- warningBg: '#FEEFB3',- warningText: '#9F6000',- night: false,- bg: 'white',- navbg: '#f6fbfc',- nav: '#f0f0f0',- pri: 'black',- sec: 'white',- factor: 1- }-}+ colors: {+ accent: '#0560FF',+ shade: '#0560FF12',+ fg: '#0560FF',+ normal: 'black',+ icon: 'gray',+ errorBg: '#FFD2D2',+ errorText: '#D8000C',+ successBg: '#DFF2BF',+ successText: '#4F8A10',+ warningBg: '#FEEFB3',+ warningText: '#9F6000',+ night: false,+ bg: 'white',+ navbg: '#f6fbfc',+ nav: '#f0f0f0',+ pri: 'black',+ sec: 'white',+ factor: 1,+ },+};const setTheme = function () {+ let css = document.createElement('style');+ css.type = 'text/css';-- let css = document.createElement('style');- css.type = 'text/css';-- let node = `+ let node = `.ql-snow.ql-toolbar button.ql-active,.ql-snow .ql-toolbar button.ql-active,.ql-snow.ql-toolbar .ql-picker-label:hover,@@ -187,7 +185,7 @@ const setTheme = function () {color: ${pageTheme.colors.icon};display: inline-block;float: left;- font-size:${(pageTheme.colors.factor * 13)};+ font-size:${pageTheme.colors.factor * 13};font-weight: 500;position: relative;vertical-align: middle;@@ -243,7 +241,7 @@ const setTheme = function () {padding: 5px 12px;white-space: nowrap;position: absolute;- font-size:${(pageTheme.colors.factor * 11)};+ font-size:${pageTheme.colors.factor * 11};}.ql-snow .ql-tooltip a.ql-action::after {@@ -262,8 +260,8 @@ const setTheme = function () {.ql-snow.ql-toolbar button,.ql-snow .ql-toolbar button {- height: ${(pageTheme.colors.factor * 32)};- width: ${(pageTheme.colors.factor * 36)};+ height: ${pageTheme.colors.factor * 32};+ width: ${pageTheme.colors.factor * 36};}@@ -308,7 +306,7 @@ const setTheme = function () {border-color:${pageTheme.colors.nav};}.ql-container {- font-size:${(pageTheme.colors.factor * 18)};+ font-size:${pageTheme.colors.factor * 15};color:${pageTheme.colors.pri};}@@ -335,196 +333,216 @@ const setTheme = function () {font-size: 25px;}++ #simpleTitleInput {+ font-family: 'Poppins', sans-serif;+ font-weight: 600 !important;+ background-color: transparent;+ border: none;+ width: 100%;+ outline: none;+ font-size: 24px;+ padding-right: 12px;+ padding-left:12px;+ height:50px;+ }+ .info-bar {+ margin-bottom:${isTablet ? '12px !important' : '0px !important'};+ padding-left:12px;+ }++ #titlebarAlt {+ height:50px;+ display:${isTablet ? 'none !important' : 'flex !important'};+ justify-content: center;+ flex-direction: column;+ }+ #titlebar {+ display:${!isTablet ? 'none !important' : 'flex !important'};+ }+ .ql-container {+ box-sizing: border-box;+ font-family: 'Poppins', sans-serif;+ margin: 0px;+ position: relative;+ height:${+ isTablet+ ? 'calc(100% - 260px) !important'+ : 'calc(100% - 110px) !important'+ };+ }- `- css.appendChild(document.createTextNode(node));- document.getElementsByTagName("head")[0].appendChild(css);-}+ `;+ css.appendChild(document.createTextNode(node));+ document.getElementsByTagName('head')[0].appendChild(css);+};let proToolbar = [- [{header: 1}, {header: 2}],- [{size: ['small', false, 'large', 'huge']}], // custom dropdown- ['bold', 'italic', 'image'], // toggled buttons- [{list: 'ordered'}, {list: 'bullet'}, {list: 'check'}],- [{header: [3, 4, 5, 6]}],- [{align: []}],- [{color: []}, {background: []}], // dropdown with defaults from theme- ['underline', 'strike', 'blockquote', 'code-block'],- [{script: 'sub'}, {script: 'super'}], // superscript/subscript- [{indent: '-1'}, {indent: '+1'}], // outdent/indent- [{direction: 'rtl'}], // text direction- ['clean'],+ [{header: 1}, {header: 2}],+ [{size: ['small', false, 'large', 'huge']}], // custom dropdown+ ['bold', 'italic', 'image'], // toggled buttons+ [{list: 'ordered'}, {list: 'bullet'}, {list: 'check'}],+ [{header: [3, 4, 5, 6]}],+ [{align: []}],+ [{color: []}, {background: []}], // dropdown with defaults from theme+ ['underline', 'strike', 'blockquote', 'code-block'],+ [{script: 'sub'}, {script: 'super'}], // superscript/subscript+ [{indent: '-1'}, {indent: '+1'}], // outdent/indent+ [{direction: 'rtl'}], // text direction+ ['clean'],];let simpleToolbar = [- [{header: 1}, {header: 2}],- ['bold', 'italic', 'underline', 'strike'], // toggled buttons- [{align: []}],- [{direction: 'rtl'}], // text direction-+ [{header: 1}, {header: 2}],+ ['bold', 'italic', 'underline', 'strike'], // toggled buttons+ [{align: []}],+ [{direction: 'rtl'}], // text direction];let fonts = ['DM Sans', 'sans-serif'];-let fontNames = fonts.map(font => getFontName(font));+let fontNames = fonts.map((font) => getFontName(font));function getFontName(font) {- return font.toLowerCase().replace(/\s/g, '-');+ return font.toLowerCase().replace(/\s/g, '-');}function addLinkMatcher() {- editor.clipboard.addMatcher(Node.TEXT_NODE, function (node, delta) {- let regex = /https?:\/\/[^\s]+/g;- if (typeof node.data !== 'string') return;-- let matches = node.data.toLowerCase().match(regex);-- if (matches && matches.length > 0) {- let ops = [];- let str = node.data;- matches.forEach(function (match) {- let split = str.split(match);- let beforeLink = split.shift();- ops.push({insert: beforeLink});- ops.push({insert: match, attributes: {link: match}});- str = split.join(match);- });- ops.push({insert: str});- delta.ops = ops;- }-- return delta;- });+ editor.clipboard.addMatcher(Node.TEXT_NODE, function (node, delta) {+ let regex = /https?:\/\/[^\s]+/g;+ if (typeof node.data !== 'string') return;++ let matches = node.data.toLowerCase().match(regex);++ if (matches && matches.length > 0) {+ let ops = [];+ let str = node.data;+ matches.forEach(function (match) {+ let split = str.split(match);+ let beforeLink = split.shift();+ ops.push({insert: beforeLink});+ ops.push({insert: match, attributes: {link: match}});+ str = split.join(match);+ });+ ops.push({insert: str});+ delta.ops = ops;+ }++ return delta;+ });}function setFonts() {- // specify the fonts you would- let fontStyles = '';- fonts.forEach(function (font) {- let fontName = getFontName(font);- fontStyles +=- '.ql-snow .ql-picker.ql-font .ql-picker-label[data-value=' +- fontName +- ']::before, .ql-snow .ql-picker.ql-font .ql-picker-item[data-value=' +- fontName +- ']::before {' +- "content: '" +- font +- "';" +- "font-family: '" +- font +- "';" +- '}' +- '.ql-font-' +- fontName +- '{' +- " font-family: '" +- font +- "';" +- '}';- });- let node = document.createElement('style');- node.innerHTML = fontStyles;- document.body.appendChild(node);+ // specify the fonts you would+ let fontStyles = '';+ fonts.forEach(function (font) {+ let fontName = getFontName(font);+ fontStyles +=+ '.ql-snow .ql-picker.ql-font .ql-picker-label[data-value=' ++ fontName ++ ']::before, .ql-snow .ql-picker.ql-font .ql-picker-item[data-value=' ++ fontName ++ ']::before {' ++ "content: '" ++ font ++ "';" ++ "font-family: '" ++ font ++ "';" ++ '}' ++ '.ql-font-' ++ fontName ++ '{' ++ " font-family: '" ++ font ++ "';" ++ '}';+ });+ let node = document.createElement('style');+ node.innerHTML = fontStyles;+ document.body.appendChild(node);}function fixDropdownMenuLocations() {- document.querySelectorAll('.ql-picker').forEach(e => {- e.addEventListener('mousedown', function (e) {- e.preventDefault();-- })- })-- document.querySelectorAll('.ql-picker-label').forEach(e => {- e.addEventListener('click', function (evt) {-- let top;- let left;- let menu;- let evtItemWidth;- let evtItemHeight;-- if (!evt.target.offsetParent) {-- let _myLocalElement = evt.target.parentElement;-- var rect = _myLocalElement.getBoundingClientRect();- evtItemWidth = _myLocalElement.offsetParent.offsetWidth;- evtItemHeight = _myLocalElement.offsetParent.offsetHeight;-- top = rect.top;- left = rect.left;-- menu = _myLocalElement.attributes.getNamedItem('aria-controls').value;-- } else {- //left = evt.target.offsetParent.offsetLeft;- evtItemWidth = evt.target.offsetParent.offsetWidth;- evtItemHeight = evt.target.offsetParent.offsetHeight;--- var rect = evt.target.offsetParent.getBoundingClientRect();- top = rect.top;- left = rect.left;- menu = evt.target.attributes.getNamedItem('aria-controls').value;- }--- let menuHeight = document.getElementById(menu).offsetHeight;- let menuWidth = document.getElementById(menu).offsetWidth;- let wDiff;- if (menuWidth < evtItemWidth) {- wDiff = evtItemWidth - menuWidth;- left = left + (wDiff / 2);- } else {- wDiff = menuWidth - evtItemWidth;- left = left - (wDiff / 2);- }--- dropDownFixPosition(- '.ql-picker-label',- menu,- top,- left,- menuHeight,- menuWidth- )-- })- })--- function dropDownFixPosition(button, dropdown, top, left, height, width) {-- let b = document.querySelector(button);-- var dropDownTop = top - (b.offsetHeight / 2) - height;-- let screenWidth = window.outerWidth;-- if (left + width > screenWidth) {- left = left - (left + width - screenWidth);- left -= 10;-- }- document.getElementById(dropdown).style.top = dropDownTop;- document.getElementById(dropdown).style.left = left;-- //dropdown.css('top', dropDownTop + 'px');- //dropdown.css('left', left + 'px');+ document.querySelectorAll('.ql-picker').forEach((e) => {+ e.addEventListener('mousedown', function (e) {+ e.preventDefault();+ });+ });++ document.querySelectorAll('.ql-picker-label').forEach((e) => {+ e.addEventListener('click', function (evt) {+ let top;+ let left;+ let menu;+ let evtItemWidth;+ let evtItemHeight;++ if (!evt.target.offsetParent) {+ let _myLocalElement = evt.target.parentElement;++ var rect = _myLocalElement.getBoundingClientRect();+ evtItemWidth = _myLocalElement.offsetParent.offsetWidth;+ evtItemHeight = _myLocalElement.offsetParent.offsetHeight;++ top = rect.top;+ left = rect.left;++ menu = _myLocalElement.attributes.getNamedItem('aria-controls').value;+ } else {+ //left = evt.target.offsetParent.offsetLeft;+ evtItemWidth = evt.target.offsetParent.offsetWidth;+ evtItemHeight = evt.target.offsetParent.offsetHeight;++ var rect = evt.target.offsetParent.getBoundingClientRect();+ top = rect.top;+ left = rect.left;+ menu = evt.target.attributes.getNamedItem('aria-controls').value;+ }++ let menuHeight = document.getElementById(menu).offsetHeight;+ let menuWidth = document.getElementById(menu).offsetWidth;+ let wDiff;+ if (menuWidth < evtItemWidth) {+ wDiff = evtItemWidth - menuWidth;+ left = left + wDiff / 2;+ } else {+ wDiff = menuWidth - evtItemWidth;+ left = left - wDiff / 2;+ }++ dropDownFixPosition(+ '.ql-picker-label',+ menu,+ top,+ left,+ menuHeight,+ menuWidth,+ );+ });+ });- window.addEventListener('resize', function () {+ function dropDownFixPosition(button, dropdown, top, left, height, width) {+ let b = document.querySelector(button);+ var dropDownTop = top - b.offsetHeight / 2 - height;- let currentTop = document.querySelector('#toolbar').offsetTop;+ let screenWidth = window.outerWidth;- let downTop =- currentTop - b.offsetHeight - height;+ if (left + width > screenWidth) {+ left = left - (left + width - screenWidth);+ left -= 10;+ }+ document.getElementById(dropdown).style.top = dropDownTop;+ document.getElementById(dropdown).style.left = left;+ //dropdown.css('top', dropDownTop + 'px');+ //dropdown.css('left', left + 'px');- document.getElementById(dropdown).style.top = downTop + 20;- document.getElementById(dropdown).style.left = left;+ window.addEventListener('resize', function () {+ let currentTop = document.querySelector('#toolbar').offsetTop;+ let downTop = currentTop - b.offsetHeight - height;- })- }-}\ No newline at end of file+ document.getElementById(dropdown).style.top = downTop + 20;+ document.getElementById(dropdown).style.left = left;+ });+ }+}diff --git a/apps/mobile/html/Web.bundle/site/index.html b/apps/mobile/html/Web.bundle/site/index.htmlindex 538c77e27..51f84dae6 100644--- a/apps/mobile/html/Web.bundle/site/index.html+++ b/apps/mobile/html/Web.bundle/site/index.html@@ -20,17 +20,48 @@.ql-toolbar::-webkit-scrollbar {display: none;}+++ #simpleTitleInput {+ font-family: 'Poppins', sans-serif;+ font-weight: 600 !important;+ background-color: transparent;+ border: none;+ width: 100%;+ outline: none;+ font-size: 24px;+ padding-right: 12px;+ padding-left:12px;+ height:50px;+ }+ .info-bar {+ margin-bottom: 0px !important;+ }++ #titlebarAlt {+ height:50px;+ display: flex;+ justify-content: center;+ flex-direction: column;+ }+ #titlebar {+ display: none !important;+ }+++</style></head><body class="app-body"><div class="app-main">- <div id="titlebar">- <form id="formBox">+ <div id="titlebar">+ <form id="formBox"><textarea maxlength="150" id="titleInput" placeholder="Title here"></textarea>+<div id="textCopy"></div>- </form>+ </form><div class="info-bar"><p id="infowords"></p><p>-</p>@@ -38,20 +69,37 @@<p>-</p><p id="infosaved"></p></div>+ </div>++ <div id="titlebarAlt">++ <input maxlength="150" id="simpleTitleInput" placeholder="Title here"></input>+ <div class="info-bar info-bar-alt">+ <p id="infowords"></p>+ <p>-</p>+ <p id="infodate"></p>+ <p>-</p>+ <p id="infosaved"></p>+ </div></div>++<div id="editor"></div></div><div id="toolbar"></div></body>+<script>+ let editor;+ let isTablet = false;+ </script><script src="quill.js"></script><script src="constants.js"></script>-<script src="listeners.js"></script><script src="module.js"></script><script src="image-resize.min.js"></script><script src="magic-url.js"></script>+<script src="listeners.js"></script><script>- let editor;const List = Quill.import("formats/list");let BlockEmbed = Quill.import("blots/block/embed");class HorizontalRule extends BlockEmbed { }@@ -404,7 +452,7 @@}const SnowTheme = Quill.import("themes/snow");- const Toolbar = Quill.import("modules/toolbar");+ const Toolbar = Quill.import("modules/toolbar");const handlers = {...Toolbar.DEFAULTS.handlers,@@ -430,11 +478,12 @@};- function loadAction(premium, noMenu) {+ function loadAction(premium, tab) {+ isTablet = tab;let titleIn = document.getElementById('titlebar');titleIn.style['padding-left'] = 0;titleIn.style['padding-right'] = 0;-+let mainToolbar = premium ? proToolbar : simpleToolbar;setFonts();Quill.register('modules/imageCompressor', imageCompressor);@@ -508,7 +557,6 @@fixDropdownMenuLocations();}- loadAction();</script></html>\ No newline at end of filediff --git a/apps/mobile/html/Web.bundle/site/listeners.js b/apps/mobile/html/Web.bundle/site/listeners.jsindex b3ab8ae64..8fa2c84dc 100644--- a/apps/mobile/html/Web.bundle/site/listeners.js+++ b/apps/mobile/html/Web.bundle/site/listeners.js@@ -1,25 +1,30 @@+let titleInput = isTablet ? 'titleInput' : 'simpleTitleInput';+let infoBar = isTablet ? '.info-bar' : '.info-bar-alt';+let info = null;function attachTitleInputListeners() {+ titleInput = isTablet ? 'titleInput' : 'simpleTitleInput';+ infoBar = isTablet ? '.info-bar' : '.info-bar-alt';document.addEventListener('DOMContentLoaded',() => {autosize();document- .querySelector('.app-main')- .addEventListener('scroll', (event) => {- if (scrollTimer) {- clearTimeout(scrollTimer);- scrollTimer = null;- }- scrollTimer = setTimeout(() => {- window.ReactNativeWebView.postMessage(- JSON.stringify({- visible: document.querySelector('.app-main').scrollTop,- title: document.getElementById('titleInput').value,- type: 'scroll',- }),- );- }, 100);- });+ .querySelector('.app-main')+ .addEventListener('scroll', (event) => {+ if (scrollTimer) {+ clearTimeout(scrollTimer);+ scrollTimer = null;+ }+ scrollTimer = setTimeout(() => {+ window.ReactNativeWebView.postMessage(+ JSON.stringify({+ visible: document.querySelector('.app-main').scrollTop,+ title: document.getElementById(titleInput).value,+ type: 'scroll',+ }),+ );+ }, 100);+ });},false,);@@ -31,7 +36,7 @@ function attachTitleInputListeners() {onTitleChange();};- document.getElementById('titleInput').onkeypress = function (evt) {+ document.getElementById(titleInput).onkeypress = function (evt) {if (evt.keyCode === 13 || evt.which === 13) {evt.preventDefault();editor.focus();@@ -41,15 +46,15 @@ function attachTitleInputListeners() {}};- document.getElementById('titleInput').onkeydown = function (evt) {+ document.getElementById(titleInput).onkeydown = function (evt) {onTitleChange(evt);};- document.getElementById('titleInput').onchange = function (evt) {+ document.getElementById(titleInput).onchange = function (evt) {autosize();};- document.getElementById('titleInput').onkeyup = function (evt) {+ document.getElementById(titleInput).onkeyup = function (evt) {onTitleChange(evt);};}@@ -57,7 +62,7 @@ function attachTitleInputListeners() {function onTitleChange(ele) {let titleMessage = {type: 'title',- value: document.getElementById('titleInput').value,+ value: document.getElementById(titleInput).value,};autosize();if (titleMessage && typeof titleMessage.value === 'string') {@@ -66,15 +71,19 @@ function onTitleChange(ele) {}function autosize() {- document.getElementById('textCopy').innerHTML = document- .getElementById('titleInput')- .value.replace(/\n/g, '<br/>');+ if (isTablet) {+ document.getElementById('textCopy').innerHTML = document+ .getElementById(titleInput)+ .value.replace(/\n/g, '<br/>');+ }}function attachEditorListeners() {/* editor.once('text-change', function () {window.ReactNativeWebView.postMessage('loaded');}); */+ titleInput = isTablet ? 'titleInput' : 'simpleTitleInput';+ infoBar = isTablet ? '.info-bar' : '.info-bar-alt';window.addEventListener('message', (data) => {let message = JSON.parse(data.data);@@ -89,14 +98,16 @@ function attachEditorListeners() {case 'reset': {editor.history.clear();editor.setText('', 'api');- document.getElementById('titleInput').value = '';- document.getElementById('titleInput').blur();+ document.getElementById(titleInput).value = '';+ document.getElementById(titleInput).blur();editor.blur();- document.getElementById('titleInput').blur();+ document.getElementById(titleInput).blur();window.blur();- document.getElementById('infodate').innerText = '';- document.getElementById('infosaved').innerText = '';- document.getElementById('infowords').innerText = '';++ info = document.querySelector(infoBar);+ info.querySelector('#infodate').innerText = '';+ info.querySelector('#infosaved').innerText = '';+ info.querySelector('#infowords').innerText = '';autosize();break;}@@ -115,7 +126,7 @@ function attachEditorListeners() {}break;case 'blur':- document.getElementById('titleInput').blur();+ document.getElementById(titleInput).blur();editor.blur();window.blur();break;@@ -129,18 +140,21 @@ function attachEditorListeners() {editor.history.clear();break;case 'dateEdited':- document.getElementById('infodate').innerText = value;+ linfo = document.querySelector(infoBar);+ info.querySelector('#infodate').innerText = value;break;case 'saving':- document.getElementById('infosaved').innerText = value;+ info = document.querySelector(infoBar);+ info.querySelector('#infosaved').innerText = value;break;case 'text':editor.setText(value, 'api');setTimeout(() => {- document.getElementById('infowords').innerText =+ info = document.querySelector(infoBar);+ info.querySelector('#infowords').innerText =editor.getText().split(' ').length + ' words';- document.getElementById('infosaved').innerText = 'Saved';+ info.querySelector('#infosaved').innerText = 'Saved';}, 100);break;@@ -148,13 +162,13 @@ function attachEditorListeners() {editor.setText('', 'api');break;case 'clearTitle':- document.getElementById('titleInput').value = '';+ document.getElementById(titleInput).value = '';break;case 'focusEditor':editor.focus();break;case 'focusTitle':- document.getElementById('titleInput').focus();+ document.getElementById(titleInput).focus();autosize();break;case 'nomenu':@@ -172,9 +186,7 @@ function attachEditorListeners() {}break;case 'title':- document.getElementById('titleInput').value = JSON.parse(- data.data,- ).value;+ document.getElementById(titleInput).value = JSON.parse(data.data).value;autosize();break;case 'theme':@@ -187,9 +199,10 @@ function attachEditorListeners() {editor.setContents(content, 'api');setTimeout(() => {- document.getElementById('infowords').innerText =+ info = document.querySelector(infoBar);+ info.querySelector('#infowords').innerText =editor.getText().split(' ').length + ' words';- document.getElementById('infosaved').innerText = 'Saved';+ info.querySelector('#infosaved').innerText = 'Saved';document.body.scrollTop = 0; // For Safaridocument.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera@@ -248,13 +261,12 @@ function attachEditorListeners() {});}}-- let infowords = document.getElementById('infowords');+ info = document.querySelector(infoBar);+ let infowords = info.querySelector('#infowords');if (infowords) {- document.getElementById('infowords').innerText =- editor.getText().split(' ').length + ' words';+ infowords.innerText =+ editor.getText().split(' ').length + ' words';}-if (deltaTimeout) {clearTimeout(deltaTimeout);diff --git a/apps/mobile/html/Web.bundle/site/styles.css b/apps/mobile/html/Web.bundle/site/styles.cssindex 10d014222..618ed7806 100644--- a/apps/mobile/html/Web.bundle/site/styles.css+++ b/apps/mobile/html/Web.bundle/site/styles.css@@ -4,13 +4,7 @@* Copyright (c) 2014, Jason Chen* Copyright (c) 2013, salesforce.com*/-.ql-container {- box-sizing: border-box;- font-family: 'Poppins', sans-serif;- margin: 0px;- position: relative;- height: calc(100% - 260px) !important;-}+.ql-container.ql-disabled .ql-tooltip {visibility: hidden;@@ -1147,7 +1141,6 @@font-family: 'Poppins';margin-top: -8px;margin-bottom: 12px;- padding-left: 12px;}#titlebar textarea:focus {outline: none;