├── .eslintignore ├── .npmignore ├── .gitignore ├── src ├── index.js ├── lib │ ├── util.js │ └── mount.js └── components │ ├── forms │ ├── index.js │ ├── Locale.vue │ ├── Type.vue │ ├── PlainText.vue │ └── Redactor.vue │ ├── Editor.vue │ ├── ContentBlocks.vue │ └── ContentBlock.vue ├── CONTRIBUTING.md ├── .babelrc ├── .eslintrc ├── .travis.yml ├── webpack.base.js ├── webpack.dist.js ├── CHANGELOG.md ├── LICENSE.md ├── package.json └── README.md /.eslintignore: -------------------------------------------------------------------------------- 1 | lib 2 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .idea 2 | example 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | npm-debug.log 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | export { default as mount } from './lib/mount'; 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Since this is an internal project, we don't accept pull requests at this time. 4 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "es2015" 4 | ], 5 | "plugins": [ 6 | "transform-object-rest-spread" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "spatie/vue", 3 | "env": { 4 | "browser": true, 5 | "node": true 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/lib/util.js: -------------------------------------------------------------------------------- 1 | export function box(v) { 2 | return { 3 | map: f => box(f(v)), 4 | fold: f => (f === undefined) ? v : f(v), 5 | }; 6 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - stable 5 | 6 | install: 7 | - npm install -g yarn 8 | - yarn install 9 | 10 | script: 11 | - npm test 12 | -------------------------------------------------------------------------------- /src/components/forms/index.js: -------------------------------------------------------------------------------- 1 | export { default as Locale } from './Locale'; 2 | export { default as BlenderMedia } from '@spatie/blender-media'; 3 | export { default as PlainText } from './PlainText'; 4 | export { default as Redactor } from './Redactor'; 5 | export { default as Type } from './Type'; 6 | -------------------------------------------------------------------------------- /src/components/forms/Locale.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 21 | -------------------------------------------------------------------------------- /webpack.base.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | module: { 3 | loaders: [ 4 | { 5 | test: /\.vue$/, 6 | loaders: ['vue'], 7 | }, 8 | { 9 | test: /\.js/, 10 | loaders: ['babel'], 11 | exclude: ['node_modules'], 12 | }, 13 | ], 14 | }, 15 | resolve: { 16 | extensions: ['.js', '.vue'], 17 | }, 18 | }; 19 | -------------------------------------------------------------------------------- /src/lib/mount.js: -------------------------------------------------------------------------------- 1 | import ContentBlocks from '../components/ContentBlocks'; 2 | import { isString } from 'lodash'; 3 | import { props, queryAll } from 'spatie-dom'; 4 | import Vue from 'vue'; 5 | 6 | export default function mount(el) { 7 | if (isString(el)) { 8 | return queryAll(el).map(el => mount(el)); 9 | } 10 | 11 | return new Vue({ 12 | el, 13 | render(createElement) { 14 | return createElement(ContentBlocks, { props: props(el) }); 15 | }, 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /src/components/forms/Type.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | -------------------------------------------------------------------------------- /webpack.dist.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const config = Object.assign({}, require('./webpack.base')); 3 | 4 | config.context = __dirname; 5 | 6 | config.entry = './src/index.js'; 7 | 8 | config.output = { 9 | path: path.resolve(__dirname, 'dist'), 10 | filename: 'index.js', 11 | library: 'blender-content-blocks', 12 | libraryTarget: 'umd', 13 | }; 14 | 15 | config.externals = { 16 | 'vue': 'vue', 17 | 'lodash': 'lodash', 18 | 'spatie-dom': 'spatie-dom', 19 | '@spatie/blender-media': '@spatie/blender-media', 20 | }; 21 | 22 | module.exports = config; 23 | -------------------------------------------------------------------------------- /src/components/forms/PlainText.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 29 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All Notable changes to `blender-content-blocks` will be documented in this file. 4 | 5 | ## 2.0.2 - 2017-09-19 6 | - Changed: English labels 7 | 8 | ## 2.0.1 - 2017-09-19 9 | - Updated: compatibility with Redactor II 2.10 10 | 11 | ## 1.1.1 - 2017-08-22 12 | - Fixed: Button clicks weren't always prevented 13 | 14 | ## 1.1.0 - 2017-05-21 15 | - Added: Allow custom types, translated attributes and media collections via `data` 16 | - Fixed: Removed broken hash links 17 | 18 | ## 1.0.5 - 2017-03-28 19 | - Fixed: Look for `types` in `data` in the content block component 20 | 21 | ## 1.0.4 - 2017-03-28 22 | - Fixed: Change `blender-media` dependency to `@spatie/blender-media` 23 | 24 | ## 1.0.3 - 2017-03-28 25 | - Added: Look for `types` in `data` in the editor mixin 26 | 27 | ## 1.0.0 - 2017-01-10 28 | - First release 29 | -------------------------------------------------------------------------------- /src/components/forms/Redactor.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 45 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | Copyright (c) Spatie bvba 4 | 5 | > Permission is hereby granted, free of charge, to any person obtaining a copy 6 | > of this software and associated documentation files (the "Software"), to deal 7 | > in the Software without restriction, including without limitation the rights 8 | > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | > copies of the Software, and to permit persons to whom the Software is 10 | > furnished to do so, subject to the following conditions: 11 | > 12 | > The above copyright notice and this permission notice shall be included in 13 | > all copies or substantial portions of the Software. 14 | > 15 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | > THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@spatie/blender-content-blocks", 3 | "version": "2.0.2", 4 | "description": "Blender content blocks component", 5 | "main": "dist/index.js", 6 | "scripts": { 7 | "build": "rm -rf dist && NODE_ENV=production webpack --config webpack.dist.js", 8 | "lint": "eslint src --ext .js --ext .vue --fix; exit 0", 9 | "prepublish": "npm run test; npm run build", 10 | "test": "exit 0" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/spatie-custom/blender-content-blocks.git" 15 | }, 16 | "keywords": [ 17 | "spatie", 18 | "blender", 19 | "javascript", 20 | "vue" 21 | ], 22 | "author": "Sebastian De Deyne", 23 | "license": "MIT", 24 | "bugs": { 25 | "url": "https://github.com/spatie-custom/blender-content-blocks/issues" 26 | }, 27 | "homepage": "https://github.com/spatie-custom/blender-content-blocks", 28 | "dependencies": { 29 | "axios": "^0.15.3", 30 | "babel-core": "^6.18.2", 31 | "dragula": "^3.7.1", 32 | "dragula-constrain": "^1.0.0", 33 | "dropzone": "^4.3.0", 34 | "font-awesome-filetypes": "^1.0.1" 35 | }, 36 | "peerDependencies": { 37 | "lodash": "^4.0.0", 38 | "spatie-dom": "^1.0.0", 39 | "vue": "^2.0.0" 40 | }, 41 | "devDependencies": { 42 | "babel-loader": "^6.2.5", 43 | "babel-plugin-transform-object-rest-spread": "^6.8.0", 44 | "babel-preset-es2015": "^6.14.0", 45 | "css-loader": "^0.25.0", 46 | "eslint": "^3.0.0", 47 | "eslint-config-spatie": "^1.2.5", 48 | "eslint-plugin-html": "^1.5.3", 49 | "eslint-plugin-vue": "^0.1.1", 50 | "lodash": "^4.0.0", 51 | "spatie-dom": "^1.0.0", 52 | "vue": "^2.0.0", 53 | "vue-loader": "^9.0.3", 54 | "webpack": "2.1.0-beta.25" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Blender Media 2 | 3 | [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) 4 | [![Build Status](https://img.shields.io/travis/spatie-custom/blender-content-blocks.svg?style=flat-square)](https://travis-ci.org/spatie-custom/blender-content-blocks) 5 | 6 | Content blocks component for [Blender](https://github.com/spatie-custom/blender), our CMS. 7 | 8 | ## Support us 9 | 10 | Learn how to create a package like this one, by watching our premium video course: 11 | 12 | [![Laravel Package training](https://spatie.be/github/package-training.jpg)](https://laravelpackage.training) 13 | 14 | We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us). 15 | 16 | We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards). 17 | 18 | ## Installation 19 | 20 | The `blender-content-blocks` can be installed from npm. 21 | 22 | ```bash 23 | yarn add @spatie/blender-content-blocks 24 | ``` 25 | 26 | `blender-content-blocks` also requires you to install `vue@'^2.0.0'`, `lodash@'^4.0.0'`, and `spatie-dom@'^1.0.0'`: 27 | 28 | ```bash 29 | yarn add vue@'^2.0.0' lodash@'^4.0.0' spatie-dom@'^1.0.0' 30 | ``` 31 | 32 | ## Usage 33 | 34 | The canonical way to use `blender-content-blocks`, is to mount it on a selector. The `mount` function will replace every element that matches a given selector with a `blender-content-blocks` component. The element should contain props just like you'd pass them with Vue. 35 | 36 | ```js 37 | import { mount } from '@spatie/blender-content-blocks'; 38 | 39 | export default function init() { 40 | mount('content-blocks'); 41 | } 42 | ``` 43 | 44 | ```html 45 | 59 | ``` 60 | 61 | ### Custom Fields 62 | 63 | Custom fields can be defined by passing `types`, `translatableAttributes` or `mediaLibraryCollections` to `data`. Here are the default values as a quick reference: 64 | 65 | ```js 66 | { 67 | types: { 68 | imageLeft: 'Afbeelding links', 69 | imageRight: 'Afbeelding rechts', 70 | }, 71 | translatableAttributes: { 72 | name: 'text', 73 | text: 'redactor', 74 | }, 75 | mediaLibraryCollections: { 76 | image: 'image', 77 | }, 78 | } 79 | ``` 80 | 81 | ## Contributing 82 | 83 | Since this is an internal project, we don't accept pull requests at this time. 84 | 85 | ## License 86 | 87 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 88 | 89 | Example images provided by [Unsplash](https://unsplash.com). 90 | -------------------------------------------------------------------------------- /src/components/Editor.vue: -------------------------------------------------------------------------------- 1 | 39 | 40 | 145 | -------------------------------------------------------------------------------- /src/components/ContentBlocks.vue: -------------------------------------------------------------------------------- 1 | 35 | 36 | 169 | -------------------------------------------------------------------------------- /src/components/ContentBlock.vue: -------------------------------------------------------------------------------- 1 | 61 | 62 | 167 | --------------------------------------------------------------------------------