Editor: Include Tables extensions or a guide to install the Tables extensions #1672
-
Hello, Has anyone had any luck adding the TipTapTables extensions to the Editor? I've tried following the Flux docs and TipTap docs and have had no luck. Here's what I've done so far:
My javascript is pretty weak and I've been modifying this code with the help of AI so it is becoming quite a mess. Any help or guidance in the right direction would be greatly appreciated. Kevin |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is my <flux:tooltip content="{{ __('Table') }}" class="contents">
<flux:editor.button x-on:click="$el.closest('[data-flux-editor]').editor.chain().focus().insertTable().run()">
<flux:icon.table-cells class="size-5!" />
</flux:editor.button>
</flux:tooltip>
<flux:dropdown position="bottom start">
<flux:editor.button tooltip="Column" class="">
<flux:icon.between-vertical-start class="size-5!" />
<flux:icon.chevron-down class="size-4!" />
</flux:editor.button>
<flux:menu>
<flux:menu.item x-on:click="$el.closest('[data-flux-editor]').editor.chain().focus().toggleHeaderColumn().run()" icon="toggle-right">{{ __('Toggle header column') }}</flux:menu.item>
<flux:menu.item x-on:click="$el.closest('[data-flux-editor]').editor.chain().focus().addColumnAfter().run()" icon="chevron-right">{{ __('Insert column after') }}</flux:menu.item>
<flux:menu.item x-on:click="$el.closest('[data-flux-editor]').editor.chain().focus().addColumnBefore().run()" icon="chevron-left">{{ __('Insert column before') }}</flux:menu.item>
<flux:menu.item x-on:click="$el.closest('[data-flux-editor]').editor.chain().focus().deleteColumn().run()" icon="x-mark">{{ __('Delete column') }}</flux:menu.item>
</flux:menu>
</flux:dropdown>
<flux:dropdown position="bottom start">
<flux:editor.button tooltip="Row" class="">
<flux:icon.between-horizontal-start class="size-5!" />
<flux:icon.chevron-down class="size-4!" />
</flux:editor.button>
<flux:menu>
<flux:menu.item x-on:click="$el.closest('[data-flux-editor]').editor.chain().focus().toggleHeaderRow().run()" icon="toggle-left">{{ __('Toggle header row') }}</flux:menu.item>
<flux:menu.item x-on:click="$el.closest('[data-flux-editor]').editor.chain().focus().addRowAfter().run()" icon="chevron-down">{{ __('Insert row after') }}</flux:menu.item>
<flux:menu.item x-on:click="$el.closest('[data-flux-editor]').editor.chain().focus().addRowBefore().run()" icon="chevron-up">{{ __('Insert row before') }}</flux:menu.item>
<flux:menu.item x-on:click="$el.closest('[data-flux-editor]').editor.chain().focus().deleteRow().run()" icon="x-mark">{{ __('Delete row') }}</flux:menu.item>
</flux:menu>
</flux:dropdown> And import { TableKit } from '@tiptap/extension-table'
document.addEventListener('flux:editor', (e) => {
e.detail.registerExtensions([
TableKit.configure({
table: {
resizable: true,
// HTMLAttributes: {
// class: 'min-w-full divide-y divide-gray-200',
// },
}
}),
]);
}); And last but no least /* Basic editor styles */
[data-flux-editor] .tiptap {
/* Table-specific styling */
table {
border-collapse: collapse;
/* margin: 0; */
margin-bottom: 1rem;
overflow: hidden;
table-layout: fixed;
width: 100%;
td,
th {
border: 1px solid var(--color-gray-300);
box-sizing: border-box;
min-width: 1em;
padding: 6px 8px;
position: relative;
vertical-align: top;
> * {
margin-bottom: 0;
}
}
th {
background-color: var(--color-gray-100);
font-weight: bold;
text-align: left;
}
.selectedCell:after {
background: var(--color-gray-200);
content: '';
left: 0;
right: 0;
top: 0;
bottom: 0;
pointer-events: none;
position: absolute;
z-index: 2;
}
.column-resize-handle {
background-color: var(--color-purple-500);
bottom: -2px;
pointer-events: none;
position: absolute;
right: -2px;
top: 0;
width: 4px;
}
}
.tableWrapper {
margin: 1.5rem 0;
overflow-x: auto;
}
&.resize-cursor {
cursor: ew-resize;
cursor: col-resize;
}
} On one hand you can find the usage of the TipTap plugin here: https://tiptap.dev/docs/editor/extensions/nodes/table |
Beta Was this translation helpful? Give feedback.
This is my
resources/views/flux/editor/table.blade.php
: