Coder Social home page Coder Social logo

maak-2904 / laraberg-vue Goto Github PK

View Code? Open in Web Editor NEW

This project forked from evryn/laraberg-vue

1.0 0.0 0.0 1.94 MB

๐Ÿ€ Laraberg Vue: Use WordPress Gutenberg editor in your Vue.js and Laravel application

JavaScript 84.70% CSS 12.70% Vue 2.60%

laraberg-vue's Introduction

Laraberg Vue

Laraberg Vue

This package contains editor-only part of Laraberg that can be implemented in your Vue.js app. For the backend, using Laraberg is required.

Its API can handle cookie-based authentications nicely (for example, Laravel Sanctum). You can edit src/js/api/api-fetch.js in case you need to deal with API calls (such as token-based auths). Read development section below for more details in this case.

Installation

Simply run the following command:

npm install --save laraberg-vue

Usage

You can examine a working project in Laraberg Vue Example repository.

Import and use the plugin. You may need to consider your backend API endpoint URL for Laraberg in the prefix option:

import Vue from 'vue'
import LarabergVue from 'laraberg-vue';

Vue.use(LarabergVue, {
  // Base URL of your API endpoint and Laraberg controller prefix
  prefix: 'https://api.example.com/laraberg',
})

You can pass other Laraberg options too. It's also possible to easily register your custom blocks. See Laraberg Vue Example project for advanced usage.

Now, use it in your template:

<template>
  <laraberg-editor v-model="html"/>
</template>

<script>
  export default  {
    data: () => ({
      html: `
        <!-- wp:heading -->
        <h2>Welcome</h2>
        <!-- /wp:heading -->
      `
	}),
  }
</script>

Limitations

This package is based on Laraberg frontend sources and under the hood, these both use Wordpress Gutenberg editor. Only a single Gutenberg editor can present on the page at the time.

Development

Building the package from source directory needs some more steps and that's because of how Gutenberg should be built (>250MB). I'm taking instructions from here:

1- Clone this repository:

git clone [email protected]:evryn/laraberg-vue.git

2- Download Wordpress Gutenberg v8.1, extract it into a directory
3- In extracted directory, build Wordpress Gutenberg and link it to your global node_modules:

npm install
npm run build
sudo npm link

4- Go back to this project's cloned directory and link global gutenberg to local node_modules:

npm install
npm link gutenberg

โš  NOTE: If you need other packages to install, it's good idea to remove gutenberg link from local node_modules and link it after installation. Or else, you may need to go through step 1 with those time consuming tasks.

Now you can do your changes. You may serve and preview it with:

npm run serve

At the end, build final assets into dist directory:

npm run build

laraberg-vue's People

Contributors

amirrezanasiri avatar

Stargazers

 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.