@@ -29,6 +29,7 @@ import type {
29
29
NonDeletedExcalidrawElement ,
30
30
Theme ,
31
31
} from '@weiwenda/excalidraw/dist/excalidraw/element/types' ;
32
+ import fallbackLangData from '@weiwenda/excalidraw/dist/excalidraw/locales/en.json' ;
32
33
import './index.css' ;
33
34
import './App.scss' ;
34
35
import { SessionWithToolbarComponent } from '../session' ;
@@ -52,6 +53,7 @@ import {useLoaderData, useNavigate, useParams, useSearchParams} from 'react-rout
52
53
import { uploadJson } from '../../share/ts/utils/APIUtils' ;
53
54
import { copyToClipboard } from '../index' ;
54
55
import { doAutoLayout } from './layoutUtils' ;
56
+ import { NestedKeyOf } from '@weiwenda/excalidraw/dist/excalidraw/utility-types' ;
55
57
56
58
const { Search} = Input ;
57
59
@@ -103,7 +105,6 @@ export default function PkbProducer({
103
105
const [ showDetail , setShowDetail ] = useState ( session . clientStore . getClientSetting ( 'curPkbShowDetail' ) ) ;
104
106
const [ showShapes , setShowShapes ] = useState ( session . clientStore . getClientSetting ( 'curPkbShowShapes' ) ) ;
105
107
const [ showSelectedShapeActions , setShowSelectedShapeActions ] = useState ( session . clientStore . getClientSetting ( 'curPkbShowSelectedShapeActions' ) ) ;
106
- const [ showSearch , setShowSearch ] = useState ( session . clientStore . getClientSetting ( 'curPkbShowSearch' ) ) ;
107
108
const [ showLibrary , setShowLibrary ] = useState ( session . clientStore . getClientSetting ( 'curPkbShowLibrary' ) ) ;
108
109
const [ docked , setDocked ] = useState ( false ) ;
109
110
const [ theme , setTheme ] = useState < Theme > ( 'light' ) ;
@@ -139,7 +140,6 @@ export default function PkbProducer({
139
140
setShowShapes ( savedContent . tools ?. showShapes ?? showShapes ) ;
140
141
setShowDetail ( savedContent . tools ?. showDetail ?? showDetail ) ;
141
142
setShowFilter ( savedContent . tools ?. showFilter ?? showFilter ) ;
142
- setShowSearch ( savedContent . tools ?. showSearch ?? showSearch ) ;
143
143
setShowSelectedShapeActions ( savedContent . tools ?. showSelectedShapeActions ?? showSelectedShapeActions ) ;
144
144
// @ts -ignore
145
145
const blob = new Blob ( [ savedContent . libraryItems || serializeLibraryAsJSON ( initialData . libraryItems ) ] ,
@@ -232,7 +232,6 @@ export default function PkbProducer({
232
232
setShowShapes ( session . clientStore . getClientSetting ( 'curPkbShowShapes' ) ) ;
233
233
setShowFilter ( session . clientStore . getClientSetting ( 'curPkbShowFilter' ) ) ;
234
234
setShowDetail ( session . clientStore . getClientSetting ( 'curPkbShowDetail' ) ) ;
235
- setShowSearch ( session . clientStore . getClientSetting ( 'curPkbShowSearch' ) ) ;
236
235
setShowSelectedShapeActions ( session . clientStore . getClientSetting ( 'curPkbShowSelectedShapeActions' ) ) ;
237
236
const convertedElements = convertToExcalidrawElements ( elements ) ;
238
237
const finalElements = convertedElements . map ( el => {
@@ -313,7 +312,6 @@ export default function PkbProducer({
313
312
const newElement = cloneElement (
314
313
Excalidraw ,
315
314
{
316
- langCode : 'zh-CN' ,
317
315
excalidrawAPI : ( api : ExcalidrawImperativeAPI ) => setExcalidrawAPI ( api ) ,
318
316
initialData : initialStatePromiseRef . current . promise ,
319
317
onLibraryChange : ( libraryItems : LibraryItems ) => {
@@ -330,7 +328,6 @@ export default function PkbProducer({
330
328
session . clientStore . setClientSetting ( 'curPkbShowLibrary' , showLibrary ) ;
331
329
session . clientStore . setClientSetting ( 'curPkbShowFilter' , showFilter ) ;
332
330
session . clientStore . setClientSetting ( 'curPkbShowDetail' , showDetail ) ;
333
- session . clientStore . setClientSetting ( 'curPkbShowSearch' , showSearch ) ;
334
331
session . clientStore . setClientSetting ( 'curPkbShowShapes' , showShapes ) ;
335
332
session . clientStore . setClientSetting ( 'curPkbShowSelectedShapeActions' , showSelectedShapeActions ) ;
336
333
}
@@ -367,7 +364,7 @@ export default function PkbProducer({
367
364
< >
368
365
< WelcomeScreen />
369
366
{
370
- ( showSearch || showFilter || showSelectedShapeActions ) &&
367
+ ( showFilter || showSelectedShapeActions ) &&
371
368
< Draggable
372
369
defaultClassName = { 'operation-board' }
373
370
position = { { x : boardX , y : boardY } }
@@ -377,42 +374,6 @@ export default function PkbProducer({
377
374
} }
378
375
>
379
376
< div style = { { width : '202px' } } >
380
- {
381
- showSearch &&
382
- < Search
383
- allowClear
384
- placeholder = '节点搜索'
385
- onSearch = { ( text ) => {
386
- if ( ! text ) {
387
- return ;
388
- }
389
- const res = text . matchAll ( / " ( .* ?) " / g) ;
390
- let query : string [ ] = [ ] ;
391
- let parts ;
392
- while ( ! ( parts = res . next ( ) ) . done ) {
393
- query . push ( parts . value [ 1 ] ) ;
394
- }
395
- text = text . replaceAll ( / " ( .* ?) " / g, '' ) ;
396
- query = query . concat ( text . split ( ' ' ) . filter ( ( s ) => s . length !== 0 ) ) ;
397
- let match = getTextElementsMatchingQuery (
398
- ( excalidrawAPI ?. getSceneElements ( ) || [ ] ) . filter ( ( el ) => el . type === 'text' ) ,
399
- query
400
- ) ;
401
-
402
- if ( match . length === 0 ) {
403
- excalidrawAPI ?. setToast ( { message : '未找到匹配项' , duration : 1000 } ) ;
404
- return false ;
405
- }
406
- // @ts -ignore
407
- excalidrawAPI ?. updateScene ( { appState : { selectedElementIds : Object . fromEntries (
408
- match . map ( ( e ) => [ e . id , true ] ) ,
409
- ) } } ) ;
410
- if ( match . length === 1 ) {
411
- excalidrawAPI ?. scrollToContent ( match [ 0 ] ) ;
412
- }
413
- } }
414
- />
415
- }
416
377
{
417
378
showFilter &&
418
379
< div style = { { background : 'var(--island-bg-color)' , padding : '0.75rem' ,
@@ -464,7 +425,7 @@ export default function PkbProducer({
464
425
setVisibleShapes ( nextSelectedTags ) ;
465
426
} }
466
427
>
467
- { t ( `toolBar.rectangle` ) }
428
+ { t ( `toolBar.${ tag } ` as NestedKeyOf < typeof fallbackLangData > ) }
468
429
</ Tag . CheckableTag >
469
430
) ) }
470
431
</ Flex >
@@ -787,7 +748,6 @@ export default function PkbProducer({
787
748
showDetail,
788
749
showLibrary,
789
750
showShapes,
790
- showSearch,
791
751
showFilter,
792
752
showSelectedShapeActions
793
753
}
@@ -830,7 +790,6 @@ export default function PkbProducer({
830
790
showLibrary,
831
791
showDetail,
832
792
showShapes,
833
- showSearch,
834
793
showFilter,
835
794
showSelectedShapeActions
836
795
}
@@ -869,11 +828,6 @@ export default function PkbProducer({
869
828
onSelect = { ( ) => setShowLibrary ( ! showLibrary ) } >
870
829
素材库
871
830
</ MainMenu . Item >
872
- < MainMenu . Item icon = { < FileSearchOutlined /> }
873
- shortcut = { showSearch ? 'ON' : 'OFF' }
874
- onSelect = { ( ) => setShowSearch ( ! showSearch ) } >
875
- 节点搜索工具
876
- </ MainMenu . Item >
877
831
< MainMenu . Item icon = { < FilterOutlined /> }
878
832
shortcut = { showFilter ? 'ON' : 'OFF' }
879
833
onSelect = { ( ) => setShowFilter ( ! showFilter ) } >
0 commit comments