Giter VIP home page Giter VIP logo

pesdk-wrapper-vuejs's Introduction

vue-pesdk

vue-pesdk

PhotoEditor SDK Vue.js wrapper

๐Ÿท Note

PhotoEditor SDK is a product of 9elements GmbH. In order to use PhotoEditor SDK inside one of your products, you will need a valid a license.

๐Ÿ”ง Installation

yarn add vue-pesdk photoeditorsdk react react-dom
or
npm i -D vue-pesdk photoeditorsdk react react-dom

photoeditorsdk, react and react-dom are peerDependencies and are needed to render the PhotoEditorSDK UI. In addition you need the PhotoEditor SDK assets. You can either get them here or copy it from your node_modules into your public asset folder. And set the assetPath prop to this folder.

If you scaffold your project with Vue CLI you can just cp the asset folder from node_modules.

cp -r node_modules/photoeditorsdk/assets/ ~/projects/your-project/static/

If needed, take a look at the official documentation for further information.

๐Ÿ‘ˆ Usage

Import the PhotoEditor SDK css styles and the vue-sdk component.

<template>
  <PhotoEditor
    asset-path="/static"
    license='{"owner": ...}'
    image-path='/static/example.jpg'
  />
</template>

<script>
  import 'photoeditorsdk/css/PhotoEditorSDK.UI.DesktopUI.min.css'
  import 'photoeditorsdk/css/PhotoEditorSDK.UI.ReactUI.min.css'

  import PhotoEditor from 'vue-pesdk'

  export default {
    components: { PhotoEditor }
  }
</script>

๐Ÿ“’ Props

prop default type required description
ui 'react' String no Select if you want to use the DesktopUI or ReactUI. Supported values are react and desktop.
license '' String yes Your PhotoEditorSDK license. Get it here
imagePath '' String yes Path to the image that will be rendered initially
assetPath 'static' String no Path to your assets. Where the PhotoEditorSDK assets are stored
assetResolver String no A function that gets called for every asset. Can turn an asset path into another path. Useful for stuff like Rails asset pipeline.
editorOptions Object no Extended configuration options for the editor object https://docs.photoeditorsdk.com/guides/html5/v4/introduction/configuration
options Object no Extended configuration options https://docs.photoeditorsdk.com/guides/html5/v4/introduction/configuration

๐Ÿ›ซ Getting Started

The idea behind this wrapper is to simplify the usage of the PhotoEditor SDK inside Vue. We try to minimize the configuration and maximize the possibilities. Because of that you have only 3 important and required props, license, imagePath and assetPath to get the editor running.

You have however to either download or copy the PhotoEditor SDK assets to your public asset folder. You can either get them here or copy it from your node_modules.

If you need more configuration possibilities, you can pass all the mentioned options to the editorOptions or options prop.

Furthermore, the editor instance is saved as a Vue Instance Property so you can access the editor instance inside your parent component with this.$pesdk after the editor is mounted.

๐Ÿ“บ Examples

Basic Example

<template>
  <PhotoEditor
    asset-path="/assets"
    :license="$options.license",
    image-path="/assets/example.jpg"
  />
</template>

<script>
  import PhotoEditor from 'vue-pesdk'
  import PesdkLicense from './myLicense.json'

  export default {
    components: { PhotoEditor },
    license: JSON.stringify(PesdkLicense)
  }

Listen to Events

You can listen to various events in the PhotoEditorSdk You can simply attach an .on() event to the editor instance.

<template>
  <PhotoEditor
    asset-path="/assets"
    :license="$options.license"
    image-path="/assets/example.jpg"
  />
</template>

<script>
  import PhotoEditor from 'vue-pesdk'
  import PesdkLicense from './myLicense.json'

  export default {
    components: { PhotoEditor },
    license: JSON.stringify(PesdkLicense), // This is optional way to store non-reactive data in vue.
    mounted () {
      this.$pesdk.on('export', (result) => {
        console.log('User clicked export, resulting image / dataurl:')
        console.log(result)
      })
    }
  }

Specifying which focus modes are available

Like mentioned earlier you can pass in all configuration options like here.

<template>
  <PhotoEditor
    asset-path="/assets"
    :license="$options.license"
    :editorOptions="customOptions"
    :options="{logLevel: 'trace'}"
    image-path="/assets/example.jpg"
  />
</template>

<script>
  import PhotoEditor from 'vue-pesdk'
  import PesdkLicense from './myLicense.json'

  export default {
    components: { PhotoEditor },
    license: JSON.strigify(PesdkLicense), // This is optional.
    data: () => ({
      customOptions: {
        controlsOptions: {
          focus: {
            availableModes: ['radial', 'mirrored', 'linear', 'gaussian']
          }
        }
      }
    })
  }

๐Ÿ“œ Changelog

Details changes for each release are documented in the CHANGELOG.md.

๐Ÿ‘จโ€๐Ÿ’ป Development

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build

# build for production and view the bundle analyzer report
npm run build --report

# run unit tests
npm run unit

# run e2e tests
npm run e2e

# run all tests
npm test

For a detailed explanation on how things work, check out the guide and docs for vue-loader.

๐Ÿ“œ License

Please see LICENSE for licensing details.

๐Ÿ‘ฅ Authors and Contributors

Please see CONTRIBUTORS for licensing details.

๐Ÿ’ฌ Support or Contact

For support requests, please use our Support Desk.

pesdk-wrapper-vuejs's People

Contributors

apertureless avatar danielhauschildt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.