thlorenz / brace

📔 browserify compatible version of the ace editor.
http://thlorenz.github.io/brace/
MIT License
1.06k stars 304 forks source link

How to get Range from Brace and TypeScript? #189

Closed doom-goober closed 2 years ago

doom-goober commented 2 years ago

I am using Brace and TypeScript. It was all working swimmingly until I needed to use Range. For the life of me, I can't get Range into my project! It's always undefined even though TypeScript recognizes it during compilation.

Basically, I need the equivalent of: "const Range = ace.require('ace/range').Range" but using imports. ace.require is undefined and I don't know what the alternative is. Thanks!

doom-goober commented 2 years ago

Ok, figured it out. In Brace's index.js add this line:

exports.Range = acequire('ace/range').Range;

Then to use it:

import * as ace from "brace"
let range:ace.Ace.Range = ace.Range.fromPoints(start, end);
editor.selection.setRange(range);