|
| 1 | +!(function (e, t) { |
| 2 | + "object" == typeof exports && "undefined" != typeof module |
| 3 | + ? t(exports) |
| 4 | + : "function" == typeof define && define.amd |
| 5 | + ? define(["exports"], t) |
| 6 | + : t((e.SearchBarAddon = {})); |
| 7 | +})(this, function (e) { |
| 8 | + "use strict"; |
| 9 | + !(function (e, t) { |
| 10 | + void 0 === t && (t = {}); |
| 11 | + var a = t.insertAt; |
| 12 | + if (e && "undefined" != typeof document) { |
| 13 | + var i = document.head || document.getElementsByTagName("head")[0], |
| 14 | + n = document.createElement("style"); |
| 15 | + (n.type = "text/css"), |
| 16 | + "top" === a && i.firstChild |
| 17 | + ? i.insertBefore(n, i.firstChild) |
| 18 | + : i.appendChild(n), |
| 19 | + n.styleSheet |
| 20 | + ? (n.styleSheet.cssText = e) |
| 21 | + : n.appendChild(document.createTextNode(e)); |
| 22 | + } |
| 23 | + })( |
| 24 | + `.xterm-search-bar__addon{position:absolute;max-width:1467px;top:0;right:28px;color:#000;background:#fff; |
| 25 | + padding:5px 10px;box-shadow:0 2px 8px #000;background-color:#252526;z-index:999;display:flex}.xterm-search-bar__addon |
| 26 | + .search-bar__input{background-color:#3c3c3c;color:#ccc;border:0;margin-bottom:0px;padding:2px;height:20px;width:227px}.xterm-search-bar__addon |
| 27 | + .search-bar__btn{min-width:20px;width:20px;height:20px;display:flex;display:-webkit-flex;flex:initial;background-position:50%; |
| 28 | + margin-left:3px;margin-bottom:0px;background-repeat:no-repeat;background-color:#252526;border:0;cursor:pointer;padding: 0}.xterm-search-bar__addon |
| 29 | + .search-bar__btn:hover{background-color:#666}.xterm-search-bar__addon .search-bar__btn.prev{background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iI2ZmZiI+PHBhdGggZD0iTTUuNCA4YS42LjYgMCAwMS4xNzYtLjQyNGw0LTRhLjU5OC41OTggMCAwMS44NDggMCAuNTk4LjU5OCAwIDAxMCAuODQ4TDYuODQ5IDhsMy41NzUgMy41NzZhLjU5OC41OTggMCAwMTAgLjg0OC41OTguNTk4IDAgMDEtLjg0OCAwbC00LTRBLjYuNiAwIDAxNS40IDgiLz48L3N2Zz4=")}.xterm-search-bar__addon |
| 30 | + .search-bar__btn.next{background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iI2ZmZiI+PHBhdGggZD0iTTEwLjYgOGEuNi42IDAgMDEtLjE3Ni40MjRsLTQgNGEuNTk4LjU5OCAwIDAxLS44NDggMCAuNTk4LjU5OCAwIDAxMC0uODQ4TDkuMTUxIDggNS41NzYgNC40MjRhLjU5OC41OTggMCAwMTAtLjg0OC41OTguNTk4IDAgMDEuODQ4IDBsNCA0QS42LjYgMCAwMTEwLjYgOCIvPjwvc3ZnPg==")}.xterm-search-bar__addon |
| 31 | + .search-bar__btn.close{background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxMiIgZmlsbD0iI2ZmZiI+PHBhdGggZD0iTTcgNmwyLTJhLjcxMS43MTEgMCAwMDAtMSAuNzExLjcxMSAwIDAwLTEgMEw2IDUgNCAzYS43MTEuNzExIDAgMDAtMSAwIC43MTEuNzExIDAgMDAwIDFsMiAyLTIgMmEuNzExLjcxMSAwIDAwMCAxIC43MTEuNzExIDAgMDAxIDBsMi0yIDIgMmEuNzExLjcxMSAwIDAwMSAwIC43MTEuNzExIDAgMDAwLTFMNyA2eiIvPjwvc3ZnPg==")}` |
| 32 | + ); |
| 33 | + const t = "xterm-search-bar__addon"; |
| 34 | + (e.SearchBarAddon = class { |
| 35 | + constructor(e) { |
| 36 | + (this.options = e || {}), |
| 37 | + this.options && |
| 38 | + this.options.searchAddon && |
| 39 | + (this.searchAddon = this.options.searchAddon); |
| 40 | + } |
| 41 | + activate(e) { |
| 42 | + (this.terminal = e), this.searchAddon; |
| 43 | + } |
| 44 | + dispose() { |
| 45 | + this.hidden(); |
| 46 | + } |
| 47 | + show() { |
| 48 | + if (!this.terminal || !this.terminal.element) return; |
| 49 | + if (this.searchBarElement) |
| 50 | + return ( |
| 51 | + (this.searchBarElement.style.visibility = "visible"), |
| 52 | + void this.searchBarElement.querySelector("input").select() |
| 53 | + ); |
| 54 | + this.terminal.element.style.position = "relative"; |
| 55 | + const e = document.createElement("div"); |
| 56 | + (e.innerHTML = |
| 57 | + `<input type="text" class="search-bar__input" name="search-bar__input"/> |
| 58 | + <button class="search-bar__btn prev"></button> |
| 59 | + <button class="search-bar__btn next"></button> |
| 60 | + <button class="search-bar__btn close"></button>`), |
| 61 | + (e.className = t); |
| 62 | + const a = this.terminal.element.parentElement; |
| 63 | + (this.searchBarElement = e), |
| 64 | +/* ["relative", "absolute", "fixed"].includes(a.style.position) || |
| 65 | + (a.style.position = "relative"),*/ |
| 66 | + a.appendChild(this.searchBarElement), |
| 67 | + this.on(".search-bar__btn.close", "click", () => { |
| 68 | + this.hidden(); |
| 69 | + }), |
| 70 | + this.on(".search-bar__btn.next", "click", () => { |
| 71 | + this.searchAddon.findNext(this.searchKey, { incremental: !1 }); |
| 72 | + }), |
| 73 | + this.on(".search-bar__btn.prev", "click", () => { |
| 74 | + this.searchAddon.findPrevious(this.searchKey, { incremental: !1 }); |
| 75 | + }), |
| 76 | + this.on(".search-bar__input", "keyup", (e) => { |
| 77 | + (this.searchKey = e.target.value), |
| 78 | + this.searchAddon.findNext(this.searchKey, { |
| 79 | + incremental: "Enter" !== e.key, |
| 80 | + }); |
| 81 | + }), |
| 82 | + this.searchBarElement.querySelector("input").select(); |
| 83 | + } |
| 84 | + hidden() { |
| 85 | + this.searchBarElement && |
| 86 | + this.terminal.element.parentElement && |
| 87 | + (this.searchBarElement.style.visibility = "hidden"); |
| 88 | + } |
| 89 | + on(e, t, a) { |
| 90 | + const i = this.terminal.element.parentElement; |
| 91 | + i.addEventListener(t, (t) => { |
| 92 | + let n = t.target; |
| 93 | + for (; n !== document.querySelector(e); ) { |
| 94 | + if (n === i) { |
| 95 | + n = null; |
| 96 | + break; |
| 97 | + } |
| 98 | + n = n.parentElement; |
| 99 | + } |
| 100 | + n === document.querySelector(e) && |
| 101 | + (a.call(this, t), t.stopPropagation()); |
| 102 | + }); |
| 103 | + } |
| 104 | + addNewStyle(e) { |
| 105 | + let a = document.getElementById(t); |
| 106 | + a || |
| 107 | + (((a = document.createElement("style")).type = "text/css"), |
| 108 | + (a.id = t), |
| 109 | + document.getElementsByTagName("head")[0].appendChild(a)), |
| 110 | + a.appendChild(document.createTextNode(e)); |
| 111 | + } |
| 112 | + }), |
| 113 | + Object.defineProperty(e, "__esModule", { value: !0 }); |
| 114 | +}); |
0 commit comments