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 text transformations inside code blocks #5862

Closed
pomek opened this issue Nov 28, 2019 · 7 comments · Fixed by ckeditor/ckeditor5-typing#222, ckeditor/ckeditor5-core#208 or ckeditor/ckeditor5-widget#116
Assignees
Labels
package:code-block type:bug This issue reports a buggy (incorrect) behavior.

Comments

@pomek
Copy link
Member

pomek commented Nov 28, 2019

📝 Provide detailed reproduction steps (if any)

  1. Open code block manual test and replace ClassicEditor.create() with:
import TextTransformation from '@ckeditor/ckeditor5-typing/src/texttransformation';

ClassicEditor
	.create( document.querySelector( '#editor' ), {
		plugins: [ Code, CodeBlock, Autoformat, Indent, ArticlePluginSet, TextTransformation ],
  1. yarn run manual -f code-block
  2. In code block, type 1/2

✔️ Expected result

1/2 should stay as 1/2.

❌ Actual result

1/2 is replaced with ½

📃 Other details

  • Browser: FF
  • OS: Mojave 10.14.6
  • CKEditor version: master

If you'd like to see this fixed sooner, add a 👍 reaction to this post.

@pomek pomek added the type:bug This issue reports a buggy (incorrect) behavior. label Nov 28, 2019
@Reinmar Reinmar added this to the iteration 29 milestone Nov 28, 2019
@Reinmar
Copy link
Member

Reinmar commented Dec 2, 2019

TODO: Does it apply to inline code too?

TODO: How was it fixed in inline code + autoformat case?

@Reinmar
Copy link
Member

Reinmar commented Dec 20, 2019

I've checked the TextTransformation's code and I think that we need to be able to either disable some sort of command (which doesn't exist at the moment) or the whole plugin (which isn't "disableable" yet). 

I'd go with the command, if it's possible to introduce here a reasonable command. By "reasonable" I mean a command which API will make sense.

If that's impossible, we should allow disabling the whole plugin. And this can be made the same way as in ckeditor/ckeditor5-widget#113 – by introducing isEnabled to the plugin itself. But then we'll have 3 repetitions of the same code, so the first step would be to extract that to a mixin that we'd mix into the Command, WidgetToolbarRepository and TextTransformations plugins.

@Reinmar Reinmar assigned Reinmar and panr and unassigned Reinmar Dec 20, 2019
@oleq
Copy link
Member

oleq commented Jan 16, 2020

I'm against a command in this case.

ATM the plugin's init() registers a watcher that interacts with the model. The command would need to enable this watcher when executed (?) and disable it when... yeah, that's a good question.

Besides, execution of any command is, in terms of a state machine, a transition between state A and state B. This text transformation command (that brings a watcher) would impact all editor states from some point until it gets disabled. IMO it violates the "paradigm of commands" as we know it.

I'm for another solution with disabling the plugin. It can have methods TextTransformation#enable and TextTransformation#disable or an observable property TextTransformation#isEnabled.

@Reinmar
Copy link
Member

Reinmar commented Jan 16, 2020

I'm fine with no command. As I said – I'd only go this way if we'd consider it clean.

We recently introduced plugin disabling in one of the plugins: ckeditor/ckeditor5-widget#113. It's a copy-paste from the command API because we didn't know how soon we'll need this in another plugin. I think I'm fine with moving this to core now so the API is available for all plugins.

@panr
Copy link
Contributor

panr commented Jan 16, 2020

OK, I'll do it that way.

@panr
Copy link
Contributor

panr commented Jan 20, 2020

I raised few PRs for the text transformation typing issue, but probably there will be another ticket for handling conversion to code block from for example paragraph with transformed text inside, like:

CKEditor © 2020

© should transform to (c), right?

@aspirin01
Copy link

aspirin01 commented Jun 2, 2023

After a lot of struggle and search,
this is the only solution I came up with


config={{
    typing: {
      transformations: {
        remove: ['symbols', 'quotes', 'arrowLeft', 'arrowRight','mathematical','typography'],
        
      },
    },
}
}

Modify your config in ckeditor component like above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment