draft-js-markdown-plugin icon indicating copy to clipboard operation
draft-js-markdown-plugin copied to clipboard

Can not select all content in code-block if disabling `renderLanguageSelect`

Open andrewfan opened this issue 7 years ago • 9 comments

I tried to get rid of language select and set renderLanguageSelect in config as the function that returns ''. Now I dont see the language select but code became not selectable.

@mxstbr the same happens in the spectrum app https://www.dropbox.com/s/hfagg1nr6sgakhs/Screenshot%202018-05-21%2015.44.36.png?dl=0 (try to start a code block and press cmd+a) Maybe we should make custom code component optional? Because now even if renderLanguageSelect return empty, content is still wrapped in CodeSwitchContainer https://github.com/withspectrum/draft-js-markdown-plugin/blob/master/src/components/Code/index.js#L11

andrewfan avatar May 21 '18 12:05 andrewfan

I think the right solution to this issue would have to allow content to be wrapped in CodeSwitchContainer, but still work as expected. It shouldn't happen that specifying renderLanguageSelect breaks the plugin, which would be the case with your suggestion.

Maybe the issue here is that the SwitchContainer is a PureComponent? Let's try changing that to a normal Component and seeing if that fixes it.

mxstbr avatar May 22 '18 08:05 mxstbr

Actually, I can't replicate this in the draft-js-markdown-plugin demo. I changed the renderLanguageSelect to () => '', but I can still select the code perfectly fine?

Note how there's no language select

mxstbr avatar May 22 '18 08:05 mxstbr

Actually, I can replicate this but only if I have a language select that doesn't have a language selected:

Is that the same bug?a

mxstbr avatar May 22 '18 08:05 mxstbr

@mxstbr the issue happens when renderLanguageSelect is 'disabled' and code-block is the last block http://lush-stamp.surge.sh/

andrewfan avatar May 22 '18 08:05 andrewfan

Even that demo works perfectly fine for me:

mxstbr avatar May 22 '18 08:05 mxstbr

@mxstbr sorry for misunderstanding, I'm using cmd+a hotkey when my cursor is in code-block

andrewfan avatar May 22 '18 13:05 andrewfan

Same, I am too in that gif above!

mxstbr avatar May 22 '18 13:05 mxstbr

@mxstbr this is what i see

andrewfan avatar May 22 '18 14:05 andrewfan

It turns out, I'm not so smart—it does the exact thing you're saying in Chrome, but not in Firefox! I think this is related to https://github.com/withspectrum/spectrum/issues/2897

mxstbr avatar May 23 '18 13:05 mxstbr