Skip to content

Commit

Permalink
fix: #336 check components
Browse files Browse the repository at this point in the history
delete core-fileInfoPlugins
  • Loading branch information
JiHong88 committed May 6, 2020
1 parent 348b4bd commit d55134d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
11 changes: 0 additions & 11 deletions sample/html/out/document-editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -546,16 +546,6 @@ <h4 class="name" id="activePlugins"><span class="type-signature"></span>activePl
<dl class="details"></dl>


<h4 class="name" id="fileInfoPlugins"><span class="type-signature"></span>fileInfoPlugins<span
class="type-signature"></span></h4>
<div class="description">
Plugins array with "checkFileInfo" and "resetFileInfo" methods.<br>
"fileInfoPlugins" runs the "add" method when creating the editor.<br>
"checkFileInfo" method is always call just before the "change" event.
</div>
<dl class="details"></dl>


<h4 class="name" id="commandMap"><span class="type-signature"></span>commandMap<span
class="type-signature"></span></h4>
<div class="description">
Expand Down Expand Up @@ -1988,7 +1978,6 @@ <h3>core</h3>
<li><a href="document-editor.html#pasteTagsWhitelistRegExp">pasteTagsWhitelistRegExp</a></li>
<li><a href="document-editor.html#hasFocus">hasFocus</a></li>
<li><a href="document-editor.html#activePlugins">activePlugins</a></li>
<li><a href="document-editor.html#fileInfoPlugins">fileInfoPlugins</a></li>
<li><a href="document-editor.html#commandMap">commandMap</a></li>
<li><a href="document-editor.html#_variable">_variable</a></li>
<li><b>Methods</b></li>
Expand Down
30 changes: 22 additions & 8 deletions src/lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,21 @@ export default function (context, pluginCallButtons, plugins, lang, options, _ic
activePlugins: null,

/**
* @description Plugins array with "checkFileInfo" and "resetFileInfo" methods.
* @description Array of "checkFileInfo" functions with the core bound
* (Plugins with "checkFileInfo" and "resetFileInfo" methods)
* "fileInfoPlugins" runs the "add" method when creating the editor.
* "checkFileInfo" method is always call just before the "change" event.
* @private
*/
_fileInfoPluginsCheck: null,

/**
* @description Array of "resetFileInfo" functions with the core bound
* (Plugins with "checkFileInfo" and "resetFileInfo" methods)
* "checkFileInfo" method is always call just before the "functions.setOptions" method.
* @private
*/
fileInfoPlugins: null,
_fileInfoPluginsReset: null,

/**
* @description Variables for file component management
Expand Down Expand Up @@ -4193,8 +4203,8 @@ export default function (context, pluginCallButtons, plugins, lang, options, _ic
* @private
*/
_checkComponents: function () {
for (let i in this.fileInfoPlugins) {
this.fileInfoPlugins[i].checkFileInfo.call(this);
for (let i in this._fileInfoPluginsCheck) {
this._fileInfoPluginsCheck[i]();
}
},

Expand All @@ -4203,8 +4213,8 @@ export default function (context, pluginCallButtons, plugins, lang, options, _ic
* @private
*/
_resetComponents: function () {
for (let i in this.fileInfoPlugins) {
this.fileInfoPlugins[i].resetFileInfo.call(this);
for (let i in this._fileInfoPluginsReset) {
this._fileInfoPluginsReset[i]();
}
},

Expand Down Expand Up @@ -4292,9 +4302,12 @@ export default function (context, pluginCallButtons, plugins, lang, options, _ic
INDENT: context.tool.indent
};

// file components
this._fileInfoPluginsCheck = [];
this._fileInfoPluginsReset = [];

// Command and file plugins registration
this.activePlugins = [];
this.fileInfoPlugins = [];
this._fileManager.tags = [];
this._fileManager.pluginMap = {};

Expand All @@ -4308,7 +4321,8 @@ export default function (context, pluginCallButtons, plugins, lang, options, _ic
}
if (typeof plugin.checkFileInfo === 'function' && typeof plugin.resetFileInfo === 'function') {
this.callPlugin(key, null, button);
this.fileInfoPlugins.push(plugin);
this._fileInfoPluginsCheck.push(plugin.checkFileInfo.bind(this));
this._fileInfoPluginsReset.push(plugin.resetFileInfo.bind(this));
}
if (plugin.fileTags) {
this.callPlugin(key, null, button);
Expand Down

0 comments on commit d55134d

Please sign in to comment.