11import { undoDepth , redoDepth } from 'prosemirror-history' ;
2- import { h } from 'vue' ;
2+ import { h , ref } from 'vue' ;
33
44import { scrollToElement } from './scroll-helpers' ;
55import { sanitizeNumber } from './helpers' ;
@@ -14,6 +14,7 @@ import TableGrid from './TableGrid.vue';
1414import TableActions from './TableActions.vue' ;
1515
1616import checkIconSvg from '@harbour-enterprises/common/icons/check.svg?raw' ;
17+ import SearchInput from './SearchInput.vue' ;
1718
1819const closeDropdown = ( dropdown ) => {
1920 dropdown . expand . value = false ;
@@ -257,6 +258,39 @@ export const makeDefaultItems = (superToolbar, isDev = false, windowWidth, role,
257258 } ,
258259 onDeactivate : ( ) => ( colorButton . iconColor . value = '#000' ) ,
259260 } ) ;
261+
262+ // search
263+ const searchRef = ref ( null ) ;
264+ const search = useToolbarItem ( {
265+ type : 'dropdown' ,
266+ name : 'search' ,
267+ active : false ,
268+ icon : toolbarIcons . search ,
269+ tooltip : 'Search' ,
270+ group : 'right' ,
271+ inputRef : searchRef ,
272+ options : [
273+ {
274+ type : 'render' ,
275+ key : 'searchDropdown' ,
276+ render : ( ) => renderSearchDropdown ( ) ,
277+ } ,
278+ ] ,
279+ } ) ;
280+
281+ const renderSearchDropdown = ( ) => {
282+
283+ const handleSubmit = ( { value } ) => {
284+ superToolbar . activeEditor . doSearch ( value ) ;
285+ } ;
286+
287+ return h ( 'div' , { } , [
288+ h ( SearchInput , {
289+ onSubmit : handleSubmit ,
290+ searchRef,
291+ } ) ,
292+ ] ) ;
293+ } ;
260294
261295 // link
262296 const link = useToolbarItem ( {
@@ -669,18 +703,6 @@ export const makeDefaultItems = (superToolbar, isDev = false, windowWidth, role,
669703 icon : toolbarIcons . trackChangesFinal ,
670704 group : 'left' ,
671705 } ) ;
672- //
673-
674- // search
675- // const search = useToolbarItem({
676- // type: "button",
677- // allowWithoutEditor: true,
678- // name: "search",
679- // tooltip: "Search",
680- // disabled: true,
681- // icon: "fas fa-magnifying-glass", // change to svg
682- // group: "right",
683- // });
684706
685707 const clearFormatting = useToolbarItem ( {
686708 type : 'button' ,
@@ -696,7 +718,7 @@ export const makeDefaultItems = (superToolbar, isDev = false, windowWidth, role,
696718 underline ,
697719 indentRight ,
698720 indentLeft ,
699- // search,
721+ search ,
700722 overflow ,
701723 ] . map ( ( item ) => item . name ) ;
702724
@@ -942,7 +964,7 @@ export const makeDefaultItems = (superToolbar, isDev = false, windowWidth, role,
942964 aiButton ,
943965 overflow ,
944966 documentMode ,
945- // search,
967+ search ,
946968 ] ;
947969
948970 if ( ! superToolbar . config ?. superdoc ?. config ?. modules ?. ai ) {
@@ -978,7 +1000,7 @@ export const makeDefaultItems = (superToolbar, isDev = false, windowWidth, role,
9781000 }
9791001
9801002 // always visible items
981- const toolbarItemsSticky = [ undo , overflow , documentMode ] . map ( ( item ) => item . name ) ;
1003+ const toolbarItemsSticky = [ search , undo , overflow , documentMode ] . map ( ( item ) => item . name ) ;
9821004 const isStickyItem = ( item ) => toolbarItemsSticky . includes ( item . name ) ;
9831005
9841006 const overflowItems = [ ] ;
0 commit comments