From 002d75c9268b336f86bac56b13ca214d6c291f67 Mon Sep 17 00:00:00 2001 From: Michael McDermott Date: Tue, 31 Jul 2018 19:24:41 -0400 Subject: [PATCH] refactor: clean up imports --- src/addon/fold-emoji.ts | 5 ++--- src/addon/fold-html.ts | 11 +++++------ src/addon/fold-math.ts | 2 +- src/addon/fold.ts | 2 +- src/addon/table-align.ts | 3 +-- src/core/cm_utils.ts | 2 +- src/keymap/hypermd.ts | 4 ++-- 7 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/addon/fold-emoji.ts b/src/addon/fold-emoji.ts index af1c93e..bc6dcbc 100644 --- a/src/addon/fold-emoji.ts +++ b/src/addon/fold-emoji.ts @@ -5,7 +5,6 @@ // import * as CodeMirror from 'codemirror' -import { Position } from 'codemirror' import { Addon, suggestedEditorConfig } from '../core' import { cm_t } from '../core/type' import { registerFolder, breakMark, FolderFunc, RequestRangeResult } from './fold' @@ -35,8 +34,8 @@ export const EmojiFolder: FolderFunc = (stream, token) => { if (!token.type || !/ formatting-emoji/.test(token.type)) return null const cm = stream.cm - const from: Position = { line: stream.lineNo, ch: token.start } - const to: Position = { line: stream.lineNo, ch: token.end } + const from: CodeMirror.Position = { line: stream.lineNo, ch: token.start } + const to: CodeMirror.Position = { line: stream.lineNo, ch: token.end } var name = token.string // with ":" var addon = getAddon(cm) diff --git a/src/addon/fold-html.ts b/src/addon/fold-html.ts index 80b3cc1..7121872 100644 --- a/src/addon/fold-html.ts +++ b/src/addon/fold-html.ts @@ -5,7 +5,6 @@ // import * as CodeMirror from 'codemirror' -import { Position } from 'codemirror' import { Addon, suggestedEditorConfig, visitElements, watchSize } from '../core' import { cm_t } from '../core/type' import { registerFolder, breakMark, FolderFunc, RequestRangeResult } from './fold' @@ -15,7 +14,7 @@ import './read-link' /** * Before folding HTML, check its security and avoid XSS attack! Returns true if safe. */ -export type CheckerFunc = (html: string, pos: Position, cm: cm_t) => boolean +export type CheckerFunc = (html: string, pos: CodeMirror.Position, cm: cm_t) => boolean export var defaultChecker: CheckerFunc = (html) => { // TODO: read https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet @@ -34,12 +33,12 @@ export var defaultChecker: CheckerFunc = (html) => { * * @param html only have one root element */ -export type RendererFunc = (html: string, pos: Position, cm: cm_t) => HTMLElement +export type RendererFunc = (html: string, pos: CodeMirror.Position, cm: cm_t) => HTMLElement /** * Create HTMLElement from HTML string and do special process with HyperMD.ReadLink */ -export var defaultRenderer: RendererFunc = (html: string, pos: Position, cm: cm_t): HTMLElement => { +export var defaultRenderer: RendererFunc = (html: string, pos: CodeMirror.Position, cm: cm_t): HTMLElement => { var tagBegin = /^<(\w+)\s*/.exec(html) if (!tagBegin) return null @@ -122,8 +121,8 @@ export const HTMLFolder: FolderFunc = (stream, token) => { if (!endInfo || !/ hmd-html-end/.test(endInfo.token.type) || / hmd-html-unclosed/.test(endInfo.token.type)) return null const cm = stream.cm - const from: Position = { line: stream.lineNo, ch: token.start } - const to: Position = { line: endInfo.lineNo, ch: endInfo.token.end } + const from: CodeMirror.Position = { line: stream.lineNo, ch: token.start } + const to: CodeMirror.Position = { line: endInfo.lineNo, ch: endInfo.token.end } const inlineMode: boolean = from.ch != 0 || to.ch < cm.getLine(to.line).length // if (!inlineMode) { diff --git a/src/addon/fold-math.ts b/src/addon/fold-math.ts index a38530f..57bc9b0 100644 --- a/src/addon/fold-math.ts +++ b/src/addon/fold-math.ts @@ -9,7 +9,7 @@ import * as CodeMirror from 'codemirror' import { Addon, FlipFlop, tryToRun, suggestedEditorConfig } from '../core' -import { TextMarker, Position, Token } from 'codemirror' +import { TextMarker, Position } from 'codemirror' import { cm_t } from '../core/type' import { registerFolder, breakMark, FolderFunc, RequestRangeResult } from './fold' diff --git a/src/addon/fold.ts b/src/addon/fold.ts index 17eb31f..63ec5f5 100644 --- a/src/addon/fold.ts +++ b/src/addon/fold.ts @@ -7,7 +7,7 @@ // import * as CodeMirror from 'codemirror' -import { Addon, FlipFlop, debounce, TokenSeeker, suggestedEditorConfig, normalVisualConfig } from '../core' +import { Addon, debounce, TokenSeeker, suggestedEditorConfig, normalVisualConfig } from '../core' import { TextMarker, Position, Token } from 'codemirror' import { cm_t } from '../core/type' import { splitLink } from './read-link' diff --git a/src/addon/table-align.ts b/src/addon/table-align.ts index 41b72ae..a5e89e2 100644 --- a/src/addon/table-align.ts +++ b/src/addon/table-align.ts @@ -6,7 +6,6 @@ import * as CodeMirror from 'codemirror' import { Addon, FlipFlop, debounce, updateCursorDisplay, suggestedEditorConfig, normalVisualConfig } from '../core' -import { LineHandle } from 'codemirror' import { cm_t } from '../core/type' import { HyperMDState, TableType } from '../mode/hypermd' @@ -111,7 +110,7 @@ export class TableAlign implements Addon.Addon, Options /* if needed */ { }, 100) /** CodeMirror renderLine event handler */ - private _procLine = (cm: cm_t, line: LineHandle, el: HTMLPreElement) => { + private _procLine = (cm: cm_t, line: CodeMirror.LineHandle, el: HTMLPreElement) => { if (!el.querySelector('.cm-hmd-table-sep')) return const lineSpan = el.firstElementChild const lineSpanChildren = Array.prototype.slice.call(lineSpan.childNodes, 0) as Node[] diff --git a/src/core/cm_utils.ts b/src/core/cm_utils.ts index f4e0d68..b4faa5a 100644 --- a/src/core/cm_utils.ts +++ b/src/core/cm_utils.ts @@ -6,9 +6,9 @@ * You shall NOT import this file; please import "core" instead */ +import { Token, Position } from "codemirror" import * as cm_internal from "./cm_internal" import { cm_t } from "./type" -import { Token, Position } from "codemirror" export { cm_internal } diff --git a/src/keymap/hypermd.ts b/src/keymap/hypermd.ts index b4178d8..0cc09d2 100644 --- a/src/keymap/hypermd.ts +++ b/src/keymap/hypermd.ts @@ -5,9 +5,9 @@ // import * as CodeMirror from 'codemirror' -import { Token, Position, cmpPos } from 'codemirror' +import { Token, cmpPos } from 'codemirror' import { cm_t } from '../core/type' -import { TokenSeeker, repeatStr, expandRange, repeat, suggestedEditorConfig } from '../core'; +import { TokenSeeker, repeatStr, repeat, suggestedEditorConfig } from '../core'; import { HyperMDState, TableType } from "../mode/hypermd" /**