From 3a35d23702820bb9c6d322a5698cd6fbcb8f57eb Mon Sep 17 00:00:00 2001 From: Radu Woinaroski Date: Sun, 10 Jan 2016 21:32:56 +0100 Subject: [PATCH 1/2] fixed CodeMirror.TextMarker.find() return type Added CodeMirror.Range type Changed CodeMirror.TextMarker.find() to return CodeMirror.Range instead of CodeMirror.Position (which was wrong). --- codemirror/codemirror.d.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/codemirror/codemirror.d.ts b/codemirror/codemirror.d.ts index 2ca58c7024..1df15739bf 100644 --- a/codemirror/codemirror.d.ts +++ b/codemirror/codemirror.d.ts @@ -601,7 +601,7 @@ declare module CodeMirror { /** Returns a {from, to} object (both holding document positions), indicating the current position of the marked range, or undefined if the marker is no longer in the document. */ - find(): CodeMirror.Position; + find(): CodeMirror.Range; /** Returns an object representing the options for the marker. If copyWidget is given true, it will clone the value of the replacedWith option, if any. */ getOptions(copyWidget: boolean): CodeMirror.TextMarkerOptions; @@ -645,7 +645,12 @@ declare module CodeMirror { new (line: number, ch: number): Position; (line: number, ch: number): Position; } - + + interface Range{ + from: CodeMirror.Position; + to: CodeMirror.Position; + } + interface Position { ch: number; line: number; @@ -795,9 +800,9 @@ declare module CodeMirror { viewportMargin?: number; /** Optional lint configuration to be used in conjunction with CodeMirror's linter addon. */ - lint?: boolean | LintOptions; - - /** Optional value to be used in conduction with CodeMirror’s placeholder add-on. */ + lint?: boolean | LintOptions; + + /** Optional value to be used in conduction with CodeMirror’s placeholder add-on. */ placeholder?: string; } From 535891011950677f24deaafb625874a19e201e7a Mon Sep 17 00:00:00 2001 From: Radu Woinaroski Date: Mon, 11 Jan 2016 11:35:19 +0100 Subject: [PATCH 2/2] pulled hljs out of 'highlight.js' so it can be also used without an AMD loader pulled the declaration of module hljs out of the declaration for module "highlight.js" so that the file can be used in both AMD and static load scenarios. --- highlightjs/highlightjs.d.ts | 276 +++++++++++++++++------------------ 1 file changed, 138 insertions(+), 138 deletions(-) diff --git a/highlightjs/highlightjs.d.ts b/highlightjs/highlightjs.d.ts index dc7606d88c..8a0eceab52 100644 --- a/highlightjs/highlightjs.d.ts +++ b/highlightjs/highlightjs.d.ts @@ -3,152 +3,152 @@ // Definitions by: Niklas Mollenhauer , Jeremy Hull // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module "highlight.js" +declare module 'highlight.js' { + export = hljs; +} + +declare module hljs { - module hljs + export function highlight( + name: string, + value: string, + ignore_illegals?: boolean, + continuation?: boolean) : IHighlightResult; + export function highlightAuto( + value: string, + languageSubset?: string[]) : IAutoHighlightResult; + + export function fixMarkup(value: string) : string; + + export function highlightBlock(block: Node) : void; + + export function configure(options: IOptions): void; + + export function initHighlighting(): void; + export function initHighlightingOnLoad(): void; + + export function registerLanguage( + name: string, + language: (hljs?: HLJSStatic) => IModeBase): void; + export function listLanguages(): string[]; + export function getLanguage(name: string): IMode; + + export function inherit(parent: Object, obj: Object): Object; + + // Common regexps + export var IDENT_RE: string; + export var UNDERSCORE_IDENT_RE: string; + export var NUMBER_RE: string; + export var C_NUMBER_RE: string; + export var BINARY_NUMBER_RE: string; + export var RE_STARTERS_RE: string; + + // Common modes + export var BACKSLASH_ESCAPE : IMode; + export var APOS_STRING_MODE : IMode; + export var QUOTE_STRING_MODE : IMode; + export var PHRASAL_WORDS_MODE : IMode; + export var C_LINE_COMMENT_MODE : IMode; + export var C_BLOCK_COMMENT_MODE : IMode; + export var HASH_COMMENT_MODE : IMode; + export var NUMBER_MODE : IMode; + export var C_NUMBER_MODE : IMode; + export var BINARY_NUMBER_MODE : IMode; + export var CSS_NUMBER_MODE : IMode; + export var REGEX_MODE : IMode; + export var TITLE_MODE : IMode; + export var UNDERSCORE_TITLE_MODE : IMode; + + export interface IHighlightResultBase { - export function highlight( - name: string, - value: string, - ignore_illegals?: boolean, - continuation?: boolean) : IHighlightResult; - export function highlightAuto( - value: string, - languageSubset?: string[]) : IAutoHighlightResult; + relevance: number; + language: string; + value: string; + } - export function fixMarkup(value: string) : string; + export interface IAutoHighlightResult extends IHighlightResultBase + { + second_best?: IAutoHighlightResult; + } - export function highlightBlock(block: Node) : void; + export interface IHighlightResult extends IHighlightResultBase + { + top: ICompiledMode; + } - export function configure(options: IOptions): void; - - export function initHighlighting(): void; - export function initHighlightingOnLoad(): void; - - export function registerLanguage( - name: string, - language: (hljs?: HLJSStatic) => IModeBase): void; - export function listLanguages(): string[]; - export function getLanguage(name: string): IMode; - - export function inherit(parent: Object, obj: Object): Object; + export interface HLJSStatic + { + inherit(parent: Object, obj: Object): Object; // Common regexps - export var IDENT_RE: string; - export var UNDERSCORE_IDENT_RE: string; - export var NUMBER_RE: string; - export var C_NUMBER_RE: string; - export var BINARY_NUMBER_RE: string; - export var RE_STARTERS_RE: string; + IDENT_RE: string; + UNDERSCORE_IDENT_RE: string; + NUMBER_RE: string; + C_NUMBER_RE: string; + BINARY_NUMBER_RE: string; + RE_STARTERS_RE: string; // Common modes - export var BACKSLASH_ESCAPE : IMode; - export var APOS_STRING_MODE : IMode; - export var QUOTE_STRING_MODE : IMode; - export var PHRASAL_WORDS_MODE : IMode; - export var C_LINE_COMMENT_MODE : IMode; - export var C_BLOCK_COMMENT_MODE : IMode; - export var HASH_COMMENT_MODE : IMode; - export var NUMBER_MODE : IMode; - export var C_NUMBER_MODE : IMode; - export var BINARY_NUMBER_MODE : IMode; - export var CSS_NUMBER_MODE : IMode; - export var REGEX_MODE : IMode; - export var TITLE_MODE : IMode; - export var UNDERSCORE_TITLE_MODE : IMode; - - export interface IHighlightResultBase - { - relevance: number; - language: string; - value: string; - } - - export interface IAutoHighlightResult extends IHighlightResultBase - { - second_best?: IAutoHighlightResult; - } - - export interface IHighlightResult extends IHighlightResultBase - { - top: ICompiledMode; - } - - export interface HLJSStatic - { - inherit(parent: Object, obj: Object): Object; - - // Common regexps - IDENT_RE: string; - UNDERSCORE_IDENT_RE: string; - NUMBER_RE: string; - C_NUMBER_RE: string; - BINARY_NUMBER_RE: string; - RE_STARTERS_RE: string; - - // Common modes - BACKSLASH_ESCAPE : IMode; - APOS_STRING_MODE : IMode; - QUOTE_STRING_MODE : IMode; - PHRASAL_WORDS_MODE : IMode; - C_LINE_COMMENT_MODE : IMode; - C_BLOCK_COMMENT_MODE : IMode; - HASH_COMMENT_MODE : IMode; - NUMBER_MODE : IMode; - C_NUMBER_MODE : IMode; - BINARY_NUMBER_MODE : IMode; - CSS_NUMBER_MODE : IMode; - REGEX_MODE : IMode; - TITLE_MODE : IMode; - UNDERSCORE_TITLE_MODE : IMode; - } - - // Reference: - // https://github.com/isagalaev/highlight.js/blob/master/docs/reference.rst - export interface IModeBase - { - className?: string; - aliases?: string[]; - begin?: string; - end?: string; - case_insensitive?: boolean; - beginKeyword?: string; - endsWithParent?: boolean; - lexems?: string; - illegal?: string; - excludeBegin?: boolean; - excludeEnd?: boolean; - returnBegin?: boolean; - returnEnd?: boolean; - starts?: string; - subLanguage?: string; - subLanguageMode?: string; - relevance?: number; - variants?: IMode[]; - } - - export interface IMode extends IModeBase - { - keywords?: any; - contains?: IMode[]; - } - - export interface ICompiledMode extends IModeBase - { - compiled: boolean; - contains?: ICompiledMode[]; - keywords?: Object; - terminators: RegExp; - terminator_end?: string; - } - - export interface IOptions - { - classPrefix?: string; - tabReplace?: string; - useBR?: boolean; - languages?: string[]; - } + BACKSLASH_ESCAPE : IMode; + APOS_STRING_MODE : IMode; + QUOTE_STRING_MODE : IMode; + PHRASAL_WORDS_MODE : IMode; + C_LINE_COMMENT_MODE : IMode; + C_BLOCK_COMMENT_MODE : IMode; + HASH_COMMENT_MODE : IMode; + NUMBER_MODE : IMode; + C_NUMBER_MODE : IMode; + BINARY_NUMBER_MODE : IMode; + CSS_NUMBER_MODE : IMode; + REGEX_MODE : IMode; + TITLE_MODE : IMode; + UNDERSCORE_TITLE_MODE : IMode; + } + + // Reference: + // https://github.com/isagalaev/highlight.js/blob/master/docs/reference.rst + export interface IModeBase + { + className?: string; + aliases?: string[]; + begin?: string; + end?: string; + case_insensitive?: boolean; + beginKeyword?: string; + endsWithParent?: boolean; + lexems?: string; + illegal?: string; + excludeBegin?: boolean; + excludeEnd?: boolean; + returnBegin?: boolean; + returnEnd?: boolean; + starts?: string; + subLanguage?: string; + subLanguageMode?: string; + relevance?: number; + variants?: IMode[]; + } + + export interface IMode extends IModeBase + { + keywords?: any; + contains?: IMode[]; + } + + export interface ICompiledMode extends IModeBase + { + compiled: boolean; + contains?: ICompiledMode[]; + keywords?: Object; + terminators: RegExp; + terminator_end?: string; + } + + export interface IOptions + { + classPrefix?: string; + tabReplace?: string; + useBR?: boolean; + languages?: string[]; } - export = hljs; }