GithubHelp home page GithubHelp logo

nova-quilljs's Introduction

Laravel Nova Quilljs editor Field

A Laravel Nova implementation of the Quill editor for Vue.js

Latest Stable Version Total Downloads License Monthly Downloads Daily Downloads

What's new (2021-11-22)?

You can use custom quilljs setting in different fields.

2021-08-09

Work with other package nova-translatable and nova-flexible-content, maybe it can change Vue this.fields.attribute, so I add uploadUrlSplit method, You can correctly upload your image.

Installation

Install via composer

composer require ek0519/quilljs

Modify quill's height, width, padding bottom

paddingBottom(integer)

In nova interface was not easy to set css about quill padding bottom, at some resolution maybe can overlaps, you can use paddingBottom to modify.

Quilljs::make(__('Content'), 'content')
        ->paddingBottom(30)
        ->withFiles('public')
        ->placeholder('please enter here')
        ->height(300)
        ->rules('required'),

fullWidth(value)

Boolean

height(value)

Number (unit px)

use Ek0519\Quilljs\Quilljs;

Quilljs::make('content')
        ->withFiles('public')
        ->fullWidth(false) (option, default full-width)
        ->height(500) (option, default 300px)
        ->rules('required'),

resize and align image

I add this module https://github.com/Fandom-OSS/quill-blot-formatter , thanks for https://github.com/Fandom-OSS

Image upload size

maxFileSize(size)

size : Number, default 2(MB)
example

use Ek0519\Quilljs\Quilljs;

Quilljs::make('content')
        ->withFiles('public')
        ->maxFileSize(3)
        ->rules('required'),

Image upload

This Nova field provides native attachments driver which works similar to Trix File Uploads.

To use this attachments driver, publish and run the migration(also publish quilljs config to set toolbar):

php artisan vendor:publish --provider="Ek0519\Quilljs\FieldServiceProvider"
php artisan migrate

Then, allow users to upload images, just like with Trix field, chaining the withFiles method onto the field's definition. When calling this method, you should pass the name of the filesystem disk that images should be stored on(in this example, we use public, please use this command php artisan storage:link ):

use Ek0519\Quilljs\Quilljs;

Quilljs::make('content')
        ->withFiles('public')
        ->placeholder('please enter here')
        ->rules('required'),

Work with other package nova-translatable and nova-flexible-content

When you use other packages like nova-translatable and nova-flexible-content, they will overwrite upload api.

Ex: origin your_host/nova-vendor/quilljs/articles/upload/content , maybe overwrite to
/nova-vendor/quilljs/articles/upload/content.en or
/nova-vendor/quilljs/articles/upload/content__SDAcscsdw.

You can use

uploadUrlSplit(split_string)

split_string : String
example

use Ek0519\Quilljs\Quilljs;

Quilljs::make('content')
        ->withFiles('public')
        ->placeholder('please enter here')
        ->uploadUrlSplit('.')
        ->rules('required')
        ->translatable(), // nova-translatable's method


Customizing Tooltips

In default, tooltip was disabled, if you want to use, in Resource add ->tooltip(true)

Quilljs::make(__('Content'), 'content')
                ->withFiles('public')
                ->tooltip(true)

in config/tooltip.php

You can use favorite description of tooltip.

<?php

