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
Revisions don't render code fields. Drafts do #12
Comments
So this was pretty interesting... when displaying revisions, the field's /**
* @inheritdoc
*/
public function getStaticHtml(mixed $value, ElementInterface $element): string
{
// Just return the input HTML with disabled inputs by default
Craft::$app->getView()->startJsBuffer();
$inputHtml = $this->getInputHtml($value, $element);
$inputHtml = preg_replace('/<(?:input|textarea|select)\s[^>]*/i', '$0 disabled', $inputHtml);
Craft::$app->getView()->clearJsBuffer();
return $inputHtml;
} ...which explicitly removes any queue'd JavaScript from rendering, which then causes the Monaco editor to not be instantiated, so the formatting is never applied. Instead, we now implement our own Addressed in: cbae501 & cdcfda0 Craft CMS 3: You can try it now by setting your semver in your "nystudio107/craft-code-field": "dev-develop-v3 as 3.0.11”, Then do a ….. Craft CMS 4: You can try it now by setting your semver in your "nystudio107/craft-code-field": "dev-develop-v4 as 4.0.11”, Then do a |
Thanks for a quick fix, and glad it was "interesting" at least. |
How many you doing? |
I’m following the pattern of Month+Day so today is 10+6. It’s a good challenge! |
ooooh sweet! You should carry the torch for me, and finish the entire year out! 💪 |
Describe the bug
When I look at a previous revision of a page that contains a code field, it just shows as a text area. Really a low priority, but wanted to report for clarity. Thanks!
To reproduce
Expected behaviour
The code field would display as code with formatting, instead of a text block. Drafts seem to function just fine
Screenshots
If applicable, add screenshots to help explain your problem.
Current revision:
Previous Revision:
Draft:
Versions
The text was updated successfully, but these errors were encountered: