@anyblock/remark-any-block 1.0.2 → 3.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/anyblock.ts +1 -1
- package/dist/remark-any-block.cjs +1588 -328
- package/dist/remark-any-block.js +1588 -328
- package/index.ts +1 -1
- package/jsdom_init.ts +12 -2
- package/package.json +45 -45
- package/styles.css +1217 -1203
- package/tsconfig.json +1 -4
package/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// JsDom。仅用于提供document对象支持 (如果Ob环境中则不需要,用ob自带document对象的)
|
|
2
2
|
export * from './jsdom_init'
|
|
3
|
-
export { ABReg } from '../ABConverter/
|
|
3
|
+
export { ABReg } from '../ABConverter/ABSetting'
|
|
4
4
|
export {
|
|
5
5
|
quartz_transformer_anyblock as transformer_anyblock,
|
|
6
6
|
// remark_anyblock_to_codeblock, // 取消注释则用库的地方会报错找不到 document
|
package/jsdom_init.ts
CHANGED
|
@@ -6,9 +6,16 @@
|
|
|
6
6
|
|
|
7
7
|
// import jsdom from "jsdom"
|
|
8
8
|
|
|
9
|
-
let dom: any = null
|
|
9
|
+
let dom: any = null // 缓存 jsdom 实例
|
|
10
|
+
let disable_disable_flag: boolean = false // 禁止禁用
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
/**
|
|
13
|
+
* @param enable 默认开启
|
|
14
|
+
* @param disable_disable 禁止禁用
|
|
15
|
+
*/
|
|
16
|
+
export async function jsdom_init(enable: boolean = true, disable_disable: boolean = false) {
|
|
17
|
+
disable_disable_flag = disable_disable
|
|
18
|
+
if (typeof document !== "undefined") return // 客户端环境,无需 jsdom 环境,同时也避免误卸载 document 环境
|
|
12
19
|
const { default: jsdom } = await import('jsdom') // 废弃,要同步,避免docuemnt初始化不及时
|
|
13
20
|
const { JSDOM } = jsdom
|
|
14
21
|
dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`, {
|
|
@@ -19,6 +26,7 @@ export async function jsdom_init(enable: boolean = true) {
|
|
|
19
26
|
|
|
20
27
|
/// 启用 jsdom 环境
|
|
21
28
|
export function jsdom_enable() {
|
|
29
|
+
if (!dom) return // console.error("jsdom_enable failed: please run jsdom_init first.") // 允许客户端中运行,不使用jsdom
|
|
22
30
|
global.Storage = dom.window.Storage;
|
|
23
31
|
global.window = dom.window as any
|
|
24
32
|
global.history = dom.window.history // @warn 若缺少该行,则在mdit+build环境下,编译报错:ReferenceError: history is not defined
|
|
@@ -38,6 +46,8 @@ export function jsdom_enable() {
|
|
|
38
46
|
|
|
39
47
|
/// 禁用 jsdom 环境
|
|
40
48
|
export function jsdom_disable() {
|
|
49
|
+
if (disable_disable_flag) return
|
|
50
|
+
if (!dom) return // console.error("jsdom_disable failed: please run jsdom_init first.") // 允许客户端中运行,不使用jsdom
|
|
41
51
|
global.window = undefined
|
|
42
52
|
global.history = undefined
|
|
43
53
|
global.document = undefined
|
package/package.json
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@anyblock/remark-any-block",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "You can flexibility to create a 'Block' by many means. It also provides many useful features, like `list to table`.",
|
|
5
|
-
"types": "@types/index_remark.d.ts",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"main": "dist/remark-any-block.cjs",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"import": "./dist/remark-any-block.js",
|
|
11
|
-
"require": "./dist/remark-any-block.cjs"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"publishConfig": {
|
|
15
|
-
"access": "public"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
19
|
-
"build": "pnpm build_vite",
|
|
20
|
-
"build_vite": "pnpm copy_abc_style && vite build",
|
|
21
|
-
"prepublishOnly": "pnpm build",
|
|
22
|
-
"copy_abc_style": "copyfiles --flat ../../src/ABConverter/style/styles.css ./"
|
|
23
|
-
},
|
|
24
|
-
"keywords": [],
|
|
25
|
-
"author": "",
|
|
26
|
-
"license": "GNU Affero General Public License v3.0",
|
|
27
|
-
"packageManager": "pnpm@10.10.0",
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"jsdom": "^26.1.0",
|
|
30
|
-
"markdown-it": "^14.1.0",
|
|
31
|
-
"mdast": "^3.0.0",
|
|
32
|
-
"mdast-util-to-markdown": "^2.1.2",
|
|
33
|
-
"tslib": "^2.8.1",
|
|
34
|
-
"unified": "^11.0.5",
|
|
35
|
-
"unist-util-visit": "^5.0.0",
|
|
36
|
-
"vfile": "^6.0.3"
|
|
37
|
-
},
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"@types/jsdom": "^21.1.7",
|
|
40
|
-
"@types/markdown-it": "^14.1.2",
|
|
41
|
-
"copyfiles": "^2.4.1",
|
|
42
|
-
"typescript": "^5.9.3",
|
|
43
|
-
"vite": "^7.2.7"
|
|
44
|
-
}
|
|
45
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@anyblock/remark-any-block",
|
|
3
|
+
"version": "3.4.11",
|
|
4
|
+
"description": "You can flexibility to create a 'Block' by many means. It also provides many useful features, like `list to table`.",
|
|
5
|
+
"types": "@types/index_remark.d.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/remark-any-block.cjs",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/remark-any-block.js",
|
|
11
|
+
"require": "./dist/remark-any-block.cjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
19
|
+
"build": "pnpm build_vite",
|
|
20
|
+
"build_vite": "pnpm copy_abc_style && vite build",
|
|
21
|
+
"prepublishOnly": "pnpm build",
|
|
22
|
+
"copy_abc_style": "copyfiles --flat ../../src/ABConverter/style/styles.css ./"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [],
|
|
25
|
+
"author": "",
|
|
26
|
+
"license": "GNU Affero General Public License v3.0",
|
|
27
|
+
"packageManager": "pnpm@10.10.0",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"jsdom": "^26.1.0",
|
|
30
|
+
"markdown-it": "^14.1.0",
|
|
31
|
+
"mdast": "^3.0.0",
|
|
32
|
+
"mdast-util-to-markdown": "^2.1.2",
|
|
33
|
+
"tslib": "^2.8.1",
|
|
34
|
+
"unified": "^11.0.5",
|
|
35
|
+
"unist-util-visit": "^5.0.0",
|
|
36
|
+
"vfile": "^6.0.3"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/jsdom": "^21.1.7",
|
|
40
|
+
"@types/markdown-it": "^14.1.2",
|
|
41
|
+
"copyfiles": "^2.4.1",
|
|
42
|
+
"typescript": "^5.9.3",
|
|
43
|
+
"vite": "^7.2.7"
|
|
44
|
+
}
|
|
45
|
+
}
|