return [
        ['Choice' =>'.ql-bold','title' =>'bold'],
        ['Choice' =>'.ql-italic','title' =>'italic'],
        ['Choice' =>'.ql-underline','title' =>'underline'],
        ['Choice' =>'.ql-header','title' =>'header'],
        ['Choice' =>'.ql-strike','title' =>'strike'],
        ['Choice' =>'.ql-blockquote','title' =>'blockquote'],
        ['Choice' =>'.ql-code-block','title' =>'code-block'],
        ['Choice' =>'.ql-size','title' =>'font-size'],
        ['Choice' =>'.ql-list[value="ordered"]','title' =>'order list'],
        ['Choice' =>'.ql-list[value="bullet"]','title' =>'bulleted list'],
        ['Choice' =>'.ql-header[value="1"]','title' =>'h1'],
        ['Choice' =>'.ql-header[value="2"]','title' =>'h2'],
        ['Choice' =>'.ql-align','title' =>'align'],
        ['Choice' =>'.ql-color','title' =>'color'],
        ['Choice' =>'.ql-background','title' =>'background'],
        ['Choice' =>'.ql-image','title' =>'image'],
        ['Choice' =>'.ql-video','title' =>'video'],
        ['Choice' =>'.ql-link','title' =>'link'],
        ['Choice' =>'.ql-formula','title' =>'formula'],
        ['Choice' =>'.ql-clean','title' =>'clean'],
        ['Choice' =>'.ql-indent[value="-1"]','title' =>'indent left'],
        ['Choice' =>'.ql-indent[value="+1"]','title' =>'indent right'],
        ['Choice' =>'.ql-header .ql-picker-label','title' =>'header size'],
        ['Choice' =>'.ql-header .ql-picker-item[data-value="1"]','title' =>'H1'],
        ['Choice' =>'.ql-header .ql-picker-item[data-value="2"]','title' =>'H2'],
        ['Choice' =>'.ql-header .ql-picker-item[data-value="3"]','title' =>'H3'],
        ['Choice' =>'.ql-header .ql-picker-item[data-value="4"]','title' =>'H4'],
        ['Choice' =>'.ql-header .ql-picker-item[data-value="5"]','title' =>'H5'],
        ['Choice' =>'.ql-header .ql-picker-item[data-value="6"]','title' =>'H6'],
        ['Choice' =>'.ql-header .ql-picker-item:last-child','title' =>'normal'],
        ['Choice' =>'.ql-size .ql-picker-item[data-value="small"]','title' =>'small'],
        ['Choice' =>'.ql-size .ql-picker-item[data-value="large"]','title' =>'large'],
        ['Choice' =>'.ql-size .ql-picker-item[data-value="huge"]','title' =>'xlarge'],
        ['Choice' =>'.ql-size .ql-picker-item:nth-child(2)','title' =>'normal'],
        ['Choice' =>'.ql-align .ql-picker-item:first-child','title' =>'align left'],
        ['Choice' =>'.ql-align .ql-picker-item[data-value="center"]','title' =>'align center'],
        ['Choice' =>'.ql-align .ql-picker-item[data-value="right"]','title' =>'align right'],
        ['Choice' =>'.ql-align .ql-picker-item[data-value="justify"]','title' =>'justify']
];

Customizing Quilljs Toolbar

If you want to change toolbar's setting, you can change quilljs.php in config folder, reference quilljs's web site https://quilljs.com/docs/modules/toolbar

return [
    ["bold", "italic", "underline", "strike"],
    ["blockquote", "code-block"],
    [ ['header'=> 1 ], ['header'=> 2]],
    [['list'=> "ordered" ], ['list'=> "bullet" ]],
    [[ 'script'=> "sub" ], [ 'script'=> "super" ]],
    [[ 'indent'=> "-1" ], [ 'indent'=> "+1" ]],
    [[ 'direction'=> "rtl" ]],
    [[ 'size'=> ["small", false, "large", "huge"] ]],
    [[ 'header'=> [1, 2, 3, 4, 5, 6, false] ]],
    [[ 'color'=> [] ], [ 'background'=> [] ]],
    [[ 'font'=> [] ]],
    [[ 'align'=> [] ]],
    ["clean"],
    ["link", "image", "video"]
];

or you can use new api ->config(array []).

Quilljs::make(__('Content'), 'content')
        ->config([
                ["bold", "italic", "underline", "strike"],
                ["blockquote", "code-block"],
                [ ['header'=> 1 ], ['header'=> 2]],
                [['list'=> "ordered" ], ['list'=> "bullet" ]],
                [[ 'script'=> "sub" ], [ 'script'=> "super" ]],
                [[ 'indent'=> "-1" ], [ 'indent'=> "+1" ]],
                [[ 'direction'=> "rtl" ]],
                [[ 'size'=> ["small", false, "large", "huge"] ]],
                [[ 'header'=> [1, 2, 3, 4, 5, 6, false] ]],
                [[ 'color'=> [] ], [ 'background'=> [] ]],
                [[ 'font'=> [] ]],
                [[ 'align'=> [] ]],
                ["clean"],
                ["link", "image", "video"]
        ]),

Video embed

