Giter VIP home page Giter VIP logo

apostrophe-editor-2's Introduction

THIS MODULE IS FOR 0.5.X ONLY, DEPRECATED FOR ALL NEW PROJECTS

You do not need this module for your new Apostrophe project and it will not work with it. See the apostrophe documentation for more information about Apostrophe 2.x.

apostrophe-editor-2

apostrophe-editor-2 is the standard editor for projects built with Apostrophe 0.5.x, an OLD version of Apostrophe.

To switch it on for an existing 0.5.x project (which would be REALLY, REALLY old at this point if it doesn't already use it), just include this module and the apostrophe-ui-2 module in your apostrophe-site configuration in app.js:

// Must be first
'apostrophe-ui-2': { },
... other modules ...
'apostrophe-editor-2': { },
... other modules ...

apostrophe-editor-2 is built on ckeditor, a widely recognized open source rich text editing solution with a history of thorough debugging across browsers and platforms.

apostrophe-editor-2 also allows users to add Apostrophe's widgets to an area.

You can use apostrophe-editor-2 as a drop-in replacement for the built-in editor. You can also specify CKEditor-specific menu items in your controls option.

Float Content Sanely With Lockups

apostrophe-editor-2 supports lockups. A lockup is a marriage between one rich text item and one widget, such as a slideshow.

Users begin by adding text blocks and widgets to the area. Then, they may drag any widget via its handle and drop it on a text block. This locks the two together.

However, we believe strongly in preserving your design intentions. So if you do not configure any lockups for a particular aposArea call, then the user is not permitted to drop widgets on text.

Lockups must be configured at the project level, typically in app.js, but you decide which lockups to enable by name when inserting each area.

Here's how you define lockups:

... more apostrophe-site configuration ...
lockups: {
  left: {
    label: 'Left',
    icon: 'icon-arrow-left',
    tooltip: 'Float Left',
    // Only allows one type of widget
    widgets: [ 'slideshow' ],
    // Override the options for slideshows when they are inside the lockup to get the size right
    slideshow: {
      size: 'one-third'
    }
  },
  right: {
    label: 'Right',
    icon: 'icon-arrow-right',
    tooltip: 'Float Right',
    // Allows two types of widget
    widgets: [ 'slideshow', 'video' ],
    slideshow: {
      size: 'one-half'
    },
    video: {
      size: 'one-half'
    }
  }
},

And here's how you permit them in a particular area:

{{
    aposArea(page, 'content2', {
      controls: ['style', 'bold', 'italic', 'slideshow' ],
      lockups: [ 'left', 'right' ] })
}}

Again, if you do not enable lockups explicitly for each area, they are not permitted.

Configuring lockups for areas in the schema of a snippet subclass works as you'd expect: just set the lockups option as you would when calling aposArea.

"But how do I get it to float?" Apostrophe guarantees that the widget and the text it's been locked to will be wrapped in a div with the apostrophe-lockup class, and also a CSS class with the same name as the lockup. So if your lockup is named left, you can count on the classes apostrophe-lockup and left existing on that div. From there you should have no trouble targeting the widget, for instance:

.apostrophe-lockup.left .apos-widget {
  float: left;
  width: 300px;
}

Actually floating and sizing things is up to you and your CSS, but lockups help you by always nesting the widget to be floated as a direct child of a div with the apostrophe-lockup class.

Adding tags with custom attributes to the Styles menu

You can pass custom attributes (like classes) to tags in the Styles menu of CKEditor by adding the element to the styles array of an area:

{{
    aposArea(page, 'content', {
      styles: [ 
        { value: 'h5', label: 'Heading 5' },
        { value: 'div', label: 'Centered', attributes: {class: 'centered' } }
      ] 
  })
}}

After which you must make the proper exception in apostrophe-site's SanitizeHtml in app.js (add it if you don't have it)

var site = require('apostrophe-site')({
  sanitizeHtml: {
    allowedAttributes: {
        a: [ 'href', 'name', 'target' ],
        img: [ 'src' ],
        div: [ 'class' ]
    },
  },
})

