Update to Webpack 3 (#223)

* Update to Webpack 3

* remove nom log
This commit is contained in:
Peter Savchenko 2017-11-26 16:31:34 +03:00 committed by GitHub
parent 7bf5bf72f1
commit d66a2f9d0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 7019 additions and 11999 deletions

16
.postcssrc Normal file
View file

@ -0,0 +1,16 @@
plugins:
postcss-smart-import: {}
postcss-custom-properties: {}
postcss-apply: {}
postcss-custom-media: {}
postcss-media-minmax: {}
postcss-custom-selectors: {}
postcss-nested-ancestors: {}
postcss-nesting: {}
postcss-nested: {}
postcss-color-function: {}
postcss-color-hex-alpha: {}
postcss-font-variant: {}
postcss-font-family-system-ui: {}
autoprefixer:
browsers: ['last 2 versions', '> 1%']

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -4,23 +4,38 @@
"description": "Codex Editor. Native JS, based on API and Open Source",
"main": "index.js",
"scripts": {
"build": "webpack"
"build": "webpack --progress --display-error-details --display-entrypoints --display-reasons"
},
"author": "Codex Team",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.21.0",
"babel-loader": "^6.2.10",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-class-display-name": "^2.1.0",
"babel-polyfill": "^6.20.0",
"babel-preset-es2015": "^6.22.0",
"babel-runtime": "^6.20.0",
"css-loader": "^0.26.1",
"eslint": "^3.12.2",
"eslint-loader": "^1.6.1",
"extract-text-webpack-plugin": "^1.0.1",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-runtime": "^6.26.0",
"css-loader": "^0.28.7",
"eslint": "^4.11.0",
"eslint-loader": "^1.9.0",
"extract-text-webpack-plugin": "^3.0.2",
"html-janitor": "^2.0.2",
"path": "^0.12.7",
"webpack": "^1.14.0"
"postcss-apply": "^0.8.0",
"postcss-color-function": "^4.0.1",
"postcss-color-hex-alpha": "^3.0.0",
"postcss-cssnext": "^3.0.2",
"postcss-custom-media": "^6.0.0",
"postcss-custom-properties": "^6.2.0",
"postcss-custom-selectors": "^4.0.1",
"postcss-font-family-system-ui": "^2.1.1",
"postcss-font-variant": "^3.0.0",
"postcss-loader": "^2.0.9",
"postcss-media-minmax": "^3.0.0",
"postcss-nested": "^2.1.2",
"postcss-nested-ancestors": "^1.0.0",
"postcss-nesting": "^4.2.1",
"postcss-smart-import": "^0.7.5",
"webpack": "^3.8.1"
}
}

View file

