Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions plugins/workspace-search/src/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ const arrowUpSvgDataUri =
/**
* CSS for workspace search.
*/
const cssContent = `path.blocklyPath.blockly-ws-search-highlight {
fill: #000;
const cssContent = `.blockly-ws-search-active g.blocklyDraggable>path {
filter: saturate(0);
}
path.blocklyPath.blockly-ws-search-highlight.blockly-ws-search-current {
fill: grey;
.blockly-ws-search-active g.blockly-ws-search-highlight>path {
filter: saturate(50%);
}
.blockly-ws-search-active g.blockly-ws-search-current>path {
filter: saturate(150%);
}
.blockly-ws-search-close-btn {
background: url(${closeSvgDataUri}) no-repeat top left;
Expand Down
10 changes: 6 additions & 4 deletions plugins/workspace-search/src/workspace_search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ export class WorkspaceSearch implements Blockly.IPositionable {
this.searchText,
this.caseSensitive,
);
this.workspace.getSvgGroup().classList.add('blockly-ws-search-active');
this.highlightSearchGroup(this.blocks);
let currentIdx = 0;
if (preserveCurrent) {
Expand Down Expand Up @@ -581,6 +582,7 @@ export class WorkspaceSearch implements Blockly.IPositionable {
}
this.currentBlockIndex = -1;
this.blocks = [];
this.workspace.getSvgGroup().classList.remove('blockly-ws-search-active');
}

/**
Expand All @@ -590,7 +592,7 @@ export class WorkspaceSearch implements Blockly.IPositionable {
* @param currentBlock The block to highlight.
*/
protected highlightCurrentSelection(currentBlock: Blockly.BlockSvg) {
const path = currentBlock.pathObject.svgPath;
const path = currentBlock.getSvgRoot();
Blockly.utils.dom.addClass(path, 'blockly-ws-search-current');
}

Expand All @@ -600,7 +602,7 @@ export class WorkspaceSearch implements Blockly.IPositionable {
* @param currentBlock The block to unhighlight.
*/
protected unhighlightCurrentSelection(currentBlock: Blockly.BlockSvg) {
const path = currentBlock.pathObject.svgPath;
const path = currentBlock.getSvgRoot();
Blockly.utils.dom.removeClass(path, 'blockly-ws-search-current');
}

Expand All @@ -611,7 +613,7 @@ export class WorkspaceSearch implements Blockly.IPositionable {
*/
protected highlightSearchGroup(blocks: Blockly.BlockSvg[]) {
blocks.forEach((block) => {
const blockPath = block.pathObject.svgPath;
const blockPath = block.getSvgRoot();
Blockly.utils.dom.addClass(blockPath, 'blockly-ws-search-highlight');
});
}
Expand All @@ -623,7 +625,7 @@ export class WorkspaceSearch implements Blockly.IPositionable {
*/
protected unhighlightSearchGroup(blocks: Blockly.BlockSvg[]) {
blocks.forEach((block) => {
const blockPath = block.pathObject.svgPath;
const blockPath = block.getSvgRoot();
Blockly.utils.dom.removeClass(blockPath, 'blockly-ws-search-highlight');
});
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/workspace-search/test/workspace_search_test.mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ suite('WorkspaceSearch', function () {
* @returns {boolean} True if the block is currently highlighted.
*/
function isBlockHighlighted(block) {
const path = block.pathObject.svgPath;
const path = block.getSvgRoot();
const classes = path.getAttribute('class');
return (
(' ' + classes + ' ').indexOf(' blockly-ws-search-highlight ') !== -1
Expand All @@ -34,7 +34,7 @@ suite('WorkspaceSearch', function () {
* @returns {boolean} True if the block is currently styled.
*/
function isBlockCurrentStyled(block) {
const path = block.pathObject.svgPath;
const path = block.getSvgRoot();
const classes = path.getAttribute('class');
return (' ' + classes + ' ').indexOf(' blockly-ws-search-current ') !== -1;
}
Expand Down
Loading