Text-Only "Areas"

apostrophe-editor-2 allows for text-only areas. Just specify textOnly: true among the options you pass to aposArea. When you do so, there will always be just one text block, and there will be no controls to drag, reorder or delete it.

(TODO: make it possible to call aposSingleton with a type of richText. For now, use the textOnly option.)

Areas with No Text

You can also have an area that does not allow rich text items at all. To request this, specify richText: false among the options you pass to aposArea. Only widgets, such as slideshows, will be offered on the "Add Content" menu.

Splitting a Text

Sometimes your users may want to add a slideshow or video in the middle of a text. To make this easier, we've added an optional split control. If you include this control in the controls array, users are able to split a text item in half at the current cursor position. This opens up the possibilty of moving a widget into place between the two text items.

CKEditor Plugins

You can load extra CKEditor plugins into CKEditor in app.js, when you configure the apostrophe-editor-2 module:

'apostrophe-editor-2': {
  plugins: [
    { name: 'headline', path: '/editor/plugins/headline/' }
  ]
}

Or, if you only want them for certain areas, with aposArea() via the plugins option:

{{
    aposArea(page, 'content', {
      plugins: [
        { name: 'headline', path: '/editor/plugins/headline/' }
      ]
    })
}}

This will instruct CKEditor to load the file /public/editor/plugins/headline/plugin.js.

Extra ckeditor configuration

You can add custom properties to the config object passed when instantiating ckeditor by setting the config option of the module. This option is merged with the config object that apostrophe-editor-2 builds. For example, let's configure the justify plugin to use classes rather than style attributes:

'apostrophe-editor-2': {
  config: {
    justifyClasses: [ 'apos-align-left', 'apos-align-center', 'apos-align-right', 'apos-align-justify' ]
  }
},

apostrophe-editor-2's People

Contributors

benirose avatar etodanik avatar jsumnersmith avatar mordred avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

mordred

apostrophe-editor-2's Issues

