Skip to content

Commit

Permalink
Fixed remove "\r\n" Quill editor when usage code block
Browse files Browse the repository at this point in the history
  • Loading branch information
tabuna committed Sep 10, 2023
1 parent 69beee0 commit a6168a1
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 18 deletions.
11 changes: 6 additions & 5 deletions public/css/orchid.rtl.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/css/orchid.rtl.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/orchid.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/orchid.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions public/mix-manifest.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions resources/js/controllers/quill_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ export default class extends ApplicationController {
connect() {
const quill = Quill;
const selector = this.element.querySelector('.quill').id;
const input = this.element.querySelector('input');
const textarea = this.element.querySelector('textarea');

const options = {
placeholder: input.placeholder,
readOnly: input.readOnly,
placeholder: textarea.placeholder,
readOnly: textarea.readOnly,
theme: 'snow',
modules: {
toolbar: {
Expand Down Expand Up @@ -42,13 +42,13 @@ export default class extends ApplicationController {
let value = JSON.parse(this.data.get("value"))

// set value
// editor.setText(input.value);
this.editor.root.innerHTML = input.value = value;
this.editor.root.innerHTML = textarea.value = value;

// save value
this.editor.on('text-change', () => {
input.value = this.editor.getText() ? this.editor.root.innerHTML : '';
input.dispatchEvent(new Event('change'));
// When usage this.editor.root.innerHtml "/n/r" has been lost
textarea.value = this.element.querySelector('.ql-editor').innerHTML || "";
textarea.dispatchEvent(new Event('change'));
});

this.editor.getModule('toolbar').addHandler('color', (value) => {
Expand Down
2 changes: 1 addition & 1 deletion resources/views/fields/quill.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<div class="quill p-3 position-relative" id="quill-wrapper-{{$id}}"
style="min-height: {{ $attributes['height'] }}">
</div>
<input class="d-none" {{ $attributes }}>
<textarea class="d-none" {{ $attributes }}></textarea>
</div>
@endcomponent

0 comments on commit a6168a1

Please sign in to comment.