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

Disable automatic bracket/quote closing #7

Open
Zei33 opened this issue Sep 30, 2020 · 14 comments
Open

Disable automatic bracket/quote closing #7

Zei33 opened this issue Sep 30, 2020 · 14 comments

Comments

@Zei33
Copy link

Zei33 commented Sep 30, 2020

Love the extension, it works so well.
How can I disable the automatic bracket/quote closing functionality?

When I type ( or ", I'd rather it didn't add ) or " after.

Can't seem to find where that code is.

Thanks for all your efforts.

@LeaVerou
Copy link
Member

In all languages or a specific one?

@AgentEnder
Copy link
Contributor

Lea, what do you think about this approach for allowing the behavior to be toggled off? https://github.com/AgentEnder/live/tree/feat/allow-disabling-of-pairs

@Zei33
Copy link
Author

Zei33 commented Sep 30, 2020

@LeaVerou In my case I just need to disable it completely on a specific textarea. I'm adding prism <pre><code> blocks inside the textarea and as I type the code, it's matching the pairs which is functionality I'd like to avoid as a personal choice.
@AgentEnder ah I see where the code is now. I didn't know the term used was "pairs". I can edit the code in my project manually now.
Still, I think it would be useful to add the functionality to toggle it to the main release.

Thanks for the help!

@AgentEnder
Copy link
Contributor

AgentEnder commented Oct 1, 2020

@LeaVerou if you don't think the data-plMatchPairs attribute is appropriate, this could also be a flag set on the global Prism.Live config option. Something such as Prism.Live.matchPairs = true by default, and then a user could override it by setting the variable to false in a script file.

If its ok with you, I'll open a PR with my current impl. and we can continue the discussion on it.
master...agentender:feat/allow-disabling-of-pairs

@LeaVerou
Copy link
Member

LeaVerou commented Oct 1, 2020

Would running this work for you or are you looking for an HTML-based way?

Prism.Live.pairs = {};

@Zei33
Copy link
Author

Zei33 commented Oct 1, 2020

@LeaVerou I think that should work. I can't speak for others but I'm only using one textarea so it's fine in my case.

@LeaVerou
Copy link
Member

LeaVerou commented Oct 1, 2020

Oh I see, @AgentEnder wants to disable on a specific textarea. That won't work then, it needs to be an attribute.

The currently proposed design violates several HTML design principles, but the general idea is sound.

I'd suggest a data-pl-pairs attribute, that takes a comma separated list of pairs (e.g. data-pairs="( ), [ ]"). An empty value or the keyword "none"` would mean no pairs.

@AgentEnder
Copy link
Contributor

Gotcha @LeaVerou . I'll update the branch and open a PR

@AgentEnder
Copy link
Contributor

@LeaVerou any updates on this one?

@LeaVerou
Copy link
Member

LeaVerou commented Sep 1, 2021

I wonder if the reason you are asking to disable it is because it doesn't work so well in some cases. If so, perhaps we should focus on fixing it for those cases? Just a thought.

@AgentEnder
Copy link
Contributor

Honestly, at this point I've not used prism in about a year, let alone prism live. Nothing against the either library as I love them both, I've just not had a recent need. Unfortunately, this means I don't really remember the pain point I had encountered.

I don't care to close out that PR, if others are not running into similar pain points.

@Zei33
Copy link
Author

Zei33 commented Sep 2, 2021

The reason I was hoping for the feature was because I was writing a blog about programming so the automatic closing was just inconvenient. I still think it would be a good option to have, and I'll certainly be using the library again in the future. Currently I'm not using it either so I have no immediate need for the change.

@bricebou
Copy link

bricebou commented Apr 3, 2022

Hi,

Any update on this issue and the proposed PR ?
I've included PrismLive inside a plugin for SPIP CMS and had to modify the script to add the ability to configure which pairs to be enabled. It would be great if we can simply pass options to the PrismLive instance.

Thanks !

@LeaVerou
Copy link
Member

I'd love to merge a PR on this, and to work with someone to implement this functionality with a good API. I don't have time to implement it myself currently. The linked PR is closed, but I just commented if the OP wants to pick this back up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants