Skip to content

Commit

Permalink
Fix: quotes in blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
awcodes committed Dec 20, 2023
1 parent 5d83fba commit a617540
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
14 changes: 7 additions & 7 deletions resources/dist/filament-tiptap-editor.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions resources/js/extensions/TiptapBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,25 @@ export const TiptapBlock = Node.create({
dom.contentEditable = 'false'
dom.classList.add('tiptap-block-wrapper')

const data = typeof node.attrs.data === 'object'
let data = typeof node.attrs.data === 'object'
? JSON.stringify(node.attrs.data)
: node.attrs.data

dom.innerHTML = `
<div
x-data='{
x-data="{
showOptionsButton: ${data === '[]' ? 'false' : 'true'},
openSettings() {
this.$dispatch("open-block-settings", {
type: "${node.attrs.type}",
statePath: "${node.attrs.statePath}",
data: JSON.parse(\`${data}\`),
this.$dispatch('open-block-settings', {
type: \`${node.attrs.type}\`,
statePath: \`${node.attrs.statePath}\`,
data: ${data},
})
},
deleteBlock() {
this.$dispatch("delete-block")
this.$dispatch('delete-block')
}
}'
}"
class="tiptap-block"
style="min-height: 3rem;"
>
Expand Down
5 changes: 3 additions & 2 deletions src/TiptapEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use FilamentTiptapEditor\Concerns\InteractsWithMedia;
use FilamentTiptapEditor\Concerns\InteractsWithMenus;
use Illuminate\Support\Arr;
use Illuminate\Support\Js;
use Illuminate\Support\Str;
use Livewire\Component;

Expand Down Expand Up @@ -268,7 +269,7 @@ public function getInsertBlockAction(): Action
event: 'insert-block',
statePath: $component->getStatePath(),
type: $arguments['type'],
data: $data,
data: Js::from($data)->toHtml(),
preview: $block->getPreview($data),
label: $block->getLabel(),
coordinates: $arguments['coordinates'] ?? [],
Expand Down Expand Up @@ -307,7 +308,7 @@ public function getUpdateBlockAction(): Action
event: 'update-block',
statePath: $component->getStatePath(),
type: $arguments['type'],
data: $data,
data: Js::from($data)->toHtml(),
preview: $block->getPreview($data),
label: $block->getLabel(),
);
Expand Down

0 comments on commit a617540

Please sign in to comment.