WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 90482db

Browse files
committed
fix: missing type aliases and MarkerGroup in ace-builds
1 parent c41e5be commit 90482db

File tree

7 files changed

+86
-46
lines changed

7 files changed

+86
-46
lines changed

ace-internal.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ export namespace Ace {
2929
type Config = typeof import("./src/config");
3030
type GutterTooltip = import( "./src/mouse/default_gutter_handler").GutterTooltip;
3131
type GutterKeyboardEvent = import( "./src/keyboard/gutter_handler").GutterKeyboardEvent;
32+
type HoverTooltip = import("ace-code/src/tooltip").HoverTooltip;
33+
type Tooltip = import("ace-code/src/tooltip").Tooltip;
34+
type PopupManager = import("ace-code/src/tooltip").PopupManager;
3235

3336
type AfterLoadCallback = (err: Error | null, module: unknown) => void;
3437
type LoaderFunction = (moduleName: string, afterLoad: AfterLoadCallback) => void;

ace.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ declare module "ace-code" {
3838
type Config = typeof import("ace-code/src/config");
3939
type GutterTooltip = import("ace-code/src/mouse/default_gutter_handler").GutterTooltip;
4040
type GutterKeyboardEvent = import("ace-code/src/keyboard/gutter_handler").GutterKeyboardEvent;
41+
type HoverTooltip = import("ace-code/src/tooltip").HoverTooltip;
42+
type Tooltip = import("ace-code/src/tooltip").Tooltip;
43+
type PopupManager = import("ace-code/src/tooltip").PopupManager;
4144
type AfterLoadCallback = (err: Error | null, module: unknown) => void;
4245
type LoaderFunction = (moduleName: string, afterLoad: AfterLoadCallback) => void;
4346
export interface ConfigOptions {

demo/test_ace_builds/index.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@ import * as ace from "ace-builds";
22
import {Range, Ace} from "ace-builds";
33
import "ace-builds/src-noconflict/ext-language_tools";
44
import "../../src/test/mockdom.js";
5+
56
var HoverTooltip = ace.require("ace/tooltip").HoverTooltip;
67
import "ace-builds/src-noconflict/mode-javascript";
78
import "ace-builds/src-noconflict/theme-monokai";
89

10+
const MarkerGroup = ace.require("ace/marker_group").MarkerGroup;
11+
const MouseEvent = ace.require("ace/mouse/mouse_event").MouseEvent;
12+
var Tooltip = ace.require("ace/tooltip").Tooltip;
13+
var popupManager: Ace.PopupManager = ace.require("ace/tooltip").popupManager;
14+
915
const editor = ace.edit(null); // should not be an error
1016
editor.setTheme("ace/theme/monokai");
1117
editor.session.setMode("ace/mode/javascript");
@@ -19,7 +25,20 @@ function configure(config: Ace.Config) {
1925

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

22-
const hover = new HoverTooltip();
28+
const markerGroup: Ace.MarkerGroup = new MarkerGroup(editor.session);
29+
const markers: Ace.MarkerGroupItem[] = [
30+
{
31+
range: new Range(0, 0, 10, 10),
32+
className: "test-class"
33+
}
34+
]
35+
markerGroup.setMarkers(markers);
36+
markerGroup.markers.every(marker => {
37+
console.log(marker.range);
38+
return true;
39+
});
40+
41+
const hover: Ace.HoverTooltip = new HoverTooltip();
2342
hover.setDataProvider((e: any, editor: Ace.Editor) => {
2443
const domNode = document.createElement("div");
2544
hover.showForRange(editor, new Range(1, 3, 3, 1), domNode, e);
@@ -34,4 +53,14 @@ editor.commands.on('exec', ({editor, command}) => {
3453
console.log(editor.getValue(), command.name);
3554
});
3655

56+
editor.container.addEventListener('click', (e: MouseEvent) => {
57+
var mouseEvent: Ace.MouseEvent = new MouseEvent(e, editor);
58+
mouseEvent.x = e.x * 2;
59+
});
60+
61+
var tooltip: Ace.Tooltip = new Tooltip(editor.container);
62+
tooltip.show('hello');
63+
64+
popupManager.addPopup(tooltip);
65+
3766
editor.destroy && editor.destroy();

demo/test_ace_builds/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"ace-builds": "file:../../ace-builds-latest.tgz"
1212
},
1313
"devDependencies": {
14-
"typescript": "^5.7.3"
14+
"typescript": "^5.8.2"
1515
}
1616
}

src/ext/language_tools.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ var config = require("../config");
66
var lang = require("../lib/lang");
77
var util = require("../autocomplete/util");
88

9+
var MarkerGroup = require("../marker_group").MarkerGroup;
10+
911
var textCompleter = require("../autocomplete/text_completer");
1012
/**@type {import("../../ace-internal").Ace.Completer}*/
1113
var keyWordCompleter = {
@@ -230,3 +232,5 @@ require("../config").defineOptions(Editor.prototype, "editor", {
230232
value: false
231233
}
232234
});
235+
236+
exports.MarkerGroup = MarkerGroup;

types/ace-ext.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ declare module "ace-code/src/ext/language_tools" {
8585
import textCompleter = require("ace-code/src/autocomplete/text_completer");
8686
export var keyWordCompleter: import("ace-code").Ace.Completer;
8787
export var snippetCompleter: import("ace-code").Ace.Completer;
88-
export { textCompleter };
88+
import { MarkerGroup } from "ace-code/src/marker_group";
89+
export { textCompleter, MarkerGroup };
8990
}
9091
declare module "ace-code/src/ext/inline_autocomplete" {
9192
/**

types/ace-modules.d.ts

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3313,6 +3313,49 @@ declare module "ace-code/src/autocomplete" {
33133313
completions: Ace.FilteredList;
33143314
}
33153315
}
3316+
declare module "ace-code/src/marker_group" {
3317+
export type EditSession = import("ace-code/src/edit_session").EditSession;
3318+
export type MarkerGroupItem = {
3319+
range: import("ace-code/src/range").Range;
3320+
className: string;
3321+
};
3322+
export type LayerConfig = import("ace-code").Ace.LayerConfig;
3323+
export type Marker = import("ace-code/src/layer/marker").Marker;
3324+
export class MarkerGroup {
3325+
/**
3326+
* @param {{markerType: "fullLine" | "line" | undefined}} [options] Options controlling the behvaiour of the marker.
3327+
* User `markerType` to control how the markers which are part of this group will be rendered:
3328+
* - `undefined`: uses `text` type markers where only text characters within the range will be highlighted.
3329+
* - `fullLine`: will fully highlight all the rows within the range, including the characters before and after the range on the respective rows.
3330+
* - `line`: will fully highlight the lines within the range but will only cover the characters between the start and end of the range.
3331+
*/
3332+
constructor(session: EditSession, options?: {
3333+
markerType: "fullLine" | "line" | undefined;
3334+
});
3335+
markerType: "line" | "fullLine";
3336+
markers: import("ace-code").Ace.MarkerGroupItem[];
3337+
session: EditSession;
3338+
/**
3339+
* Finds the first marker containing pos
3340+
*/
3341+
getMarkerAtPosition(pos: import("ace-code").Ace.Point): import("ace-code").Ace.MarkerGroupItem | undefined;
3342+
/**
3343+
* Comparator for Array.sort function, which sorts marker definitions by their positions
3344+
*
3345+
* @param {MarkerGroupItem} a first marker.
3346+
* @param {MarkerGroupItem} b second marker.
3347+
* @returns {number} negative number if a should be before b, positive number if b should be before a, 0 otherwise.
3348+
*/
3349+
markersComparator(a: MarkerGroupItem, b: MarkerGroupItem): number;
3350+
/**
3351+
* Sets marker definitions to be rendered. Limits the number of markers at MAX_MARKERS.
3352+
* @param {MarkerGroupItem[]} markers an array of marker definitions.
3353+
*/
3354+
setMarkers(markers: MarkerGroupItem[]): void;
3355+
update(html: any, markerLayer: Marker, session: EditSession, config: LayerConfig): void;
3356+
MAX_MARKERS: number;
3357+
}
3358+
}
33163359
declare module "ace-code/src/autocomplete/text_completer" {
33173360
export function getCompletions(editor: any, session: any, pos: any, prefix: any, callback: any): void;
33183361
}
@@ -3417,49 +3460,6 @@ declare module "ace-code/src/occur" {
34173460
import { Search } from "ace-code/src/search";
34183461
import { EditSession } from "ace-code/src/edit_session";
34193462
}
3420-
declare module "ace-code/src/marker_group" {
3421-
export type EditSession = import("ace-code/src/edit_session").EditSession;
3422-
export type MarkerGroupItem = {
3423-
range: import("ace-code/src/range").Range;
3424-
className: string;
3425-
};
3426-
export type LayerConfig = import("ace-code").Ace.LayerConfig;
3427-
export type Marker = import("ace-code/src/layer/marker").Marker;
3428-
export class MarkerGroup {
3429-
/**
3430-
* @param {{markerType: "fullLine" | "line" | undefined}} [options] Options controlling the behvaiour of the marker.
3431-
* User `markerType` to control how the markers which are part of this group will be rendered:
3432-
* - `undefined`: uses `text` type markers where only text characters within the range will be highlighted.
3433-
* - `fullLine`: will fully highlight all the rows within the range, including the characters before and after the range on the respective rows.
3434-
* - `line`: will fully highlight the lines within the range but will only cover the characters between the start and end of the range.
3435-
*/
3436-
constructor(session: EditSession, options?: {
3437-
markerType: "fullLine" | "line" | undefined;
3438-
});
3439-
markerType: "line" | "fullLine";
3440-
markers: import("ace-code").Ace.MarkerGroupItem[];
3441-
session: EditSession;
3442-
/**
3443-
* Finds the first marker containing pos
3444-
*/
3445-
getMarkerAtPosition(pos: import("ace-code").Ace.Point): import("ace-code").Ace.MarkerGroupItem | undefined;
3446-
/**
3447-
* Comparator for Array.sort function, which sorts marker definitions by their positions
3448-
*
3449-
* @param {MarkerGroupItem} a first marker.
3450-
* @param {MarkerGroupItem} b second marker.
3451-
* @returns {number} negative number if a should be before b, positive number if b should be before a, 0 otherwise.
3452-
*/
3453-
markersComparator(a: MarkerGroupItem, b: MarkerGroupItem): number;
3454-
/**
3455-
* Sets marker definitions to be rendered. Limits the number of markers at MAX_MARKERS.
3456-
* @param {MarkerGroupItem[]} markers an array of marker definitions.
3457-
*/
3458-
setMarkers(markers: MarkerGroupItem[]): void;
3459-
update(html: any, markerLayer: Marker, session: EditSession, config: LayerConfig): void;
3460-
MAX_MARKERS: number;
3461-
}
3462-
}
34633463
declare module "ace-code/src/edit_session/fold" {
34643464
export class Fold extends RangeList {
34653465
constructor(range: Range, placeholder: any);

0 commit comments

Comments
 (0)