Skip to content
This repository has been archived by the owner on Jul 29, 2023. It is now read-only.

Commit

Permalink
Initial commit on tinymce-emoji TinyMCE plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Johnson authored and Josh Johnson committed Aug 13, 2017
0 parents commit 2d581d6
Show file tree
Hide file tree
Showing 11 changed files with 244 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
"es2015"
]
}
70 changes: 70 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"env": {
"browser": true,
"es6": true
},

"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},

"globals": {
"tinymce": true
},

"rules": {
"camelcase": 0,
"strict": 0,
"eqeqeq": 0,
"no-underscore-dangle": 0,
"consistent-return": 0,
"no-shadow": 0,
"no-use-before-define": 0,
"brace-style": [2, "1tbs"],
"guard-for-in": 0,
"no-floating-decimal": 2,
"no-nested-ternary": 2,
"radix": 2,
"wrap-iife": [2, "inside"],
"consistent-this": [2, "self"],
"no-bitwise": 2,
"max-depth": [1, 8],
"max-statements": [2, 150],
"max-len": [1, 140, 4],
"eol-last": 0,
"quotes": 0,
"no-trailing-spaces": 2,
"comma-spacing": [2, {"before": false, "after": true}],
"comma-dangle": ["error", "never"],
"space-in-parens": [2, "never"],
"space-infix-ops": [2, {"int32Hint": false}],
"space-before-function-paren": ["error", {
"anonymous": "always",
"named": "never",
"asyncArrow": "ignore"
}],
"object-curly-spacing": ["error", "always"],
"no-mixed-spaces-and-tabs": "error",
"keyword-spacing": 2,
"space-unary-ops": [1, { "words": true, "nonwords": false }],
"space-before-blocks": [2, "always"],
"no-multiple-empty-lines": [1, {"max": 2}],
"operator-linebreak": [2, "after"],
"semi": [2, "always"],
"indent": ["error", 2, {"SwitchCase": 1}],
"curly": [2, "all"],
"dot-notation": [2, {"allowKeywords": false}],
"no-else-return": 0,
"no-eval": 2,
"no-implied-eval": 2,
"no-loop-func": 2,
"no-multi-str": 2,
"no-multi-spaces": 2,
"no-sequences": 2,
"no-new": 2,
"no-caller": 2
},

"extends": "eslint:recommended"
}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
*.log
dist
.DS_Store
yarn.lock
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# tinymceEmoji TinyMCE Plugin

Welcome stranger! This is a repo containing the tinymceEmoji TinyMCE plugin.

## The development server

By running the `npm start` command you start the development server and open a browser window with an instance of TinyMCE with your plugin added to it. This window will reload automatically whenever a change is detected in the `index.html` file in the `static` folder or in one of the JavaScript files in the `src` directory.

## The production build

By running the `npm run build` command Webpack will create a `dist` directory with a child directory with the name of your plugin (tinymce-emoji) containing three files:

* `plugin.js` - the bundled plugin
* `plugin.min.js` - the bundles, uglified and minified plugin
* `LICENSE` - a file explaining the license of your plugin (copied over from `src/LICENSE`)
20 changes: 20 additions & 0 deletions config/webpack.config.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
entry: './src/index.js',
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader'
}
]
},
plugins: [
new HtmlWebpackPlugin({
inject: true,
template: './static/index.html'
})
]
}
37 changes: 37 additions & 0 deletions config/webpack.config.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const path = require('path')
const webpack = require('webpack')
const CopyWebpackPlugin = require('copy-webpack-plugin')

const pluginName = 'tinymce-emoji'

module.exports = {
entry: {
'plugin': './src/index.js',
'plugin.min': './src/index.js'
},
output: {
path: path.join(__dirname, '../dist', pluginName),
filename: '[name].js'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader'
}
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
include: /\.min\.js$/,
minimize: true
}),
new CopyWebpackPlugin([
{
from: path.join(__dirname, '../src/LICENSE'),
to: path.join(__dirname, '../dist', pluginName)
}
])
]
}
28 changes: 28 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "tinymce-emoji",
"version": "0.0.1",
"description": "tinymceEmoji TinyMCE plugin repo",
"scripts": {
"start": "webpack-dev-server --config config/webpack.config.dev.js --progress --open --inline",
"lint": "eslint 'src/**/*.js'",
"build": "webpack --config config/webpack.config.prod.js --progress"
},
"author": "",
"devDependencies": {
"babel-core": "^6.21.0",
"babel-loader": "^6.2.10",
"babel-preset-es2015": "^6.18.0",
"copy-webpack-plugin": "^4.0.1",
"eslint": "^3.12.2",
"eslint-config-standard": "^6.2.1",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^2.0.1",
"html-webpack-plugin": "^2.26.0",
"webpack": "^2.2.0",
"webpack-dev-server": "^1.16.2"
},
"dependencies": {
"lodash": "^4.17.4"
},
"license": "MIT"
}
21 changes: 21 additions & 0 deletions src/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2017 Josh Johnson <[email protected]> (geekjosh.co.uk)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import plugin from './plugin';

tinymce.PluginManager.add('tinymceEmoji', plugin);
24 changes: 24 additions & 0 deletions src/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import _ from 'lodash';

const plugin = (editor) => {
editor.addButton('tinymceEmoji', {
text: 'tinymceEmoji',
icon: false,
onclick: () => {
// Open window
editor.windowManager.open({
title: 'tinymceEmoji plugin',
body: [
{ type: 'textbox', name: 'title' }
],
onsubmit(e) {
// Insert content when the window form is submitted
const kebabbyString = _.kebabCase(e.data.title);
editor.insertContent(kebabbyString);
}
});
}
});
};

export default plugin;
16 changes: 16 additions & 0 deletions static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
<script>
tinymce.init({
selector:'textarea',
plugins: 'tinymceEmoji',
toolbar: 'tinymceEmoji'
});
</script>
</head>
<body>
<textarea>Testing tinymceEmoji</textarea>
</body>
</html>

0 comments on commit 2d581d6

Please sign in to comment.