From 3d8c312c7af842b27e77b9efbc463b085be224c5 Mon Sep 17 00:00:00 2001 From: Lennard Fonteijn Date: Wed, 3 May 2023 17:12:40 +0200 Subject: [PATCH] Added a plugin to disable read-only mode --- plugins/disable-readonly/index.js | 22 ++++++++++++++++++++++ plugins/disable-readonly/manifest.json | 8 ++++++++ plugins/plugin-index.md | 1 + plugins/plugin-manager/js/app.js | 2 -- 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 plugins/disable-readonly/index.js create mode 100644 plugins/disable-readonly/manifest.json diff --git a/plugins/disable-readonly/index.js b/plugins/disable-readonly/index.js new file mode 100644 index 0000000..147aac2 --- /dev/null +++ b/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; + } +})(); diff --git a/plugins/disable-readonly/manifest.json b/plugins/disable-readonly/manifest.json new file mode 100644 index 0000000..245daa9 --- /dev/null +++ b/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" +} diff --git a/plugins/plugin-index.md b/plugins/plugin-index.md index e10f230..7fa953e 100644 --- a/plugins/plugin-index.md +++ b/plugins/plugin-index.md @@ -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) diff --git a/plugins/plugin-manager/js/app.js b/plugins/plugin-manager/js/app.js index c18a8bb..0485f97 100644 --- a/plugins/plugin-manager/js/app.js +++ b/plugins/plugin-manager/js/app.js @@ -258,8 +258,6 @@ app.controller("PluginsController", function ($scope, $rootScope, api) { } $rootScope.$on("reloadConfig", function () { - alert("trload"); - reloadConfig(); $scope.$apply();