From 72af9efc8d87c2cd9c93dbadc46419a6983e7afa Mon Sep 17 00:00:00 2001 From: sunhao Date: Tue, 18 Feb 2025 16:26:20 +0800 Subject: [PATCH] * [refac] support for setting history and outline button in toolbar. --- lib/zin/wg/docapp/js/v1.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/zin/wg/docapp/js/v1.js b/lib/zin/wg/docapp/js/v1.js index d74014f717..ea719d46b4 100644 --- a/lib/zin/wg/docapp/js/v1.js +++ b/lib/zin/wg/docapp/js/v1.js @@ -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); };