├── .github
└── workflows
│ └── codeql.yml
├── .gitignore
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── bower.help
├── bower.json
├── dev
└── index.html
├── dist
├── editor.min.css
├── images
│ ├── header-bg.gif
│ ├── header-bg.orig.gif
│ ├── icons.old.png
│ ├── icons.png
│ ├── logo.png
│ └── resize.gif
└── wysiwyg.min.js
├── gulpfile.js
├── package.json
└── src
├── css
└── editor.sass
├── images
├── header-bg.gif
├── header-bg.orig.gif
├── icons.old.png
├── icons.png
├── logo.png
└── resize.gif
├── js
├── ngpColorsGrid.js
├── ngpContentFrame.js
├── ngpImageResizer.js
├── ngpResizable.js
├── ngpSymbolsGrid.js
├── ngpUtils.js
├── wysiwyg.js
└── wysiwygEdit.js
└── tests
├── conf.js
└── load-spec.js
/.github/workflows/codeql.yml:
--------------------------------------------------------------------------------
1 | # For most projects, this workflow file will not need changing; you simply need
2 | # to commit it to your repository.
3 | #
4 | # You may wish to alter this file to override the set of languages analyzed,
5 | # or to provide custom queries or build logic.
6 | #
7 | # ******** NOTE ********
8 | # We have attempted to detect the languages in your repository. Please check
9 | # the `language` matrix defined below to confirm you have the correct set of
10 | # supported CodeQL languages.
11 | #
12 | name: "CodeQL Advanced"
13 |
14 | on:
15 | push:
16 | branches: [ "master" ]
17 | pull_request:
18 | branches: [ "master" ]
19 | schedule:
20 | - cron: '30 8 * * 3'
21 |
22 | jobs:
23 | analyze:
24 | name: Analyze (${{ matrix.language }})
25 | # Runner size impacts CodeQL analysis time. To learn more, please see:
26 | # - https://gh.io/recommended-hardware-resources-for-running-codeql
27 | # - https://gh.io/supported-runners-and-hardware-resources
28 | # - https://gh.io/using-larger-runners (GitHub.com only)
29 | # Consider using larger runners or machines with greater resources for possible analysis time improvements.
30 | runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
31 | permissions:
32 | # required for all workflows
33 | security-events: write
34 |
35 | # required to fetch internal or private CodeQL packs
36 | packages: read
37 |
38 | # only required for workflows in private repositories
39 | actions: read
40 | contents: read
41 |
42 | strategy:
43 | fail-fast: false
44 | matrix:
45 | include:
46 | - language: javascript-typescript
47 | build-mode: none
48 | # CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
49 | # Use `c-cpp` to analyze code written in C, C++ or both
50 | # Use 'java-kotlin' to analyze code written in Java, Kotlin or both
51 | # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
52 | # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
53 | # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
54 | # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
55 | # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
56 | steps:
57 | - name: Checkout repository
58 | uses: actions/checkout@v4
59 |
60 | # Add any setup steps before running the `github/codeql-action/init` action.
61 | # This includes steps like installing compilers or runtimes (`actions/setup-node`
62 | # or others). This is typically only required for manual builds.
63 | # - name: Setup runtime (example)
64 | # uses: actions/setup-example@v1
65 |
66 | # Initializes the CodeQL tools for scanning.
67 | - name: Initialize CodeQL
68 | uses: github/codeql-action/init@v3
69 | with:
70 | languages: ${{ matrix.language }}
71 | build-mode: ${{ matrix.build-mode }}
72 | # If you wish to specify custom queries, you can do so here or in a config file.
73 | # By default, queries listed here will override any specified in a config file.
74 | # Prefix the list here with "+" to use these queries and those in the config file.
75 |
76 | # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
77 | # queries: security-extended,security-and-quality
78 |
79 | # If the analyze step fails for one of the languages you are analyzing with
80 | # "We were unable to automatically build your code", modify the matrix above
81 | # to set the build mode to "manual" for that language. Then modify this step
82 | # to build your code.
83 | # ℹ️ Command-line programs to run using the OS shell.
84 | # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
85 | - if: matrix.build-mode == 'manual'
86 | shell: bash
87 | run: |
88 | echo 'If you are using a "manual" build mode for one or more of the' \
89 | 'languages you are analyzing, replace this with the commands to build' \
90 | 'your code, for example:'
91 | echo ' make bootstrap'
92 | echo ' make release'
93 | exit 1
94 |
95 | - name: Perform CodeQL Analysis
96 | uses: github/codeql-action/analyze@v3
97 | with:
98 | category: "/language:${{matrix.language}}"
99 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/*
2 | .idea/*
3 | dev/editor.css
4 | dev/wysiwyg.js
5 | dev/images/*
6 | build/*
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## Bug fixes
4 |
5 | 0.3.0 XSS vulnerability fix from (2015-09-23) happen to be replacing inline styles because $sanitize was utilized. I will have to think some good workaround for this but for now
6 | I recommend using configuration for the XSS. In other words if you want to sanitize the user's input, use sanitize: true in configuration
7 |
8 | ## Imprevements
9 |
10 | - added configuration for the editor
11 | - added configurable toolbar
12 |
13 |
14 | 0.2.1 XSS vulnerability fix (2015-09-23)
15 |
16 | ## Bug fixes
17 |
18 | - used $sanitize to prevent XSS when render from the model to view. Gret read about it: https://www.blackhat.com/docs/eu-14/materials/eu-14-Javed-Revisiting-XSS-Sanitization-wp.pdf
19 |
20 | ## Imprevements
21 |
22 | - added changelog
23 |
24 |
25 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Sergey Petrenko
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ngWYSIWYG
2 | =========
3 |
4 | Folks, for your judgement and, hopefully, contributions, here is the true angular WYSIWYG.
5 | I took images and layout from the tinyeditor, so kudos to Michael Leigeber.
6 |
7 | Here is the Demo
8 |
9 | ### Why iFrame?
10 |
11 | A real rich text editor must reflect the true stage of the editing content. Any CSS and/or Javascript on the host page must not overide the specifics of the content.
12 | Moreover, iframe allows to isolate your security issues (any possible Javascript code in the content may polute your window's scope).
13 |
14 |
15 | Installation
16 | =========================
17 |
18 | ## Requirements
19 |
20 | 1. `AngularJS` ≥ `1.2.x`
21 | 2. `Angular Sanitize` ≥ `1.2.x`
22 |
23 | ### Bower
24 |
25 | ````Shell
26 | $ bower install ngWYSIWYG --save
27 | ```
28 |
29 | Include the ngWYSIWYG files in your index.html:
30 | ````HTML
31 |
32 |
33 | ```
34 |
35 | Add it as module to your app.js:
36 |
37 | ````JavaScript
38 | ['ngWYSIWYG']
39 | ````
40 |
41 | Use it wherever you want:
42 |
43 | ```HTML
44 |
45 | ```
46 |
47 | ## Configuration
48 |
49 | You can configure the editor for two options (will extend l8r). First option is if you want to sanitize input from the user and prevent XSS attacks. This option uses angular's
50 | $sanitize. The second option will allow to configure toolbar buttons. You will be able to configure which buttons you want to show. Please see example.
51 |
52 | ````JavaScript
53 | angular.module('myApp', ['ngWYSIWYG']).
54 | controller('demoController', ['$scope', '$q', '$timeout', function($scope, $q, $timeout) {
55 | $scope.your_variable = 'some HTML text here';
56 | $scope.api = {
57 | scope: $scope,
58 | $scope.editorConfig = {
59 | sanitize: false,
60 | toolbar: [
61 | { name: 'basicStyling', items: ['bold', 'italic', 'underline', 'strikethrough', 'subscript', 'superscript', '-', 'leftAlign', 'centerAlign', 'rightAlign', 'blockJustify', '-'] },
62 | { name: 'paragraph', items: ['orderedList', 'unorderedList', 'outdent', 'indent', '-'] },
63 | { name: 'doers', items: ['removeFormatting', 'undo', 'redo', '-'] },
64 | { name: 'colors', items: ['fontColor', 'backgroundColor', '-'] },
65 | { name: 'links', items: ['image', 'hr', 'symbols', 'link', 'unlink', '-'] },
66 | { name: 'tools', items: ['print', '-'] },
67 | { name: 'styling', items: ['font', 'size', 'format'] },
68 | ]
69 | };
70 | };
71 | }]);
72 | ````
73 |
74 | ```HTML
75 |
76 | ```
77 |
78 | ## Custom content style
79 |
80 | This option enables you to specify a custom CSS file to be used within the editor (the editable area).
81 |
82 | ````HTML
83 |
84 | ```
85 |
86 | If you specify a relative path, it is resolved in relation to the URL of the (HTML) file that includes ngWYSIWYG,
87 | NOT relative to ngWYSIWYG itself. In the example above, if the HTML file is hosted at http://www.example.com/wysiwyg.html,
88 | then the css URL will be resolved to: http://www.example.com/some_style.css.
89 |
90 | ### Use case
91 |
92 | This configuration is useful when you want your editor's content area to show the content exactly like its going to be
93 | show in the destination, without adding inline css to it. For example, let's say that the destination has a black background color
94 | with a white font-color. In this case your some_style.css file would have the following properties:
95 |
96 | ```CSS
97 | html, body {
98 | background-color: black;
99 | color: #ffffff;
100 | }
101 | ```
102 |
103 | ## API
104 |
105 | There is an idea on the api functions to delegate some responsibilities to the customer's scope.
106 | The first thing which is implemented is insert image delegation. By default the directive uses a simple prompt function to accept image's url. However,
107 | there is a way to bring up a custom dialog box on the customer's side and return promise.
108 |
109 | ````JavaScript
110 | angular.module('myApp', ['ngWYSIWYG']).
111 | controller('demoController', ['$scope', '$q', '$timeout', function($scope, $q, $timeout) {
112 | $scope.your_variable = 'some HTML text here';
113 | $scope.api = {
114 | scope: $scope,
115 | $scope.editorConfig = {
116 | sanitize: false,
117 | toolbar: [
118 | { name: 'basicStyling', items: ['bold', 'italic', 'underline', 'strikethrough', 'subscript', 'superscript', '-', 'leftAlign', 'centerAlign', 'rightAlign', 'blockJustify', '-'] },
119 | { name: 'paragraph', items: ['orderedList', 'unorderedList', 'outdent', 'indent', '-'] },
120 | { name: 'doers', items: ['removeFormatting', 'undo', 'redo', '-'] },
121 | { name: 'colors', items: ['fontColor', 'backgroundColor', '-'] },
122 | { name: 'links', items: ['image', 'hr', 'symbols', 'link', 'unlink', '-'] },
123 | { name: 'tools', items: ['print', '-'] },
124 | { name: 'styling', items: ['font', 'size', 'format'] },
125 | ]
126 | };
127 | insertImage: function() {
128 | var deferred = $q.defer();
129 | $timeout(function() {
130 | var val = prompt('Enter image url', 'http://');
131 | if(val) {
132 | deferred.resolve('');
133 | }
134 | else {
135 | deferred.reject(null);
136 | }
137 | }, 1000);
138 | return deferred.promise;
139 | }
140 | };
141 | }]);
142 | ````
143 | Make sure you feed the api object to the directive like this:
144 |
145 | ```HTML
146 |
147 | ```
148 |
149 | ### Simple download (aka git clone/fork)
150 |
151 | 1. Include dist/wysiwyg.min.js in your project using script tag.
152 | 1. Include dist/editor.min.js in your project using link tag.
153 | 2. Add dependency to `ngWYSIWYG` to your app module. Example: ```angular.module('myApp', ['ngWYSIWYG'])```.
154 | 3. Add element ``````.
155 |
156 | Maintenance
157 | =========================
158 |
159 | ### Roadmap
160 |
161 | - Current cursor/caret position style reflection on the toolbar
162 | - Material Design
163 | - Implement tests
164 | - Look for the Angular 2.0
165 |
166 | ### Issues?
167 |
168 | If you find any, please let me know by sumbitting an issue request. I will be working on it actively.
169 |
170 | ## Contributers
171 |
172 | Contributions are welcome and special thanks to all the contributions!
173 |
174 | ## License
175 |
176 | [MIT license](http://opensource.org/licenses/MIT)
177 |
--------------------------------------------------------------------------------
/bower.help:
--------------------------------------------------------------------------------
1 | http://briantford.com/blog/angular-bower
2 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ngWYSIWYG",
3 | "version": "0.6.2",
4 | "homepage": "https://github.com/psergus/ngWYSIWYG",
5 | "authors": [
6 | "Sergey Petrenko "
7 | ],
8 | "description": "Angular WYSIWYG directive",
9 | "main": [
10 | "dist/editor.min.css",
11 | "dist/wysiwyg.min.js",
12 | "dist/images/header-bg.gif",
13 | "dist/images/icons.png",
14 | "dist/images/resize.gif"
15 | ],
16 | "keywords": [
17 | "angular",
18 | "wysiwyg",
19 | "texteditor",
20 | "angular",
21 | "iframe",
22 | "angular",
23 | "directive",
24 | "angualr",
25 | "rich",
26 | "text",
27 | "angular",
28 | "wysiwyg",
29 | "angular",
30 | "angular",
31 | "editor"
32 | ],
33 | "license": "MIT",
34 | "ignore": [
35 | "**/.*",
36 | "node_modules",
37 | "bower_components",
38 | "test",
39 | "tests"
40 | ],
41 | "dependencies": {
42 | "angular": "~1.2.0",
43 | "angular-sanitize": "~1.2.0"
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/dev/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Angular WYSIWYG Demo
7 |
8 |
9 |
10 |
11 |
12 |