Comments (5)
YES! Thank you! that was a super easy fix!
from contenttools.
Hi @chronofish can you post enough of your JS and HTML somewhere I can have a look, clearly something is going wrong the first time save is called (you don't need to return anything) but I can't see what from the information you've provided. The error the second time around is likely due to the editor not being put into the right state after the first save and some element being missing.
from contenttools.
Relevant HTML
Save button
<div class='col mt-auto text-right'>
<i class="fas fa-save " id='saveButton'></i>
</div>
Editable section
<section
class="[ part_content ] [ formatted ] m-0 p-0"
data-editable
data-name="part_content"
>
<!-- editable part_content -->
<h2>Place cursor and start editing!</h2>
<p>
You can use the floating toolbar to edit this document - just be sure to hit the save button before you're done!
</p>
<p>
More fund stuff
</p>
<!-- endeditable part_content -->
</section>
javascript (file called contentTools.js)
// ContentTools
import ContentTools from'ContentTools/build/content-tools.min.js';
window.addEventListener('load', function() {
var editor;
ContentTools.StylePalette.add([
new ContentTools.Style('Author', 'author', ['p'])
]);
editor = ContentTools.EditorApp.get();
editor.init('*[data-editable]', 'data-name', '', false);
editor.addEventListener('saved', async function (ev) {
var name, payload, regions, xhr, template;
return true;
});
var sb = document.getElementById('saveButton');
sb.onclick = function() {
editor.save();
}
editor.start();
});
from contenttools.
Also - thanks for the impressively fast response!
from contenttools.
Ah OK so you have a custom save button - no worries but this explains why the editors state is getting out of wack.
So if your save button is passive (as in you want the button to save the document but not exit the editing mode) then when you call save flag that you want this to be a passive save save(true)
.
However, if you want the save button to save the changes and exit edit mode then you need to stop the editor, something like:
editor.ignition().state('ready')
editor.stop(true)
Let me know if that helps out.
from contenttools.
Related Issues (20)
- 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.