完成世界书、骰子、apiconfig页面处理
This commit is contained in:
30
frontend/node_modules/hast-util-from-html-isomorphic/lib/browser.js
generated
vendored
Normal file
30
frontend/node_modules/hast-util-from-html-isomorphic/lib/browser.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @typedef {import('hast').Root} Root
|
||||
*
|
||||
* @typedef {typeof import('./index.js').fromHtmlIsomorphic} FromHtmlIsomorphic
|
||||
*/
|
||||
|
||||
import {fromDom} from 'hast-util-from-dom'
|
||||
|
||||
const parser = new DOMParser()
|
||||
|
||||
/** @type {FromHtmlIsomorphic} */
|
||||
export function fromHtmlIsomorphic(value, options) {
|
||||
const node = options?.fragment
|
||||
? parseFragment(value)
|
||||
: parser.parseFromString(value, 'text/html')
|
||||
|
||||
return /** @type {Root} */ (fromDom(node))
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse as a fragment.
|
||||
*
|
||||
* @param {string} value
|
||||
* @returns {DocumentFragment}
|
||||
*/
|
||||
function parseFragment(value) {
|
||||
const template = document.createElement('template')
|
||||
template.innerHTML = value
|
||||
return template.content
|
||||
}
|
||||
14
frontend/node_modules/hast-util-from-html-isomorphic/lib/index.d.ts
generated
vendored
Normal file
14
frontend/node_modules/hast-util-from-html-isomorphic/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Turn HTML into a syntax tree, using browser APIs when available, so it has
|
||||
* a smaller bundle size there.
|
||||
*
|
||||
* @param {string} value
|
||||
* Serialized HTML to parse.
|
||||
* @param {Options | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns {Root}
|
||||
* Tree.
|
||||
*/
|
||||
export function fromHtmlIsomorphic(value: string, options?: Options | null | undefined): Root;
|
||||
export type Root = import('hast').Root;
|
||||
export type Options = Pick<import('hast-util-from-html').Options, 'fragment'>;
|
||||
Reference in New Issue
Block a user