Skip to content

Commit 7c77dc1

Browse files
feat: add shareText (Acode-Foundation#2104)
* feat: add shareText * fix * format * feat: added toggle * format * fix: conflict
1 parent 5e99727 commit 7c77dc1

39 files changed

Lines changed: 156 additions & 1 deletion

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"babel-loader": "^10.1.1",
7676
"com.foxdebug.acode.rk.auth": "file:src/plugins/auth",
7777
"com.foxdebug.acode.rk.customtabs": "file:src/plugins/custom-tabs",
78+
"com.foxdebug.acode.rk.exec.proot": "file:src/plugins/proot",
7879
"com.foxdebug.acode.rk.exec.terminal": "file:src/plugins/terminal",
7980
"com.foxdebug.acode.rk.plugin.plugincontext": "file:src/plugins/pluginContext",
8081
"cordova-android": "^15.0.0",

src/cm/commandRegistry.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,14 @@ function registerCoreCommands() {
436436
requiresView: true,
437437
run: pasteCommand,
438438
});
439+
440+
addCommand({
441+
name: "share",
442+
description: "Share",
443+
readOnly: true,
444+
requiresView: true,
445+
run: shareCommand,
446+
});
439447
addCommand({
440448
name: "problems",
441449
description: "Show errors and warnings",
@@ -1293,6 +1301,31 @@ function pasteCommand(view) {
12931301
return true;
12941302
}
12951303

1304+
function shareCommand(view) {
1305+
const resolvedView = resolveView(view);
1306+
if (!resolvedView) return false;
1307+
1308+
const { state } = resolvedView;
1309+
const ranges = state.selection.ranges;
1310+
const segments = [];
1311+
1312+
ranges.forEach((range) => {
1313+
if (range.empty) {
1314+
const line = state.doc.lineAt(range.head);
1315+
segments.push(state.doc.sliceString(line.from, line.to));
1316+
return;
1317+
}
1318+
1319+
segments.push(state.doc.sliceString(range.from, range.to));
1320+
});
1321+
1322+
const textToShare = segments.join("\n");
1323+
1324+
system.shareText(textToShare, console.log, console.error);
1325+
1326+
return true;
1327+
}
1328+
12961329
function selectWordCommand(view) {
12971330
const resolvedView = resolveView(view);
12981331
if (!resolvedView) return false;

src/lang/ar-ye.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@
731731
"plugin-not-supported": "Plugin not supported",
732732
"plugin-not-supported-info": "The plugin was created for older version of Acode.",
733733
"login-to-view": "Please login to view this...",
734+
"show share button": "Show share button",
735+
"settings-info-editor-show-share-button": "Show share button in selection menu.",
734736
"iap-plugin-purchase-warning": "لا تتم مزامنة الإضافات المشتراة مع حساب Acode الخاص بك. استخدم نفس حساب Google في متجر Play لاستعادة عملية الشراء.",
735737
"iap-pro-purchase-warning": "لن تتم مزامنة عملية الشراء هذه مع حساب Acode الخاص بك. استخدم نفس حساب Google في متجر Play لاستعادة عملية الشراء.",
736738
"confirm-login": "لم تقم بتسجيل الدخول إلى Acode، هل تريد تسجيل الدخول الآن؟"

src/lang/be-by.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@
731731
"plugin-not-supported": "Plugin not supported",
732732
"plugin-not-supported-info": "The plugin was created for older version of Acode.",
733733
"login-to-view": "Please login to view this...",
734+
"show share button": "Show share button",
735+
"settings-info-editor-show-share-button": "Show share button in selection menu.",
734736
"iap-plugin-purchase-warning": "Набытыя плагіны не сінхранізуюцца з вашым уліковым запісам Acode. Выкарыстоўвайце той жа ўліковы запіс Google у Play Store для аднаўлення пакупкі.",
735737
"iap-pro-purchase-warning": "Гэтая пакупка не будзе сінхранізавана з вашым уліковым запісам Acode. Выкарыстоўвайце той жа ўліковы запіс Google у Play Store для аднаўлення пакупкі.",
736738
"confirm-login": "Вы не ўвайшлі ў Acode, увайсці зараз?"

src/lang/bn-bd.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@
731731
"plugin-not-supported": "Plugin not supported",
732732
"plugin-not-supported-info": "The plugin was created for older version of Acode.",
733733
"login-to-view": "Please login to view this...",
734+
"show share button": "Show share button",
735+
"settings-info-editor-show-share-button": "Show share button in selection menu.",
734736
"iap-plugin-purchase-warning": "ক্রয়কৃত প্লাগইনগুলি আপনার Acode অ্যাকাউন্টের সাথে সিঙ্ক হয় না। আপনার ক্রয় পুনরুদ্ধার করতে প্লে স্টোরে একই Google অ্যাকাউন্ট ব্যবহার করুন।",
735737
"iap-pro-purchase-warning": "এই ক্রয়টি আপনার Acode অ্যাকাউন্টের সাথে সিঙ্ক হবে না। আপনার ক্রয় পুনরুদ্ধার করতে প্লে স্টোরে একই Google অ্যাকাউন্ট ব্যবহার করুন।",
736738
"confirm-login": "আপনি Acode-এ সাইন ইন করেননি, এখন সাইন ইন করবেন?"

src/lang/cs-cz.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@
731731
"plugin-not-supported": "Plugin not supported",
732732
"plugin-not-supported-info": "The plugin was created for older version of Acode.",
733733
"login-to-view": "Please login to view this...",
734+
"show share button": "Show share button",
735+
"settings-info-editor-show-share-button": "Show share button in selection menu.",
734736
"iap-plugin-purchase-warning": "Zakoupené pluginy nejsou synchronizovány s vaším účtem Acode. Pro obnovení nákupu použijte stejný účet Google v Obchodě Play.",
735737
"iap-pro-purchase-warning": "Tento nákup nebude synchronizován s vaším účtem Acode. Pro obnovení nákupu použijte stejný účet Google v Obchodě Play.",
736738
"confirm-login": "Nejste přihlášeni do Acode, přihlásit se nyní?"

src/lang/de-de.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@
731731
"plugin-not-supported": "Plugin not supported",
732732
"plugin-not-supported-info": "The plugin was created for older version of Acode.",
733733
"login-to-view": "Please login to view this...",
734+
"show share button": "Show share button",
735+
"settings-info-editor-show-share-button": "Show share button in selection menu.",
734736
"iap-plugin-purchase-warning": "Gekaufte Plugins werden nicht mit Ihrem Acode-Konto synchronisiert. Verwenden Sie dasselbe Google-Konto im Play Store, um Ihren Kauf wiederherzustellen.",
735737
"iap-pro-purchase-warning": "Dieser Kauf wird nicht mit Ihrem Acode-Konto synchronisiert. Verwenden Sie dasselbe Google-Konto im Play Store, um Ihren Kauf wiederherzustellen.",
736738
"confirm-login": "Sie sind nicht bei Acode angemeldet, jetzt anmelden?"

src/lang/en-us.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"settings saved": "Settings saved",
8282
"show line numbers": "Show line numbers",
8383
"show hidden files": "Show hidden files",
84+
"show share button": "Show share button",
8485
"show spaces": "Show spaces",
8586
"soft tab": "Soft tab",
8687
"sort by name": "Sort by name",
@@ -672,6 +673,7 @@
672673
"settings-info-editor-rtl-text": "Switch right-to-left behavior per line.",
673674
"settings-info-editor-scroll-settings": "Adjust scrollbar size, speed, and gesture behavior.",
674675
"settings-info-editor-shift-click-selection": "Extend selection with Shift + tap or click.",
676+
"settings-info-editor-show-share-button": "Show share button in selection menu.",
675677
"settings-info-editor-show-spaces": "Display visible whitespace markers.",
676678
"settings-info-editor-soft-tab": "Insert spaces instead of tab characters.",
677679
"settings-info-editor-tab-size": "Set how many spaces each tab step uses.",

src/lang/es-sv.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@
731731
"plugin-not-supported": "Plugin not supported",
732732
"plugin-not-supported-info": "The plugin was created for older version of Acode.",
733733
"login-to-view": "Please login to view this...",
734+
"show share button": "Show share button",
735+
"settings-info-editor-show-share-button": "Show share button in selection menu.",
734736
"iap-plugin-purchase-warning": "Los plugins comprados no se sincronizan con tu cuenta de Acode. Usa la misma cuenta de Google en Play Store para restaurar tu compra.",
735737
"iap-pro-purchase-warning": "Esta compra no se sincronizará con tu cuenta de Acode. Usa la misma cuenta de Google en Play Store para restaurar tu compra.",
736738
"confirm-login": "No has iniciado sesión en Acode, ¿iniciar sesión ahora?"

0 commit comments

Comments
 (0)