Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable checkboxes (currently disabled) #94

Open
1 task
bverkron opened this issue Jan 13, 2024 · 5 comments
Open
1 task

Enable checkboxes (currently disabled) #94

bverkron opened this issue Jan 13, 2024 · 5 comments
Labels
enhancement New feature or request
Milestone

Comments

@bverkron
Copy link

bverkron commented Jan 13, 2024

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 bverkron added the enhancement New feature or request label Jan 13, 2024
@bverkron bverkron changed the title Allow enabling of checkboxes Enable checkboxes (currently disabled) Jan 13, 2024
@Zavy86
Copy link
Owner

Zavy86 commented Jan 13, 2024

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?

@bverkron
Copy link
Author

bverkron commented Jan 13, 2024

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.

@Zavy86
Copy link
Owner

Zavy86 commented Jan 14, 2024

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

@Zavy86 Zavy86 self-assigned this Jan 14, 2024
@bverkron
Copy link
Author

bverkron commented Jan 14, 2024

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
Copy link
Author

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 :)

@Zavy86 Zavy86 added this to the Release 1.1 milestone Aug 22, 2024
@Zavy86 Zavy86 removed their assignment Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants