Skip to content

Commit

Permalink
Merge pull request #84 from obgnail/dev
Browse files Browse the repository at this point in the history
hotfix: 兼容延迟加载
  • Loading branch information
obgnail authored Aug 15, 2023
2 parents ce84dd3 + 34b975f commit b0f2e0e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
17 changes: 15 additions & 2 deletions plugin/auto_number.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,21 @@
}
}

global._pluginUtils.decorate(() => !!File, File.editor.export, "exportToHTML", decoMixin.beforeExport, null);
global._pluginUtils.decorate(() => !!File, File.editor.library.outline, "getHeaderMatrix", null, decoMixin.afterGetHeaderMatrix);
global._pluginUtils.decorate(
() => (File && File.editor && File.editor.export && File.editor.export.exportToHTML),
File.editor.export,
"exportToHTML",
decoMixin.beforeExport,
null
);
global._pluginUtils.decorate(
() => (File && File.editor && File.editor.library && File.editor.library.outline
&& File.editor.library.outline.getHeaderMatrix),
File.editor.library.outline,
"getHeaderMatrix",
null,
decoMixin.afterGetHeaderMatrix
);
}

//////////////////////// 以下是声明式插件系统代码 ////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions plugin/global/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@
}

const decorateOpenFile = (before, after) => {
decorate(() => !!File, File.editor.library, "openFile", before, after)
decorate(() => (File && File.editor && File.editor.library && File.editor.library.openFile), File.editor.library, "openFile", before, after)
}

const decorateAddCodeBlock = (before, after) => {
decorate(() => !!File, File.editor.fences, "addCodeBlock", before, after)
decorate(() => (File && File.editor && File.editor.fences && File.editor.fences.addCodeBlock), File.editor.fences, "addCodeBlock", before, after)
}

const loopDetector = (until, after, detectInterval = 20) => {
Expand Down
2 changes: 1 addition & 1 deletion plugin/read_only.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
global._pluginUtils.registerWindowHotkey(config.HOTKEY, call);

global._pluginUtils.decorate(
() => !!File,
() => (File && File.freshLock),
File,
"freshLock",
null,
Expand Down
2 changes: 1 addition & 1 deletion plugin/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(() => {
// 打开新窗口后自动关闭
global._pluginUtils.decorate(
() => !!File,
() => (File && File.editor && File.editor.library && File.editor.library.openFileInNewWindow),
File.editor.library,
"openFileInNewWindow",
null,
Expand Down

0 comments on commit b0f2e0e

Please sign in to comment.