diff --git a/package.json b/package.json index 55e51ad90..b583b9a95 100644 --- a/package.json +++ b/package.json @@ -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": {}, diff --git a/src/ace/commands.js b/src/ace/commands.js index 3980110c8..f88579bd4 100644 --- a/src/ace/commands.js +++ b/src/ace/commands.js @@ -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", diff --git a/src/lib/commands.js b/src/lib/commands.js index 651b4b28f..1e849e750 100644 --- a/src/lib/commands.js +++ b/src/lib/commands.js @@ -182,6 +182,10 @@ export default { plugins(); break; + case "file_browser": + FileBrowser(); + break; + default: return; } diff --git a/src/pages/plugin/plugin.js b/src/pages/plugin/plugin.js index ff9013bb9..82202cf52 100644 --- a/src/pages/plugin/plugin.js +++ b/src/pages/plugin/plugin.js @@ -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; diff --git a/src/sidebarApps/extensions/index.js b/src/sidebarApps/extensions/index.js index 14e57d4be..2d0bc64f9 100644 --- a/src/sidebarApps/extensions/index.js +++ b/src/sidebarApps/extensions/index.js @@ -115,6 +115,7 @@ async function searchPlugin() { $searchResult.content = plugins.map(ListItem); updateHeight($searchResult); } catch (error) { + window.log("error", error); $searchResult.content = {strings["error"]}; } finally { $searchResult.classList.remove("loading"); diff --git a/src/styles/markdown.scss b/src/styles/markdown.scss index 8011a1261..2b0b95c6f 100644 --- a/src/styles/markdown.scss +++ b/src/styles/markdown.scss @@ -134,6 +134,7 @@ font-family: monospace, monospace; _font-family: "courier new", monospace; font-size: 0.98em; + padding: 0.25rem; } kbd { @@ -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, @@ -284,7 +309,6 @@ content: ""; } - pre, blockquote { border: 1px solid #999; padding-right: 1em; @@ -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; } + } } diff --git a/src/utils/helpers.js b/src/utils/helpers.js index 798489c08..424718c02 100644 --- a/src/utils/helpers.js +++ b/src/utils/helpers.js @@ -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; } }, diff --git a/www/index.html b/www/index.html index 3353560a6..aa1ce8cea 100644 --- a/www/index.html +++ b/www/index.html @@ -164,11 +164,11 @@