Giter VIP home page Giter VIP logo

ngwig's Introduction

ngWig

Dependencies

it's only AngularJS! No jQuery or other WYSIWYG monsters

  • ng-wig2+ - Angular1.3+
  • ng-wig3+ - Angular1.5+

Also suports latest Angular1.7.8

Usage

angular.module('yourApp', ['ngWig'])

it's just attribute directive for textarea:

<ng-wig ng-model="text1"></ng-wig>

Sanitization

Important: ngWig is light weight solution that does not include sanitization module. So it's your own responsiblity to be sure that content that you placed there is already checked and does not have any possible injections. Credits to @MacJu for highlighting the issue.

Installation

ngWig could be simply installed via npm:

npm install ng-wig

or via bower:

bower install ng-wig

CDN

https://cdnjs.cloudflare.com/ajax/libs/ng-wig/3.0.14/ng-wig.min.js

https://cdnjs.cloudflare.com/ajax/libs/ng-wig/3.0.14/ng-wig.js

https://cdnjs.cloudflare.com/ajax/libs/ng-wig/3.0.14/css/ng-wig.css

Always last version CDN

https://cdn.jsdelivr.net/gh/stevermeister/ngWig@master/dist/ng-wig.min.js

https://cdn.jsdelivr.net/gh/stevermeister/ngWig@master/dist/ng-wig.js

https://cdn.jsdelivr.net/gh/stevermeister/ngWig@master/dist/css/ng-wig.css