@ -54,6 +54,7 @@
/**
* Require Editor modules places in components/modules dir
*/
// eslint-disable-next-line
let modules = editorModules.map( module => {
return require('./components/modules/' + module );
@ -219,7 +220,7 @@ module.exports = class CodexEditor {
*/
getModulesDiff( name ) {
let modules = {};
let diff = {};
for(let moduleName in this.moduleInstances) {
@ -231,11 +232,11 @@ module.exports = class CodexEditor {
continue;
}
modules[moduleName] = this.moduleInstances[moduleName];
diff[moduleName] = this.moduleInstances[moduleName];
}
return modules;
return diff;
}

View file

@ -18,7 +18,9 @@ module.exports = (function (callbacks) {
callbacks.globalKeydown = function (event) {
switch (event.keyCode) {
case editor.core.keys.ENTER : enterKeyPressed_(event); break;
}
};
@ -31,10 +33,12 @@ module.exports = (function (callbacks) {
callbacks.redactorKeyDown = function (event) {
switch (event.keyCode) {
case editor.core.keys.TAB : tabKeyPressedOnRedactorsZone_(event); break;
case editor.core.keys.ENTER : enterKeyPressedOnRedactorsZone_(event); break;
case editor.core.keys.ESC : escapeKeyPressedOnRedactorsZone_(event); break;
default : defaultKeyPressedOnRedactorsZone_(event); break;
}
};
@ -47,10 +51,12 @@ module.exports = (function (callbacks) {
callbacks.globalKeyup = function (event) {
switch (event.keyCode) {
case editor.core.keys.UP :
case editor.core.keys.LEFT :
case editor.core.keys.RIGHT :
case editor.core.keys.DOWN : arrowKeyPressed_(event); break;
}
};

View file

@ -52,12 +52,12 @@ module.exports = (function (saver) {
let getBlockData = function (block) {
return saveBlockData(block)
.then(validateBlockData)
.catch(editor.core.log);
.then(validateBlockData)
.catch(editor.core.log);
};
/**
/**
* @private
* Call block`s plugin save method and return saved data
*
@ -102,7 +102,7 @@ module.exports = (function (saver) {
};
/**
/**
* Call plugin`s validate method. Return false if validation failed
*
* @param data
@ -137,7 +137,7 @@ module.exports = (function (saver) {
};
/**
/**
* Compile article output
*
* @param savedData

View file

@ -121,8 +121,10 @@ module.exports = (function (inline) {
* For more complicated tools, we should write our own behavior
*/
switch (type) {
case 'createLink' : editor.toolbar.inline.createLinkAction(event, type); break;
default : editor.toolbar.inline.defaultToolAction(type); break;
}
/**

View file

@ -5,30 +5,30 @@
*/
// let className = {
/**
/**
* @const {string} BLOCK_CLASSNAME - redactor blocks name
*/
// BLOCK_CLASSNAME : 'ce-block',
// BLOCK_CLASSNAME : 'ce-block',
/**
/**
* @const {String} wrapper for plugins content
*/
// BLOCK_CONTENT : 'ce-block__content',
// BLOCK_CONTENT : 'ce-block__content',
/**
/**
* @const {String} BLOCK_STRETCHED - makes block stretched
*/
// BLOCK_STRETCHED : 'ce-block--stretched',
// BLOCK_STRETCHED : 'ce-block--stretched',
/**
/**
* @const {String} BLOCK_HIGHLIGHTED - adds background
*/
// BLOCK_HIGHLIGHTED : 'ce-block--focused',
// BLOCK_HIGHLIGHTED : 'ce-block--focused',
/**
/**
* @const {String} - for all default settings
*/
// SETTINGS_ITEM : 'ce-settings__item'
// SETTINGS_ITEM : 'ce-settings__item'
// };
let CSS = {
@ -124,6 +124,11 @@ class UI {
*/
this.Editor.Toolbar.make();
/**
* Load and append CSS
*/
this.loadStyles();
resolve();
})
@ -143,13 +148,21 @@ class UI {
/** Add eventlisteners to redactor elements */
// .then(bindEvents_)
.catch(e => {
.catch(e => {
console.error(e);
console.error(e);
// editor.core.log("Can't draw editor interface");
});
});
}
loadStyles() {
let styles = require('../../styles/main.css');
console.log('styles: %o', styles);
}

View file

@ -0,0 +1,625 @@
/**
* Editor wrapper
*/
.codex-editor{
position: relative;
.hide {
display: none;
}
}
/**
* Working zone - redactor
*/
.ce-redactor{
position: relative;
padding-bottom: 120px;
min-height: 350px;
}
.ce-block__content a {
color: #186baa;
}
/*.ce-redactor * {
box-sizing: border-box;
}*/
/**
* Remove outlines from inputs
*/
.ce-redactor [contenteditable]{
outline: none !important;
}
/**
* Toolbar
*/
.ce-toolbar{
position: absolute;
z-index: 2;
width: 100%;
/* hidden by default */
display: none;
}
.ce-toolbar.opened{
display: block;
}
.ce-toolbar__content {
position: relative;
max-width: 600px;
margin: 0 auto;
}
/**
* Plus button
*/
.ce-toolbar__plus{
position: absolute;
background-position: center center;
background-repeat: no-repeat;
text-align: center;
transition: transform 100ms ease;
will-change: transform;
margin-left: -50px;
}
.ce-toolbar__plus.clicked{
transform: rotate(45deg);
}
/**
* Tools list
*/
.ce-toolbar__tools{
position: absolute;
top: 0;
left: 0;
/* hidden by default */
opacity: 0;
visibility: hidden;
transform: translateX(-100px);
transition: all 150ms cubic-bezier(0.600, -0.280, 0.735, 0.045);
}
.ce-toolbar__tools.opened{
opacity: 1;
visibility: visible;
transform: none;
}
.ce-toolbar__plus,
.ce-toolbar__tools li {
display: inline-block;
width: 32px;
height: 32px;
background-color: #eff2f5;
/*box-shadow: 0 0 0 1px #6d748c;*/
margin-right: 17px;
border-radius: 16px;
text-align: center;
vertical-align: top;
cursor: pointer;
font-size: 14px;
will-change: transform, margin-right;
transition: transform 200ms cubic-bezier(0.600, -0.280, 0.735, 0.045), margin 200ms ease-out;
}
.ce-toolbar__tools li i{
line-height: 32px;
}
.ce-toolbar__tools li:hover,
.ce-toolbar__tools .selected{
background: #383b5d;
box-shadow: none;
color: #fff;
}
/* animation for tools opening */
.ce-toolbar__tools li{
transform: rotate(-180deg) scale(.7);
margin-right: -15px;
}
.ce-toolbar__tools.opened li{
transform: none;
margin-right: 17px;
}
/**
* Toolbar right zone with SETTINGS and DELETE
*/
.ce-toolbar__actions{
position: absolute;
right: 15px;
border-radius: 2px;
padding: 6px 5px;
line-height: 1em;
font-size: 14px;
background: #fff;
}
/**
* Settings button
*/
.ce-toolbar__settings-btn{
margin-right: .3em;
cursor: pointer;
}
.ce-toolbar__settings-btn,
.ce-toolbar__remove-btn{
color: #5e6475;
}
.ce-toolbar__settings-btn:hover,
.ce-toolbar__remove-btn:hover{
color: #272b35
}
/**
* Settigns panel
*/
.ce-settings,
.ce-toolbar__remove-confirmation{
position: absolute;
right: 0;
margin-top: 10px;
min-width: 200px;
background: #FFFFFF;
border: 1px solid #e7e9f1;
box-shadow: 0px 2px 5px 0px rgba(16, 23, 49, 0.05);
border-radius: 3px;
white-space: nowrap;
color: #2b2d31;
font-size: 13.4px;
/* hidden by default */
display: none;
}
/**
* Settings and remove-confirmation corner
*/
.ce-settings:before,
.ce-toolbar__remove-confirmation:before,
.ce-settings:after,
.ce-toolbar__remove-confirmation:after{
content: "";
position: absolute;
top: -14px;
right: 10px;
border-style: solid;
}
.ce-settings:before,
.ce-toolbar__remove-confirmation:before {
margin: -2px -1px 0;
border-width: 8px;
border-color: transparent transparent #e7e9f1 transparent;
}
.ce-settings:after,
.ce-toolbar__remove-confirmation:after {
border-width: 7px;
border-color: transparent transparent #fff transparent;
}
.ce-settings:before,
.ce-settings:after{
right: 31px;
}
.ce-toolbar__remove-confirmation:before,
.ce-toolbar__remove-confirmation:after{
right: 10px;
}
.ce-toolbar__remove-confirmation{
right: -3px;
}
/**
* Plugins settings style helper
*/
.cdx-plugin-settings--horisontal {
display: -webkit-flex;
display: -moz-flex;
display: -ms-flex;
display: -o-flex;
display: flex;
}
.cdx-plugin-settings--horisontal .cdx-plugin-settings__item {
flex: 1 0 auto;
text-align: center;
}
.ce-settings__item,
.ce-toolbar__remove-confirm,
.ce-toolbar__remove-cancel,
.cdx-plugin-settings__item {
padding: 15px;
cursor: pointer;
line-height: 1em;
}
.ce-settings__item:hover,
.ce-toolbar__remove-cancel:hover,
.cdx-plugin-settings__item:hover {
background: #edf0f5;
}
.ce-settings.opened,
.ce-toolbar__remove-confirmation.opened{
display: block;
}
.ce-settings_plugin{
border-bottom: 1px solid #e7e9f1;
}
.ce-settings_plugin:empty{
display: none;
}
.ce-settings__item:not(:last-of-type) {
border-bottom: 1px solid #e7e9f1;
}
.ce-settings__item i,
.cdx-plugin-settings__item i {
min-width: 16px;
margin-right: 1.3em;
}
.ce-settings__item i::before {
min-width: 16px;
margin: 0;
}
/**
* Trash button
*/
.ce-toolbar__remove-btn {
cursor: pointer;
}
.ce-toolbar__remove-confirm{
color: #ea5c5c;
}
.ce-toolbar__remove-confirm:hover{
background: #e23d3d;
color: #fff;
}
/** Anchor input */
.ce-settings__anchor-wrapper:hover {
background: none;
}
.ce-settings__anchor-input {
max-width: 100%;
border: 0;
outline: none;
padding: 14px 0;
margin: -15px 0;
font-size: inherit;
color: #000;
height: 1em;
}
.ce-settings__anchor-input::-webkit-input-placeholder {color: rgba(112, 118, 132, 0.5);}
.ce-settings__anchor-input::-moz-placeholder {color: rgba(112, 118, 132, 0.5);}
.ce-settings__anchor-input:-moz-placeholder {color: rgba(112, 118, 132, 0.5);}
.ce-settings__anchor-input:-ms-input-placeholder {color: rgba(112, 118, 132, 0.5);}
.ce-settings__anchor-hash {
display: inline-block;
background-size: contain;
height: 11px;
width: 10px;
vertical-align: middle;
}
/**
* Overlayed inline toolbar
*/
.ce-toolbar-inline{
position: absolute;
left: 0;
top: 0;
z-index: 3;
background: #242533;
border-radius: 3px;
padding: 0 5px;
margin-top: -.5em;
will-change: transform;
transition: transform .2s cubic-bezier(0.600, -0.280, 0.735, 0.045);
color: #fff;
/* hidden by default */
display: none;
}
.ce-toolbar-inline.opened {
display: block;
}
.ce-toolbar-inline__buttons{
}
.ce-toolbar-inline__buttons button{
background: none;
border: 0;
margin: 0 !important;
height: auto !important;
padding: 13px 9px;
line-height: 1em;
color: inherit;
font-size: 12px;
cursor: pointer;
}
.ce-toolbar-inline__buttons button:hover{
background: #171827;
color: #428bff;
}
.ce-toolbar-inline__actions{
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
border-radius: 3px;
background: #242533;
display: none;
}
.ce-toolbar-inline__actions.opened{
display: block;
}
.ce-toolbar-inline__actions input{
background: transparent !important;
border : 0 !important;
box-sizing: border-box !important;
padding: 12px;
font-size: 13px;
width: 100%;
color: #fff;
outline: none;
}
.ce-toolbar-inline__actions input::-moz-placeholder{ color: #afb4c3 !important;}
.ce-toolbar-inline__actions input::-webkit-input-placeholder{ color: #afb4c3 !important;}
/**
* Base blocks
*/
.ce-block {
margin: 0 5px;
border-radius: 3px;
}
.ce-block--focused {
background: #f9f9fb;
}
.ce-block--feed-mode {
position: relative;
}
.ce-block--feed-mode:before {
content: '\e81b';
font-family: "codex_editor";
display: inline-block;
position: absolute;
left: 17px;
top: 13px;
font-size: 16px;
color: #7d6060;
}
.ce-block--anchor {
position: relative;
}
.ce-block--anchor::after {
display: inline-block;
content: "#" attr(data-anchor);
color: #868896;
position: absolute;
left: 17px;
top: 13px;
max-width: 100px;
word-wrap: break-word;
font-size: 12px;
line-height: 1.4em;
}
/**
* Block content holder
*/
.ce-block__content{
max-width: 600px;
margin: 0 auto;
padding: 1px;
}
.ce-block--stretched{
max-width: none;
padding: 0;
}
.cdx-unavailable-block {
display: block;
margin: 10px 0;
padding: 80px;
background-color: #fff7f7;
text-align: center;
border-radius: 3px;
color: #ce5f5f;
}
/**
* Typographycs
*/
.ce-redactor p{
margin: 0;
}
/**
* Loading bar class
*/
.ce-redactor__loader {
background-image: repeating-linear-gradient(-45deg, transparent, transparent 4px, #f5f9ff 4px, #eaedef 8px) !important;
background-size: 56px 56px;
animation: loading-bar 600ms infinite linear;
}
@keyframes loading-bar {
100% { background-position: -56% 0 }
}
/**
* Notifications
*/
.cdx-notifications-block {
position: fixed;
bottom: 0;
left: 0;
padding: 15px;
}
.cdx-notification__notification-appending div {
animation: notification 100ms infinite ease-in;
}
@keyframes notification {
0% { transform: translateY(20px); }
100% { transform: translateY(0px); }
}
.cdx-notification {
width: 250px;
margin-top: 15px;
padding: 15px;
background: #fff;
border: 1px solid #e7e9f1;
box-shadow: 0px 2px 5px 0px rgba(16, 23, 49, 0.05);
border-radius: 3px;
font-size: 14px;
}
.cdx-notification__message {
margin-bottom: 15px;
}
.cdx-notification__ok-btn,
.cdx-notification__cancel-btn {
padding: 4px 7px;
cursor: pointer;
background: #4584d8;
color: #fff;
min-width: 50px;
display: inline-block;
text-align: center;
border-radius: 2px;
}
.cdx-notification__cancel-btn {
margin-left: 10px;
background: #dae0e8;
color: inherit;
}
.cdx-notification__cancel-btn {
background: #cad5e2;
}
.cdx-notification__ok-btn:hover {
background: #3d77c3;
}
.cdx-notification__input {
display: block;
width: 100%;
margin-bottom: 15px;
border: none;
outline: none;
padding: 2px 0;
font-size: inherit;
border-bottom: 2px solid #d1d3da;
}
.cdx-notification-error {
border-left: 4px solid rgb(255, 112, 112);
}
.cdx-notification-warn {
border-left: 4px solid rgb(79, 146, 247);
}
/**
* Mobile viewport styles
* =================================
*/
@media all and (max-width: 1000px){
.ce-block{
margin: 0;
}
.ce-block__content,
.ce-toolbar__content
{
padding: 0 25px;
}
.ce-toolbar {
margin-top: 5px;
}
.ce-toolbar__actions {
right: 0;
top: -10px;
font-size: 14px;
line-height: 18px;
}
.ce-toolbar__settings-btn {
display: block;
margin-bottom: 3px;
}
.ce-toolbar__plus {
margin-left: -25px;
}
.ce-toolbar__plus,
.ce-toolbar__tools li {
width: 22px;
height: 22px;
}
.ce-toolbar__tools li i {
line-height: 22px;
}
.ce-toolbar__tools {
left: 30px;
font-size: 13px;
}
.ce-block--anchor::after {
display: none;
}
}

View file

@ -20,8 +20,8 @@ const VERSION = process.env.VERSION || pkg.version;
* Plugins for bundle
* @type {webpack}
*/
var webpack = require('webpack');
var ExtractTextWebpackPlugin = require('extract-text-webpack-plugin');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var fs = require('fs');
@ -57,17 +57,20 @@ module.exports = {
devtool: NODE_ENV == 'development' ? 'source-map' : null,
/**
* Tell webpack what directories should be searched when resolving modules.
*/
resolve : {
fallback: path.join(__dirname, 'node_modules'),
modulesDirectories : [ './modules' ],
extensions : ['', '.js', '.json']
// fallback: path.join(__dirname, 'node_modules'),
modules : [ path.join(__dirname, "src"), "node_modules"]
},
//
resolveLoader : {
modulesDirectories: [ './node_modules' ],
moduleTemplates: ['*-webpack-loader', '*-web-loader', '*-loader', '*'],
extensions: ['', '.js']
},
// resolveLoader : {
// modules: [ path.resolve(__dirname, "src"), "node_modules" ],
// moduleTemplates: ['*-webpack-loader', '*-web-loader', '*-loader', '*'],
// extensions: ['.js']
// },
plugins: [
@ -92,25 +95,47 @@ module.exports = {
],
module : {
loaders : [ {
test : /\.js$/,
exclude: /node_modules/,
loader : 'babel',
query: {
presets: [ __dirname + '/node_modules/babel-preset-es2015' ],
plugins: ['class-display-name']
rules : [
{
test : /\.js$/,
exclude: /node_modules/,
use : {
loader: 'babel-loader',
options: {
presets: [ __dirname + '/node_modules/babel-preset-es2015' ],
plugins: ['class-display-name']
}
}
},
{
test : /\.js$/,
use: 'eslint-loader?fix=true',
exclude: /node_modules/
},
{
test: /\.css$/,
exclude: /node_modules/,
use: [
{
loader: 'css-loader',
options: {
// minimize: 1,
importLoaders: 1
}
},
'postcss-loader'
]
// use: ExtractTextPlugin.extract([
// {
// loader: 'css-loader',
// options: {
// // minimize: 1,
// importLoaders: 1
// }
// },
// 'postcss-loader'
// ])
}
},
{
test : /\.js$/,
loader: 'eslint-loader?fix=true',
exclude: /node_modules/
},
{
test : /\.css$/,
exclude: /node_modules/,
loader: ExtractTextWebpackPlugin.extract('style-loader', 'css-loader')
} ]
]
}
};