WikiDocs icon indicating copy to clipboard operation
WikiDocs copied to clipboard

Enable checkboxes (currently disabled)

Open bverkron opened this issue 1 year ago • 5 comments

Describe the feature

Would like to be able to check / uncheck checkboxes in wiki pages. They render with the common syntax of - [ ] but are disabled and cannot be checked / unchecked.

The HTML in the browser shows <input type="checkbox" disabled>. If I remove the 'disabled' attribute in the browser dev tools the checkboxes work beautifully.

I don't see a way to enable them with overrides like with the css styles or js scripts. The 'disabled' properly seems to be baked into the ParsedownExtended.php file.

https://github.com/Zavy86/WikiDocs/blob/1dcc28070df28290cab46edc2b02c9458634d9af/libraries/parsedown-extended-1.1.2-modified/ParsedownExtended.php#L1316C51-L1316C58

Is your feature request related to a problem? (optional)

No response

Screenshots (optional)

Current / default behaviour Screenshot 2024-01-13 at 1 40 18 PM

Desired behaviour Screenshot 2024-01-13 at 1 40 28 PM

Extra fields

  • [ ] I'd like to work on this feature

bverkron avatar Jan 13 '24 21:01 bverkron

The problem is that the markdown file is not updated in display mode .. I don't understand the additional value of being able to flag the checkbox .. Or did I misunderstand your request?

Zavy86 avatar Jan 13 '24 21:01 Zavy86

The intent is not to have the check state persist but rather to follow steps, for example, as you're going through instructions. The state of the checkboxes being ephemeral and resetting on page reload is totally fine.

As an example I am updating some financial workflow documentation for my wife and have a bulleted list for the steps to follow (example are download financial transactions, import transaction, categorize transactions, etc). This gets done every week or two. Having a simple checklist right in the wiki document she can use to keep track of her steps would be helpful. It can be easy to lose your place while following steps with just bulleted lists. She could have a separate app / lists elsewhere but that's yet another window / app she then has to keep open and juggle around to. Much easier to do right along with the instructions.

I grant that checkboxes in a wiki page seem a bit odd but to me it's odder (and more frustrating) to have checkboxes render but then not be usable. To me it does not make sense to have them disabled because then what would be the point of using them over a bulleted list? They have a separate and valuable purpose over bulleted lists but are hampered by being disabled.

bverkron avatar Jan 13 '24 22:01 bverkron

oh wow.. It is really a good idea to use them as a checklist. I will think about how to implement it!

Zavy86 avatar Jan 14 '24 08:01 Zavy86

I will think about how to implement it!

Amazing!

Looking at the doc for ParsedownExtended it refers to the checkboxes as 'tasks' and they should be enabled by default, I think.

Searching the WikiDocs code I see the following block which seems to be setting tasks to true (i.e. enabled) if there is no value set in options['lists']['tasks']

        // Task
        $state = $this->options['lists']['tasks'] ?? true;
        if ($state !== false) {
            $this->BlockTypes['['][] = 'Checkbox';
        }

As far as I can tell that should evaluate $state to true because I don't see anywhere else in the code where options['lists']['tasks'] is set (i.e. anywhere it could be set to false). But maybe my mental parsing of that code it wrong. I don't have a PHP environment I can test this in or time to set one up.

It's also interesting to see $state reused over and over again in that file (which I've always been told is not good practice) so maybe it's getting set to false elsewhere in that file and not updated to true in that line for tasks? Grasping at straws here.

bverkron avatar Jan 14 '24 18:01 bverkron

Looking again I don't see how the above code can even effect the disabled HTML attribute of the checkboxes. It seems to be hard coded here.

    protected function checkboxUnchecked($text)
    {
        if ($this->markupEscaped || $this->safeMode) {
            $text = self::escape($text);
        }

        return '<p><label><input type="checkbox" disabled /><span> '.$this->format($text).'</span></label></p>';
    }

    protected function checkboxChecked($text)
    {
        if ($this->markupEscaped || $this->safeMode) {
            $text = self::escape($text);
        }

        return '<p><label><input type="checkbox" checked disabled /><span> '.$this->format($text).'</span></label></p>';
    }

It's a big unclear to me how to apply enforce the "task" => (boolean) $value // default true from the ParsedownExtended doc in the context of WikiDocs or if that will even solve the issue based on how the above code is designed.

For now I have just bind mounted the /var/www/localhost/htdocs/libraries/parsedown-extended-1.1.2-modified directory to my host along with my scripts and other customization, which is not ideal but works for now :)

bverkron avatar Jan 14 '24 20:01 bverkron