Skip to content

Commit 309b4ce

Browse files
author
Ajit Kumar
committed
v1.10.1
1 parent 4fd799f commit 309b4ce

File tree

12 files changed

+118
-43
lines changed

12 files changed

+118
-43
lines changed

.vscode/plugins.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"plugins":["cordova-plugin-buildinfo","cordova-plugin-device","cordova-plugin-file","cordova-plugin-ftp","cordova-plugin-iap","cordova-plugin-sdcard","cordova-plugin-server","cordova-plugin-sftp","cordova-clipboard","cordova-plugin-browser","cordova-plugin-system"]}
1+
{"plugins":["cordova-plugin-buildinfo","cordova-plugin-device","cordova-plugin-file","cordova-plugin-ftp","cordova-plugin-iap","cordova-plugin-sdcard","cordova-plugin-server","cordova-plugin-sftp","cordova-clipboard","cordova-plugin-browser","cordova-plugin-system","cordova-plugin-consent","admob-plus-cordova"]}

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Change Log
22

3+
## [1.10.1]
4+
5+
- New
6+
- [x] **Updated Ace editor** | 946
7+
- Updated Ace editor to version 1.32.9
8+
- Fixes
9+
- [x] **Scrolling** | 946
10+
- Fixed scrollbars not showing up properly.
11+
312
## [1.10.0]
413

514
- New
@@ -12,8 +21,6 @@
1221
- Fixed updates for plugin not showing up.
1322
- [x] **Markdown** | 945
1423
- Fixed markdown preview not working properly.
15-
16-
- Fixes
1724
- [x] **Text selection** | 937
1825
- Fixed context menu not showing up when selecting all text from context menu after click and hold.
1926

config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version='1.0' encoding='utf-8' ?>
2-
<widget id="com.foxdebug.acode" android-versionCode="945" version="1.10.0"
2+
<widget id="com.foxdebug.acode" android-versionCode="946" version="1.10.1"
33
xmlns="http://www.w3.org/ns/widgets"
44
xmlns:android="http://schemas.android.com/apk/res/android"
55
xmlns:cdv="http://cordova.apache.org/ns/1.0">

