Skip to content

Commit

Permalink
Added a plugin to disable read-only mode
Browse files Browse the repository at this point in the history
  • Loading branch information
LennardF1989 committed May 3, 2023
1 parent 42d6bf6 commit 3d8c312
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
22 changes: 22 additions & 0 deletions plugins/disable-readonly/index.js
@@ -0,0 +1,22 @@
/* global BF2042Portal, _Blockly */
(function () {
const plugin = BF2042Portal.Plugins.getPlugin("disable-readonly");

if(_Blockly.getMainWorkspace().options.readOnly) {
plugin.initializeWorkspace = function () {
setReadOnly(false);
};

setReadOnly(false);

//NOTE: We have to apply this to the existing workspace
_Blockly.getMainWorkspace().clear();
setTimeout(function() {
_Blockly.getMainWorkspace().undo();
}, 0);
}

function setReadOnly(toggle) {
_Blockly.getMainWorkspace().options.readOnly = toggle;
}
})();
8 changes: 8 additions & 0 deletions plugins/disable-readonly/manifest.json
@@ -0,0 +1,8 @@
{
"id": "disable-readonly",
"name": "Disable Read-only",
"version": "1.0.0",
"description": "Disables read-only on a workspace to enable selection and the context menu",
"author": "LennardF1989",
"main": "index.js"
}
1 change: 1 addition & 0 deletions plugins/plugin-index.md
Expand Up @@ -4,6 +4,7 @@ A curated list of all known plugins, sorted by alphabet. Create an Issue to have
| Name | Description | Author | Links |
|-|-|-|-|
| Dark Context Menu | Turn the context menu dark | LennardF1989 | [Source](https://github.com/LennardF1989/BF2042-Portal-Extensions/tree/master/plugins/dark-context-menu) / [Manifest](https://bf2042-portal-extensions.lennardf1989.com/plugins/dark-context-menu/manifest.json)
| Disable Read-only | Disables read-only on a workspace to enable selection and the context menu | LennardF1989 | [Source](https://github.com/LennardF1989/BF2042-Portal-Extensions/tree/master/plugins/disable-readonly) / [Manifest](https://bf2042-portal-extensions.lennardf1989.com/plugins/disable-readonly/manifest.json)
| Portal Unleashed | A Battlefield Portal scripting tool | [Ludonope](https://github.com/Ludonope) | [Source](https://github.com/Ludonope/BFPortalUnleashed) / [Manifest](https://ludonope.github.io/BFPortalUnleashed/dist/manifest.json)
| Red Variables | Turn variable blocks red | Gambit | [Source](https://github.com/LennardF1989/BF2042-Portal-Extensions/tree/master/plugins/red-variables) / [Manifest](https://bf2042-portal-extensions.lennardf1989.com/plugins/red-variables/manifest.json)
| Snippets | Insert snippets of blocks to your portal workspace | [TheOzzy](https://github.com/The0zzy) | [Source](https://github.com/The0zzy/bf2042-portal-snippet-plugin) / [Manifest](https://the0zzy.github.io/bf2042-portal-snippet-plugin/manifest.json)
Expand Down
2 changes: 0 additions & 2 deletions plugins/plugin-manager/js/app.js
Expand Up @@ -258,8 +258,6 @@ app.controller("PluginsController", function ($scope, $rootScope, api) {
}

$rootScope.$on("reloadConfig", function () {
alert("trload");

reloadConfig();

$scope.$apply();
Expand Down

0 comments on commit 3d8c312

Please sign in to comment.