Skip to content

Commit

Permalink
minor fixes and tweaks
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
bajrangCoder committed Dec 14, 2024
1 parent 0a2acc8 commit 1a71c00
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 45 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
"cordova-clipboard": {},
"cordova-plugin-buildinfo": {},
"cordova-plugin-device": {},
"cordova-plugin-file": {
"ANDROIDX_WEBKIT_VERSION": "1.4.0"
},
"cordova-plugin-file": {},
"cordova-plugin-sftp": {},
"cordova-plugin-server": {},
"cordova-plugin-ftp": {},
Expand Down
8 changes: 8 additions & 0 deletions src/ace/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,14 @@ const commands = [
},
readOnly: true,
},
{
name: "openFileExplorer",
description: "File Explorer",
exec() {
acode.exec("open", "file_browser");
},
readOnly: true,
},
{
name: "copyDeviceInfo",
description: "Copy Device info",
Expand Down
4 changes: 4 additions & 0 deletions src/lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ export default {
plugins();
break;

case "file_browser":
FileBrowser();
break;

default:
return;
}
Expand Down
27 changes: 27 additions & 0 deletions src/pages/plugin/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,33 @@ export default async function PluginInclude(
);
});

// add copy button to code blocks
const codeBlocks = $page.body.querySelectorAll("pre");
codeBlocks.forEach((pre) => {
pre.style.position = "relative";
const copyButton = document.createElement("button");
copyButton.className = "copy-button";
copyButton.textContent = "Copy";

copyButton.addEventListener("click", async () => {
const code = pre.querySelector("code")?.textContent || pre.textContent;
try {
cordova.plugins.clipboard.copy(code);
copyButton.textContent = "Copied!";
setTimeout(() => {
copyButton.textContent = "Copy";
}, 2000);
} catch (err) {
copyButton.textContent = "Failed to copy";
setTimeout(() => {
copyButton.textContent = "Copy";
}, 2000);
}
});

pre.appendChild(copyButton);
});

if ($settingsIcon) {
$settingsIcon.remove();
$settingsIcon = null;
Expand Down
1 change: 1 addition & 0 deletions src/sidebarApps/extensions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ async function searchPlugin() {
$searchResult.content = plugins.map(ListItem);
updateHeight($searchResult);
} catch (error) {
window.log("error", error);
$searchResult.content = <span className="error">{strings["error"]}</span>;
} finally {
$searchResult.classList.remove("loading");
Expand Down
96 changes: 59 additions & 37 deletions src/styles/markdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
font-family: monospace, monospace;
_font-family: "courier new", monospace;
font-size: 0.98em;
padding: 0.25rem;
}

kbd {
Expand Down Expand Up @@ -161,6 +162,30 @@
white-space: pre;
white-space: pre-wrap;
word-wrap: break-word;
position: relative !important;
}

pre:hover .copy-button {
opacity: 1;
}

.copy-button {
position: absolute;
top: 8px;
right: 5px;
padding: 4px 8px;
background: rgba(0, 0, 0, 0.8);
border: none;
border-radius: 4px;
cursor: pointer;
opacity: 0;
transition: opacity 0.2s;
font-size: 12px;
color: inherit;

&:hover {
background: rgba(0, 0, 0, 0.9);
}
}

b,
Expand Down Expand Up @@ -284,7 +309,6 @@
content: "";
}

pre,
blockquote {
border: 1px solid #999;
padding-right: 1em;
Expand Down Expand Up @@ -390,47 +414,45 @@
color: var(--color-caution);
}
.task-list-item {
list-style-type: none;

label {
font-weight: 400;
}

&.enabled label {
cursor: pointer;
}

&+.task-list-item {
margin-top: 0.25rem;
}

.handle {
display: none;
}

&-checkbox {
margin: 0 0.2em 0.25em -1.4em;
vertical-align: middle;
border-radius: 4px;
cursor: pointer;
}
list-style-type: none;

label {
font-weight: 400;
}

&.enabled label {
cursor: pointer;
}

& + .task-list-item {
margin-top: 0.25rem;
}

.handle {
display: none;
}

ul:dir(rtl) .task-list-item-checkbox,
ol:dir(rtl) .task-list-item-checkbox {
margin: 0 -1.6em 0.25em 0.2em;
&-checkbox {
margin: 0 0.2em 0.25em -1.4em;
vertical-align: middle;
border-radius: 4px;
cursor: pointer;
}
}

.contains-task-list {
ul:dir(rtl) .task-list-item-checkbox,
ol:dir(rtl) .task-list-item-checkbox {
margin: 0 -1.6em 0.25em 0.2em;
}

&:hover .task-list-item-convert-container,
&:focus-within .task-list-item-convert-container {
display: block;
width: auto;
height: 24px;
overflow: visible;
clip: auto;
}
.contains-task-list {
&:hover .task-list-item-convert-container,
&:focus-within .task-list-item-convert-container {
display: block;
width: auto;
height: 24px;
overflow: visible;
clip: auto;
}
}
}
1 change: 1 addition & 0 deletions src/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ export default {
const { status } = await ajax.get(Url.join(constants.API_BASE, "status"));
return status === "ok";
} catch (error) {
window.log("error", error);
return false;
}
},
Expand Down
10 changes: 5 additions & 5 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@

<title>Acode</title>
<!--styles-->
<link rel="stylesheet" href="./css/build/327.css">
<link rel="stylesheet" href="./css/build/450.css">
<link rel="stylesheet" href="./css/build/599.css">
<link rel="stylesheet" href="./css/build/608.css">
<link rel="stylesheet" href="./css/build/725.css">
<link rel="stylesheet" href="./css/build/218.css">
<link rel="stylesheet" href="./css/build/32.css">
<link rel="stylesheet" href="./css/build/383.css">
<link rel="stylesheet" href="./css/build/53.css">
<link rel="stylesheet" href="./css/build/609.css">
<link rel="stylesheet" href="./css/build/about.css">
<link rel="stylesheet" href="./css/build/customTheme.css">
<link rel="stylesheet" href="./css/build/donate.css">
Expand Down

0 comments on commit 1a71c00

Please sign in to comment.