Comments (11)
Ahh - it should strip HTML commends before attempting to parse inner HTML but perhaps it's failing if there's nothing in the comment - this is an issue with HTMLString. I'll resolve ASAP, thanks for highlighting.
from contenttools.
Even if there's content in it, it's still failing :)
from contenttools.
Hmmm... that's odd - I don't think there's a test spec for this so will add one at the same time.
from contenttools.
OK that now correctly removes comments before parsing (my RegExp was incorrect). There's now comments in the test spec data.
Only down side is any comments you add will be removed as soon as the element containing them is edited and saved, I hadn't considered supporting comments within the editable regions up to this point and I'm not entirely sure how they would be catered for when a user edits the content - but happy to consider arguments for supporting them :)
from contenttools.
The reason I'm actually using comments is that I needed to add some sort of hidden marker inside the html. So for if I generate <!--marker1--> ...unknown html... <!--/marker1-->
, I can get the insides of those comments when saving and process them in a different way.
from contenttools.
Can you place those markers outside of the editable regions? For example:
<!--marker1--><div data-editable="marker1">
<p>
Here goes my editable content...
</p>
</div><!--/marker1-->
I actually do something very similar with Jinja2 templates for the getcontenttools.com
website.
from contenttools.
If they need to be inside of the editable element one option would be to consider using a span tag:
<div data-editable="my-region">
<p>
Here <span class="marker1">goes my editable content...</span>
</p>
</div>
It should still be relatively easy to extract this content safely.
from contenttools.
Right now as an alternative I'm wrapping the content inside a div with a data-ce-tag="static"
, although the thing is I don't know what will be inside that so I might be messing up the content by adding a div. The best thing I thought was to add starting & ending comment tags so I can keep track of them. They need to be inside the editable content though.
from contenttools.
Ah OK that makes a lot of sense - if you use a static
element then the content inside wont be parsed by the editor, however one thing to be aware of is since the library basically relies on the browsers innerHTML
output for static elements it might come back a little bit different once saved and across different browsers - but it should still be valid HTML of course.
from contenttools.
So will comments not be stripped out anymore? :)
from contenttools.
So if you use comments in static elements they shouldn't be stripped - they certainly aren't in Chrome - however as I say it does depend on the innerHTML
output of each browser.
from contenttools.
Related Issues (20)
- Save issue - saves fine, but won't allow a second "save" HOT 5
- Making CT compatible with CSP style-src set to 'self'
- Can't edit files that were included or read by php HOT 17
- Edit multiple paragraphs at once. HOT 2
- Is there a way to change the default tag output for normal html tags HOT 2
- Missing translation in /src/scripts/ui/dialogs/table.coffee
- Problem update image classes HOT 5
- Build files to use dynamic import in pure javascript HOT 1
- How to use assign ? HOT 2
- Hot to keep style attributes on save.
- Support for Sass >= 1.33 HOT 11
- npm install failed HOT 2
- Feature: Support drag & drop of images
- The image uploader HOT 2
- Inspector bar doesn't show embedded HTML elements when wrapped with paragraph HOT 1
- Line breaks not saving
- Add class to a link
- Lazy loading of images
- Source code edit? Insert <script> tag HOT 3
- The part in italics is not the right one HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from contenttools.