diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..edc68d462 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +src/js/polyfills.js \ No newline at end of file diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 000000000..1fe2e17f2 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,114 @@ +{ + "rules": { + "no-empty": [ + 2, + { + "allowEmptyCatch": true + } + ], + "brace-style": [ + 2, + "1tbs", + { + "allowSingleLine": true + } + ], + "no-mixed-spaces-and-tabs": 2, + "no-multiple-empty-lines": 2, + "no-multi-str": 2, + "no-multi-spaces": 2, + "space-unary-ops": [ + 2, + { + "words": false, + "nonwords": false + } + ], + "key-spacing": [ + 2, + { + "beforeColon": false, + "afterColon": true + } + ], + "no-spaced-func": 2, + "space-before-function-paren": [ + 2, + "always" + ], + "array-bracket-spacing": [ + 2, + "never", + { + "objectsInArrays": false + } + ], + "space-in-parens": [ + 2, + "never" + ], + "comma-dangle": [ + 2, + "never" + ], + "no-trailing-spaces": 2, + "camelcase": [ + 2, + { + "properties": "never" + } + ], + "comma-style": [ + 2, + "last" + ], + "curly": [ + 2, + "all" + ], + "one-var": [ + 2, + "consecutive" + ], + "operator-linebreak": [ + 2, + "after" + ], + "semi": [ + 2, + "always" + ], + "space-infix-ops": 2, + "keyword-spacing": [ + 2, + { + "overrides": { + "else": { + "before": true + }, + "while": { + "before": true + }, + "catch": { + "before": true + } + } + } + ], + "space-before-blocks": [ + 2, + "always" + ], + "indent": [ + 2, + 4, + { + "SwitchCase": 1 + } + ], + "quotes": [ + 2, + "single" + ] + } +} diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index d2a8313e3..000000000 --- a/.jscsrc +++ /dev/null @@ -1,134 +0,0 @@ -{ - "disallowEmptyBlocks": true, - "disallowKeywordsOnNewLine": [ - "else" - ], - "disallowMixedSpacesAndTabs": true, - "disallowMultipleLineBreaks": true, - "disallowMultipleLineStrings": true, - "disallowMultipleSpaces": true, - "disallowNewlineBeforeBlockStatements": true, - "disallowSpaceAfterPrefixUnaryOperators": [ - "++", - "--", - "+", - "-", - "~", - "!" - ], - "disallowSpaceAfterObjectKeys": true, - "disallowSpaceBeforePostfixUnaryOperators": [ - "++", - "--" - ], - "disallowSpacesInCallExpression": true, - "disallowSpacesInFunctionDeclaration": { - "beforeOpeningRoundBrace": true - }, - "disallowSpacesInsideArrayBrackets": true, - "disallowSpacesInsideBrackets": true, - "disallowSpacesInsideParentheses": true, - "disallowTrailingComma": true, - "disallowTrailingWhitespace": true, - "requireBlocksOnNewline": true, - "requireCamelCaseOrUpperCaseIdentifiers": true, - "requireCapitalizedConstructors": true, - "requireCommaBeforeLineBreak": true, - "requireCurlyBraces": [ - "if", - "else", - "for", - "while", - "do", - "try", - "catch" - ], - "requireLineBreakAfterVariableAssignment": true, - "requireMultipleVarDecl": true, - "requireOperatorBeforeLineBreak": [ - "?", - "=", - "+", - "-", - "/", - "*", - "==", - "===", - "!=", - "!==", - ">", - ">=", - "<", - "<=" - ], - "requireSemicolons": true, - "requireSpaceAfterBinaryOperators": [ - "=", - ",", - "+", - "-", - "/", - "*", - "==", - "===", - "!=", - "!==" - ], - "requireSpaceAfterKeywords": [ - "do", - "for", - "if", - "else", - "switch", - "case", - "try", - "catch", - "void", - "while", - "with", - "return", - "typeof", - "function" - ], - "requireSpaceBeforeBinaryOperators": [ - "=", - "+", - "-", - "/", - "*", - "==", - "===", - "!=", - "!==" - ], - "requireSpaceBeforeBlockStatements": true, - "requireSpaceBeforeKeywords": [ - "else", - "while", - "catch" - ], - "requireSpaceBetweenArguments": true, - "requireSpacesInAnonymousFunctionExpression": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true - }, - "requireSpacesInConditionalExpression": { - "afterTest": true, - "beforeConsequent": true, - "afterConsequent": true, - "beforeAlternate": true - }, - "requireSpacesInForStatement": true, - "requireSpacesInFunctionDeclaration": { - "beforeOpeningCurlyBrace": true - }, - "requireSpacesInFunction": { - "beforeOpeningCurlyBrace": true - }, - "requireSpacesInsideObjectBrackets": { - "allExcept": [ "}", ")" ] - }, - "validateIndentation": 4, - "validateParameterSeparator": ", ", - "validateQuoteMarks": "'" -} diff --git a/.jshintignore b/.jshintignore new file mode 100644 index 000000000..21504fcd6 --- /dev/null +++ b/.jshintignore @@ -0,0 +1,5 @@ +demo/ +dist/ +spec/vendor/*.js +src/js/polyfills.js +index.js \ No newline at end of file diff --git a/.jshintrc b/.jshintrc index 09b469916..0de71e5b5 100644 --- a/.jshintrc +++ b/.jshintrc @@ -14,5 +14,6 @@ "sub": true, "undef": true, "unused": true, - "validthis": true + "validthis": true, + "esversion": 6 } diff --git a/.stylelintrc b/.stylelintrc new file mode 100644 index 000000000..f97c1549c --- /dev/null +++ b/.stylelintrc @@ -0,0 +1,4 @@ +{ + "rules": { + } +} \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d3edcf551..cbb685de6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,9 +20,9 @@ To help create consistent looking code throughout the project, we use a few tool We use [JSHint](http://jshint.com/) on each build to find easy-to-catch errors and potential problems in our js. You can find our JSHint settings in the `.jshintrc` file in the root of the project. -#### jscs +#### ESLint -We use [jscs](http://jscs.info/) on each build to enforce some code style rules we have for our project. You can find our jscs settings in the `.jscsrc` file in the root of the project. +We use [ESLint](https://eslint.org/) on each build to enforce some code style rules we have for our project. You can find our ESLint settings in the `.eslintrc` file in the root of the project. #### EditorConfig @@ -48,8 +48,8 @@ grunt These are the other available grunt tasks: * __js__: runs jslint and jasmine tests and creates minified and concatenated versions of the script; -* __css__: runs autoprefixer and csslint -* __test__: runs jasmine tests, jslint and csslint +* __css__: runs autoprefixer and stylelint +* __test__: runs jasmine tests, jslint and stylelint * __watch__: watch for modifications on script/scss files * __spec__: runs a task against a specified file diff --git a/Gruntfile.js b/Gruntfile.js index 8544542de..8045c7de8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -93,7 +93,6 @@ module.exports = function (grunt) { // TODO: build check with debug and devel false gruntConfig.jshint = { options: { - ignores: ['src/js/polyfills.js'], jshintrc: true, reporter: require('jshint-stylish') }, @@ -106,16 +105,14 @@ module.exports = function (grunt) { } }; - // TODO: "maximumLineLength": 120 - gruntConfig.jscs = { + gruntConfig.eslint = { src: [ 'src/js/**/*.js', 'spec/*.spec.js', - 'Gruntfile.js', - '!src/js/polyfills.js' + 'Gruntfile.js' ], options: { - config: '.jscsrc' + config: '.eslintrc' } }; @@ -126,7 +123,7 @@ module.exports = function (grunt) { specs: ['spec/*.spec.js'], helpers: 'spec/helpers/*.js', vendor: [ - 'node_modules/lodash/index.js', + 'node_modules/lodash/lodash.js', 'spec/vendor/jasmine-jsreporter.js', 'spec/vendor/jasmine-jsreporter-script.js' ], @@ -172,20 +169,10 @@ module.exports = function (grunt) { } }; - gruntConfig.csslint = { - strict: { - options: { - 'box-sizing': false, - 'compatible-vendor-prefixes': false, - 'fallback-colors': false, - 'gradients': false, - 'important': false, - 'import': 2, - 'outline-none': false, - 'adjoining-classes': false - }, - src: 'dist/css/**/*.css' - } + gruntConfig.stylelint = { + all: [ + 'dist/css/**/*.css' + ] }; gruntConfig.sass = { @@ -333,16 +320,16 @@ module.exports = function (grunt) { }); if (parseInt(process.env.TRAVIS_PULL_REQUEST, 10) > 0) { - grunt.registerTask('travis', ['jshint', 'jscs', 'jasmine:suite', 'csslint', 'coveralls']); + grunt.registerTask('travis', ['jshint', 'eslint', 'jasmine:suite', 'stylelint', 'coveralls']); } else { - grunt.registerTask('travis', ['connect', 'jshint', 'jscs', 'jasmine:suite', 'csslint', 'saucelabs-jasmine', 'coveralls']); + grunt.registerTask('travis', ['connect', 'jshint', 'eslint', 'jasmine:suite', 'stylelint', 'saucelabs-jasmine', 'coveralls']); } - grunt.registerTask('test', ['jshint', 'jscs', 'concat', 'jasmine:suite', 'csslint']); + grunt.registerTask('test', ['jshint', 'eslint', 'concat', 'jasmine:suite', 'stylelint']); grunt.registerTask('sauce', ['connect', 'saucelabs-jasmine']); - grunt.registerTask('js', ['jshint', 'jscs', 'concat', 'jasmine:suite', 'uglify']); - grunt.registerTask('css', ['sass', 'autoprefixer', 'cssmin', 'csslint']); - grunt.registerTask('default', ['js', 'css']); + grunt.registerTask('js', ['jshint', 'eslint', 'concat', 'jasmine:suite', 'uglify']); + grunt.registerTask('css', ['sass', 'autoprefixer', 'cssmin', 'stylelint']); + grunt.registerTask('default', ['css', 'js']); grunt.registerTask('spec', 'Runs a task on a specified file', function (taskName, fileName) { globalConfig.file = fileName; diff --git a/OPTIONS.md b/OPTIONS.md index 9739e1b52..1e752672b 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -333,7 +333,6 @@ var editor = new MediumEditor('.editable', { hideDelay: 500, previewValueSelector: 'a' } -} }); ``` @@ -435,7 +434,6 @@ var editor = new MediumEditor('.editable', { targetCheckbox: false, targetCheckboxText: 'Open in new window' } -} }); ``` diff --git a/README.md b/README.md index 0db7945e1..1ac5fb6d3 100644 --- a/README.md +++ b/README.md @@ -252,7 +252,6 @@ var editor = new MediumEditor('.editable', { hideDelay: 500, previewValueSelector: 'a' } -} }); ``` @@ -320,7 +319,6 @@ var editor = new MediumEditor('.editable', { targetCheckbox: false, targetCheckboxText: 'Open in new window' } -} }); ``` @@ -677,8 +675,8 @@ grunt These are the other available grunt tasks: * __js__: runs jslint and jasmine tests and creates minified and concatenated versions of the script; -* __css__: runs autoprefixer and csslint -* __test__: runs jasmine tests, jslint and csslint +* __css__: runs autoprefixer and stylelint +* __test__: runs jasmine tests, jslint and stylelint * __watch__: watch for modifications on script/scss files * __spec__: runs a task against a specified file @@ -704,9 +702,9 @@ To help create consistent looking code throughout the project, we use a few tool We use [JSHint](http://jshint.com/) on each build to find easy-to-catch errors and potential problems in our js. You can find our JSHint settings in the `.jshintrc` file in the root of the project. -#### jscs +#### ESLint -We use [jscs](http://jscs.info/) on each build to enforce some code style rules we have for our project. You can find our jscs settings in the `.jscsrc` file in the root of the project. +We use [ESLint](https://eslint.org/) on each build to enforce some code style rules we have for our project. You can find our ESLint settings in the `.eslintrc` file in the root of the project. #### EditorConfig diff --git a/dist/css/medium-editor.css b/dist/css/medium-editor.css index de9813251..a1c058acf 100644 --- a/dist/css/medium-editor.css +++ b/dist/css/medium-editor.css @@ -1,52 +1,21 @@ -@-webkit-keyframes medium-editor-image-loading { - 0% { - -webkit-transform: scale(0); - transform: scale(0); } - 100% { - -webkit-transform: scale(1); - transform: scale(1); } } - @keyframes medium-editor-image-loading { 0% { - -webkit-transform: scale(0); - transform: scale(0); } - 100% { - -webkit-transform: scale(1); - transform: scale(1); } } - -@-webkit-keyframes medium-editor-pop-upwards { - 0% { - opacity: 0; - -webkit-transform: matrix(0.97, 0, 0, 1, 0, 12); - transform: matrix(0.97, 0, 0, 1, 0, 12); } - 20% { - opacity: .7; - -webkit-transform: matrix(0.99, 0, 0, 1, 0, 2); - transform: matrix(0.99, 0, 0, 1, 0, 2); } - 40% { - opacity: 1; - -webkit-transform: matrix(1, 0, 0, 1, 0, -1); - transform: matrix(1, 0, 0, 1, 0, -1); } + transform: scale(0); } 100% { - -webkit-transform: matrix(1, 0, 0, 1, 0, 0); - transform: matrix(1, 0, 0, 1, 0, 0); } } + transform: scale(1); } } @keyframes medium-editor-pop-upwards { 0% { opacity: 0; - -webkit-transform: matrix(0.97, 0, 0, 1, 0, 12); - transform: matrix(0.97, 0, 0, 1, 0, 12); } + transform: matrix(0.97, 0, 0, 1, 0, 12); } 20% { opacity: .7; - -webkit-transform: matrix(0.99, 0, 0, 1, 0, 2); - transform: matrix(0.99, 0, 0, 1, 0, 2); } + transform: matrix(0.99, 0, 0, 1, 0, 2); } 40% { opacity: 1; - -webkit-transform: matrix(1, 0, 0, 1, 0, -1); - transform: matrix(1, 0, 0, 1, 0, -1); } + transform: matrix(1, 0, 0, 1, 0, -1); } 100% { - -webkit-transform: matrix(1, 0, 0, 1, 0, 0); - transform: matrix(1, 0, 0, 1, 0, 0); } } + transform: matrix(1, 0, 0, 1, 0, 0); } } .medium-editor-anchor-preview { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; @@ -57,9 +26,9 @@ position: absolute; text-align: center; top: 0; + visibility: hidden; word-break: break-all; word-wrap: break-word; - visibility: hidden; z-index: 2000; } .medium-editor-anchor-preview a { color: #fff; @@ -73,8 +42,7 @@ background: #ddd; } .medium-editor-image-loading { - -webkit-animation: medium-editor-image-loading 1s infinite ease-in-out; - animation: medium-editor-image-loading 1s infinite ease-in-out; + animation: medium-editor-image-loading 1s infinite ease-in-out; background-color: #333; border-radius: 100%; display: inline-block; @@ -86,22 +54,22 @@ .medium-editor-placeholder:after { content: attr(data-placeholder) !important; font-style: italic; - position: absolute; left: 0; - top: 0; - white-space: pre; + margin: inherit; padding: inherit; - margin: inherit; } + position: absolute; + top: 0; + white-space: pre; } .medium-editor-placeholder-relative { position: relative; } .medium-editor-placeholder-relative:after { content: attr(data-placeholder) !important; font-style: italic; - position: relative; - white-space: pre; + margin: inherit; padding: inherit; - margin: inherit; } + position: relative; + white-space: pre; } .medium-toolbar-arrow-under:after, .medium-toolbar-arrow-over:before { border-style: solid; @@ -166,8 +134,7 @@ position: relative; } .medium-editor-toolbar-active.medium-editor-stalker-toolbar { - -webkit-animation: medium-editor-pop-upwards 160ms forwards linear; - animation: medium-editor-pop-upwards 160ms forwards linear; } + animation: medium-editor-pop-upwards 160ms forwards linear; } .medium-editor-action-bold { font-weight: bolder; } @@ -188,11 +155,11 @@ .medium-editor-toolbar-form label { border: none; box-sizing: border-box; + display: inline-block; font-size: 14px; margin: 0; padding: 6px; - width: 316px; - display: inline-block; } + width: 316px; } .medium-editor-toolbar-form .medium-editor-toolbar-input:focus, .medium-editor-toolbar-form label:focus { -webkit-appearance: none; @@ -217,8 +184,8 @@ display: table; } .medium-editor-element { - word-wrap: break-word; - min-height: 30px; } + min-height: 30px; + word-wrap: break-word; } .medium-editor-element img { max-width: 100%; } .medium-editor-element sub { diff --git a/dist/css/medium-editor.min.css b/dist/css/medium-editor.min.css index e46f81c02..697afe214 100644 --- a/dist/css/medium-editor.min.css +++ b/dist/css/medium-editor.min.css @@ -1 +1 @@ -.medium-editor-anchor-preview,.medium-editor-toolbar{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:16px;z-index:2000}@-webkit-keyframes medium-editor-image-loading{0%{-webkit-transform:scale(0);transform:scale(0)}100%{-webkit-transform:scale(1);transform:scale(1)}}@keyframes medium-editor-image-loading{0%{-webkit-transform:scale(0);transform:scale(0)}100%{-webkit-transform:scale(1);transform:scale(1)}}@-webkit-keyframes medium-editor-pop-upwards{0%{opacity:0;-webkit-transform:matrix(.97,0,0,1,0,12);transform:matrix(.97,0,0,1,0,12)}20%{opacity:.7;-webkit-transform:matrix(.99,0,0,1,0,2);transform:matrix(.99,0,0,1,0,2)}40%{opacity:1;-webkit-transform:matrix(1,0,0,1,0,-1);transform:matrix(1,0,0,1,0,-1)}100%{-webkit-transform:matrix(1,0,0,1,0,0);transform:matrix(1,0,0,1,0,0)}}@keyframes medium-editor-pop-upwards{0%{opacity:0;-webkit-transform:matrix(.97,0,0,1,0,12);transform:matrix(.97,0,0,1,0,12)}20%{opacity:.7;-webkit-transform:matrix(.99,0,0,1,0,2);transform:matrix(.99,0,0,1,0,2)}40%{opacity:1;-webkit-transform:matrix(1,0,0,1,0,-1);transform:matrix(1,0,0,1,0,-1)}100%{-webkit-transform:matrix(1,0,0,1,0,0);transform:matrix(1,0,0,1,0,0)}}.medium-editor-anchor-preview{left:0;line-height:1.4;max-width:280px;position:absolute;text-align:center;top:0;word-break:break-all;word-wrap:break-word;visibility:hidden}.medium-editor-anchor-preview a{color:#fff;display:inline-block;margin:5px 5px 10px}.medium-editor-placeholder-relative:after,.medium-editor-placeholder:after{content:attr(data-placeholder)!important;white-space:pre;padding:inherit;margin:inherit;font-style:italic}.medium-editor-anchor-preview-active{visibility:visible}.medium-editor-dragover{background:#ddd}.medium-editor-image-loading{-webkit-animation:medium-editor-image-loading 1s infinite ease-in-out;animation:medium-editor-image-loading 1s infinite ease-in-out;background-color:#333;border-radius:100%;display:inline-block;height:40px;width:40px}.medium-editor-placeholder{position:relative}.medium-editor-placeholder:after{position:absolute;left:0;top:0}.medium-editor-placeholder-relative,.medium-editor-placeholder-relative:after{position:relative}.medium-toolbar-arrow-over:before,.medium-toolbar-arrow-under:after{border-style:solid;content:'';display:block;height:0;left:50%;margin-left:-8px;position:absolute;width:0}.medium-toolbar-arrow-under:after{border-width:8px 8px 0}.medium-toolbar-arrow-over:before{border-width:0 8px 8px;top:-8px}.medium-editor-toolbar{left:0;position:absolute;top:0;visibility:hidden}.medium-editor-toolbar ul{margin:0;padding:0}.medium-editor-toolbar li{float:left;list-style:none;margin:0;padding:0}.medium-editor-toolbar li button{box-sizing:border-box;cursor:pointer;display:block;font-size:14px;line-height:1.33;margin:0;padding:15px;text-decoration:none}.medium-editor-toolbar li button:focus{outline:0}.medium-editor-toolbar li .medium-editor-action-underline{text-decoration:underline}.medium-editor-toolbar li .medium-editor-action-pre{font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;font-weight:100;padding:15px 0}.medium-editor-toolbar-active{visibility:visible}.medium-editor-sticky-toolbar{position:fixed;top:1px}.medium-editor-relative-toolbar{position:relative}.medium-editor-toolbar-active.medium-editor-stalker-toolbar{-webkit-animation:medium-editor-pop-upwards 160ms forwards linear;animation:medium-editor-pop-upwards 160ms forwards linear}.medium-editor-action-bold{font-weight:bolder}.medium-editor-action-italic{font-style:italic}.medium-editor-toolbar-form{display:none}.medium-editor-toolbar-form a,.medium-editor-toolbar-form input{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif}.medium-editor-toolbar-form .medium-editor-toolbar-form-row{line-height:14px;margin-left:5px;padding-bottom:5px}.medium-editor-toolbar-form .medium-editor-toolbar-input,.medium-editor-toolbar-form label{border:none;box-sizing:border-box;font-size:14px;margin:0;padding:6px;width:316px;display:inline-block}.medium-editor-toolbar-form .medium-editor-toolbar-input:focus,.medium-editor-toolbar-form label:focus{-webkit-appearance:none;-moz-appearance:none;appearance:none;border:none;box-shadow:none;outline:0}.medium-editor-toolbar-form a{display:inline-block;font-size:24px;font-weight:bolder;margin:0 10px;text-decoration:none}.medium-editor-toolbar-form-active{display:block}.medium-editor-toolbar-actions:after{clear:both;content:"";display:table}.medium-editor-element{word-wrap:break-word;min-height:30px}.medium-editor-element img{max-width:100%}.medium-editor-element sub{vertical-align:sub}.medium-editor-element sup{vertical-align:super}.medium-editor-hidden{display:none} \ No newline at end of file +@keyframes medium-editor-image-loading{0%{transform:scale(0)}100%{transform:scale(1)}}@keyframes medium-editor-pop-upwards{0%{opacity:0;transform:matrix(.97,0,0,1,0,12)}20%{opacity:.7;transform:matrix(.99,0,0,1,0,2)}40%{opacity:1;transform:matrix(1,0,0,1,0,-1)}100%{transform:matrix(1,0,0,1,0,0)}}.medium-editor-anchor-preview{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:16px;left:0;line-height:1.4;max-width:280px;position:absolute;text-align:center;top:0;visibility:hidden;word-break:break-all;word-wrap:break-word;z-index:2000}.medium-editor-anchor-preview a{color:#fff;display:inline-block;margin:5px 5px 10px}.medium-editor-anchor-preview-active{visibility:visible}.medium-editor-dragover{background:#ddd}.medium-editor-image-loading{animation:medium-editor-image-loading 1s infinite ease-in-out;background-color:#333;border-radius:100%;display:inline-block;height:40px;width:40px}.medium-editor-placeholder{position:relative}.medium-editor-placeholder:after{content:attr(data-placeholder)!important;font-style:italic;left:0;margin:inherit;padding:inherit;position:absolute;top:0;white-space:pre}.medium-editor-placeholder-relative{position:relative}.medium-editor-placeholder-relative:after{content:attr(data-placeholder)!important;font-style:italic;margin:inherit;padding:inherit;position:relative;white-space:pre}.medium-toolbar-arrow-over:before,.medium-toolbar-arrow-under:after{border-style:solid;content:'';display:block;height:0;left:50%;margin-left:-8px;position:absolute;width:0}.medium-toolbar-arrow-under:after{border-width:8px 8px 0 8px}.medium-toolbar-arrow-over:before{border-width:0 8px 8px 8px;top:-8px}.medium-editor-toolbar{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:16px;left:0;position:absolute;top:0;visibility:hidden;z-index:2000}.medium-editor-toolbar ul{margin:0;padding:0}.medium-editor-toolbar li{float:left;list-style:none;margin:0;padding:0}.medium-editor-toolbar li button{box-sizing:border-box;cursor:pointer;display:block;font-size:14px;line-height:1.33;margin:0;padding:15px;text-decoration:none}.medium-editor-toolbar li button:focus{outline:0}.medium-editor-toolbar li .medium-editor-action-underline{text-decoration:underline}.medium-editor-toolbar li .medium-editor-action-pre{font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;font-weight:100;padding:15px 0}.medium-editor-toolbar-active{visibility:visible}.medium-editor-sticky-toolbar{position:fixed;top:1px}.medium-editor-relative-toolbar{position:relative}.medium-editor-toolbar-active.medium-editor-stalker-toolbar{animation:medium-editor-pop-upwards 160ms forwards linear}.medium-editor-action-bold{font-weight:bolder}.medium-editor-action-italic{font-style:italic}.medium-editor-toolbar-form{display:none}.medium-editor-toolbar-form a,.medium-editor-toolbar-form input{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif}.medium-editor-toolbar-form .medium-editor-toolbar-form-row{line-height:14px;margin-left:5px;padding-bottom:5px}.medium-editor-toolbar-form .medium-editor-toolbar-input,.medium-editor-toolbar-form label{border:none;box-sizing:border-box;display:inline-block;font-size:14px;margin:0;padding:6px;width:316px}.medium-editor-toolbar-form .medium-editor-toolbar-input:focus,.medium-editor-toolbar-form label:focus{-webkit-appearance:none;-moz-appearance:none;appearance:none;border:none;box-shadow:none;outline:0}.medium-editor-toolbar-form a{display:inline-block;font-size:24px;font-weight:bolder;margin:0 10px;text-decoration:none}.medium-editor-toolbar-form-active{display:block}.medium-editor-toolbar-actions:after{clear:both;content:"";display:table}.medium-editor-element{min-height:30px;word-wrap:break-word}.medium-editor-element img{max-width:100%}.medium-editor-element sub{vertical-align:sub}.medium-editor-element sup{vertical-align:super}.medium-editor-hidden{display:none} \ No newline at end of file diff --git a/dist/css/themes/beagle.css b/dist/css/themes/beagle.css index edab17ee9..1135bf85c 100644 --- a/dist/css/themes/beagle.css +++ b/dist/css/themes/beagle.css @@ -17,8 +17,7 @@ height: 40px; min-width: 40px; padding: 5px 12px; - -webkit-transition: background-color .2s ease-in, color .2s ease-in; - transition: background-color .2s ease-in, color .2s ease-in; } + transition: background-color .2s ease-in, color .2s ease-in; } .medium-editor-toolbar li button:hover { background-color: #000; color: #a2d7c7; } @@ -63,8 +62,7 @@ color: rgba(248, 245, 243, 0.8); } .medium-editor-toolbar-form a { color: #ccc; - -webkit-transform: translateY(2px); - transform: translateY(2px); } + transform: translateY(2px); } .medium-editor-toolbar-form .medium-editor-toolbar-close { margin-right: 16px; } diff --git a/dist/css/themes/beagle.min.css b/dist/css/themes/beagle.min.css index 5afbb9743..86489ff7f 100644 --- a/dist/css/themes/beagle.min.css +++ b/dist/css/themes/beagle.min.css @@ -1 +1 @@ -.medium-toolbar-arrow-under:after{border-color:#000 transparent transparent;top:40px}.medium-toolbar-arrow-over:before{border-color:transparent transparent #000}.medium-editor-toolbar{background-color:#000;border:none;border-radius:50px}.medium-editor-toolbar li button{background-color:transparent;border:none;box-sizing:border-box;color:#ccc;height:40px;min-width:40px;padding:5px 12px;-webkit-transition:background-color .2s ease-in,color .2s ease-in;transition:background-color .2s ease-in,color .2s ease-in}.medium-editor-toolbar li .medium-editor-button-active,.medium-editor-toolbar li button:hover{background-color:#000;color:#a2d7c7}.medium-editor-toolbar li .medium-editor-button-first{border-bottom-left-radius:50px;border-top-left-radius:50px;padding-left:24px}.medium-editor-toolbar li .medium-editor-button-last{border-bottom-right-radius:50px;border-right:none;border-top-right-radius:50px;padding-right:24px}.medium-editor-toolbar-form{background:#000;border-radius:50px;color:#ccc;overflow:hidden}.medium-editor-toolbar-form .medium-editor-toolbar-input{background:#000;box-sizing:border-box;color:#ccc;height:40px;padding-left:16px;width:220px}.medium-editor-toolbar-form .medium-editor-toolbar-input::-webkit-input-placeholder{color:#f8f5f3;color:rgba(248,245,243,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input:-moz-placeholder{color:#f8f5f3;color:rgba(248,245,243,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input::-moz-placeholder{color:#f8f5f3;color:rgba(248,245,243,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input:-ms-input-placeholder{color:#f8f5f3;color:rgba(248,245,243,.8)}.medium-editor-toolbar-form a{color:#ccc;-webkit-transform:translateY(2px);transform:translateY(2px)}.medium-editor-toolbar-form .medium-editor-toolbar-close{margin-right:16px}.medium-editor-toolbar-anchor-preview{background:#000;border-radius:50px;padding:5px 12px}.medium-editor-anchor-preview a{color:#ccc;text-decoration:none}.medium-editor-toolbar-actions button,.medium-editor-toolbar-actions li{border-radius:50px} \ No newline at end of file +.medium-toolbar-arrow-under:after{border-color:#000 transparent transparent transparent;top:40px}.medium-toolbar-arrow-over:before{border-color:transparent transparent #000 transparent}.medium-editor-toolbar{background-color:#000;border:none;border-radius:50px}.medium-editor-toolbar li button{background-color:transparent;border:none;box-sizing:border-box;color:#ccc;height:40px;min-width:40px;padding:5px 12px;transition:background-color .2s ease-in,color .2s ease-in}.medium-editor-toolbar li button:hover{background-color:#000;color:#a2d7c7}.medium-editor-toolbar li .medium-editor-button-first{border-bottom-left-radius:50px;border-top-left-radius:50px;padding-left:24px}.medium-editor-toolbar li .medium-editor-button-last{border-bottom-right-radius:50px;border-right:none;border-top-right-radius:50px;padding-right:24px}.medium-editor-toolbar li .medium-editor-button-active{background-color:#000;color:#a2d7c7}.medium-editor-toolbar-form{background:#000;border-radius:50px;color:#ccc;overflow:hidden}.medium-editor-toolbar-form .medium-editor-toolbar-input{background:#000;box-sizing:border-box;color:#ccc;height:40px;padding-left:16px;width:220px}.medium-editor-toolbar-form .medium-editor-toolbar-input::-webkit-input-placeholder{color:#f8f5f3;color:rgba(248,245,243,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input:-moz-placeholder{color:#f8f5f3;color:rgba(248,245,243,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input::-moz-placeholder{color:#f8f5f3;color:rgba(248,245,243,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input:-ms-input-placeholder{color:#f8f5f3;color:rgba(248,245,243,.8)}.medium-editor-toolbar-form a{color:#ccc;transform:translateY(2px)}.medium-editor-toolbar-form .medium-editor-toolbar-close{margin-right:16px}.medium-editor-toolbar-anchor-preview{background:#000;border-radius:50px;padding:5px 12px}.medium-editor-anchor-preview a{color:#ccc;text-decoration:none}.medium-editor-toolbar-actions button,.medium-editor-toolbar-actions li{border-radius:50px} \ No newline at end of file diff --git a/dist/css/themes/bootstrap.css b/dist/css/themes/bootstrap.css index a1f4ef28a..929f1faaa 100644 --- a/dist/css/themes/bootstrap.css +++ b/dist/css/themes/bootstrap.css @@ -17,8 +17,7 @@ color: #fff; height: 60px; min-width: 60px; - -webkit-transition: background-color .2s ease-in, color .2s ease-in; - transition: background-color .2s ease-in, color .2s ease-in; } + transition: background-color .2s ease-in, color .2s ease-in; } .medium-editor-toolbar li button:hover { background-color: #3276b1; color: #fff; } diff --git a/dist/css/themes/bootstrap.min.css b/dist/css/themes/bootstrap.min.css index 4063c7505..f36daf480 100644 --- a/dist/css/themes/bootstrap.min.css +++ b/dist/css/themes/bootstrap.min.css @@ -1 +1 @@ -.medium-toolbar-arrow-under:after{border-color:#428bca transparent transparent;top:60px}.medium-toolbar-arrow-over:before{border-color:transparent transparent #428bca}.medium-editor-toolbar{background-color:#428bca;border:1px solid #357ebd;border-radius:4px}.medium-editor-toolbar li button{background-color:transparent;border:none;border-right:1px solid #357ebd;box-sizing:border-box;color:#fff;height:60px;min-width:60px;-webkit-transition:background-color .2s ease-in,color .2s ease-in;transition:background-color .2s ease-in,color .2s ease-in}.medium-editor-toolbar li .medium-editor-button-active,.medium-editor-toolbar li button:hover{background-color:#3276b1;color:#fff}.medium-editor-toolbar li .medium-editor-button-first{border-bottom-left-radius:4px;border-top-left-radius:4px}.medium-editor-toolbar li .medium-editor-button-last{border-bottom-right-radius:4px;border-right:none;border-top-right-radius:4px}.medium-editor-toolbar-form{background:#428bca;border-radius:4px;color:#fff}.medium-editor-toolbar-form .medium-editor-toolbar-input{background:#428bca;color:#fff;height:60px}.medium-editor-toolbar-form .medium-editor-toolbar-input::-webkit-input-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input:-moz-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input::-moz-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input:-ms-input-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form a{color:#fff}.medium-editor-toolbar-anchor-preview{background:#428bca;border-radius:4px;color:#fff}.medium-editor-placeholder:after{color:#357ebd} \ No newline at end of file +.medium-toolbar-arrow-under:after{border-color:#428bca transparent transparent transparent;top:60px}.medium-toolbar-arrow-over:before{border-color:transparent transparent #428bca transparent}.medium-editor-toolbar{background-color:#428bca;border:1px solid #357ebd;border-radius:4px}.medium-editor-toolbar li button{background-color:transparent;border:none;border-right:1px solid #357ebd;box-sizing:border-box;color:#fff;height:60px;min-width:60px;transition:background-color .2s ease-in,color .2s ease-in}.medium-editor-toolbar li button:hover{background-color:#3276b1;color:#fff}.medium-editor-toolbar li .medium-editor-button-first{border-bottom-left-radius:4px;border-top-left-radius:4px}.medium-editor-toolbar li .medium-editor-button-last{border-bottom-right-radius:4px;border-right:none;border-top-right-radius:4px}.medium-editor-toolbar li .medium-editor-button-active{background-color:#3276b1;color:#fff}.medium-editor-toolbar-form{background:#428bca;border-radius:4px;color:#fff}.medium-editor-toolbar-form .medium-editor-toolbar-input{background:#428bca;color:#fff;height:60px}.medium-editor-toolbar-form .medium-editor-toolbar-input::-webkit-input-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input:-moz-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input::-moz-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input:-ms-input-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form a{color:#fff}.medium-editor-toolbar-anchor-preview{background:#428bca;border-radius:4px;color:#fff}.medium-editor-placeholder:after{color:#357ebd} \ No newline at end of file diff --git a/dist/css/themes/default.css b/dist/css/themes/default.css index 02668c6b9..a30157655 100644 --- a/dist/css/themes/default.css +++ b/dist/css/themes/default.css @@ -7,26 +7,23 @@ top: -8px; } .medium-editor-toolbar { - background-color: #242424; - background: -webkit-linear-gradient(top, #242424, rgba(36, 36, 36, 0.75)); background: linear-gradient(to bottom, #242424, rgba(36, 36, 36, 0.75)); + background-color: #242424; border: 1px solid #000; border-radius: 5px; box-shadow: 0 0 3px #000; } .medium-editor-toolbar li button { - background-color: #242424; - background: -webkit-linear-gradient(top, #242424, rgba(36, 36, 36, 0.89)); background: linear-gradient(to bottom, #242424, rgba(36, 36, 36, 0.89)); + background-color: #242424; border: 0; - border-right: 1px solid #000; border-left: 1px solid #333; border-left: 1px solid rgba(255, 255, 255, 0.1); + border-right: 1px solid #000; box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3); color: #fff; height: 50px; min-width: 50px; - -webkit-transition: background-color .2s ease-in; - transition: background-color .2s ease-in; } + transition: background-color .2s ease-in; } .medium-editor-toolbar li button:hover { background-color: #000; color: yellow; } @@ -37,9 +34,8 @@ border-bottom-right-radius: 5px; border-top-right-radius: 5px; } .medium-editor-toolbar li .medium-editor-button-active { - background-color: #000; - background: -webkit-linear-gradient(top, #242424, rgba(0, 0, 0, 0.89)); background: linear-gradient(to bottom, #242424, rgba(0, 0, 0, 0.89)); + background-color: #000; color: #fff; } .medium-editor-toolbar-form { diff --git a/dist/css/themes/default.min.css b/dist/css/themes/default.min.css index ac5847843..bad2e21bd 100644 --- a/dist/css/themes/default.min.css +++ b/dist/css/themes/default.min.css @@ -1 +1 @@ -.medium-toolbar-arrow-under:after{border-color:#242424 transparent transparent;top:50px}.medium-toolbar-arrow-over:before{border-color:transparent transparent #242424;top:-8px}.medium-editor-toolbar{background-color:#242424;background:-webkit-linear-gradient(top,#242424,rgba(36,36,36,.75));background:linear-gradient(to bottom,#242424,rgba(36,36,36,.75));border:1px solid #000;border-radius:5px;box-shadow:0 0 3px #000}.medium-editor-toolbar li button{background-color:#242424;background:-webkit-linear-gradient(top,#242424,rgba(36,36,36,.89));background:linear-gradient(to bottom,#242424,rgba(36,36,36,.89));border:0;border-right:1px solid #000;border-left:1px solid #333;border-left:1px solid rgba(255,255,255,.1);box-shadow:0 2px 2px rgba(0,0,0,.3);color:#fff;height:50px;min-width:50px;-webkit-transition:background-color .2s ease-in;transition:background-color .2s ease-in}.medium-editor-toolbar li button:hover{background-color:#000;color:#ff0}.medium-editor-toolbar li .medium-editor-button-first{border-bottom-left-radius:5px;border-top-left-radius:5px}.medium-editor-toolbar li .medium-editor-button-last{border-bottom-right-radius:5px;border-top-right-radius:5px}.medium-editor-toolbar li .medium-editor-button-active{background-color:#000;background:-webkit-linear-gradient(top,#242424,rgba(0,0,0,.89));background:linear-gradient(to bottom,#242424,rgba(0,0,0,.89));color:#fff}.medium-editor-toolbar-form{background:#242424;border-radius:5px;color:#999}.medium-editor-toolbar-form .medium-editor-toolbar-input{background:#242424;box-sizing:border-box;color:#ccc;height:50px}.medium-editor-toolbar-form a{color:#fff}.medium-editor-toolbar-anchor-preview{background:#242424;border-radius:5px;color:#fff}.medium-editor-placeholder:after{color:#b3b3b1} \ No newline at end of file +.medium-toolbar-arrow-under:after{border-color:#242424 transparent transparent transparent;top:50px}.medium-toolbar-arrow-over:before{border-color:transparent transparent #242424 transparent;top:-8px}.medium-editor-toolbar{background:linear-gradient(to bottom,#242424,rgba(36,36,36,.75));background-color:#242424;border:1px solid #000;border-radius:5px;box-shadow:0 0 3px #000}.medium-editor-toolbar li button{background:linear-gradient(to bottom,#242424,rgba(36,36,36,.89));background-color:#242424;border:0;border-left:1px solid #333;border-left:1px solid rgba(255,255,255,.1);border-right:1px solid #000;box-shadow:0 2px 2px rgba(0,0,0,.3);color:#fff;height:50px;min-width:50px;transition:background-color .2s ease-in}.medium-editor-toolbar li button:hover{background-color:#000;color:#ff0}.medium-editor-toolbar li .medium-editor-button-first{border-bottom-left-radius:5px;border-top-left-radius:5px}.medium-editor-toolbar li .medium-editor-button-last{border-bottom-right-radius:5px;border-top-right-radius:5px}.medium-editor-toolbar li .medium-editor-button-active{background:linear-gradient(to bottom,#242424,rgba(0,0,0,.89));background-color:#000;color:#fff}.medium-editor-toolbar-form{background:#242424;border-radius:5px;color:#999}.medium-editor-toolbar-form .medium-editor-toolbar-input{background:#242424;box-sizing:border-box;color:#ccc;height:50px}.medium-editor-toolbar-form a{color:#fff}.medium-editor-toolbar-anchor-preview{background:#242424;border-radius:5px;color:#fff}.medium-editor-placeholder:after{color:#b3b3b1} \ No newline at end of file diff --git a/dist/css/themes/flat.css b/dist/css/themes/flat.css index ae809d489..fdd608133 100644 --- a/dist/css/themes/flat.css +++ b/dist/css/themes/flat.css @@ -1,24 +1,23 @@ .medium-toolbar-arrow-under:after { - top: 60px; - border-color: #57ad68 transparent transparent transparent; } + border-color: #57ad68 transparent transparent transparent; + top: 60px; } .medium-toolbar-arrow-over:before { - top: -8px; - border-color: transparent transparent #57ad68 transparent; } + border-color: transparent transparent #57ad68 transparent; + top: -8px; } .medium-editor-toolbar { background-color: #57ad68; } .medium-editor-toolbar li { padding: 0; } .medium-editor-toolbar li button { - min-width: 60px; - height: 60px; + background-color: transparent; border: none; border-right: 1px solid #9ccea6; - background-color: transparent; color: #fff; - -webkit-transition: background-color .2s ease-in, color .2s ease-in; - transition: background-color .2s ease-in, color .2s ease-in; } + height: 60px; + min-width: 60px; + transition: background-color .2s ease-in, color .2s ease-in; } .medium-editor-toolbar li button:hover { background-color: #346a3f; color: #fff; } @@ -29,9 +28,9 @@ border-right: none; } .medium-editor-toolbar-form .medium-editor-toolbar-input { - height: 60px; background: #57ad68; - color: #fff; } + color: #fff; + height: 60px; } .medium-editor-toolbar-form .medium-editor-toolbar-input::-webkit-input-placeholder { color: #fff; color: rgba(255, 255, 255, 0.8); } diff --git a/dist/css/themes/flat.min.css b/dist/css/themes/flat.min.css index b97ec7d97..ccfeb5da3 100644 --- a/dist/css/themes/flat.min.css +++ b/dist/css/themes/flat.min.css @@ -1 +1 @@ -.medium-toolbar-arrow-under:after{top:60px;border-color:#57ad68 transparent transparent}.medium-toolbar-arrow-over:before{top:-8px;border-color:transparent transparent #57ad68}.medium-editor-toolbar{background-color:#57ad68}.medium-editor-toolbar li{padding:0}.medium-editor-toolbar li button{min-width:60px;height:60px;border:none;border-right:1px solid #9ccea6;background-color:transparent;color:#fff;-webkit-transition:background-color .2s ease-in,color .2s ease-in;transition:background-color .2s ease-in,color .2s ease-in}.medium-editor-toolbar li button:hover{background-color:#346a3f;color:#fff}.medium-editor-toolbar li .medium-editor-button-active{background-color:#23482a;color:#fff}.medium-editor-toolbar li .medium-editor-button-last{border-right:none}.medium-editor-toolbar-form .medium-editor-toolbar-input{height:60px;background:#57ad68;color:#fff}.medium-editor-toolbar-form .medium-editor-toolbar-input::-webkit-input-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input:-moz-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input::-moz-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input:-ms-input-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form a{color:#fff}.medium-editor-toolbar-anchor-preview{background:#57ad68;color:#fff}.medium-editor-placeholder:after{color:#9ccea6} \ No newline at end of file +.medium-toolbar-arrow-under:after{border-color:#57ad68 transparent transparent transparent;top:60px}.medium-toolbar-arrow-over:before{border-color:transparent transparent #57ad68 transparent;top:-8px}.medium-editor-toolbar{background-color:#57ad68}.medium-editor-toolbar li{padding:0}.medium-editor-toolbar li button{background-color:transparent;border:none;border-right:1px solid #9ccea6;color:#fff;height:60px;min-width:60px;transition:background-color .2s ease-in,color .2s ease-in}.medium-editor-toolbar li button:hover{background-color:#346a3f;color:#fff}.medium-editor-toolbar li .medium-editor-button-active{background-color:#23482a;color:#fff}.medium-editor-toolbar li .medium-editor-button-last{border-right:none}.medium-editor-toolbar-form .medium-editor-toolbar-input{background:#57ad68;color:#fff;height:60px}.medium-editor-toolbar-form .medium-editor-toolbar-input::-webkit-input-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input:-moz-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input::-moz-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input:-ms-input-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form a{color:#fff}.medium-editor-toolbar-anchor-preview{background:#57ad68;color:#fff}.medium-editor-placeholder:after{color:#9ccea6} \ No newline at end of file diff --git a/dist/css/themes/mani.css b/dist/css/themes/mani.css index 1b1567de8..498db2ab1 100644 --- a/dist/css/themes/mani.css +++ b/dist/css/themes/mani.css @@ -3,55 +3,52 @@ display: none; } .medium-editor-toolbar { - border: 1px solid #cdd6e0; + background: linear-gradient(to top, #dee7f0, white); background-color: #dee7f0; background-color: rgba(222, 231, 240, 0.95); - background: -webkit-linear-gradient(bottom, #dee7f0, white); - background: linear-gradient(to top, #dee7f0, white); + border: 1px solid #cdd6e0; border-radius: 2px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45); } .medium-editor-toolbar li button { - min-width: 50px; - height: 50px; + background-color: transparent; border: none; border-right: 1px solid #cdd6e0; - background-color: transparent; color: #40648a; - -webkit-transition: background-color .2s ease-in, color .2s ease-in; - transition: background-color .2s ease-in, color .2s ease-in; } + height: 50px; + min-width: 50px; + transition: background-color .2s ease-in, color .2s ease-in; } .medium-editor-toolbar li button:hover { background-color: #5c90c7; background-color: rgba(92, 144, 199, 0.45); color: #fff; } .medium-editor-toolbar li .medium-editor-button-first { - border-top-left-radius: 2px; - border-bottom-left-radius: 2px; } + border-bottom-left-radius: 2px; + border-top-left-radius: 2px; } .medium-editor-toolbar li .medium-editor-button-last { - border-top-right-radius: 2px; - border-bottom-right-radius: 2px; } + border-bottom-right-radius: 2px; + border-top-right-radius: 2px; } .medium-editor-toolbar li .medium-editor-button-active { + background: linear-gradient(to bottom, #dee7f0, rgba(0, 0, 0, 0.1)); background-color: #5c90c7; background-color: rgba(92, 144, 199, 0.45); - color: #000; - background: -webkit-linear-gradient(top, #dee7f0, rgba(0, 0, 0, 0.1)); - background: linear-gradient(to bottom, #dee7f0, rgba(0, 0, 0, 0.1)); } + color: #000; } .medium-editor-toolbar-form { background: #dee7f0; - color: #999; - border-radius: 2px; } + border-radius: 2px; + color: #999; } .medium-editor-toolbar-form .medium-editor-toolbar-input { - height: 50px; background: #dee7f0; + box-sizing: border-box; color: #40648a; - box-sizing: border-box; } + height: 50px; } .medium-editor-toolbar-form a { color: #40648a; } .medium-editor-toolbar-anchor-preview { background: #dee7f0; - color: #40648a; - border-radius: 2px; } + border-radius: 2px; + color: #40648a; } .medium-editor-placeholder:after { color: #cdd6e0; } diff --git a/dist/css/themes/mani.min.css b/dist/css/themes/mani.min.css index 7a10b7a5d..3911e304a 100644 --- a/dist/css/themes/mani.min.css +++ b/dist/css/themes/mani.min.css @@ -1 +1 @@ -.medium-toolbar-arrow-over:before,.medium-toolbar-arrow-under:after{display:none}.medium-editor-toolbar{border:1px solid #cdd6e0;background-color:#dee7f0;background-color:rgba(222,231,240,.95);background:-webkit-linear-gradient(bottom,#dee7f0,#fff);background:linear-gradient(to top,#dee7f0,#fff);border-radius:2px;box-shadow:0 2px 6px rgba(0,0,0,.45)}.medium-editor-toolbar li button{min-width:50px;height:50px;border:none;border-right:1px solid #cdd6e0;background-color:transparent;color:#40648a;-webkit-transition:background-color .2s ease-in,color .2s ease-in;transition:background-color .2s ease-in,color .2s ease-in}.medium-editor-toolbar li button:hover{background-color:#5c90c7;background-color:rgba(92,144,199,.45);color:#fff}.medium-editor-toolbar li .medium-editor-button-first{border-top-left-radius:2px;border-bottom-left-radius:2px}.medium-editor-toolbar li .medium-editor-button-last{border-top-right-radius:2px;border-bottom-right-radius:2px}.medium-editor-toolbar li .medium-editor-button-active{background-color:#5c90c7;background-color:rgba(92,144,199,.45);color:#000;background:-webkit-linear-gradient(top,#dee7f0,rgba(0,0,0,.1));background:linear-gradient(to bottom,#dee7f0,rgba(0,0,0,.1))}.medium-editor-toolbar-form{background:#dee7f0;color:#999;border-radius:2px}.medium-editor-toolbar-form .medium-editor-toolbar-input{height:50px;background:#dee7f0;color:#40648a;box-sizing:border-box}.medium-editor-toolbar-form a{color:#40648a}.medium-editor-toolbar-anchor-preview{background:#dee7f0;color:#40648a;border-radius:2px}.medium-editor-placeholder:after{color:#cdd6e0} \ No newline at end of file +.medium-toolbar-arrow-over:before,.medium-toolbar-arrow-under:after{display:none}.medium-editor-toolbar{background:linear-gradient(to top,#dee7f0,#fff);background-color:#dee7f0;background-color:rgba(222,231,240,.95);border:1px solid #cdd6e0;border-radius:2px;box-shadow:0 2px 6px rgba(0,0,0,.45)}.medium-editor-toolbar li button{background-color:transparent;border:none;border-right:1px solid #cdd6e0;color:#40648a;height:50px;min-width:50px;transition:background-color .2s ease-in,color .2s ease-in}.medium-editor-toolbar li button:hover{background-color:#5c90c7;background-color:rgba(92,144,199,.45);color:#fff}.medium-editor-toolbar li .medium-editor-button-first{border-bottom-left-radius:2px;border-top-left-radius:2px}.medium-editor-toolbar li .medium-editor-button-last{border-bottom-right-radius:2px;border-top-right-radius:2px}.medium-editor-toolbar li .medium-editor-button-active{background:linear-gradient(to bottom,#dee7f0,rgba(0,0,0,.1));background-color:#5c90c7;background-color:rgba(92,144,199,.45);color:#000}.medium-editor-toolbar-form{background:#dee7f0;border-radius:2px;color:#999}.medium-editor-toolbar-form .medium-editor-toolbar-input{background:#dee7f0;box-sizing:border-box;color:#40648a;height:50px}.medium-editor-toolbar-form a{color:#40648a}.medium-editor-toolbar-anchor-preview{background:#dee7f0;border-radius:2px;color:#40648a}.medium-editor-placeholder:after{color:#cdd6e0} \ No newline at end of file diff --git a/dist/css/themes/roman.css b/dist/css/themes/roman.css index 1929119fb..136b15c00 100644 --- a/dist/css/themes/roman.css +++ b/dist/css/themes/roman.css @@ -8,51 +8,48 @@ border-radius: 5px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45); } .medium-editor-toolbar li button { - min-width: 50px; - height: 50px; + background: linear-gradient(to bottom, #fff, rgba(0, 0, 0, 0.2)); + background-color: transparent; border: none; border-right: 1px solid #a8a8a8; - background-color: transparent; - color: #889aac; box-shadow: inset 0 0 3px #f8f8e6; - background: -webkit-linear-gradient(top, #fff, rgba(0, 0, 0, 0.2)); - background: linear-gradient(to bottom, #fff, rgba(0, 0, 0, 0.2)); + color: #889aac; + height: 50px; + min-width: 50px; text-shadow: 1px 4px 6px #def, 0 0 0 #000, 1px 4px 6px #def; - -webkit-transition: background-color .2s ease-in; - transition: background-color .2s ease-in; } + transition: background-color .2s ease-in; } .medium-editor-toolbar li button:hover { background-color: #fff; color: #fff; color: rgba(0, 0, 0, 0.8); } .medium-editor-toolbar li .medium-editor-button-first { - border-top-left-radius: 5px; - border-bottom-left-radius: 5px; } + border-bottom-left-radius: 5px; + border-top-left-radius: 5px; } .medium-editor-toolbar li .medium-editor-button-last { - border-top-right-radius: 5px; - border-bottom-right-radius: 5px; } + border-bottom-right-radius: 5px; + border-top-right-radius: 5px; } .medium-editor-toolbar li .medium-editor-button-active { + background: linear-gradient(to top, #fff, rgba(0, 0, 0, 0.1)); background-color: #ccc; color: #000; - color: rgba(0, 0, 0, 0.8); - background: -webkit-linear-gradient(bottom, #fff, rgba(0, 0, 0, 0.1)); - background: linear-gradient(to top, #fff, rgba(0, 0, 0, 0.1)); } + color: rgba(0, 0, 0, 0.8); } .medium-editor-toolbar-form { background: #fff; - color: #999; - border-radius: 5px; } + border-radius: 5px; + color: #999; } .medium-editor-toolbar-form .medium-editor-toolbar-input { - margin: 0; - height: 50px; background: #fff; - color: #a8a8a8; } + color: #a8a8a8; + height: 50px; + margin: 0; } .medium-editor-toolbar-form a { color: #889aac; } .medium-editor-toolbar-anchor-preview { background: #fff; - color: #889aac; - border-radius: 5px; } + border-radius: 5px; + color: #889aac; } .medium-editor-placeholder:after { color: #a8a8a8; } diff --git a/dist/css/themes/roman.min.css b/dist/css/themes/roman.min.css index 1568f684c..ca567eeb3 100644 --- a/dist/css/themes/roman.min.css +++ b/dist/css/themes/roman.min.css @@ -1 +1 @@ -.medium-toolbar-arrow-over:before,.medium-toolbar-arrow-under:after{display:none}.medium-editor-toolbar{background-color:#fff;background-color:rgba(255,255,255,.95);border-radius:5px;box-shadow:0 2px 6px rgba(0,0,0,.45)}.medium-editor-toolbar li button{min-width:50px;height:50px;border:none;border-right:1px solid #a8a8a8;background-color:transparent;color:#889aac;box-shadow:inset 0 0 3px #f8f8e6;background:-webkit-linear-gradient(top,#fff,rgba(0,0,0,.2));background:linear-gradient(to bottom,#fff,rgba(0,0,0,.2));text-shadow:1px 4px 6px #def,0 0 0 #000,1px 4px 6px #def;-webkit-transition:background-color .2s ease-in;transition:background-color .2s ease-in}.medium-editor-toolbar li button:hover{background-color:#fff;color:#fff;color:rgba(0,0,0,.8)}.medium-editor-toolbar li .medium-editor-button-first{border-top-left-radius:5px;border-bottom-left-radius:5px}.medium-editor-toolbar li .medium-editor-button-last{border-top-right-radius:5px;border-bottom-right-radius:5px}.medium-editor-toolbar li .medium-editor-button-active{background-color:#ccc;color:#000;color:rgba(0,0,0,.8);background:-webkit-linear-gradient(bottom,#fff,rgba(0,0,0,.1));background:linear-gradient(to top,#fff,rgba(0,0,0,.1))}.medium-editor-toolbar-form{background:#fff;color:#999;border-radius:5px}.medium-editor-toolbar-form .medium-editor-toolbar-input{margin:0;height:50px;background:#fff;color:#a8a8a8}.medium-editor-toolbar-form a{color:#889aac}.medium-editor-toolbar-anchor-preview{background:#fff;color:#889aac;border-radius:5px}.medium-editor-placeholder:after{color:#a8a8a8} \ No newline at end of file +.medium-toolbar-arrow-over:before,.medium-toolbar-arrow-under:after{display:none}.medium-editor-toolbar{background-color:#fff;background-color:rgba(255,255,255,.95);border-radius:5px;box-shadow:0 2px 6px rgba(0,0,0,.45)}.medium-editor-toolbar li button{background:linear-gradient(to bottom,#fff,rgba(0,0,0,.2));background-color:transparent;border:none;border-right:1px solid #a8a8a8;box-shadow:inset 0 0 3px #f8f8e6;color:#889aac;height:50px;min-width:50px;text-shadow:1px 4px 6px #def,0 0 0 #000,1px 4px 6px #def;transition:background-color .2s ease-in}.medium-editor-toolbar li button:hover{background-color:#fff;color:#fff;color:rgba(0,0,0,.8)}.medium-editor-toolbar li .medium-editor-button-first{border-bottom-left-radius:5px;border-top-left-radius:5px}.medium-editor-toolbar li .medium-editor-button-last{border-bottom-right-radius:5px;border-top-right-radius:5px}.medium-editor-toolbar li .medium-editor-button-active{background:linear-gradient(to top,#fff,rgba(0,0,0,.1));background-color:#ccc;color:#000;color:rgba(0,0,0,.8)}.medium-editor-toolbar-form{background:#fff;border-radius:5px;color:#999}.medium-editor-toolbar-form .medium-editor-toolbar-input{background:#fff;color:#a8a8a8;height:50px;margin:0}.medium-editor-toolbar-form a{color:#889aac}.medium-editor-toolbar-anchor-preview{background:#fff;border-radius:5px;color:#889aac}.medium-editor-placeholder:after{color:#a8a8a8} \ No newline at end of file diff --git a/dist/css/themes/tim.css b/dist/css/themes/tim.css index a3576bd0f..0e122d3e6 100644 --- a/dist/css/themes/tim.css +++ b/dist/css/themes/tim.css @@ -17,8 +17,7 @@ color: #ffedd5; height: 60px; min-width: 60px; - -webkit-transition: background-color .2s ease-in, color .2s ease-in; - transition: background-color .2s ease-in, color .2s ease-in; } + transition: background-color .2s ease-in, color .2s ease-in; } .medium-editor-toolbar li button:hover { background-color: #030200; color: #ffedd5; } diff --git a/dist/css/themes/tim.min.css b/dist/css/themes/tim.min.css index 882dfe3f6..c6f62d257 100644 --- a/dist/css/themes/tim.min.css +++ b/dist/css/themes/tim.min.css @@ -1 +1 @@ -.medium-toolbar-arrow-under:after{border-color:#2f1e07 transparent transparent;top:60px}.medium-toolbar-arrow-over:before{border-color:transparent transparent #2f1e07}.medium-editor-toolbar{background-color:#2f1e07;border:1px solid #5b3a0e;border-radius:6px}.medium-editor-toolbar li button{background-color:transparent;border:none;border-right:1px solid #5b3a0e;box-sizing:border-box;color:#ffedd5;height:60px;min-width:60px;-webkit-transition:background-color .2s ease-in,color .2s ease-in;transition:background-color .2s ease-in,color .2s ease-in}.medium-editor-toolbar li .medium-editor-button-active,.medium-editor-toolbar li button:hover{background-color:#030200;color:#ffedd5}.medium-editor-toolbar li .medium-editor-button-first{border-bottom-left-radius:6px;border-top-left-radius:6px}.medium-editor-toolbar li .medium-editor-button-last{border-bottom-right-radius:6px;border-right:none;border-top-right-radius:6px}.medium-editor-toolbar-form{background:#2f1e07;border-radius:6px;color:#ffedd5}.medium-editor-toolbar-form .medium-editor-toolbar-input{background:#2f1e07;color:#ffedd5;height:60px}.medium-editor-toolbar-form .medium-editor-toolbar-input::-webkit-input-placeholder{color:#ffedd5;color:rgba(255,237,213,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input:-moz-placeholder{color:#ffedd5;color:rgba(255,237,213,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input::-moz-placeholder{color:#ffedd5;color:rgba(255,237,213,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input:-ms-input-placeholder{color:#ffedd5;color:rgba(255,237,213,.8)}.medium-editor-toolbar-form a{color:#ffedd5}.medium-editor-toolbar-anchor-preview{background:#2f1e07;border-radius:6px;color:#ffedd5}.medium-editor-placeholder:after{color:#5b3a0e} \ No newline at end of file +.medium-toolbar-arrow-under:after{border-color:#2f1e07 transparent transparent transparent;top:60px}.medium-toolbar-arrow-over:before{border-color:transparent transparent #2f1e07 transparent}.medium-editor-toolbar{background-color:#2f1e07;border:1px solid #5b3a0e;border-radius:6px}.medium-editor-toolbar li button{background-color:transparent;border:none;border-right:1px solid #5b3a0e;box-sizing:border-box;color:#ffedd5;height:60px;min-width:60px;transition:background-color .2s ease-in,color .2s ease-in}.medium-editor-toolbar li button:hover{background-color:#030200;color:#ffedd5}.medium-editor-toolbar li .medium-editor-button-first{border-bottom-left-radius:6px;border-top-left-radius:6px}.medium-editor-toolbar li .medium-editor-button-last{border-bottom-right-radius:6px;border-right:none;border-top-right-radius:6px}.medium-editor-toolbar li .medium-editor-button-active{background-color:#030200;color:#ffedd5}.medium-editor-toolbar-form{background:#2f1e07;border-radius:6px;color:#ffedd5}.medium-editor-toolbar-form .medium-editor-toolbar-input{background:#2f1e07;color:#ffedd5;height:60px}.medium-editor-toolbar-form .medium-editor-toolbar-input::-webkit-input-placeholder{color:#ffedd5;color:rgba(255,237,213,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input:-moz-placeholder{color:#ffedd5;color:rgba(255,237,213,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input::-moz-placeholder{color:#ffedd5;color:rgba(255,237,213,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input:-ms-input-placeholder{color:#ffedd5;color:rgba(255,237,213,.8)}.medium-editor-toolbar-form a{color:#ffedd5}.medium-editor-toolbar-anchor-preview{background:#2f1e07;border-radius:6px;color:#ffedd5}.medium-editor-placeholder:after{color:#5b3a0e} \ No newline at end of file diff --git a/dist/js/medium-editor.js b/dist/js/medium-editor.js index 568fa893c..1fbad845c 100644 --- a/dist/js/medium-editor.js +++ b/dist/js/medium-editor.js @@ -182,7 +182,7 @@ if (!("classList" in document.createElement("_"))) { */ /*global self, unescape */ -/*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true, +/*jslint bitwise: true, regexp: true, confusion: true, vars: true, white: true, plusplus: true */ /*! @source http://purl.eligrey.com/github/Blob.js/blob/master/Blob.js */ @@ -399,7 +399,7 @@ if (!("classList" in document.createElement("_"))) { 'use strict'; -function MediumEditor(elements, options) { +function MediumEditor (elements, options) { 'use strict'; return this.init(elements, options); } @@ -409,7 +409,7 @@ MediumEditor.extensions = {}; (function (window) { 'use strict'; - function copyInto(overwrite, dest) { + function copyInto (overwrite, dest) { var prop, sources = Array.prototype.slice.call(arguments, 2); dest = dest || {}; @@ -438,13 +438,14 @@ MediumEditor.extensions = {}; testText = document.createTextNode(' '); testParent.appendChild(testText); nodeContainsWorksWithTextNodes = testParent.contains(testText); - } catch (exc) {} + } catch (exc) { + } var Util = { // http://stackoverflow.com/questions/17907445/how-to-detect-ie11#comment30165888_17907562 // by rg89 - isIE: ((navigator.appName === 'Microsoft Internet Explorer') || ((navigator.appName === 'Netscape') && (new RegExp('Trident/.*rv:([0-9]{1,}[.0-9]{0,})').exec(navigator.userAgent) !== null))), + isIE: ((navigator.appName === 'Microsoft Internet Explorer') || ((navigator.appName === 'Netscape') && (new RegExp('Trident/.*rv:([0-9]+[.0-9]*)').exec(navigator.userAgent) !== null))), isEdge: (/Edge\/\d+/).exec(navigator.userAgent) !== null, @@ -473,11 +474,7 @@ MediumEditor.extensions = {}; * See #591 */ isMetaCtrlKey: function (event) { - if ((Util.isMac && event.metaKey) || (!Util.isMac && event.ctrlKey)) { - return true; - } - - return false; + return !!((Util.isMac && event.metaKey) || (!Util.isMac && event.ctrlKey)); }, /** @@ -494,11 +491,7 @@ MediumEditor.extensions = {}; return keyCode === keys; } - if (-1 === keys.indexOf(keyCode)) { - return false; - } - - return true; + return -1 !== keys.indexOf(keyCode); }, getKeyCode: function (event) { @@ -524,12 +517,12 @@ MediumEditor.extensions = {}; emptyElementNames: ['br', 'col', 'colgroup', 'hr', 'img', 'input', 'source', 'wbr'], - extend: function extend(/* dest, source1, source2, ...*/) { + extend: function extend (/* dest, source1, source2, ...*/) { var args = [true].concat(Array.prototype.slice.call(arguments)); return copyInto.apply(this, args); }, - defaults: function defaults(/*dest, source1, source2, ...*/) { + defaults: function defaults (/*dest, source1, source2, ...*/) { var args = [false].concat(Array.prototype.slice.call(arguments)); return copyInto.apply(this, args); }, @@ -633,12 +626,12 @@ MediumEditor.extensions = {}; var textIndexOfEndOfFarthestNode, endSplitPoint; textIndexOfEndOfFarthestNode = currentTextIndex + currentNode.nodeValue.length + - (newNode ? newNode.nodeValue.length : 0) - 1; + (newNode ? newNode.nodeValue.length : 0) - 1; endSplitPoint = matchEndIndex - currentTextIndex - - (newNode ? currentNode.nodeValue.length : 0); + (newNode ? currentNode.nodeValue.length : 0); if (textIndexOfEndOfFarthestNode >= matchEndIndex && - currentTextIndex !== textIndexOfEndOfFarthestNode && - endSplitPoint !== 0) { + currentTextIndex !== textIndexOfEndOfFarthestNode && + endSplitPoint !== 0) { (newNode || currentNode).splitText(endSplitPoint); } }, @@ -648,7 +641,7 @@ MediumEditor.extensions = {}; * 1) All text content of the elements are in separate blocks. No piece of text content should span * across multiple blocks. This means no element return by this function should have * any blocks as children. - * 2) The union of the textcontent of all of the elements returned here covers all + * 2) The union of the text content of all of the elements returned here covers all * of the text within the element. * * @@ -706,7 +699,7 @@ MediumEditor.extensions = {}; // - A descendant of a sibling element // - A sibling text node of an ancestor // - A descendant of a sibling element of an ancestor - findAdjacentTextNodeWithContent: function findAdjacentTextNodeWithContent(rootNode, targetNode, ownerDocument) { + findAdjacentTextNodeWithContent: function findAdjacentTextNodeWithContent (rootNode, targetNode, ownerDocument) { var pastTarget = false, nextNode, nodeIterator = ownerDocument.createNodeIterator(rootNode, NodeFilter.SHOW_TEXT, null, false); @@ -744,7 +737,7 @@ MediumEditor.extensions = {}; return previousSibling; }, - isDescendant: function isDescendant(parent, child, checkEquality) { + isDescendant: function isDescendant (parent, child, checkEquality) { if (!parent || !child) { return false; } @@ -769,7 +762,7 @@ MediumEditor.extensions = {}; }, // https://github.com/jashkenas/underscore - isElement: function isElement(obj) { + isElement: function isElement (obj) { return !!(obj && obj.nodeType === 1); }, @@ -861,7 +854,8 @@ MediumEditor.extensions = {}; if (!MediumEditor.util.isEdge && doc.queryCommandSupported('insertHTML')) { try { return doc.execCommand.apply(doc, ecArgs); - } catch (ignore) {} + } catch (ignore) { + } } selection = doc.getSelection(); @@ -875,13 +869,13 @@ MediumEditor.extensions = {}; if (Util.isMediumEditorElement(toReplace) && !toReplace.firstChild) { range.selectNode(toReplace.appendChild(doc.createTextNode(''))); } else if ((toReplace.nodeType === 3 && range.startOffset === 0 && range.endOffset === toReplace.nodeValue.length) || - (toReplace.nodeType !== 3 && toReplace.innerHTML === range.toString())) { + (toReplace.nodeType !== 3 && toReplace.innerHTML === range.toString())) { // Ensure range covers maximum amount of nodes as possible // By moving up the DOM and selecting ancestors whose only child is the range while (!Util.isMediumEditorElement(toReplace) && - toReplace.parentNode && - toReplace.parentNode.childNodes.length === 1 && - !Util.isMediumEditorElement(toReplace.parentNode)) { + toReplace.parentNode && + toReplace.parentNode.childNodes.length === 1 && + !Util.isMediumEditorElement(toReplace.parentNode)) { toReplace = toReplace.parentNode; } range.selectNode(toReplace); @@ -954,7 +948,7 @@ MediumEditor.extensions = {}; tagName = '<' + tagName + '>'; } - // When FF, IE and Edge, we have to handle blockquote node seperately as 'formatblock' does not work. + // When FF, IE and Edge, we have to handle blockquote node separately as 'formatblock' does not work. // https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand#Commands if (blockContainer && blockContainer.nodeName.toLowerCase() === 'blockquote') { // For IE, just use outdent @@ -1079,19 +1073,90 @@ MediumEditor.extensions = {}; return false; }, + findFirstTextNodeInSelection: function (selection) { + if (selection.anchorNode.nodeType === 3) { + return selection.anchorNode; + } + + var node = selection.anchorNode.firstChild; + + while (node) { + if (selection.containsNode(node, true)) { + if (node.nodeType === 3) { + return node; + } else { + node = node.firstChild; + } + } else { + node = node.nextSibling; + } + } + + return null; + }, + cleanListDOM: function (ownerDocument, element) { if (element.nodeName.toLowerCase() !== 'li') { - return; - } + if (this.isIE || this.isEdge) { + return; + } - var list = element.parentElement; + var selection = ownerDocument.getSelection(), + newRange = ownerDocument.createRange(), + oldRange = selection.getRangeAt(0), + startContainer = oldRange.startContainer, + startOffset = oldRange.startOffset, + endContainer = oldRange.endContainer, + endOffset = oldRange.endOffset, + node, newNode, nextNode, moveEndOffset; + + if (element.nodeName.toLowerCase() === 'span') { + // Chrome & Safari unwraps removed li elements into a span + node = element; + moveEndOffset = false; + } else { + // FF leaves them as text nodes + node = this.findFirstTextNodeInSelection(selection); + moveEndOffset = startContainer.nodeType !== 3; + } + + while (node) { + if (node.nodeName.toLowerCase() !== 'span' && node.nodeType !== 3) { + break; + } + + if (node.nextSibling && node.nextSibling.nodeName.toLowerCase() === 'br') { + node.nextSibling.remove(); - if (list.parentElement.nodeName.toLowerCase() === 'p') { // yes we need to clean up - Util.unwrap(list.parentElement, ownerDocument); + if (moveEndOffset) { + endOffset--; + } + } - // move cursor at the end of the text inside the list - // for some unknown reason, the cursor is moved to end of the "visual" line - MediumEditor.selection.moveCursor(ownerDocument, element.firstChild, element.firstChild.textContent.length); + nextNode = node.nextSibling; + + newNode = ownerDocument.createElement('p'); + node.parentNode.replaceChild(newNode, node); + newNode.appendChild(node); + + node = nextNode; + } + + // Restore selection + newRange.setStart(startContainer, startOffset); + newRange.setEnd(endContainer, endOffset); + selection.removeAllRanges(); + selection.addRange(newRange); + } else { + var list = element.parentElement; + + if (list.parentElement.nodeName.toLowerCase() === 'p') { // yes we need to clean up + Util.unwrap(list.parentElement, ownerDocument); + + // move cursor at the end of the text inside the list + // for some unknown reason, the cursor is moved to end of the "visual" line + MediumEditor.selection.moveCursor(ownerDocument, element.firstChild, element.firstChild.textContent.length); + } } }, @@ -1483,7 +1548,7 @@ MediumEditor.extensions = {}; }, guid: function () { - function _s4() { + function _s4 () { return Math .floor((1 + Math.random()) * 0x10000) .toString(16) @@ -1572,11 +1637,12 @@ MediumEditor.extensions = {}; * current instance of MediumEditor when this is called. * All helper methods will exist as well */ - init: function () {}, + init: function () { + }, /* base: [MediumEditor instance] * - * If not overriden, this will be set to the current instance + * If not overridden, this will be set to the current instance * of MediumEditor, before the init method is called */ base: undefined, @@ -1666,7 +1732,7 @@ MediumEditor.extensions = {}; /* setInactive: [function ()] * * If implemented, this function is called when MediumEditor knows - * that this extension is currently disabled. Curently, this + * that this extension is currently disabled. Currently, this * is called at the beginning of each state change for * the editor & toolbar. After calling this, MediumEditor * will attempt to update the extension, either via checkState() @@ -1697,7 +1763,7 @@ MediumEditor.extensions = {}; /* window: [Window] * - * If not overriden, this will be set to the window object + * If not overridden, this will be set to the window object * to be used by MediumEditor and its extensions. This is * passed via the 'contentWindow' option to MediumEditor * and is the global 'window' object by default @@ -1706,7 +1772,7 @@ MediumEditor.extensions = {}; /* document: [Document] * - * If not overriden, this will be set to the document object + * If not overridden, this will be set to the document object * to be used by MediumEditor and its extensions. This is * passed via the 'ownerDocument' optin to MediumEditor * and is the global 'document' object by default @@ -1773,7 +1839,7 @@ MediumEditor.extensions = {}; (function () { 'use strict'; - function filterOnlyParentElements(node) { + function filterOnlyParentElements (node) { if (MediumEditor.util.isBlockContainer(node)) { return NodeFilter.FILTER_ACCEPT; } else { @@ -1917,12 +1983,11 @@ MediumEditor.extensions = {}; if (allowRangeToStartAtEndOfNode || selectionState.start < nextCharIndex) { range.setStart(node, selectionState.start - charIndex); foundStart = true; - } - // We're at the end of a text node where the selection could start but we shouldn't - // make the selection start here because allowRangeToStartAtEndOfNode is false. - // However, we should keep a reference to this node in case there aren't any more - // text nodes after this, so that we have somewhere to import the selection to - else { + } else { + // We're at the end of a text node where the selection could start but we shouldn't + // make the selection start here because allowRangeToStartAtEndOfNode is false. + // However, we should keep a reference to this node in case there aren't any more + // text nodes after this, so that we have somewhere to import the selection to lastTextNode = node; } } @@ -1994,9 +2059,9 @@ MediumEditor.extensions = {}; return node.nodeName.toLowerCase() === 'a'; }; if (selectionState.start === selectionState.end && - range.startContainer.nodeType === 3 && - range.startOffset === range.startContainer.nodeValue.length && - MediumEditor.util.traverseUp(range.startContainer, nodeInsideAnchorTagFunction)) { + range.startContainer.nodeType === 3 && + range.startOffset === range.startContainer.nodeValue.length && + MediumEditor.util.traverseUp(range.startContainer, nodeInsideAnchorTagFunction)) { var prevNode = range.startContainer, currentNode = range.startContainer.parentNode; while (currentNode !== null && currentNode.nodeName.toLowerCase() !== 'a') { @@ -2074,7 +2139,7 @@ MediumEditor.extensions = {}; }, // Returns -1 unless the cursor is at the beginning of a paragraph/block - // If the paragraph/block is preceeded by empty paragraphs/block (with no text) + // If the paragraph/block is preceded by empty paragraphs/block (with no text) // it will return the number of empty paragraphs before the cursor. // Otherwise, it will return 0, which indicates the cursor is at the beginning // of a paragraph/block, and not at the end of the paragraph/block before it @@ -2099,9 +2164,8 @@ MediumEditor.extensions = {}; // If there is no previous sibling, this is the first text element in the editor if (!previousSibling) { return -1; - } - // If the previous sibling has text, then there are no empty blocks before this - else if (previousSibling.nodeValue) { + } else if (previousSibling.nodeValue) { + // If the previous sibling has text, then there are no empty blocks before this return -1; } } @@ -2151,7 +2215,7 @@ MediumEditor.extensions = {}; if (next === img) { break; } - // If we haven't hit the iamge, but found text that contains content + // If we haven't hit the image, but found text that contains content // then the range doesn't start with an image if (next.nodeValue) { return false; @@ -2236,7 +2300,7 @@ MediumEditor.extensions = {}; selectionContainsContent: function (doc) { var sel = doc.getSelection(); - // collapsed selection or selection withour range doesn't contain content + // collapsed selection or selection without range doesn't contain content if (!sel || sel.isCollapsed || !sel.rangeCount) { return false; } @@ -2277,7 +2341,7 @@ MediumEditor.extensions = {}; // http://stackoverflow.com/questions/4176923/html-of-selected-text // by Tim Down - getSelectionHtml: function getSelectionHtml(doc) { + getSelectionHtml: function getSelectionHtml (doc) { var i, html = '', sel = doc.getSelection(), @@ -2298,9 +2362,9 @@ MediumEditor.extensions = {}; * * @param {DOMElement} An element containing the cursor to find offsets relative to. * @param {Range} A Range representing cursor position. Will window.getSelection if none is passed. - * @return {Object} 'left' and 'right' attributes contain offsets from begining and end of Element + * @return {Object} 'left' and 'right' attributes contain offsets from beginning and end of Element */ - getCaretOffsets: function getCaretOffsets(element, range) { + getCaretOffsets: function getCaretOffsets (element, range) { var preCaretRange, postCaretRange; if (!range) { @@ -2451,7 +2515,7 @@ MediumEditor.extensions = {}; (function () { 'use strict'; - function isElementDescendantOfExtension(extensions, element) { + function isElementDescendantOfExtension (extensions, element) { if (!extensions) { return false; } @@ -2676,17 +2740,17 @@ MediumEditor.extensions = {}; // Helper method to call all listeners to execCommand var callListeners = function (args, result) { - if (doc.execCommand.listeners) { - doc.execCommand.listeners.forEach(function (listener) { - listener({ - command: args[0], - value: args[2], - args: args, - result: result + if (doc.execCommand.listeners) { + doc.execCommand.listeners.forEach(function (listener) { + listener({ + command: args[0], + value: args[2], + args: args, + result: result + }); }); - }); - } - }, + } + }, // Create a wrapper method for execCommand which will: // 1) Call document.execCommand with the correct arguments @@ -2916,7 +2980,7 @@ MediumEditor.extensions = {}; if (!this.contentCache) { return; } - // An event triggered which signifies that the user may have changed someting + // An event triggered which signifies that the user may have changed something // Look in our cache of input for the contenteditables to see if something changed var index = target.getAttribute('medium-editor-index'), html = target.innerHTML; @@ -3593,7 +3657,7 @@ MediumEditor.extensions = {}; return false; }, - /* hideForm: [function ()] + /* showForm: [function ()] * * This function should show the form element inside * the toolbar container @@ -3772,7 +3836,7 @@ MediumEditor.extensions = {}; if (this.targetCheckbox) { // fixme: ideally, this targetCheckboxText would be a formLabel too, - // figure out how to deprecate? also consider `fa-` icon default implcations. + // figure out how to deprecate? also consider `fa-` icon default implications. template.push( '