Only support Youtube Facebook,default size in Nova was width 800px and height 450px,define in css

.ql-video{
  width: 800px;
  height: 450px;
}

Youtube

Facebook

nova-quilljs's People

Contributors

ek0519 avatar ekman0519 avatar gavro avatar mennotempelaar avatar urbanfivable avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nova-quilljs's Issues

Undefined property $attachCallback

Hi,

Thanks for this package!

However, I'm getting

ErrorException: Undefined property: Laravel\Nova\Fields\Text::$attachCallback in file /asdf/vendor/ek0519/quilljs/src/Http/Controllers/UploadController.php on line 26

Any ideas?

请修改你的README文档内容

你一个老外,请不要在readme里放入不利**的内容链接,香港事务,你无权干预和评论,请删掉这些链接!像你这样不尊重国家主权的开发者, 代码也是不值得信任的。耗子尾汁!

You are a foreigner, please do not put in the readme adverse links to China, Hong Kong affairs, you have no right to intervene and comment, please delete these links! For developers like you who don't respect national sovereignty, code can't be trusted. Rat tail juice!

Editor Height

Thank you for this great package. Is there any option to set a height for the editor? And is it possible to resize it?

Error when updating Nova from v3.8.4 to v3.9.2

Hey there,

First of all, I like your package very much!

The placeholder method which is being used within the Ek0519\Quilljs\Quilljs class overrides the placeholder method within the Laravel\Nova\Fields\Field.

I guess within these updates the placeholder method has been changed to:

/**
 * Set the placeholder text for the field if supported.
 *
 * @param string $text
 * @return $this
 */
public function placeholder($text)
{
    $this->placeholder = $text;
    $this->withMeta(['extraAttributes' => ['placeholder' => $text]]);

    return $this;
}

This gives an error like this:

Declaration of Ek0519\Quilljs\Quilljs::placeholder(string $value) should be compatible with Laravel\Nova\Fields\Field::placeholder($text) {"userId":1,"exception":"[object] (ErrorException(code: 0): Declaration of Ek0519\\Quilljs\\Quilljs::placeholder(string $value) should be compatible with Laravel\\Nova\\Fields\\Field::placeholder($text) at /vendor/ek0519/quilljs/src/Quilljs.php:53)

So I did change the placeholder method within the Ek0519\Quilljs\Quilljs class to:

public function placeholder($text)
{
    return $this->withMeta(['placeholder'=> $text]);
}

And this fixes the issue.

I don't know how you want to update this; Should I send you a PR?

Paste html markup in Quill Editor

Hi,

I've got a question about the conversion of pasted markup in the QuillJS Editor. I would like to give editors the option to paste existing markup inside the editor, but the editor doesn't seem to convert it to correct html. Can you tell me if this is supported within this plugin, and if so how I can enable this feature?

For example:

<table>
    <thead>
        <tr>
            <th colspan="2">The table header</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>The table body</td>
            <td>with two columns</td>
        </tr>
    </tbody>
</table>

Is converted to:

<div class="ql-editor" data-gramm="false" contenteditable="true">
    <p>&lt;table&gt;</p>
    <p>&nbsp;&nbsp;&lt;thead&gt;</p>
    <p>&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;</p>
    <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;th colspan="2"&gt;The table header&lt;/th&gt;</p>
    <p>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr&gt;</p>
    <p>&nbsp;&nbsp;&lt;/thead&gt;</p>
    <p>&nbsp;&nbsp;&lt;tbody&gt;</p>
    <p>&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;</p>
    <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;The table body&lt;/td&gt;</p>
    <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;with two columns&lt;/td&gt;</p>
    <p>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr&gt;</p>
    <p>&nbsp;&nbsp;&lt;/tbody&gt;</p>
    <p>&lt;/table&gt;</p>
</div>

The image attachment does not getting save

Hi, firstly thank you for creating this awesome package! And I am implementing the field with image upload feature, the image uploaded and displayed fine. However, it does not move the record from nova_pending_trix_attachments table to nova_trix_attachments after resource updated. I am using the latest laravel nova version 3.18.0 with the original trix attachment do this fine. Could you please take a look?

Paragraph Spacing

Currently in when writing text in 'Normal' text style, and then press Enter, it skips a line.
It looks like it becomes double spaced.

Is it possible when pressing enter to go directly to the line below? (i.e. similar to this text editor on github)
Screen Shot 2020-03-27 at 11 54 50 AM

Editor overlaps fields below it

The editor overlaps any fields below it (in Firefox) at least.
image

What solves it for me is setting the height on .ql-container instead of .quill-editor. Also the padding-bottom is not needed that way. Of course the overall height of the editor then exceeds the set height due to the height of the toolbar, but I would prefer that to overlapping.

TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))

