本文整理汇总了TypeScript中codemirror/addon/runmode/runmode.node.js类的典型用法代码示例。如果您正苦于以下问题:TypeScript node.js类的具体用法?TypeScript node.js怎么用?TypeScript node.js使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了node.js类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getInnerModeName
/**
* Helper method to determine the name of the innermost (i.e. current)
* mode. Think of this as an abstraction over CodeMirror's innerMode
* with added type guards.
*/
function getInnerModeName(
mode: CodeMirror.Mode<{}>,
state: any
): string | null {
const inner = innerMode(mode, state)
return inner && inner.mode ? getModeName(inner.mode) : null
}
示例2: detectMode
function detectMode(request: IHighlightRequest): CodeMirror.Mode<{}> | null {
const mimeType =
extensionMIMEMap.get(request.extension) || guessMimeType(request.contents)
if (!mimeType) {
return null
}
return getMode({}, mimeType) || null
}
示例3: detectMode
async function detectMode(
request: IHighlightRequest
): Promise<CodeMirror.Mode<{}> | null> {
const mimeType =
extensionMIMEMap.get(request.extension.toLowerCase()) ||
guessMimeType(request.contents)
if (!mimeType) {
return null
}
const modeDefinition = mimeModeMap.get(mimeType)
if (modeDefinition === undefined) {
return null
}
await modeDefinition.install()
return getMode({}, mimeType) || null
}