Code Monkey home page Code Monkey logo

Comments (1)

anthonyjb avatar anthonyjb commented on August 18, 2024

You can certainly support multiple editable areas or regions (and I do so on a number of sites). Typically the way I tend to approach this is something like:

<ul>
    <li class="post">
        <div class="post__body" data-editable="1">
            <p>...</p>
        </div>
    </li>
    <li class="post">
        <div class="post__body" data-editable="2">
            <p>...</p> 
        </div>
    </li>
</ul>

Then for the save init/save code:

var editor = ContentTools.EditorApp.get();
editor.init('*[data-editable]', 'data-editable');

editor.bind('save', function (regions) {

    // The regions will be keyed against post Ids and so you can map changes in the content to the
    // individual posts.
    var payload = new FormData();
    for (var postId in regions) {
        if (regions.hasOwnProperty(name)) {
            payload.append(postId, regions[postId]);
        }
    }

});

You can of course store additional information against the region (e.g data-field-name="synopis") and access it from the HTML using document.querySelector('data-editable=' + postId).getAttribute('data-field-name'); That way you can have multiple editable regions within each post.

As for anchoring a tool bar to the top of each editable area that's not currently supported, the toolbox is anchored to the screen not the content.

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.