Giter VIP home page Giter VIP logo

ember-cli-summernote's Introduction

Ember-cli-summernote

Build Status NPM Downlaads npm version

Ember Observer Score

Description

Ember-cli-summernote is an Ember CLI add-on. This addon actually converts summernote to an Ember component which is a re-usable unit. This is still a work in progress. Pull requests are welcome.

DEMO

Installation

# install via npm
$ npm install ember-cli-summernote --save-dev
# make ember-cli fetch internal dependencies
$ ember g ember-cli-summernote

Basic Usage

Handlebar Template

As of version 1.1.0, the addon embraces DDAU. The content property is readonly and onContentChange action is used for updated contents.

import Ember from 'ember';

export default Ember.ObjectController.extend({
  contentHeight: 200,
  postContent: "Some intial contents go here. Lorem Ipsum is simply dummy text of the printing.",
  editingDisabled: false,

  actions: {
    onContentChange(text) {
      set(this, 'postContent', text);
    },

    changeHeight(someObject) {
      let height = someObject.doSomeCalculationToGetHeight();
      set(this, 'contentHeight', height)
    }
  }
});

As a result to follow DDAU, the summernote internall callback onChange will not be supported through the callbacks property in a consumming application.

{{summer-note height=contentHeight
              btnSize=bs-sm
              airMode=false
              focus=false
              header="Example"
              content=(readonly postContent)
              onContentChange=(action 'onContentChange')
              disabled=editingDisabled
              callbacks=callbackOptions
              toolbarOptions=toolbarOptions}}

Example of configuring the toolbar options.

    toolbarOptions: {
      style: false,
      insert: {
        picture: false
      },
      help: false
    }

Custom buttons usage

In hbs file

    {{summer-note content=article customButtons=customButtons}}

In controller file

    import Ember from 'ember';

    export default Ember.Controller.extend({
        article: 'some text',
        customButtons: [],

        init() {

            let _onNewBlock = this.get('onNewBlock').bind(this);

            let newBlockButton = function (context) {
                var ui = $.summernote.ui;

                var button = ui.button({
                    contents: '<i class="fa fa-file-text-o"/> New div',
                    tooltip: 'New div',
                    click: _onNewBlock
                });

                return button.render();
            }

            this.customButtons.push(newBlockButton);

        },

        onNewBlock() {
            let blocks = '<div class="header" id="headerBlock"></div>';
            this.set('article', article + blocks);
        }
    });

All callbacks except onChange are supported.

The onChange callback are used internally for the onContentChange action.

    callbackOptions: {
      onInit: function() {
        console.log('Summernote is launched');
      },
      onEnter: function() {
        console.log('Enter/Return key pressed');
      },
      onPaste: function(e) {
        console.log('Called event paste');
      },
    },

config/environment.js

The bootstrap resources will not be imported to your resources by default.

Also you can set lang option for the editor.

var ENV = {
  modulePrefix: 'dummy',
  environment: environment,
  ...
  'ember-cli-summernote': {
    "importBootstrapCSS": true,
    "importBootstrapJS": true,
    "lang": "en-US // "ru-RU" //"lang": "en-US"
  }
}

Test Helper

This addon also provides a convenient test helper to interact with the editor in acceptance tests.

fillInSummernote('.summernote-container', '<p>Test Text Entered.</p>');

getContentFromSummernote('.summernote-container');

Demo

You can clone this repo and run the app

$ sudo npm install -g ember-cli

# clone the codebase
$ git clone http://github.com/vsymguysung/ember-cli-summernote.git
$ cd ember-cli-summernote

# install dependencies
$ npm install; bower install

# fire up local server
$ ember serve

# visit the page with the following url.
http://localhost:4200

Inspired by

License

MIT license.

ember-cli-summernote's People

Contributors

brett-anderson avatar devotox avatar ember-tomster avatar gcampes avatar hchokshi avatar hxbkx avatar jevanlingen avatar odoe avatar richipargo avatar roosnic1 avatar vsymguysung avatar wzowee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ember-cli-summernote's Issues

not initialized

Hi Guys,

we are now trying to use the latest version
"summernote": "0.8.8",
"ember-cli-summernote": "1.5.2"

but we don't see the editor initialized. we only see an empty div.

did anyone else got the same? not sure what i'm not doing right.

Attempting to import font files from summernote dist directory that doesn't exist

After installing ember-cli-summernote and running the blueprint to install the bower dependencies, I am receiving an error on ember build/serve:

Error: ENOENT: no such file or directory, scandir '/project-path/tmp/funnel-input_base_path-kcgi7jIX.tmp/bower_components/summernote/dist/font/'

I noticed the addon's index.js is attempting to import the following:

app.import(path.join(summernotePath, 'font/summernote.eot'), { destDir: 'assets/font' });
app.import(path.join(summernotePath, 'font/summernote.ttf'), { destDir: 'assets/font' });
app.import(path.join(summernotePath, 'font/summernote.woff'), { destDir: 'assets/font' });

However, those files do not appear to exist in v0.7.0 of summernote in /bower_components/summernote/dist.

lang support

Hi,

Thank you for addon and one quick question:

How to change language, I tried lang="hr-HR" but no luck.

demo not working

i installed the demo as per the instructions, this is what i see when trying to load in the browse

