diff --git a/src/Cherry.config.js b/src/Cherry.config.js index 79fd441c..1017162d 100644 --- a/src/Cherry.config.js +++ b/src/Cherry.config.js @@ -280,6 +280,13 @@ const defaultConfig = { // 'Ctrl-b': 'bold', // 'Ctrl-Alt-m': 'formula', }, + // 一些按钮的配置信息 + config: { + formula: { + showLatexLive: true, // true: 显示 www.latexlive.com 外链; false:不显示 + templateConfig: false, // false: 使用默认模板 + }, + }, }, // 打开draw.io编辑页的url,如果为空则drawio按钮失效 drawioIframeUrl: '', diff --git a/src/toolbars/BubbleFormula.js b/src/toolbars/BubbleFormula.js index 5f93f03f..dab15336 100644 --- a/src/toolbars/BubbleFormula.js +++ b/src/toolbars/BubbleFormula.js @@ -156,18 +156,21 @@ export default class BubbleFormula { }, }; + /** + * 是否显示 www.latexlive.com 的外链 + */ + showLatexLive = true; + /** * 点击具体公式后的回调函数 * @param {string} latex */ afterClick(latex) {} - /** - * @param {Object.} formulaConfig - */ - constructor(formulaConfig = {}) { - if (Object.keys(formulaConfig).length) { - this.formulaConfig = formulaConfig; + constructor(options = {}) { + if (Object.keys(options).length) { + this.formulaConfig = options.templateConfig || this.formulaConfig; + this.showLatexLive = options.showLatexLive; } this.init(); this.initEventListeners(); @@ -209,7 +212,9 @@ export default class BubbleFormula { }" data-name="${formulaMenuKey}">${formulaMenuStr}`; }) .join(''); - const appendLatexLive = `
查看更多:www.latexlive.com
`; + const appendLatexLive = this.showLatexLive + ? `
查看更多:www.latexlive.com
` + : ''; return `${ulStr}${formulaSelect}${appendLatexLive}`; } diff --git a/src/toolbars/hooks/Formula.js b/src/toolbars/hooks/Formula.js index ef43e6d8..91bd8001 100644 --- a/src/toolbars/hooks/Formula.js +++ b/src/toolbars/hooks/Formula.js @@ -23,7 +23,7 @@ export default class Formula extends MenuBase { constructor($cherry) { super($cherry); this.setName('formula', 'insertFormula'); - this.subBubbleFormulaMenu = new BubbleFormula($cherry?.options?.engine?.syntax?.formula?.config || {}); + this.subBubbleFormulaMenu = new BubbleFormula($cherry?.options?.toolbars?.config?.formula); $cherry.editor.options.wrapperDom.appendChild(this.subBubbleFormulaMenu.dom); this.catchOnce = ''; } diff --git a/types/cherry.d.ts b/types/cherry.d.ts index f8f92825..def5755e 100644 --- a/types/cherry.d.ts +++ b/types/cherry.d.ts @@ -235,6 +235,8 @@ export interface CherryToolbarOptions { customMenu?: Record; /** 自定义快捷键 */ shortcutKey?: Object | false; + /** 一些按钮的配置信息 */ + config?: Object; } export interface CherryFileUploadHandler {