Skip to content

fix: missing type aliases and MarkerGroup in ace-builds #5782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ace-internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export namespace Ace {
type Config = typeof import("./src/config");
type GutterTooltip = import( "./src/mouse/default_gutter_handler").GutterTooltip;
type GutterKeyboardEvent = import( "./src/keyboard/gutter_handler").GutterKeyboardEvent;
type HoverTooltip = import("ace-code/src/tooltip").HoverTooltip;
type Tooltip = import("ace-code/src/tooltip").Tooltip;
type PopupManager = import("ace-code/src/tooltip").PopupManager;

type AfterLoadCallback = (err: Error | null, module: unknown) => void;
type LoaderFunction = (moduleName: string, afterLoad: AfterLoadCallback) => void;
Expand Down
3 changes: 3 additions & 0 deletions ace.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ declare module "ace-code" {
type Config = typeof import("ace-code/src/config");
type GutterTooltip = import("ace-code/src/mouse/default_gutter_handler").GutterTooltip;
type GutterKeyboardEvent = import("ace-code/src/keyboard/gutter_handler").GutterKeyboardEvent;
type HoverTooltip = import("ace-code/src/tooltip").HoverTooltip;
type Tooltip = import("ace-code/src/tooltip").Tooltip;
type PopupManager = import("ace-code/src/tooltip").PopupManager;
type AfterLoadCallback = (err: Error | null, module: unknown) => void;
type LoaderFunction = (moduleName: string, afterLoad: AfterLoadCallback) => void;
export interface ConfigOptions {
Expand Down
31 changes: 30 additions & 1 deletion demo/test_ace_builds/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ import * as ace from "ace-builds";
import {Range, Ace} from "ace-builds";
import "ace-builds/src-noconflict/ext-language_tools";
import "../../src/test/mockdom.js";

var HoverTooltip = ace.require("ace/tooltip").HoverTooltip;
import "ace-builds/src-noconflict/mode-javascript";
import "ace-builds/src-noconflict/theme-monokai";

const MarkerGroup = ace.require("ace/marker_group").MarkerGroup;
const MouseEvent = ace.require("ace/mouse/mouse_event").MouseEvent;
var Tooltip = ace.require("ace/tooltip").Tooltip;
var popupManager: Ace.PopupManager = ace.require("ace/tooltip").popupManager;

const editor = ace.edit(null); // should not be an error
editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/javascript");
Expand All @@ -19,7 +25,20 @@ function configure(config: Ace.Config) {

configure(ace.config) // should not be a error

const hover = new HoverTooltip();
const markerGroup: Ace.MarkerGroup = new MarkerGroup(editor.session);
const markers: Ace.MarkerGroupItem[] = [
{
range: new Range(0, 0, 10, 10),
className: "test-class"
}
]
markerGroup.setMarkers(markers);
markerGroup.markers.every(marker => {
console.log(marker.range);
return true;
});

const hover: Ace.HoverTooltip = new HoverTooltip();
hover.setDataProvider((e: any, editor: Ace.Editor) => {
const domNode = document.createElement("div");
hover.showForRange(editor, new Range(1, 3, 3, 1), domNode, e);
Expand All @@ -34,4 +53,14 @@ editor.commands.on('exec', ({editor, command}) => {
console.log(editor.getValue(), command.name);
});

editor.container.addEventListener('click', (e: MouseEvent) => {
var mouseEvent: Ace.MouseEvent = new MouseEvent(e, editor);
mouseEvent.x = e.x * 2;
});

var tooltip: Ace.Tooltip = new Tooltip(editor.container);
tooltip.show('hello');

popupManager.addPopup(tooltip);

editor.destroy && editor.destroy();
2 changes: 1 addition & 1 deletion demo/test_ace_builds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"ace-builds": "file:../../ace-builds-latest.tgz"
},
"devDependencies": {
"typescript": "^5.7.3"
"typescript": "^5.8.2"
}
}
4 changes: 4 additions & 0 deletions src/ext/language_tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ var config = require("../config");
var lang = require("../lib/lang");
var util = require("../autocomplete/util");

var MarkerGroup = require("../marker_group").MarkerGroup;

var textCompleter = require("../autocomplete/text_completer");
/**@type {import("../../ace-internal").Ace.Completer}*/
var keyWordCompleter = {
Expand Down Expand Up @@ -230,3 +232,5 @@ require("../config").defineOptions(Editor.prototype, "editor", {
value: false
}
});

exports.MarkerGroup = MarkerGroup;
3 changes: 2 additions & 1 deletion types/ace-ext.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ declare module "ace-code/src/ext/language_tools" {
import textCompleter = require("ace-code/src/autocomplete/text_completer");
export var keyWordCompleter: import("ace-code").Ace.Completer;
export var snippetCompleter: import("ace-code").Ace.Completer;
export { textCompleter };
import { MarkerGroup } from "ace-code/src/marker_group";
export { textCompleter, MarkerGroup };
}
declare module "ace-code/src/ext/inline_autocomplete" {
/**
Expand Down
86 changes: 43 additions & 43 deletions types/ace-modules.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3313,6 +3313,49 @@ declare module "ace-code/src/autocomplete" {
completions: Ace.FilteredList;
}
}
declare module "ace-code/src/marker_group" {
export type EditSession = import("ace-code/src/edit_session").EditSession;
export type MarkerGroupItem = {
range: import("ace-code/src/range").Range;
className: string;
};
export type LayerConfig = import("ace-code").Ace.LayerConfig;
export type Marker = import("ace-code/src/layer/marker").Marker;
export class MarkerGroup {
/**
* @param {{markerType: "fullLine" | "line" | undefined}} [options] Options controlling the behvaiour of the marker.
* User `markerType` to control how the markers which are part of this group will be rendered:
* - `undefined`: uses `text` type markers where only text characters within the range will be highlighted.
* - `fullLine`: will fully highlight all the rows within the range, including the characters before and after the range on the respective rows.
* - `line`: will fully highlight the lines within the range but will only cover the characters between the start and end of the range.
*/
constructor(session: EditSession, options?: {
markerType: "fullLine" | "line" | undefined;
});
markerType: "line" | "fullLine";
markers: import("ace-code").Ace.MarkerGroupItem[];
session: EditSession;
/**
* Finds the first marker containing pos
*/
getMarkerAtPosition(pos: import("ace-code").Ace.Point): import("ace-code").Ace.MarkerGroupItem | undefined;
/**
* Comparator for Array.sort function, which sorts marker definitions by their positions
*
* @param {MarkerGroupItem} a first marker.
* @param {MarkerGroupItem} b second marker.
* @returns {number} negative number if a should be before b, positive number if b should be before a, 0 otherwise.
*/
markersComparator(a: MarkerGroupItem, b: MarkerGroupItem): number;
/**
* Sets marker definitions to be rendered. Limits the number of markers at MAX_MARKERS.
* @param {MarkerGroupItem[]} markers an array of marker definitions.
*/
setMarkers(markers: MarkerGroupItem[]): void;
update(html: any, markerLayer: Marker, session: EditSession, config: LayerConfig): void;
MAX_MARKERS: number;
}
}
declare module "ace-code/src/autocomplete/text_completer" {
export function getCompletions(editor: any, session: any, pos: any, prefix: any, callback: any): void;
}
Expand Down Expand Up @@ -3417,49 +3460,6 @@ declare module "ace-code/src/occur" {
import { Search } from "ace-code/src/search";
import { EditSession } from "ace-code/src/edit_session";
}
declare module "ace-code/src/marker_group" {
export type EditSession = import("ace-code/src/edit_session").EditSession;
export type MarkerGroupItem = {
range: import("ace-code/src/range").Range;
className: string;
};
export type LayerConfig = import("ace-code").Ace.LayerConfig;
export type Marker = import("ace-code/src/layer/marker").Marker;
export class MarkerGroup {
/**
* @param {{markerType: "fullLine" | "line" | undefined}} [options] Options controlling the behvaiour of the marker.
* User `markerType` to control how the markers which are part of this group will be rendered:
* - `undefined`: uses `text` type markers where only text characters within the range will be highlighted.
* - `fullLine`: will fully highlight all the rows within the range, including the characters before and after the range on the respective rows.
* - `line`: will fully highlight the lines within the range but will only cover the characters between the start and end of the range.
*/
constructor(session: EditSession, options?: {
markerType: "fullLine" | "line" | undefined;
});
markerType: "line" | "fullLine";
markers: import("ace-code").Ace.MarkerGroupItem[];
session: EditSession;
/**
* Finds the first marker containing pos
*/
getMarkerAtPosition(pos: import("ace-code").Ace.Point): import("ace-code").Ace.MarkerGroupItem | undefined;
/**
* Comparator for Array.sort function, which sorts marker definitions by their positions
*
* @param {MarkerGroupItem} a first marker.
* @param {MarkerGroupItem} b second marker.
* @returns {number} negative number if a should be before b, positive number if b should be before a, 0 otherwise.
*/
markersComparator(a: MarkerGroupItem, b: MarkerGroupItem): number;
/**
* Sets marker definitions to be rendered. Limits the number of markers at MAX_MARKERS.
* @param {MarkerGroupItem[]} markers an array of marker definitions.
*/
setMarkers(markers: MarkerGroupItem[]): void;
update(html: any, markerLayer: Marker, session: EditSession, config: LayerConfig): void;
MAX_MARKERS: number;
}
}
declare module "ace-code/src/edit_session/fold" {
export class Fold extends RangeList {
constructor(range: Range, placeholder: any);
Expand Down
Loading