Code Monkey home page Code Monkey logo

Comments (5)

chronofish avatar chronofish commented on August 19, 2024 1

YES! Thank you! that was a super easy fix!

from contenttools.

anthonyjb avatar anthonyjb commented on August 19, 2024

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.

chronofish avatar chronofish commented on August 19, 2024

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.

chronofish avatar chronofish commented on August 19, 2024

Also - thanks for the impressively fast response!

from contenttools.

anthonyjb avatar anthonyjb commented on August 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.