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
1 change: 1 addition & 0 deletions packages/yasgui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"autosuggest-highlight": "^3.1.1",
"blueimp-md5": "^2.12.0",
"choices.js": "^9.0.1",
"dompurify": "^2.0.7",
"es6-object-assign": "^1.1.0",
"jsuri": "^1.3.1",
"lodash-es": "^4.17.15",
Expand Down
10 changes: 5 additions & 5 deletions packages/yasgui/src/endpointSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { pick } from "lodash-es";
import { addClass } from "@triply/yasgui-utils";
require("./endpointSelect.scss");
import parse from "autosuggest-highlight/parse";
import { sanitize } from "dompurify";

//Export this here instead of from our custom-types folder of autocomplete-js
//as this interface is exported via the yasgui config. The custom typings are
Expand Down Expand Up @@ -128,15 +129,14 @@ export class EndpointSelect extends EventEmitter {
},
resultItem: {
content: (data, source) => {
const endpoint = sanitize(data.value.endpoint);

// Custom handling of items with history, these are able to be removed
if (data.value.type && data.value.type === "history") {
// Add a container to make folding work correctly
const resultsContainer = document.createElement("div");
// Match is highlighted text
resultsContainer.innerHTML = parse(
data.value.endpoint,
createHighlights(data.value.endpoint, this.inputField.value)
).reduce(
resultsContainer.innerHTML = parse(endpoint, createHighlights(endpoint, this.inputField.value)).reduce(
(current, object) => (object.highlight ? current + object.text.bold() : current + object.text),
""
);
Expand All @@ -147,7 +147,7 @@ export class EndpointSelect extends EventEmitter {
removeBtn.textContent = "✖";
addClass(removeBtn, "removeItem");
removeBtn.addEventListener("mousedown", (event) => {
this.history = this.history.filter((item) => item.endpoint !== data.value.endpoint);
this.history = this.history.filter((item) => item.endpoint !== endpoint);
this.emit(
"remove",
this.value,
Expand Down