@anyblock/remark-any-block 1.0.1-beta2 → 1.0.1-beta3

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.
@@ -24,16 +24,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
25
25
  const MarkdownIt = require("markdown-it");
26
26
  let dom = null;
27
- async function jsdom_init() {
27
+ async function jsdom_init(enable = true) {
28
28
  const { default: jsdom } = await import("jsdom");
29
29
  const { JSDOM } = jsdom;
30
30
  dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`, {
31
31
  url: "http://localhost/"
32
32
  // @warn 若缺少该行,则在mdit+build环境下,编译报错
33
33
  });
34
- jsdom_able();
34
+ if (enable) jsdom_enable();
35
35
  }
36
- async function jsdom_able() {
36
+ async function jsdom_enable() {
37
37
  global.Storage = dom.window.Storage;
38
38
  global.window = dom.window;
39
39
  global.history = dom.window.history;
@@ -1,15 +1,15 @@
1
1
  import MarkdownIt from "markdown-it";
2
2
  let dom = null;
3
- async function jsdom_init() {
3
+ async function jsdom_init(enable = true) {
4
4
  const { default: jsdom } = await import("jsdom");
5
5
  const { JSDOM } = jsdom;
6
6
  dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`, {
7
7
  url: "http://localhost/"
8
8
  // @warn 若缺少该行,则在mdit+build环境下,编译报错
9
9
  });
10
- jsdom_able();
10
+ if (enable) jsdom_enable();
11
11
  }
12
- async function jsdom_able() {
12
+ async function jsdom_enable() {
13
13
  global.Storage = dom.window.Storage;
14
14
  global.window = dom.window;
15
15
  global.history = dom.window.history;
package/jsdom_init.ts CHANGED
@@ -8,17 +8,17 @@
8
8
 
9
9
  let dom: any = null;
10
10
 
11
- export async function jsdom_init() {
11
+ export async function jsdom_init(enable: boolean = true) {
12
12
  const { default: jsdom } = await import('jsdom') // 废弃,要同步,避免docuemnt初始化不及时
13
13
  const { JSDOM } = jsdom
14
14
  dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`, {
15
15
  url: 'http://localhost/', // @warn 若缺少该行,则在mdit+build环境下,编译报错
16
16
  })
17
- jsdom_able()
17
+ if (enable) jsdom_enable()
18
18
  }
19
19
 
20
20
  /// 启用 jsdom 环境
21
- export async function jsdom_able() {
21
+ export async function jsdom_enable() {
22
22
  global.Storage = dom.window.Storage;
23
23
  global.window = dom.window as any
24
24
  global.history = dom.window.history // @warn 若缺少该行,则在mdit+build环境下,编译报错:ReferenceError: history is not defined
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anyblock/remark-any-block",
3
- "version": "1.0.1-beta2",
3
+ "version": "1.0.1-beta3",
4
4
  "description": "You can flexibility to create a 'Block' by many means. It also provides many useful features, like `list to table`.",
5
5
  "types": "@types/index_remark.d.ts",
6
6
  "type": "module",