TinyMCE re-writing http citations
Permalink 3 users found helpful
It is a common style guide to cite references to web pages as (note the right-angled brackets)
The content block of Concrete5 tries to remove or rewrite these references on re-editing a content block.
Safari 5.1.2 and Chrome(latest) will not be able to re-save a block containing these references. Firefox 7.0.1 and IE 8 drop these references, thus 'losing' import components of a document.
To reproduce this issue I do the following:
Create a blank new page in C5, then add a content block.
In the TinyMCE editor I type and add that to the page.
Publish the page.
Check the published page source and the block contains as expected.
Now if try to I edit that page and edit the block in Safari or Chrome. The text is no longer visible and the block cannot be saved via the editor.
If I try to edit that block in Firefox or IE then the is removed and replaced with a non breaking space.
Any suggestions or work arounds would be greatly appreciated.
Thanks, Marcus.
<http://www.reference.com/>
The content block of Concrete5 tries to remove or rewrite these references on re-editing a content block.
Safari 5.1.2 and Chrome(latest) will not be able to re-save a block containing these references. Firefox 7.0.1 and IE 8 drop these references, thus 'losing' import components of a document.
To reproduce this issue I do the following:
Create a blank new page in C5, then add a content block.
In the TinyMCE editor I type
<http://test.com>
Publish the page.
Check the published page source and the block contains
<p><http://test.com></p>
Now if try to I edit that page and edit the block in Safari or Chrome. The text is no longer visible and the block cannot be saved via the editor.
If I try to edit that block in Firefox or IE then the
<http://test.com>
Any suggestions or work arounds would be greatly appreciated.
Thanks, Marcus.
I think the issue is that mrowell wants to show a citation, not an actual link, but that editing the escapes for left and right angle turns them back into left and right angles, and hence they keep on getting translated back into tags. So the solution would be to stop it from getting translated into links.
It is something I have suffered, but not happily solved. As far as I know, this is unfortunately a quirk of the HTML text area, so much deeper embedded in the web than TinyMCE.
There are some 'bodges', but not solutions.
- Look for unicode extended characters that look like < and > and use them instead.
- Put all the citations in a separate block. That way at least the main text can be edited without needing to re enter all the escape sequences.
It is something I have suffered, but not happily solved. As far as I know, this is unfortunately a quirk of the HTML text area, so much deeper embedded in the web than TinyMCE.
There are some 'bodges', but not solutions.
- Look for unicode extended characters that look like < and > and use them instead.
- Put all the citations in a separate block. That way at least the main text can be edited without needing to re enter all the escape sequences.
Steev & JohntheFish,
Thanks for your suggestions.
As JohntheFish mentioned we are not wanting the text to be a link, and instead want the right-angle brackets to remain as they are and the url to be a plain text citation.
Great idea at using some other unicode characters. There are a few that might do the trick. I'll need do some cross browser testing and report back here.
Thanks, Marcus.
Thanks for your suggestions.
As JohntheFish mentioned we are not wanting the text to be a link, and instead want the right-angle brackets to remain as they are and the url to be a plain text citation.
Great idea at using some other unicode characters. There are a few that might do the trick. I'll need do some cross browser testing and report back here.
Thanks, Marcus.
Sorry, I misunderstood?
You could use 'pre' tag in an HTML block?
You could use 'pre' tag in an HTML block?
We got some help on this issue.
We have resolved it as follows:
1) /concrete/blocks/content/edit.php
Wrapped the $controller->getContentEditMode() with the htmlspecialchars function.
It basically forces the tags that tinyMCE would have rewritten into their html/ascii equivalent.
2) /concrete/blocks/content/editor_config.php
I added entity_encoding:"raw", into the tinyMCE.init function which forces tinyMCE to be a bit less harsh with its cleanup. (I haven't tested this but I think we can just add the entity_encoding:"raw" to our custom Text Editor Settings).
I hope that helps someone else.
We have resolved it as follows:
1) /concrete/blocks/content/edit.php
Wrapped the $controller->getContentEditMode() with the htmlspecialchars function.
It basically forces the tags that tinyMCE would have rewritten into their html/ascii equivalent.
<?php defined('C5_EXECUTE') or die("Access Denied."); //$replaceOnUnload = 1; $bt->inc('editor_init.php'); ?> <div style="text-align: center" id="ccm-editor-pane"> <textarea id="ccm-content-<?php echo $b->getBlockID()?>-<?php echo $a->getAreaID()?>" class="advancedEditor ccm-advanced-editor" name="content"><?php echo htmlspecialchars($controller->getContentEditMode()); ?></textarea> </div>
2) /concrete/blocks/content/editor_config.php
I added entity_encoding:"raw", into the tinyMCE.init function which forces tinyMCE to be a bit less harsh with its cleanup. (I haven't tested this but I think we can just add the entity_encoding:"raw" to our custom Text Editor Settings).
I hope that helps someone else.
That did the trick. HUGE help, thx!
We tweaked the changes a bit more as that config was rewriting a few to many things.
Now the only change to default config is
/concrete/blocks/content/edit.php
Now the only change to default config is
/concrete/blocks/content/edit.php
<?php defined('C5_EXECUTE') or die("Access Denied."); //$replaceOnUnload = 1; $bt->inc('editor_init.php'); ?> <div style="text-align: center" id="ccm-editor-pane"> <textarea id="ccm-content-<?php echo $b->getBlockID()?>-<?php echo $a->getAreaID()?>" class="advancedEditor ccm-advanced-editor" name="content"><?php echo htmlspecialchars($controller->getContentEditMode(),ENT_NOQUOTES , 'UTF-8', true); ?></textarea> </div>
Then either use 'Insert link to page' for site linking or chain icon for other links.
Does that help?
Steev