ember.debug.js:16808Uncaught Error: Assertion Failed: Ember Views require jQuery between 1.7 and 2.1EmberError @ ember.debug.js:16808_emberMetalCore.default.assert @ ember.debug.js:5517(anonymous function) @ ember.debug.js:46888internalRequire @ ember.debug.js:77internalRequire @ ember.debug.js:73internalRequire @ ember.debug.js:73requireModule @ ember.debug.js:43(anonymous function) @ ember.debug.js:59507(anonymous function) @ ember.debug.js:59508
loader.js:135Uncaught Error: Could not find module ember imported from dummy/appmissingModule @ loader.js:135findModule @ loader.js:150Module.reify @ loader.js:86Module.build @ loader.js:104findModule @ loader.js:152requireModule @ loader.js:139(anonymous function) @ app-boot.js:23
VM621:272 Uncaught TypeError: Cannot read property 'extend' of undefined(anonymous function) @ VM621:272requireModule @ VM621:40(anonymous function) @ VM621:7689triggerOnce @ VM621:7723completed @ VM621:7745

Fastboot Support

When attempting to use the addon with a fastboot enabled app, requests fail due to the summernote.min.js javascript generating errors, since its not meant to run on the server.

This should be a fairly straightforward fix I believe, by adjusting the index.js's import logic as follows:

if (config.importBootstrapJS && !process.env.EMBER_CLI_FASTBOOT) {
  app.import(path.join(bootstrapPath, '/js/bootstrap.min.js'));
}

//...

if (!process.env.EMBER_CLI_FASTBOOT) {
  app.import(path.join(summernotePath, 'summernote.min.js'));
}
//import the rest of the dependencies as normal...

Problems re-rendering

Thanks for the add-on.

Say we have a list of items and clicking on an item renders a child view with the summernote component and the item's content passed in.

I had to do the following to update the content within the component:

 setup: Ember.on('didRender', function() {
    $('#editor').summernote();
  }),
 update: Ember.on('didUpdate', function() {
   $('".note-editable').html(this.get("content"));
 })

Uncaught Error: Assertion Failed: tooltip has to exist on Ember.$.fn.tooltip

I get the following error with Ember-cli version 0.1.6, straight install:
Uncaught Error: Assertion Failed: tooltip has to exist on Ember.$.fn.tooltip ember.js:3865
Ember.assert summer-note.js:33
Ember.Component.extend.didInsertElement ember.js:19671
apply ember.js:19245
superWrapper ember.js:40881
EmberObject.extend.trigger ember.js:19673
apply ember.js:19245
superWrapper ember.js:39584
Renderer.didInsertElement ember.js:10679
Renderer_renderTree ember.js:10705
(anonymous function) ember.js:679
DeferredActionQueues.invoke ember.js:749
DeferredActionQueues.flush ember.js:135
Backburner.end ember.js:190
Backburner.run ember.js:18223
run ember.js:2542
runInitialize jquery.js:3143
jQuery.Callbacks.fire jquery.js:3255
jQuery.Callbacks.self.fireWith jquery.js:3467
jQuery.extend.ready jquery.js:3498
completed

Problems when shown in a modal.

If the component is show inside a modal the Help page is displayed & clicking the X closes the whole thing; clicking elsewhere closes summernote but leaves the overlay.

capture

Like much of the work on npmjs incomplete & buggy; surely it only looks good on a CV if it's any good

better directions

please write some better directions-I am not sure what I am supposed to install via NPM.

Am I supposed to install summernote via NPM? I guess I am missing something.

Crashes other styles with 1.5.1

Hello,

It is nice to see, that bower seems to be not needed anymore by 1.5.1.

But unfortunately version 1.5.1 crashes styles of other components / the app.
For example the global style
a:not([href]):not([tabindex])
changes the color of some buttons and links.

An other effect was, that a vertical list of menu items in ribbon style was collapsed to a smaller space.

So please check your style changes and apply them only for your component and not globally.

moving from bower to npm

Hi Guys,

i'm trying to move away from bower and use completely the npm package. still i get the message of
Build Error (SourceMapConcat)
ENOENT: no such file or directory, open 'tmp\source_map_concat-input_base_path-ufw4nrVe.tmp\bower_components\summernote\dist\summernote.min.js'

do you know what could be?
i'm having summernote as a dependency and ember-cli-summernote as a devDependency.

Binding 'backend' content changes to the component

Hi,

I don't know if this is the correct method, but I had an issue where I was updating the backend model that was providing the html content, but this change was not being reflected in the WYSIWYG output.

To fix this I had two options:

Option 1

Edit the summer-note src ember-cli-summernote/addon/components/summer-note.js and around line 72 (just above doUpdate) I inserted:

observeContent: Ember.observer('content', function(){
   this.$('.note-editable').html(this.get('content'));
}),

Option 2

Extend the component (which mostly, should be upgrade proof). Create a new component file, in my case it was in app/pods/components/summer-note/component.js

import Ember from 'ember';
import SummerNoteComponent from 'ember-cli-summernote/components/summer-note';

export default SummerNoteComponent.extend({
  observeContent: Ember.observer('content', function(){
    this.$('.note-editable').html(this.get('content'));
  }),
});

I just thought I would put this up here in case others had a similar problem...

Help implementing ember-cli-summernote add-on in existing app

Hi there. Thanks for putting this together! I'm attempting to implement it in a small ember-cli project of mine that I'm using to learn, experiment and share with others. I am new to ember and am having difficulty using this add-on. Would you be will to take a look at my implementation and see where I'm going wrong?

Here's repo branch where I'm attempting to add ember-cli-summernote - https://github.com/jvenator/interest-bucket/tree/summernote

I did the following things so far...

  • $ npm install ember-cli-summernote --save-dev
  • $ ember g ember-cli-summernote
  • ran npm install && bower install
  • updated Brocfile.js and confirmed that bower_components includes assets for bootstrap and fontawesome
  • created a route for /summernote
  • created a template at templates/summernote.hbs and dropped in your example markup

Do you see anything I might be missing or doing incorrectly? Thanks for your time.

Also, I'm happy to contribute some additional documentation/explanation to your repot based on what I learn.

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.