|
95 | 95 | text-align: center;
|
96 | 96 | margin-top: 1rem;
|
97 | 97 | }
|
| 98 | + |
| 99 | + .prompt, |
| 100 | + .confirmation { |
| 101 | + margin-bottom: 0.25rem; |
| 102 | + } |
| 103 | + |
| 104 | + .confirmation { |
| 105 | + font-style: italic; |
| 106 | + } |
| 107 | + |
| 108 | + .hidden { |
| 109 | + display: none; |
| 110 | + } |
98 | 111 | </style>
|
99 | 112 | </head>
|
100 | 113 | <body>
|
101 | 114 | <div id="container" class="container" style="-webkit-user-select: none; -webkit-app-region: drag;">
|
102 | 115 | <div class="waiting-header">Waiting for React to connect…</div>
|
103 |
| - <div class="boxes"> |
| 116 | + <div class="boxes" style="-webkit-app-region: none;"> |
104 | 117 | <div class="box">
|
105 | 118 | <div class="box-header">React Native</div>
|
106 | 119 | <div class="box-content">
|
|
115 | 128 | <div class="box">
|
116 | 129 | <div class="box-header">React DOM</div>
|
117 | 130 | <div class="box-content">
|
118 |
| - Add one of the following: |
| 131 | + <div id="box-content-prompt" class="prompt"> |
| 132 | + Add one of the following (click to copy): |
| 133 | + </div> |
| 134 | + <div id="box-content-confirmation" class="confirmation hidden"> |
| 135 | + Copied to clipboard. |
| 136 | + </div> |
119 | 137 | <span class="input" contenteditable="true" id="localhost"></span>
|
120 | 138 | <span class="input" contenteditable="true" id="byip"></span>
|
121 | 139 | to the top of the page you want to debug,
|
|
127 | 145 | </div>
|
128 | 146 | </div>
|
129 | 147 | <script>
|
| 148 | + const {clipboard} = require("electron"); |
130 | 149 | const port = process.env.PORT || 8097;
|
131 | 150 | const localIp = require("ip").address();
|
132 | 151 | const $ = document.querySelector.bind(document);
|
| 152 | + const $promptDiv = $("#box-content-prompt"); |
| 153 | + const $confirmationDiv = $("#box-content-confirmation"); |
| 154 | + let timeoutID; |
133 | 155 |
|
134 |
| - function selectAll(event) { |
| 156 | + function selectAllAndCopy(event) { |
135 | 157 | const element = event.target;
|
136 | 158 | if (window.getSelection) {
|
137 |
| - const selection = window.getSelection(); |
| 159 | + const selection = window.getSelection(); |
138 | 160 | const range = document.createRange();
|
139 | 161 | range.selectNodeContents(element);
|
140 | 162 | selection.removeAllRanges();
|
141 | 163 | selection.addRange(range);
|
| 164 | + clipboard.writeText(event.target.textContent); |
| 165 | + |
| 166 | + $promptDiv.classList.add('hidden'); |
| 167 | + $confirmationDiv.classList.remove('hidden'); |
| 168 | + |
| 169 | + if (timeoutID) { |
| 170 | + clearTimeout(timeoutID); |
| 171 | + } |
| 172 | + |
| 173 | + timeoutID = setTimeout(() => { |
| 174 | + $promptDiv.classList.remove('hidden'); |
| 175 | + $confirmationDiv.classList.add('hidden'); |
| 176 | + }, 1000); |
142 | 177 | }
|
143 | 178 | }
|
144 | 179 |
|
|
150 | 185 |
|
151 | 186 | const $localhost = $("#localhost");
|
152 | 187 | $localhost.innerText = `<script src="http://localhost:${port}"></` + 'script>';
|
153 |
| - $localhost.addEventListener('click', selectAll); |
154 |
| - $localhost.addEventListener('focus', selectAll); |
| 188 | + $localhost.addEventListener('click', selectAllAndCopy); |
| 189 | + $localhost.addEventListener('focus', selectAllAndCopy); |
155 | 190 |
|
156 | 191 | const $byIp = $("#byip");
|
157 | 192 | $byIp.innerText = `<script src="http://${localIp}:${port}"></` + 'script>';
|
158 |
| - $byIp.addEventListener('click', selectAll); |
159 |
| - $byIp.addEventListener('focus', selectAll); |
| 193 | + $byIp.addEventListener('click', selectAllAndCopy); |
| 194 | + $byIp.addEventListener('focus', selectAllAndCopy); |
160 | 195 |
|
161 | 196 | let devtools;
|
162 | 197 | try {
|
|
0 commit comments