Added CM.registerHelper definition.

-- This is defined in the base library and
   used by a lot of addons.
-- Also fixed position constructor definition, as
   given by codemirror docs:

   CodeMirror.Pos(line: integer, ?ch: integer)
   * A constructor for the {line, ch} objects that are
   * used to represent positions in editor documents.
This commit is contained in:
Mark Wong Siang Kai
2016-03-03 20:47:15 -08:00
parent ba4c4fc6c9
commit 2e46d83d9f
2 changed files with 13 additions and 8 deletions
+4 -4
View File
@@ -39,10 +39,7 @@ var annotation: CodeMirror.Annotation = {
ch: 0,
line: 0
},
to: {
ch: 1,
line: 0
},
to: CodeMirror.Pos(1),
message: "test",
severity: "warning"
};
@@ -50,3 +47,6 @@ var annotation: CodeMirror.Annotation = {
myCodeMirror.getValue();
myCodeMirror.getValue("foo")
myCodeMirror.setValue("bar");
CodeMirror.registerHelper("lint", "javascript", {});
+9 -4
View File
@@ -32,6 +32,11 @@ declare module CodeMirror {
whenever a new CodeMirror instance is initialized. */
function defineInitHook(func: Function): void;
/** Registers a helper value with the given name in the given namespace (type). This is used to define functionality
that may be looked up by mode. Will create (if it doesn't already exist) a property on the CodeMirror object for
the given type, pointing to an object that maps names to values. I.e. after doing
CodeMirror.registerHelper("hint", "foo", myFoo), the value CodeMirror.hint.foo will point to myFoo. */
function registerHelper(namespace: string, name: string, helper: any): void;
function on(element: any, eventName: string, handler: Function): void;
@@ -651,8 +656,8 @@ declare module CodeMirror {
}
interface PositionConstructor {
new (line: number, ch: number): Position;
(line: number, ch: number): Position;
new (line: number, ch?: number): Position;
(line: number, ch?: number): Position;
}
interface Range{
@@ -811,8 +816,8 @@ declare module CodeMirror {
/** Optional lint configuration to be used in conjunction with CodeMirror's linter addon. */
lint?: boolean | LintOptions;
/** Optional value to be used in conduction with CodeMirrors placeholder add-on. */
placeholder?: string;
/** Optional value to be used in conjuction with CodeMirrors placeholder add-on. */
placeholder?: string;
}
interface TextMarkerOptions {