Giter Club home page Giter Club logo

shopware-tip-tap's Introduction

Description

A plugin to intergrate Tiptap editor into Shopware.

Installation

For development purpose, I suggest using https://github.com/shopware/platform.

Clone this plugin into your custom/plugins folder and install it like a normal plugin.

Usage

A component with tag sas-tiptap-editor is available to use.

<sas-tiptap-editor
    :options="editorOptions"
    :value="currentValue"
    @input="updateCurrentValue"
/>

with options props you can set the toolbar options for the editor. An example of the options is:

editorOptions: [
  {
    type: 'set',
    title: 'Heading',
    icon: 'heading',
    children: [
      {
        name: 'Heading',
        title: 'Heading 1',
        icon: 'h-1',
        config: {
          level: 1,
        }
      },
      {
        name: 'Heading',
        title: 'Heading 2',
        icon: 'h-2',
        config: {
          level: 2,
        }
      },
      {
        name: 'Heading',
        title: 'Heading 3',
        icon: 'h-3',
        config: {
          level: 3,
        }
      }
    ]
  },
  {
    type: 'Color',
    icon: 'font-color',
  },
  {
    name: 'Bold',
    title: 'Bold',
    icon: 'bold',
  },
  {
    name: 'Italic',
    title: 'Italic',
    icon: 'italic',
  },
  {
    name: 'Underline',
    title: 'Underline',
    icon: 'underline',
  },
  {
    name: 'Strike',
    title: 'Strikethrough',
    icon: 'strikethrough',
  },
  {
    type: 'set',
    title: 'Text Align',
    icon: 'align-justify',
    children: [
      {
        name: 'TextAlign',
        title: 'Left',
        icon: 'align-left',
        config: {
          textAlign: 'left',
        }
      },
      {
        name: 'TextAlign',
        title: 'Center',
        icon: 'align-center',
        config: {
          textAlign: 'center',
        }
      },
      {
        name: 'TextAlign',
        title: 'Right',
        icon: 'align-right',
        config: {
          textAlign: 'right',
        }
      },
      {
        name: 'TextAlign',
        title: 'Justify',
        icon: 'align-justify',
        config: {
          textAlign: 'justify',
        }
      },
    ]
  },
  {
    name: 'OrderedList',
    title: 'Ordered list',
    icon: 'list-ordered',
  },
  {
    name: 'BulletList',
    title: 'Bullet list',
    icon: 'list-unordered',
  },
  {
    type: 'sw-media',
    name: 'SwMedia',
    title: 'Media library',
    icon: 'gallery-line',
  },
  {
    name: 'Undo',
    title: 'Undo',
    icon: 'arrow-go-back-line',
  },
  {
    name: 'Redo',
    title: 'Redo',
    icon: 'arrow-go-forward-line',
  },
  {
    type: 'link',
    title: 'Link',
    icon: 'link',
  }
]

Too long? You can set mode prop to full and all available options will show up.

With set as a type, you can create a dropdown menu of many items.

An option must provide name, icon properties in order to work.

All available options are still in development. You can find it in shopware-tip-tap/src/Resources/app/administration/options. We can create more options here.

Add new options

An example of an option:

import Option from './Option.js';

export default class Bold extends Option {
  constructor (icon, title, editor) {
    super(icon, title);
    this.action = () => editor.chain().focus().toggleBold().run();
    this.isActive = () => editor.isActive('bold');
  }
};

With option class, what essential you need to do is to provide super(icon, title);. With an action property that you can provide whatever logic that you want to execute when the option is clicked.

We also provide config property for you to pass in data that you want to use. You can receive it as a param of the constructor funtion.

constructor (icon, title, editor, config) 
{
    super(icon, title);
    this.action = () => localStorage.setItem('tiptap-editor-config', config);
}

shopware-tip-tap's People

Contributors

crisalder2806 avatar

Stargazers

 avatar  avatar  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.