FIX: do not markdownify calendar if plugin is not enabled

FIX: do not markdownify calendar if plugin is not enabled

diff --git a/assets/javascripts/lib/discourse-markdown/discourse-calendar.js.es6 b/assets/javascripts/lib/discourse-markdown/discourse-calendar.js.es6
index 31fc966..5583d4a 100644
--- a/assets/javascripts/lib/discourse-markdown/discourse-calendar.js.es6
+++ b/assets/javascripts/lib/discourse-markdown/discourse-calendar.js.es6
@@ -1,7 +1,7 @@
 const calendarRule = {
   tag: "calendar",
 
-  wrap: function(token, info) {
+  wrap(token, info) {
     token.attrs = [
       ["class", "calendar"],
       ["data-calendar-type", info.attrs.type || "dynamic"]
@@ -28,10 +28,13 @@ export function setup(helper) {
   ]);
 
   helper.registerOptions((opts, siteSettings) => {
-    opts.features.calendar_enabled = !!siteSettings.calendar_enabled;
+    opts.features["discourse-calendar-enabled"] = !!siteSettings.calendar_enabled;
   });
 
   helper.registerPlugin(md => {
-    md.block.bbcode.ruler.push("discourse-calendar", calendarRule);
+    const features = md.options.discourse.features;
+    if (features["discourse-calendar-enabled"]) {
+      md.block.bbcode.ruler.push("discourse-calendar", calendarRule);
+    }
   });
 }

GitHub sha: d7e77f97

1 Like