mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-07 13:41:23 +00:00
Merge branch 'master' into master
This commit is contained in:
@@ -21,12 +21,11 @@ class InvoicesController extends Controller
|
|||||||
{
|
{
|
||||||
$this->authorize('viewAny', Invoice::class);
|
$this->authorize('viewAny', Invoice::class);
|
||||||
|
|
||||||
$limit = $request->has('limit') ? $request->limit : 10;
|
$limit = $request->input('limit', 10);
|
||||||
|
|
||||||
$invoices = Invoice::whereCompany()
|
$invoices = Invoice::whereCompany()
|
||||||
->join('customers', 'customers.id', '=', 'invoices.customer_id')
|
|
||||||
->applyFilters($request->all())
|
->applyFilters($request->all())
|
||||||
->select('invoices.*', 'customers.name')
|
->with('customer')
|
||||||
->latest()
|
->latest()
|
||||||
->paginateData($limit);
|
->paginateData($limit);
|
||||||
|
|
||||||
|
|||||||
@@ -49,8 +49,10 @@ class CustomerRequest extends FormRequest
|
|||||||
'prefix' => [
|
'prefix' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
],
|
],
|
||||||
|
'tax_id' => [
|
||||||
|
'nullable',
|
||||||
|
],
|
||||||
'enable_portal' => [
|
'enable_portal' => [
|
||||||
|
|
||||||
'boolean',
|
'boolean',
|
||||||
],
|
],
|
||||||
'currency_id' => [
|
'currency_id' => [
|
||||||
@@ -133,6 +135,7 @@ class CustomerRequest extends FormRequest
|
|||||||
'password',
|
'password',
|
||||||
'phone',
|
'phone',
|
||||||
'prefix',
|
'prefix',
|
||||||
|
'tax_id',
|
||||||
'company_name',
|
'company_name',
|
||||||
'contact_name',
|
'contact_name',
|
||||||
'website',
|
'website',
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class CustomerResource extends JsonResource
|
|||||||
'formatted_created_at' => $this->formattedCreatedAt,
|
'formatted_created_at' => $this->formattedCreatedAt,
|
||||||
'avatar' => $this->avatar,
|
'avatar' => $this->avatar,
|
||||||
'prefix' => $this->prefix,
|
'prefix' => $this->prefix,
|
||||||
|
'tax_id' => $this->tax_id,
|
||||||
'billing' => $this->when($this->billingAddress()->exists(), function () {
|
'billing' => $this->when($this->billingAddress()->exists(), function () {
|
||||||
return new AddressResource($this->billingAddress);
|
return new AddressResource($this->billingAddress);
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class CustomerResource extends JsonResource
|
|||||||
'due_amount' => $this->due_amount,
|
'due_amount' => $this->due_amount,
|
||||||
'base_due_amount' => $this->base_due_amount,
|
'base_due_amount' => $this->base_due_amount,
|
||||||
'prefix' => $this->prefix,
|
'prefix' => $this->prefix,
|
||||||
|
'tax_id' => $this->tax_id,
|
||||||
'billing' => $this->when($this->billingAddress()->exists(), function () {
|
'billing' => $this->when($this->billingAddress()->exists(), function () {
|
||||||
return new AddressResource($this->billingAddress);
|
return new AddressResource($this->billingAddress);
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -248,53 +248,34 @@ class Invoice extends Model implements HasMedia
|
|||||||
|
|
||||||
public function scopeApplyFilters($query, array $filters)
|
public function scopeApplyFilters($query, array $filters)
|
||||||
{
|
{
|
||||||
$filters = collect($filters);
|
$filters = collect($filters)->filter()->all();
|
||||||
|
|
||||||
if ($filters->get('search')) {
|
return $query->when($filters['search'] ?? null, function ($query, $search) {
|
||||||
$query->whereSearch($filters->get('search'));
|
$query->whereSearch($search);
|
||||||
}
|
})->when($filters['status'] ?? null, function ($query, $status) {
|
||||||
|
match ($status) {
|
||||||
if ($filters->get('status')) {
|
self::STATUS_UNPAID, self::STATUS_PARTIALLY_PAID, self::STATUS_PAID => $query->wherePaidStatus($status),
|
||||||
if (
|
'DUE' => $query->whereDueStatus($status),
|
||||||
$filters->get('status') == self::STATUS_UNPAID ||
|
default => $query->whereStatus($status),
|
||||||
$filters->get('status') == self::STATUS_PARTIALLY_PAID ||
|
};
|
||||||
$filters->get('status') == self::STATUS_PAID
|
})->when($filters['paid_status'] ?? null, function ($query, $paidStatus) {
|
||||||
) {
|
$query->wherePaidStatus($paidStatus);
|
||||||
$query->wherePaidStatus($filters->get('status'));
|
})->when($filters['invoice_id'] ?? null, function ($query, $invoiceId) {
|
||||||
} elseif ($filters->get('status') == 'DUE') {
|
$query->whereInvoice($invoiceId);
|
||||||
$query->whereDueStatus($filters->get('status'));
|
})->when($filters['invoice_number'] ?? null, function ($query, $invoiceNumber) {
|
||||||
} else {
|
$query->whereInvoiceNumber($invoiceNumber);
|
||||||
$query->whereStatus($filters->get('status'));
|
})->when(($filters['from_date'] ?? null) && ($filters['to_date'] ?? null), function ($query) use ($filters) {
|
||||||
}
|
$start = Carbon::parse($filters['from_date']);
|
||||||
}
|
$end = Carbon::parse($filters['to_date']);
|
||||||
|
|
||||||
if ($filters->get('paid_status')) {
|
|
||||||
$query->wherePaidStatus($filters->get('status'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($filters->get('invoice_id')) {
|
|
||||||
$query->whereInvoice($filters->get('invoice_id'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($filters->get('invoice_number')) {
|
|
||||||
$query->whereInvoiceNumber($filters->get('invoice_number'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($filters->get('from_date') && $filters->get('to_date')) {
|
|
||||||
$start = Carbon::createFromFormat('Y-m-d', $filters->get('from_date'));
|
|
||||||
$end = Carbon::createFromFormat('Y-m-d', $filters->get('to_date'));
|
|
||||||
$query->invoicesBetween($start, $end);
|
$query->invoicesBetween($start, $end);
|
||||||
}
|
})->when($filters['customer_id'] ?? null, function ($query, $customerId) {
|
||||||
|
$query->where('customer_id', $customerId);
|
||||||
if ($filters->get('customer_id')) {
|
})->when($filters['orderByField'] ?? null, function ($query, $orderByField) use ($filters) {
|
||||||
$query->whereCustomer($filters->get('customer_id'));
|
$orderBy = $filters['orderBy'] ?? 'desc';
|
||||||
}
|
$query->orderBy($orderByField, $orderBy);
|
||||||
|
}, function ($query) {
|
||||||
if ($filters->get('orderByField') || $filters->get('orderBy')) {
|
$query->orderBy('sequence_number', 'desc');
|
||||||
$field = $filters->get('orderByField') ? $filters->get('orderByField') : 'sequence_number';
|
});
|
||||||
$orderBy = $filters->get('orderBy') ? $filters->get('orderBy') : 'desc';
|
|
||||||
$query->whereOrder($field, $orderBy);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scopeWhereInvoice($query, $invoice_id)
|
public function scopeWhereInvoice($query, $invoice_id)
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ trait GeneratesPdfTrait
|
|||||||
'{CONTACT_EMAIL}' => $customer->email,
|
'{CONTACT_EMAIL}' => $customer->email,
|
||||||
'{CONTACT_PHONE}' => $customer->phone,
|
'{CONTACT_PHONE}' => $customer->phone,
|
||||||
'{CONTACT_WEBSITE}' => $customer->website,
|
'{CONTACT_WEBSITE}' => $customer->website,
|
||||||
|
'{CONTACT_TAX_ID}' => __('pdf_tax_id').': '.$customer->tax_id,
|
||||||
];
|
];
|
||||||
|
|
||||||
$customFields = $this->fields;
|
$customFields = $this->fields;
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('customers', function (Blueprint $table) {
|
||||||
|
$table->string('tax_id')->nullable()->after('github_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('customers', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('tax_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -172,6 +172,7 @@
|
|||||||
"customers": {
|
"customers": {
|
||||||
"title": "Customers",
|
"title": "Customers",
|
||||||
"prefix": "Prefix",
|
"prefix": "Prefix",
|
||||||
|
"tax_id": "Tax ID",
|
||||||
"add_customer": "Add Customer",
|
"add_customer": "Add Customer",
|
||||||
"contacts_list": "Customer List",
|
"contacts_list": "Customer List",
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
|
|||||||
13
package.json
13
package.json
@@ -2,7 +2,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite --host",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"serve": "vite preview",
|
"serve": "vite preview",
|
||||||
"test": "eslint ./resources/scripts --ext .js,.vue"
|
"test": "eslint ./resources/scripts --ext .js,.vue"
|
||||||
@@ -30,11 +30,12 @@
|
|||||||
"@heroicons/vue": "^1.0.6",
|
"@heroicons/vue": "^1.0.6",
|
||||||
"@popperjs/core": "^2.11.8",
|
"@popperjs/core": "^2.11.8",
|
||||||
"@stripe/stripe-js": "^2.4.0",
|
"@stripe/stripe-js": "^2.4.0",
|
||||||
"@tiptap/core": "^2.1.16",
|
"@tiptap/core": "^2.8.0",
|
||||||
"@tiptap/extension-text-align": "^2.1.16",
|
"@tiptap/extension-link": "^2.8.0",
|
||||||
"@tiptap/pm": "^2.0.0",
|
"@tiptap/extension-text-align": "^2.8.0",
|
||||||
"@tiptap/starter-kit": "^2.1.16",
|
"@tiptap/pm": "^2.8.0",
|
||||||
"@tiptap/vue-3": "^2.1.16",
|
"@tiptap/starter-kit": "^2.8.0",
|
||||||
|
"@tiptap/vue-3": "^2.8.0",
|
||||||
"@types/node": "^20.11.9",
|
"@types/node": "^20.11.9",
|
||||||
"@vuelidate/components": "^1.2.6",
|
"@vuelidate/components": "^1.2.6",
|
||||||
"@vuelidate/core": "^2.0.3",
|
"@vuelidate/core": "^2.0.3",
|
||||||
|
|||||||
@@ -116,6 +116,15 @@
|
|||||||
/>
|
/>
|
||||||
</BaseInputGroup>
|
</BaseInputGroup>
|
||||||
</BaseInputGrid>
|
</BaseInputGrid>
|
||||||
|
|
||||||
|
<BaseInputGroup :label="$t('customers.tax_id')">
|
||||||
|
<BaseInput
|
||||||
|
v-model="customerStore.currentCustomer.tax_id"
|
||||||
|
type="text"
|
||||||
|
class="mt-1 md:mt-0"
|
||||||
|
/>
|
||||||
|
</BaseInputGroup>
|
||||||
|
|
||||||
</BaseInputGrid>
|
</BaseInputGrid>
|
||||||
</BaseTab>
|
</BaseTab>
|
||||||
|
|
||||||
|
|||||||
@@ -157,6 +157,24 @@
|
|||||||
@input="v$.currentCustomer.prefix.$touch()"
|
@input="v$.currentCustomer.prefix.$touch()"
|
||||||
/>
|
/>
|
||||||
</BaseInputGroup>
|
</BaseInputGroup>
|
||||||
|
|
||||||
|
<BaseInputGroup
|
||||||
|
:label="$t('customers.tax_id')"
|
||||||
|
:error="
|
||||||
|
v$.currentCustomer.tax_id.$error &&
|
||||||
|
v$.currentCustomer.tax_id.$errors[0].$message
|
||||||
|
"
|
||||||
|
:content-loading="isFetchingInitialData"
|
||||||
|
>
|
||||||
|
<BaseInput
|
||||||
|
v-model="customerStore.currentCustomer.tax_id"
|
||||||
|
:content-loading="isFetchingInitialData"
|
||||||
|
type="text"
|
||||||
|
name="tax_id"
|
||||||
|
:invalid="v$.currentCustomer.tax_id.$error"
|
||||||
|
@input="v$.currentCustomer.tax_id.$touch()"
|
||||||
|
/>
|
||||||
|
</BaseInputGroup>
|
||||||
</BaseInputGrid>
|
</BaseInputGrid>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -645,6 +663,9 @@ const rules = computed(() => {
|
|||||||
minLength(3)
|
minLength(3)
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
tax_id: {
|
||||||
|
required: helpers.withMessage(t('validation.required'), required),
|
||||||
|
},
|
||||||
currency_id: {
|
currency_id: {
|
||||||
required: helpers.withMessage(t('validation.required'), required),
|
required: helpers.withMessage(t('validation.required'), required),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -174,6 +174,7 @@
|
|||||||
:data="fetchData"
|
:data="fetchData"
|
||||||
:columns="estimateColumns"
|
:columns="estimateColumns"
|
||||||
:placeholder-count="estimateStore.totalEstimateCount >= 20 ? 10 : 5"
|
:placeholder-count="estimateStore.totalEstimateCount >= 20 ? 10 : 5"
|
||||||
|
:key="tableKey"
|
||||||
class="mt-10"
|
class="mt-10"
|
||||||
>
|
>
|
||||||
<template #header>
|
<template #header>
|
||||||
@@ -256,6 +257,7 @@ const dialogStore = useDialogStore()
|
|||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
|
|
||||||
const tableComponent = ref(null)
|
const tableComponent = ref(null)
|
||||||
|
const tableKey = ref(0)
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const showFilters = ref(false)
|
const showFilters = ref(false)
|
||||||
const status = ref([
|
const status = ref([
|
||||||
@@ -408,6 +410,8 @@ function setFilters() {
|
|||||||
state.selectAllField = false
|
state.selectAllField = false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
tableKey.value += 1
|
||||||
|
|
||||||
refreshTable()
|
refreshTable()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,6 +172,7 @@
|
|||||||
:data="fetchData"
|
:data="fetchData"
|
||||||
:columns="invoiceColumns"
|
:columns="invoiceColumns"
|
||||||
:placeholder-count="invoiceStore.invoiceTotalCount >= 20 ? 10 : 5"
|
:placeholder-count="invoiceStore.invoiceTotalCount >= 20 ? 10 : 5"
|
||||||
|
:key="tableKey"
|
||||||
class="mt-10"
|
class="mt-10"
|
||||||
>
|
>
|
||||||
<!-- Select All Checkbox -->
|
<!-- Select All Checkbox -->
|
||||||
@@ -288,6 +289,7 @@ const { t } = useI18n()
|
|||||||
// Local State
|
// Local State
|
||||||
const utils = inject('$utils')
|
const utils = inject('$utils')
|
||||||
const table = ref(null)
|
const table = ref(null)
|
||||||
|
const tableKey = ref(0)
|
||||||
const showFilters = ref(false)
|
const showFilters = ref(false)
|
||||||
|
|
||||||
const status = ref([
|
const status = ref([
|
||||||
@@ -416,9 +418,12 @@ async function fetchData({ page, filter, sort }) {
|
|||||||
page,
|
page,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(data)
|
||||||
|
|
||||||
isRequestOngoing.value = true
|
isRequestOngoing.value = true
|
||||||
|
|
||||||
let response = await invoiceStore.fetchInvoices(data)
|
let response = await invoiceStore.fetchInvoices(data)
|
||||||
|
console.log('API response:', response.data.data)
|
||||||
|
|
||||||
isRequestOngoing.value = false
|
isRequestOngoing.value = false
|
||||||
|
|
||||||
@@ -464,6 +469,8 @@ function setFilters() {
|
|||||||
state.selectAllField = false
|
state.selectAllField = false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
tableKey.value += 1
|
||||||
|
|
||||||
refreshTable()
|
refreshTable()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -180,6 +180,7 @@ async function getFields() {
|
|||||||
{ label: 'Email', value: 'CONTACT_EMAIL' },
|
{ label: 'Email', value: 'CONTACT_EMAIL' },
|
||||||
{ label: 'Phone', value: 'CONTACT_PHONE' },
|
{ label: 'Phone', value: 'CONTACT_PHONE' },
|
||||||
{ label: 'Website', value: 'CONTACT_WEBSITE' },
|
{ label: 'Website', value: 'CONTACT_WEBSITE' },
|
||||||
|
{ label: 'Tax ID', value: 'CONTACT_TAX_ID' },
|
||||||
...customerFields.value.map((i) => ({
|
...customerFields.value.map((i) => ({
|
||||||
label: i.label,
|
label: i.label,
|
||||||
value: i.slug,
|
value: i.slug,
|
||||||
|
|||||||
@@ -8,598 +8,73 @@
|
|||||||
</BaseContentPlaceholders>
|
</BaseContentPlaceholders>
|
||||||
<div
|
<div
|
||||||
v-else
|
v-else
|
||||||
class="
|
class="box-border w-full text-sm leading-8 text-left bg-white border border-gray-200 rounded-md min-h-[200px] overflow-hidden"
|
||||||
box-border
|
|
||||||
w-full
|
|
||||||
text-sm
|
|
||||||
leading-8
|
|
||||||
text-left
|
|
||||||
bg-white
|
|
||||||
border border-gray-200
|
|
||||||
rounded-md
|
|
||||||
min-h-[200px]
|
|
||||||
overflow-hidden
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<div v-if="editor" class="editor-content">
|
<div v-if="editor" class="editor-content">
|
||||||
<div class="flex justify-end p-2 border-b border-gray-200 md:hidden">
|
<div class="flex justify-end p-2 border-b border-gray-200 md:hidden">
|
||||||
<BaseDropdown width-class="w-48">
|
<BaseDropdown width-class="w-48">
|
||||||
<template #activator>
|
<template #activator>
|
||||||
<div
|
<div
|
||||||
class="
|
class="flex items-center justify-center w-6 h-6 ml-2 text-sm text-black bg-white rounded-sm md:h-9 md:w-9"
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
ml-2
|
|
||||||
text-sm text-black
|
|
||||||
bg-white
|
|
||||||
rounded-sm
|
|
||||||
md:h-9 md:w-9
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<dots-vertical-icon class="w-6 h-6 text-gray-600" />
|
<dots-vertical-icon class="w-6 h-6 text-gray-600" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<div class="flex flex-wrap space-x-1">
|
<div class="flex flex-wrap space-x-1">
|
||||||
<span
|
<button
|
||||||
class="
|
v-for="button in editorButtons"
|
||||||
flex
|
type="button"
|
||||||
items-center
|
:key="button.name"
|
||||||
justify-center
|
class="p-1 rounded hover:bg-gray-100"
|
||||||
w-6
|
@click="button.action"
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('bold') }"
|
|
||||||
@click="editor.chain().focus().toggleBold().run()"
|
|
||||||
>
|
>
|
||||||
<bold-icon class="h-3 cursor-pointer fill-current" />
|
<component
|
||||||
</span>
|
:is="button.icon"
|
||||||
<span
|
v-if="button.icon"
|
||||||
class="
|
class="w-4 h-4 text-gray-700 fill-gray-700"
|
||||||
flex
|
/>
|
||||||
items-center
|
<span v-else-if="button.text" class="px-1 text-sm font-medium text-gray-600">
|
||||||
justify-center
|
{{ button.text }}
|
||||||
w-6
|
</span>
|
||||||
h-6
|
</button>
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('italic') }"
|
|
||||||
@click="editor.chain().focus().toggleItalic().run()"
|
|
||||||
>
|
|
||||||
<italic-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('strike') }"
|
|
||||||
@click="editor.chain().focus().toggleStrike().run()"
|
|
||||||
>
|
|
||||||
<strikethrough-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('code') }"
|
|
||||||
@click="editor.chain().focus().toggleCode().run()"
|
|
||||||
>
|
|
||||||
<coding-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('paragraph') }"
|
|
||||||
@click="editor.chain().focus().setParagraph().run()"
|
|
||||||
>
|
|
||||||
<paragraph-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{
|
|
||||||
'bg-gray-200': editor.isActive('heading', { level: 1 }),
|
|
||||||
}"
|
|
||||||
@click="editor.chain().focus().toggleHeading({ level: 1 }).run()"
|
|
||||||
>
|
|
||||||
H1
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{
|
|
||||||
'bg-gray-200': editor.isActive('heading', { level: 2 }),
|
|
||||||
}"
|
|
||||||
@click="editor.chain().focus().toggleHeading({ level: 2 }).run()"
|
|
||||||
>
|
|
||||||
H2
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{
|
|
||||||
'bg-gray-200': editor.isActive('heading', { level: 3 }),
|
|
||||||
}"
|
|
||||||
@click="editor.chain().focus().toggleHeading({ level: 3 }).run()"
|
|
||||||
>
|
|
||||||
H3
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('bulletList') }"
|
|
||||||
@click="editor.chain().focus().toggleBulletList().run()"
|
|
||||||
>
|
|
||||||
<list-ul-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('orderedList') }"
|
|
||||||
@click="editor.chain().focus().toggleOrderedList().run()"
|
|
||||||
>
|
|
||||||
<list-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('blockquote') }"
|
|
||||||
@click="editor.chain().focus().toggleBlockquote().run()"
|
|
||||||
>
|
|
||||||
<quote-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('codeBlock') }"
|
|
||||||
@click="editor.chain().focus().toggleCodeBlock().run()"
|
|
||||||
>
|
|
||||||
<code-block-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('undo') }"
|
|
||||||
@click="editor.chain().focus().undo().run()"
|
|
||||||
>
|
|
||||||
<undo-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('redo') }"
|
|
||||||
@click="editor.chain().focus().redo().run()"
|
|
||||||
>
|
|
||||||
<redo-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</BaseDropdown>
|
</BaseDropdown>
|
||||||
</div>
|
</div>
|
||||||
<div class="hidden p-2 border-b border-gray-200 md:flex">
|
<div class="hidden p-2 border-b border-gray-200 md:flex">
|
||||||
<div class="flex flex-wrap space-x-1">
|
<div class="flex flex-wrap space-x-1">
|
||||||
<span
|
<button
|
||||||
class="
|
v-for="button in editorButtons"
|
||||||
flex
|
type="button"
|
||||||
items-center
|
:key="button.name"
|
||||||
justify-center
|
class="p-1 rounded hover:bg-gray-100"
|
||||||
w-6
|
@click="button.action"
|
||||||
h-6
|
>
|
||||||
rounded-sm
|
<component
|
||||||
cursor-pointer
|
:is="button.icon"
|
||||||
hover:bg-gray-100
|
v-if="button.icon"
|
||||||
"
|
class="w-4 h-4 text-gray-700 fill-gray-700"
|
||||||
:class="{ 'bg-gray-200': editor.isActive('bold') }"
|
/>
|
||||||
@click="editor.chain().focus().toggleBold().run()"
|
<span v-else-if="button.text" class="px-1 text-sm font-medium text-gray-600">
|
||||||
>
|
{{ button.text }}
|
||||||
<bold-icon class="h-3 cursor-pointer fill-current" />
|
</span>
|
||||||
</span>
|
</button>
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('italic') }"
|
|
||||||
@click="editor.chain().focus().toggleItalic().run()"
|
|
||||||
>
|
|
||||||
<italic-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('strike') }"
|
|
||||||
@click="editor.chain().focus().toggleStrike().run()"
|
|
||||||
>
|
|
||||||
<strikethrough-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('code') }"
|
|
||||||
@click="editor.chain().focus().toggleCode().run()"
|
|
||||||
>
|
|
||||||
<coding-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('paragraph') }"
|
|
||||||
@click="editor.chain().focus().setParagraph().run()"
|
|
||||||
>
|
|
||||||
<paragraph-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('heading', { level: 1 }) }"
|
|
||||||
@click="editor.chain().focus().toggleHeading({ level: 1 }).run()"
|
|
||||||
>
|
|
||||||
H1
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('heading', { level: 2 }) }"
|
|
||||||
@click="editor.chain().focus().toggleHeading({ level: 2 }).run()"
|
|
||||||
>
|
|
||||||
H2
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('heading', { level: 3 }) }"
|
|
||||||
@click="editor.chain().focus().toggleHeading({ level: 3 }).run()"
|
|
||||||
>
|
|
||||||
H3
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('bulletList') }"
|
|
||||||
@click="editor.chain().focus().toggleBulletList().run()"
|
|
||||||
>
|
|
||||||
<list-ul-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('orderedList') }"
|
|
||||||
@click="editor.chain().focus().toggleOrderedList().run()"
|
|
||||||
>
|
|
||||||
<list-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('blockquote') }"
|
|
||||||
@click="editor.chain().focus().toggleBlockquote().run()"
|
|
||||||
>
|
|
||||||
<quote-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('codeBlock') }"
|
|
||||||
@click="editor.chain().focus().toggleCodeBlock().run()"
|
|
||||||
>
|
|
||||||
<code-block-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('undo') }"
|
|
||||||
@click="editor.chain().focus().undo().run()"
|
|
||||||
>
|
|
||||||
<undo-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive('redo') }"
|
|
||||||
@click="editor.chain().focus().redo().run()"
|
|
||||||
>
|
|
||||||
<redo-icon class="h-3 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive({ textAlign: 'left' }) }"
|
|
||||||
@click="editor.chain().focus().setTextAlign('left').run()"
|
|
||||||
>
|
|
||||||
<menu-alt2-icon class="h-5 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive({ textAlign: 'right' }) }"
|
|
||||||
@click="editor.chain().focus().setTextAlign('right').run()"
|
|
||||||
>
|
|
||||||
<menu-alt3-icon class="h-5 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{
|
|
||||||
'bg-gray-200': editor.isActive({ textAlign: 'justify' }),
|
|
||||||
}"
|
|
||||||
@click="editor.chain().focus().setTextAlign('justify').run()"
|
|
||||||
>
|
|
||||||
<menu-icon class="h-5 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="
|
|
||||||
flex
|
|
||||||
items-center
|
|
||||||
justify-center
|
|
||||||
w-6
|
|
||||||
h-6
|
|
||||||
rounded-sm
|
|
||||||
cursor-pointer
|
|
||||||
hover:bg-gray-100
|
|
||||||
"
|
|
||||||
:class="{ 'bg-gray-200': editor.isActive({ textAlign: 'center' }) }"
|
|
||||||
@click="editor.chain().focus().setTextAlign('center').run()"
|
|
||||||
>
|
|
||||||
<menu-center-icon class="h-5 cursor-pointer fill-current" />
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<editor-content
|
<editor-content
|
||||||
:editor="editor"
|
:editor="editor"
|
||||||
class="
|
class="box-border relative w-full text-sm leading-8 text-left editor__content"
|
||||||
box-border
|
|
||||||
relative
|
|
||||||
w-full
|
|
||||||
text-sm
|
|
||||||
leading-8
|
|
||||||
text-left
|
|
||||||
editor__content
|
|
||||||
"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { onUnmounted, watch } from 'vue'
|
import { ref, onUnmounted, watch, markRaw } from 'vue'
|
||||||
import { useEditor, EditorContent } from '@tiptap/vue-3'
|
import { useEditor, EditorContent } from '@tiptap/vue-3'
|
||||||
import StarterKit from '@tiptap/starter-kit'
|
import StarterKit from '@tiptap/starter-kit'
|
||||||
import {
|
|
||||||
DotsVerticalIcon,
|
|
||||||
MenuAlt2Icon,
|
|
||||||
MenuAlt3Icon,
|
|
||||||
MenuIcon,
|
|
||||||
} from '@heroicons/vue/outline'
|
|
||||||
import TextAlign from '@tiptap/extension-text-align'
|
import TextAlign from '@tiptap/extension-text-align'
|
||||||
|
import Link from '@tiptap/extension-link'
|
||||||
|
import { DotsVerticalIcon } from '@heroicons/vue/outline'
|
||||||
import {
|
import {
|
||||||
BoldIcon,
|
BoldIcon,
|
||||||
CodingIcon,
|
CodingIcon,
|
||||||
@@ -614,26 +89,12 @@ import {
|
|||||||
CodeBlockIcon,
|
CodeBlockIcon,
|
||||||
MenuCenterIcon,
|
MenuCenterIcon,
|
||||||
} from './icons/index.js'
|
} from './icons/index.js'
|
||||||
|
import { MenuAlt2Icon, MenuAlt3Icon, MenuIcon, LinkIcon } from '@heroicons/vue/solid'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
EditorContent,
|
EditorContent,
|
||||||
BoldIcon,
|
|
||||||
CodingIcon,
|
|
||||||
ItalicIcon,
|
|
||||||
ListIcon,
|
|
||||||
ListUlIcon,
|
|
||||||
ParagraphIcon,
|
|
||||||
QuoteIcon,
|
|
||||||
StrikethroughIcon,
|
|
||||||
UndoIcon,
|
|
||||||
RedoIcon,
|
|
||||||
CodeBlockIcon,
|
|
||||||
DotsVerticalIcon,
|
DotsVerticalIcon,
|
||||||
MenuCenterIcon,
|
|
||||||
MenuAlt2Icon,
|
|
||||||
MenuAlt3Icon,
|
|
||||||
MenuIcon,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
@@ -646,7 +107,9 @@ export default {
|
|||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
emits: ['update:modelValue'],
|
emits: ['update:modelValue'],
|
||||||
|
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const editor = useEditor({
|
const editor = useEditor({
|
||||||
content: props.modelValue,
|
content: props.modelValue,
|
||||||
@@ -656,38 +119,62 @@ export default {
|
|||||||
types: ['heading', 'paragraph'],
|
types: ['heading', 'paragraph'],
|
||||||
alignments: ['left', 'right', 'center', 'justify'],
|
alignments: ['left', 'right', 'center', 'justify'],
|
||||||
}),
|
}),
|
||||||
|
Link.configure({
|
||||||
|
openOnClick: false,
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
|
onUpdate: ({ editor }) => {
|
||||||
onUpdate: () => {
|
emit('update:modelValue', editor.getHTML())
|
||||||
emit('update:modelValue', editor.value.getHTML())
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
const editorButtons = ref([
|
||||||
() => props.modelValue,
|
{ name: 'bold', icon: markRaw(BoldIcon), action: () => editor.value.chain().focus().toggleBold().run() },
|
||||||
(value) => {
|
{ name: 'italic', icon: markRaw(ItalicIcon), action: () => editor.value.chain().focus().toggleItalic().run() },
|
||||||
const isSame = editor.value.getHTML() === value
|
{ name: 'strike', icon: markRaw(StrikethroughIcon), action: () => editor.value.chain().focus().toggleStrike().run() },
|
||||||
|
{ name: 'code', icon: markRaw(CodingIcon), action: () => editor.value.chain().focus().toggleCode().run() },
|
||||||
if (isSame) {
|
{ name: 'paragraph', icon: markRaw(ParagraphIcon), action: () => editor.value.chain().focus().setParagraph().run() },
|
||||||
return
|
{ name: 'h1', text: 'H1', action: () => editor.value.chain().focus().toggleHeading({ level: 1 }).run() },
|
||||||
|
{ name: 'h2', text: 'H2', action: () => editor.value.chain().focus().toggleHeading({ level: 2 }).run() },
|
||||||
|
{ name: 'h3', text: 'H3', action: () => editor.value.chain().focus().toggleHeading({ level: 3 }).run() },
|
||||||
|
{ name: 'bulletList', icon: markRaw(ListUlIcon), action: () => editor.value.chain().focus().toggleBulletList().run() },
|
||||||
|
{ name: 'orderedList', icon: markRaw(ListIcon), action: () => editor.value.chain().focus().toggleOrderedList().run() },
|
||||||
|
{ name: 'blockquote', icon: markRaw(QuoteIcon), action: () => editor.value.chain().focus().toggleBlockquote().run() },
|
||||||
|
{ name: 'codeBlock', icon: markRaw(CodeBlockIcon), action: () => editor.value.chain().focus().toggleCodeBlock().run() },
|
||||||
|
{ name: 'undo', icon: markRaw(UndoIcon), action: () => editor.value.chain().focus().undo().run() },
|
||||||
|
{ name: 'redo', icon: markRaw(RedoIcon), action: () => editor.value.chain().focus().redo().run() },
|
||||||
|
{ name: 'alignLeft', icon: markRaw(MenuAlt2Icon), action: () => editor.value.chain().focus().setTextAlign('left').run() },
|
||||||
|
{ name: 'alignRight', icon: markRaw(MenuAlt3Icon), action: () => editor.value.chain().focus().setTextAlign('right').run() },
|
||||||
|
{ name: 'alignJustify', icon: markRaw(MenuIcon), action: () => editor.value.chain().focus().setTextAlign('justify').run() },
|
||||||
|
{ name: 'alignCenter', icon: markRaw(MenuCenterIcon), action: () => editor.value.chain().focus().setTextAlign('center').run() },
|
||||||
|
{ name: 'addLink', icon: markRaw(LinkIcon), action: () => {
|
||||||
|
const url = window.prompt('URL')
|
||||||
|
if (url) {
|
||||||
|
editor.value.chain().focus().setLink({ href: url }).run()
|
||||||
}
|
}
|
||||||
|
}},
|
||||||
|
])
|
||||||
|
|
||||||
editor.value.commands.setContent(props.modelValue, false)
|
watch(() => props.modelValue, (newValue) => {
|
||||||
|
if (editor.value && newValue !== editor.value.getHTML()) {
|
||||||
|
editor.value.commands.setContent(newValue, false)
|
||||||
}
|
}
|
||||||
)
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
setTimeout(() => {
|
if (editor.value) {
|
||||||
editor.value.destroy()
|
editor.value.destroy()
|
||||||
}, 500)
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
editor,
|
editor,
|
||||||
|
editorButtons,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.ProseMirror {
|
.ProseMirror {
|
||||||
min-height: 200px;
|
min-height: 200px;
|
||||||
@@ -747,6 +234,11 @@ export default {
|
|||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: rgb(var(--color-primary-500));
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.ProseMirror:focus {
|
.ProseMirror:focus {
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
let rows = reactive([])
|
const rows = ref([])
|
||||||
let isLoading = ref(false)
|
let isLoading = ref(false)
|
||||||
|
|
||||||
let tableColumns = reactive(props.columns.map((column) => new Column(column)))
|
let tableColumns = reactive(props.columns.map((column) => new Column(column)))
|
||||||
@@ -339,14 +339,13 @@ function lodashGet(array, key) {
|
|||||||
return get(array, key)
|
return get(array, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usesLocalData.value) {
|
watch(
|
||||||
watch(
|
() => props.data,
|
||||||
() => props.data,
|
() => {
|
||||||
() => {
|
mapDataToRows()
|
||||||
mapDataToRows()
|
},
|
||||||
}
|
{ deep: true }
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await mapDataToRows()
|
await mapDataToRows()
|
||||||
|
|||||||
5
resources/scripts/main.js
vendored
5
resources/scripts/main.js
vendored
@@ -14,11 +14,10 @@ import.meta.glob([
|
|||||||
|
|
||||||
window.pinia = pinia
|
window.pinia = pinia
|
||||||
window.Vuelidate = Vuelidate
|
window.Vuelidate = Vuelidate
|
||||||
|
import InvoiceShelf from './InvoiceShelf.js'
|
||||||
import InvoiceShelf from './InvoiceShelf'
|
|
||||||
|
|
||||||
window.Vue = Vue
|
window.Vue = Vue
|
||||||
window.router = router
|
window.router = router
|
||||||
window.VueRouter = VueRouter
|
window.VueRouter = VueRouter
|
||||||
|
|
||||||
window.InvoiceShelf = new InvoiceShelf()
|
window.InvoiceShelf = new InvoiceShelf()
|
||||||
9
vite.config.js
vendored
9
vite.config.js
vendored
@@ -32,11 +32,8 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
laravel({
|
laravel([
|
||||||
input: [
|
'resources/scripts/main.js'
|
||||||
'resources/scripts/main.js',
|
])
|
||||||
],
|
|
||||||
refresh: true,
|
|
||||||
})
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user