src/ace/touchHandler.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,7 @@ export default function addTouchListeners(editor, minimal, onclick) {
526526
const hDirection = moveX > 0 ? RIGHT : LEFT;
527527

528528
const { getEditorHeight, getEditorWidth } = editorManager;
529-
// Why I used it in first place?
530-
// const { scrollLeft } = editor.renderer.scrollBarH;
531529
const scrollLeft = editor.renderer.getScrollLeft();
532-
// const { scrollTop } = editor.renderer.scrollBarV;
533530
const scrollTop = editor.renderer.getScrollTop();
534531
const [editorWidth, editorHeight] = [getEditorWidth(editor), getEditorHeight(editor)];
535532

@@ -986,6 +983,7 @@ export default function addTouchListeners(editor, minimal, onclick) {
986983
* Editor container on scroll end
987984
*/
988985
function onscrollend() {
986+
scrollTimeout = null;
989987
editor._emit('scroll-end');
990988
if (!touchEnded) return;
991989

@@ -1011,6 +1009,11 @@ export default function addTouchListeners(editor, minimal, onclick) {
10111009
* Editor container on change session
10121010
*/
10131011
function onchangesession() {
1012+
if (scrollTimeout) {
1013+
clearTimeout(scrollTimeout);
1014+
onscrollend();
1015+
}
1016+
10141017
cancelAnimationFrame(scrollAnimationFrame);
10151018
setTimeout(() => {
10161019
const copyText = editor.session.getTextRange(editor.getSelectionRange());

src/components/scrollbar/index.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import './style.scss';
22
import tag from 'html-tag-js';
33

44
/**
5-
* @typedef {HTMLElement} Scrollbar
5+
* @typedef {object} Scrollbar
66
* @property {function():void} destroy
77
* @property {function():void} render
88
* @property {function():void} show
99
* @property {function():void} hide
1010
* @property {function():void} resize
1111
* @property {function():void} onshow
12+
* @property {function():void} onhide
13+
* @property {function():void} hideImmediately
1214
* @property {number} value
1315
* @property {number} size
1416
* @property {boolean} visible
@@ -22,7 +24,7 @@ import tag from 'html-tag-js';
2224
* @param {Number} [options.width]
2325
* @param {function():void} [options.onscroll]
2426
* @param {function():void} [options.onscrollend]
25-
* @returns {Scrollbar}
27+
* @returns {Scrollbar & HTMLElement}
2628
*/
2729
export default function ScrollBar(options) {
2830
if (!options || !options.parent) {
@@ -225,6 +227,13 @@ export default function ScrollBar(options) {
225227
if (typeof onhide === 'function') onhide();
226228
}
227229

230+
function hideImmediately() {
231+
$scrollbar.dataset.hidden = true;
232+
$scrollbar.classList.add('hide');
233+
$scrollbar.remove();
234+
if (typeof onhide === 'function') onhide();
235+
}
236+
228237
Object.defineProperty($scrollbar, 'size', {
229238
get: () => scrollbarSize,
230239
set: setWidth,
@@ -279,5 +288,9 @@ export default function ScrollBar(options) {
279288
},
280289
});
281290

291+
Object.defineProperty($scrollbar, 'hideImmediately', {
292+
value: hideImmediately,
293+
});
294+
282295
return $scrollbar;
283296
}

src/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ declare const KEYBINDING_FILE: string;
88
declare const IS_FREE_VERSION: string;
99
declare const ANDROID_SDK_INT: number;
1010
declare const DOES_SUPPORT_THEME: boolean;
11+
declare const acode: object;
1112

1213
interface Window {
1314
ASSETS_DIRECTORY: string;
@@ -18,6 +19,7 @@ interface Window {
1819
IS_FREE_VERSION: string;
1920
ANDROID_SDK_INT: number;
2021
DOES_SUPPORT_THEME: boolean;
22+
acode: object;
2123
}
2224

2325
interface String{

src/lib/editorManager.js

Lines changed: 79 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ import { setCommands, setKeyBindings } from 'ace/commands';
1414
import { HARDKEYBOARDHIDDEN_NO, getSystemConfiguration } from './systemConfiguration';
1515
import SideButton, { sideButtonContainer } from 'components/sideButton';
1616

17-
//TODO: Add option to work multiple files at same time in large display.
18-
1917
/**
20-
*
21-
* @param {HTMLElement} $header
22-
* @param {HTMLElement} $body
18+
* Represents an editor manager that handles multiple files and provides various editor configurations and event listeners.
19+
* @param {HTMLElement} $header - The header element.
20+
* @param {HTMLElement} $body - The body element.
21+
* @returns {Promise<Object>} A promise that resolves to the editor manager object.
2322
*/
2423
async function EditorManager($header, $body) {
2524
/**
@@ -231,8 +230,8 @@ async function EditorManager($header, $body) {
231230
return manager;
232231

233232
/**
234-
*
235-
* @param {EditorFile} file
233+
* Adds a file to the manager's file list and updates the UI.
234+
* @param {File} file - The file to be added.
236235
*/
237236
function addFile(file) {
238237
if (manager.files.includes(file)) return;
@@ -241,6 +240,10 @@ async function EditorManager($header, $body) {
241240
$header.text = file.name;
242241
}
243242

243+
/**
244+
* Sets up the editor with various configurations and event listeners.
245+
* @returns {Promise<void>} A promise that resolves once the editor is set up.
246+
*/
244247
async function setupEditor() {
245248
const Emmet = ace.require('ace/ext/emmet');
246249
const textInput = editor.textInput.getElement();
@@ -386,6 +389,9 @@ async function EditorManager($header, $body) {
386389
);
387390
}
388391

392+
/**
393+
* Scrolls the cursor into view if it is not currently visible.
394+
*/
389395
function scrollCursorIntoView() {
390396
keyboardHandler.off('keyboardShow', scrollCursorIntoView);
391397
if (isCursorVisible()) return;
@@ -411,7 +417,7 @@ async function EditorManager($header, $body) {
411417
}
412418

413419
/**
414-
* Callback function
420+
* Sets the vertical scroll value of the editor. This is called when the editor is scrolled horizontally using the scrollbar.
415421
* @param {Number} value
416422
*/
417423
function onscrollV(value) {
@@ -425,13 +431,17 @@ async function EditorManager($header, $body) {
425431
cancelAnimationFrame(scrollAnimationFrame);
426432
}
427433

434+
/**
435+
* Handles the onscroll event for the vend element.
436+
*/
428437
function onscrollVend() {
429438
preventScrollbarV = false;
430439
}
431440

441+
432442
/**
433-
* Callback function
434-
* @param {Number} value
443+
* Sets the horizontal scroll value of the editor. This is called when the editor is scrolled vertically using the scrollbar.
444+
* @param {number} value - The scroll value.
435445
*/
436446
function onscrollH(value) {
437447
preventScrollbarH = true;
@@ -444,12 +454,15 @@ async function EditorManager($header, $body) {
444454
cancelAnimationFrame(scrollAnimationFrame);
445455
}
446456

457+
/**
458+
* Handles the event when the horizontal scrollbar reaches the end.
459+
*/
447460
function onscrollHEnd() {
448461
preventScrollbarH = false;
449462
}
450463

451464
/**
452-
* Callback function called on scroll vertically
465+
* Sets scrollbars value based on the editor's scroll position.
453466
*/
454467
function setHScrollValue() {
455468
if (appSettings.value.textWrap || preventScrollbarH) return;
@@ -466,13 +479,17 @@ async function EditorManager($header, $body) {
466479
editor._emit('scroll', 'horizontal');
467480
}
468481

482+
/**
483+
* Handles the scroll left event.
484+
* Updates the horizontal scroll value and renders the horizontal scrollbar.
485+
*/
469486
function onscrollleft() {
470487
setHScrollValue();
471488
$hScrollbar.render();
472489
}
473490

474491
/**
475-
* Callback function called on scroll vertically
492+
* Sets scrollbars value based on the editor's scroll position.
476493
*/
477494
function setVScrollValue() {
478495
if (preventScrollbarV) return;
@@ -489,11 +506,19 @@ async function EditorManager($header, $body) {
489506
editor._emit('scroll', 'vertical');
490507
}
491508

509+
/**
510+
* Handles the scroll top event.
511+
* Updates the vertical scroll value and renders the vertical scrollbar.
512+
*/
492513
function onscrolltop() {
493514
setVScrollValue();
494515
$vScrollbar.render();
495516
}
496517

518+
/**
519+
* Updates the floating button visibility based on the provided show parameter.
520+
* @param {boolean} [show=false] - Indicates whether to show the floating button.
521+
*/
497522
function updateFloatingButton(show = false) {
498523
const { $headerToggler } = acode;
499524
const { $toggler } = quickTools;
@@ -513,25 +538,30 @@ async function EditorManager($header, $body) {
513538
$headerToggler.classList.remove('hide');
514539
root.appendOuter($headerToggler);
515540
}
516-
} else {
517-
if (!scrollBarVisibilityCount) {
518-
if ($toggler.isConnected) {
519-
$toggler.classList.add('hide');
520-
timeoutQuicktoolsToggler = setTimeout(
521-
() => $toggler.remove(),
522-
300,
523-
);
524-
}
525-
if ($headerToggler.isConnected) {
526-
$headerToggler.classList.add('hide');
527-
timeoutHeaderToggler = setTimeout(() => $headerToggler.remove(), 300);
528-
}
529-
}
530541

531-
++scrollBarVisibilityCount;
542+
return;
543+
}
544+
545+
if (!scrollBarVisibilityCount) {
546+
if ($toggler.isConnected) {
547+
$toggler.classList.add('hide');
548+
timeoutQuicktoolsToggler = setTimeout(
549+
() => $toggler.remove(),
550+
300,
551+
);
552+
}
553+
if ($headerToggler.isConnected) {
554+
$headerToggler.classList.add('hide');
555+
timeoutHeaderToggler = setTimeout(() => $headerToggler.remove(), 300);
556+
}
532557
}
558+
559+
++scrollBarVisibilityCount;
533560
}
534561

562+
/**
563+
* Toggles the visibility of the problem button based on the presence of annotations in the files.
564+
*/
535565
function toggleProblemButton() {
536566
const fileWithProblems = manager.files.find((file) => {
537567
const annotations = file.session.getAnnotations();
@@ -545,6 +575,11 @@ async function EditorManager($header, $body) {
545575
}
546576
}
547577

578+
/**
579+
* Updates the side button container based on the value of `showSideButtons` in `appSettings`.
580+
* If `showSideButtons` is `false`, the side button container is removed from the DOM.
581+
* If `showSideButtons` is `true`, the side button container is appended to the body element.
582+
*/
548583
function updateSideButtonContainer() {
549584
const { showSideButtons } = appSettings.value;
550585
if (!showSideButtons) {
@@ -555,6 +590,10 @@ async function EditorManager($header, $body) {
555590
$body.append(sideButtonContainer);
556591
}
557592

593+
/**
594+
* Updates the margin of the editor and optionally updates the gutter settings.
595+
* @param {boolean} [updateGutter=false] - Whether to update the gutter settings.
596+
*/
558597
function updateMargin(updateGutter = false) {
559598
const { showSideButtons, linenumbers, showAnnotations } = appSettings.value;
560599
const top = 0;
@@ -576,6 +615,10 @@ async function EditorManager($header, $body) {
576615
});
577616
}
578617

618+
/**
619+
* Switches the active file in the editor.
620+
* @param {string} id - The ID of the file to switch to.
621+
*/
579622
function switchFile(id) {
580623
const { id: activeFileId } = manager.activeFile || {};
581624
if (activeFileId === id) return;
@@ -587,8 +630,8 @@ async function EditorManager($header, $body) {
587630
editor.setSession(file.session);
588631
$header.text = file.filename;
589632

590-
$hScrollbar.remove();
591-
$vScrollbar.remove();
633+
$hScrollbar.hideImmediately();
634+
$vScrollbar.hideImmediately();
592635

593636
setVScrollValue();
594637
if (!appSettings.value.textWrap) {
@@ -601,6 +644,9 @@ async function EditorManager($header, $body) {
601644
events.emit('switch-file', file);
602645
}
603646

647+
/**
648+
* Initializes the file tab container.
649+
*/
604650
function initFileTabContainer() {
605651
let $list;
606652

@@ -656,6 +702,10 @@ async function EditorManager($header, $body) {
656702
manager.emit('int-open-file-list', openFileListPos);
657703
}
658704

705+
/**
706+
* Checks if there are any unsaved files in the manager.
707+
* @returns {number} The number of unsaved files.
708+
*/
659709
function hasUnsavedFiles() {
660710
const unsavedFiles = manager.files.filter((file) => file.isUnsaved);
661711
return unsavedFiles.length;

www/js/ace/ace.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

www/js/ace/ext-inline_autocomplete.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

www/js/ace/ext-language_tools.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)