Error - node_modules/moog/index.js:317 if (key.substr(0, 2) === '__') {

When I add 'apostrophe-editor-2': { } into my app.js after 'apostrophe-ui-2': { } I get this error.

Any ideas?

node app.js
WARNING: No session secret provided, please set the `secret` property of the `session` property of the apostrophe-express module in app.js
WARNING: no versions of the script editor exist, but you are pushing that asset in the apostrophe-global module.
WARNING: no versions of the stylesheet user exist, but you are pushing that asset in the apostrophe-global module.
/node_modules/moog/index.js:317
          if (key.substr(0, 2) === '__') {
                  ^

TypeError: key.substr is not a function
    node_modules/moog/index.js:317:19
    at Function.forEach (node_modules/moog/node_modules/lodash/dist/lodash.js:3298:15)
    at applyOptions (node_modules/moog/index.js:313:11)
node_modules/moog/index.js:230:15
    at iterate (node_modules/moog/node_modules/async/lib/async.js:146:13)
    at Immediate.<anonymous> (node_modules/moog/node_modules/async/lib/async.js:157:25)
    at runCallback (timers.js:666:20)
    at tryOnImmediate (timers.js:639:5)
    at processImmediate [as _immediateCallback] (timers.js:611:5)
[9]+  Killed: 9               node app.js

My app.js looks:

var apos = require('apostrophe')({
  shortName: 'xxx',
  title: 'xxx',

  // These are the modules we want to bring into the project.
  modules: {
    // This configures the apostrophe-users module to add an admin-level
    // group by default
    'apostrophe-users': {
      groups: [
        {
          title: 'guest',
          permissions: [ ]
        },
        {
          title: 'admin',
          permissions: [ 'admin' ]
        }
      ]
    },
    // This configures the apostrophe-assets module to push a 'site.less'
    // stylesheet by default
    'apostrophe-assets': {
      stylesheets: [
          {
            name: 'site'
          },
          {
            name: 'bootstrap'
          }

      ]
    },
    // Add your modules and their respective configuration here!

      'apostrophe-ui-2': { },
      'apostrophe-editor-2': { }

}

});

Thanks!

Too many page versions

Right now we save a version of the entire page every 5 seconds if any changes have been made. This can lead to a very large database.

We can address it by pruning out consecutive versions by the same author less than X minutes apart, once they are Y hours old.

We need to stop storing diffs and start generating them dynamically in order for the removal of intervening versions to still result in reasonable-looking diffs.

Styles not being saved?

I have the following area set up:

{{ aposArea(page, 'header2', {
                    textOnly: true,
                    controls: [ 'style', 'bold', 'italic' ],
                    styles: [
                      { element: 'h2', label: 'Heading 2' },
                      { element: 'h3', label: 'Heading 3' }
                    ]
                  }) }}

I select the "h2" style, and it looks correct. Once I save and go back to that page - I no longer see the "h2" element, but a "p" element encompassing my content.

Do we have options to set limits on widgets?

If I want my editors to be able to add event widgets (for example) to an area but only want to allow ONE item per widget, can I define the limit of that widget programmatically as opposed to letting the user choose?

When adding widgets to an area, seem to nest inside each other

Often when adding a widget to an area, it will add a duplicates of itself into other widgets in the same area.

To reproduce:

  1. create an area with multiple widget/item types available (mine had events, map, and rich text)
  2. add an events widget with 1 item in it
  3. add a map widget with 1 item in it
  4. add another events widget with 1 item of it

You should see a duplicate of this second events widget appear nested inside of the map widget. If not, keep adding widgets. It will happen eventually, I swear!

Editor stripping iframes

I imported a bunch of blog posts from Wordpress that have iframe embeds in them (for videos). They appear fine in apostrophe, but when i click on the editor, they all get stripped away. I set

sanitizeHtml: {
    allowedAttributes: false,
    allowedTags: false,
  },

in app.js and also set allowedContent: true like this:

'apostrophe-editor-2': {
      plugins: [
        { name: 'autocorrect', path: '/editor/plugins/autocorrect/' }
      ],
      config: {
        allowedContent: true
      }
    }

But nothing is working. Am I right in thinking that this is a CKEditor issue?

Can't include CKeditor plugin

Hi!
I can't include plugin for CKeditor.

I have next settings:

'apostrophe-editor-2': {
    plugins: [
            { name: 'panelbutton', path: '/editor/plugins/panelbutton/' },
            { name: 'colorbutton', path: '/editor/plugins/colorbutton/' }
        ]
    },

plugins folders is placed in public directory 'public/editor/plugins/.....'

in aposArea next options

{{ aposArea(page, 'advt1', {controls: ['colorbutton']}) }}

but without results.

Help me please to decide this problem

Thanks!

Add Content button should appear on bottom of area aswell

Hey guys

I'm fiddling around with apostrophe now, and I found a pretty annoying thing:
The "Add content" button is just at the top of an area (let's say a new blog post). While this is not an issue, the problem with inserting new content is that it gets inserted at the top. So while I'm writing a new blogpost, every new image or every new text element that I insert, has to be moved to the bottom.

IMO it would be more useful to the user to either:
Add Content button at the bottom, which inserts the content at the bottom
or
Add content at the bottom by default

I made a screenshot with the demo.apostrophenow.org page :-)

https://dl.dropboxusercontent.com/spa/agn3r6rkwi4rxn7/my31q67q.png

Would that be possible?
Cheers
Chris

Controls go away and do not come back

  1. Create two text blocks (two separate items added with "add content")
  2. Switch back to editing the first one
  3. The controls for the second rich text item are gone. Not just the ckeditor controls (which makes sense) but the editor-2 controls. They fail to come back when the ckeditor controls are hidden.

Need a friendlier UI for rolling back changes at the area level

You can undo any change via Page Versions, but this is not the friendliest way to bring back that widget you just removed.

We could override the undo/redo keys, in which case we're taking over responsibility for that from ckeditor, which normally does a fine job, but only for the current text editor, not for widgets.

Or we could provide a separate undo/redo mechanism which would leverage the page version history and thus be able to undo widget deletes and the like.

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.