├── .babelrc ├── .eslintrc.js ├── .gitignore ├── .npmignore ├── README.md ├── demo ├── App.vue ├── cards │ └── Test.vue ├── components │ └── ToggleButton.vue ├── index.html └── main.js ├── index.html ├── package-lock.json ├── package.json ├── src ├── MobiledocButton.js ├── MobiledocEditor.vue ├── addons │ ├── MobiledocToolbar.js │ └── compToCard.js ├── helpers │ ├── mobiledocFormats.js │ └── titlelize.js └── index.js ├── test ├── e2e │ ├── custom-assertions │ │ └── elementCount.js │ ├── nightwatch.conf.js │ ├── runner.js │ └── specs │ │ └── test.js └── unit │ ├── .eslintrc │ ├── coverage │ ├── PhantomJS 2.1.1 (Mac OS X 0.0.0) │ │ ├── base.css │ │ ├── index.html │ │ ├── prettify.css │ │ ├── prettify.js │ │ ├── sort-arrow-sprite.png │ │ └── sorter.js │ ├── lcov-report │ │ ├── base.css │ │ ├── components │ │ │ ├── MobiledocEditor.vue.html │ │ │ └── index.html │ │ ├── index.html │ │ ├── prettify.css │ │ ├── prettify.js │ │ ├── sort-arrow-sprite.png │ │ ├── sorter.js │ │ └── src │ │ │ ├── App.vue.html │ │ │ ├── Main.vue.html │ │ │ ├── components │ │ │ ├── MobiledocButton.vue.html │ │ │ ├── MobiledocEditor.vue.html │ │ │ ├── MobiledocLinkButton.vue.html │ │ │ ├── MobiledocMarkupButton.vue.html │ │ │ ├── MobiledocSectionButton.vue.html │ │ │ └── index.html │ │ │ ├── dev.js.html │ │ │ ├── index.html │ │ │ ├── index.js.html │ │ │ └── utils │ │ │ ├── index.html │ │ │ └── titlelize.js.html │ └── lcov.info │ ├── index.js │ ├── karma.conf.js │ └── specs │ ├── MobiledocButton.spec.js │ ├── MobiledocController.spec.js │ └── MobiledocEditor.spec.js └── webpack.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["es2015", { "modules": false }], 4 | "stage-2" 5 | ], 6 | "plugins": ["transform-runtime", "transform-vue-jsx"], 7 | "comments": false 8 | } 9 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: 'babel-eslint', 4 | env: { 5 | browser: true, 6 | node: true 7 | }, 8 | extends: 'vue', 9 | // required to lint *.vue files 10 | plugins: [ 11 | 'html' 12 | ], 13 | // add your custom rules here 14 | rules: {}, 15 | globals: {} 16 | } 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .git 3 | node_modules/ 4 | dist/ 5 | npm-debug.log 6 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .babelrc 2 | webpack.config.js 3 | demo/ 4 | test/ 5 | src/ 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vue Mobiledoc Editor 2 | 3 | A Mobiledoc editor written using Vue and [Mobiledoc Kit](https://github.com/bustlelabs/mobiledoc-kit). 4 | 5 | ### Installation 6 | 7 | ``` 8 | npm install vue-mobiledoc-editor 9 | ``` 10 | 11 | The `vue-mobiledoc-editor` will install the `mobiledoc-kit` package as a dependency and load its assets. 12 | 13 | ### Basic Usage 14 | 15 | This package is composed of two main components: 16 | 17 | * `MobiledocEditor` 18 | * `MobiledocButton` 19 | 20 | Additionally, you can use the following addons: 21 | * `MobiledocToolbar` (component) 22 | * `compToCard` (factory function) 23 | 24 | 25 | The most basic usage with an empty editor and a standard toolbar is: 26 | 27 | ``` 28 | // template 29 | 30 | 31 | 32 | 33 | // script 34 | import Mobiledoc, { MobiledocToolbar } from "vue-mobiledoc-editor" 35 | 36 | export default { 37 | components: { 38 | Editor: Mobiledoc.Editor, 39 | Toolbar: MobiledocToolbar 40 | } 41 | } 42 | 43 | ``` 44 | 45 | You can check out the live `mobiledoc-kit` [demo](https://bustle.github.io/mobiledoc-kit/demo/) or clone the repo and run `npm run dev` for a more interactive example. 46 | 47 | Read on for how to provide custom configurations to each component. 48 | 49 | #### Mobiledoc Editor 50 | 51 | The mobiledoc editor is a component that accepts these Mobiledoc-specific props: 52 | 53 | * `mobiledoc`, a Mobiledoc to be edited. (*The package also exports an `EMPTY_MOBILEDOC` template that you can use as a default when passing a `mobiledoc` payload to the editor.*) 54 | 55 | * `atoms`, an array of available atoms for use by the editor. 56 | 57 | * `cards`, an array of available cards for use by the editor. (Jump to the section on Card-based components for details on how to create cards as Vue components.) 58 | 59 | * `cardOptions`, an object of additional props to pass to rendered cards. 60 | 61 | * `spellcheck`, a boolean. Defaults to true. 62 | 63 | * `autofocus`, a boolean. Defaults to true. 64 | 65 | * `placeholder`, a string to use as the placeholder text when the mobiledoc is blank. 66 | 67 | * `serializeVersion`, a string representing the mobiledoc version to serialize to when firing the `postWasUpdated` action. Defaults to 0.3.0. 68 | 69 | * 'enableEditing', a boolean that represents whether the editor is rendered in display or edit mode. 70 | 71 | Additionally, it can emit the following events: 72 | 73 | * `willCreateEditor`, a callback that fires when the Mobiledoc editor instance is about to be created. Takes no arguments. 74 | 75 | * `didCreateEditor`, a callback that fires once the Mobiledoc editor instance has been created. Will be called with the editor instance and may be used to configure it further. 76 | 77 | * `postWasUpdated`, a callback that will fire whenever the underlying document changes. It is called with the serialized mobiledoc. 78 | 79 | (*Note: For placeholder and other mobiledoc-related styles to work, you must import/copy mobiledoc-kit's [default CSS](https://github.com/bustle/mobiledoc-kit/blob/master/src/css/mobiledoc-kit.css) file yourself.*) 80 | 81 | Example usage: 82 | 83 | ``` 84 | 87 | 88 | ``` 89 | 90 | The editor has the following `refs` and `slots` available: 91 | 92 | ```HTML 93 | 94 | 95 | 96 |
97 | 98 | 99 | ``` 100 | 101 | You can further manipulate the editor's post element (e.g. for styling) by using `$refs.editorPost`; or you can grab the editor instance directly using the `didCreateEditor` hook. 102 | 103 | Using `provide/inject`, the Editor also provides the `editorVm` to all child components. The `editorVM` has the following data and methods: 104 | 105 | * `editor`, a function that returns the Mobiledoc editor instance itself 106 | 107 | * `activeSectionTags`, an object with true values for section tag names in the current selection. For example activeSectionTagNames.isH1. 108 | 109 | * `activeMarkupTags`, an object with true values for markup tag names in the current selection. For example activeMarkupTagNames.isStrong 110 | 111 | * `canEdit`, a function that returns a boolean stating whether editing is currently enabled or disabled. 112 | 113 | * `toggleMarkup`, toggles the passed markup tag name in the current selection. 114 | 115 | * `toggleSection`, toggles the passed section tag name in the current selection. 116 | 117 | * `toggleLink`, toggles the linking of a selection. The user will be prompted for a URL if required. 118 | 119 | * `addAtom`, passed an atom `name`, `text`, and `payload`, will add that atom at the cursor position. 120 | 121 | * `addCard`, passed a card `name`, `payload`, and `editMode` will add that card at the end of a post and render it in the specified mode initially. 122 | 123 | * `toggleEditMode`, updates the `canEdit` state and toggles the edit mode of the mobiledoc editor. 124 | 125 | You can use the `MobiledocEditor.editor` instance itself to take full advantage of the features in the [mobiledoc-kit API documentation](http://bustlelabs.github.io/mobiledoc-kit/demo/docs/). 126 | 127 | 128 | #### Mobiledoc Button 129 | 130 | The `MobiledocButton` is a functional component that delegates the passed `props` to the appropriate button. Because of this, *every button requires* the `type` prop. Any additional props depend on the type of button. 131 | 132 | There are five types of buttons: 133 | 134 | * `MarkupButton`, requires a `tag` prop to identify the type of markup to toggle. 135 | 136 | * `SectionButton`, requires a `tag` prop to identify the type of section to toggle. 137 | 138 | * `LinkButton`, accepts an optional `prompt` prop that you can pass if you wish to provide a custom dialog that the user will shown when prompted input the link. 139 | 140 | * `AtomButton`, requires a `name` prop to identify the atom that will be added to the end of the post and accepts an optional `text` and `payload` prop. 141 | 142 | * `CardButton`, requires a `name` prop to identify the card that will be added to the end of the post and accepts an optional `payload` and `mode` prop. There are two `mode` options, `edit` or `display`; the default is `display`. 143 | 144 | Additionally, all buttons accept a`label` prop, to set the content of the button when used as a blockless component. 145 | 146 | Example usage: 147 | 148 | ``` 149 | 150 | ``` 151 | 152 | #### Mobiledoc Toolbar 153 | 154 | The component creates a standard toolbar for the mobiledoc editor. 155 | 156 | Example usage: 157 | 158 | ``` 159 | 160 | ``` 161 | 162 | ### Advanced Usage 163 | 164 | #### Component Cards 165 | 166 | Mobiledoc supports "cards", blocks of rich content that are embedded into a post. 167 | 168 | `vue-mobiledoc-editor` comes with a helper for using your own Vue components as the display and edit modes of a card. 169 | 170 | The card's properties are passed as props to the component. You can use them like this: 171 | 172 | ``` 173 | // components/cards/example.vue 174 | 175 | 180 | 181 | 192 | 193 | ``` 194 | Then, to use the component as a card, wrap your own component in the `compToCard` 195 | serializer function, before passing it to the editor as a card option: 196 | 197 | ``` 198 | // components/editor.js 199 | 206 | 207 | 223 | ``` 224 | 225 | Please note that your card must have a name to identify it. So if your component does not have a name, you'll need to provide your own to the serializer function: `compToCard(NamelessComponent, 'MyCardName')`. 226 | 227 | The following mobiledoc-specific properties are passed to the component: 228 | 229 | - `env`, an object of that holds environment-specific properties 230 | - `payload`, an object that holds the data payload retrieved from the mobiledoc for this card 231 | 232 | For more details on the API for authoring cards in vanilla JavaScript, as welll as the `env` properties available to the card, see [CARDS.md](https://github.com/bustlelabs/mobiledoc-kit/blob/master/CARDS.md). 233 | 234 | #### Creating custom mobiledoc components 235 | 236 | To create components that control the mobiledoc editor, just inject the `editorVm` to child components. 237 | 238 | For example, you can create a button that toggles whether the editor is editable or not: 239 | 240 | ``` 241 | export default { 242 | inject: ['editorVm'] 243 | render(h) { 244 | const { canEdit, toggleEditMode } = this.editorVm 245 | return h( 246 | 249 | ) 250 | } 251 | } 252 | ``` 253 | 254 | *Note: Mobiledoc components must be nested under the Mobiledoc `Editor`.* 255 | 256 | ## Development 257 | 258 | To get started: 259 | 260 | * `git clone` this repository 261 | 262 | * `npm install` 263 | 264 | 265 | Run the development server: 266 | 267 | A development server is available under the `/demo` directory. You can check out the demo for an example of basic usage or to interactively test your contribution. 268 | 269 | * `npm run dev` from project root 270 | 271 | * Visit your app at `http://localhost:8080`. 272 | 273 | 274 | Run tests: 275 | 276 | * `npm run unit` 277 | 278 | 279 | Build to `dist/`: 280 | 281 | * `npm run build` 282 | 283 | 284 | #### Getting Help 285 | 286 | If you'd like to report a bug or request a feature, please [open an issue](https://github.com/studbits/vue-mobiledoc-editor/issues). 287 | -------------------------------------------------------------------------------- /demo/App.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 24 | 73 | -------------------------------------------------------------------------------- /demo/cards/Test.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 26 | -------------------------------------------------------------------------------- /demo/components/ToggleButton.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 16 | -------------------------------------------------------------------------------- /demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | vue-mobiledoc-editor 6 | 7 | 8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /demo/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App' 3 | 4 | /* eslint-disable no-new */ 5 | new Vue({ 6 | el: '#app', 7 | ...App 8 | }) 9 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | vue-mobiledoc-editor 6 | 7 | 8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-mobiledoc-editor", 3 | "description": "a vuejs mobiledoc editor", 4 | "version": "1.2.21", 5 | "author": "Alid Castano ", 6 | "module": "dist/build.js", 7 | "main": "dist/build.js", 8 | "scripts": { 9 | "purge": "rm -rf dist/", 10 | "bundle": "cross-env NODE_ENV=production webpack --progress --hide-modules", 11 | "dev": "cross-env NODE_ENV=development webpack-dev-server --inline --hot", 12 | "unit": "cross-env NODE_ENV=testing karma start test/unit/karma.conf.js", 13 | "build": "npm run purge && npm run bundle", 14 | "bump": "npm --no-git-tag-version version patch && npm run build && npm publish" 15 | }, 16 | "dependencies": { 17 | "mobiledoc-kit": "0.10.15", 18 | "vue": "^2.3.4" 19 | }, 20 | "devDependencies": { 21 | "babel-core": "^6.0.0", 22 | "babel-eslint": "^7.2.3", 23 | "babel-helper-vue-jsx-merge-props": "^2.0.2", 24 | "babel-loader": "^6.0.0", 25 | "babel-plugin-syntax-jsx": "^6.18.0", 26 | "babel-plugin-transform-runtime": "^6.15.0", 27 | "babel-plugin-transform-vue-jsx": "^3.2.0", 28 | "babel-preset-es2015": "^6.0.0", 29 | "babel-preset-stage-2": "^6.18.0", 30 | "chai": "^3.5.0", 31 | "copy-webpack-plugin": "^4.0.1", 32 | "cross-env": "^3.0.0", 33 | "css-loader": "^0.25.0", 34 | "eslint": "^4.1.1", 35 | "eslint-config-vue": "^2.0.2", 36 | "eslint-loader": "^1.8.0", 37 | "eslint-plugin-html": "^3.0.0", 38 | "eslint-plugin-vue": "^2.1.0", 39 | "extract-text-webpack-plugin": "^3.0.0", 40 | "file-loader": "^0.9.0", 41 | "html-webpack-plugin": "^2.24.1", 42 | "isparta-loader": "^2.0.0", 43 | "karma": "1.3.0", 44 | "karma-coverage": "1.1.1", 45 | "karma-mocha": "1.2.0", 46 | "karma-phantomjs-launcher": "1.0.2", 47 | "karma-sinon-chai": "1.2.0", 48 | "karma-sourcemap-loader": "0.3.7", 49 | "karma-spec-reporter": "0.0.26", 50 | "karma-webpack": "1.7.0", 51 | "mocha": "^3.2.0", 52 | "sinon": "^1.17.3", 53 | "sinon-chai": "^2.8.0", 54 | "vue-loader": "^10.0.0", 55 | "vue-template-compiler": "^2.3.4", 56 | "webpack": "2.2.0-rc.2", 57 | "webpack-dev-server": "2.1.0-beta.9", 58 | "webpack-merge": "1.1.2" 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/MobiledocButton.js: -------------------------------------------------------------------------------- 1 | import titlelize from './helpers/titlelize' 2 | 3 | const button = (h, ctx, clickAction) => { 4 | return ( 5 | 12 | ) 13 | } 14 | 15 | export default { 16 | props: { 17 | // all buttons 18 | type: { type: String, required: true }, 19 | label: { type: String }, 20 | // markup or section buttons 21 | tag: { type: String }, 22 | // link buttons 23 | prompt: { type: Object }, 24 | // atom or card buttons 25 | name: { type: String }, 26 | text: { type: String, default: () => '' }, 27 | payload: { type: Object, default: () => {} }, 28 | // card buttons 29 | editMode: { type: Boolean, default: () => true } 30 | }, 31 | 32 | inject: ['editorVm'], 33 | 34 | render (h) { 35 | const editorVm = this.editorVm 36 | const type = titlelize(this.type) 37 | if (type === 'Markup') { 38 | if (!this.tag) throw new Error(`Markup buttons require a 'tag' prop`) 39 | return button(h, this, () => editorVm.toggleMarkup(this.tag)) 40 | } else if (type === 'Section') { 41 | if (!this.tag) throw new Error(`Section buttons require a 'tag' prop`) 42 | return button(h, this, () => editorVm.toggleSection(this.tag)) 43 | } else if (type === 'Link') { 44 | return button(h, this, () => editorVm.toggleLink()) 45 | } else if (type === 'Atom') { 46 | if (!this.name) throw new Error(`Atom buttons require a 'name' prop`) 47 | const { name, text, payload } = this 48 | return button(h, this, () => editorVm.addAtom(name, text, payload)) 49 | } else if (type === 'Card') { 50 | if (!this.name) throw new Error(`Card buttons require a 'name' prop`) 51 | const { name, payload, editMode } = this 52 | return button(h, this, () => editorVm.addCard(name, payload, editMode)) 53 | } else throw new Error(`The button ${type} does not exist`) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/MobiledocEditor.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /src/addons/MobiledocToolbar.js: -------------------------------------------------------------------------------- 1 | import MobiledocButton from '../MobiledocButton' 2 | 3 | export default { 4 | functional: true, 5 | 6 | render (h) { 7 | return ( 8 |
9 | B 10 | I 11 | Link 12 | H1 13 | H2 14 | UL 15 | OL 16 | Blockquote 17 | Pullquote 18 | 19 |
20 | ) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/addons/compToCard.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | function renderCard (comp, isEditing = false) { 4 | const CompCard = Vue.extend(comp) 5 | 6 | return function createCard ({ env, options, payload }) { 7 | const targetNode = document.createElement('div') 8 | 9 | let cardVm 10 | env.didRender(() => { 11 | payload = { ...payload } // copy payload 12 | 13 | const propsData = { env, payload, options, isEditing } 14 | 15 | cardVm = new CompCard({ propsData }).$mount() 16 | targetNode.appendChild(cardVm.$el) 17 | }) 18 | 19 | env.onTeardown(() => { 20 | // target node is auto destroyed; we only need to clean up comp instance 21 | cardVm.$destroy() 22 | }) 23 | 24 | return targetNode 25 | } 26 | } 27 | 28 | export default function compToCard (component, name) { 29 | if (!name && typeof component.name === 'undefined') { 30 | throw new Error("Can't create card, no name defined: " + component) 31 | } 32 | 33 | return { 34 | name: name || component.name, 35 | type: 'dom', 36 | component, 37 | render: renderCard(component), 38 | edit: renderCard(component, true) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/helpers/mobiledocFormats.js: -------------------------------------------------------------------------------- 1 | export const EMPTY_MOBILEDOC = { 2 | version: '0.3.0', 3 | markups: [], 4 | atoms: [], 5 | cards: [], 6 | sections: [] 7 | } 8 | -------------------------------------------------------------------------------- /src/helpers/titlelize.js: -------------------------------------------------------------------------------- 1 | export function capitalize (str) { 2 | return str.charAt(0).toUpperCase() + str.slice(1) 3 | } 4 | 5 | export function camelize (str) { 6 | return str.replace(/\W+(.)/g, function (match, chr) { 7 | return chr.toUpperCase() 8 | }) 9 | } 10 | 11 | export default function (str) { 12 | return capitalize(camelize(str)) 13 | } 14 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import MobiledocEditor from 'MobiledocEditor' 2 | import MobiledocButton from 'MobiledocButton' 3 | import MobiledocToolbar from 'addons/MobiledocToolbar' 4 | import compToCard from 'addons/compToCard' 5 | import { EMPTY_MOBILEDOC } from './helpers/mobiledocFormats' 6 | 7 | export { 8 | MobiledocEditor, 9 | MobiledocButton, 10 | MobiledocToolbar, 11 | compToCard, 12 | EMPTY_MOBILEDOC 13 | } 14 | 15 | export default { 16 | Editor: MobiledocEditor, 17 | Button: MobiledocButton 18 | } 19 | -------------------------------------------------------------------------------- /test/e2e/custom-assertions/elementCount.js: -------------------------------------------------------------------------------- 1 | // A custom Nightwatch assertion. 2 | // the name of the method is the filename. 3 | // can be used in tests like this: 4 | // 5 | // browser.assert.elementCount(selector, count) 6 | // 7 | // for how to write custom assertions see 8 | // http://nightwatchjs.org/guide#writing-custom-assertions 9 | exports.assertion = function (selector, count) { 10 | this.message = 'Testing if element <' + selector + '> has count: ' + count 11 | this.expected = count 12 | this.pass = function (val) { 13 | return val === this.expected 14 | } 15 | this.value = function (res) { 16 | return res.value 17 | } 18 | this.command = function (cb) { 19 | var self = this 20 | return this.api.execute(function (selector) { 21 | return document.querySelectorAll(selector).length 22 | }, [selector], function (res) { 23 | cb.call(self, res) 24 | }) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/e2e/nightwatch.conf.js: -------------------------------------------------------------------------------- 1 | require('babel-register') 2 | var config = require('../../config') 3 | 4 | // http://nightwatchjs.org/guide#settings-file 5 | module.exports = { 6 | src_folders: ['test/e2e/specs'], 7 | output_folder: 'test/e2e/reports', 8 | custom_assertions_path: ['test/e2e/custom-assertions'], 9 | 10 | selenium: { 11 | start_process: true, 12 | server_path: 'node_modules/selenium-server/lib/runner/selenium-server-standalone-2.53.1.jar', 13 | host: '127.0.0.1', 14 | port: 4444, 15 | cli_args: { 16 | 'webdriver.chrome.driver': require('chromedriver').path 17 | } 18 | }, 19 | 20 | test_settings: { 21 | default: { 22 | selenium_port: 4444, 23 | selenium_host: 'localhost', 24 | silent: true, 25 | globals: { 26 | devServerURL: 'http://localhost:' + (process.env.PORT || config.dev.port) 27 | } 28 | }, 29 | 30 | chrome: { 31 | desiredCapabilities: { 32 | browserName: 'chrome', 33 | javascriptEnabled: true, 34 | acceptSslCerts: true 35 | } 36 | }, 37 | 38 | firefox: { 39 | desiredCapabilities: { 40 | browserName: 'firefox', 41 | javascriptEnabled: true, 42 | acceptSslCerts: true 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /test/e2e/runner.js: -------------------------------------------------------------------------------- 1 | // 1. start the dev server using production config 2 | process.env.NODE_ENV = 'testing' 3 | var server = require('../../build/dev-server.js') 4 | 5 | var opts = process.argv.slice(2) 6 | if (opts.indexOf('--config') === -1) { 7 | opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js']) 8 | } 9 | if (opts.indexOf('--env') === -1) { 10 | opts = opts.concat(['--env', 'chrome']) 11 | } 12 | 13 | var spawn = require('cross-spawn') 14 | var runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' }) 15 | 16 | runner.on('exit', function (code) { 17 | server.close() 18 | process.exit(code) 19 | 20 | runner.on('error', function (err) { 21 | server.close() 22 | throw err 23 | }) 24 | -------------------------------------------------------------------------------- /test/e2e/specs/test.js: -------------------------------------------------------------------------------- 1 | // For authoring Nightwatch tests, see 2 | // http://nightwatchjs.org/guide#usage 3 | 4 | module.exports = { 5 | 'default e2e tests': function(browser) { 6 | // automatically uses dev Server port from /config.index.js 7 | // default: http://localhost:8080 8 | // see nightwatch.conf.js 9 | const devServer = browser.globals.devServerURL 10 | 11 | browser 12 | .url(devServer) 13 | .waitForElementVisible('#app', 5000) 14 | .assert.elementPresent('.hello') 15 | .assert.containsText('h1', 'Welcome to Your Vue.js App') 16 | .assert.elementCount('img', 1) 17 | .end() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/unit/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "mocha": true 5 | }, 6 | "globals": { 7 | "expect": true, 8 | "sinon": true 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/unit/coverage/PhantomJS 2.1.1 (Mac OS X 0.0.0)/base.css: -------------------------------------------------------------------------------- 1 | body, html { 2 | margin:0; padding: 0; 3 | height: 100%; 4 | } 5 | body { 6 | font-family: Helvetica Neue, Helvetica, Arial; 7 | font-size: 14px; 8 | color:#333; 9 | } 10 | .small { font-size: 12px; } 11 | *, *:after, *:before { 12 | -webkit-box-sizing:border-box; 13 | -moz-box-sizing:border-box; 14 | box-sizing:border-box; 15 | } 16 | h1 { font-size: 20px; margin: 0;} 17 | h2 { font-size: 14px; } 18 | pre { 19 | font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; 20 | margin: 0; 21 | padding: 0; 22 | -moz-tab-size: 2; 23 | -o-tab-size: 2; 24 | tab-size: 2; 25 | } 26 | a { color:#0074D9; text-decoration:none; } 27 | a:hover { text-decoration:underline; } 28 | .strong { font-weight: bold; } 29 | .space-top1 { padding: 10px 0 0 0; } 30 | .pad2y { padding: 20px 0; } 31 | .pad1y { padding: 10px 0; } 32 | .pad2x { padding: 0 20px; } 33 | .pad2 { padding: 20px; } 34 | .pad1 { padding: 10px; } 35 | .space-left2 { padding-left:55px; } 36 | .space-right2 { padding-right:20px; } 37 | .center { text-align:center; } 38 | .clearfix { display:block; } 39 | .clearfix:after { 40 | content:''; 41 | display:block; 42 | height:0; 43 | clear:both; 44 | visibility:hidden; 45 | } 46 | .fl { float: left; } 47 | @media only screen and (max-width:640px) { 48 | .col3 { width:100%; max-width:100%; } 49 | .hide-mobile { display:none!important; } 50 | } 51 | 52 | .quiet { 53 | color: #7f7f7f; 54 | color: rgba(0,0,0,0.5); 55 | } 56 | .quiet a { opacity: 0.7; } 57 | 58 | .fraction { 59 | font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; 60 | font-size: 10px; 61 | color: #555; 62 | background: #E8E8E8; 63 | padding: 4px 5px; 64 | border-radius: 3px; 65 | vertical-align: middle; 66 | } 67 | 68 | div.path a:link, div.path a:visited { color: #333; } 69 | table.coverage { 70 | border-collapse: collapse; 71 | margin: 10px 0 0 0; 72 | padding: 0; 73 | } 74 | 75 | table.coverage td { 76 | margin: 0; 77 | padding: 0; 78 | vertical-align: top; 79 | } 80 | table.coverage td.line-count { 81 | text-align: right; 82 | padding: 0 5px 0 20px; 83 | } 84 | table.coverage td.line-coverage { 85 | text-align: right; 86 | padding-right: 10px; 87 | min-width:20px; 88 | } 89 | 90 | table.coverage td span.cline-any { 91 | display: inline-block; 92 | padding: 0 5px; 93 | width: 100%; 94 | } 95 | .missing-if-branch { 96 | display: inline-block; 97 | margin-right: 5px; 98 | border-radius: 3px; 99 | position: relative; 100 | padding: 0 4px; 101 | background: #333; 102 | color: yellow; 103 | } 104 | 105 | .skip-if-branch { 106 | display: none; 107 | margin-right: 10px; 108 | position: relative; 109 | padding: 0 4px; 110 | background: #ccc; 111 | color: white; 112 | } 113 | .missing-if-branch .typ, .skip-if-branch .typ { 114 | color: inherit !important; 115 | } 116 | .coverage-summary { 117 | border-collapse: collapse; 118 | width: 100%; 119 | } 120 | .coverage-summary tr { border-bottom: 1px solid #bbb; } 121 | .keyline-all { border: 1px solid #ddd; } 122 | .coverage-summary td, .coverage-summary th { padding: 10px; } 123 | .coverage-summary tbody { border: 1px solid #bbb; } 124 | .coverage-summary td { border-right: 1px solid #bbb; } 125 | .coverage-summary td:last-child { border-right: none; } 126 | .coverage-summary th { 127 | text-align: left; 128 | font-weight: normal; 129 | white-space: nowrap; 130 | } 131 | .coverage-summary th.file { border-right: none !important; } 132 | .coverage-summary th.pct { } 133 | .coverage-summary th.pic, 134 | .coverage-summary th.abs, 135 | .coverage-summary td.pct, 136 | .coverage-summary td.abs { text-align: right; } 137 | .coverage-summary td.file { white-space: nowrap; } 138 | .coverage-summary td.pic { min-width: 120px !important; } 139 | .coverage-summary tfoot td { } 140 | 141 | .coverage-summary .sorter { 142 | height: 10px; 143 | width: 7px; 144 | display: inline-block; 145 | margin-left: 0.5em; 146 | background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; 147 | } 148 | .coverage-summary .sorted .sorter { 149 | background-position: 0 -20px; 150 | } 151 | .coverage-summary .sorted-desc .sorter { 152 | background-position: 0 -10px; 153 | } 154 | .status-line { height: 10px; } 155 | /* dark red */ 156 | .red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } 157 | .low .chart { border:1px solid #C21F39 } 158 | /* medium red */ 159 | .cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } 160 | /* light red */ 161 | .low, .cline-no { background:#FCE1E5 } 162 | /* light green */ 163 | .high, .cline-yes { background:rgb(230,245,208) } 164 | /* medium green */ 165 | .cstat-yes { background:rgb(161,215,106) } 166 | /* dark green */ 167 | .status-line.high, .high .cover-fill { background:rgb(77,146,33) } 168 | .high .chart { border:1px solid rgb(77,146,33) } 169 | /* dark yellow (gold) */ 170 | .medium .chart { border:1px solid #f9cd0b; } 171 | .status-line.medium, .medium .cover-fill { background: #f9cd0b; } 172 | /* light yellow */ 173 | .medium { background: #fff4c2; } 174 | /* light gray */ 175 | span.cline-neutral { background: #eaeaea; } 176 | 177 | .cbranch-no { background: yellow !important; color: #111; } 178 | 179 | .cstat-skip { background: #ddd; color: #111; } 180 | .fstat-skip { background: #ddd; color: #111 !important; } 181 | .cbranch-skip { background: #ddd !important; color: #111; } 182 | 183 | 184 | .cover-fill, .cover-empty { 185 | display:inline-block; 186 | height: 12px; 187 | } 188 | .chart { 189 | line-height: 0; 190 | } 191 | .cover-empty { 192 | background: white; 193 | } 194 | .cover-full { 195 | border-right: none !important; 196 | } 197 | pre.prettyprint { 198 | border: none !important; 199 | padding: 0 !important; 200 | margin: 0 !important; 201 | } 202 | .com { color: #999 !important; } 203 | .ignore-none { color: #999; font-weight: normal; } 204 | 205 | .wrapper { 206 | min-height: 100%; 207 | height: auto !important; 208 | height: 100%; 209 | margin: 0 auto -48px; 210 | } 211 | .footer, .push { 212 | height: 48px; 213 | } 214 | -------------------------------------------------------------------------------- /test/unit/coverage/PhantomJS 2.1.1 (Mac OS X 0.0.0)/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for All files 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | / 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 0/0 26 |
27 |
28 | 100% 29 | Branches 30 | 0/0 31 |
32 |
33 | 100% 34 | Functions 35 | 0/0 36 |
37 |
38 | 100% 39 | Lines 40 | 0/0 41 |
42 |
43 |
44 |
45 |
46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 |
FileStatementsBranchesFunctionsLines
63 |
64 |
65 | 69 |
70 | 71 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /test/unit/coverage/PhantomJS 2.1.1 (Mac OS X 0.0.0)/prettify.css: -------------------------------------------------------------------------------- 1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} 2 | -------------------------------------------------------------------------------- /test/unit/coverage/PhantomJS 2.1.1 (Mac OS X 0.0.0)/prettify.js: -------------------------------------------------------------------------------- 1 | window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); 2 | -------------------------------------------------------------------------------- /test/unit/coverage/PhantomJS 2.1.1 (Mac OS X 0.0.0)/sort-arrow-sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alidcast/vue-mobiledoc-editor/0a6123871430bc6640e8343d96937445eeb69691/test/unit/coverage/PhantomJS 2.1.1 (Mac OS X 0.0.0)/sort-arrow-sprite.png -------------------------------------------------------------------------------- /test/unit/coverage/PhantomJS 2.1.1 (Mac OS X 0.0.0)/sorter.js: -------------------------------------------------------------------------------- 1 | var addSorting = (function () { 2 | "use strict"; 3 | var cols, 4 | currentSort = { 5 | index: 0, 6 | desc: false 7 | }; 8 | 9 | // returns the summary table element 10 | function getTable() { return document.querySelector('.coverage-summary'); } 11 | // returns the thead element of the summary table 12 | function getTableHeader() { return getTable().querySelector('thead tr'); } 13 | // returns the tbody element of the summary table 14 | function getTableBody() { return getTable().querySelector('tbody'); } 15 | // returns the th element for nth column 16 | function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; } 17 | 18 | // loads all columns 19 | function loadColumns() { 20 | var colNodes = getTableHeader().querySelectorAll('th'), 21 | colNode, 22 | cols = [], 23 | col, 24 | i; 25 | 26 | for (i = 0; i < colNodes.length; i += 1) { 27 | colNode = colNodes[i]; 28 | col = { 29 | key: colNode.getAttribute('data-col'), 30 | sortable: !colNode.getAttribute('data-nosort'), 31 | type: colNode.getAttribute('data-type') || 'string' 32 | }; 33 | cols.push(col); 34 | if (col.sortable) { 35 | col.defaultDescSort = col.type === 'number'; 36 | colNode.innerHTML = colNode.innerHTML + ''; 37 | } 38 | } 39 | return cols; 40 | } 41 | // attaches a data attribute to every tr element with an object 42 | // of data values keyed by column name 43 | function loadRowData(tableRow) { 44 | var tableCols = tableRow.querySelectorAll('td'), 45 | colNode, 46 | col, 47 | data = {}, 48 | i, 49 | val; 50 | for (i = 0; i < tableCols.length; i += 1) { 51 | colNode = tableCols[i]; 52 | col = cols[i]; 53 | val = colNode.getAttribute('data-value'); 54 | if (col.type === 'number') { 55 | val = Number(val); 56 | } 57 | data[col.key] = val; 58 | } 59 | return data; 60 | } 61 | // loads all row data 62 | function loadData() { 63 | var rows = getTableBody().querySelectorAll('tr'), 64 | i; 65 | 66 | for (i = 0; i < rows.length; i += 1) { 67 | rows[i].data = loadRowData(rows[i]); 68 | } 69 | } 70 | // sorts the table using the data for the ith column 71 | function sortByIndex(index, desc) { 72 | var key = cols[index].key, 73 | sorter = function (a, b) { 74 | a = a.data[key]; 75 | b = b.data[key]; 76 | return a < b ? -1 : a > b ? 1 : 0; 77 | }, 78 | finalSorter = sorter, 79 | tableBody = document.querySelector('.coverage-summary tbody'), 80 | rowNodes = tableBody.querySelectorAll('tr'), 81 | rows = [], 82 | i; 83 | 84 | if (desc) { 85 | finalSorter = function (a, b) { 86 | return -1 * sorter(a, b); 87 | }; 88 | } 89 | 90 | for (i = 0; i < rowNodes.length; i += 1) { 91 | rows.push(rowNodes[i]); 92 | tableBody.removeChild(rowNodes[i]); 93 | } 94 | 95 | rows.sort(finalSorter); 96 | 97 | for (i = 0; i < rows.length; i += 1) { 98 | tableBody.appendChild(rows[i]); 99 | } 100 | } 101 | // removes sort indicators for current column being sorted 102 | function removeSortIndicators() { 103 | var col = getNthColumn(currentSort.index), 104 | cls = col.className; 105 | 106 | cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); 107 | col.className = cls; 108 | } 109 | // adds sort indicators for current column being sorted 110 | function addSortIndicators() { 111 | getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; 112 | } 113 | // adds event listeners for all sorter widgets 114 | function enableUI() { 115 | var i, 116 | el, 117 | ithSorter = function ithSorter(i) { 118 | var col = cols[i]; 119 | 120 | return function () { 121 | var desc = col.defaultDescSort; 122 | 123 | if (currentSort.index === i) { 124 | desc = !currentSort.desc; 125 | } 126 | sortByIndex(i, desc); 127 | removeSortIndicators(); 128 | currentSort.index = i; 129 | currentSort.desc = desc; 130 | addSortIndicators(); 131 | }; 132 | }; 133 | for (i =0 ; i < cols.length; i += 1) { 134 | if (cols[i].sortable) { 135 | // add the click event handler on the th so users 136 | // dont have to click on those tiny arrows 137 | el = getNthColumn(i).querySelector('.sorter').parentElement; 138 | if (el.addEventListener) { 139 | el.addEventListener('click', ithSorter(i)); 140 | } else { 141 | el.attachEvent('onclick', ithSorter(i)); 142 | } 143 | } 144 | } 145 | } 146 | // adds sorting functionality to the UI 147 | return function () { 148 | if (!getTable()) { 149 | return; 150 | } 151 | cols = loadColumns(); 152 | loadData(cols); 153 | addSortIndicators(); 154 | enableUI(); 155 | }; 156 | })(); 157 | 158 | window.addEventListener('load', addSorting); 159 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/base.css: -------------------------------------------------------------------------------- 1 | body, html { 2 | margin:0; padding: 0; 3 | height: 100%; 4 | } 5 | body { 6 | font-family: Helvetica Neue, Helvetica, Arial; 7 | font-size: 14px; 8 | color:#333; 9 | } 10 | .small { font-size: 12px; } 11 | *, *:after, *:before { 12 | -webkit-box-sizing:border-box; 13 | -moz-box-sizing:border-box; 14 | box-sizing:border-box; 15 | } 16 | h1 { font-size: 20px; margin: 0;} 17 | h2 { font-size: 14px; } 18 | pre { 19 | font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; 20 | margin: 0; 21 | padding: 0; 22 | -moz-tab-size: 2; 23 | -o-tab-size: 2; 24 | tab-size: 2; 25 | } 26 | a { color:#0074D9; text-decoration:none; } 27 | a:hover { text-decoration:underline; } 28 | .strong { font-weight: bold; } 29 | .space-top1 { padding: 10px 0 0 0; } 30 | .pad2y { padding: 20px 0; } 31 | .pad1y { padding: 10px 0; } 32 | .pad2x { padding: 0 20px; } 33 | .pad2 { padding: 20px; } 34 | .pad1 { padding: 10px; } 35 | .space-left2 { padding-left:55px; } 36 | .space-right2 { padding-right:20px; } 37 | .center { text-align:center; } 38 | .clearfix { display:block; } 39 | .clearfix:after { 40 | content:''; 41 | display:block; 42 | height:0; 43 | clear:both; 44 | visibility:hidden; 45 | } 46 | .fl { float: left; } 47 | @media only screen and (max-width:640px) { 48 | .col3 { width:100%; max-width:100%; } 49 | .hide-mobile { display:none!important; } 50 | } 51 | 52 | .quiet { 53 | color: #7f7f7f; 54 | color: rgba(0,0,0,0.5); 55 | } 56 | .quiet a { opacity: 0.7; } 57 | 58 | .fraction { 59 | font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; 60 | font-size: 10px; 61 | color: #555; 62 | background: #E8E8E8; 63 | padding: 4px 5px; 64 | border-radius: 3px; 65 | vertical-align: middle; 66 | } 67 | 68 | div.path a:link, div.path a:visited { color: #333; } 69 | table.coverage { 70 | border-collapse: collapse; 71 | margin: 10px 0 0 0; 72 | padding: 0; 73 | } 74 | 75 | table.coverage td { 76 | margin: 0; 77 | padding: 0; 78 | vertical-align: top; 79 | } 80 | table.coverage td.line-count { 81 | text-align: right; 82 | padding: 0 5px 0 20px; 83 | } 84 | table.coverage td.line-coverage { 85 | text-align: right; 86 | padding-right: 10px; 87 | min-width:20px; 88 | } 89 | 90 | table.coverage td span.cline-any { 91 | display: inline-block; 92 | padding: 0 5px; 93 | width: 100%; 94 | } 95 | .missing-if-branch { 96 | display: inline-block; 97 | margin-right: 5px; 98 | border-radius: 3px; 99 | position: relative; 100 | padding: 0 4px; 101 | background: #333; 102 | color: yellow; 103 | } 104 | 105 | .skip-if-branch { 106 | display: none; 107 | margin-right: 10px; 108 | position: relative; 109 | padding: 0 4px; 110 | background: #ccc; 111 | color: white; 112 | } 113 | .missing-if-branch .typ, .skip-if-branch .typ { 114 | color: inherit !important; 115 | } 116 | .coverage-summary { 117 | border-collapse: collapse; 118 | width: 100%; 119 | } 120 | .coverage-summary tr { border-bottom: 1px solid #bbb; } 121 | .keyline-all { border: 1px solid #ddd; } 122 | .coverage-summary td, .coverage-summary th { padding: 10px; } 123 | .coverage-summary tbody { border: 1px solid #bbb; } 124 | .coverage-summary td { border-right: 1px solid #bbb; } 125 | .coverage-summary td:last-child { border-right: none; } 126 | .coverage-summary th { 127 | text-align: left; 128 | font-weight: normal; 129 | white-space: nowrap; 130 | } 131 | .coverage-summary th.file { border-right: none !important; } 132 | .coverage-summary th.pct { } 133 | .coverage-summary th.pic, 134 | .coverage-summary th.abs, 135 | .coverage-summary td.pct, 136 | .coverage-summary td.abs { text-align: right; } 137 | .coverage-summary td.file { white-space: nowrap; } 138 | .coverage-summary td.pic { min-width: 120px !important; } 139 | .coverage-summary tfoot td { } 140 | 141 | .coverage-summary .sorter { 142 | height: 10px; 143 | width: 7px; 144 | display: inline-block; 145 | margin-left: 0.5em; 146 | background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; 147 | } 148 | .coverage-summary .sorted .sorter { 149 | background-position: 0 -20px; 150 | } 151 | .coverage-summary .sorted-desc .sorter { 152 | background-position: 0 -10px; 153 | } 154 | .status-line { height: 10px; } 155 | /* dark red */ 156 | .red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } 157 | .low .chart { border:1px solid #C21F39 } 158 | /* medium red */ 159 | .cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } 160 | /* light red */ 161 | .low, .cline-no { background:#FCE1E5 } 162 | /* light green */ 163 | .high, .cline-yes { background:rgb(230,245,208) } 164 | /* medium green */ 165 | .cstat-yes { background:rgb(161,215,106) } 166 | /* dark green */ 167 | .status-line.high, .high .cover-fill { background:rgb(77,146,33) } 168 | .high .chart { border:1px solid rgb(77,146,33) } 169 | /* dark yellow (gold) */ 170 | .medium .chart { border:1px solid #f9cd0b; } 171 | .status-line.medium, .medium .cover-fill { background: #f9cd0b; } 172 | /* light yellow */ 173 | .medium { background: #fff4c2; } 174 | /* light gray */ 175 | span.cline-neutral { background: #eaeaea; } 176 | 177 | .cbranch-no { background: yellow !important; color: #111; } 178 | 179 | .cstat-skip { background: #ddd; color: #111; } 180 | .fstat-skip { background: #ddd; color: #111 !important; } 181 | .cbranch-skip { background: #ddd !important; color: #111; } 182 | 183 | 184 | .cover-fill, .cover-empty { 185 | display:inline-block; 186 | height: 12px; 187 | } 188 | .chart { 189 | line-height: 0; 190 | } 191 | .cover-empty { 192 | background: white; 193 | } 194 | .cover-full { 195 | border-right: none !important; 196 | } 197 | pre.prettyprint { 198 | border: none !important; 199 | padding: 0 !important; 200 | margin: 0 !important; 201 | } 202 | .com { color: #999 !important; } 203 | .ignore-none { color: #999; font-weight: normal; } 204 | 205 | .wrapper { 206 | min-height: 100%; 207 | height: auto !important; 208 | height: 100%; 209 | margin: 0 auto -48px; 210 | } 211 | .footer, .push { 212 | height: 48px; 213 | } 214 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/components/MobiledocEditor.vue.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for components/MobiledocEditor.vue 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files / components/ MobiledocEditor.vue 20 |

21 |
22 |
23 | 17.5% 24 | Statements 25 | 7/40 26 |
27 |
28 | 33.33% 29 | Branches 30 | 4/12 31 |
32 |
33 | 4.55% 34 | Functions 35 | 1/22 36 |
37 |
38 | 8.57% 39 | Lines 40 | 3/35 41 |
42 |
43 | 1 branch 44 | Ignored      45 |
46 |
47 |
48 |
49 |

 50 | 
453 | 
1 51 | 2 52 | 3 53 | 4 54 | 5 55 | 6 56 | 7 57 | 8 58 | 9 59 | 10 60 | 11 61 | 12 62 | 13 63 | 14 64 | 15 65 | 16 66 | 17 67 | 18 68 | 19 69 | 20 70 | 21 71 | 22 72 | 23 73 | 24 74 | 25 75 | 26 76 | 27 77 | 28 78 | 29 79 | 30 80 | 31 81 | 32 82 | 33 83 | 34 84 | 35 85 | 36 86 | 37 87 | 38 88 | 39 89 | 40 90 | 41 91 | 42 92 | 43 93 | 44 94 | 45 95 | 46 96 | 47 97 | 48 98 | 49 99 | 50 100 | 51 101 | 52 102 | 53 103 | 54 104 | 55 105 | 56 106 | 57 107 | 58 108 | 59 109 | 60 110 | 61 111 | 62 112 | 63 113 | 64 114 | 65 115 | 66 116 | 67 117 | 68 118 | 69 119 | 70 120 | 71 121 | 72 122 | 73 123 | 74 124 | 75 125 | 76 126 | 77 127 | 78 128 | 79 129 | 80 130 | 81 131 | 82 132 | 83 133 | 84 134 | 85 135 | 86 136 | 87 137 | 88 138 | 89 139 | 90 140 | 91 141 | 92 142 | 93 143 | 94 144 | 95 145 | 96 146 | 97 147 | 98 148 | 99 149 | 100 150 | 101 151 | 102 152 | 103 153 | 104 154 | 105 155 | 106 156 | 107 157 | 108 158 | 109 159 | 110 160 | 111 161 | 112 162 | 113 163 | 114 164 | 115 165 | 116 166 | 117 167 | 118 168 | 119 169 | 120 170 | 121 171 | 122 172 | 123 173 | 124 174 | 125 175 | 126 176 | 127 177 | 128 178 | 129 179 | 130 180 | 131 181 | 132 182 | 133 183 | 134 184 | 135  185 |   186 |   187 |   188 |   189 |   190 |   191 |   192 |   193 |   194 |   195 |   196 | 197 |   198 | 199 |   200 |   201 |   202 |   203 |   204 |   205 |   206 |   207 |   208 |   209 |   210 |   211 |   212 |   213 |   214 |   215 |   216 |   217 |   218 |   219 |   220 |   221 |   222 |   223 |   224 |   225 |   226 |   227 |   228 |   229 |   230 |   231 |   232 |   233 |   234 |   235 |   236 |   237 |   238 |   239 |   240 |   241 |   242 |   243 |   244 |   245 |   246 |   247 |   248 |   249 |   250 |   251 |   252 |   253 |   254 |   255 |   256 |   257 |   258 |   259 |   260 |   261 |   262 |   263 |   264 |   265 |   266 |   267 |   268 |   269 |   270 |   271 |   272 |   273 |   274 |   275 |   276 |   277 |   278 |   279 |   280 |   281 |   282 |   283 |   284 |   285 |   286 |   287 |   288 |   289 |   290 |   291 |   292 |   293 |   294 |   295 |   296 |   297 |   298 |   299 |   300 |   301 |   302 |   303 |   304 |   305 |   306 |   307 |   308 |   309 |   310 |   311 |   312 |   313 |   314 |   315 |   316 |   317 |   318 |  
//
319 | //
320 | //
321 | //
322 | //
323 | //
324 | //
325 | //
326 | //
327 | //
328 | //
329 |  
330 | import Mobiledoc, { UI } from "mobiledoc-kit"
331 |  
332 | const EMPTY_MOBILEDOC = {
333 |   version: "0.3.0",
334 |   markups: [],
335 |   atoms: [],
336 |   cards: [],
337 |   sections: []
338 | }
339 |  
340 | export default {
341 |   name: "mobiledoc-editor",
342 |   props: {
343 |     autofocus: { type: Boolean, default: () => true },
344 |     spellCheck: { type: Boolean, default: () => true },
345 |     placeholder: { type: String, default: () => "" },
346 |     serializeVersion: { type: String, default: () => "0.3.0" },
347 |     atoms: { type: Array, default: () => [] },
348 |     cards: { type: Array, default: () => [] },
349 |     mobiledoc: { type: Object, default: () => EMPTY_MOBILEDOC }
350 |   },
351 |  
352 |   data() {
353 |     return {
354 |       activeMarkupTags: [],
355 |       activeSectionTags: []
356 |     }
357 |   },
358 |  
359 |   computed: {
360 |     _editorOptions() {
361 |       return {
362 |         autofocus: this.autofocus,
363 |         spellcheck: this.spellcheck,
364 |         placeholder: this.placeholder,
365 |         serializeVersion: this.serializeVersion,
366 |         atoms: this.atoms,
367 |         cards: this.cards,
368 |         mobiledoc: this.mobiledoc
369 |       }
370 |     }
371 |   },
372 |  
373 |   methods: {
374 |     toggleMarkup(tagName) {
375 |       this.editor.toggleMarkup(tagName)
376 |     },
377 |  
378 |     toggleSection(tagName) {
379 |       this.editor.toggleSection(tagName)
380 |     },
381 |  
382 |     toggleLink() {
383 |       if (!this.editor.hasCursor()) { // if text isn't selected
384 |         return
385 |       }
386 |  
387 |       if (this.editor.hasActiveMarkup("a")) {
388 |         this.editor.toggleMarkup("a")
389 |       } else {
390 |         UI.toggleLink(this.editor)
391 |       }
392 |     },
393 |  
394 |     // addAtom(atomName, text, payload) {
395 |     //   this.editor.insertAtom(atomName, text, payload)
396 |     // },
397 |     //
398 |     // addCard(cardName, payLoad, editMode = false) {
399 |     //   this.editor.insertCard(cardName, payload, editMode)
400 |     // },
401 |     //
402 |     // addCardInEditMode(cardName, payLoad, editMode = true) {
403 |     //   this.editor.insertCard(cardName, payload, editMode)
404 |     // },
405 |  
406 |     _setActiveMarkupTags() {
407 |       this.activeMarkupTags = this.editor.activeMarkups.map(m => m.tagName)
408 |     },
409 |  
410 |     _setActiveSectionTags() {
411 |       // editor.activeSections are leaf sections
412 |       // Map section tag names (e.g. 'p', 'ul', 'ol') so that list buttons are updated
413 |       this.activeSectionTags = this.editor.activeSections.map(s => {
414 |         return s.isNested ? s.parent.tagName : s.tagName
415 |       })
416 |     }
417 |   },
418 |  
419 |   // create editor instance and setup event hooks
420 |   beforeMount() {
421 |     this.$emit("willCreateEditor")
422 |  
423 |     this.editor = new Mobiledoc.Editor(this._editorOptions)
424 |  
425 |     this.editor.inputModeDidChange(() => {
426 |       this._setActiveMarkupTags()
427 |       this._setActiveSectionTags()
428 |     })
429 |  
430 |     this.$emit("didCreateEditor", this.editor)
431 |  
432 |     this.editor.postDidChange(() => {
433 |       // serialize the editor's post to the mobiledoc version format
434 |       // any cards or atoms present in doc, will be ommited
435 |       const mobiledoc = this.editor.serialize(this.serializeVersion)
436 |       this.$emit("onChange", mobiledoc)
437 |     })
438 |   },
439 |  
440 |   mounted() {
441 |     if (this.editor) {
442 |       // reference element will be replaced by editor's rendered post
443 |       this.editor.render(this.$refs.editor)
444 |     }
445 |   },
446 |  
447 |   beforeDestroy() {
448 |     this.editor.destroy()
449 |   }
450 | }
451 |  
452 |  
454 |
455 |
456 | 460 | 461 | 462 | 469 | 470 | 471 | 472 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/components/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for components/ 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files components/ 20 |

21 |
22 |
23 | 17.5% 24 | Statements 25 | 7/40 26 |
27 |
28 | 33.33% 29 | Branches 30 | 4/12 31 |
32 |
33 | 4.55% 34 | Functions 35 | 1/22 36 |
37 |
38 | 8.57% 39 | Lines 40 | 3/35 41 |
42 |
43 | 1 branch 44 | Ignored      45 |
46 |
47 |
48 |
49 |
50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |
FileStatementsBranchesFunctionsLines
MobiledocEditor.vue
17.5%7/4033.33%4/124.55%1/228.57%3/35
80 |
81 |
82 | 86 | 87 | 88 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for All files 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | / 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 0/0 26 |
27 |
28 | 100% 29 | Branches 30 | 0/0 31 |
32 |
33 | 100% 34 | Functions 35 | 0/0 36 |
37 |
38 | 100% 39 | Lines 40 | 0/0 41 |
42 |
43 |
44 |
45 |
46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 |
FileStatementsBranchesFunctionsLines
63 |
64 |
65 | 69 | 70 | 71 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/prettify.css: -------------------------------------------------------------------------------- 1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} 2 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/prettify.js: -------------------------------------------------------------------------------- 1 | window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); 2 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/sort-arrow-sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alidcast/vue-mobiledoc-editor/0a6123871430bc6640e8343d96937445eeb69691/test/unit/coverage/lcov-report/sort-arrow-sprite.png -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/sorter.js: -------------------------------------------------------------------------------- 1 | var addSorting = (function () { 2 | "use strict"; 3 | var cols, 4 | currentSort = { 5 | index: 0, 6 | desc: false 7 | }; 8 | 9 | // returns the summary table element 10 | function getTable() { return document.querySelector('.coverage-summary'); } 11 | // returns the thead element of the summary table 12 | function getTableHeader() { return getTable().querySelector('thead tr'); } 13 | // returns the tbody element of the summary table 14 | function getTableBody() { return getTable().querySelector('tbody'); } 15 | // returns the th element for nth column 16 | function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; } 17 | 18 | // loads all columns 19 | function loadColumns() { 20 | var colNodes = getTableHeader().querySelectorAll('th'), 21 | colNode, 22 | cols = [], 23 | col, 24 | i; 25 | 26 | for (i = 0; i < colNodes.length; i += 1) { 27 | colNode = colNodes[i]; 28 | col = { 29 | key: colNode.getAttribute('data-col'), 30 | sortable: !colNode.getAttribute('data-nosort'), 31 | type: colNode.getAttribute('data-type') || 'string' 32 | }; 33 | cols.push(col); 34 | if (col.sortable) { 35 | col.defaultDescSort = col.type === 'number'; 36 | colNode.innerHTML = colNode.innerHTML + ''; 37 | } 38 | } 39 | return cols; 40 | } 41 | // attaches a data attribute to every tr element with an object 42 | // of data values keyed by column name 43 | function loadRowData(tableRow) { 44 | var tableCols = tableRow.querySelectorAll('td'), 45 | colNode, 46 | col, 47 | data = {}, 48 | i, 49 | val; 50 | for (i = 0; i < tableCols.length; i += 1) { 51 | colNode = tableCols[i]; 52 | col = cols[i]; 53 | val = colNode.getAttribute('data-value'); 54 | if (col.type === 'number') { 55 | val = Number(val); 56 | } 57 | data[col.key] = val; 58 | } 59 | return data; 60 | } 61 | // loads all row data 62 | function loadData() { 63 | var rows = getTableBody().querySelectorAll('tr'), 64 | i; 65 | 66 | for (i = 0; i < rows.length; i += 1) { 67 | rows[i].data = loadRowData(rows[i]); 68 | } 69 | } 70 | // sorts the table using the data for the ith column 71 | function sortByIndex(index, desc) { 72 | var key = cols[index].key, 73 | sorter = function (a, b) { 74 | a = a.data[key]; 75 | b = b.data[key]; 76 | return a < b ? -1 : a > b ? 1 : 0; 77 | }, 78 | finalSorter = sorter, 79 | tableBody = document.querySelector('.coverage-summary tbody'), 80 | rowNodes = tableBody.querySelectorAll('tr'), 81 | rows = [], 82 | i; 83 | 84 | if (desc) { 85 | finalSorter = function (a, b) { 86 | return -1 * sorter(a, b); 87 | }; 88 | } 89 | 90 | for (i = 0; i < rowNodes.length; i += 1) { 91 | rows.push(rowNodes[i]); 92 | tableBody.removeChild(rowNodes[i]); 93 | } 94 | 95 | rows.sort(finalSorter); 96 | 97 | for (i = 0; i < rows.length; i += 1) { 98 | tableBody.appendChild(rows[i]); 99 | } 100 | } 101 | // removes sort indicators for current column being sorted 102 | function removeSortIndicators() { 103 | var col = getNthColumn(currentSort.index), 104 | cls = col.className; 105 | 106 | cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); 107 | col.className = cls; 108 | } 109 | // adds sort indicators for current column being sorted 110 | function addSortIndicators() { 111 | getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; 112 | } 113 | // adds event listeners for all sorter widgets 114 | function enableUI() { 115 | var i, 116 | el, 117 | ithSorter = function ithSorter(i) { 118 | var col = cols[i]; 119 | 120 | return function () { 121 | var desc = col.defaultDescSort; 122 | 123 | if (currentSort.index === i) { 124 | desc = !currentSort.desc; 125 | } 126 | sortByIndex(i, desc); 127 | removeSortIndicators(); 128 | currentSort.index = i; 129 | currentSort.desc = desc; 130 | addSortIndicators(); 131 | }; 132 | }; 133 | for (i =0 ; i < cols.length; i += 1) { 134 | if (cols[i].sortable) { 135 | // add the click event handler on the th so users 136 | // dont have to click on those tiny arrows 137 | el = getNthColumn(i).querySelector('.sorter').parentElement; 138 | if (el.addEventListener) { 139 | el.addEventListener('click', ithSorter(i)); 140 | } else { 141 | el.attachEvent('onclick', ithSorter(i)); 142 | } 143 | } 144 | } 145 | } 146 | // adds sorting functionality to the UI 147 | return function () { 148 | if (!getTable()) { 149 | return; 150 | } 151 | cols = loadColumns(); 152 | loadData(cols); 153 | addSortIndicators(); 154 | enableUI(); 155 | }; 156 | })(); 157 | 158 | window.addEventListener('load', addSorting); 159 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/src/App.vue.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for src/App.vue 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files / src/ App.vue 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 13/13 26 |
27 |
28 | 100% 29 | Branches 30 | 4/4 31 |
32 |
33 | 100% 34 | Functions 35 | 2/2 36 |
37 |
38 | 100% 39 | Lines 40 | 6/6 41 |
42 |
43 | 1 branch 44 | Ignored      45 |
46 |
47 |
48 |
49 |

 50 | 
156 | 
1 51 | 2 52 | 3 53 | 4 54 | 5 55 | 6 56 | 7 57 | 8 58 | 9 59 | 10 60 | 11 61 | 12 62 | 13 63 | 14 64 | 15 65 | 16 66 | 17 67 | 18 68 | 19 69 | 20 70 | 21 71 | 22 72 | 23 73 | 24 74 | 25 75 | 26 76 | 27 77 | 28 78 | 29 79 | 30 80 | 31 81 | 32 82 | 33 83 | 34 84 | 35 85 | 36  86 |   87 |   88 |   89 |   90 |   91 |   92 |   93 |   94 |   95 |   96 |   97 | 98 | 99 | 100 | 101 |   102 |   103 |   104 |   105 |   106 |   107 |   108 |   109 |   110 |   111 |   112 |   113 | 114 |   115 |   116 |   117 |   118 |   119 |   120 |  
//
121 | //
122 | //
123 | //
124 | //
125 | //
126 | //
127 | //
128 | //
129 | //
130 | //
131 |  
132 | import Editor from "./components/MobiledocEditor.vue"
133 | import MarkupButton from "./components/MobiledocMarkupButton.vue"
134 | import SectionButton from "./components/MobiledocSectionButton.vue"
135 | import LinkButton from "./components/MobiledocLinkButton.vue"
136 |  
137 | export default {
138 |   name: "app",
139 |  
140 |   components: {
141 |     Editor,
142 |     MarkupButton,
143 |     SectionButton,
144 |     LinkButton
145 |   },
146 |  
147 |   data() {
148 |     return {
149 |       componentName: "Vue Mobiledoc Editor",
150 |       placeholder: "Start Writing..."
151 |     }
152 |   }
153 | }
154 |  
155 |  
157 |
158 |
159 | 163 | 164 | 165 | 172 | 173 | 174 | 175 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/src/Main.vue.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for src/main.vue 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files / src/ main.vue 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 9/9 26 |
27 |
28 | 100% 29 | Branches 30 | 4/4 31 |
32 |
33 | 100% 34 | Functions 35 | 2/2 36 |
37 |
38 | 100% 39 | Lines 40 | 4/4 41 |
42 |
43 | 1 branch 44 | Ignored      45 |
46 |
47 |
48 |
49 |

 50 | 
141 | 
1 51 | 2 52 | 3 53 | 4 54 | 5 55 | 6 56 | 7 57 | 8 58 | 9 59 | 10 60 | 11 61 | 12 62 | 13 63 | 14 64 | 15 65 | 16 66 | 17 67 | 18 68 | 19 69 | 20 70 | 21 71 | 22 72 | 23 73 | 24 74 | 25 75 | 26 76 | 27 77 | 28 78 | 29 79 | 30 80 | 31  81 |   82 |   83 |   84 |   85 |   86 |   87 |   88 |   89 |   90 |   91 |   92 | 93 | 94 |   95 |   96 |   97 |   98 |   99 |   100 |   101 |   102 |   103 |   104 | 105 |   106 |   107 |   108 |   109 |   110 |  
//
111 | //
112 | //
113 | //
114 | //
115 | //
116 | //
117 | //
118 | //
119 | //
120 | //
121 |  
122 | import MobiledocEditor from "./components/MobiledocEditor.vue"
123 | import MobiledocButton from "./components/MobiledocButton.vue"
124 |  
125 | export default {
126 |   name: "app",
127 |  
128 |   components: {
129 |     MobiledocEditor,
130 |     MobiledocButton
131 |   },
132 |  
133 |   data() {
134 |     return {
135 |       placeholder: "Start Writing..."
136 |     }
137 |   }
138 | }
139 |  
140 |  
142 |
143 |
144 | 148 | 149 | 150 | 157 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/src/components/MobiledocButton.vue.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for src/components/MobiledocButton.vue 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files / src/components/ MobiledocButton.vue 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 17/17 26 |
27 |
28 | 100% 29 | Branches 30 | 10/10 31 |
32 |
33 | 100% 34 | Functions 35 | 6/6 36 |
37 |
38 | 100% 39 | Lines 40 | 11/11 41 |
42 |
43 | 1 branch 44 | Ignored      45 |
46 |
47 |
48 |
49 |

 50 | 
189 | 
1 51 | 2 52 | 3 53 | 4 54 | 5 55 | 6 56 | 7 57 | 8 58 | 9 59 | 10 60 | 11 61 | 12 62 | 13 63 | 14 64 | 15 65 | 16 66 | 17 67 | 18 68 | 19 69 | 20 70 | 21 71 | 22 72 | 23 73 | 24 74 | 25 75 | 26 76 | 27 77 | 28 78 | 29 79 | 30 80 | 31 81 | 32 82 | 33 83 | 34 84 | 35 85 | 36 86 | 37 87 | 38 88 | 39 89 | 40 90 | 41 91 | 42 92 | 43 93 | 44 94 | 45 95 | 46 96 | 47  97 |   98 |   99 |   100 |   101 |   102 |   103 |   104 |   105 |   106 | 107 |   108 | 109 | 12× 110 |   111 |   112 |   113 |   114 |   115 |   116 |   117 |   118 |   119 |   120 | 121 | 122 |   123 |   124 |   125 | 126 | 127 |   128 |   129 |   130 | 131 | 132 |   133 |   134 |   135 |   136 |   137 | 138 |   139 |   140 |   141 |   142 |  
//
143 | //
144 | //
145 | //
146 | //
147 | //
148 | //
149 | //
150 | //
151 |  
152 | import titlelize, { capitalize } from "../utils/titlelize"
153 |  
154 | function isLink(tag) {
155 |   return tag === "a" || capitalize(tag) === capitalize("link")
156 | }
157 |  
158 | export default {
159 |   props: {
160 |     type: { type: String, required: true },
161 |     for: { type: String, required: true }
162 |   },
163 |  
164 |   computed: {
165 |     typeName() {
166 |       if (isLink(this.for)) { return "Link" }
167 |       return titlelize(this.type)
168 |     },
169 |  
170 |     tagName() {
171 |       if (isLink(this.for)) { return "a" }
172 |       return titlelize(this.for)
173 |     },
174 |  
175 |     isActive() {
176 |       let typeState = `active${this.typeName}Tags`
177 |       return `this.$parent.${typeState}.indexOf(${this.tagName}) > 1`
178 |     }
179 |   },
180 |  
181 |   methods: {
182 |     toggle() {
183 |       this.$root.$emit(`toggle${this.typeName}`, this.tagName)
184 |     }
185 |   }
186 | }
187 |  
188 |  
190 |
191 |
192 | 196 | 197 | 198 | 205 | 206 | 207 | 208 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/src/components/MobiledocEditor.vue.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for src/components/MobiledocEditor.vue 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files / src/components/ MobiledocEditor.vue 20 |

21 |
22 |
23 | 68.89% 24 | Statements 25 | 31/45 26 |
27 |
28 | 40% 29 | Branches 30 | 4/10 31 |
32 |
33 | 62.5% 34 | Functions 35 | 15/24 36 |
37 |
38 | 66.67% 39 | Lines 40 | 26/39 41 |
42 |
43 | 1 branch 44 | Ignored      45 |
46 |
47 |
48 |
49 |

 50 | 
477 | 
1 51 | 2 52 | 3 53 | 4 54 | 5 55 | 6 56 | 7 57 | 8 58 | 9 59 | 10 60 | 11 61 | 12 62 | 13 63 | 14 64 | 15 65 | 16 66 | 17 67 | 18 68 | 19 69 | 20 70 | 21 71 | 22 72 | 23 73 | 24 74 | 25 75 | 26 76 | 27 77 | 28 78 | 29 79 | 30 80 | 31 81 | 32 82 | 33 83 | 34 84 | 35 85 | 36 86 | 37 87 | 38 88 | 39 89 | 40 90 | 41 91 | 42 92 | 43 93 | 44 94 | 45 95 | 46 96 | 47 97 | 48 98 | 49 99 | 50 100 | 51 101 | 52 102 | 53 103 | 54 104 | 55 105 | 56 106 | 57 107 | 58 108 | 59 109 | 60 110 | 61 111 | 62 112 | 63 113 | 64 114 | 65 115 | 66 116 | 67 117 | 68 118 | 69 119 | 70 120 | 71 121 | 72 122 | 73 123 | 74 124 | 75 125 | 76 126 | 77 127 | 78 128 | 79 129 | 80 130 | 81 131 | 82 132 | 83 133 | 84 134 | 85 135 | 86 136 | 87 137 | 88 138 | 89 139 | 90 140 | 91 141 | 92 142 | 93 143 | 94 144 | 95 145 | 96 146 | 97 147 | 98 148 | 99 149 | 100 150 | 101 151 | 102 152 | 103 153 | 104 154 | 105 155 | 106 156 | 107 157 | 108 158 | 109 159 | 110 160 | 111 161 | 112 162 | 113 163 | 114 164 | 115 165 | 116 166 | 117 167 | 118 168 | 119 169 | 120 170 | 121 171 | 122 172 | 123 173 | 124 174 | 125 175 | 126 176 | 127 177 | 128 178 | 129 179 | 130 180 | 131 181 | 132 182 | 133 183 | 134 184 | 135 185 | 136 186 | 137 187 | 138 188 | 139 189 | 140 190 | 141 191 | 142 192 | 143  193 |   194 |   195 |   196 |   197 |   198 |   199 |   200 |   201 |   202 |   203 |   204 | 205 |   206 | 207 |   208 |   209 |   210 |   211 |   212 |   213 |   214 |   215 |   216 |   217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 |   225 |   226 |   227 | 228 |   229 |   230 |   231 |   232 |   233 |   234 |   235 | 236 |   237 |   238 |   239 |   240 |   241 |   242 |   243 |   244 |   245 |   246 |   247 |   248 |   249 |   250 |   251 |   252 |   253 |   254 |   255 |   256 |   257 |   258 |   259 |   260 |   261 |   262 |   263 |   264 |   265 |   266 |   267 |   268 |   269 |   270 |   271 |   272 |   273 |   274 |   275 |   276 |   277 |   278 |   279 |   280 |   281 |   282 |   283 |   284 |   285 |   286 |   287 |   288 |   289 |   290 |   291 |   292 |   293 |   294 |   295 | 296 | 297 | 298 |   299 |   300 |   301 |   302 | 303 | 304 |   305 | 306 |   307 | 308 |   309 |   310 |   311 |   312 | 313 |   314 | 315 |   316 |   317 | 318 | 319 |   320 |   321 |   322 |   323 | 324 |   325 | 326 | 327 |   328 |   329 |   330 |   331 |   332 |   333 |   334 |  
//
335 | //
336 | //
337 | //
338 | //
339 | //
340 | //
341 | //
342 | //
343 | //
344 | //
345 |  
346 | import Mobiledoc, { UI } from "mobiledoc-kit"
347 |  
348 | const EMPTY_MOBILEDOC = {
349 |   version: "0.3.0",
350 |   markups: [],
351 |   atoms: [],
352 |   cards: [],
353 |   sections: []
354 | }
355 |  
356 | export default {
357 |   name: "mobiledoc-editor",
358 |   props: {
359 |     autofocus: { type: Boolean, default: () => true },
360 |     spellCheck: { type: Boolean, default: () => true },
361 |     placeholder: { type: String, default: () => "" },
362 |     serializeVersion: { type: String, default: () => "0.3.0" },
363 |     atoms: { type: Array, default: () => [] },
364 |     cards: { type: Array, default: () => [] },
365 |     mobiledoc: { type: Object, default: () => EMPTY_MOBILEDOC }
366 |   },
367 |  
368 |   data() {
369 |     return {
370 |       activeMarkupTags: [],
371 |       activeSectionTags: []
372 |     }
373 |   },
374 |  
375 |   computed: {
376 |     _editorOptions() {
377 |       return {
378 |         autofocus: this.autofocus,
379 |         spellcheck: this.spellcheck,
380 |         placeholder: this.placeholder,
381 |         serializeVersion: this.serializeVersion,
382 |         atoms: this.atoms,
383 |         cards: this.cards,
384 |         mobiledoc: this.mobiledoc
385 |       }
386 |     }
387 |   },
388 |  
389 |   methods: {
390 |     toggleMarkup(tagName) {
391 |       this.editor.toggleMarkup(tagName)
392 |     },
393 |  
394 |     toggleSection(tagName) {
395 |       this.editor.toggleSection(tagName)
396 |     },
397 |  
398 |     toggleLink() {
399 |       if (!this.editor.hasCursor()) { // if text isn"t selected
400 |         return
401 |       }
402 |  
403 |       if (this.editor.hasActiveMarkup("a")) {
404 |         this.editor.toggleMarkup("a")
405 |       } else {
406 |         UI.toggleLink(this.editor)
407 |       }
408 |     },
409 |  
410 |     // addAtom(atomName, text, payload) {
411 |     //   this.editor.insertAtom(atomName, text, payload)
412 |     // },
413 |     //
414 |     // addCard(cardName, payLoad, editMode = false) {
415 |     //   this.editor.insertCard(cardName, payload, editMode)
416 |     // },
417 |     //
418 |     // addCardInEditMode(cardName, payLoad, editMode = true) {
419 |     //   this.editor.insertCard(cardName, payload, editMode)
420 |     // },
421 |  
422 |     _setActiveMarkupTags() {
423 |       this.activeMarkupTags = this.editor.activeMarkups.map(m => m.tagName)
424 |     },
425 |  
426 |     _setActiveSectionTags() {
427 |       // editor.activeSections are leaf sections
428 |       // Map section tag names (e.g. "p", "ul", "ol") so that list buttons are updated
429 |       this.activeSectionTags = this.editor.activeSections.map(s => {
430 |         return s.isNested ? s.parent.tagName : s.tagName
431 |       })
432 |     }
433 |   },
434 |  
435 |   // setup event listeners
436 |   created() {
437 |     this.$root.$on("toggleMarkup", this.toggleMarkup)
438 |     this.$root.$on("toggleSection", this.toggleSection)
439 |     this.$root.$on("toggleLink", this.toggleLink)
440 |   },
441 |  
442 |   // create editor instance
443 |   // setup event hooks
444 |   beforeMount() {
445 |     this.$emit("willCreateEditor")
446 |  
447 |     this.editor = new Mobiledoc.Editor(this._editorOptions)
448 |  
449 |     this.editor.inputModeDidChange(() => {
450 |       this._setActiveMarkupTags()
451 |       this._setActiveSectionTags()
452 |     })
453 |  
454 |     this.$emit("didCreateEditor", this.editor)
455 |  
456 |     this.editor.postDidChange(() => {
457 |       // serialize the editor"s post to the mobiledoc version format
458 |       // any cards or atoms present in doc, will be ommited
459 |       const mobiledoc = this.editor.serialize(this.serializeVersion)
460 |       this.$emit("onChange", mobiledoc)
461 |     })
462 |   },
463 |  
464 |   // replace editor element with rendered post
465 |   mounted() {
466 |     // mounted is recalled when data changes, so make sure it only runs once
467 |     this.$once("mounted", () => this.editor.render(this.$refs.editor))
468 |     this.$emit("mounted")
469 |   },
470 |  
471 |   beforeDestroy() {
472 |     this.editor.destroy()
473 |   }
474 | }
475 |  
476 |  
478 |
479 |
480 | 484 | 485 | 486 | 493 | 494 | 495 | 496 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/src/components/MobiledocLinkButton.vue.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for src/components/MobiledocLinkButton.vue 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files / src/components/ MobiledocLinkButton.vue 20 |

21 |
22 |
23 | 75% 24 | Statements 25 | 3/4 26 |
27 |
28 | 100% 29 | Branches 30 | 0/0 31 |
32 |
33 | 50% 34 | Functions 35 | 1/2 36 |
37 |
38 | 66.67% 39 | Lines 40 | 2/3 41 |
42 |
43 |
44 |
45 |

 46 | 
119 | 
1 47 | 2 48 | 3 49 | 4 50 | 5 51 | 6 52 | 7 53 | 8 54 | 9 55 | 10 56 | 11 57 | 12 58 | 13 59 | 14 60 | 15 61 | 16 62 | 17 63 | 18 64 | 19 65 | 20 66 | 21 67 | 22 68 | 23 69 | 24 70 | 25  71 |   72 |   73 |   74 |   75 |   76 |   77 |   78 |   79 |   80 |   81 |   82 |   83 | 84 |   85 |   86 |   87 |   88 |   89 |   90 |   91 |   92 |   93 |   94 |  
//
 95 | //
 96 | //
 97 | //
 98 | //
 99 | //
100 | //
101 | //
102 | //
103 |  
104 | export default {
105 |   computed: {
106 |     isActive() {
107 |       return this.$parent.activeMarkupTags.indexOf("a") > -1
108 |     }
109 |   },
110 |  
111 |   methods: {
112 |     toggle() {
113 |       this.$emit("toggleLink")
114 |     }
115 |   }
116 | }
117 |  
118 |  
120 |
121 |
122 | 126 | 127 | 128 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/src/components/MobiledocMarkupButton.vue.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for src/components/MobiledocMarkupButton.vue 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files / src/components/ MobiledocMarkupButton.vue 20 |

21 |
22 |
23 | 88.89% 24 | Statements 25 | 8/9 26 |
27 |
28 | 100% 29 | Branches 30 | 4/4 31 |
32 |
33 | 75% 34 | Functions 35 | 3/4 36 |
37 |
38 | 80% 39 | Lines 40 | 4/5 41 |
42 |
43 | 1 branch 44 | Ignored      45 |
46 |
47 |
48 |
49 |

 50 | 
153 | 
1 51 | 2 52 | 3 53 | 4 54 | 5 55 | 6 56 | 7 57 | 8 58 | 9 59 | 10 60 | 11 61 | 12 62 | 13 63 | 14 64 | 15 65 | 16 66 | 17 67 | 18 68 | 19 69 | 20 70 | 21 71 | 22 72 | 23 73 | 24 74 | 25 75 | 26 76 | 27 77 | 28 78 | 29 79 | 30 80 | 31 81 | 32 82 | 33 83 | 34 84 | 35  85 |   86 |   87 |   88 |   89 |   90 |   91 |   92 |   93 |   94 | 95 |   96 |   97 |   98 |   99 |   100 |   101 |   102 |   103 | 104 |   105 |   106 |   107 | 108 |   109 |   110 |   111 |   112 |   113 |   114 |   115 |   116 |   117 |   118 |  
//
119 | //
120 | //
121 | //
122 | //
123 | //
124 | //
125 | //
126 | //
127 |  
128 | import titlelize from "../utils/titlelize"
129 |  
130 | export default {
131 |   props: {
132 |     for: { type: String, required: true }
133 |   },
134 |  
135 |   computed: {
136 |     tag() {
137 |       return titlelize(this.for)
138 |     },
139 |  
140 |     isActive() {
141 |       return this.$parent.activeMarkupTags.indexOf(this.tag.toLowerCase()) > -1
142 |     }
143 |   },
144 |  
145 |   methods: {
146 |     toggle() {
147 |       this.$emit("toggleMarkup", this.tag)
148 |     }
149 |   }
150 | }
151 |  
152 |  
154 |
155 |
156 | 160 | 161 | 162 | 169 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/src/components/MobiledocSectionButton.vue.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for src/components/MobiledocSectionButton.vue 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files / src/components/ MobiledocSectionButton.vue 20 |

21 |
22 |
23 | 88.89% 24 | Statements 25 | 8/9 26 |
27 |
28 | 100% 29 | Branches 30 | 4/4 31 |
32 |
33 | 75% 34 | Functions 35 | 3/4 36 |
37 |
38 | 80% 39 | Lines 40 | 4/5 41 |
42 |
43 | 1 branch 44 | Ignored      45 |
46 |
47 |
48 |
49 |

 50 | 
153 | 
1 51 | 2 52 | 3 53 | 4 54 | 5 55 | 6 56 | 7 57 | 8 58 | 9 59 | 10 60 | 11 61 | 12 62 | 13 63 | 14 64 | 15 65 | 16 66 | 17 67 | 18 68 | 19 69 | 20 70 | 21 71 | 22 72 | 23 73 | 24 74 | 25 75 | 26 76 | 27 77 | 28 78 | 29 79 | 30 80 | 31 81 | 32 82 | 33 83 | 34 84 | 35  85 |   86 |   87 |   88 |   89 |   90 |   91 |   92 |   93 |   94 | 95 |   96 |   97 |   98 |   99 |   100 |   101 |   102 |   103 | 104 |   105 |   106 |   107 | 108 |   109 |   110 |   111 |   112 |   113 |   114 |   115 |   116 |   117 |   118 |  
//
119 | //
120 | //
121 | //
122 | //
123 | //
124 | //
125 | //
126 | //
127 |  
128 | import titlelize from "../utils/titlelize"
129 |  
130 | export default {
131 |   props: {
132 |     for: { type: String, required: true }
133 |   },
134 |  
135 |   computed: {
136 |     tag() {
137 |       return titlelize(this.for)
138 |     },
139 |  
140 |     isActive() {
141 |       return this.$parent.activeSectionTags.indexOf(this.tag.toLowerCase()) > -1
142 |     }
143 |   },
144 |  
145 |   methods: {
146 |     toggle() {
147 |       this.$parent.toggleSection(this.tag)
148 |     }
149 |   }
150 | }
151 |  
152 |  
154 |
155 |
156 | 160 | 161 | 162 | 169 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/src/components/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for src/components/ 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files src/components/ 20 |

21 |
22 |
23 | 77.42% 24 | Statements 25 | 48/62 26 |
27 |
28 | 70% 29 | Branches 30 | 14/20 31 |
32 |
33 | 70% 34 | Functions 35 | 21/30 36 |
37 |
38 | 74% 39 | Lines 40 | 37/50 41 |
42 |
43 | 2 branches 44 | Ignored      45 |
46 |
47 |
48 |
49 |
50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 |
FileStatementsBranchesFunctionsLines
MobiledocButton.vue
100%17/17100%10/10100%6/6100%11/11
MobiledocEditor.vue
68.89%31/4540%4/1062.5%15/2466.67%26/39
93 |
94 |
95 | 99 | 100 | 101 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/src/dev.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for src/dev.js 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files / src/ dev.js 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 9/9 26 |
27 |
28 | 100% 29 | Branches 30 | 4/4 31 |
32 |
33 | 100% 34 | Functions 35 | 1/1 36 |
37 |
38 | 100% 39 | Lines 40 | 4/4 41 |
42 |
43 |
44 |
45 |

46 | 
74 | 
1 47 | 2 48 | 3 49 | 4 50 | 5 51 | 6 52 | 7 53 | 8 54 | 9 55 | 10 56 | 57 |   58 |   59 | 60 |   61 |   62 |   63 |   64 |  
import Vue from "vue"
65 | import Main from "./main"
66 |  
67 | /* eslint-disable no-new */
68 | new Vue({
69 |   el: "#app",
70 |   ...Main
71 | })
72 |  
73 |  
75 |
76 |
77 | 81 | 82 | 83 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for src/ 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files src/ 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 27/27 26 |
27 |
28 | 92.86% 29 | Branches 30 | 13/14 31 |
32 |
33 | 100% 34 | Functions 35 | 4/4 36 |
37 |
38 | 100% 39 | Lines 40 | 12/12 41 |
42 |
43 | 2 branches 44 | Ignored      45 |
46 |
47 |
48 |
49 |
50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 |
FileStatementsBranchesFunctionsLines
dev.js
100%9/9100%4/4100%1/1100%4/4
index.js
100%9/983.33%5/6100%1/1100%4/4
main.vue
100%9/9100%4/4100%2/2100%4/4
106 |
107 |
108 | 112 | 113 | 114 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/src/index.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for src/index.js 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files / src/ index.js 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 9/9 26 |
27 |
28 | 83.33% 29 | Branches 30 | 5/6 31 |
32 |
33 | 100% 34 | Functions 35 | 1/1 36 |
37 |
38 | 100% 39 | Lines 40 | 4/4 41 |
42 |
43 | 1 branch 44 | Ignored      45 |
46 |
47 |
48 |
49 |

 50 | 
 81 | 
1 51 | 2 52 | 3 53 | 4 54 | 5 55 | 6 56 | 7 57 | 8 58 | 9 59 | 10 60 | 11 61 |   62 | 63 | 64 |   65 |   66 |   67 |   68 |   69 |   70 |  
import Main from "./main"
 71 |  
 72 | Eif (typeof window !== "undefined") {
 73 |   window.Main = Main
 74 | }
 75 |  
 76 | export {
 77 |   Main
 78 | }
 79 |  
 80 |  
82 |
83 |
84 | 88 | 89 | 90 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/src/utils/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for src/utils/ 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files src/utils/ 20 |

21 |
22 |
23 | 90% 24 | Statements 25 | 9/10 26 |
27 |
28 | 100% 29 | Branches 30 | 0/0 31 |
32 |
33 | 75% 34 | Functions 35 | 3/4 36 |
37 |
38 | 85.71% 39 | Lines 40 | 6/7 41 |
42 |
43 |
44 |
45 |
46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |
FileStatementsBranchesFunctionsLines
titlelize.js
90%9/10100%0/075%3/485.71%6/7
76 |
77 |
78 | 82 | 83 | 84 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/src/utils/titlelize.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for src/utils/titlelize.js 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files / src/utils/ titlelize.js 20 |

21 |
22 |
23 | 90% 24 | Statements 25 | 9/10 26 |
27 |
28 | 100% 29 | Branches 30 | 0/0 31 |
32 |
33 | 75% 34 | Functions 35 | 3/4 36 |
37 |
38 | 85.71% 39 | Lines 40 | 6/7 41 |
42 |
43 |
44 |
45 |

 46 | 
 89 | 
1 47 | 2 48 | 3 49 | 4 50 | 5 51 | 6 52 | 7 53 | 8 54 | 9 55 | 10 56 | 11 57 | 12 58 | 13 59 | 14 60 | 15 61 | 28× 62 |   63 |   64 | 65 | 66 |   67 |   68 |   69 |   70 |   71 | 72 |   73 |   74 |  
export function capitalize(str) {
 75 |   return str.charAt(0).toUpperCase() + str.slice(1)
 76 | }
 77 |  
 78 | export function camelize(str) {
 79 |   return str.replace(/\W+(.)/g, function (match, chr) {
 80 |     return chr.toUpperCase()
 81 |   })
 82 | }
 83 |  
 84 | export default function (str) {
 85 |   return capitalize(camelize(str))
 86 | }
 87 |  
 88 |  
90 |
91 |
92 | 96 | 97 | 98 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alidcast/vue-mobiledoc-editor/0a6123871430bc6640e8343d96937445eeb69691/test/unit/coverage/lcov.info -------------------------------------------------------------------------------- /test/unit/index.js: -------------------------------------------------------------------------------- 1 | // Polyfill fn.bind() for PhantomJS 2 | /* eslint-disable no-extend-native */ 3 | Function.prototype.bind = require("function-bind") 4 | 5 | // require all test files (files that ends with .spec.js) 6 | const testsContext = require.context("./specs", true, /\.spec$/) 7 | testsContext.keys().forEach(testsContext) 8 | 9 | // require all src files except index.js for coverage. 10 | // you can also change this to match only the subset of files that 11 | // you want coverage for. 12 | const srcContext = require.context("../../src", true, /^\.\/(?!index(\.js)?$)/) 13 | srcContext.keys().forEach(srcContext) 14 | -------------------------------------------------------------------------------- /test/unit/karma.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var merge = require('webpack-merge') 3 | var webpack = require('webpack') 4 | var webpackConfig = require('../../webpack.config.js') 5 | var projectRoot = path.resolve(__dirname, '../../') 6 | 7 | 8 | module.exports = function (config) { 9 | config.set({ 10 | browsers: ['PhantomJS'], 11 | frameworks: ['mocha', 'sinon-chai'], 12 | reporters: ['spec', 'coverage'], 13 | files: ['./index.js'], 14 | preprocessors: { 15 | './index.js': ['webpack', 'sourcemap'] 16 | }, 17 | webpack: webpackConfig, 18 | // avoid walls of useless tests 19 | webpackMiddleware: { 20 | noInfo: true 21 | } 22 | //, 23 | // singleRun: true, 24 | // coverageReporter: { 25 | // dir: './coverage', 26 | // reporters: [ 27 | // { type: 'lcov', subdir: '.' }, 28 | // { type: 'text-summary' } 29 | // ] 30 | // } 31 | }) 32 | } 33 | -------------------------------------------------------------------------------- /test/unit/specs/MobiledocButton.spec.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue" 2 | import MobiledocController from "src/MobiledocController" 3 | import MobiledocEditor from "src/MobiledocEditor" 4 | import MobiledocButton from "src/MobiledocButton" 5 | 6 | const { spy } = sinon 7 | 8 | describe("", function () { 9 | const ctrl = new MobiledocController() 10 | const Btn = Vue.extend(MobiledocButton(ctrl)) 11 | 12 | it("markup button receives necessary props", () => { 13 | let markupProps = { type: "markup", tag: "strong" } 14 | let btn = new Btn({ propsData: markupProps }) 15 | expect(btn.type).to.equal("markup") 16 | expect(btn.tag).to.equal("strong") 17 | }) 18 | 19 | it("section button receives necessary props", () => { 20 | let sectionProps = { type: "section", tag: "h1" } 21 | let btn = new Btn({ propsData: sectionProps }) 22 | expect(btn.type).to.equal("section") 23 | expect(btn.tag).to.equal("h1") 24 | }) 25 | 26 | it("link button receives necessary props", () => { 27 | let linkProps = { type: "markup", tag: "a" } 28 | let btn = new Btn({ propsData: linkProps }) 29 | expect(btn.type).to.equal("markup") 30 | expect(btn.tag).to.equal("a") 31 | // TODO prompt 32 | }) 33 | 34 | it("atom button receives necessary props", () => { 35 | let atomProps = { name: "mention", text: "@hello" } 36 | let btn = new Btn({ propsData: atomProps }) 37 | expect(btn.name).to.equal("mention") 38 | expect(btn.text).to.equal("@hello") 39 | // TODO payload 40 | }) 41 | 42 | it("card button receives necessary props", () => { 43 | let atomProps = { name: "image", mode: "display" } 44 | let btn = new Btn({ propsData: atomProps }) 45 | expect(btn.name).to.equal("image") 46 | expect(btn.mode).to.equal("display") 47 | // TODO 48 | // payload, cardOptions 49 | }) 50 | }) 51 | -------------------------------------------------------------------------------- /test/unit/specs/MobiledocController.spec.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue" 2 | import MobiledocController from "src/MobiledocController" 3 | import MobiledocEditor from "src/MobiledocEditor" 4 | import MobiledocButton from "src/MobiledocButton" 5 | 6 | const { spy } = sinon 7 | 8 | describe("MobiledocController", function () { 9 | const ctrl = new MobiledocController() 10 | const vm = new Vue(MobiledocEditor(ctrl)) 11 | 12 | it("should update controller data with new editor instance", (done) => { 13 | expect(ctrl.editor).to.be.empty 14 | vm.$mount() 15 | Vue.nextTick(() => { 16 | expect(ctrl.editor.mobiledoc.version).to.equal('0.3.0') 17 | done() 18 | }) 19 | }) 20 | 21 | // TODO finish these tests, they're being stubborn 22 | // 23 | 24 | // it("should update activeMarkupTags data", (done) => { 25 | // expect(ctrl.activeMarkupTags).to.be.empty 26 | // vm.$mount() 27 | // Vue.nextTick(() => { 28 | // ctrl.editor.toggleMarkup('strong') 29 | // ctrl.editor.insertText('Strong Text') 30 | // expect(ctrl.activeMarkupTags).to.equal(['strong']) 31 | // console.log(ctrl.activeMarkupTags) 32 | // done() 33 | // }) 34 | // }) 35 | // 36 | // it("should update activeSectionTags data", (done) => { 37 | // expect(ctrl.activeSectionsTags).to.be.empty 38 | // vm.$mount() 39 | // Vue.nextTick(() => { 40 | // // ctrl.editor.toggleSection('h1') 41 | // // ctrl.editor.insertText('A Heading') 42 | // done() 43 | // }) 44 | // }) 45 | // 46 | // it("fires InputModeChanged when markup or section changed", (done) => { 47 | // Vue.nextTick(() => { 48 | // done() 49 | // }) 50 | // }) 51 | }) 52 | -------------------------------------------------------------------------------- /test/unit/specs/MobiledocEditor.spec.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue" 2 | import MobiledocEditor from "src/MobiledocEditor" 3 | import MobiledocController from "src/MobiledocController" 4 | 5 | const { spy } = sinon 6 | 7 | describe("", function () { 8 | const ctrl = new MobiledocController() 9 | const editor = new Vue(MobiledocEditor(ctrl)) 10 | 11 | it("all props that serve as editor options have defaults", () => { 12 | expect(editor.autofocus).to.not.be.undefined 13 | expect(editor.placeholder).to.not.be.undefined 14 | expect(editor.spellCheck).to.not.be.undefined 15 | expect(editor.serializeVersion).to.not.be.undefined 16 | expect(editor.atoms).to.not.be.undefined 17 | expect(editor.cards).to.not.be.undefined 18 | expect(editor.mobiledoc).to.not.be.undefined 19 | }) 20 | 21 | it("fires willCreateEditor callback", (done) => { 22 | let callback = spy() 23 | editor.$on("willCreateEditor", callback) 24 | editor.$mount() 25 | Vue.nextTick(() => { 26 | expect(callback).to.have.been.called 27 | done() 28 | }) 29 | }) 30 | 31 | it("fires didCreateEditor callback with editor instance", (done) => { 32 | let callback = spy() 33 | editor.$on("didCreateEditor", callback) 34 | editor.$mount() 35 | editor.$nextTick(() => { 36 | expect(callback).to.have.been.calledWith(ctrl.editor) 37 | done() 38 | }) 39 | }) 40 | 41 | it("fires willCreateEditor before didCreateEditor callback", (done) => { 42 | let callbackFirst = spy() 43 | let callbackSecond = spy() 44 | editor.$on("didCreateEditor", callbackFirst) 45 | editor.$on("didCreateEditor", callbackSecond) 46 | editor.$mount() 47 | editor.$nextTick(() => { 48 | expect(callbackFirst).to.have.been.calledBefore(callbackSecond) 49 | done() 50 | }) 51 | }) 52 | 53 | it("fires postWasUpdated callback with mobiledoc", (done) => { 54 | let callback = spy() 55 | editor.$on("postWasUpdated", callback) 56 | editor.$mount() 57 | editor.$nextTick(() => { 58 | ctrl.editor.run(postEditor => { 59 | const changeMade = postEditor.builder.createMarkupSection("p") 60 | postEditor.insertSection(changeMade) 61 | }) 62 | expect(callback).to.have.been.calledWithMatch({ version: "0.3.0" }) 63 | done() 64 | }) 65 | }) 66 | }) 67 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var webpack = require('webpack') 3 | var merge = require('webpack-merge') 4 | var HtmlWebpackPlugin = require('html-webpack-plugin') 5 | var ExtractTextPlugin = require("extract-text-webpack-plugin") 6 | 7 | var projectRoot = path.resolve(__dirname, './') 8 | var devRoot = path.resolve(__dirname, './demo') 9 | var prodRoot = path.resolve(__dirname, './src') 10 | 11 | const baseConfig = { 12 | resolve: { 13 | extensions: [ 14 | '.js', '.vue' 15 | ], 16 | alias: { 17 | 'vue$': 'vue/dist/vue.common.js', // use standalone package 18 | 'src': prodRoot, 19 | 'demo': devRoot 20 | }, 21 | modules: [ 22 | prodRoot, 23 | "node_modules" 24 | ] 25 | }, 26 | module: { 27 | rules: [ 28 | { 29 | test: /\.vue$/, 30 | loader: 'vue-loader', 31 | options: { 32 | extractCSS: true, 33 | loaders: { 34 | 'scss': 'vue-style-loader!css-loader!sass-loader', 35 | 'sass': 'vue-style-loader!css-loader!sass-loader?indentedSyntax' 36 | } 37 | } 38 | }, 39 | { 40 | test: /\.js$/, 41 | use: [ 42 | 'babel-loader', 43 | 'eslint-loader' 44 | ], 45 | exclude: /node_modules/, 46 | include: projectRoot, 47 | }, 48 | { 49 | test: /\.(png|jpg|gif|svg)$/, 50 | loader: 'file-loader', 51 | options: { 52 | name: '[name].[ext]?[hash]' 53 | } 54 | } 55 | ] 56 | } 57 | } 58 | 59 | const devConfig = { 60 | entry: `${devRoot}/main.js`, 61 | output: { 62 | publicPath: '/' 63 | }, 64 | devtool: '#eval-source-map', 65 | devServer: { 66 | // contentBase: __dirname + "/src", 67 | historyApiFallback: true, 68 | noInfo: true 69 | }, 70 | performance: { hints: false }, 71 | plugins: [ 72 | new webpack.DefinePlugin({ 73 | 'process.env': { 74 | NODE_ENV: '"development"' 75 | } 76 | }), 77 | new webpack.optimize.OccurrenceOrderPlugin(), 78 | new webpack.HotModuleReplacementPlugin(), 79 | new webpack.NoErrorsPlugin(), 80 | new HtmlWebpackPlugin({ 81 | template: `${devRoot}/index.html`, 82 | inject: true 83 | }) 84 | ] 85 | } 86 | 87 | const prodConfig = { 88 | entry: `${prodRoot}/index.js`, 89 | output: { 90 | path: path.resolve(__dirname, './dist'), 91 | publicPath: '/dist/', 92 | filename: 'build.js', 93 | library: 'vueMobiledocEditor', 94 | libraryTarget: 'umd' 95 | }, 96 | externals: { 97 | vue: 'vue' 98 | }, 99 | devtool: '#source-map', 100 | plugins: (baseConfig.plugins || []).concat([ 101 | new webpack.DefinePlugin({ 102 | 'process.env': { 103 | NODE_ENV: '"production"' 104 | } 105 | }), 106 | new webpack.optimize.UglifyJsPlugin({ 107 | sourceMap: true, 108 | compress: { 109 | warnings: false 110 | } 111 | }), 112 | new webpack.LoaderOptionsPlugin({ 113 | minimize: true 114 | }) 115 | ]) 116 | } 117 | 118 | const testConfig = { 119 | devtool: '#inline-source-map', 120 | plugins: [ 121 | new webpack.DefinePlugin({ 122 | 'process.env': '"testing"' 123 | }) 124 | ] 125 | } 126 | 127 | var finalConfig 128 | 129 | if (process.env.NODE_ENV === 'development') { 130 | finalConfig = merge(baseConfig, devConfig) 131 | } 132 | else if (process.env.NODE_ENV === 'production') { 133 | finalConfig = merge(baseConfig, prodConfig) 134 | } 135 | else if (process.env.NODE_ENV === 'testing') { 136 | finalConfig = merge(baseConfig, testConfig) 137 | // no need for original entry during tests 138 | delete finalConfig.entry 139 | } 140 | else { 141 | throw 'Node environment does not exist' 142 | } 143 | 144 | module.exports = finalConfig 145 | --------------------------------------------------------------------------------