Skip to content

Commit

Permalink
fix: small bug in moveToMouse; types
Browse files Browse the repository at this point in the history
  • Loading branch information
mkslanc committed Jan 27, 2025
1 parent 78d65ff commit e9ef62d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions ace-internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ export namespace Ace {
"gutterclick": (e: MouseEvent) => void;
"showGutterTooltip": (e: GutterTooltip) => void;
"hideGutterTooltip": (e: GutterTooltip) => void;
"compositionStart": () => void;
}

interface AcePopupEvents {
Expand Down Expand Up @@ -1334,6 +1335,7 @@ declare module "./src/editor" {
showSettingsMenu?: () => void,
searchBox?: Ace.SearchBox,
_eventRegistry?: any,
$textInputAriaLabel?: string
}
}

Expand Down
1 change: 1 addition & 0 deletions ace.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ declare module "ace-code" {
"gutterclick": (e: MouseEvent) => void;
"showGutterTooltip": (e: GutterTooltip) => void;
"hideGutterTooltip": (e: GutterTooltip) => void;
"compositionStart": () => void;
}
interface AcePopupEvents {
"click": (e: MouseEvent) => void;
Expand Down
4 changes: 2 additions & 2 deletions src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ class Editor {
/**
* Called whenever a text "paste" happens.
* @param {String} text The pasted text
* @param {any} event
* @param {ClipboardEvent} [event]
* @internal
**/
onPaste(text, event) {
Expand All @@ -863,7 +863,7 @@ class Editor {

/**
*
* @param {string | {text: string}} e
* @param {string | {text: string, event?: ClipboardEvent}} e
* @returns {boolean}
*/
$handlePaste(e) {
Expand Down
8 changes: 4 additions & 4 deletions src/keyboard/textinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var valueResetRegex = isIOS ? /\s/ : /\n/;
var isMobile = useragent.isMobile;

var TextInput;
TextInput= function(parentNode, host) {
TextInput= function(/**@type{HTMLTextAreaElement} */parentNode, /**@type{import("../editor").Editor} */host) {
/**@type {HTMLTextAreaElement & {msGetInputContext?: () => {compositionStartOffset: number}, getInputContext?: () => {compositionStartOffset: number}}}*/
var text = dom.createElement("textarea");
text.className = "ace_text-input";
Expand All @@ -35,7 +35,7 @@ TextInput= function(parentNode, host) {
text.style.opacity = "0";
parentNode.insertBefore(text, parentNode.firstChild);

var copied = false;
/**@type{boolean|string}*/var copied = false;
var pasted = false;
/**@type {(boolean|Object) & {context?: any, useTextareaForIME?: boolean, selectionStart?: number, markerRange?: any}}} */
var inComposition = false;
Expand All @@ -62,7 +62,7 @@ TextInput= function(parentNode, host) {

// Set number of extra lines in textarea, some screenreaders
// perform better with extra lines above and below in the textarea.
this.setNumberOfExtraLines = function(number) {
this.setNumberOfExtraLines = function(/**@type{number}*/number) {
rowStart = Number.MAX_SAFE_INTEGER;
rowEnd = Number.MIN_SAFE_INTEGER;

Expand Down Expand Up @@ -695,7 +695,7 @@ TextInput= function(parentNode, host) {
var rect = host.container.getBoundingClientRect();
var style = dom.computedStyle(host.container);
var top = rect.top + (parseInt(style.borderTopWidth) || 0);
var left = rect.left + (parseInt(rect.borderLeftWidth) || 0);
var left = rect.left + (parseInt(style.borderLeftWidth) || 0);
var maxTop = rect.bottom - top - text.clientHeight -2;
var move = function(e) {
dom.translate(text, e.clientX - left - 2, Math.min(e.clientY - top - 2, maxTop));
Expand Down

0 comments on commit e9ef62d

Please sign in to comment.