With 2.3.0 the Custom HTML block is not working at all.
Attempting to insert the block produces "This block has encountered an error and cannot be previewed."
Custom HTML block appears
Uncaught TypeError: Cannot read property 'initialize' of undefined
The above error occurred in the <t> component:
Uncaught TypeError: Cannot read property 'on' of undefined
TypeError: wp.codeEditor is undefined
The above error occurred in the <t> component:
TypeError: this.editor is undefined
Are you missing the code mirror script like #5381 Do you have any particular plugin or code disabling this script?
What if you go to /wp-admin/plugin-editor.php does the code mirror editor work there?
What if you go to /wp-admin/plugin-editor.php...?
I fall directly in the classic WordPress Code Editor, with gutenberg.php in the edit window.
Is that what you want to know?
no, or try to go to "Appearance -> Editor" for instance, do you see the theme editor?
Yeah sure, I can go there, and with syntax highligting working OK.
Thanks for confirming, might have something to do with the way we load code mirror in Gutenberg or something but it's hard to fix if we can't reproduce :)
Thanks for verifying!
I downloaded my site from the AIX server lock stock and barrel, imported the database and started running it locally. Everything is just the same except when I try to load the custom HTML block.
I'm comparing the generated HTML for the page. There are unexpected differences.
OK, I have an explanation.
My local installs are sub-directory installs. e.g. qw/src, qw/hm, qw/wordpress etc
When I downloaded the working version from cwiccer.com I installed it in qw/cwiccer
So I was able to reproduce the problem.
I eventually realised that the requests to load the codemirror scripts and styles
were going to the parent directory ( qw )
/wp-admin/load-scripts.php?load=wp-codemirror,code-editor,htmlhint,csslint,jshint
/wp-admin/load-styles.php?load=wp-codemirror,code-editor
which was running WordPress 4.8.5, so did not have wp-codemirror.
Updating the installation at qw and reloading the cached requests resolved the problem.
Change https://github.com/WordPress/gutenberg/blob/master/components/code-editor/index.js
possibly using
var ajaxurl = '/cwiccer/wp-admin/admin-ajax.php',
to determine the URL
Found the same discrepancy yesterday.
On localhost, we have a virtual host "localweb" with one WP installation in project-3:
In the WP Settings/General panel, we have:
WordPress Address (URL) set to http://localweb/project-3
Site Address (URL) set to http://localweb/project-3
The erroneous call to load the code mirror script (and other modules) is:
http://localweb/wp-admin/load-scripts.php?load=wp-codemirror,code-editor,htmlhint,csslint,jshint
...erroneous as there is no WP installation under "localweb".
It should be:
http://localweb/project-3/wp-admin/load-scripts.php?load=wp-codemirror,code-editor,htmlhint, csslint,jshint
The problem is similar when hosted on a distant server, with WP installed in a subdomain called "dbl":
WordPress Address (URL) set to https://www.domain-name.com/dbl
Site Address (URL) set to https://www.domain-name.com
The erroneous call:
https://www.domain-name.com/wp-admin/load-scripts.php?load=wp-codemirror,code-editor,htmlhint,csslint,jshint
Should be:
https://www.domain-name.com/dbl/wp-admin/load-scripts.php?load=wp-codemirror,code-editor,htmlhint,csslint,jshint
The code found in gutenberg/components/code-editor/index.js appears indeed related to this problem as it also correlates the first screenshot provided in issue #5381.
Is this not in a project or milestone yet? The HTML block is pretty primal in our usage, would greatly appreciate if it was fixed soon :)
To clarify/summarise this issue:
Right now we na茂vely load the Code Mirror assets by requesting /wp-admin/load-scripts.php. This absolute path, however, will not work when WordPress is served from a subdirectory, e.g. example.com/blog/.
We have a proxy setup where
newsroom.guidevine.comguidevine.com/newsroomnewsroom.guidevine.comJust an FYI as a consideration
--
This does cause all sorts of other problems but it seems to be in a core merge proposal already
Most helpful comment
To clarify/summarise this issue:
Right now we na茂vely load the Code Mirror assets by requesting
/wp-admin/load-scripts.php. This absolute path, however, will not work when WordPress is served from a subdirectory, e.g.example.com/blog/.