Skip to content

Commit 39bee2f

Browse files
authored
minor fixes and tweaks (#1103)
- Added new command(`file explorer`) to open file manager - Added copy button to code blocks on plugin page - some error logging for debugging - few markdown tweaks
1 parent 0a2acc8 commit 39bee2f

8 files changed

Lines changed: 106 additions & 45 deletions

File tree

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
"cordova-clipboard": {},
2525
"cordova-plugin-buildinfo": {},
2626
"cordova-plugin-device": {},
27-
"cordova-plugin-file": {
28-
"ANDROIDX_WEBKIT_VERSION": "1.4.0"
29-
},
27+
"cordova-plugin-file": {},
3028
"cordova-plugin-sftp": {},
3129
"cordova-plugin-server": {},
3230
"cordova-plugin-ftp": {},

src/ace/commands.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,14 @@ const commands = [
309309
},
310310
readOnly: true,
311311
},
312+
{
313+
name: "openFileExplorer",
314+
description: "File Explorer",
315+
exec() {
316+
acode.exec("open", "file_browser");
317+
},
318+
readOnly: true,
319+
},
312320
{
313321
name: "copyDeviceInfo",
314322
description: "Copy Device info",

src/lib/commands.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ export default {
182182
plugins();
183183
break;
184184

185+
case "file_browser":
186+
FileBrowser();
187+
break;
188+
185189
default:
186190
return;
187191
}

src/pages/plugin/plugin.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,33 @@ export default async function PluginInclude(
356356
);
357357
});
358358

359+
// add copy button to code blocks
360+
const codeBlocks = $page.body.querySelectorAll("pre");
361+
codeBlocks.forEach((pre) => {
362+
pre.style.position = "relative";
363+
const copyButton = document.createElement("button");
364+
copyButton.className = "copy-button";
365+
copyButton.textContent = "Copy";
366+
367+
copyButton.addEventListener("click", async () => {
368+
const code = pre.querySelector("code")?.textContent || pre.textContent;
369+
try {
370+
cordova.plugins.clipboard.copy(code);
371+
copyButton.textContent = "Copied!";
372+
setTimeout(() => {
373+
copyButton.textContent = "Copy";
374+
}, 2000);
375+
} catch (err) {
376+
copyButton.textContent = "Failed to copy";
377+
setTimeout(() => {
378+
copyButton.textContent = "Copy";
379+
}, 2000);
380+
}
381+
});
382+
383+
pre.appendChild(copyButton);
384+
});
385+
359386
if ($settingsIcon) {
360387
$settingsIcon.remove();
361388
$settingsIcon = null;

src/sidebarApps/extensions/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ async function searchPlugin() {
115115
$searchResult.content = plugins.map(ListItem);
116116
updateHeight($searchResult);
117117
} catch (error) {
118+
window.log("error", error);
118119
$searchResult.content = <span className="error">{strings["error"]}</span>;
119120
} finally {
120121
$searchResult.classList.remove("loading");

src/styles/markdown.scss

Lines changed: 59 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
font-family: monospace, monospace;
135135
_font-family: "courier new", monospace;
136136
font-size: 0.98em;
137+
padding: 0.25rem;
137138
}
138139

139140
kbd {
@@ -161,6 +162,30 @@
161162
white-space: pre;
162163
white-space: pre-wrap;
163164
word-wrap: break-word;
165+
position: relative !important;
166+
}
167+
168+
pre:hover .copy-button {
169+
opacity: 1;
170+
}
171+
172+
.copy-button {
173+
position: absolute;
174+
top: 8px;
175+
right: 5px;
176+
padding: 4px 8px;
177+
background: rgba(0, 0, 0, 0.8);
178+
border: none;
179+
border-radius: 4px;
180+
cursor: pointer;
181+
opacity: 0;
182+
transition: opacity 0.2s;
183+
font-size: 12px;
184+
color: inherit;
185+
186+
&:hover {
187+
background: rgba(0, 0, 0, 0.9);
188+
}
164189
}
165190

166191
b,
@@ -284,7 +309,6 @@
284309
content: "";
285310
}
286311

287-
pre,
288312
blockquote {
289313
border: 1px solid #999;
290314
padding-right: 1em;
@@ -390,47 +414,45 @@
390414
color: var(--color-caution);
391415
}
392416
.task-list-item {
393-
list-style-type: none;
394-
395-
label {
396-
font-weight: 400;
397-
}
398-
399-
&.enabled label {
400-
cursor: pointer;
401-
}
402-
403-
&+.task-list-item {
404-
margin-top: 0.25rem;
405-
}
406-
407-
.handle {
408-
display: none;
409-
}
410-
411-
&-checkbox {
412-
margin: 0 0.2em 0.25em -1.4em;
413-
vertical-align: middle;
414-
border-radius: 4px;
415-
cursor: pointer;
416-
}
417+
list-style-type: none;
418+
419+
label {
420+
font-weight: 400;
417421
}
418422

423+
&.enabled label {
424+
cursor: pointer;
425+
}
426+
427+
& + .task-list-item {
428+
margin-top: 0.25rem;
429+
}
430+
431+
.handle {
432+
display: none;
433+
}
419434

420-
ul:dir(rtl) .task-list-item-checkbox,
421-
ol:dir(rtl) .task-list-item-checkbox {
422-
margin: 0 -1.6em 0.25em 0.2em;
435+
&-checkbox {
436+
margin: 0 0.2em 0.25em -1.4em;
437+
vertical-align: middle;
438+
border-radius: 4px;
439+
cursor: pointer;
423440
}
441+
}
424442

425-
.contains-task-list {
443+
ul:dir(rtl) .task-list-item-checkbox,
444+
ol:dir(rtl) .task-list-item-checkbox {
445+
margin: 0 -1.6em 0.25em 0.2em;
446+
}
426447

427-
&:hover .task-list-item-convert-container,
428-
&:focus-within .task-list-item-convert-container {
429-
display: block;
430-
width: auto;
431-
height: 24px;
432-
overflow: visible;
433-
clip: auto;
434-
}
448+
.contains-task-list {
449+
&:hover .task-list-item-convert-container,
450+
&:focus-within .task-list-item-convert-container {
451+
display: block;
452+
width: auto;
453+
height: 24px;
454+
overflow: visible;
455+
clip: auto;
435456
}
457+
}
436458
}

src/utils/helpers.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ export default {
330330
const { status } = await ajax.get(Url.join(constants.API_BASE, "status"));
331331
return status === "ok";
332332
} catch (error) {
333+
window.log("error", error);
333334
return false;
334335
}
335336
},

www/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@
164164

165165
<title>Acode</title>
166166
<!--styles-->
167-
<link rel="stylesheet" href="./css/build/327.css">
168-
<link rel="stylesheet" href="./css/build/450.css">
169-
<link rel="stylesheet" href="./css/build/599.css">
170-
<link rel="stylesheet" href="./css/build/608.css">
171-
<link rel="stylesheet" href="./css/build/725.css">
167+
<link rel="stylesheet" href="./css/build/218.css">
168+
<link rel="stylesheet" href="./css/build/32.css">
169+
<link rel="stylesheet" href="./css/build/383.css">
170+
<link rel="stylesheet" href="./css/build/53.css">
171+
<link rel="stylesheet" href="./css/build/609.css">
172172
<link rel="stylesheet" href="./css/build/about.css">
173173
<link rel="stylesheet" href="./css/build/customTheme.css">
174174
<link rel="stylesheet" href="./css/build/donate.css">

0 commit comments

Comments
 (0)