|
21 | 21 | :size="24" |
22 | 22 | :item="nodeModel?.properties.node_data" |
23 | 23 | /> |
24 | | - <h4 class="ellipsis-1 break-all">{{ nodeModel.properties.stepName }}</h4> |
| 24 | + <h4 |
| 25 | + class="ellipsis-1 break-all" |
| 26 | + v-html="highlightedStepName(nodeModel.properties.stepName)" |
| 27 | + ></h4> |
25 | 28 | </div> |
26 | 29 |
|
27 | 30 | <div @mousemove.stop @mousedown.stop @keydown.stop @click.stop> |
@@ -288,7 +291,7 @@ const mousedown = (event?: any) => { |
288 | 291 | set(props.nodeModel, 'isHovered', !props.nodeModel.isSelected) |
289 | 292 | props.nodeModel.graphModel.toFront(props.nodeModel.id) |
290 | 293 | } |
291 | | -const showicon = ref<number | null>(null) |
| 294 | +const showicon = ref<number | string | null>(null) |
292 | 295 | const copyNode = () => { |
293 | 296 | props.nodeModel.graphModel.clearSelectElements() |
294 | 297 | const cloneNode = props.nodeModel.graphModel.cloneNode(props.nodeModel.id) |
@@ -436,23 +439,51 @@ const closeNodeMenu = () => { |
436 | 439 | * 检索选中时候触发 |
437 | 440 | * @param kw |
438 | 441 | */ |
| 442 | +
|
| 443 | +const keyWord = ref('') |
| 444 | +const currentKeyWord = ref(false) |
439 | 445 | const selectOn = (kw: string) => { |
440 | 446 | props.nodeModel.setSelected(true) |
| 447 | + keyWord.value = kw |
| 448 | + currentKeyWord.value = false |
441 | 449 | console.log('selectOn', kw) |
442 | 450 | } |
443 | 451 | /** |
444 | 452 | * 定位时触发 |
445 | 453 | * @param kw |
446 | 454 | */ |
447 | 455 | const focusOn = (kw: string) => { |
| 456 | + currentKeyWord.value = true |
448 | 457 | console.log('focusOn', kw) |
449 | 458 | } |
450 | 459 | /** |
451 | 460 | * 清除时触发 |
452 | 461 | */ |
453 | 462 | const clearSelectOn = () => { |
| 463 | + keyWord.value = '' |
| 464 | + currentKeyWord.value = false |
454 | 465 | console.log('onClearSearchSelect') |
455 | 466 | } |
| 467 | +
|
| 468 | +// 高亮选中关键字 |
| 469 | +
|
| 470 | +const highlightedStepName = (contentText: string) => { |
| 471 | + let res = contentText |
| 472 | + if (keyWord.value === '') { |
| 473 | + return res |
| 474 | + } else { |
| 475 | + const wordsArray = contentText.split('') |
| 476 | + for (let i = 0; i < wordsArray.length; i++) { |
| 477 | + if (keyWord.value.includes(wordsArray[i])) { |
| 478 | + wordsArray[i] = currentKeyWord.value |
| 479 | + ? `<span style='background: #FF8800;'>${wordsArray[i]}</span>` |
| 480 | + : `<span style='background: #FFC60A;'>${wordsArray[i]}</span>` |
| 481 | + } |
| 482 | + } |
| 483 | + res = wordsArray.join('') |
| 484 | + return res |
| 485 | + } |
| 486 | +} |
456 | 487 | onMounted(() => { |
457 | 488 | set(props.nodeModel, 'openNodeMenu', (anchorData: any) => { |
458 | 489 | showAnchor.value ? closeNodeMenu() : openNodeMenu(anchorData) |
|
0 commit comments