[Demo] (http://stevermeister.github.io/ngWig/demo/)

![Screenshot] (http://stevermeister.github.io/ngWig/images/ng-wig-demo.png)

Examples

Quick start (plunker)

<ng-wig ng-model="text1"></ng-wig>

Disabled (plunker)

<ng-wig ng-model="text1" ng-disabled="true"></ng-wig>

Edit Source option (plunker)

<ng-wig ng-model="text1" source-mode-allowed></ng-wig>

Placeholder (plunker)

<ng-wig ng-model="text1" placeholder="'Enter instructions here.'"></ng-wig>

ngModel sync (plunker)

<ng-wig ng-model="text1"></ng-wig>
<ng-wig ng-model="text1"></ng-wig>

Set buttons (plunker)

<ng-wig ng-model="text1" buttons="formats, bold, italic"></ng-wig>

Setup generic buttons (plunker)

.config(['ngWigToolbarProvider', function(ngWigToolbarProvider) {
  ngWigToolbarProvider.setButtons(['bold', 'italic']);
}]);

Add standard buttons (plunker)

.config(['ngWigToolbarProvider', function(ngWigToolbarProvider) {
  ngWigToolbarProvider.addStandardButton('underline', 'Underline', 'underline', 'fa-underline');
}]);

Add custom button (plugin) (plunker)

  • Javascript:

      angular.module('ngWig').config(['ngWigToolbarProvider', function(ngWigToolbarProvider) {
          ngWigToolbarProvider.addCustomButton('my-custom', 'nw-my-custom-button');
      }])
      .component('nwMyCustomButton', {
          template: '<button class="nw-button my-custom" title="My Custom Button" ng-click="$ctrl.click()">My Custom Button</button>',
          controller: function() {
              this.click = function(){
                  alert('My Custom Button');
              };
          }
      });
    
  • CSS:

      .nw-button.my-custom:before {
          content: '\f1b3';
      }
    

OnPaste Hook (plunker)

    <ng-wig ng-model="text1" on-paste="onPaste($event, pasteContent)"></ng-wig>

Formats (plugin) (plunker)

    <ng-wig ng-model="text1" buttons="formats"></ng-wig>

Forecolor (plugin) (plunker)

    <ng-wig ng-model="text1" buttons="forecolor"></ng-wig>

Clear Styles (plugin) (plunker)

    <ng-wig ng-model="text1" buttons="clear-styles"></ng-wig>

Contribution (Development Setup)

npm install
npm run devSetup

Creating plugins

ngwig's People

Contributors

bampakoa avatar besuhoff avatar bolelamx avatar dependabot[bot] avatar dmitry-egorov avatar drwebmaker avatar gitter-badger avatar hbugdoll avatar justinwinslow avatar micc83 avatar robhicks avatar rommelatienza avatar sashless avatar sketchynix avatar stevermeister avatar volodziu avatar yuriykuzin 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngwig's Issues

Custom template

How can I overwrite templateUrl without modifying ngWig directive itself?

inner container height

the area is not getting focus when the height of editor is fixed and it's bigger then heights of the text

Allow for disabling the WYSIWYG

It would be nice if the consumer could use the ng-disabled attribute to show the text editor as disabled. In this case we would want the text-area to be non-editable and the buttons to be always disabled. This would be useful for cases where you want to conditionally enable/disable the editor, or perhaps use the same display for a read-only view.

Custom Toolbar

How can i customize the toolbar? For example i want to remove the heading button.

regards

Unlink text

When I create a link, I cannot unlink (only by deleting the linked word).

npm install isn't working

I'm getting a failure when I try to install the ng-wig package through npm. It almost looks like it's trying to run some sort of post-install script and failing on it, but I haven't been able to figure out how to fix it.
The error is as follows:
image

Any help with this would be much appreciated

Cancel link insertion

When I click the "link" icon
and click cancel on the popup
it inserts "http://" in the text

I expect nothing to happen when I click cancel

Strange FF issue

Hi,
I've added the component to our project and under FF i'm unable to click inside freely the cursor sticks to the place before the first character. I can write and press enter for new line but thats all.

Any idea,
Thanks in advance

ng-wig tries to load 'http://localhost/undefined' on initialisation

On every initialisation ng-wig tries to load 'http://localhost/undefined' and fails.

It seems like it tries to load a css style inside an iframe, but scope.cssPath is undefined.

init ng-wig.js:118
invokeLinkFn angular.js:8141
nodeLinkFn angular.js:7653
compositeLinkFn angular.js:7009
compositeLinkFn angular.js:7012
nodeLinkFn angular.js:7648
(anonymous function) angular.js:7884
processQueue angular.js:13073
(anonymous function) angular.js:13089
Scope.$eval angular.js:14289
Scope.$digest angular.js:14105
Scope.$apply angular.js:14393
done angular.js:9567
completeRequest angular.js:9754
requestLoaded angular.js:9695

Paste issues in IE 9+

When trying to bind a custom paste function, on IE I encounter this problem with this line (ng-wig.js, line ~151).

var pasteContent = (event.originalEvent || event).clipboardData.getData('text/plain');

Throws an error on IE, due to it not supporting text/plain and only Text. It pastes the raw data still, but I am unable to fire my custom function.

restoring list item styles inside ng-wig

This is not a problem with ng-wig itself, but might be useful for others who run into the dreaded "Where are my list items gone ????" problem.

If you are using ng-wig inside a modern CSS framework such as Bourbon, your list styles can get redefined away, and at first glance it's pretty hard to work out where to fix the problem.

Manually overriding just the "list-style-type" in your CSS wont bring them back :(

.... But, manually overriding the list-style-type AND manually overriding the left padding back to a sane default does the trick.

.nw-editor {
 // .... as per the standard css for ng-wig

 // now add these 2 blocks : 
  ol {
    list-style-type: decimal;
    margin-bottom: 1px;
    padding-left: 60px;    
    //@extend %default-ol;
  }

  ul {
    list-style-type: disc;
    margin-bottom: 1px;
    padding-left: 60px;
   // @extend %default-ul;
  }
}

Seems like these CSS frameworks hide the list styles by fiddling with the left padding, which causes havoc with the ng-wig control.

Hope that helps someone out there.

html format

When you look at text in html, it's not very convenient to read. Indention on html would be convenient.

copy and paste

When I do copy from a word docs and paste in to the component it keeps all the fonts from the word docs.
Is there a way to disable this kind of behavior?

License?

I wasn't able to find a license file or one mentioned in package.json, the readme, etc. Would it be possible to add an appropriate license?

Icon set

Hi,

Could you please point me where did you get your icons from?

Enhance paste functionality

Currently, pasting using a custom function calls this line

var pasteContent = (event.originalEvent || event).clipboardData.getData('text/plain');

This tries to get the plain text of the line. But if we want the HTML content, we must perform our own actions on the event object. The paste functionality could be enhanced to (optionally) try to get HTML first, then plain text second.

var contentToProcess = (event.originalEvent || event).clipboardData.getData('text/html');

if (!contentToProcess) {
   contentToProcess = (event.originalEvent || event).clipboardData.getData('text/plain');
}

Though, you will run into issues on IE due it it only accepting Text as a parameter of getData. Will need to consider this article to try and get pasting HTML to work on IE https://www.lucidchart.com/techblog/2014/12/02/definitive-guide-copying-pasting-javascript/

Auto-expand editable area

Very good addition would be auto-expanding of the editable area once amount of text becomes too big (so that there's no vertical scrolling)

Clear formatting button

Hi,

I was just thinking for adding a button to clear formatting of a selected piece of text. What's your opinion?

Thanks!

Module name

Module name is not 'ng-wig' but actually 'ngWig', Return error on first install.

And return undefined on line 120 of ng-wig.js

Documentation error

@stevermeister I have been using your plug-in, great by the way and love the new feature of the on-paste feature, which I am currently using.

I needed to use the paste feature to check if the text pasted in was UTF-8 encoded, and after reading your documentation and digging through the paste object I noticed that clipboardData is actually in the originalEvent object within the pasteEvent, so rather than pasteEvent.clipboardData.getData('text/plain') it should be pasteEvent.originalEvent.clipboardData.getData('text/plain');

Thanks again.
Tom

Issue opening in Ipad

Text is going out of the boundary in rich-text in Ipad. Scrollbar is not functioning when opening in Ipad.

Styles inside iframe

In order to give style to edited text we need to include ng-wig.css inside iframe (as a link) and add class "nw-content" to iframe's

Insert special characters

It would be great if someone can develop a feature to add special characters as an html entity into the editor. Insert a special character say copyright symbol © in the editor so that the produced HTML is &#169;

livereload inserted javascript automatically appended to content.

I noticed that I'm getting live reload insertion while I'm using grunt within my project. It'll create data as it should, and append a <script> inside of it all like so:
<p><ul><li>kljsdf sdfdfs<br></li></ul><div><br></div><h1>yfd</h1></p><script src=\"http://127.0.0.1:35729/livereload.js?ext=Safari&amp;extver=2.0.9\"></script>
For any page that I'm inserting this live reload into.

Manual Installation Issue

I could use some expertise on how to correctly install this on an existing angular project. i tried to copy the files from the ZIP into my "content" directory and run the script in index.html, however i receive the following error when my app.js attempt to import the module.

"Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:modulerr] Failed to instantiate module ngWig due to:
Error: [$injector:modulerr] Failed to instantiate module ngwig-app-templates due to:
Error: [$injector:nomod] Module 'ngwig-app-templates' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument."

States for toolbar buttons

Ideally, toolbar buttons should have "active" state. e.g. when current block of text is formatted as "ol", the "ol" button should have "active" state

ng-maxlength and ng-minlength doesn't work

<textarea
      required=true
      name="deal_public_description"
      ng-model="description"
      ng-maxlength=3000
      ng-minlength=300
      cols="30"
      rows="10"
      ng-wig="description"
      data-autoexpand="off"
    >
</textarea>

is valid when description =

0123456789
0123456789
0123456789
0123456789
0123456789
0123456789
0123456789
0123456789
0123456789
0123456789
0123456789
0123456789
0123456789
0123456789
0

155 characters

Question about sizing the text area.

Hello,

Had a quick question. I've tried setting the width and height on ngWig several different ways. It seems like no matter what i do, the change to height, changes the height of the actual text area, but leaves the box the same size, and also causes any form elements under the ngWig to raise and overlap the box. I've tried setting cols and rows like such:

<textarea ng-wig="" cols="50" rows="5"></textarea>

and tried changing the style

<textarea ng-wig="" style="set height here"></textarea>

Any info on what I should do here?

Thanks!
B

feature request

Steve,

Is there anyway you could add a directive features to add custom $sce filter to allow the css attributes of ng-wig go through when binding with ng-bind-html?

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.