Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: clean up imports #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/addon/fold-emoji.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 5 additions & 6 deletions src/addon/fold-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/addon/fold-math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
2 changes: 1 addition & 1 deletion src/addon/fold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 1 addition & 2 deletions src/addon/table-align.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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[]
Expand Down
2 changes: 1 addition & 1 deletion src/core/cm_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
4 changes: 2 additions & 2 deletions src/keymap/hypermd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"

/**
Expand Down