* [refac] support for setting history and outline button in toolbar.

This commit is contained in:
sunhao
2025-02-18 17:02:07 +08:00
committed by 代婷婷
parent 7281223150
commit 72af9efc8d
+17 -1
View File
@@ -748,8 +748,12 @@ const actionsMap =
moreItems.push({icon: 'link', text: getLang('relateObject'), className: 'relateObject-btn', onClick() {$('.doc-view-sidebar-nav [z-type="relateObject"]').trigger('click')}})
}
const isToolbar = info.ui === 'toolbar';
const actions = [
isToolbar ? {hint: docApp.fullscreen ? lang.exitFullscreen : lang.enterFullscreen, icon: docApp.fullscreen ? 'fullscreen-exit' : 'fullscreen', command: 'toggleFullscreen'} : null,
canEditDoc ? {icon: 'edit', type: 'ghost text-primary', hint: lang.edit, rounded: 'lg', command: 'startEditDoc'} : null,
(isToolbar && docApp.props.showDocOutline !== false) ? {hint: lang.docOutline, icon: 'list-box', command: 'toggleViewSideTab/outline'} : null,
(isToolbar && docApp.props.showDocHistory !== false) ? {hint: lang.history, icon: 'history', command: 'toggleViewSideTab/history'} : null,
moreItems.length ? {icon: 'icon-ellipsis-v', type: 'dropdown', rounded: 'lg', placement: 'bottom-end', caret: false, items: moreItems} : null,
];
@@ -944,7 +948,12 @@ const actionsMap =
);
}
const isToolbar = info.ui === 'toolbar';
const docApp = this;
return [
isToolbar ? {hint: docApp.fullscreen ? lang.exitFullscreen : lang.enterFullscreen, icon: docApp.fullscreen ? 'fullscreen-exit' : 'fullscreen', command: 'toggleFullscreen'} : null,
(isToolbar && docApp.props.showDocOutline !== false) ? {hint: lang.docOutline, icon: 'list-box', command: 'toggleViewSideTab/outline'} : null,
(isToolbar && docApp.props.showDocHistory !== false) ? {hint: lang.history, icon: 'history', command: 'toggleViewSideTab/history'} : null,
doc.status === 'draft' ? {text: lang.saveDraft, size: 'md', className: 'btn-wide', type: 'secondary', command: 'saveDoc/draft'} : null,
{text: lang.release, size: 'md', className: 'btn-wide', type: 'primary', command: 'saveDoc'},
{text: lang.cancel, size: 'md', className: 'btn-wide', type: 'primary-outline', command: 'cancelEditDoc'},
@@ -957,7 +966,7 @@ const actionsMap =
* 定义文档创建时的操作按钮。
* Define the actions on toolbar of the doc creating page.
*/
'doc-create': function()
'doc-create': function(info)
{
const lang = getLang();
if(isApiLib())
@@ -977,7 +986,12 @@ const actionsMap =
{text: lang.importJSON, command: 'importFile/json'},
);
}
const isToolbar = info.ui === 'toolbar';
const docApp = this;
return [
isToolbar ? {hint: docApp.fullscreen ? lang.exitFullscreen : lang.enterFullscreen, icon: docApp.fullscreen ? 'fullscreen-exit' : 'fullscreen', command: 'toggleFullscreen'} : null,
(isToolbar && docApp.props.showDocOutline !== false) ? {hint: lang.docOutline, icon: 'list-box', command: 'toggleViewSideTab/outline'} : null,
{text: lang.saveDraft, size: 'md', className: 'btn-wide', type: 'secondary', command: 'saveNewDoc/draft'},
{text: lang.release, size: 'md', className: 'btn-wide', type: 'primary', command: 'saveNewDoc'},
{text: lang.cancel, size: 'md', className: 'btn-wide', type: 'primary-outline', command: 'cancelCreateDoc'},
@@ -1921,6 +1935,8 @@ window.setDocAppOptions = function(_, options)
getSortableOptions : getSortableOptions,
getDocViewSidebarTabs: getDocViewSidebarTabs,
getSpaceFetcher : getSpaceFetcher,
showDocOutline : true,
showDocHistory : true,
}, window.docAppOptions, options);
};