Hi,
I got an error message when using this package.
I don't know whether it affects the function or not.
I'm using the last version of laravel nova.

vendor.js?id=0846a9071dc76942659b:1 TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
    at p.mounted (quilljs:1)
    at Pt (vendor.js?id=0846a9071dc76942659b:1)
    at en (vendor.js?id=0846a9071dc76942659b:1)
    at Object.insert (vendor.js?id=0846a9071dc76942659b:1)
    at y (vendor.js?id=0846a9071dc76942659b:1)
    at p.__patch__ (vendor.js?id=0846a9071dc76942659b:1)
    at p.t._update (vendor.js?id=0846a9071dc76942659b:1)
    at p.ln.before (vendor.js?id=0846a9071dc76942659b:1)
    at ln.get (vendor.js?id=0846a9071dc76942659b:1)
    at ln.run (vendor.js?id=0846a9071dc76942659b:1)
It @ vendor.js?id=0846a9071dc76942659b:1
jt @ vendor.js?id=0846a9071dc76942659b:1
Yt @ vendor.js?id=0846a9071dc76942659b:1
Pt @ vendor.js?id=0846a9071dc76942659b:1
en @ vendor.js?id=0846a9071dc76942659b:1
insert @ vendor.js?id=0846a9071dc76942659b:1
y @ vendor.js?id=0846a9071dc76942659b:1
(anonymous) @ vendor.js?id=0846a9071dc76942659b:1
t._update @ vendor.js?id=0846a9071dc76942659b:1
ln.before @ vendor.js?id=0846a9071dc76942659b:1
ln.get @ vendor.js?id=0846a9071dc76942659b:1
ln.run @ vendor.js?id=0846a9071dc76942659b:1
un @ vendor.js?id=0846a9071dc76942659b:1
(anonymous) @ vendor.js?id=0846a9071dc76942659b:1
Gt @ vendor.js?id=0846a9071dc76942659b:1
Promise.then (async)
Vt @ vendor.js?id=0846a9071dc76942659b:1
ee @ vendor.js?id=0846a9071dc76942659b:1
(anonymous) @ vendor.js?id=0846a9071dc76942659b:1
ln.update @ vendor.js?id=0846a9071dc76942659b:1
Mt.notify @ vendor.js?id=0846a9071dc76942659b:1
set @ vendor.js?id=0846a9071dc76942659b:1
On.dn.set @ vendor.js?id=0846a9071dc76942659b:1
(anonymous) @ app.js?id=866a14858a4d8d105161:1
k @ app.js?id=866a14858a4d8d105161:1
(anonymous) @ app.js?id=866a14858a4d8d105161:1
e.<computed> @ app.js?id=866a14858a4d8d105161:1
o @ app.js?id=866a14858a4d8d105161:1
(anonymous) @ app.js?id=866a14858a4d8d105161:1
Promise.then (async)
o @ app.js?id=866a14858a4d8d105161:1
(anonymous) @ app.js?id=866a14858a4d8d105161:1
t @ app.js?id=866a14858a4d8d105161:1
(anonymous) @ app.js?id=866a14858a4d8d105161:1
(anonymous) @ app.js?id=866a14858a4d8d105161:1
(anonymous) @ app.js?id=866a14858a4d8d105161:1
k @ app.js?id=866a14858a4d8d105161:1
(anonymous) @ app.js?id=866a14858a4d8d105161:1
e.<computed> @ app.js?id=866a14858a4d8d105161:1
o @ app.js?id=866a14858a4d8d105161:1
(anonymous) @ app.js?id=866a14858a4d8d105161:1
t @ app.js?id=866a14858a4d8d105161:1
(anonymous) @ app.js?id=866a14858a4d8d105161:1
(anonymous) @ app.js?id=866a14858a4d8d105161:1
Pt @ vendor.js?id=0846a9071dc76942659b:1
en @ vendor.js?id=0846a9071dc76942659b:1
vn._init @ vendor.js?id=0846a9071dc76942659b:1
p @ vendor.js?id=0846a9071dc76942659b:1
(anonymous) @ vendor.js?id=0846a9071dc76942659b:1
init @ vendor.js?id=0846a9071dc76942659b:1
n @ vendor.js?id=0846a9071dc76942659b:1
(anonymous) @ vendor.js?id=0846a9071dc76942659b:1
M @ vendor.js?id=0846a9071dc76942659b:1
(anonymous) @ vendor.js?id=0846a9071dc76942659b:1
t._update @ vendor.js?id=0846a9071dc76942659b:1
ln.before @ vendor.js?id=0846a9071dc76942659b:1
ln.get @ vendor.js?id=0846a9071dc76942659b:1
ln.run @ vendor.js?id=0846a9071dc76942659b:1
un @ vendor.js?id=0846a9071dc76942659b:1
(anonymous) @ vendor.js?id=0846a9071dc76942659b:1
Gt @ vendor.js?id=0846a9071dc76942659b:1
Promise.then (async)
Vt @ vendor.js?id=0846a9071dc76942659b:1
ee @ vendor.js?id=0846a9071dc76942659b:1
t.$nextTick @ vendor.js?id=0846a9071dc76942659b:1
(anonymous) @ app.js?id=866a14858a4d8d105161:1
k @ app.js?id=866a14858a4d8d105161:1
(anonymous) @ app.js?id=866a14858a4d8d105161:1
e.<computed> @ app.js?id=866a14858a4d8d105161:1
o @ app.js?id=866a14858a4d8d105161:1
(anonymous) @ app.js?id=866a14858a4d8d105161:1
Promise.then (async)
o @ app.js?id=866a14858a4d8d105161:1
(anonymous) @ app.js?id=866a14858a4d8d105161:1
t @ app.js?id=866a14858a4d8d105161:1
(anonymous) @ app.js?id=866a14858a4d8d105161:1
l @ app.js?id=866a14858a4d8d105161:1
z @ vendor.js?id=0846a9071dc76942659b:1
o @ vendor.js?id=0846a9071dc76942659b:1
lt @ vendor.js?id=0846a9071dc76942659b:1
qt.confirmTransition @ vendor.js?id=0846a9071dc76942659b:1
qt.transitionTo @ vendor.js?id=0846a9071dc76942659b:1
xt.init @ vendor.js?id=0846a9071dc76942659b:1
beforeCreate @ vendor.js?id=0846a9071dc76942659b:1
Pt @ vendor.js?id=0846a9071dc76942659b:1
en @ vendor.js?id=0846a9071dc76942659b:1
vn._init @ vendor.js?id=0846a9071dc76942659b:1
vn @ vendor.js?id=0846a9071dc76942659b:1
value @ app.js?id=866a14858a4d8d105161:1
(anonymous) @ edit?viaResource=&viaResourceId=&viaRelationship=:232

MIssing styles when showing stored contnet on resource details page.

Consider these..

Screenshot from 2021-06-11 14-50-43

How can I add styles for the indented, centered and right aligned texts or overwrite the .ql-indent-x & .ql-align-x classes?

In the front-end I just targeted a parent class quill and then in it .ql-indent-x etc.. but in Nova, that is not an option.

Maybe If a create a custom field to extend this one, I can add my styles? Doesn't seem like the right way to go about it though...

Image upload error

Hi,

I have done all the steps below:
composer require ek0519/quilljs
php artisan vendor:publish --provider="Ek0519\Quilljs\FieldServiceProvider"
php artisan migrate
php artisan storage:link

But when I upload a image, even it is a small logo image, it will show [upload error].
Other function like text or embedding video work perfectly.

Can let me know how to solve this?

404 error on image upload

Zrzut ekranu 2020-11-21 170811

I have done all the steps:
composer require ek0519/quilljs
php artisan vendor:publish --provider="Ek0519\Quilljs\FieldServiceProvider"
php artisan migrate
php artisan storage:link

Laravel Nova ver 3.14

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.