@bagelink/vue 0.0.398 → 0.0.402
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/BglVideo.vue.d.ts.map +1 -1
- package/dist/components/ModalConfirm.vue.d.ts +24 -0
- package/dist/components/ModalConfirm.vue.d.ts.map +1 -0
- package/dist/components/ModalForm.vue.d.ts +10 -6
- package/dist/components/ModalForm.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.cjs +2802 -108
- package/dist/index.mjs +2802 -108
- package/dist/plugins/modal.d.ts +14 -2
- package/dist/plugins/modal.d.ts.map +1 -1
- package/dist/style.css +121 -21
- package/package.json +5 -1
- package/src/components/BglVideo.vue +8 -4
- package/src/components/ModalConfirm.vue +26 -0
- package/src/components/ModalForm.vue +15 -12
- package/src/components/form/inputs/RichText.vue +133 -19
- package/src/components/form/inputs/SelectInput.vue +5 -4
- package/src/components/index.ts +1 -0
- package/src/plugins/modal.ts +26 -4
- package/src/styles/layout.css +9 -0
- package/src/styles/mobilLayout.css +11 -0
package/dist/index.mjs
CHANGED
|
@@ -315,7 +315,7 @@ async function detectOverflow$1(state2, options) {
|
|
|
315
315
|
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
316
316
|
};
|
|
317
317
|
}
|
|
318
|
-
const arrow$
|
|
318
|
+
const arrow$4 = (options) => ({
|
|
319
319
|
name: "arrow",
|
|
320
320
|
options,
|
|
321
321
|
async fn(state2) {
|
|
@@ -1506,7 +1506,7 @@ const q = "__floating-vue__popper", Q = () => defineComponent({
|
|
|
1506
1506
|
})), !t && this.flip && e.middleware.push(flip$2({
|
|
1507
1507
|
padding: this.overflowPadding,
|
|
1508
1508
|
boundary: this.boundary
|
|
1509
|
-
}))), e.middleware.push(arrow$
|
|
1509
|
+
}))), e.middleware.push(arrow$4({
|
|
1510
1510
|
element: this.$_arrowNode,
|
|
1511
1511
|
padding: this.arrowPadding
|
|
1512
1512
|
})), this.arrowOverflow && e.middleware.push({
|
|
@@ -4855,6 +4855,15 @@ const ModalPlugin = {
|
|
|
4855
4855
|
const hideModal = (index2) => {
|
|
4856
4856
|
modalStack.value.splice(index2, 1);
|
|
4857
4857
|
};
|
|
4858
|
+
const modalConfirm = (options) => new Promise((resolve) => {
|
|
4859
|
+
if (typeof options === "string")
|
|
4860
|
+
options = { title: options, message: "" };
|
|
4861
|
+
modalStack.value.push({
|
|
4862
|
+
modalOptions: { ...options, resolve },
|
|
4863
|
+
modalType: "confirm",
|
|
4864
|
+
componentSlots: {}
|
|
4865
|
+
});
|
|
4866
|
+
});
|
|
4858
4867
|
const showModal = (modalType, options, slots = {}) => {
|
|
4859
4868
|
modalStack.value.push({
|
|
4860
4869
|
modalOptions: options,
|
|
@@ -4868,6 +4877,7 @@ const ModalPlugin = {
|
|
|
4868
4877
|
app.provide(ModalSymbol, {
|
|
4869
4878
|
showModal: (options, slots) => showModal("modal", options, slots),
|
|
4870
4879
|
showModalForm: (options, slots) => showModal("modalForm", options, slots),
|
|
4880
|
+
confirm: (userOptions) => modalConfirm(userOptions),
|
|
4871
4881
|
hideModal: (index2 = modalStack.value.length - 1) => hideModal(index2)
|
|
4872
4882
|
// modalOptions,
|
|
4873
4883
|
});
|
|
@@ -4878,7 +4888,9 @@ const ModalPlugin = {
|
|
|
4878
4888
|
const props2 = { ...modal.modalOptions, visible: true, "onUpdate:visible": () => hideModal(index2) };
|
|
4879
4889
|
if (modal.modalType === "modalForm")
|
|
4880
4890
|
return h$2(ModalForm, props2, modal.componentSlots);
|
|
4881
|
-
|
|
4891
|
+
if (modal.modalType === "confirm")
|
|
4892
|
+
return h$2(_sfc_main$n, props2, {});
|
|
4893
|
+
return h$2(_sfc_main$F, props2, modal.componentSlots);
|
|
4882
4894
|
});
|
|
4883
4895
|
}
|
|
4884
4896
|
});
|
|
@@ -5017,7 +5029,7 @@ const iffer = (field, itemData) => {
|
|
|
5017
5029
|
return true;
|
|
5018
5030
|
};
|
|
5019
5031
|
const denullify = (itemData, fieldID) => fieldID && itemData ? itemData[fieldID] : null;
|
|
5020
|
-
const _sfc_main$
|
|
5032
|
+
const _sfc_main$I = /* @__PURE__ */ defineComponent({
|
|
5021
5033
|
__name: "MaterialIcon",
|
|
5022
5034
|
props: {
|
|
5023
5035
|
icon: {},
|
|
@@ -5040,7 +5052,7 @@ const _hoisted_3$l = { class: "nav-links-wrapper" };
|
|
|
5040
5052
|
const _hoisted_4$e = { class: "tooltip" };
|
|
5041
5053
|
const _hoisted_5$b = { class: "bot-buttons-wrapper" };
|
|
5042
5054
|
const _hoisted_6$7 = { class: "tooltip" };
|
|
5043
|
-
const _sfc_main$
|
|
5055
|
+
const _sfc_main$H = /* @__PURE__ */ defineComponent({
|
|
5044
5056
|
__name: "NavBar",
|
|
5045
5057
|
props: {
|
|
5046
5058
|
footerLinks: { default: () => [] },
|
|
@@ -5064,7 +5076,7 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
5064
5076
|
"aria-label": "Toggle Navigation",
|
|
5065
5077
|
tabindex: "0"
|
|
5066
5078
|
}, [
|
|
5067
|
-
createVNode(unref(_sfc_main$
|
|
5079
|
+
createVNode(unref(_sfc_main$I), {
|
|
5068
5080
|
icon: "chevron_right",
|
|
5069
5081
|
class: "top-arrow"
|
|
5070
5082
|
})
|
|
@@ -5083,7 +5095,7 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
5083
5095
|
}
|
|
5084
5096
|
}, {
|
|
5085
5097
|
default: withCtx(() => [
|
|
5086
|
-
createVNode(unref(_sfc_main$
|
|
5098
|
+
createVNode(unref(_sfc_main$I), {
|
|
5087
5099
|
icon: link.icon
|
|
5088
5100
|
}, null, 8, ["icon"]),
|
|
5089
5101
|
createElementVNode("div", _hoisted_4$e, toDisplayString(link.label), 1)
|
|
@@ -5105,7 +5117,7 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
5105
5117
|
key: link.label
|
|
5106
5118
|
}, {
|
|
5107
5119
|
default: withCtx(() => [
|
|
5108
|
-
createVNode(unref(_sfc_main$
|
|
5120
|
+
createVNode(unref(_sfc_main$I), {
|
|
5109
5121
|
icon: link.icon
|
|
5110
5122
|
}, null, 8, ["icon"]),
|
|
5111
5123
|
createElementVNode("div", _hoisted_6$7, toDisplayString(link.label), 1)
|
|
@@ -5127,7 +5139,7 @@ const _export_sfc = (sfc, props2) => {
|
|
|
5127
5139
|
}
|
|
5128
5140
|
return target;
|
|
5129
5141
|
};
|
|
5130
|
-
const NavBar = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
5142
|
+
const NavBar = /* @__PURE__ */ _export_sfc(_sfc_main$H, [["__scopeId", "data-v-727b754a"]]);
|
|
5131
5143
|
const _hoisted_1$D = {
|
|
5132
5144
|
key: 0,
|
|
5133
5145
|
class: "loading"
|
|
@@ -5136,7 +5148,7 @@ const _hoisted_2$w = {
|
|
|
5136
5148
|
key: 1,
|
|
5137
5149
|
class: "bgl_btn-flex"
|
|
5138
5150
|
};
|
|
5139
|
-
const _sfc_main$
|
|
5151
|
+
const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
5140
5152
|
__name: "Btn",
|
|
5141
5153
|
props: {
|
|
5142
5154
|
disabled: { type: Boolean, default: false },
|
|
@@ -5224,7 +5236,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
5224
5236
|
}, {
|
|
5225
5237
|
default: withCtx(() => [
|
|
5226
5238
|
_ctx.loading ? (openBlock(), createElementBlock("div", _hoisted_1$D)) : (openBlock(), createElementBlock("div", _hoisted_2$w, [
|
|
5227
|
-
_ctx.icon ? (openBlock(), createBlock(unref(_sfc_main$
|
|
5239
|
+
_ctx.icon ? (openBlock(), createBlock(unref(_sfc_main$I), {
|
|
5228
5240
|
key: 0,
|
|
5229
5241
|
icon: _ctx.icon
|
|
5230
5242
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -5232,7 +5244,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
5232
5244
|
!unref(slots)["default"] && _ctx.value ? (openBlock(), createElementBlock(Fragment$1, { key: 1 }, [
|
|
5233
5245
|
createTextVNode(toDisplayString(_ctx.value), 1)
|
|
5234
5246
|
], 64)) : createCommentVNode("", true),
|
|
5235
|
-
props2["icon.end"] ? (openBlock(), createBlock(unref(_sfc_main$
|
|
5247
|
+
props2["icon.end"] ? (openBlock(), createBlock(unref(_sfc_main$I), {
|
|
5236
5248
|
key: 2,
|
|
5237
5249
|
icon: props2["icon.end"]
|
|
5238
5250
|
}, null, 8, ["icon"])) : createCommentVNode("", true)
|
|
@@ -5243,10 +5255,10 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
5243
5255
|
};
|
|
5244
5256
|
}
|
|
5245
5257
|
});
|
|
5246
|
-
const Btn = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
5258
|
+
const Btn = /* @__PURE__ */ _export_sfc(_sfc_main$G, [["__scopeId", "data-v-d09a83c5"]]);
|
|
5247
5259
|
const _hoisted_1$C = { class: "tool-bar" };
|
|
5248
5260
|
const _hoisted_2$v = { class: "modal-footer mt-3" };
|
|
5249
|
-
const _sfc_main$
|
|
5261
|
+
const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
5250
5262
|
__name: "Modal",
|
|
5251
5263
|
props: {
|
|
5252
5264
|
side: { type: Boolean },
|
|
@@ -5300,7 +5312,7 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
5300
5312
|
onClick: _cache[1] || (_cache[1] = () => _ctx.dismissable ? closeModal() : ""),
|
|
5301
5313
|
onKeydown: withKeys(closeModal, ["esc"])
|
|
5302
5314
|
}, [
|
|
5303
|
-
createVNode(unref(_sfc_main$
|
|
5315
|
+
createVNode(unref(_sfc_main$v), {
|
|
5304
5316
|
class: "modal",
|
|
5305
5317
|
onClick: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
5306
5318
|
}, ["stop"])),
|
|
@@ -5315,7 +5327,7 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
5315
5327
|
icon: "close",
|
|
5316
5328
|
onClick: closeModal
|
|
5317
5329
|
}, null, 8, ["style"]),
|
|
5318
|
-
_ctx.title ? (openBlock(), createBlock(unref(_sfc_main$
|
|
5330
|
+
_ctx.title ? (openBlock(), createBlock(unref(_sfc_main$t), {
|
|
5319
5331
|
key: 0,
|
|
5320
5332
|
class: "modal-title",
|
|
5321
5333
|
tag: "h3",
|
|
@@ -5340,7 +5352,7 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
5340
5352
|
};
|
|
5341
5353
|
}
|
|
5342
5354
|
});
|
|
5343
|
-
const _sfc_main$
|
|
5355
|
+
const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
5344
5356
|
__name: "ModalForm",
|
|
5345
5357
|
props: /* @__PURE__ */ mergeModels({
|
|
5346
5358
|
side: { type: Boolean },
|
|
@@ -5351,7 +5363,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
5351
5363
|
schema: { type: Function },
|
|
5352
5364
|
onSubmit: { type: Function },
|
|
5353
5365
|
onDelete: { type: Function },
|
|
5354
|
-
|
|
5366
|
+
visible: { type: Boolean },
|
|
5355
5367
|
onError: { type: Function },
|
|
5356
5368
|
modelValue: {}
|
|
5357
5369
|
}, {
|
|
@@ -5360,10 +5372,11 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
5360
5372
|
},
|
|
5361
5373
|
"modelModifiers": {}
|
|
5362
5374
|
}),
|
|
5363
|
-
emits: ["update:modelValue"],
|
|
5364
|
-
setup(__props, { expose: __expose }) {
|
|
5375
|
+
emits: /* @__PURE__ */ mergeModels(["update:visible"], ["update:modelValue"]),
|
|
5376
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
5365
5377
|
const bagel = useBagel();
|
|
5366
5378
|
const props2 = __props;
|
|
5379
|
+
const emit2 = __emit;
|
|
5367
5380
|
const modal = ref();
|
|
5368
5381
|
const computedFormSchema = computed(() => {
|
|
5369
5382
|
if (typeof props2.schema === "function")
|
|
@@ -5400,12 +5413,13 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
5400
5413
|
}
|
|
5401
5414
|
__expose({ setFormValues });
|
|
5402
5415
|
return (_ctx, _cache) => {
|
|
5403
|
-
return openBlock(), createBlock(unref(_sfc_main$
|
|
5404
|
-
"
|
|
5416
|
+
return openBlock(), createBlock(unref(_sfc_main$F), {
|
|
5417
|
+
"onUpdate:visible": _cache[1] || (_cache[1] = ($event) => emit2("update:visible", $event)),
|
|
5405
5418
|
side: _ctx.side,
|
|
5406
5419
|
ref_key: "modal",
|
|
5407
5420
|
ref: modal,
|
|
5408
5421
|
width: _ctx.width,
|
|
5422
|
+
visible: _ctx.visible,
|
|
5409
5423
|
dismissable: _ctx.dismissable,
|
|
5410
5424
|
title: _ctx.title
|
|
5411
5425
|
}, createSlots({
|
|
@@ -5448,16 +5462,16 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
5448
5462
|
]),
|
|
5449
5463
|
key: "0"
|
|
5450
5464
|
} : void 0
|
|
5451
|
-
]), 1032, ["
|
|
5465
|
+
]), 1032, ["side", "width", "visible", "dismissable", "title"]);
|
|
5452
5466
|
};
|
|
5453
5467
|
}
|
|
5454
5468
|
});
|
|
5455
|
-
const ModalForm = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
5469
|
+
const ModalForm = /* @__PURE__ */ _export_sfc(_sfc_main$E, [["__scopeId", "data-v-04d84995"]]);
|
|
5456
5470
|
const _hoisted_1$B = { class: "accordion-item" };
|
|
5457
5471
|
const _hoisted_2$u = ["aria-expanded", "aria-controls"];
|
|
5458
5472
|
const _hoisted_3$k = { class: "accordion-label" };
|
|
5459
5473
|
const _hoisted_4$d = ["id", "aria-hidden"];
|
|
5460
|
-
const _sfc_main$
|
|
5474
|
+
const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
5461
5475
|
__name: "AccordionItem",
|
|
5462
5476
|
props: {
|
|
5463
5477
|
label: {},
|
|
@@ -5492,7 +5506,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
5492
5506
|
createElementVNode("div", {
|
|
5493
5507
|
class: normalizeClass(["accordion-icon", { open: unref(open) }])
|
|
5494
5508
|
}, [
|
|
5495
|
-
createVNode(unref(_sfc_main$
|
|
5509
|
+
createVNode(unref(_sfc_main$I), { icon: "expand_more" })
|
|
5496
5510
|
], 2)
|
|
5497
5511
|
], 8, _hoisted_2$u),
|
|
5498
5512
|
createVNode(Transition, { name: "expand" }, {
|
|
@@ -5512,11 +5526,11 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
5512
5526
|
};
|
|
5513
5527
|
}
|
|
5514
5528
|
});
|
|
5515
|
-
const AccordionItem = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
5529
|
+
const AccordionItem = /* @__PURE__ */ _export_sfc(_sfc_main$D, [["__scopeId", "data-v-bf74738b"]]);
|
|
5516
5530
|
const _hoisted_1$A = { class: "list-wrap bgl_card thin grid overflow-hidden h-100 p-0" };
|
|
5517
5531
|
const _hoisted_2$t = { class: "p-1" };
|
|
5518
5532
|
const _hoisted_3$j = { class: "list-content auto-flow-rows align-items-start overflow-y h-100" };
|
|
5519
|
-
const _sfc_main$
|
|
5533
|
+
const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
5520
5534
|
__name: "ListView",
|
|
5521
5535
|
setup(__props) {
|
|
5522
5536
|
return (_ctx, _cache) => {
|
|
@@ -5533,7 +5547,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
5533
5547
|
});
|
|
5534
5548
|
const _hoisted_1$z = { class: "txt16 no-margin ellipsis" };
|
|
5535
5549
|
const _hoisted_2$s = { class: "txt14 no-margin txt-gray ellipsis" };
|
|
5536
|
-
const _sfc_main$
|
|
5550
|
+
const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
5537
5551
|
__name: "ListItem",
|
|
5538
5552
|
props: {
|
|
5539
5553
|
src: {},
|
|
@@ -5574,7 +5588,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
|
5574
5588
|
});
|
|
5575
5589
|
const _hoisted_1$y = { class: "page-top" };
|
|
5576
5590
|
const _hoisted_2$r = { class: "top-title" };
|
|
5577
|
-
const _sfc_main$
|
|
5591
|
+
const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
5578
5592
|
__name: "PageTitle",
|
|
5579
5593
|
props: {
|
|
5580
5594
|
value: {
|
|
@@ -5600,7 +5614,7 @@ const _hoisted_4$c = ["onClick"];
|
|
|
5600
5614
|
const _hoisted_5$a = { class: "flex" };
|
|
5601
5615
|
const _hoisted_6$6 = ["onClick"];
|
|
5602
5616
|
const _hoisted_7$2 = { key: 1 };
|
|
5603
|
-
const _sfc_main$
|
|
5617
|
+
const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
5604
5618
|
__name: "TableSchema",
|
|
5605
5619
|
props: {
|
|
5606
5620
|
data: {},
|
|
@@ -5648,7 +5662,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
5648
5662
|
createElementVNode("div", {
|
|
5649
5663
|
class: normalizeClass(["list-arrows", { sorted: unref(sortField) === field.id }])
|
|
5650
5664
|
}, [
|
|
5651
|
-
createVNode(unref(_sfc_main$
|
|
5665
|
+
createVNode(unref(_sfc_main$I), {
|
|
5652
5666
|
class: normalizeClass({ desc: unref(sortDirection) === "DESC" }),
|
|
5653
5667
|
icon: "keyboard_arrow_up"
|
|
5654
5668
|
}, null, 8, ["class"])
|
|
@@ -5694,16 +5708,16 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
5694
5708
|
};
|
|
5695
5709
|
}
|
|
5696
5710
|
});
|
|
5697
|
-
const TableSchema = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
5698
|
-
const _sfc_main$
|
|
5711
|
+
const TableSchema = /* @__PURE__ */ _export_sfc(_sfc_main$z, [["__scopeId", "data-v-10808aad"]]);
|
|
5712
|
+
const _sfc_main$y = {};
|
|
5699
5713
|
const _hoisted_1$w = { class: "flex space-between" };
|
|
5700
5714
|
function _sfc_render$1(_ctx, _cache) {
|
|
5701
5715
|
return openBlock(), createElementBlock("div", _hoisted_1$w, [
|
|
5702
5716
|
renderSlot(_ctx.$slots, "default")
|
|
5703
5717
|
]);
|
|
5704
5718
|
}
|
|
5705
|
-
const TopBar = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
5706
|
-
const _sfc_main$
|
|
5719
|
+
const TopBar = /* @__PURE__ */ _export_sfc(_sfc_main$y, [["render", _sfc_render$1]]);
|
|
5720
|
+
const _sfc_main$x = {};
|
|
5707
5721
|
function _sfc_render(_ctx, _cache) {
|
|
5708
5722
|
const _component_router_view = resolveComponent("router-view");
|
|
5709
5723
|
return openBlock(), createBlock(_component_router_view, null, {
|
|
@@ -5725,7 +5739,7 @@ function _sfc_render(_ctx, _cache) {
|
|
|
5725
5739
|
_: 1
|
|
5726
5740
|
});
|
|
5727
5741
|
}
|
|
5728
|
-
const RouterWrapper = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
5742
|
+
const RouterWrapper = /* @__PURE__ */ _export_sfc(_sfc_main$x, [["render", _sfc_render]]);
|
|
5729
5743
|
const _hoisted_1$v = {
|
|
5730
5744
|
key: 0,
|
|
5731
5745
|
class: "data"
|
|
@@ -5738,7 +5752,7 @@ const _hoisted_3$h = { class: "key" };
|
|
|
5738
5752
|
const _hoisted_4$b = { key: 1 };
|
|
5739
5753
|
const _hoisted_5$9 = { class: "key" };
|
|
5740
5754
|
const _hoisted_6$5 = { class: "vlue" };
|
|
5741
|
-
const _sfc_main$
|
|
5755
|
+
const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
5742
5756
|
__name: "DataPreview",
|
|
5743
5757
|
props: /* @__PURE__ */ mergeModels({
|
|
5744
5758
|
schema: {},
|
|
@@ -5753,7 +5767,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
5753
5767
|
return (_ctx, _cache) => {
|
|
5754
5768
|
var _a2;
|
|
5755
5769
|
return __props.data ? (openBlock(), createElementBlock("div", _hoisted_1$v, [
|
|
5756
|
-
_ctx.title ? (openBlock(), createBlock(unref(_sfc_main$
|
|
5770
|
+
_ctx.title ? (openBlock(), createBlock(unref(_sfc_main$t), {
|
|
5757
5771
|
key: 0,
|
|
5758
5772
|
label: _ctx.title
|
|
5759
5773
|
}, null, 8, ["label"])) : createCommentVNode("", true),
|
|
@@ -5787,12 +5801,12 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
5787
5801
|
};
|
|
5788
5802
|
}
|
|
5789
5803
|
});
|
|
5790
|
-
const DataPreview = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
5804
|
+
const DataPreview = /* @__PURE__ */ _export_sfc(_sfc_main$w, [["__scopeId", "data-v-bb2526f9"]]);
|
|
5791
5805
|
const _hoisted_1$u = {
|
|
5792
5806
|
key: 0,
|
|
5793
5807
|
class: "card_label"
|
|
5794
5808
|
};
|
|
5795
|
-
const _sfc_main$
|
|
5809
|
+
const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
5796
5810
|
__name: "Card",
|
|
5797
5811
|
props: {
|
|
5798
5812
|
label: {},
|
|
@@ -5822,7 +5836,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
5822
5836
|
}
|
|
5823
5837
|
});
|
|
5824
5838
|
const _hoisted_1$t = ["src", "alt"];
|
|
5825
|
-
const _sfc_main$
|
|
5839
|
+
const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
5826
5840
|
__name: "Avatar",
|
|
5827
5841
|
props: {
|
|
5828
5842
|
fallback: {},
|
|
@@ -5848,8 +5862,8 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
5848
5862
|
};
|
|
5849
5863
|
}
|
|
5850
5864
|
});
|
|
5851
|
-
const Avatar = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
5852
|
-
const _sfc_main$
|
|
5865
|
+
const Avatar = /* @__PURE__ */ _export_sfc(_sfc_main$u, [["__scopeId", "data-v-c38bc02a"]]);
|
|
5866
|
+
const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
5853
5867
|
__name: "Title",
|
|
5854
5868
|
props: {
|
|
5855
5869
|
value: {
|
|
@@ -5877,7 +5891,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
5877
5891
|
};
|
|
5878
5892
|
}
|
|
5879
5893
|
});
|
|
5880
|
-
const _sfc_main$
|
|
5894
|
+
const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
5881
5895
|
__name: "Accordion",
|
|
5882
5896
|
setup(__props) {
|
|
5883
5897
|
const state2 = reactive({
|
|
@@ -5893,7 +5907,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
5893
5907
|
});
|
|
5894
5908
|
const _hoisted_1$s = ["dismissable"];
|
|
5895
5909
|
const _hoisted_2$o = { class: "m-0" };
|
|
5896
|
-
const _sfc_main$
|
|
5910
|
+
const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
5897
5911
|
__name: "Alert",
|
|
5898
5912
|
props: {
|
|
5899
5913
|
message: {},
|
|
@@ -5913,7 +5927,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
5913
5927
|
class: normalizeClass(["alert", [_ctx.type]]),
|
|
5914
5928
|
dismissable: _ctx.dismissable
|
|
5915
5929
|
}, [
|
|
5916
|
-
createVNode(unref(_sfc_main$
|
|
5930
|
+
createVNode(unref(_sfc_main$I), {
|
|
5917
5931
|
class: "alert_icon",
|
|
5918
5932
|
icon: _ctx.type,
|
|
5919
5933
|
size: 2,
|
|
@@ -5931,8 +5945,8 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
5931
5945
|
};
|
|
5932
5946
|
}
|
|
5933
5947
|
});
|
|
5934
|
-
const Alert = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
5935
|
-
const _sfc_main$
|
|
5948
|
+
const Alert = /* @__PURE__ */ _export_sfc(_sfc_main$r, [["__scopeId", "data-v-4017e821"]]);
|
|
5949
|
+
const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
5936
5950
|
__name: "Badge",
|
|
5937
5951
|
props: {
|
|
5938
5952
|
color: {},
|
|
@@ -5947,13 +5961,13 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
5947
5961
|
return openBlock(), createElementBlock("div", {
|
|
5948
5962
|
class: normalizeClass(["pill", [_ctx.color]])
|
|
5949
5963
|
}, [
|
|
5950
|
-
_ctx.icon ? (openBlock(), createBlock(unref(_sfc_main$
|
|
5964
|
+
_ctx.icon ? (openBlock(), createBlock(unref(_sfc_main$I), {
|
|
5951
5965
|
key: 0,
|
|
5952
5966
|
class: "inline",
|
|
5953
5967
|
icon: _ctx.icon
|
|
5954
5968
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
5955
5969
|
createTextVNode(" " + toDisplayString(_ctx.text) + " ", 1),
|
|
5956
|
-
props2["icon.end"] ? (openBlock(), createBlock(unref(_sfc_main$
|
|
5970
|
+
props2["icon.end"] ? (openBlock(), createBlock(unref(_sfc_main$I), {
|
|
5957
5971
|
key: 1,
|
|
5958
5972
|
class: "inline",
|
|
5959
5973
|
icon: props2["icon.end"]
|
|
@@ -5962,10 +5976,10 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
5962
5976
|
};
|
|
5963
5977
|
}
|
|
5964
5978
|
});
|
|
5965
|
-
const Badge = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
5979
|
+
const Badge = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["__scopeId", "data-v-561f7a72"]]);
|
|
5966
5980
|
const _hoisted_1$r = ["src"];
|
|
5967
5981
|
const _hoisted_2$n = ["src", "autoplay", "muted", "loop", "controls"];
|
|
5968
|
-
const _sfc_main$
|
|
5982
|
+
const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
5969
5983
|
__name: "BglVideo",
|
|
5970
5984
|
props: {
|
|
5971
5985
|
src: {},
|
|
@@ -6033,13 +6047,13 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
6033
6047
|
};
|
|
6034
6048
|
}
|
|
6035
6049
|
});
|
|
6036
|
-
const BglVideo = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
6050
|
+
const BglVideo = /* @__PURE__ */ _export_sfc(_sfc_main$p, [["__scopeId", "data-v-b1ad7c32"]]);
|
|
6037
6051
|
const _hoisted_1$q = {
|
|
6038
6052
|
key: 0,
|
|
6039
6053
|
class: "blocker"
|
|
6040
6054
|
};
|
|
6041
6055
|
const _hoisted_2$m = { class: "Handlers" };
|
|
6042
|
-
const _sfc_main$
|
|
6056
|
+
const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
6043
6057
|
__name: "Carousel",
|
|
6044
6058
|
props: {
|
|
6045
6059
|
autoHeight: {
|
|
@@ -6213,7 +6227,48 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
6213
6227
|
};
|
|
6214
6228
|
}
|
|
6215
6229
|
});
|
|
6216
|
-
const Carousel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
6230
|
+
const Carousel = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["__scopeId", "data-v-068aa914"]]);
|
|
6231
|
+
const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
6232
|
+
__name: "ModalConfirm",
|
|
6233
|
+
props: {
|
|
6234
|
+
title: {},
|
|
6235
|
+
message: {},
|
|
6236
|
+
resolve: { type: Function }
|
|
6237
|
+
},
|
|
6238
|
+
emits: ["update:visible"],
|
|
6239
|
+
setup(__props, { emit: __emit }) {
|
|
6240
|
+
const props2 = __props;
|
|
6241
|
+
const emit2 = __emit;
|
|
6242
|
+
function select2(val) {
|
|
6243
|
+
props2.resolve(val);
|
|
6244
|
+
emit2("update:visible");
|
|
6245
|
+
}
|
|
6246
|
+
return (_ctx, _cache) => {
|
|
6247
|
+
return openBlock(), createBlock(unref(_sfc_main$F), {
|
|
6248
|
+
width: "380px",
|
|
6249
|
+
dismissable: false,
|
|
6250
|
+
title: _ctx.title
|
|
6251
|
+
}, {
|
|
6252
|
+
footer: withCtx(() => [
|
|
6253
|
+
createVNode(unref(Btn), {
|
|
6254
|
+
onClick: _cache[0] || (_cache[0] = ($event) => select2(true)),
|
|
6255
|
+
color: "primary",
|
|
6256
|
+
value: "Confirm"
|
|
6257
|
+
}),
|
|
6258
|
+
createVNode(unref(Btn), {
|
|
6259
|
+
onClick: _cache[1] || (_cache[1] = ($event) => select2(false)),
|
|
6260
|
+
color: "red",
|
|
6261
|
+
value: "Cancel"
|
|
6262
|
+
})
|
|
6263
|
+
]),
|
|
6264
|
+
default: withCtx(() => [
|
|
6265
|
+
createTextVNode(toDisplayString(_ctx.message) + " ", 1)
|
|
6266
|
+
]),
|
|
6267
|
+
_: 1
|
|
6268
|
+
}, 8, ["title"]);
|
|
6269
|
+
};
|
|
6270
|
+
}
|
|
6271
|
+
});
|
|
6217
6272
|
const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
6218
6273
|
__name: "BglForm",
|
|
6219
6274
|
props: {
|
|
@@ -6297,7 +6352,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
6297
6352
|
ref: form,
|
|
6298
6353
|
onSubmit: withModifiers(runSubmit, ["prevent"])
|
|
6299
6354
|
}, [
|
|
6300
|
-
_ctx.label ? (openBlock(), createBlock(unref(_sfc_main$
|
|
6355
|
+
_ctx.label ? (openBlock(), createBlock(unref(_sfc_main$t), {
|
|
6301
6356
|
key: 0,
|
|
6302
6357
|
tag: "h4",
|
|
6303
6358
|
label: _ctx.label
|
|
@@ -15223,6 +15278,8 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
15223
15278
|
});
|
|
15224
15279
|
const emit2 = __emit;
|
|
15225
15280
|
const getLabel = (option2) => {
|
|
15281
|
+
if (!option2)
|
|
15282
|
+
return "";
|
|
15226
15283
|
if (typeof option2 === "string")
|
|
15227
15284
|
return option2;
|
|
15228
15285
|
if (typeof option2 === "number")
|
|
@@ -15230,6 +15287,8 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
15230
15287
|
return option2.label;
|
|
15231
15288
|
};
|
|
15232
15289
|
const getValue = (option2) => {
|
|
15290
|
+
if (!option2)
|
|
15291
|
+
return "";
|
|
15233
15292
|
if (typeof option2 === "string")
|
|
15234
15293
|
return option2;
|
|
15235
15294
|
if (typeof option2 === "number")
|
|
@@ -15277,8 +15336,6 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
15277
15336
|
watch(
|
|
15278
15337
|
() => props2.modelValue,
|
|
15279
15338
|
(newVal) => {
|
|
15280
|
-
if (!newVal)
|
|
15281
|
-
return;
|
|
15282
15339
|
if (!props2.multiselect) {
|
|
15283
15340
|
const newOption = props2.options.find((o2) => getValue(o2) === newVal) || newVal;
|
|
15284
15341
|
if (!isSelected(newOption)) {
|
|
@@ -15296,7 +15353,6 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
15296
15353
|
watch(
|
|
15297
15354
|
() => props2.options,
|
|
15298
15355
|
() => {
|
|
15299
|
-
const original = JSON.stringify(props2.options.map(getValue));
|
|
15300
15356
|
[...selectedItems.value].forEach((option2, i2) => {
|
|
15301
15357
|
const exists = props2.options.find(
|
|
15302
15358
|
(o2) => getValue(o2) === getValue(option2)
|
|
@@ -15306,9 +15362,6 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
15306
15362
|
else
|
|
15307
15363
|
selectedItems.value.splice(i2, 1, exists);
|
|
15308
15364
|
});
|
|
15309
|
-
const newSelection = JSON.stringify(selectedItems.value.map(getValue));
|
|
15310
|
-
if (original !== newSelection)
|
|
15311
|
-
emitUpdate();
|
|
15312
15365
|
},
|
|
15313
15366
|
{ deep: true }
|
|
15314
15367
|
);
|
|
@@ -15321,7 +15374,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
15321
15374
|
class: "bagel-input selectinput"
|
|
15322
15375
|
}, {
|
|
15323
15376
|
popper: withCtx(({ hide: hide2 }) => [
|
|
15324
|
-
createVNode(unref(_sfc_main$
|
|
15377
|
+
createVNode(unref(_sfc_main$v), {
|
|
15325
15378
|
class: "selectinput-options p-05",
|
|
15326
15379
|
style: normalizeStyle({ width: _ctx.fullWidth ? "100%" : "auto" })
|
|
15327
15380
|
}, {
|
|
@@ -15342,11 +15395,11 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
15342
15395
|
key: `${option2}${i2}`,
|
|
15343
15396
|
onClick: ($event) => select2(option2)
|
|
15344
15397
|
}, [
|
|
15345
|
-
isSelected(option2) ? (openBlock(), createBlock(unref(_sfc_main$
|
|
15398
|
+
isSelected(option2) ? (openBlock(), createBlock(unref(_sfc_main$I), {
|
|
15346
15399
|
key: 0,
|
|
15347
15400
|
icon: "check"
|
|
15348
15401
|
})) : createCommentVNode("", true),
|
|
15349
|
-
!isSelected(option2) ? (openBlock(), createBlock(unref(_sfc_main$
|
|
15402
|
+
!isSelected(option2) ? (openBlock(), createBlock(unref(_sfc_main$I), {
|
|
15350
15403
|
key: 1,
|
|
15351
15404
|
class: "opacity-3",
|
|
15352
15405
|
icon: "fiber_manual_record"
|
|
@@ -15370,7 +15423,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
15370
15423
|
class: normalizeClass(["selectinput-btn", { isEmpty: selectedItems.value.length === 0 }])
|
|
15371
15424
|
}, [
|
|
15372
15425
|
createElementVNode("p", null, toDisplayString(selectedLabel.value), 1),
|
|
15373
|
-
createVNode(unref(_sfc_main$
|
|
15426
|
+
createVNode(unref(_sfc_main$I), normalizeProps(guardReactiveProps({ icon: unref(open) ? "unfold_less" : "unfold_more" })), null, 16)
|
|
15374
15427
|
], 42, _hoisted_1$m),
|
|
15375
15428
|
_ctx.required ? (openBlock(), createElementBlock("input", {
|
|
15376
15429
|
key: 0,
|
|
@@ -15387,7 +15440,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
15387
15440
|
};
|
|
15388
15441
|
}
|
|
15389
15442
|
});
|
|
15390
|
-
const SelectInput = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-
|
|
15443
|
+
const SelectInput = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-fdfda40b"]]);
|
|
15391
15444
|
/*!
|
|
15392
15445
|
* vue-draggable-next v2.2.0
|
|
15393
15446
|
* (c) 2023 Anish George
|
|
@@ -17943,7 +17996,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
17943
17996
|
rows[index2][fieldname] = value;
|
|
17944
17997
|
emits("update:modelValue", rows);
|
|
17945
17998
|
}
|
|
17946
|
-
function
|
|
17999
|
+
function addRow2() {
|
|
17947
18000
|
const rows = [...props2.modelValue];
|
|
17948
18001
|
const entry = {
|
|
17949
18002
|
idx: rows.length
|
|
@@ -17960,7 +18013,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
17960
18013
|
rows.push(entry);
|
|
17961
18014
|
emits("update:modelValue", rows);
|
|
17962
18015
|
}
|
|
17963
|
-
function
|
|
18016
|
+
function removeRow2(idx) {
|
|
17964
18017
|
const rows = [...props2.modelValue];
|
|
17965
18018
|
rows.splice(idx, 1);
|
|
17966
18019
|
emits("update:modelValue", rows);
|
|
@@ -18013,7 +18066,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
18013
18066
|
key: row.id
|
|
18014
18067
|
}, [
|
|
18015
18068
|
createElementVNode("div", _hoisted_5$8, [
|
|
18016
|
-
createVNode(unref(_sfc_main$
|
|
18069
|
+
createVNode(unref(_sfc_main$I), { icon: "more_vert" })
|
|
18017
18070
|
]),
|
|
18018
18071
|
(openBlock(true), createElementBlock(Fragment$1, null, renderList((_a3 = unref(entityMeta)) == null ? void 0 : _a3.fields, (field) => {
|
|
18019
18072
|
return openBlock(), createElementBlock("div", {
|
|
@@ -18030,9 +18083,9 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
18030
18083
|
], 2);
|
|
18031
18084
|
}), 128)),
|
|
18032
18085
|
createElementVNode("div", _hoisted_6$4, [
|
|
18033
|
-
createVNode(unref(_sfc_main$
|
|
18086
|
+
createVNode(unref(_sfc_main$I), {
|
|
18034
18087
|
icon: "delete",
|
|
18035
|
-
onClick: ($event) =>
|
|
18088
|
+
onClick: ($event) => removeRow2(index2)
|
|
18036
18089
|
}, null, 8, ["onClick"])
|
|
18037
18090
|
])
|
|
18038
18091
|
]);
|
|
@@ -18049,7 +18102,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
18049
18102
|
flat: "",
|
|
18050
18103
|
icon: "add",
|
|
18051
18104
|
color: "light",
|
|
18052
|
-
onClick:
|
|
18105
|
+
onClick: addRow2
|
|
18053
18106
|
}, {
|
|
18054
18107
|
default: withCtx(() => [
|
|
18055
18108
|
createTextVNode(" New ")
|
|
@@ -18200,12 +18253,12 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
18200
18253
|
]),
|
|
18201
18254
|
_ctx.helptext ? (openBlock(), createElementBlock("p", _hoisted_5$7, toDisplayString(_ctx.helptext), 1)) : createCommentVNode("", true)
|
|
18202
18255
|
], 8, _hoisted_2$g),
|
|
18203
|
-
_ctx.iconStart ? (openBlock(), createBlock(unref(_sfc_main$
|
|
18256
|
+
_ctx.iconStart ? (openBlock(), createBlock(unref(_sfc_main$I), {
|
|
18204
18257
|
key: 0,
|
|
18205
18258
|
class: "iconStart",
|
|
18206
18259
|
icon: _ctx.iconStart
|
|
18207
18260
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
18208
|
-
_ctx.icon ? (openBlock(), createBlock(unref(_sfc_main$
|
|
18261
|
+
_ctx.icon ? (openBlock(), createBlock(unref(_sfc_main$I), {
|
|
18209
18262
|
key: 1,
|
|
18210
18263
|
icon: _ctx.icon
|
|
18211
18264
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -18244,7 +18297,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
18244
18297
|
[vModelCheckbox, val.value]
|
|
18245
18298
|
]),
|
|
18246
18299
|
createElementVNode("span", null, [
|
|
18247
|
-
createVNode(unref(_sfc_main$
|
|
18300
|
+
createVNode(unref(_sfc_main$I), { icon: "check" })
|
|
18248
18301
|
])
|
|
18249
18302
|
]);
|
|
18250
18303
|
};
|
|
@@ -18636,7 +18689,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
18636
18689
|
style: normalizeStyle([`--p:${fileQ.progress}`, { "--b": "2px" }])
|
|
18637
18690
|
}, [
|
|
18638
18691
|
fileQ.progress < 100 ? (openBlock(), createElementBlock("span", _hoisted_12, toDisplayString(`${fileQ.progress.toFixed(0)}`), 1)) : createCommentVNode("", true),
|
|
18639
|
-
createVNode(unref(_sfc_main$
|
|
18692
|
+
createVNode(unref(_sfc_main$I), {
|
|
18640
18693
|
class: "success",
|
|
18641
18694
|
icon: "check"
|
|
18642
18695
|
})
|
|
@@ -27411,7 +27464,7 @@ function handleSingleClick(view, pos, inside, event, selectNode) {
|
|
|
27411
27464
|
function handleDoubleClick(view, pos, inside, event) {
|
|
27412
27465
|
return runHandlerOnContext(view, "handleDoubleClickOn", pos, inside, event) || view.someProp("handleDoubleClick", (f2) => f2(view, pos, event));
|
|
27413
27466
|
}
|
|
27414
|
-
function handleTripleClick(view, pos, inside, event) {
|
|
27467
|
+
function handleTripleClick$1(view, pos, inside, event) {
|
|
27415
27468
|
return runHandlerOnContext(view, "handleTripleClickOn", pos, inside, event) || view.someProp("handleTripleClick", (f2) => f2(view, pos, event)) || defaultTripleClick(view, inside, event);
|
|
27416
27469
|
}
|
|
27417
27470
|
function defaultTripleClick(view, inside, event) {
|
|
@@ -27461,7 +27514,7 @@ handlers.mousedown = (view, _event) => {
|
|
|
27461
27514
|
if (view.input.mouseDown)
|
|
27462
27515
|
view.input.mouseDown.done();
|
|
27463
27516
|
view.input.mouseDown = new MouseDown(view, pos, event, !!flushed);
|
|
27464
|
-
} else if ((type3 == "doubleClick" ? handleDoubleClick : handleTripleClick)(view, pos.pos, pos.inside, event)) {
|
|
27517
|
+
} else if ((type3 == "doubleClick" ? handleDoubleClick : handleTripleClick$1)(view, pos.pos, pos.inside, event)) {
|
|
27465
27518
|
event.preventDefault();
|
|
27466
27519
|
} else {
|
|
27467
27520
|
setSelectionOrigin(view, "pointer");
|
|
@@ -32972,8 +33025,8 @@ const Keymap = Extension.create({
|
|
|
32972
33025
|
if (empty2 || !allWasSelected) {
|
|
32973
33026
|
return;
|
|
32974
33027
|
}
|
|
32975
|
-
const
|
|
32976
|
-
if (!
|
|
33028
|
+
const isEmpty2 = newState.doc.textBetween(0, newState.doc.content.size, " ", " ").length === 0;
|
|
33029
|
+
if (!isEmpty2) {
|
|
32977
33030
|
return;
|
|
32978
33031
|
}
|
|
32979
33032
|
const tr2 = newState.tr;
|
|
@@ -34709,18 +34762,18 @@ function gapCursor() {
|
|
|
34709
34762
|
return $anchor.pos == $head.pos && GapCursor.valid($head) ? new GapCursor($head) : null;
|
|
34710
34763
|
},
|
|
34711
34764
|
handleClick,
|
|
34712
|
-
handleKeyDown,
|
|
34765
|
+
handleKeyDown: handleKeyDown$1,
|
|
34713
34766
|
handleDOMEvents: { beforeinput }
|
|
34714
34767
|
}
|
|
34715
34768
|
});
|
|
34716
34769
|
}
|
|
34717
|
-
const handleKeyDown = keydownHandler({
|
|
34718
|
-
"ArrowLeft": arrow$
|
|
34719
|
-
"ArrowRight": arrow$
|
|
34720
|
-
"ArrowUp": arrow$
|
|
34721
|
-
"ArrowDown": arrow$
|
|
34770
|
+
const handleKeyDown$1 = keydownHandler({
|
|
34771
|
+
"ArrowLeft": arrow$3("horiz", -1),
|
|
34772
|
+
"ArrowRight": arrow$3("horiz", 1),
|
|
34773
|
+
"ArrowUp": arrow$3("vert", -1),
|
|
34774
|
+
"ArrowDown": arrow$3("vert", 1)
|
|
34722
34775
|
});
|
|
34723
|
-
function arrow$
|
|
34776
|
+
function arrow$3(axis2, dir) {
|
|
34724
34777
|
const dirStr = axis2 == "vert" ? dir > 0 ? "down" : "up" : dir > 0 ? "right" : "left";
|
|
34725
34778
|
return function(state2, dispatch, view) {
|
|
34726
34779
|
let sel = state2.selection;
|
|
@@ -36253,7 +36306,7 @@ var toPaddingObject = function toPaddingObject2(padding, state2) {
|
|
|
36253
36306
|
})) : padding;
|
|
36254
36307
|
return mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
|
|
36255
36308
|
};
|
|
36256
|
-
function arrow(_ref) {
|
|
36309
|
+
function arrow$1(_ref) {
|
|
36257
36310
|
var _state$modifiersData$;
|
|
36258
36311
|
var state2 = _ref.state, name = _ref.name, options = _ref.options;
|
|
36259
36312
|
var arrowElement = state2.elements.arrow;
|
|
@@ -36298,11 +36351,11 @@ function effect$1(_ref2) {
|
|
|
36298
36351
|
}
|
|
36299
36352
|
state2.elements.arrow = arrowElement;
|
|
36300
36353
|
}
|
|
36301
|
-
const arrow$
|
|
36354
|
+
const arrow$2 = {
|
|
36302
36355
|
name: "arrow",
|
|
36303
36356
|
enabled: true,
|
|
36304
36357
|
phase: "main",
|
|
36305
|
-
fn: arrow,
|
|
36358
|
+
fn: arrow$1,
|
|
36306
36359
|
effect: effect$1,
|
|
36307
36360
|
requires: ["popperOffsets"],
|
|
36308
36361
|
requiresIfExists: ["preventOverflow"]
|
|
@@ -37294,7 +37347,7 @@ function popperGenerator(generatorOptions) {
|
|
|
37294
37347
|
return instance;
|
|
37295
37348
|
};
|
|
37296
37349
|
}
|
|
37297
|
-
var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$
|
|
37350
|
+
var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$2, hide$1];
|
|
37298
37351
|
var createPopper = /* @__PURE__ */ popperGenerator({
|
|
37299
37352
|
defaultModifiers
|
|
37300
37353
|
});
|
|
@@ -39440,6 +39493,2633 @@ const Youtube = Node$2.create({
|
|
|
39440
39493
|
];
|
|
39441
39494
|
}
|
|
39442
39495
|
});
|
|
39496
|
+
var readFromCache;
|
|
39497
|
+
var addToCache;
|
|
39498
|
+
if (typeof WeakMap != "undefined") {
|
|
39499
|
+
let cache = /* @__PURE__ */ new WeakMap();
|
|
39500
|
+
readFromCache = (key) => cache.get(key);
|
|
39501
|
+
addToCache = (key, value) => {
|
|
39502
|
+
cache.set(key, value);
|
|
39503
|
+
return value;
|
|
39504
|
+
};
|
|
39505
|
+
} else {
|
|
39506
|
+
const cache = [];
|
|
39507
|
+
const cacheSize = 10;
|
|
39508
|
+
let cachePos = 0;
|
|
39509
|
+
readFromCache = (key) => {
|
|
39510
|
+
for (let i2 = 0; i2 < cache.length; i2 += 2)
|
|
39511
|
+
if (cache[i2] == key)
|
|
39512
|
+
return cache[i2 + 1];
|
|
39513
|
+
};
|
|
39514
|
+
addToCache = (key, value) => {
|
|
39515
|
+
if (cachePos == cacheSize)
|
|
39516
|
+
cachePos = 0;
|
|
39517
|
+
cache[cachePos++] = key;
|
|
39518
|
+
return cache[cachePos++] = value;
|
|
39519
|
+
};
|
|
39520
|
+
}
|
|
39521
|
+
var TableMap = class {
|
|
39522
|
+
constructor(width, height, map4, problems) {
|
|
39523
|
+
this.width = width;
|
|
39524
|
+
this.height = height;
|
|
39525
|
+
this.map = map4;
|
|
39526
|
+
this.problems = problems;
|
|
39527
|
+
}
|
|
39528
|
+
// Find the dimensions of the cell at the given position.
|
|
39529
|
+
findCell(pos) {
|
|
39530
|
+
for (let i2 = 0; i2 < this.map.length; i2++) {
|
|
39531
|
+
const curPos = this.map[i2];
|
|
39532
|
+
if (curPos != pos)
|
|
39533
|
+
continue;
|
|
39534
|
+
const left2 = i2 % this.width;
|
|
39535
|
+
const top2 = i2 / this.width | 0;
|
|
39536
|
+
let right2 = left2 + 1;
|
|
39537
|
+
let bottom2 = top2 + 1;
|
|
39538
|
+
for (let j = 1; right2 < this.width && this.map[i2 + j] == curPos; j++) {
|
|
39539
|
+
right2++;
|
|
39540
|
+
}
|
|
39541
|
+
for (let j = 1; bottom2 < this.height && this.map[i2 + this.width * j] == curPos; j++) {
|
|
39542
|
+
bottom2++;
|
|
39543
|
+
}
|
|
39544
|
+
return { left: left2, top: top2, right: right2, bottom: bottom2 };
|
|
39545
|
+
}
|
|
39546
|
+
throw new RangeError(`No cell with offset ${pos} found`);
|
|
39547
|
+
}
|
|
39548
|
+
// Find the left side of the cell at the given position.
|
|
39549
|
+
colCount(pos) {
|
|
39550
|
+
for (let i2 = 0; i2 < this.map.length; i2++) {
|
|
39551
|
+
if (this.map[i2] == pos) {
|
|
39552
|
+
return i2 % this.width;
|
|
39553
|
+
}
|
|
39554
|
+
}
|
|
39555
|
+
throw new RangeError(`No cell with offset ${pos} found`);
|
|
39556
|
+
}
|
|
39557
|
+
// Find the next cell in the given direction, starting from the cell
|
|
39558
|
+
// at `pos`, if any.
|
|
39559
|
+
nextCell(pos, axis2, dir) {
|
|
39560
|
+
const { left: left2, right: right2, top: top2, bottom: bottom2 } = this.findCell(pos);
|
|
39561
|
+
if (axis2 == "horiz") {
|
|
39562
|
+
if (dir < 0 ? left2 == 0 : right2 == this.width)
|
|
39563
|
+
return null;
|
|
39564
|
+
return this.map[top2 * this.width + (dir < 0 ? left2 - 1 : right2)];
|
|
39565
|
+
} else {
|
|
39566
|
+
if (dir < 0 ? top2 == 0 : bottom2 == this.height)
|
|
39567
|
+
return null;
|
|
39568
|
+
return this.map[left2 + this.width * (dir < 0 ? top2 - 1 : bottom2)];
|
|
39569
|
+
}
|
|
39570
|
+
}
|
|
39571
|
+
// Get the rectangle spanning the two given cells.
|
|
39572
|
+
rectBetween(a2, b2) {
|
|
39573
|
+
const {
|
|
39574
|
+
left: leftA,
|
|
39575
|
+
right: rightA,
|
|
39576
|
+
top: topA,
|
|
39577
|
+
bottom: bottomA
|
|
39578
|
+
} = this.findCell(a2);
|
|
39579
|
+
const {
|
|
39580
|
+
left: leftB,
|
|
39581
|
+
right: rightB,
|
|
39582
|
+
top: topB,
|
|
39583
|
+
bottom: bottomB
|
|
39584
|
+
} = this.findCell(b2);
|
|
39585
|
+
return {
|
|
39586
|
+
left: Math.min(leftA, leftB),
|
|
39587
|
+
top: Math.min(topA, topB),
|
|
39588
|
+
right: Math.max(rightA, rightB),
|
|
39589
|
+
bottom: Math.max(bottomA, bottomB)
|
|
39590
|
+
};
|
|
39591
|
+
}
|
|
39592
|
+
// Return the position of all cells that have the top left corner in
|
|
39593
|
+
// the given rectangle.
|
|
39594
|
+
cellsInRect(rect) {
|
|
39595
|
+
const result = [];
|
|
39596
|
+
const seen = {};
|
|
39597
|
+
for (let row = rect.top; row < rect.bottom; row++) {
|
|
39598
|
+
for (let col = rect.left; col < rect.right; col++) {
|
|
39599
|
+
const index2 = row * this.width + col;
|
|
39600
|
+
const pos = this.map[index2];
|
|
39601
|
+
if (seen[pos])
|
|
39602
|
+
continue;
|
|
39603
|
+
seen[pos] = true;
|
|
39604
|
+
if (col == rect.left && col && this.map[index2 - 1] == pos || row == rect.top && row && this.map[index2 - this.width] == pos) {
|
|
39605
|
+
continue;
|
|
39606
|
+
}
|
|
39607
|
+
result.push(pos);
|
|
39608
|
+
}
|
|
39609
|
+
}
|
|
39610
|
+
return result;
|
|
39611
|
+
}
|
|
39612
|
+
// Return the position at which the cell at the given row and column
|
|
39613
|
+
// starts, or would start, if a cell started there.
|
|
39614
|
+
positionAt(row, col, table) {
|
|
39615
|
+
for (let i2 = 0, rowStart = 0; ; i2++) {
|
|
39616
|
+
const rowEnd = rowStart + table.child(i2).nodeSize;
|
|
39617
|
+
if (i2 == row) {
|
|
39618
|
+
let index2 = col + row * this.width;
|
|
39619
|
+
const rowEndIndex = (row + 1) * this.width;
|
|
39620
|
+
while (index2 < rowEndIndex && this.map[index2] < rowStart)
|
|
39621
|
+
index2++;
|
|
39622
|
+
return index2 == rowEndIndex ? rowEnd - 1 : this.map[index2];
|
|
39623
|
+
}
|
|
39624
|
+
rowStart = rowEnd;
|
|
39625
|
+
}
|
|
39626
|
+
}
|
|
39627
|
+
// Find the table map for the given table node.
|
|
39628
|
+
static get(table) {
|
|
39629
|
+
return readFromCache(table) || addToCache(table, computeMap(table));
|
|
39630
|
+
}
|
|
39631
|
+
};
|
|
39632
|
+
function computeMap(table) {
|
|
39633
|
+
if (table.type.spec.tableRole != "table")
|
|
39634
|
+
throw new RangeError("Not a table node: " + table.type.name);
|
|
39635
|
+
const width = findWidth(table), height = table.childCount;
|
|
39636
|
+
const map4 = [];
|
|
39637
|
+
let mapPos = 0;
|
|
39638
|
+
let problems = null;
|
|
39639
|
+
const colWidths = [];
|
|
39640
|
+
for (let i2 = 0, e = width * height; i2 < e; i2++)
|
|
39641
|
+
map4[i2] = 0;
|
|
39642
|
+
for (let row = 0, pos = 0; row < height; row++) {
|
|
39643
|
+
const rowNode = table.child(row);
|
|
39644
|
+
pos++;
|
|
39645
|
+
for (let i2 = 0; ; i2++) {
|
|
39646
|
+
while (mapPos < map4.length && map4[mapPos] != 0)
|
|
39647
|
+
mapPos++;
|
|
39648
|
+
if (i2 == rowNode.childCount)
|
|
39649
|
+
break;
|
|
39650
|
+
const cellNode = rowNode.child(i2);
|
|
39651
|
+
const { colspan, rowspan, colwidth } = cellNode.attrs;
|
|
39652
|
+
for (let h2 = 0; h2 < rowspan; h2++) {
|
|
39653
|
+
if (h2 + row >= height) {
|
|
39654
|
+
(problems || (problems = [])).push({
|
|
39655
|
+
type: "overlong_rowspan",
|
|
39656
|
+
pos,
|
|
39657
|
+
n: rowspan - h2
|
|
39658
|
+
});
|
|
39659
|
+
break;
|
|
39660
|
+
}
|
|
39661
|
+
const start2 = mapPos + h2 * width;
|
|
39662
|
+
for (let w2 = 0; w2 < colspan; w2++) {
|
|
39663
|
+
if (map4[start2 + w2] == 0)
|
|
39664
|
+
map4[start2 + w2] = pos;
|
|
39665
|
+
else
|
|
39666
|
+
(problems || (problems = [])).push({
|
|
39667
|
+
type: "collision",
|
|
39668
|
+
row,
|
|
39669
|
+
pos,
|
|
39670
|
+
n: colspan - w2
|
|
39671
|
+
});
|
|
39672
|
+
const colW = colwidth && colwidth[w2];
|
|
39673
|
+
if (colW) {
|
|
39674
|
+
const widthIndex = (start2 + w2) % width * 2, prev = colWidths[widthIndex];
|
|
39675
|
+
if (prev == null || prev != colW && colWidths[widthIndex + 1] == 1) {
|
|
39676
|
+
colWidths[widthIndex] = colW;
|
|
39677
|
+
colWidths[widthIndex + 1] = 1;
|
|
39678
|
+
} else if (prev == colW) {
|
|
39679
|
+
colWidths[widthIndex + 1]++;
|
|
39680
|
+
}
|
|
39681
|
+
}
|
|
39682
|
+
}
|
|
39683
|
+
}
|
|
39684
|
+
mapPos += colspan;
|
|
39685
|
+
pos += cellNode.nodeSize;
|
|
39686
|
+
}
|
|
39687
|
+
const expectedPos = (row + 1) * width;
|
|
39688
|
+
let missing = 0;
|
|
39689
|
+
while (mapPos < expectedPos)
|
|
39690
|
+
if (map4[mapPos++] == 0)
|
|
39691
|
+
missing++;
|
|
39692
|
+
if (missing)
|
|
39693
|
+
(problems || (problems = [])).push({ type: "missing", row, n: missing });
|
|
39694
|
+
pos++;
|
|
39695
|
+
}
|
|
39696
|
+
const tableMap = new TableMap(width, height, map4, problems);
|
|
39697
|
+
let badWidths = false;
|
|
39698
|
+
for (let i2 = 0; !badWidths && i2 < colWidths.length; i2 += 2)
|
|
39699
|
+
if (colWidths[i2] != null && colWidths[i2 + 1] < height)
|
|
39700
|
+
badWidths = true;
|
|
39701
|
+
if (badWidths)
|
|
39702
|
+
findBadColWidths(tableMap, colWidths, table);
|
|
39703
|
+
return tableMap;
|
|
39704
|
+
}
|
|
39705
|
+
function findWidth(table) {
|
|
39706
|
+
let width = -1;
|
|
39707
|
+
let hasRowSpan = false;
|
|
39708
|
+
for (let row = 0; row < table.childCount; row++) {
|
|
39709
|
+
const rowNode = table.child(row);
|
|
39710
|
+
let rowWidth = 0;
|
|
39711
|
+
if (hasRowSpan)
|
|
39712
|
+
for (let j = 0; j < row; j++) {
|
|
39713
|
+
const prevRow = table.child(j);
|
|
39714
|
+
for (let i2 = 0; i2 < prevRow.childCount; i2++) {
|
|
39715
|
+
const cell = prevRow.child(i2);
|
|
39716
|
+
if (j + cell.attrs.rowspan > row)
|
|
39717
|
+
rowWidth += cell.attrs.colspan;
|
|
39718
|
+
}
|
|
39719
|
+
}
|
|
39720
|
+
for (let i2 = 0; i2 < rowNode.childCount; i2++) {
|
|
39721
|
+
const cell = rowNode.child(i2);
|
|
39722
|
+
rowWidth += cell.attrs.colspan;
|
|
39723
|
+
if (cell.attrs.rowspan > 1)
|
|
39724
|
+
hasRowSpan = true;
|
|
39725
|
+
}
|
|
39726
|
+
if (width == -1)
|
|
39727
|
+
width = rowWidth;
|
|
39728
|
+
else if (width != rowWidth)
|
|
39729
|
+
width = Math.max(width, rowWidth);
|
|
39730
|
+
}
|
|
39731
|
+
return width;
|
|
39732
|
+
}
|
|
39733
|
+
function findBadColWidths(map4, colWidths, table) {
|
|
39734
|
+
if (!map4.problems)
|
|
39735
|
+
map4.problems = [];
|
|
39736
|
+
const seen = {};
|
|
39737
|
+
for (let i2 = 0; i2 < map4.map.length; i2++) {
|
|
39738
|
+
const pos = map4.map[i2];
|
|
39739
|
+
if (seen[pos])
|
|
39740
|
+
continue;
|
|
39741
|
+
seen[pos] = true;
|
|
39742
|
+
const node = table.nodeAt(pos);
|
|
39743
|
+
if (!node) {
|
|
39744
|
+
throw new RangeError(`No cell with offset ${pos} found`);
|
|
39745
|
+
}
|
|
39746
|
+
let updated = null;
|
|
39747
|
+
const attrs = node.attrs;
|
|
39748
|
+
for (let j = 0; j < attrs.colspan; j++) {
|
|
39749
|
+
const col = (i2 + j) % map4.width;
|
|
39750
|
+
const colWidth = colWidths[col * 2];
|
|
39751
|
+
if (colWidth != null && (!attrs.colwidth || attrs.colwidth[j] != colWidth))
|
|
39752
|
+
(updated || (updated = freshColWidth(attrs)))[j] = colWidth;
|
|
39753
|
+
}
|
|
39754
|
+
if (updated)
|
|
39755
|
+
map4.problems.unshift({
|
|
39756
|
+
type: "colwidth mismatch",
|
|
39757
|
+
pos,
|
|
39758
|
+
colwidth: updated
|
|
39759
|
+
});
|
|
39760
|
+
}
|
|
39761
|
+
}
|
|
39762
|
+
function freshColWidth(attrs) {
|
|
39763
|
+
if (attrs.colwidth)
|
|
39764
|
+
return attrs.colwidth.slice();
|
|
39765
|
+
const result = [];
|
|
39766
|
+
for (let i2 = 0; i2 < attrs.colspan; i2++)
|
|
39767
|
+
result.push(0);
|
|
39768
|
+
return result;
|
|
39769
|
+
}
|
|
39770
|
+
function tableNodeTypes(schema) {
|
|
39771
|
+
let result = schema.cached.tableNodeTypes;
|
|
39772
|
+
if (!result) {
|
|
39773
|
+
result = schema.cached.tableNodeTypes = {};
|
|
39774
|
+
for (const name in schema.nodes) {
|
|
39775
|
+
const type3 = schema.nodes[name], role = type3.spec.tableRole;
|
|
39776
|
+
if (role)
|
|
39777
|
+
result[role] = type3;
|
|
39778
|
+
}
|
|
39779
|
+
}
|
|
39780
|
+
return result;
|
|
39781
|
+
}
|
|
39782
|
+
var tableEditingKey = new PluginKey("selectingCells");
|
|
39783
|
+
function cellAround($pos) {
|
|
39784
|
+
for (let d2 = $pos.depth - 1; d2 > 0; d2--)
|
|
39785
|
+
if ($pos.node(d2).type.spec.tableRole == "row")
|
|
39786
|
+
return $pos.node(0).resolve($pos.before(d2 + 1));
|
|
39787
|
+
return null;
|
|
39788
|
+
}
|
|
39789
|
+
function cellWrapping($pos) {
|
|
39790
|
+
for (let d2 = $pos.depth; d2 > 0; d2--) {
|
|
39791
|
+
const role = $pos.node(d2).type.spec.tableRole;
|
|
39792
|
+
if (role === "cell" || role === "header_cell")
|
|
39793
|
+
return $pos.node(d2);
|
|
39794
|
+
}
|
|
39795
|
+
return null;
|
|
39796
|
+
}
|
|
39797
|
+
function isInTable(state2) {
|
|
39798
|
+
const $head = state2.selection.$head;
|
|
39799
|
+
for (let d2 = $head.depth; d2 > 0; d2--)
|
|
39800
|
+
if ($head.node(d2).type.spec.tableRole == "row")
|
|
39801
|
+
return true;
|
|
39802
|
+
return false;
|
|
39803
|
+
}
|
|
39804
|
+
function selectionCell(state2) {
|
|
39805
|
+
const sel = state2.selection;
|
|
39806
|
+
if ("$anchorCell" in sel && sel.$anchorCell) {
|
|
39807
|
+
return sel.$anchorCell.pos > sel.$headCell.pos ? sel.$anchorCell : sel.$headCell;
|
|
39808
|
+
} else if ("node" in sel && sel.node && sel.node.type.spec.tableRole == "cell") {
|
|
39809
|
+
return sel.$anchor;
|
|
39810
|
+
}
|
|
39811
|
+
const $cell = cellAround(sel.$head) || cellNear(sel.$head);
|
|
39812
|
+
if ($cell) {
|
|
39813
|
+
return $cell;
|
|
39814
|
+
}
|
|
39815
|
+
throw new RangeError(`No cell found around position ${sel.head}`);
|
|
39816
|
+
}
|
|
39817
|
+
function cellNear($pos) {
|
|
39818
|
+
for (let after = $pos.nodeAfter, pos = $pos.pos; after; after = after.firstChild, pos++) {
|
|
39819
|
+
const role = after.type.spec.tableRole;
|
|
39820
|
+
if (role == "cell" || role == "header_cell")
|
|
39821
|
+
return $pos.doc.resolve(pos);
|
|
39822
|
+
}
|
|
39823
|
+
for (let before = $pos.nodeBefore, pos = $pos.pos; before; before = before.lastChild, pos--) {
|
|
39824
|
+
const role = before.type.spec.tableRole;
|
|
39825
|
+
if (role == "cell" || role == "header_cell")
|
|
39826
|
+
return $pos.doc.resolve(pos - before.nodeSize);
|
|
39827
|
+
}
|
|
39828
|
+
}
|
|
39829
|
+
function pointsAtCell($pos) {
|
|
39830
|
+
return $pos.parent.type.spec.tableRole == "row" && !!$pos.nodeAfter;
|
|
39831
|
+
}
|
|
39832
|
+
function moveCellForward($pos) {
|
|
39833
|
+
return $pos.node(0).resolve($pos.pos + $pos.nodeAfter.nodeSize);
|
|
39834
|
+
}
|
|
39835
|
+
function inSameTable($cellA, $cellB) {
|
|
39836
|
+
return $cellA.depth == $cellB.depth && $cellA.pos >= $cellB.start(-1) && $cellA.pos <= $cellB.end(-1);
|
|
39837
|
+
}
|
|
39838
|
+
function nextCell($pos, axis2, dir) {
|
|
39839
|
+
const table = $pos.node(-1);
|
|
39840
|
+
const map4 = TableMap.get(table);
|
|
39841
|
+
const tableStart = $pos.start(-1);
|
|
39842
|
+
const moved2 = map4.nextCell($pos.pos - tableStart, axis2, dir);
|
|
39843
|
+
return moved2 == null ? null : $pos.node(0).resolve(tableStart + moved2);
|
|
39844
|
+
}
|
|
39845
|
+
function removeColSpan(attrs, pos, n2 = 1) {
|
|
39846
|
+
const result = { ...attrs, colspan: attrs.colspan - n2 };
|
|
39847
|
+
if (result.colwidth) {
|
|
39848
|
+
result.colwidth = result.colwidth.slice();
|
|
39849
|
+
result.colwidth.splice(pos, n2);
|
|
39850
|
+
if (!result.colwidth.some((w2) => w2 > 0))
|
|
39851
|
+
result.colwidth = null;
|
|
39852
|
+
}
|
|
39853
|
+
return result;
|
|
39854
|
+
}
|
|
39855
|
+
function addColSpan(attrs, pos, n2 = 1) {
|
|
39856
|
+
const result = { ...attrs, colspan: attrs.colspan + n2 };
|
|
39857
|
+
if (result.colwidth) {
|
|
39858
|
+
result.colwidth = result.colwidth.slice();
|
|
39859
|
+
for (let i2 = 0; i2 < n2; i2++)
|
|
39860
|
+
result.colwidth.splice(pos, 0, 0);
|
|
39861
|
+
}
|
|
39862
|
+
return result;
|
|
39863
|
+
}
|
|
39864
|
+
function columnIsHeader(map4, table, col) {
|
|
39865
|
+
const headerCell = tableNodeTypes(table.type.schema).header_cell;
|
|
39866
|
+
for (let row = 0; row < map4.height; row++)
|
|
39867
|
+
if (table.nodeAt(map4.map[col + row * map4.width]).type != headerCell)
|
|
39868
|
+
return false;
|
|
39869
|
+
return true;
|
|
39870
|
+
}
|
|
39871
|
+
var CellSelection = class _CellSelection extends Selection$1 {
|
|
39872
|
+
// A table selection is identified by its anchor and head cells. The
|
|
39873
|
+
// positions given to this constructor should point _before_ two
|
|
39874
|
+
// cells in the same table. They may be the same, to select a single
|
|
39875
|
+
// cell.
|
|
39876
|
+
constructor($anchorCell, $headCell = $anchorCell) {
|
|
39877
|
+
const table = $anchorCell.node(-1);
|
|
39878
|
+
const map4 = TableMap.get(table);
|
|
39879
|
+
const tableStart = $anchorCell.start(-1);
|
|
39880
|
+
const rect = map4.rectBetween(
|
|
39881
|
+
$anchorCell.pos - tableStart,
|
|
39882
|
+
$headCell.pos - tableStart
|
|
39883
|
+
);
|
|
39884
|
+
const doc2 = $anchorCell.node(0);
|
|
39885
|
+
const cells = map4.cellsInRect(rect).filter((p2) => p2 != $headCell.pos - tableStart);
|
|
39886
|
+
cells.unshift($headCell.pos - tableStart);
|
|
39887
|
+
const ranges = cells.map((pos) => {
|
|
39888
|
+
const cell = table.nodeAt(pos);
|
|
39889
|
+
if (!cell) {
|
|
39890
|
+
throw RangeError(`No cell with offset ${pos} found`);
|
|
39891
|
+
}
|
|
39892
|
+
const from2 = tableStart + pos + 1;
|
|
39893
|
+
return new SelectionRange(
|
|
39894
|
+
doc2.resolve(from2),
|
|
39895
|
+
doc2.resolve(from2 + cell.content.size)
|
|
39896
|
+
);
|
|
39897
|
+
});
|
|
39898
|
+
super(ranges[0].$from, ranges[0].$to, ranges);
|
|
39899
|
+
this.$anchorCell = $anchorCell;
|
|
39900
|
+
this.$headCell = $headCell;
|
|
39901
|
+
}
|
|
39902
|
+
map(doc2, mapping) {
|
|
39903
|
+
const $anchorCell = doc2.resolve(mapping.map(this.$anchorCell.pos));
|
|
39904
|
+
const $headCell = doc2.resolve(mapping.map(this.$headCell.pos));
|
|
39905
|
+
if (pointsAtCell($anchorCell) && pointsAtCell($headCell) && inSameTable($anchorCell, $headCell)) {
|
|
39906
|
+
const tableChanged = this.$anchorCell.node(-1) != $anchorCell.node(-1);
|
|
39907
|
+
if (tableChanged && this.isRowSelection())
|
|
39908
|
+
return _CellSelection.rowSelection($anchorCell, $headCell);
|
|
39909
|
+
else if (tableChanged && this.isColSelection())
|
|
39910
|
+
return _CellSelection.colSelection($anchorCell, $headCell);
|
|
39911
|
+
else
|
|
39912
|
+
return new _CellSelection($anchorCell, $headCell);
|
|
39913
|
+
}
|
|
39914
|
+
return TextSelection.between($anchorCell, $headCell);
|
|
39915
|
+
}
|
|
39916
|
+
// Returns a rectangular slice of table rows containing the selected
|
|
39917
|
+
// cells.
|
|
39918
|
+
content() {
|
|
39919
|
+
const table = this.$anchorCell.node(-1);
|
|
39920
|
+
const map4 = TableMap.get(table);
|
|
39921
|
+
const tableStart = this.$anchorCell.start(-1);
|
|
39922
|
+
const rect = map4.rectBetween(
|
|
39923
|
+
this.$anchorCell.pos - tableStart,
|
|
39924
|
+
this.$headCell.pos - tableStart
|
|
39925
|
+
);
|
|
39926
|
+
const seen = {};
|
|
39927
|
+
const rows = [];
|
|
39928
|
+
for (let row = rect.top; row < rect.bottom; row++) {
|
|
39929
|
+
const rowContent = [];
|
|
39930
|
+
for (let index2 = row * map4.width + rect.left, col = rect.left; col < rect.right; col++, index2++) {
|
|
39931
|
+
const pos = map4.map[index2];
|
|
39932
|
+
if (seen[pos])
|
|
39933
|
+
continue;
|
|
39934
|
+
seen[pos] = true;
|
|
39935
|
+
const cellRect = map4.findCell(pos);
|
|
39936
|
+
let cell = table.nodeAt(pos);
|
|
39937
|
+
if (!cell) {
|
|
39938
|
+
throw RangeError(`No cell with offset ${pos} found`);
|
|
39939
|
+
}
|
|
39940
|
+
const extraLeft = rect.left - cellRect.left;
|
|
39941
|
+
const extraRight = cellRect.right - rect.right;
|
|
39942
|
+
if (extraLeft > 0 || extraRight > 0) {
|
|
39943
|
+
let attrs = cell.attrs;
|
|
39944
|
+
if (extraLeft > 0) {
|
|
39945
|
+
attrs = removeColSpan(attrs, 0, extraLeft);
|
|
39946
|
+
}
|
|
39947
|
+
if (extraRight > 0) {
|
|
39948
|
+
attrs = removeColSpan(
|
|
39949
|
+
attrs,
|
|
39950
|
+
attrs.colspan - extraRight,
|
|
39951
|
+
extraRight
|
|
39952
|
+
);
|
|
39953
|
+
}
|
|
39954
|
+
if (cellRect.left < rect.left) {
|
|
39955
|
+
cell = cell.type.createAndFill(attrs);
|
|
39956
|
+
if (!cell) {
|
|
39957
|
+
throw RangeError(
|
|
39958
|
+
`Could not create cell with attrs ${JSON.stringify(attrs)}`
|
|
39959
|
+
);
|
|
39960
|
+
}
|
|
39961
|
+
} else {
|
|
39962
|
+
cell = cell.type.create(attrs, cell.content);
|
|
39963
|
+
}
|
|
39964
|
+
}
|
|
39965
|
+
if (cellRect.top < rect.top || cellRect.bottom > rect.bottom) {
|
|
39966
|
+
const attrs = {
|
|
39967
|
+
...cell.attrs,
|
|
39968
|
+
rowspan: Math.min(cellRect.bottom, rect.bottom) - Math.max(cellRect.top, rect.top)
|
|
39969
|
+
};
|
|
39970
|
+
if (cellRect.top < rect.top) {
|
|
39971
|
+
cell = cell.type.createAndFill(attrs);
|
|
39972
|
+
} else {
|
|
39973
|
+
cell = cell.type.create(attrs, cell.content);
|
|
39974
|
+
}
|
|
39975
|
+
}
|
|
39976
|
+
rowContent.push(cell);
|
|
39977
|
+
}
|
|
39978
|
+
rows.push(table.child(row).copy(Fragment.from(rowContent)));
|
|
39979
|
+
}
|
|
39980
|
+
const fragment = this.isColSelection() && this.isRowSelection() ? table : rows;
|
|
39981
|
+
return new Slice(Fragment.from(fragment), 1, 1);
|
|
39982
|
+
}
|
|
39983
|
+
replace(tr2, content = Slice.empty) {
|
|
39984
|
+
const mapFrom = tr2.steps.length, ranges = this.ranges;
|
|
39985
|
+
for (let i2 = 0; i2 < ranges.length; i2++) {
|
|
39986
|
+
const { $from, $to } = ranges[i2], mapping = tr2.mapping.slice(mapFrom);
|
|
39987
|
+
tr2.replace(
|
|
39988
|
+
mapping.map($from.pos),
|
|
39989
|
+
mapping.map($to.pos),
|
|
39990
|
+
i2 ? Slice.empty : content
|
|
39991
|
+
);
|
|
39992
|
+
}
|
|
39993
|
+
const sel = Selection$1.findFrom(
|
|
39994
|
+
tr2.doc.resolve(tr2.mapping.slice(mapFrom).map(this.to)),
|
|
39995
|
+
-1
|
|
39996
|
+
);
|
|
39997
|
+
if (sel)
|
|
39998
|
+
tr2.setSelection(sel);
|
|
39999
|
+
}
|
|
40000
|
+
replaceWith(tr2, node) {
|
|
40001
|
+
this.replace(tr2, new Slice(Fragment.from(node), 0, 0));
|
|
40002
|
+
}
|
|
40003
|
+
forEachCell(f2) {
|
|
40004
|
+
const table = this.$anchorCell.node(-1);
|
|
40005
|
+
const map4 = TableMap.get(table);
|
|
40006
|
+
const tableStart = this.$anchorCell.start(-1);
|
|
40007
|
+
const cells = map4.cellsInRect(
|
|
40008
|
+
map4.rectBetween(
|
|
40009
|
+
this.$anchorCell.pos - tableStart,
|
|
40010
|
+
this.$headCell.pos - tableStart
|
|
40011
|
+
)
|
|
40012
|
+
);
|
|
40013
|
+
for (let i2 = 0; i2 < cells.length; i2++) {
|
|
40014
|
+
f2(table.nodeAt(cells[i2]), tableStart + cells[i2]);
|
|
40015
|
+
}
|
|
40016
|
+
}
|
|
40017
|
+
// True if this selection goes all the way from the top to the
|
|
40018
|
+
// bottom of the table.
|
|
40019
|
+
isColSelection() {
|
|
40020
|
+
const anchorTop = this.$anchorCell.index(-1);
|
|
40021
|
+
const headTop = this.$headCell.index(-1);
|
|
40022
|
+
if (Math.min(anchorTop, headTop) > 0)
|
|
40023
|
+
return false;
|
|
40024
|
+
const anchorBottom = anchorTop + this.$anchorCell.nodeAfter.attrs.rowspan;
|
|
40025
|
+
const headBottom = headTop + this.$headCell.nodeAfter.attrs.rowspan;
|
|
40026
|
+
return Math.max(anchorBottom, headBottom) == this.$headCell.node(-1).childCount;
|
|
40027
|
+
}
|
|
40028
|
+
// Returns the smallest column selection that covers the given anchor
|
|
40029
|
+
// and head cell.
|
|
40030
|
+
static colSelection($anchorCell, $headCell = $anchorCell) {
|
|
40031
|
+
const table = $anchorCell.node(-1);
|
|
40032
|
+
const map4 = TableMap.get(table);
|
|
40033
|
+
const tableStart = $anchorCell.start(-1);
|
|
40034
|
+
const anchorRect = map4.findCell($anchorCell.pos - tableStart);
|
|
40035
|
+
const headRect = map4.findCell($headCell.pos - tableStart);
|
|
40036
|
+
const doc2 = $anchorCell.node(0);
|
|
40037
|
+
if (anchorRect.top <= headRect.top) {
|
|
40038
|
+
if (anchorRect.top > 0)
|
|
40039
|
+
$anchorCell = doc2.resolve(tableStart + map4.map[anchorRect.left]);
|
|
40040
|
+
if (headRect.bottom < map4.height)
|
|
40041
|
+
$headCell = doc2.resolve(
|
|
40042
|
+
tableStart + map4.map[map4.width * (map4.height - 1) + headRect.right - 1]
|
|
40043
|
+
);
|
|
40044
|
+
} else {
|
|
40045
|
+
if (headRect.top > 0)
|
|
40046
|
+
$headCell = doc2.resolve(tableStart + map4.map[headRect.left]);
|
|
40047
|
+
if (anchorRect.bottom < map4.height)
|
|
40048
|
+
$anchorCell = doc2.resolve(
|
|
40049
|
+
tableStart + map4.map[map4.width * (map4.height - 1) + anchorRect.right - 1]
|
|
40050
|
+
);
|
|
40051
|
+
}
|
|
40052
|
+
return new _CellSelection($anchorCell, $headCell);
|
|
40053
|
+
}
|
|
40054
|
+
// True if this selection goes all the way from the left to the
|
|
40055
|
+
// right of the table.
|
|
40056
|
+
isRowSelection() {
|
|
40057
|
+
const table = this.$anchorCell.node(-1);
|
|
40058
|
+
const map4 = TableMap.get(table);
|
|
40059
|
+
const tableStart = this.$anchorCell.start(-1);
|
|
40060
|
+
const anchorLeft = map4.colCount(this.$anchorCell.pos - tableStart);
|
|
40061
|
+
const headLeft = map4.colCount(this.$headCell.pos - tableStart);
|
|
40062
|
+
if (Math.min(anchorLeft, headLeft) > 0)
|
|
40063
|
+
return false;
|
|
40064
|
+
const anchorRight = anchorLeft + this.$anchorCell.nodeAfter.attrs.colspan;
|
|
40065
|
+
const headRight = headLeft + this.$headCell.nodeAfter.attrs.colspan;
|
|
40066
|
+
return Math.max(anchorRight, headRight) == map4.width;
|
|
40067
|
+
}
|
|
40068
|
+
eq(other) {
|
|
40069
|
+
return other instanceof _CellSelection && other.$anchorCell.pos == this.$anchorCell.pos && other.$headCell.pos == this.$headCell.pos;
|
|
40070
|
+
}
|
|
40071
|
+
// Returns the smallest row selection that covers the given anchor
|
|
40072
|
+
// and head cell.
|
|
40073
|
+
static rowSelection($anchorCell, $headCell = $anchorCell) {
|
|
40074
|
+
const table = $anchorCell.node(-1);
|
|
40075
|
+
const map4 = TableMap.get(table);
|
|
40076
|
+
const tableStart = $anchorCell.start(-1);
|
|
40077
|
+
const anchorRect = map4.findCell($anchorCell.pos - tableStart);
|
|
40078
|
+
const headRect = map4.findCell($headCell.pos - tableStart);
|
|
40079
|
+
const doc2 = $anchorCell.node(0);
|
|
40080
|
+
if (anchorRect.left <= headRect.left) {
|
|
40081
|
+
if (anchorRect.left > 0)
|
|
40082
|
+
$anchorCell = doc2.resolve(
|
|
40083
|
+
tableStart + map4.map[anchorRect.top * map4.width]
|
|
40084
|
+
);
|
|
40085
|
+
if (headRect.right < map4.width)
|
|
40086
|
+
$headCell = doc2.resolve(
|
|
40087
|
+
tableStart + map4.map[map4.width * (headRect.top + 1) - 1]
|
|
40088
|
+
);
|
|
40089
|
+
} else {
|
|
40090
|
+
if (headRect.left > 0)
|
|
40091
|
+
$headCell = doc2.resolve(tableStart + map4.map[headRect.top * map4.width]);
|
|
40092
|
+
if (anchorRect.right < map4.width)
|
|
40093
|
+
$anchorCell = doc2.resolve(
|
|
40094
|
+
tableStart + map4.map[map4.width * (anchorRect.top + 1) - 1]
|
|
40095
|
+
);
|
|
40096
|
+
}
|
|
40097
|
+
return new _CellSelection($anchorCell, $headCell);
|
|
40098
|
+
}
|
|
40099
|
+
toJSON() {
|
|
40100
|
+
return {
|
|
40101
|
+
type: "cell",
|
|
40102
|
+
anchor: this.$anchorCell.pos,
|
|
40103
|
+
head: this.$headCell.pos
|
|
40104
|
+
};
|
|
40105
|
+
}
|
|
40106
|
+
static fromJSON(doc2, json) {
|
|
40107
|
+
return new _CellSelection(doc2.resolve(json.anchor), doc2.resolve(json.head));
|
|
40108
|
+
}
|
|
40109
|
+
static create(doc2, anchorCell, headCell = anchorCell) {
|
|
40110
|
+
return new _CellSelection(doc2.resolve(anchorCell), doc2.resolve(headCell));
|
|
40111
|
+
}
|
|
40112
|
+
getBookmark() {
|
|
40113
|
+
return new CellBookmark(this.$anchorCell.pos, this.$headCell.pos);
|
|
40114
|
+
}
|
|
40115
|
+
};
|
|
40116
|
+
CellSelection.prototype.visible = false;
|
|
40117
|
+
Selection$1.jsonID("cell", CellSelection);
|
|
40118
|
+
var CellBookmark = class _CellBookmark {
|
|
40119
|
+
constructor(anchor, head) {
|
|
40120
|
+
this.anchor = anchor;
|
|
40121
|
+
this.head = head;
|
|
40122
|
+
}
|
|
40123
|
+
map(mapping) {
|
|
40124
|
+
return new _CellBookmark(mapping.map(this.anchor), mapping.map(this.head));
|
|
40125
|
+
}
|
|
40126
|
+
resolve(doc2) {
|
|
40127
|
+
const $anchorCell = doc2.resolve(this.anchor), $headCell = doc2.resolve(this.head);
|
|
40128
|
+
if ($anchorCell.parent.type.spec.tableRole == "row" && $headCell.parent.type.spec.tableRole == "row" && $anchorCell.index() < $anchorCell.parent.childCount && $headCell.index() < $headCell.parent.childCount && inSameTable($anchorCell, $headCell))
|
|
40129
|
+
return new CellSelection($anchorCell, $headCell);
|
|
40130
|
+
else
|
|
40131
|
+
return Selection$1.near($headCell, 1);
|
|
40132
|
+
}
|
|
40133
|
+
};
|
|
40134
|
+
function drawCellSelection(state2) {
|
|
40135
|
+
if (!(state2.selection instanceof CellSelection))
|
|
40136
|
+
return null;
|
|
40137
|
+
const cells = [];
|
|
40138
|
+
state2.selection.forEachCell((node, pos) => {
|
|
40139
|
+
cells.push(
|
|
40140
|
+
Decoration.node(pos, pos + node.nodeSize, { class: "selectedCell" })
|
|
40141
|
+
);
|
|
40142
|
+
});
|
|
40143
|
+
return DecorationSet.create(state2.doc, cells);
|
|
40144
|
+
}
|
|
40145
|
+
function isCellBoundarySelection({ $from, $to }) {
|
|
40146
|
+
if ($from.pos == $to.pos || $from.pos < $from.pos - 6)
|
|
40147
|
+
return false;
|
|
40148
|
+
let afterFrom = $from.pos;
|
|
40149
|
+
let beforeTo = $to.pos;
|
|
40150
|
+
let depth = $from.depth;
|
|
40151
|
+
for (; depth >= 0; depth--, afterFrom++)
|
|
40152
|
+
if ($from.after(depth + 1) < $from.end(depth))
|
|
40153
|
+
break;
|
|
40154
|
+
for (let d2 = $to.depth; d2 >= 0; d2--, beforeTo--)
|
|
40155
|
+
if ($to.before(d2 + 1) > $to.start(d2))
|
|
40156
|
+
break;
|
|
40157
|
+
return afterFrom == beforeTo && /row|table/.test($from.node(depth).type.spec.tableRole);
|
|
40158
|
+
}
|
|
40159
|
+
function isTextSelectionAcrossCells({ $from, $to }) {
|
|
40160
|
+
let fromCellBoundaryNode;
|
|
40161
|
+
let toCellBoundaryNode;
|
|
40162
|
+
for (let i2 = $from.depth; i2 > 0; i2--) {
|
|
40163
|
+
const node = $from.node(i2);
|
|
40164
|
+
if (node.type.spec.tableRole === "cell" || node.type.spec.tableRole === "header_cell") {
|
|
40165
|
+
fromCellBoundaryNode = node;
|
|
40166
|
+
break;
|
|
40167
|
+
}
|
|
40168
|
+
}
|
|
40169
|
+
for (let i2 = $to.depth; i2 > 0; i2--) {
|
|
40170
|
+
const node = $to.node(i2);
|
|
40171
|
+
if (node.type.spec.tableRole === "cell" || node.type.spec.tableRole === "header_cell") {
|
|
40172
|
+
toCellBoundaryNode = node;
|
|
40173
|
+
break;
|
|
40174
|
+
}
|
|
40175
|
+
}
|
|
40176
|
+
return fromCellBoundaryNode !== toCellBoundaryNode && $to.parentOffset === 0;
|
|
40177
|
+
}
|
|
40178
|
+
function normalizeSelection(state2, tr2, allowTableNodeSelection) {
|
|
40179
|
+
const sel = (tr2 || state2).selection;
|
|
40180
|
+
const doc2 = (tr2 || state2).doc;
|
|
40181
|
+
let normalize2;
|
|
40182
|
+
let role;
|
|
40183
|
+
if (sel instanceof NodeSelection && (role = sel.node.type.spec.tableRole)) {
|
|
40184
|
+
if (role == "cell" || role == "header_cell") {
|
|
40185
|
+
normalize2 = CellSelection.create(doc2, sel.from);
|
|
40186
|
+
} else if (role == "row") {
|
|
40187
|
+
const $cell = doc2.resolve(sel.from + 1);
|
|
40188
|
+
normalize2 = CellSelection.rowSelection($cell, $cell);
|
|
40189
|
+
} else if (!allowTableNodeSelection) {
|
|
40190
|
+
const map4 = TableMap.get(sel.node);
|
|
40191
|
+
const start2 = sel.from + 1;
|
|
40192
|
+
const lastCell = start2 + map4.map[map4.width * map4.height - 1];
|
|
40193
|
+
normalize2 = CellSelection.create(doc2, start2 + 1, lastCell);
|
|
40194
|
+
}
|
|
40195
|
+
} else if (sel instanceof TextSelection && isCellBoundarySelection(sel)) {
|
|
40196
|
+
normalize2 = TextSelection.create(doc2, sel.from);
|
|
40197
|
+
} else if (sel instanceof TextSelection && isTextSelectionAcrossCells(sel)) {
|
|
40198
|
+
normalize2 = TextSelection.create(doc2, sel.$from.start(), sel.$from.end());
|
|
40199
|
+
}
|
|
40200
|
+
if (normalize2)
|
|
40201
|
+
(tr2 || (tr2 = state2.tr)).setSelection(normalize2);
|
|
40202
|
+
return tr2;
|
|
40203
|
+
}
|
|
40204
|
+
var fixTablesKey = new PluginKey("fix-tables");
|
|
40205
|
+
function changedDescendants(old, cur, offset2, f2) {
|
|
40206
|
+
const oldSize = old.childCount, curSize = cur.childCount;
|
|
40207
|
+
outer:
|
|
40208
|
+
for (let i2 = 0, j = 0; i2 < curSize; i2++) {
|
|
40209
|
+
const child = cur.child(i2);
|
|
40210
|
+
for (let scan = j, e = Math.min(oldSize, i2 + 3); scan < e; scan++) {
|
|
40211
|
+
if (old.child(scan) == child) {
|
|
40212
|
+
j = scan + 1;
|
|
40213
|
+
offset2 += child.nodeSize;
|
|
40214
|
+
continue outer;
|
|
40215
|
+
}
|
|
40216
|
+
}
|
|
40217
|
+
f2(child, offset2);
|
|
40218
|
+
if (j < oldSize && old.child(j).sameMarkup(child))
|
|
40219
|
+
changedDescendants(old.child(j), child, offset2 + 1, f2);
|
|
40220
|
+
else
|
|
40221
|
+
child.nodesBetween(0, child.content.size, f2, offset2 + 1);
|
|
40222
|
+
offset2 += child.nodeSize;
|
|
40223
|
+
}
|
|
40224
|
+
}
|
|
40225
|
+
function fixTables(state2, oldState) {
|
|
40226
|
+
let tr2;
|
|
40227
|
+
const check = (node, pos) => {
|
|
40228
|
+
if (node.type.spec.tableRole == "table")
|
|
40229
|
+
tr2 = fixTable(state2, node, pos, tr2);
|
|
40230
|
+
};
|
|
40231
|
+
if (!oldState)
|
|
40232
|
+
state2.doc.descendants(check);
|
|
40233
|
+
else if (oldState.doc != state2.doc)
|
|
40234
|
+
changedDescendants(oldState.doc, state2.doc, 0, check);
|
|
40235
|
+
return tr2;
|
|
40236
|
+
}
|
|
40237
|
+
function fixTable(state2, table, tablePos, tr2) {
|
|
40238
|
+
const map4 = TableMap.get(table);
|
|
40239
|
+
if (!map4.problems)
|
|
40240
|
+
return tr2;
|
|
40241
|
+
if (!tr2)
|
|
40242
|
+
tr2 = state2.tr;
|
|
40243
|
+
const mustAdd = [];
|
|
40244
|
+
for (let i2 = 0; i2 < map4.height; i2++)
|
|
40245
|
+
mustAdd.push(0);
|
|
40246
|
+
for (let i2 = 0; i2 < map4.problems.length; i2++) {
|
|
40247
|
+
const prob = map4.problems[i2];
|
|
40248
|
+
if (prob.type == "collision") {
|
|
40249
|
+
const cell = table.nodeAt(prob.pos);
|
|
40250
|
+
if (!cell)
|
|
40251
|
+
continue;
|
|
40252
|
+
const attrs = cell.attrs;
|
|
40253
|
+
for (let j = 0; j < attrs.rowspan; j++)
|
|
40254
|
+
mustAdd[prob.row + j] += prob.n;
|
|
40255
|
+
tr2.setNodeMarkup(
|
|
40256
|
+
tr2.mapping.map(tablePos + 1 + prob.pos),
|
|
40257
|
+
null,
|
|
40258
|
+
removeColSpan(attrs, attrs.colspan - prob.n, prob.n)
|
|
40259
|
+
);
|
|
40260
|
+
} else if (prob.type == "missing") {
|
|
40261
|
+
mustAdd[prob.row] += prob.n;
|
|
40262
|
+
} else if (prob.type == "overlong_rowspan") {
|
|
40263
|
+
const cell = table.nodeAt(prob.pos);
|
|
40264
|
+
if (!cell)
|
|
40265
|
+
continue;
|
|
40266
|
+
tr2.setNodeMarkup(tr2.mapping.map(tablePos + 1 + prob.pos), null, {
|
|
40267
|
+
...cell.attrs,
|
|
40268
|
+
rowspan: cell.attrs.rowspan - prob.n
|
|
40269
|
+
});
|
|
40270
|
+
} else if (prob.type == "colwidth mismatch") {
|
|
40271
|
+
const cell = table.nodeAt(prob.pos);
|
|
40272
|
+
if (!cell)
|
|
40273
|
+
continue;
|
|
40274
|
+
tr2.setNodeMarkup(tr2.mapping.map(tablePos + 1 + prob.pos), null, {
|
|
40275
|
+
...cell.attrs,
|
|
40276
|
+
colwidth: prob.colwidth
|
|
40277
|
+
});
|
|
40278
|
+
}
|
|
40279
|
+
}
|
|
40280
|
+
let first2, last;
|
|
40281
|
+
for (let i2 = 0; i2 < mustAdd.length; i2++)
|
|
40282
|
+
if (mustAdd[i2]) {
|
|
40283
|
+
if (first2 == null)
|
|
40284
|
+
first2 = i2;
|
|
40285
|
+
last = i2;
|
|
40286
|
+
}
|
|
40287
|
+
for (let i2 = 0, pos = tablePos + 1; i2 < map4.height; i2++) {
|
|
40288
|
+
const row = table.child(i2);
|
|
40289
|
+
const end2 = pos + row.nodeSize;
|
|
40290
|
+
const add2 = mustAdd[i2];
|
|
40291
|
+
if (add2 > 0) {
|
|
40292
|
+
let role = "cell";
|
|
40293
|
+
if (row.firstChild) {
|
|
40294
|
+
role = row.firstChild.type.spec.tableRole;
|
|
40295
|
+
}
|
|
40296
|
+
const nodes = [];
|
|
40297
|
+
for (let j = 0; j < add2; j++) {
|
|
40298
|
+
const node = tableNodeTypes(state2.schema)[role].createAndFill();
|
|
40299
|
+
if (node)
|
|
40300
|
+
nodes.push(node);
|
|
40301
|
+
}
|
|
40302
|
+
const side = (i2 == 0 || first2 == i2 - 1) && last == i2 ? pos + 1 : end2 - 1;
|
|
40303
|
+
tr2.insert(tr2.mapping.map(side), nodes);
|
|
40304
|
+
}
|
|
40305
|
+
pos = end2;
|
|
40306
|
+
}
|
|
40307
|
+
return tr2.setMeta(fixTablesKey, { fixTables: true });
|
|
40308
|
+
}
|
|
40309
|
+
function pastedCells(slice4) {
|
|
40310
|
+
if (!slice4.size)
|
|
40311
|
+
return null;
|
|
40312
|
+
let { content, openStart, openEnd } = slice4;
|
|
40313
|
+
while (content.childCount == 1 && (openStart > 0 && openEnd > 0 || content.child(0).type.spec.tableRole == "table")) {
|
|
40314
|
+
openStart--;
|
|
40315
|
+
openEnd--;
|
|
40316
|
+
content = content.child(0).content;
|
|
40317
|
+
}
|
|
40318
|
+
const first2 = content.child(0);
|
|
40319
|
+
const role = first2.type.spec.tableRole;
|
|
40320
|
+
const schema = first2.type.schema, rows = [];
|
|
40321
|
+
if (role == "row") {
|
|
40322
|
+
for (let i2 = 0; i2 < content.childCount; i2++) {
|
|
40323
|
+
let cells = content.child(i2).content;
|
|
40324
|
+
const left2 = i2 ? 0 : Math.max(0, openStart - 1);
|
|
40325
|
+
const right2 = i2 < content.childCount - 1 ? 0 : Math.max(0, openEnd - 1);
|
|
40326
|
+
if (left2 || right2)
|
|
40327
|
+
cells = fitSlice(
|
|
40328
|
+
tableNodeTypes(schema).row,
|
|
40329
|
+
new Slice(cells, left2, right2)
|
|
40330
|
+
).content;
|
|
40331
|
+
rows.push(cells);
|
|
40332
|
+
}
|
|
40333
|
+
} else if (role == "cell" || role == "header_cell") {
|
|
40334
|
+
rows.push(
|
|
40335
|
+
openStart || openEnd ? fitSlice(
|
|
40336
|
+
tableNodeTypes(schema).row,
|
|
40337
|
+
new Slice(content, openStart, openEnd)
|
|
40338
|
+
).content : content
|
|
40339
|
+
);
|
|
40340
|
+
} else {
|
|
40341
|
+
return null;
|
|
40342
|
+
}
|
|
40343
|
+
return ensureRectangular(schema, rows);
|
|
40344
|
+
}
|
|
40345
|
+
function ensureRectangular(schema, rows) {
|
|
40346
|
+
const widths = [];
|
|
40347
|
+
for (let i2 = 0; i2 < rows.length; i2++) {
|
|
40348
|
+
const row = rows[i2];
|
|
40349
|
+
for (let j = row.childCount - 1; j >= 0; j--) {
|
|
40350
|
+
const { rowspan, colspan } = row.child(j).attrs;
|
|
40351
|
+
for (let r2 = i2; r2 < i2 + rowspan; r2++)
|
|
40352
|
+
widths[r2] = (widths[r2] || 0) + colspan;
|
|
40353
|
+
}
|
|
40354
|
+
}
|
|
40355
|
+
let width = 0;
|
|
40356
|
+
for (let r2 = 0; r2 < widths.length; r2++)
|
|
40357
|
+
width = Math.max(width, widths[r2]);
|
|
40358
|
+
for (let r2 = 0; r2 < widths.length; r2++) {
|
|
40359
|
+
if (r2 >= rows.length)
|
|
40360
|
+
rows.push(Fragment.empty);
|
|
40361
|
+
if (widths[r2] < width) {
|
|
40362
|
+
const empty2 = tableNodeTypes(schema).cell.createAndFill();
|
|
40363
|
+
const cells = [];
|
|
40364
|
+
for (let i2 = widths[r2]; i2 < width; i2++) {
|
|
40365
|
+
cells.push(empty2);
|
|
40366
|
+
}
|
|
40367
|
+
rows[r2] = rows[r2].append(Fragment.from(cells));
|
|
40368
|
+
}
|
|
40369
|
+
}
|
|
40370
|
+
return { height: rows.length, width, rows };
|
|
40371
|
+
}
|
|
40372
|
+
function fitSlice(nodeType, slice4) {
|
|
40373
|
+
const node = nodeType.createAndFill();
|
|
40374
|
+
const tr2 = new Transform(node).replace(0, node.content.size, slice4);
|
|
40375
|
+
return tr2.doc;
|
|
40376
|
+
}
|
|
40377
|
+
function clipCells({ width, height, rows }, newWidth, newHeight) {
|
|
40378
|
+
if (width != newWidth) {
|
|
40379
|
+
const added = [];
|
|
40380
|
+
const newRows = [];
|
|
40381
|
+
for (let row = 0; row < rows.length; row++) {
|
|
40382
|
+
const frag = rows[row], cells = [];
|
|
40383
|
+
for (let col = added[row] || 0, i2 = 0; col < newWidth; i2++) {
|
|
40384
|
+
let cell = frag.child(i2 % frag.childCount);
|
|
40385
|
+
if (col + cell.attrs.colspan > newWidth)
|
|
40386
|
+
cell = cell.type.createChecked(
|
|
40387
|
+
removeColSpan(
|
|
40388
|
+
cell.attrs,
|
|
40389
|
+
cell.attrs.colspan,
|
|
40390
|
+
col + cell.attrs.colspan - newWidth
|
|
40391
|
+
),
|
|
40392
|
+
cell.content
|
|
40393
|
+
);
|
|
40394
|
+
cells.push(cell);
|
|
40395
|
+
col += cell.attrs.colspan;
|
|
40396
|
+
for (let j = 1; j < cell.attrs.rowspan; j++)
|
|
40397
|
+
added[row + j] = (added[row + j] || 0) + cell.attrs.colspan;
|
|
40398
|
+
}
|
|
40399
|
+
newRows.push(Fragment.from(cells));
|
|
40400
|
+
}
|
|
40401
|
+
rows = newRows;
|
|
40402
|
+
width = newWidth;
|
|
40403
|
+
}
|
|
40404
|
+
if (height != newHeight) {
|
|
40405
|
+
const newRows = [];
|
|
40406
|
+
for (let row = 0, i2 = 0; row < newHeight; row++, i2++) {
|
|
40407
|
+
const cells = [], source = rows[i2 % height];
|
|
40408
|
+
for (let j = 0; j < source.childCount; j++) {
|
|
40409
|
+
let cell = source.child(j);
|
|
40410
|
+
if (row + cell.attrs.rowspan > newHeight)
|
|
40411
|
+
cell = cell.type.create(
|
|
40412
|
+
{
|
|
40413
|
+
...cell.attrs,
|
|
40414
|
+
rowspan: Math.max(1, newHeight - cell.attrs.rowspan)
|
|
40415
|
+
},
|
|
40416
|
+
cell.content
|
|
40417
|
+
);
|
|
40418
|
+
cells.push(cell);
|
|
40419
|
+
}
|
|
40420
|
+
newRows.push(Fragment.from(cells));
|
|
40421
|
+
}
|
|
40422
|
+
rows = newRows;
|
|
40423
|
+
height = newHeight;
|
|
40424
|
+
}
|
|
40425
|
+
return { width, height, rows };
|
|
40426
|
+
}
|
|
40427
|
+
function growTable(tr2, map4, table, start2, width, height, mapFrom) {
|
|
40428
|
+
const schema = tr2.doc.type.schema;
|
|
40429
|
+
const types = tableNodeTypes(schema);
|
|
40430
|
+
let empty2;
|
|
40431
|
+
let emptyHead;
|
|
40432
|
+
if (width > map4.width) {
|
|
40433
|
+
for (let row = 0, rowEnd = 0; row < map4.height; row++) {
|
|
40434
|
+
const rowNode = table.child(row);
|
|
40435
|
+
rowEnd += rowNode.nodeSize;
|
|
40436
|
+
const cells = [];
|
|
40437
|
+
let add2;
|
|
40438
|
+
if (rowNode.lastChild == null || rowNode.lastChild.type == types.cell)
|
|
40439
|
+
add2 = empty2 || (empty2 = types.cell.createAndFill());
|
|
40440
|
+
else
|
|
40441
|
+
add2 = emptyHead || (emptyHead = types.header_cell.createAndFill());
|
|
40442
|
+
for (let i2 = map4.width; i2 < width; i2++)
|
|
40443
|
+
cells.push(add2);
|
|
40444
|
+
tr2.insert(tr2.mapping.slice(mapFrom).map(rowEnd - 1 + start2), cells);
|
|
40445
|
+
}
|
|
40446
|
+
}
|
|
40447
|
+
if (height > map4.height) {
|
|
40448
|
+
const cells = [];
|
|
40449
|
+
for (let i2 = 0, start22 = (map4.height - 1) * map4.width; i2 < Math.max(map4.width, width); i2++) {
|
|
40450
|
+
const header = i2 >= map4.width ? false : table.nodeAt(map4.map[start22 + i2]).type == types.header_cell;
|
|
40451
|
+
cells.push(
|
|
40452
|
+
header ? emptyHead || (emptyHead = types.header_cell.createAndFill()) : empty2 || (empty2 = types.cell.createAndFill())
|
|
40453
|
+
);
|
|
40454
|
+
}
|
|
40455
|
+
const emptyRow = types.row.create(null, Fragment.from(cells)), rows = [];
|
|
40456
|
+
for (let i2 = map4.height; i2 < height; i2++)
|
|
40457
|
+
rows.push(emptyRow);
|
|
40458
|
+
tr2.insert(tr2.mapping.slice(mapFrom).map(start2 + table.nodeSize - 2), rows);
|
|
40459
|
+
}
|
|
40460
|
+
return !!(empty2 || emptyHead);
|
|
40461
|
+
}
|
|
40462
|
+
function isolateHorizontal(tr2, map4, table, start2, left2, right2, top2, mapFrom) {
|
|
40463
|
+
if (top2 == 0 || top2 == map4.height)
|
|
40464
|
+
return false;
|
|
40465
|
+
let found2 = false;
|
|
40466
|
+
for (let col = left2; col < right2; col++) {
|
|
40467
|
+
const index2 = top2 * map4.width + col, pos = map4.map[index2];
|
|
40468
|
+
if (map4.map[index2 - map4.width] == pos) {
|
|
40469
|
+
found2 = true;
|
|
40470
|
+
const cell = table.nodeAt(pos);
|
|
40471
|
+
const { top: cellTop, left: cellLeft } = map4.findCell(pos);
|
|
40472
|
+
tr2.setNodeMarkup(tr2.mapping.slice(mapFrom).map(pos + start2), null, {
|
|
40473
|
+
...cell.attrs,
|
|
40474
|
+
rowspan: top2 - cellTop
|
|
40475
|
+
});
|
|
40476
|
+
tr2.insert(
|
|
40477
|
+
tr2.mapping.slice(mapFrom).map(map4.positionAt(top2, cellLeft, table)),
|
|
40478
|
+
cell.type.createAndFill({
|
|
40479
|
+
...cell.attrs,
|
|
40480
|
+
rowspan: cellTop + cell.attrs.rowspan - top2
|
|
40481
|
+
})
|
|
40482
|
+
);
|
|
40483
|
+
col += cell.attrs.colspan - 1;
|
|
40484
|
+
}
|
|
40485
|
+
}
|
|
40486
|
+
return found2;
|
|
40487
|
+
}
|
|
40488
|
+
function isolateVertical(tr2, map4, table, start2, top2, bottom2, left2, mapFrom) {
|
|
40489
|
+
if (left2 == 0 || left2 == map4.width)
|
|
40490
|
+
return false;
|
|
40491
|
+
let found2 = false;
|
|
40492
|
+
for (let row = top2; row < bottom2; row++) {
|
|
40493
|
+
const index2 = row * map4.width + left2, pos = map4.map[index2];
|
|
40494
|
+
if (map4.map[index2 - 1] == pos) {
|
|
40495
|
+
found2 = true;
|
|
40496
|
+
const cell = table.nodeAt(pos);
|
|
40497
|
+
const cellLeft = map4.colCount(pos);
|
|
40498
|
+
const updatePos = tr2.mapping.slice(mapFrom).map(pos + start2);
|
|
40499
|
+
tr2.setNodeMarkup(
|
|
40500
|
+
updatePos,
|
|
40501
|
+
null,
|
|
40502
|
+
removeColSpan(
|
|
40503
|
+
cell.attrs,
|
|
40504
|
+
left2 - cellLeft,
|
|
40505
|
+
cell.attrs.colspan - (left2 - cellLeft)
|
|
40506
|
+
)
|
|
40507
|
+
);
|
|
40508
|
+
tr2.insert(
|
|
40509
|
+
updatePos + cell.nodeSize,
|
|
40510
|
+
cell.type.createAndFill(
|
|
40511
|
+
removeColSpan(cell.attrs, 0, left2 - cellLeft)
|
|
40512
|
+
)
|
|
40513
|
+
);
|
|
40514
|
+
row += cell.attrs.rowspan - 1;
|
|
40515
|
+
}
|
|
40516
|
+
}
|
|
40517
|
+
return found2;
|
|
40518
|
+
}
|
|
40519
|
+
function insertCells(state2, dispatch, tableStart, rect, cells) {
|
|
40520
|
+
let table = tableStart ? state2.doc.nodeAt(tableStart - 1) : state2.doc;
|
|
40521
|
+
if (!table) {
|
|
40522
|
+
throw new Error("No table found");
|
|
40523
|
+
}
|
|
40524
|
+
let map4 = TableMap.get(table);
|
|
40525
|
+
const { top: top2, left: left2 } = rect;
|
|
40526
|
+
const right2 = left2 + cells.width, bottom2 = top2 + cells.height;
|
|
40527
|
+
const tr2 = state2.tr;
|
|
40528
|
+
let mapFrom = 0;
|
|
40529
|
+
function recomp() {
|
|
40530
|
+
table = tableStart ? tr2.doc.nodeAt(tableStart - 1) : tr2.doc;
|
|
40531
|
+
if (!table) {
|
|
40532
|
+
throw new Error("No table found");
|
|
40533
|
+
}
|
|
40534
|
+
map4 = TableMap.get(table);
|
|
40535
|
+
mapFrom = tr2.mapping.maps.length;
|
|
40536
|
+
}
|
|
40537
|
+
if (growTable(tr2, map4, table, tableStart, right2, bottom2, mapFrom))
|
|
40538
|
+
recomp();
|
|
40539
|
+
if (isolateHorizontal(tr2, map4, table, tableStart, left2, right2, top2, mapFrom))
|
|
40540
|
+
recomp();
|
|
40541
|
+
if (isolateHorizontal(tr2, map4, table, tableStart, left2, right2, bottom2, mapFrom))
|
|
40542
|
+
recomp();
|
|
40543
|
+
if (isolateVertical(tr2, map4, table, tableStart, top2, bottom2, left2, mapFrom))
|
|
40544
|
+
recomp();
|
|
40545
|
+
if (isolateVertical(tr2, map4, table, tableStart, top2, bottom2, right2, mapFrom))
|
|
40546
|
+
recomp();
|
|
40547
|
+
for (let row = top2; row < bottom2; row++) {
|
|
40548
|
+
const from2 = map4.positionAt(row, left2, table), to2 = map4.positionAt(row, right2, table);
|
|
40549
|
+
tr2.replace(
|
|
40550
|
+
tr2.mapping.slice(mapFrom).map(from2 + tableStart),
|
|
40551
|
+
tr2.mapping.slice(mapFrom).map(to2 + tableStart),
|
|
40552
|
+
new Slice(cells.rows[row - top2], 0, 0)
|
|
40553
|
+
);
|
|
40554
|
+
}
|
|
40555
|
+
recomp();
|
|
40556
|
+
tr2.setSelection(
|
|
40557
|
+
new CellSelection(
|
|
40558
|
+
tr2.doc.resolve(tableStart + map4.positionAt(top2, left2, table)),
|
|
40559
|
+
tr2.doc.resolve(tableStart + map4.positionAt(bottom2 - 1, right2 - 1, table))
|
|
40560
|
+
)
|
|
40561
|
+
);
|
|
40562
|
+
dispatch(tr2);
|
|
40563
|
+
}
|
|
40564
|
+
var handleKeyDown = keydownHandler({
|
|
40565
|
+
ArrowLeft: arrow("horiz", -1),
|
|
40566
|
+
ArrowRight: arrow("horiz", 1),
|
|
40567
|
+
ArrowUp: arrow("vert", -1),
|
|
40568
|
+
ArrowDown: arrow("vert", 1),
|
|
40569
|
+
"Shift-ArrowLeft": shiftArrow("horiz", -1),
|
|
40570
|
+
"Shift-ArrowRight": shiftArrow("horiz", 1),
|
|
40571
|
+
"Shift-ArrowUp": shiftArrow("vert", -1),
|
|
40572
|
+
"Shift-ArrowDown": shiftArrow("vert", 1),
|
|
40573
|
+
Backspace: deleteCellSelection,
|
|
40574
|
+
"Mod-Backspace": deleteCellSelection,
|
|
40575
|
+
Delete: deleteCellSelection,
|
|
40576
|
+
"Mod-Delete": deleteCellSelection
|
|
40577
|
+
});
|
|
40578
|
+
function maybeSetSelection(state2, dispatch, selection) {
|
|
40579
|
+
if (selection.eq(state2.selection))
|
|
40580
|
+
return false;
|
|
40581
|
+
if (dispatch)
|
|
40582
|
+
dispatch(state2.tr.setSelection(selection).scrollIntoView());
|
|
40583
|
+
return true;
|
|
40584
|
+
}
|
|
40585
|
+
function arrow(axis2, dir) {
|
|
40586
|
+
return (state2, dispatch, view) => {
|
|
40587
|
+
if (!view)
|
|
40588
|
+
return false;
|
|
40589
|
+
const sel = state2.selection;
|
|
40590
|
+
if (sel instanceof CellSelection) {
|
|
40591
|
+
return maybeSetSelection(
|
|
40592
|
+
state2,
|
|
40593
|
+
dispatch,
|
|
40594
|
+
Selection$1.near(sel.$headCell, dir)
|
|
40595
|
+
);
|
|
40596
|
+
}
|
|
40597
|
+
if (axis2 != "horiz" && !sel.empty)
|
|
40598
|
+
return false;
|
|
40599
|
+
const end2 = atEndOfCell(view, axis2, dir);
|
|
40600
|
+
if (end2 == null)
|
|
40601
|
+
return false;
|
|
40602
|
+
if (axis2 == "horiz") {
|
|
40603
|
+
return maybeSetSelection(
|
|
40604
|
+
state2,
|
|
40605
|
+
dispatch,
|
|
40606
|
+
Selection$1.near(state2.doc.resolve(sel.head + dir), dir)
|
|
40607
|
+
);
|
|
40608
|
+
} else {
|
|
40609
|
+
const $cell = state2.doc.resolve(end2);
|
|
40610
|
+
const $next = nextCell($cell, axis2, dir);
|
|
40611
|
+
let newSel;
|
|
40612
|
+
if ($next)
|
|
40613
|
+
newSel = Selection$1.near($next, 1);
|
|
40614
|
+
else if (dir < 0)
|
|
40615
|
+
newSel = Selection$1.near(state2.doc.resolve($cell.before(-1)), -1);
|
|
40616
|
+
else
|
|
40617
|
+
newSel = Selection$1.near(state2.doc.resolve($cell.after(-1)), 1);
|
|
40618
|
+
return maybeSetSelection(state2, dispatch, newSel);
|
|
40619
|
+
}
|
|
40620
|
+
};
|
|
40621
|
+
}
|
|
40622
|
+
function shiftArrow(axis2, dir) {
|
|
40623
|
+
return (state2, dispatch, view) => {
|
|
40624
|
+
if (!view)
|
|
40625
|
+
return false;
|
|
40626
|
+
const sel = state2.selection;
|
|
40627
|
+
let cellSel;
|
|
40628
|
+
if (sel instanceof CellSelection) {
|
|
40629
|
+
cellSel = sel;
|
|
40630
|
+
} else {
|
|
40631
|
+
const end2 = atEndOfCell(view, axis2, dir);
|
|
40632
|
+
if (end2 == null)
|
|
40633
|
+
return false;
|
|
40634
|
+
cellSel = new CellSelection(state2.doc.resolve(end2));
|
|
40635
|
+
}
|
|
40636
|
+
const $head = nextCell(cellSel.$headCell, axis2, dir);
|
|
40637
|
+
if (!$head)
|
|
40638
|
+
return false;
|
|
40639
|
+
return maybeSetSelection(
|
|
40640
|
+
state2,
|
|
40641
|
+
dispatch,
|
|
40642
|
+
new CellSelection(cellSel.$anchorCell, $head)
|
|
40643
|
+
);
|
|
40644
|
+
};
|
|
40645
|
+
}
|
|
40646
|
+
function deleteCellSelection(state2, dispatch) {
|
|
40647
|
+
const sel = state2.selection;
|
|
40648
|
+
if (!(sel instanceof CellSelection))
|
|
40649
|
+
return false;
|
|
40650
|
+
if (dispatch) {
|
|
40651
|
+
const tr2 = state2.tr;
|
|
40652
|
+
const baseContent = tableNodeTypes(state2.schema).cell.createAndFill().content;
|
|
40653
|
+
sel.forEachCell((cell, pos) => {
|
|
40654
|
+
if (!cell.content.eq(baseContent))
|
|
40655
|
+
tr2.replace(
|
|
40656
|
+
tr2.mapping.map(pos + 1),
|
|
40657
|
+
tr2.mapping.map(pos + cell.nodeSize - 1),
|
|
40658
|
+
new Slice(baseContent, 0, 0)
|
|
40659
|
+
);
|
|
40660
|
+
});
|
|
40661
|
+
if (tr2.docChanged)
|
|
40662
|
+
dispatch(tr2);
|
|
40663
|
+
}
|
|
40664
|
+
return true;
|
|
40665
|
+
}
|
|
40666
|
+
function handleTripleClick(view, pos) {
|
|
40667
|
+
const doc2 = view.state.doc, $cell = cellAround(doc2.resolve(pos));
|
|
40668
|
+
if (!$cell)
|
|
40669
|
+
return false;
|
|
40670
|
+
view.dispatch(view.state.tr.setSelection(new CellSelection($cell)));
|
|
40671
|
+
return true;
|
|
40672
|
+
}
|
|
40673
|
+
function handlePaste(view, _2, slice4) {
|
|
40674
|
+
if (!isInTable(view.state))
|
|
40675
|
+
return false;
|
|
40676
|
+
let cells = pastedCells(slice4);
|
|
40677
|
+
const sel = view.state.selection;
|
|
40678
|
+
if (sel instanceof CellSelection) {
|
|
40679
|
+
if (!cells)
|
|
40680
|
+
cells = {
|
|
40681
|
+
width: 1,
|
|
40682
|
+
height: 1,
|
|
40683
|
+
rows: [
|
|
40684
|
+
Fragment.from(
|
|
40685
|
+
fitSlice(tableNodeTypes(view.state.schema).cell, slice4)
|
|
40686
|
+
)
|
|
40687
|
+
]
|
|
40688
|
+
};
|
|
40689
|
+
const table = sel.$anchorCell.node(-1);
|
|
40690
|
+
const start2 = sel.$anchorCell.start(-1);
|
|
40691
|
+
const rect = TableMap.get(table).rectBetween(
|
|
40692
|
+
sel.$anchorCell.pos - start2,
|
|
40693
|
+
sel.$headCell.pos - start2
|
|
40694
|
+
);
|
|
40695
|
+
cells = clipCells(cells, rect.right - rect.left, rect.bottom - rect.top);
|
|
40696
|
+
insertCells(view.state, view.dispatch, start2, rect, cells);
|
|
40697
|
+
return true;
|
|
40698
|
+
} else if (cells) {
|
|
40699
|
+
const $cell = selectionCell(view.state);
|
|
40700
|
+
const start2 = $cell.start(-1);
|
|
40701
|
+
insertCells(
|
|
40702
|
+
view.state,
|
|
40703
|
+
view.dispatch,
|
|
40704
|
+
start2,
|
|
40705
|
+
TableMap.get($cell.node(-1)).findCell($cell.pos - start2),
|
|
40706
|
+
cells
|
|
40707
|
+
);
|
|
40708
|
+
return true;
|
|
40709
|
+
} else {
|
|
40710
|
+
return false;
|
|
40711
|
+
}
|
|
40712
|
+
}
|
|
40713
|
+
function handleMouseDown(view, startEvent) {
|
|
40714
|
+
var _a2;
|
|
40715
|
+
if (startEvent.ctrlKey || startEvent.metaKey)
|
|
40716
|
+
return;
|
|
40717
|
+
const startDOMCell = domInCell(view, startEvent.target);
|
|
40718
|
+
let $anchor;
|
|
40719
|
+
if (startEvent.shiftKey && view.state.selection instanceof CellSelection) {
|
|
40720
|
+
setCellSelection(view.state.selection.$anchorCell, startEvent);
|
|
40721
|
+
startEvent.preventDefault();
|
|
40722
|
+
} else if (startEvent.shiftKey && startDOMCell && ($anchor = cellAround(view.state.selection.$anchor)) != null && ((_a2 = cellUnderMouse(view, startEvent)) == null ? void 0 : _a2.pos) != $anchor.pos) {
|
|
40723
|
+
setCellSelection($anchor, startEvent);
|
|
40724
|
+
startEvent.preventDefault();
|
|
40725
|
+
} else if (!startDOMCell) {
|
|
40726
|
+
return;
|
|
40727
|
+
}
|
|
40728
|
+
function setCellSelection($anchor2, event) {
|
|
40729
|
+
let $head = cellUnderMouse(view, event);
|
|
40730
|
+
const starting = tableEditingKey.getState(view.state) == null;
|
|
40731
|
+
if (!$head || !inSameTable($anchor2, $head)) {
|
|
40732
|
+
if (starting)
|
|
40733
|
+
$head = $anchor2;
|
|
40734
|
+
else
|
|
40735
|
+
return;
|
|
40736
|
+
}
|
|
40737
|
+
const selection = new CellSelection($anchor2, $head);
|
|
40738
|
+
if (starting || !view.state.selection.eq(selection)) {
|
|
40739
|
+
const tr2 = view.state.tr.setSelection(selection);
|
|
40740
|
+
if (starting)
|
|
40741
|
+
tr2.setMeta(tableEditingKey, $anchor2.pos);
|
|
40742
|
+
view.dispatch(tr2);
|
|
40743
|
+
}
|
|
40744
|
+
}
|
|
40745
|
+
function stop() {
|
|
40746
|
+
view.root.removeEventListener("mouseup", stop);
|
|
40747
|
+
view.root.removeEventListener("dragstart", stop);
|
|
40748
|
+
view.root.removeEventListener("mousemove", move);
|
|
40749
|
+
if (tableEditingKey.getState(view.state) != null)
|
|
40750
|
+
view.dispatch(view.state.tr.setMeta(tableEditingKey, -1));
|
|
40751
|
+
}
|
|
40752
|
+
function move(_event) {
|
|
40753
|
+
const event = _event;
|
|
40754
|
+
const anchor = tableEditingKey.getState(view.state);
|
|
40755
|
+
let $anchor2;
|
|
40756
|
+
if (anchor != null) {
|
|
40757
|
+
$anchor2 = view.state.doc.resolve(anchor);
|
|
40758
|
+
} else if (domInCell(view, event.target) != startDOMCell) {
|
|
40759
|
+
$anchor2 = cellUnderMouse(view, startEvent);
|
|
40760
|
+
if (!$anchor2)
|
|
40761
|
+
return stop();
|
|
40762
|
+
}
|
|
40763
|
+
if ($anchor2)
|
|
40764
|
+
setCellSelection($anchor2, event);
|
|
40765
|
+
}
|
|
40766
|
+
view.root.addEventListener("mouseup", stop);
|
|
40767
|
+
view.root.addEventListener("dragstart", stop);
|
|
40768
|
+
view.root.addEventListener("mousemove", move);
|
|
40769
|
+
}
|
|
40770
|
+
function atEndOfCell(view, axis2, dir) {
|
|
40771
|
+
if (!(view.state.selection instanceof TextSelection))
|
|
40772
|
+
return null;
|
|
40773
|
+
const { $head } = view.state.selection;
|
|
40774
|
+
for (let d2 = $head.depth - 1; d2 >= 0; d2--) {
|
|
40775
|
+
const parent = $head.node(d2), index2 = dir < 0 ? $head.index(d2) : $head.indexAfter(d2);
|
|
40776
|
+
if (index2 != (dir < 0 ? 0 : parent.childCount))
|
|
40777
|
+
return null;
|
|
40778
|
+
if (parent.type.spec.tableRole == "cell" || parent.type.spec.tableRole == "header_cell") {
|
|
40779
|
+
const cellPos = $head.before(d2);
|
|
40780
|
+
const dirStr = axis2 == "vert" ? dir > 0 ? "down" : "up" : dir > 0 ? "right" : "left";
|
|
40781
|
+
return view.endOfTextblock(dirStr) ? cellPos : null;
|
|
40782
|
+
}
|
|
40783
|
+
}
|
|
40784
|
+
return null;
|
|
40785
|
+
}
|
|
40786
|
+
function domInCell(view, dom) {
|
|
40787
|
+
for (; dom && dom != view.dom; dom = dom.parentNode) {
|
|
40788
|
+
if (dom.nodeName == "TD" || dom.nodeName == "TH") {
|
|
40789
|
+
return dom;
|
|
40790
|
+
}
|
|
40791
|
+
}
|
|
40792
|
+
return null;
|
|
40793
|
+
}
|
|
40794
|
+
function cellUnderMouse(view, event) {
|
|
40795
|
+
const mousePos = view.posAtCoords({
|
|
40796
|
+
left: event.clientX,
|
|
40797
|
+
top: event.clientY
|
|
40798
|
+
});
|
|
40799
|
+
if (!mousePos)
|
|
40800
|
+
return null;
|
|
40801
|
+
return mousePos ? cellAround(view.state.doc.resolve(mousePos.pos)) : null;
|
|
40802
|
+
}
|
|
40803
|
+
var TableView$1 = class TableView2 {
|
|
40804
|
+
constructor(node, cellMinWidth) {
|
|
40805
|
+
this.node = node;
|
|
40806
|
+
this.cellMinWidth = cellMinWidth;
|
|
40807
|
+
this.dom = document.createElement("div");
|
|
40808
|
+
this.dom.className = "tableWrapper";
|
|
40809
|
+
this.table = this.dom.appendChild(document.createElement("table"));
|
|
40810
|
+
this.colgroup = this.table.appendChild(document.createElement("colgroup"));
|
|
40811
|
+
updateColumnsOnResize(node, this.colgroup, this.table, cellMinWidth);
|
|
40812
|
+
this.contentDOM = this.table.appendChild(document.createElement("tbody"));
|
|
40813
|
+
}
|
|
40814
|
+
update(node) {
|
|
40815
|
+
if (node.type != this.node.type)
|
|
40816
|
+
return false;
|
|
40817
|
+
this.node = node;
|
|
40818
|
+
updateColumnsOnResize(node, this.colgroup, this.table, this.cellMinWidth);
|
|
40819
|
+
return true;
|
|
40820
|
+
}
|
|
40821
|
+
ignoreMutation(record) {
|
|
40822
|
+
return record.type == "attributes" && (record.target == this.table || this.colgroup.contains(record.target));
|
|
40823
|
+
}
|
|
40824
|
+
};
|
|
40825
|
+
function updateColumnsOnResize(node, colgroup, table, cellMinWidth, overrideCol, overrideValue) {
|
|
40826
|
+
var _a2;
|
|
40827
|
+
let totalWidth = 0;
|
|
40828
|
+
let fixedWidth = true;
|
|
40829
|
+
let nextDOM = colgroup.firstChild;
|
|
40830
|
+
const row = node.firstChild;
|
|
40831
|
+
if (!row)
|
|
40832
|
+
return;
|
|
40833
|
+
for (let i2 = 0, col = 0; i2 < row.childCount; i2++) {
|
|
40834
|
+
const { colspan, colwidth } = row.child(i2).attrs;
|
|
40835
|
+
for (let j = 0; j < colspan; j++, col++) {
|
|
40836
|
+
const hasWidth = overrideCol == col ? overrideValue : colwidth && colwidth[j];
|
|
40837
|
+
const cssWidth = hasWidth ? hasWidth + "px" : "";
|
|
40838
|
+
totalWidth += hasWidth || cellMinWidth;
|
|
40839
|
+
if (!hasWidth)
|
|
40840
|
+
fixedWidth = false;
|
|
40841
|
+
if (!nextDOM) {
|
|
40842
|
+
colgroup.appendChild(document.createElement("col")).style.width = cssWidth;
|
|
40843
|
+
} else {
|
|
40844
|
+
if (nextDOM.style.width != cssWidth)
|
|
40845
|
+
nextDOM.style.width = cssWidth;
|
|
40846
|
+
nextDOM = nextDOM.nextSibling;
|
|
40847
|
+
}
|
|
40848
|
+
}
|
|
40849
|
+
}
|
|
40850
|
+
while (nextDOM) {
|
|
40851
|
+
const after = nextDOM.nextSibling;
|
|
40852
|
+
(_a2 = nextDOM.parentNode) == null ? void 0 : _a2.removeChild(nextDOM);
|
|
40853
|
+
nextDOM = after;
|
|
40854
|
+
}
|
|
40855
|
+
if (fixedWidth) {
|
|
40856
|
+
table.style.width = totalWidth + "px";
|
|
40857
|
+
table.style.minWidth = "";
|
|
40858
|
+
} else {
|
|
40859
|
+
table.style.width = "";
|
|
40860
|
+
table.style.minWidth = totalWidth + "px";
|
|
40861
|
+
}
|
|
40862
|
+
}
|
|
40863
|
+
var columnResizingPluginKey = new PluginKey(
|
|
40864
|
+
"tableColumnResizing"
|
|
40865
|
+
);
|
|
40866
|
+
function columnResizing({
|
|
40867
|
+
handleWidth = 5,
|
|
40868
|
+
cellMinWidth = 25,
|
|
40869
|
+
View = TableView$1,
|
|
40870
|
+
lastColumnResizable = true
|
|
40871
|
+
} = {}) {
|
|
40872
|
+
const plugin = new Plugin({
|
|
40873
|
+
key: columnResizingPluginKey,
|
|
40874
|
+
state: {
|
|
40875
|
+
init(_2, state2) {
|
|
40876
|
+
plugin.spec.props.nodeViews[tableNodeTypes(state2.schema).table.name] = (node, view) => new View(node, cellMinWidth, view);
|
|
40877
|
+
return new ResizeState(-1, false);
|
|
40878
|
+
},
|
|
40879
|
+
apply(tr2, prev) {
|
|
40880
|
+
return prev.apply(tr2);
|
|
40881
|
+
}
|
|
40882
|
+
},
|
|
40883
|
+
props: {
|
|
40884
|
+
attributes: (state2) => {
|
|
40885
|
+
const pluginState = columnResizingPluginKey.getState(state2);
|
|
40886
|
+
return pluginState && pluginState.activeHandle > -1 ? { class: "resize-cursor" } : {};
|
|
40887
|
+
},
|
|
40888
|
+
handleDOMEvents: {
|
|
40889
|
+
mousemove: (view, event) => {
|
|
40890
|
+
handleMouseMove(
|
|
40891
|
+
view,
|
|
40892
|
+
event,
|
|
40893
|
+
handleWidth,
|
|
40894
|
+
cellMinWidth,
|
|
40895
|
+
lastColumnResizable
|
|
40896
|
+
);
|
|
40897
|
+
},
|
|
40898
|
+
mouseleave: (view) => {
|
|
40899
|
+
handleMouseLeave(view);
|
|
40900
|
+
},
|
|
40901
|
+
mousedown: (view, event) => {
|
|
40902
|
+
handleMouseDown2(view, event, cellMinWidth);
|
|
40903
|
+
}
|
|
40904
|
+
},
|
|
40905
|
+
decorations: (state2) => {
|
|
40906
|
+
const pluginState = columnResizingPluginKey.getState(state2);
|
|
40907
|
+
if (pluginState && pluginState.activeHandle > -1) {
|
|
40908
|
+
return handleDecorations(state2, pluginState.activeHandle);
|
|
40909
|
+
}
|
|
40910
|
+
},
|
|
40911
|
+
nodeViews: {}
|
|
40912
|
+
}
|
|
40913
|
+
});
|
|
40914
|
+
return plugin;
|
|
40915
|
+
}
|
|
40916
|
+
var ResizeState = class _ResizeState {
|
|
40917
|
+
constructor(activeHandle, dragging) {
|
|
40918
|
+
this.activeHandle = activeHandle;
|
|
40919
|
+
this.dragging = dragging;
|
|
40920
|
+
}
|
|
40921
|
+
apply(tr2) {
|
|
40922
|
+
const state2 = this;
|
|
40923
|
+
const action = tr2.getMeta(columnResizingPluginKey);
|
|
40924
|
+
if (action && action.setHandle != null)
|
|
40925
|
+
return new _ResizeState(action.setHandle, false);
|
|
40926
|
+
if (action && action.setDragging !== void 0)
|
|
40927
|
+
return new _ResizeState(state2.activeHandle, action.setDragging);
|
|
40928
|
+
if (state2.activeHandle > -1 && tr2.docChanged) {
|
|
40929
|
+
let handle = tr2.mapping.map(state2.activeHandle, -1);
|
|
40930
|
+
if (!pointsAtCell(tr2.doc.resolve(handle))) {
|
|
40931
|
+
handle = -1;
|
|
40932
|
+
}
|
|
40933
|
+
return new _ResizeState(handle, state2.dragging);
|
|
40934
|
+
}
|
|
40935
|
+
return state2;
|
|
40936
|
+
}
|
|
40937
|
+
};
|
|
40938
|
+
function handleMouseMove(view, event, handleWidth, cellMinWidth, lastColumnResizable) {
|
|
40939
|
+
const pluginState = columnResizingPluginKey.getState(view.state);
|
|
40940
|
+
if (!pluginState)
|
|
40941
|
+
return;
|
|
40942
|
+
if (!pluginState.dragging) {
|
|
40943
|
+
const target = domCellAround(event.target);
|
|
40944
|
+
let cell = -1;
|
|
40945
|
+
if (target) {
|
|
40946
|
+
const { left: left2, right: right2 } = target.getBoundingClientRect();
|
|
40947
|
+
if (event.clientX - left2 <= handleWidth)
|
|
40948
|
+
cell = edgeCell(view, event, "left", handleWidth);
|
|
40949
|
+
else if (right2 - event.clientX <= handleWidth)
|
|
40950
|
+
cell = edgeCell(view, event, "right", handleWidth);
|
|
40951
|
+
}
|
|
40952
|
+
if (cell != pluginState.activeHandle) {
|
|
40953
|
+
if (!lastColumnResizable && cell !== -1) {
|
|
40954
|
+
const $cell = view.state.doc.resolve(cell);
|
|
40955
|
+
const table = $cell.node(-1);
|
|
40956
|
+
const map4 = TableMap.get(table);
|
|
40957
|
+
const tableStart = $cell.start(-1);
|
|
40958
|
+
const col = map4.colCount($cell.pos - tableStart) + $cell.nodeAfter.attrs.colspan - 1;
|
|
40959
|
+
if (col == map4.width - 1) {
|
|
40960
|
+
return;
|
|
40961
|
+
}
|
|
40962
|
+
}
|
|
40963
|
+
updateHandle(view, cell);
|
|
40964
|
+
}
|
|
40965
|
+
}
|
|
40966
|
+
}
|
|
40967
|
+
function handleMouseLeave(view) {
|
|
40968
|
+
const pluginState = columnResizingPluginKey.getState(view.state);
|
|
40969
|
+
if (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging)
|
|
40970
|
+
updateHandle(view, -1);
|
|
40971
|
+
}
|
|
40972
|
+
function handleMouseDown2(view, event, cellMinWidth) {
|
|
40973
|
+
var _a2;
|
|
40974
|
+
const win = (_a2 = view.dom.ownerDocument.defaultView) != null ? _a2 : window;
|
|
40975
|
+
const pluginState = columnResizingPluginKey.getState(view.state);
|
|
40976
|
+
if (!pluginState || pluginState.activeHandle == -1 || pluginState.dragging)
|
|
40977
|
+
return false;
|
|
40978
|
+
const cell = view.state.doc.nodeAt(pluginState.activeHandle);
|
|
40979
|
+
const width = currentColWidth(view, pluginState.activeHandle, cell.attrs);
|
|
40980
|
+
view.dispatch(
|
|
40981
|
+
view.state.tr.setMeta(columnResizingPluginKey, {
|
|
40982
|
+
setDragging: { startX: event.clientX, startWidth: width }
|
|
40983
|
+
})
|
|
40984
|
+
);
|
|
40985
|
+
function finish(event2) {
|
|
40986
|
+
win.removeEventListener("mouseup", finish);
|
|
40987
|
+
win.removeEventListener("mousemove", move);
|
|
40988
|
+
const pluginState2 = columnResizingPluginKey.getState(view.state);
|
|
40989
|
+
if (pluginState2 == null ? void 0 : pluginState2.dragging) {
|
|
40990
|
+
updateColumnWidth(
|
|
40991
|
+
view,
|
|
40992
|
+
pluginState2.activeHandle,
|
|
40993
|
+
draggedWidth(pluginState2.dragging, event2, cellMinWidth)
|
|
40994
|
+
);
|
|
40995
|
+
view.dispatch(
|
|
40996
|
+
view.state.tr.setMeta(columnResizingPluginKey, { setDragging: null })
|
|
40997
|
+
);
|
|
40998
|
+
}
|
|
40999
|
+
}
|
|
41000
|
+
function move(event2) {
|
|
41001
|
+
if (!event2.which)
|
|
41002
|
+
return finish(event2);
|
|
41003
|
+
const pluginState2 = columnResizingPluginKey.getState(view.state);
|
|
41004
|
+
if (!pluginState2)
|
|
41005
|
+
return;
|
|
41006
|
+
if (pluginState2.dragging) {
|
|
41007
|
+
const dragged = draggedWidth(pluginState2.dragging, event2, cellMinWidth);
|
|
41008
|
+
displayColumnWidth(view, pluginState2.activeHandle, dragged, cellMinWidth);
|
|
41009
|
+
}
|
|
41010
|
+
}
|
|
41011
|
+
win.addEventListener("mouseup", finish);
|
|
41012
|
+
win.addEventListener("mousemove", move);
|
|
41013
|
+
event.preventDefault();
|
|
41014
|
+
return true;
|
|
41015
|
+
}
|
|
41016
|
+
function currentColWidth(view, cellPos, { colspan, colwidth }) {
|
|
41017
|
+
const width = colwidth && colwidth[colwidth.length - 1];
|
|
41018
|
+
if (width)
|
|
41019
|
+
return width;
|
|
41020
|
+
const dom = view.domAtPos(cellPos);
|
|
41021
|
+
const node = dom.node.childNodes[dom.offset];
|
|
41022
|
+
let domWidth = node.offsetWidth, parts = colspan;
|
|
41023
|
+
if (colwidth) {
|
|
41024
|
+
for (let i2 = 0; i2 < colspan; i2++)
|
|
41025
|
+
if (colwidth[i2]) {
|
|
41026
|
+
domWidth -= colwidth[i2];
|
|
41027
|
+
parts--;
|
|
41028
|
+
}
|
|
41029
|
+
}
|
|
41030
|
+
return domWidth / parts;
|
|
41031
|
+
}
|
|
41032
|
+
function domCellAround(target) {
|
|
41033
|
+
while (target && target.nodeName != "TD" && target.nodeName != "TH")
|
|
41034
|
+
target = target.classList && target.classList.contains("ProseMirror") ? null : target.parentNode;
|
|
41035
|
+
return target;
|
|
41036
|
+
}
|
|
41037
|
+
function edgeCell(view, event, side, handleWidth) {
|
|
41038
|
+
const offset2 = side == "right" ? -handleWidth : handleWidth;
|
|
41039
|
+
const found2 = view.posAtCoords({
|
|
41040
|
+
left: event.clientX + offset2,
|
|
41041
|
+
top: event.clientY
|
|
41042
|
+
});
|
|
41043
|
+
if (!found2)
|
|
41044
|
+
return -1;
|
|
41045
|
+
const { pos } = found2;
|
|
41046
|
+
const $cell = cellAround(view.state.doc.resolve(pos));
|
|
41047
|
+
if (!$cell)
|
|
41048
|
+
return -1;
|
|
41049
|
+
if (side == "right")
|
|
41050
|
+
return $cell.pos;
|
|
41051
|
+
const map4 = TableMap.get($cell.node(-1)), start2 = $cell.start(-1);
|
|
41052
|
+
const index2 = map4.map.indexOf($cell.pos - start2);
|
|
41053
|
+
return index2 % map4.width == 0 ? -1 : start2 + map4.map[index2 - 1];
|
|
41054
|
+
}
|
|
41055
|
+
function draggedWidth(dragging, event, cellMinWidth) {
|
|
41056
|
+
const offset2 = event.clientX - dragging.startX;
|
|
41057
|
+
return Math.max(cellMinWidth, dragging.startWidth + offset2);
|
|
41058
|
+
}
|
|
41059
|
+
function updateHandle(view, value) {
|
|
41060
|
+
view.dispatch(
|
|
41061
|
+
view.state.tr.setMeta(columnResizingPluginKey, { setHandle: value })
|
|
41062
|
+
);
|
|
41063
|
+
}
|
|
41064
|
+
function updateColumnWidth(view, cell, width) {
|
|
41065
|
+
const $cell = view.state.doc.resolve(cell);
|
|
41066
|
+
const table = $cell.node(-1), map4 = TableMap.get(table), start2 = $cell.start(-1);
|
|
41067
|
+
const col = map4.colCount($cell.pos - start2) + $cell.nodeAfter.attrs.colspan - 1;
|
|
41068
|
+
const tr2 = view.state.tr;
|
|
41069
|
+
for (let row = 0; row < map4.height; row++) {
|
|
41070
|
+
const mapIndex = row * map4.width + col;
|
|
41071
|
+
if (row && map4.map[mapIndex] == map4.map[mapIndex - map4.width])
|
|
41072
|
+
continue;
|
|
41073
|
+
const pos = map4.map[mapIndex];
|
|
41074
|
+
const attrs = table.nodeAt(pos).attrs;
|
|
41075
|
+
const index2 = attrs.colspan == 1 ? 0 : col - map4.colCount(pos);
|
|
41076
|
+
if (attrs.colwidth && attrs.colwidth[index2] == width)
|
|
41077
|
+
continue;
|
|
41078
|
+
const colwidth = attrs.colwidth ? attrs.colwidth.slice() : zeroes(attrs.colspan);
|
|
41079
|
+
colwidth[index2] = width;
|
|
41080
|
+
tr2.setNodeMarkup(start2 + pos, null, { ...attrs, colwidth });
|
|
41081
|
+
}
|
|
41082
|
+
if (tr2.docChanged)
|
|
41083
|
+
view.dispatch(tr2);
|
|
41084
|
+
}
|
|
41085
|
+
function displayColumnWidth(view, cell, width, cellMinWidth) {
|
|
41086
|
+
const $cell = view.state.doc.resolve(cell);
|
|
41087
|
+
const table = $cell.node(-1), start2 = $cell.start(-1);
|
|
41088
|
+
const col = TableMap.get(table).colCount($cell.pos - start2) + $cell.nodeAfter.attrs.colspan - 1;
|
|
41089
|
+
let dom = view.domAtPos($cell.start(-1)).node;
|
|
41090
|
+
while (dom && dom.nodeName != "TABLE") {
|
|
41091
|
+
dom = dom.parentNode;
|
|
41092
|
+
}
|
|
41093
|
+
if (!dom)
|
|
41094
|
+
return;
|
|
41095
|
+
updateColumnsOnResize(
|
|
41096
|
+
table,
|
|
41097
|
+
dom.firstChild,
|
|
41098
|
+
dom,
|
|
41099
|
+
cellMinWidth,
|
|
41100
|
+
col,
|
|
41101
|
+
width
|
|
41102
|
+
);
|
|
41103
|
+
}
|
|
41104
|
+
function zeroes(n2) {
|
|
41105
|
+
return Array(n2).fill(0);
|
|
41106
|
+
}
|
|
41107
|
+
function handleDecorations(state2, cell) {
|
|
41108
|
+
const decorations = [];
|
|
41109
|
+
const $cell = state2.doc.resolve(cell);
|
|
41110
|
+
const table = $cell.node(-1);
|
|
41111
|
+
if (!table) {
|
|
41112
|
+
return DecorationSet.empty;
|
|
41113
|
+
}
|
|
41114
|
+
const map4 = TableMap.get(table);
|
|
41115
|
+
const start2 = $cell.start(-1);
|
|
41116
|
+
const col = map4.colCount($cell.pos - start2) + $cell.nodeAfter.attrs.colspan;
|
|
41117
|
+
for (let row = 0; row < map4.height; row++) {
|
|
41118
|
+
const index2 = col + row * map4.width - 1;
|
|
41119
|
+
if ((col == map4.width || map4.map[index2] != map4.map[index2 + 1]) && (row == 0 || map4.map[index2] != map4.map[index2 - map4.width])) {
|
|
41120
|
+
const cellPos = map4.map[index2];
|
|
41121
|
+
const pos = start2 + cellPos + table.nodeAt(cellPos).nodeSize - 1;
|
|
41122
|
+
const dom = document.createElement("div");
|
|
41123
|
+
dom.className = "column-resize-handle";
|
|
41124
|
+
decorations.push(Decoration.widget(pos, dom));
|
|
41125
|
+
}
|
|
41126
|
+
}
|
|
41127
|
+
return DecorationSet.create(state2.doc, decorations);
|
|
41128
|
+
}
|
|
41129
|
+
function selectedRect(state2) {
|
|
41130
|
+
const sel = state2.selection;
|
|
41131
|
+
const $pos = selectionCell(state2);
|
|
41132
|
+
const table = $pos.node(-1);
|
|
41133
|
+
const tableStart = $pos.start(-1);
|
|
41134
|
+
const map4 = TableMap.get(table);
|
|
41135
|
+
const rect = sel instanceof CellSelection ? map4.rectBetween(
|
|
41136
|
+
sel.$anchorCell.pos - tableStart,
|
|
41137
|
+
sel.$headCell.pos - tableStart
|
|
41138
|
+
) : map4.findCell($pos.pos - tableStart);
|
|
41139
|
+
return { ...rect, tableStart, map: map4, table };
|
|
41140
|
+
}
|
|
41141
|
+
function addColumn(tr2, { map: map4, tableStart, table }, col) {
|
|
41142
|
+
let refColumn = col > 0 ? -1 : 0;
|
|
41143
|
+
if (columnIsHeader(map4, table, col + refColumn)) {
|
|
41144
|
+
refColumn = col == 0 || col == map4.width ? null : 0;
|
|
41145
|
+
}
|
|
41146
|
+
for (let row = 0; row < map4.height; row++) {
|
|
41147
|
+
const index2 = row * map4.width + col;
|
|
41148
|
+
if (col > 0 && col < map4.width && map4.map[index2 - 1] == map4.map[index2]) {
|
|
41149
|
+
const pos = map4.map[index2];
|
|
41150
|
+
const cell = table.nodeAt(pos);
|
|
41151
|
+
tr2.setNodeMarkup(
|
|
41152
|
+
tr2.mapping.map(tableStart + pos),
|
|
41153
|
+
null,
|
|
41154
|
+
addColSpan(cell.attrs, col - map4.colCount(pos))
|
|
41155
|
+
);
|
|
41156
|
+
row += cell.attrs.rowspan - 1;
|
|
41157
|
+
} else {
|
|
41158
|
+
const type3 = refColumn == null ? tableNodeTypes(table.type.schema).cell : table.nodeAt(map4.map[index2 + refColumn]).type;
|
|
41159
|
+
const pos = map4.positionAt(row, col, table);
|
|
41160
|
+
tr2.insert(tr2.mapping.map(tableStart + pos), type3.createAndFill());
|
|
41161
|
+
}
|
|
41162
|
+
}
|
|
41163
|
+
return tr2;
|
|
41164
|
+
}
|
|
41165
|
+
function addColumnBefore(state2, dispatch) {
|
|
41166
|
+
if (!isInTable(state2))
|
|
41167
|
+
return false;
|
|
41168
|
+
if (dispatch) {
|
|
41169
|
+
const rect = selectedRect(state2);
|
|
41170
|
+
dispatch(addColumn(state2.tr, rect, rect.left));
|
|
41171
|
+
}
|
|
41172
|
+
return true;
|
|
41173
|
+
}
|
|
41174
|
+
function addColumnAfter(state2, dispatch) {
|
|
41175
|
+
if (!isInTable(state2))
|
|
41176
|
+
return false;
|
|
41177
|
+
if (dispatch) {
|
|
41178
|
+
const rect = selectedRect(state2);
|
|
41179
|
+
dispatch(addColumn(state2.tr, rect, rect.right));
|
|
41180
|
+
}
|
|
41181
|
+
return true;
|
|
41182
|
+
}
|
|
41183
|
+
function removeColumn(tr2, { map: map4, table, tableStart }, col) {
|
|
41184
|
+
const mapStart = tr2.mapping.maps.length;
|
|
41185
|
+
for (let row = 0; row < map4.height; ) {
|
|
41186
|
+
const index2 = row * map4.width + col;
|
|
41187
|
+
const pos = map4.map[index2];
|
|
41188
|
+
const cell = table.nodeAt(pos);
|
|
41189
|
+
const attrs = cell.attrs;
|
|
41190
|
+
if (col > 0 && map4.map[index2 - 1] == pos || col < map4.width - 1 && map4.map[index2 + 1] == pos) {
|
|
41191
|
+
tr2.setNodeMarkup(
|
|
41192
|
+
tr2.mapping.slice(mapStart).map(tableStart + pos),
|
|
41193
|
+
null,
|
|
41194
|
+
removeColSpan(attrs, col - map4.colCount(pos))
|
|
41195
|
+
);
|
|
41196
|
+
} else {
|
|
41197
|
+
const start2 = tr2.mapping.slice(mapStart).map(tableStart + pos);
|
|
41198
|
+
tr2.delete(start2, start2 + cell.nodeSize);
|
|
41199
|
+
}
|
|
41200
|
+
row += attrs.rowspan;
|
|
41201
|
+
}
|
|
41202
|
+
}
|
|
41203
|
+
function deleteColumn(state2, dispatch) {
|
|
41204
|
+
if (!isInTable(state2))
|
|
41205
|
+
return false;
|
|
41206
|
+
if (dispatch) {
|
|
41207
|
+
const rect = selectedRect(state2);
|
|
41208
|
+
const tr2 = state2.tr;
|
|
41209
|
+
if (rect.left == 0 && rect.right == rect.map.width)
|
|
41210
|
+
return false;
|
|
41211
|
+
for (let i2 = rect.right - 1; ; i2--) {
|
|
41212
|
+
removeColumn(tr2, rect, i2);
|
|
41213
|
+
if (i2 == rect.left)
|
|
41214
|
+
break;
|
|
41215
|
+
const table = rect.tableStart ? tr2.doc.nodeAt(rect.tableStart - 1) : tr2.doc;
|
|
41216
|
+
if (!table) {
|
|
41217
|
+
throw RangeError("No table found");
|
|
41218
|
+
}
|
|
41219
|
+
rect.table = table;
|
|
41220
|
+
rect.map = TableMap.get(table);
|
|
41221
|
+
}
|
|
41222
|
+
dispatch(tr2);
|
|
41223
|
+
}
|
|
41224
|
+
return true;
|
|
41225
|
+
}
|
|
41226
|
+
function rowIsHeader(map4, table, row) {
|
|
41227
|
+
var _a2;
|
|
41228
|
+
const headerCell = tableNodeTypes(table.type.schema).header_cell;
|
|
41229
|
+
for (let col = 0; col < map4.width; col++)
|
|
41230
|
+
if (((_a2 = table.nodeAt(map4.map[col + row * map4.width])) == null ? void 0 : _a2.type) != headerCell)
|
|
41231
|
+
return false;
|
|
41232
|
+
return true;
|
|
41233
|
+
}
|
|
41234
|
+
function addRow(tr2, { map: map4, tableStart, table }, row) {
|
|
41235
|
+
var _a2;
|
|
41236
|
+
let rowPos = tableStart;
|
|
41237
|
+
for (let i2 = 0; i2 < row; i2++)
|
|
41238
|
+
rowPos += table.child(i2).nodeSize;
|
|
41239
|
+
const cells = [];
|
|
41240
|
+
let refRow = row > 0 ? -1 : 0;
|
|
41241
|
+
if (rowIsHeader(map4, table, row + refRow))
|
|
41242
|
+
refRow = row == 0 || row == map4.height ? null : 0;
|
|
41243
|
+
for (let col = 0, index2 = map4.width * row; col < map4.width; col++, index2++) {
|
|
41244
|
+
if (row > 0 && row < map4.height && map4.map[index2] == map4.map[index2 - map4.width]) {
|
|
41245
|
+
const pos = map4.map[index2];
|
|
41246
|
+
const attrs = table.nodeAt(pos).attrs;
|
|
41247
|
+
tr2.setNodeMarkup(tableStart + pos, null, {
|
|
41248
|
+
...attrs,
|
|
41249
|
+
rowspan: attrs.rowspan + 1
|
|
41250
|
+
});
|
|
41251
|
+
col += attrs.colspan - 1;
|
|
41252
|
+
} else {
|
|
41253
|
+
const type3 = refRow == null ? tableNodeTypes(table.type.schema).cell : (_a2 = table.nodeAt(map4.map[index2 + refRow * map4.width])) == null ? void 0 : _a2.type;
|
|
41254
|
+
const node = type3 == null ? void 0 : type3.createAndFill();
|
|
41255
|
+
if (node)
|
|
41256
|
+
cells.push(node);
|
|
41257
|
+
}
|
|
41258
|
+
}
|
|
41259
|
+
tr2.insert(rowPos, tableNodeTypes(table.type.schema).row.create(null, cells));
|
|
41260
|
+
return tr2;
|
|
41261
|
+
}
|
|
41262
|
+
function addRowBefore(state2, dispatch) {
|
|
41263
|
+
if (!isInTable(state2))
|
|
41264
|
+
return false;
|
|
41265
|
+
if (dispatch) {
|
|
41266
|
+
const rect = selectedRect(state2);
|
|
41267
|
+
dispatch(addRow(state2.tr, rect, rect.top));
|
|
41268
|
+
}
|
|
41269
|
+
return true;
|
|
41270
|
+
}
|
|
41271
|
+
function addRowAfter(state2, dispatch) {
|
|
41272
|
+
if (!isInTable(state2))
|
|
41273
|
+
return false;
|
|
41274
|
+
if (dispatch) {
|
|
41275
|
+
const rect = selectedRect(state2);
|
|
41276
|
+
dispatch(addRow(state2.tr, rect, rect.bottom));
|
|
41277
|
+
}
|
|
41278
|
+
return true;
|
|
41279
|
+
}
|
|
41280
|
+
function removeRow(tr2, { map: map4, table, tableStart }, row) {
|
|
41281
|
+
let rowPos = 0;
|
|
41282
|
+
for (let i2 = 0; i2 < row; i2++)
|
|
41283
|
+
rowPos += table.child(i2).nodeSize;
|
|
41284
|
+
const nextRow = rowPos + table.child(row).nodeSize;
|
|
41285
|
+
const mapFrom = tr2.mapping.maps.length;
|
|
41286
|
+
tr2.delete(rowPos + tableStart, nextRow + tableStart);
|
|
41287
|
+
const seen = /* @__PURE__ */ new Set();
|
|
41288
|
+
for (let col = 0, index2 = row * map4.width; col < map4.width; col++, index2++) {
|
|
41289
|
+
const pos = map4.map[index2];
|
|
41290
|
+
if (seen.has(pos))
|
|
41291
|
+
continue;
|
|
41292
|
+
seen.add(pos);
|
|
41293
|
+
if (row > 0 && pos == map4.map[index2 - map4.width]) {
|
|
41294
|
+
const attrs = table.nodeAt(pos).attrs;
|
|
41295
|
+
tr2.setNodeMarkup(tr2.mapping.slice(mapFrom).map(pos + tableStart), null, {
|
|
41296
|
+
...attrs,
|
|
41297
|
+
rowspan: attrs.rowspan - 1
|
|
41298
|
+
});
|
|
41299
|
+
col += attrs.colspan - 1;
|
|
41300
|
+
} else if (row < map4.height && pos == map4.map[index2 + map4.width]) {
|
|
41301
|
+
const cell = table.nodeAt(pos);
|
|
41302
|
+
const attrs = cell.attrs;
|
|
41303
|
+
const copy2 = cell.type.create(
|
|
41304
|
+
{ ...attrs, rowspan: cell.attrs.rowspan - 1 },
|
|
41305
|
+
cell.content
|
|
41306
|
+
);
|
|
41307
|
+
const newPos = map4.positionAt(row + 1, col, table);
|
|
41308
|
+
tr2.insert(tr2.mapping.slice(mapFrom).map(tableStart + newPos), copy2);
|
|
41309
|
+
col += attrs.colspan - 1;
|
|
41310
|
+
}
|
|
41311
|
+
}
|
|
41312
|
+
}
|
|
41313
|
+
function deleteRow(state2, dispatch) {
|
|
41314
|
+
if (!isInTable(state2))
|
|
41315
|
+
return false;
|
|
41316
|
+
if (dispatch) {
|
|
41317
|
+
const rect = selectedRect(state2), tr2 = state2.tr;
|
|
41318
|
+
if (rect.top == 0 && rect.bottom == rect.map.height)
|
|
41319
|
+
return false;
|
|
41320
|
+
for (let i2 = rect.bottom - 1; ; i2--) {
|
|
41321
|
+
removeRow(tr2, rect, i2);
|
|
41322
|
+
if (i2 == rect.top)
|
|
41323
|
+
break;
|
|
41324
|
+
const table = rect.tableStart ? tr2.doc.nodeAt(rect.tableStart - 1) : tr2.doc;
|
|
41325
|
+
if (!table) {
|
|
41326
|
+
throw RangeError("No table found");
|
|
41327
|
+
}
|
|
41328
|
+
rect.table = table;
|
|
41329
|
+
rect.map = TableMap.get(rect.table);
|
|
41330
|
+
}
|
|
41331
|
+
dispatch(tr2);
|
|
41332
|
+
}
|
|
41333
|
+
return true;
|
|
41334
|
+
}
|
|
41335
|
+
function isEmpty(cell) {
|
|
41336
|
+
const c2 = cell.content;
|
|
41337
|
+
return c2.childCount == 1 && c2.child(0).isTextblock && c2.child(0).childCount == 0;
|
|
41338
|
+
}
|
|
41339
|
+
function cellsOverlapRectangle({ width, height, map: map4 }, rect) {
|
|
41340
|
+
let indexTop = rect.top * width + rect.left, indexLeft = indexTop;
|
|
41341
|
+
let indexBottom = (rect.bottom - 1) * width + rect.left, indexRight = indexTop + (rect.right - rect.left - 1);
|
|
41342
|
+
for (let i2 = rect.top; i2 < rect.bottom; i2++) {
|
|
41343
|
+
if (rect.left > 0 && map4[indexLeft] == map4[indexLeft - 1] || rect.right < width && map4[indexRight] == map4[indexRight + 1])
|
|
41344
|
+
return true;
|
|
41345
|
+
indexLeft += width;
|
|
41346
|
+
indexRight += width;
|
|
41347
|
+
}
|
|
41348
|
+
for (let i2 = rect.left; i2 < rect.right; i2++) {
|
|
41349
|
+
if (rect.top > 0 && map4[indexTop] == map4[indexTop - width] || rect.bottom < height && map4[indexBottom] == map4[indexBottom + width])
|
|
41350
|
+
return true;
|
|
41351
|
+
indexTop++;
|
|
41352
|
+
indexBottom++;
|
|
41353
|
+
}
|
|
41354
|
+
return false;
|
|
41355
|
+
}
|
|
41356
|
+
function mergeCells(state2, dispatch) {
|
|
41357
|
+
const sel = state2.selection;
|
|
41358
|
+
if (!(sel instanceof CellSelection) || sel.$anchorCell.pos == sel.$headCell.pos)
|
|
41359
|
+
return false;
|
|
41360
|
+
const rect = selectedRect(state2), { map: map4 } = rect;
|
|
41361
|
+
if (cellsOverlapRectangle(map4, rect))
|
|
41362
|
+
return false;
|
|
41363
|
+
if (dispatch) {
|
|
41364
|
+
const tr2 = state2.tr;
|
|
41365
|
+
const seen = {};
|
|
41366
|
+
let content = Fragment.empty;
|
|
41367
|
+
let mergedPos;
|
|
41368
|
+
let mergedCell;
|
|
41369
|
+
for (let row = rect.top; row < rect.bottom; row++) {
|
|
41370
|
+
for (let col = rect.left; col < rect.right; col++) {
|
|
41371
|
+
const cellPos = map4.map[row * map4.width + col];
|
|
41372
|
+
const cell = rect.table.nodeAt(cellPos);
|
|
41373
|
+
if (seen[cellPos] || !cell)
|
|
41374
|
+
continue;
|
|
41375
|
+
seen[cellPos] = true;
|
|
41376
|
+
if (mergedPos == null) {
|
|
41377
|
+
mergedPos = cellPos;
|
|
41378
|
+
mergedCell = cell;
|
|
41379
|
+
} else {
|
|
41380
|
+
if (!isEmpty(cell))
|
|
41381
|
+
content = content.append(cell.content);
|
|
41382
|
+
const mapped = tr2.mapping.map(cellPos + rect.tableStart);
|
|
41383
|
+
tr2.delete(mapped, mapped + cell.nodeSize);
|
|
41384
|
+
}
|
|
41385
|
+
}
|
|
41386
|
+
}
|
|
41387
|
+
if (mergedPos == null || mergedCell == null) {
|
|
41388
|
+
return true;
|
|
41389
|
+
}
|
|
41390
|
+
tr2.setNodeMarkup(mergedPos + rect.tableStart, null, {
|
|
41391
|
+
...addColSpan(
|
|
41392
|
+
mergedCell.attrs,
|
|
41393
|
+
mergedCell.attrs.colspan,
|
|
41394
|
+
rect.right - rect.left - mergedCell.attrs.colspan
|
|
41395
|
+
),
|
|
41396
|
+
rowspan: rect.bottom - rect.top
|
|
41397
|
+
});
|
|
41398
|
+
if (content.size) {
|
|
41399
|
+
const end2 = mergedPos + 1 + mergedCell.content.size;
|
|
41400
|
+
const start2 = isEmpty(mergedCell) ? mergedPos + 1 : end2;
|
|
41401
|
+
tr2.replaceWith(start2 + rect.tableStart, end2 + rect.tableStart, content);
|
|
41402
|
+
}
|
|
41403
|
+
tr2.setSelection(
|
|
41404
|
+
new CellSelection(tr2.doc.resolve(mergedPos + rect.tableStart))
|
|
41405
|
+
);
|
|
41406
|
+
dispatch(tr2);
|
|
41407
|
+
}
|
|
41408
|
+
return true;
|
|
41409
|
+
}
|
|
41410
|
+
function splitCell(state2, dispatch) {
|
|
41411
|
+
const nodeTypes = tableNodeTypes(state2.schema);
|
|
41412
|
+
return splitCellWithType(({ node }) => {
|
|
41413
|
+
return nodeTypes[node.type.spec.tableRole];
|
|
41414
|
+
})(state2, dispatch);
|
|
41415
|
+
}
|
|
41416
|
+
function splitCellWithType(getCellType) {
|
|
41417
|
+
return (state2, dispatch) => {
|
|
41418
|
+
var _a2;
|
|
41419
|
+
const sel = state2.selection;
|
|
41420
|
+
let cellNode;
|
|
41421
|
+
let cellPos;
|
|
41422
|
+
if (!(sel instanceof CellSelection)) {
|
|
41423
|
+
cellNode = cellWrapping(sel.$from);
|
|
41424
|
+
if (!cellNode)
|
|
41425
|
+
return false;
|
|
41426
|
+
cellPos = (_a2 = cellAround(sel.$from)) == null ? void 0 : _a2.pos;
|
|
41427
|
+
} else {
|
|
41428
|
+
if (sel.$anchorCell.pos != sel.$headCell.pos)
|
|
41429
|
+
return false;
|
|
41430
|
+
cellNode = sel.$anchorCell.nodeAfter;
|
|
41431
|
+
cellPos = sel.$anchorCell.pos;
|
|
41432
|
+
}
|
|
41433
|
+
if (cellNode == null || cellPos == null) {
|
|
41434
|
+
return false;
|
|
41435
|
+
}
|
|
41436
|
+
if (cellNode.attrs.colspan == 1 && cellNode.attrs.rowspan == 1) {
|
|
41437
|
+
return false;
|
|
41438
|
+
}
|
|
41439
|
+
if (dispatch) {
|
|
41440
|
+
let baseAttrs = cellNode.attrs;
|
|
41441
|
+
const attrs = [];
|
|
41442
|
+
const colwidth = baseAttrs.colwidth;
|
|
41443
|
+
if (baseAttrs.rowspan > 1)
|
|
41444
|
+
baseAttrs = { ...baseAttrs, rowspan: 1 };
|
|
41445
|
+
if (baseAttrs.colspan > 1)
|
|
41446
|
+
baseAttrs = { ...baseAttrs, colspan: 1 };
|
|
41447
|
+
const rect = selectedRect(state2), tr2 = state2.tr;
|
|
41448
|
+
for (let i2 = 0; i2 < rect.right - rect.left; i2++)
|
|
41449
|
+
attrs.push(
|
|
41450
|
+
colwidth ? {
|
|
41451
|
+
...baseAttrs,
|
|
41452
|
+
colwidth: colwidth && colwidth[i2] ? [colwidth[i2]] : null
|
|
41453
|
+
} : baseAttrs
|
|
41454
|
+
);
|
|
41455
|
+
let lastCell;
|
|
41456
|
+
for (let row = rect.top; row < rect.bottom; row++) {
|
|
41457
|
+
let pos = rect.map.positionAt(row, rect.left, rect.table);
|
|
41458
|
+
if (row == rect.top)
|
|
41459
|
+
pos += cellNode.nodeSize;
|
|
41460
|
+
for (let col = rect.left, i2 = 0; col < rect.right; col++, i2++) {
|
|
41461
|
+
if (col == rect.left && row == rect.top)
|
|
41462
|
+
continue;
|
|
41463
|
+
tr2.insert(
|
|
41464
|
+
lastCell = tr2.mapping.map(pos + rect.tableStart, 1),
|
|
41465
|
+
getCellType({ node: cellNode, row, col }).createAndFill(attrs[i2])
|
|
41466
|
+
);
|
|
41467
|
+
}
|
|
41468
|
+
}
|
|
41469
|
+
tr2.setNodeMarkup(
|
|
41470
|
+
cellPos,
|
|
41471
|
+
getCellType({ node: cellNode, row: rect.top, col: rect.left }),
|
|
41472
|
+
attrs[0]
|
|
41473
|
+
);
|
|
41474
|
+
if (sel instanceof CellSelection)
|
|
41475
|
+
tr2.setSelection(
|
|
41476
|
+
new CellSelection(
|
|
41477
|
+
tr2.doc.resolve(sel.$anchorCell.pos),
|
|
41478
|
+
lastCell ? tr2.doc.resolve(lastCell) : void 0
|
|
41479
|
+
)
|
|
41480
|
+
);
|
|
41481
|
+
dispatch(tr2);
|
|
41482
|
+
}
|
|
41483
|
+
return true;
|
|
41484
|
+
};
|
|
41485
|
+
}
|
|
41486
|
+
function setCellAttr(name, value) {
|
|
41487
|
+
return function(state2, dispatch) {
|
|
41488
|
+
if (!isInTable(state2))
|
|
41489
|
+
return false;
|
|
41490
|
+
const $cell = selectionCell(state2);
|
|
41491
|
+
if ($cell.nodeAfter.attrs[name] === value)
|
|
41492
|
+
return false;
|
|
41493
|
+
if (dispatch) {
|
|
41494
|
+
const tr2 = state2.tr;
|
|
41495
|
+
if (state2.selection instanceof CellSelection)
|
|
41496
|
+
state2.selection.forEachCell((node, pos) => {
|
|
41497
|
+
if (node.attrs[name] !== value)
|
|
41498
|
+
tr2.setNodeMarkup(pos, null, {
|
|
41499
|
+
...node.attrs,
|
|
41500
|
+
[name]: value
|
|
41501
|
+
});
|
|
41502
|
+
});
|
|
41503
|
+
else
|
|
41504
|
+
tr2.setNodeMarkup($cell.pos, null, {
|
|
41505
|
+
...$cell.nodeAfter.attrs,
|
|
41506
|
+
[name]: value
|
|
41507
|
+
});
|
|
41508
|
+
dispatch(tr2);
|
|
41509
|
+
}
|
|
41510
|
+
return true;
|
|
41511
|
+
};
|
|
41512
|
+
}
|
|
41513
|
+
function deprecated_toggleHeader(type3) {
|
|
41514
|
+
return function(state2, dispatch) {
|
|
41515
|
+
if (!isInTable(state2))
|
|
41516
|
+
return false;
|
|
41517
|
+
if (dispatch) {
|
|
41518
|
+
const types = tableNodeTypes(state2.schema);
|
|
41519
|
+
const rect = selectedRect(state2), tr2 = state2.tr;
|
|
41520
|
+
const cells = rect.map.cellsInRect(
|
|
41521
|
+
type3 == "column" ? {
|
|
41522
|
+
left: rect.left,
|
|
41523
|
+
top: 0,
|
|
41524
|
+
right: rect.right,
|
|
41525
|
+
bottom: rect.map.height
|
|
41526
|
+
} : type3 == "row" ? {
|
|
41527
|
+
left: 0,
|
|
41528
|
+
top: rect.top,
|
|
41529
|
+
right: rect.map.width,
|
|
41530
|
+
bottom: rect.bottom
|
|
41531
|
+
} : rect
|
|
41532
|
+
);
|
|
41533
|
+
const nodes = cells.map((pos) => rect.table.nodeAt(pos));
|
|
41534
|
+
for (let i2 = 0; i2 < cells.length; i2++)
|
|
41535
|
+
if (nodes[i2].type == types.header_cell)
|
|
41536
|
+
tr2.setNodeMarkup(
|
|
41537
|
+
rect.tableStart + cells[i2],
|
|
41538
|
+
types.cell,
|
|
41539
|
+
nodes[i2].attrs
|
|
41540
|
+
);
|
|
41541
|
+
if (tr2.steps.length == 0)
|
|
41542
|
+
for (let i2 = 0; i2 < cells.length; i2++)
|
|
41543
|
+
tr2.setNodeMarkup(
|
|
41544
|
+
rect.tableStart + cells[i2],
|
|
41545
|
+
types.header_cell,
|
|
41546
|
+
nodes[i2].attrs
|
|
41547
|
+
);
|
|
41548
|
+
dispatch(tr2);
|
|
41549
|
+
}
|
|
41550
|
+
return true;
|
|
41551
|
+
};
|
|
41552
|
+
}
|
|
41553
|
+
function isHeaderEnabledByType(type3, rect, types) {
|
|
41554
|
+
const cellPositions = rect.map.cellsInRect({
|
|
41555
|
+
left: 0,
|
|
41556
|
+
top: 0,
|
|
41557
|
+
right: type3 == "row" ? rect.map.width : 1,
|
|
41558
|
+
bottom: type3 == "column" ? rect.map.height : 1
|
|
41559
|
+
});
|
|
41560
|
+
for (let i2 = 0; i2 < cellPositions.length; i2++) {
|
|
41561
|
+
const cell = rect.table.nodeAt(cellPositions[i2]);
|
|
41562
|
+
if (cell && cell.type !== types.header_cell) {
|
|
41563
|
+
return false;
|
|
41564
|
+
}
|
|
41565
|
+
}
|
|
41566
|
+
return true;
|
|
41567
|
+
}
|
|
41568
|
+
function toggleHeader(type3, options) {
|
|
41569
|
+
options = options || { useDeprecatedLogic: false };
|
|
41570
|
+
if (options.useDeprecatedLogic)
|
|
41571
|
+
return deprecated_toggleHeader(type3);
|
|
41572
|
+
return function(state2, dispatch) {
|
|
41573
|
+
if (!isInTable(state2))
|
|
41574
|
+
return false;
|
|
41575
|
+
if (dispatch) {
|
|
41576
|
+
const types = tableNodeTypes(state2.schema);
|
|
41577
|
+
const rect = selectedRect(state2), tr2 = state2.tr;
|
|
41578
|
+
const isHeaderRowEnabled = isHeaderEnabledByType("row", rect, types);
|
|
41579
|
+
const isHeaderColumnEnabled = isHeaderEnabledByType(
|
|
41580
|
+
"column",
|
|
41581
|
+
rect,
|
|
41582
|
+
types
|
|
41583
|
+
);
|
|
41584
|
+
const isHeaderEnabled = type3 === "column" ? isHeaderRowEnabled : type3 === "row" ? isHeaderColumnEnabled : false;
|
|
41585
|
+
const selectionStartsAt = isHeaderEnabled ? 1 : 0;
|
|
41586
|
+
const cellsRect = type3 == "column" ? {
|
|
41587
|
+
left: 0,
|
|
41588
|
+
top: selectionStartsAt,
|
|
41589
|
+
right: 1,
|
|
41590
|
+
bottom: rect.map.height
|
|
41591
|
+
} : type3 == "row" ? {
|
|
41592
|
+
left: selectionStartsAt,
|
|
41593
|
+
top: 0,
|
|
41594
|
+
right: rect.map.width,
|
|
41595
|
+
bottom: 1
|
|
41596
|
+
} : rect;
|
|
41597
|
+
const newType = type3 == "column" ? isHeaderColumnEnabled ? types.cell : types.header_cell : type3 == "row" ? isHeaderRowEnabled ? types.cell : types.header_cell : types.cell;
|
|
41598
|
+
rect.map.cellsInRect(cellsRect).forEach((relativeCellPos) => {
|
|
41599
|
+
const cellPos = relativeCellPos + rect.tableStart;
|
|
41600
|
+
const cell = tr2.doc.nodeAt(cellPos);
|
|
41601
|
+
if (cell) {
|
|
41602
|
+
tr2.setNodeMarkup(cellPos, newType, cell.attrs);
|
|
41603
|
+
}
|
|
41604
|
+
});
|
|
41605
|
+
dispatch(tr2);
|
|
41606
|
+
}
|
|
41607
|
+
return true;
|
|
41608
|
+
};
|
|
41609
|
+
}
|
|
41610
|
+
toggleHeader("row", {
|
|
41611
|
+
useDeprecatedLogic: true
|
|
41612
|
+
});
|
|
41613
|
+
toggleHeader("column", {
|
|
41614
|
+
useDeprecatedLogic: true
|
|
41615
|
+
});
|
|
41616
|
+
var toggleHeaderCell = toggleHeader("cell", {
|
|
41617
|
+
useDeprecatedLogic: true
|
|
41618
|
+
});
|
|
41619
|
+
function findNextCell($cell, dir) {
|
|
41620
|
+
if (dir < 0) {
|
|
41621
|
+
const before = $cell.nodeBefore;
|
|
41622
|
+
if (before)
|
|
41623
|
+
return $cell.pos - before.nodeSize;
|
|
41624
|
+
for (let row = $cell.index(-1) - 1, rowEnd = $cell.before(); row >= 0; row--) {
|
|
41625
|
+
const rowNode = $cell.node(-1).child(row);
|
|
41626
|
+
const lastChild2 = rowNode.lastChild;
|
|
41627
|
+
if (lastChild2) {
|
|
41628
|
+
return rowEnd - 1 - lastChild2.nodeSize;
|
|
41629
|
+
}
|
|
41630
|
+
rowEnd -= rowNode.nodeSize;
|
|
41631
|
+
}
|
|
41632
|
+
} else {
|
|
41633
|
+
if ($cell.index() < $cell.parent.childCount - 1) {
|
|
41634
|
+
return $cell.pos + $cell.nodeAfter.nodeSize;
|
|
41635
|
+
}
|
|
41636
|
+
const table = $cell.node(-1);
|
|
41637
|
+
for (let row = $cell.indexAfter(-1), rowStart = $cell.after(); row < table.childCount; row++) {
|
|
41638
|
+
const rowNode = table.child(row);
|
|
41639
|
+
if (rowNode.childCount)
|
|
41640
|
+
return rowStart + 1;
|
|
41641
|
+
rowStart += rowNode.nodeSize;
|
|
41642
|
+
}
|
|
41643
|
+
}
|
|
41644
|
+
return null;
|
|
41645
|
+
}
|
|
41646
|
+
function goToNextCell(direction) {
|
|
41647
|
+
return function(state2, dispatch) {
|
|
41648
|
+
if (!isInTable(state2))
|
|
41649
|
+
return false;
|
|
41650
|
+
const cell = findNextCell(selectionCell(state2), direction);
|
|
41651
|
+
if (cell == null)
|
|
41652
|
+
return false;
|
|
41653
|
+
if (dispatch) {
|
|
41654
|
+
const $cell = state2.doc.resolve(cell);
|
|
41655
|
+
dispatch(
|
|
41656
|
+
state2.tr.setSelection(TextSelection.between($cell, moveCellForward($cell))).scrollIntoView()
|
|
41657
|
+
);
|
|
41658
|
+
}
|
|
41659
|
+
return true;
|
|
41660
|
+
};
|
|
41661
|
+
}
|
|
41662
|
+
function deleteTable(state2, dispatch) {
|
|
41663
|
+
const $pos = state2.selection.$anchor;
|
|
41664
|
+
for (let d2 = $pos.depth; d2 > 0; d2--) {
|
|
41665
|
+
const node = $pos.node(d2);
|
|
41666
|
+
if (node.type.spec.tableRole == "table") {
|
|
41667
|
+
if (dispatch)
|
|
41668
|
+
dispatch(
|
|
41669
|
+
state2.tr.delete($pos.before(d2), $pos.after(d2)).scrollIntoView()
|
|
41670
|
+
);
|
|
41671
|
+
return true;
|
|
41672
|
+
}
|
|
41673
|
+
}
|
|
41674
|
+
return false;
|
|
41675
|
+
}
|
|
41676
|
+
function tableEditing({
|
|
41677
|
+
allowTableNodeSelection = false
|
|
41678
|
+
} = {}) {
|
|
41679
|
+
return new Plugin({
|
|
41680
|
+
key: tableEditingKey,
|
|
41681
|
+
// This piece of state is used to remember when a mouse-drag
|
|
41682
|
+
// cell-selection is happening, so that it can continue even as
|
|
41683
|
+
// transactions (which might move its anchor cell) come in.
|
|
41684
|
+
state: {
|
|
41685
|
+
init() {
|
|
41686
|
+
return null;
|
|
41687
|
+
},
|
|
41688
|
+
apply(tr2, cur) {
|
|
41689
|
+
const set2 = tr2.getMeta(tableEditingKey);
|
|
41690
|
+
if (set2 != null)
|
|
41691
|
+
return set2 == -1 ? null : set2;
|
|
41692
|
+
if (cur == null || !tr2.docChanged)
|
|
41693
|
+
return cur;
|
|
41694
|
+
const { deleted, pos } = tr2.mapping.mapResult(cur);
|
|
41695
|
+
return deleted ? null : pos;
|
|
41696
|
+
}
|
|
41697
|
+
},
|
|
41698
|
+
props: {
|
|
41699
|
+
decorations: drawCellSelection,
|
|
41700
|
+
handleDOMEvents: {
|
|
41701
|
+
mousedown: handleMouseDown
|
|
41702
|
+
},
|
|
41703
|
+
createSelectionBetween(view) {
|
|
41704
|
+
return tableEditingKey.getState(view.state) != null ? view.state.selection : null;
|
|
41705
|
+
},
|
|
41706
|
+
handleTripleClick,
|
|
41707
|
+
handleKeyDown,
|
|
41708
|
+
handlePaste
|
|
41709
|
+
},
|
|
41710
|
+
appendTransaction(_2, oldState, state2) {
|
|
41711
|
+
return normalizeSelection(
|
|
41712
|
+
state2,
|
|
41713
|
+
fixTables(state2, oldState),
|
|
41714
|
+
allowTableNodeSelection
|
|
41715
|
+
);
|
|
41716
|
+
}
|
|
41717
|
+
});
|
|
41718
|
+
}
|
|
41719
|
+
function updateColumns(node, colgroup, table, cellMinWidth, overrideCol, overrideValue) {
|
|
41720
|
+
let totalWidth = 0;
|
|
41721
|
+
let fixedWidth = true;
|
|
41722
|
+
let nextDOM = colgroup.firstChild;
|
|
41723
|
+
const row = node.firstChild;
|
|
41724
|
+
for (let i2 = 0, col = 0; i2 < row.childCount; i2 += 1) {
|
|
41725
|
+
const { colspan, colwidth } = row.child(i2).attrs;
|
|
41726
|
+
for (let j = 0; j < colspan; j += 1, col += 1) {
|
|
41727
|
+
const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j];
|
|
41728
|
+
const cssWidth = hasWidth ? `${hasWidth}px` : "";
|
|
41729
|
+
totalWidth += hasWidth || cellMinWidth;
|
|
41730
|
+
if (!hasWidth) {
|
|
41731
|
+
fixedWidth = false;
|
|
41732
|
+
}
|
|
41733
|
+
if (!nextDOM) {
|
|
41734
|
+
colgroup.appendChild(document.createElement("col")).style.width = cssWidth;
|
|
41735
|
+
} else {
|
|
41736
|
+
if (nextDOM.style.width !== cssWidth) {
|
|
41737
|
+
nextDOM.style.width = cssWidth;
|
|
41738
|
+
}
|
|
41739
|
+
nextDOM = nextDOM.nextSibling;
|
|
41740
|
+
}
|
|
41741
|
+
}
|
|
41742
|
+
}
|
|
41743
|
+
while (nextDOM) {
|
|
41744
|
+
const after = nextDOM.nextSibling;
|
|
41745
|
+
nextDOM.parentNode.removeChild(nextDOM);
|
|
41746
|
+
nextDOM = after;
|
|
41747
|
+
}
|
|
41748
|
+
if (fixedWidth) {
|
|
41749
|
+
table.style.width = `${totalWidth}px`;
|
|
41750
|
+
table.style.minWidth = "";
|
|
41751
|
+
} else {
|
|
41752
|
+
table.style.width = "";
|
|
41753
|
+
table.style.minWidth = `${totalWidth}px`;
|
|
41754
|
+
}
|
|
41755
|
+
}
|
|
41756
|
+
class TableView {
|
|
41757
|
+
constructor(node, cellMinWidth) {
|
|
41758
|
+
this.node = node;
|
|
41759
|
+
this.cellMinWidth = cellMinWidth;
|
|
41760
|
+
this.dom = document.createElement("div");
|
|
41761
|
+
this.dom.className = "tableWrapper";
|
|
41762
|
+
this.table = this.dom.appendChild(document.createElement("table"));
|
|
41763
|
+
this.colgroup = this.table.appendChild(document.createElement("colgroup"));
|
|
41764
|
+
updateColumns(node, this.colgroup, this.table, cellMinWidth);
|
|
41765
|
+
this.contentDOM = this.table.appendChild(document.createElement("tbody"));
|
|
41766
|
+
}
|
|
41767
|
+
update(node) {
|
|
41768
|
+
if (node.type !== this.node.type) {
|
|
41769
|
+
return false;
|
|
41770
|
+
}
|
|
41771
|
+
this.node = node;
|
|
41772
|
+
updateColumns(node, this.colgroup, this.table, this.cellMinWidth);
|
|
41773
|
+
return true;
|
|
41774
|
+
}
|
|
41775
|
+
ignoreMutation(mutation) {
|
|
41776
|
+
return mutation.type === "attributes" && (mutation.target === this.table || this.colgroup.contains(mutation.target));
|
|
41777
|
+
}
|
|
41778
|
+
}
|
|
41779
|
+
function createColGroup(node, cellMinWidth, overrideCol, overrideValue) {
|
|
41780
|
+
let totalWidth = 0;
|
|
41781
|
+
let fixedWidth = true;
|
|
41782
|
+
const cols = [];
|
|
41783
|
+
const row = node.firstChild;
|
|
41784
|
+
if (!row) {
|
|
41785
|
+
return {};
|
|
41786
|
+
}
|
|
41787
|
+
for (let i2 = 0, col = 0; i2 < row.childCount; i2 += 1) {
|
|
41788
|
+
const { colspan, colwidth } = row.child(i2).attrs;
|
|
41789
|
+
for (let j = 0; j < colspan; j += 1, col += 1) {
|
|
41790
|
+
const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j];
|
|
41791
|
+
const cssWidth = hasWidth ? `${hasWidth}px` : "";
|
|
41792
|
+
totalWidth += hasWidth || cellMinWidth;
|
|
41793
|
+
if (!hasWidth) {
|
|
41794
|
+
fixedWidth = false;
|
|
41795
|
+
}
|
|
41796
|
+
cols.push(["col", cssWidth ? { style: `width: ${cssWidth}` } : {}]);
|
|
41797
|
+
}
|
|
41798
|
+
}
|
|
41799
|
+
const tableWidth = fixedWidth ? `${totalWidth}px` : "";
|
|
41800
|
+
const tableMinWidth = fixedWidth ? "" : `${totalWidth}px`;
|
|
41801
|
+
const colgroup = ["colgroup", {}, ...cols];
|
|
41802
|
+
return { colgroup, tableWidth, tableMinWidth };
|
|
41803
|
+
}
|
|
41804
|
+
function createCell(cellType, cellContent) {
|
|
41805
|
+
if (cellContent) {
|
|
41806
|
+
return cellType.createChecked(null, cellContent);
|
|
41807
|
+
}
|
|
41808
|
+
return cellType.createAndFill();
|
|
41809
|
+
}
|
|
41810
|
+
function getTableNodeTypes(schema) {
|
|
41811
|
+
if (schema.cached.tableNodeTypes) {
|
|
41812
|
+
return schema.cached.tableNodeTypes;
|
|
41813
|
+
}
|
|
41814
|
+
const roles = {};
|
|
41815
|
+
Object.keys(schema.nodes).forEach((type3) => {
|
|
41816
|
+
const nodeType = schema.nodes[type3];
|
|
41817
|
+
if (nodeType.spec.tableRole) {
|
|
41818
|
+
roles[nodeType.spec.tableRole] = nodeType;
|
|
41819
|
+
}
|
|
41820
|
+
});
|
|
41821
|
+
schema.cached.tableNodeTypes = roles;
|
|
41822
|
+
return roles;
|
|
41823
|
+
}
|
|
41824
|
+
function createTable(schema, rowsCount, colsCount, withHeaderRow, cellContent) {
|
|
41825
|
+
const types = getTableNodeTypes(schema);
|
|
41826
|
+
const headerCells = [];
|
|
41827
|
+
const cells = [];
|
|
41828
|
+
for (let index2 = 0; index2 < colsCount; index2 += 1) {
|
|
41829
|
+
const cell = createCell(types.cell, cellContent);
|
|
41830
|
+
if (cell) {
|
|
41831
|
+
cells.push(cell);
|
|
41832
|
+
}
|
|
41833
|
+
if (withHeaderRow) {
|
|
41834
|
+
const headerCell = createCell(types.header_cell, cellContent);
|
|
41835
|
+
if (headerCell) {
|
|
41836
|
+
headerCells.push(headerCell);
|
|
41837
|
+
}
|
|
41838
|
+
}
|
|
41839
|
+
}
|
|
41840
|
+
const rows = [];
|
|
41841
|
+
for (let index2 = 0; index2 < rowsCount; index2 += 1) {
|
|
41842
|
+
rows.push(types.row.createChecked(null, withHeaderRow && index2 === 0 ? headerCells : cells));
|
|
41843
|
+
}
|
|
41844
|
+
return types.table.createChecked(null, rows);
|
|
41845
|
+
}
|
|
41846
|
+
function isCellSelection(value) {
|
|
41847
|
+
return value instanceof CellSelection;
|
|
41848
|
+
}
|
|
41849
|
+
const deleteTableWhenAllCellsSelected = ({ editor }) => {
|
|
41850
|
+
const { selection } = editor.state;
|
|
41851
|
+
if (!isCellSelection(selection)) {
|
|
41852
|
+
return false;
|
|
41853
|
+
}
|
|
41854
|
+
let cellCount = 0;
|
|
41855
|
+
const table = findParentNodeClosestToPos(selection.ranges[0].$from, (node) => {
|
|
41856
|
+
return node.type.name === "table";
|
|
41857
|
+
});
|
|
41858
|
+
table === null || table === void 0 ? void 0 : table.node.descendants((node) => {
|
|
41859
|
+
if (node.type.name === "table") {
|
|
41860
|
+
return false;
|
|
41861
|
+
}
|
|
41862
|
+
if (["tableCell", "tableHeader"].includes(node.type.name)) {
|
|
41863
|
+
cellCount += 1;
|
|
41864
|
+
}
|
|
41865
|
+
});
|
|
41866
|
+
const allCellsSelected = cellCount === selection.ranges.length;
|
|
41867
|
+
if (!allCellsSelected) {
|
|
41868
|
+
return false;
|
|
41869
|
+
}
|
|
41870
|
+
editor.commands.deleteTable();
|
|
41871
|
+
return true;
|
|
41872
|
+
};
|
|
41873
|
+
const Table = Node$2.create({
|
|
41874
|
+
name: "table",
|
|
41875
|
+
// @ts-ignore
|
|
41876
|
+
addOptions() {
|
|
41877
|
+
return {
|
|
41878
|
+
HTMLAttributes: {},
|
|
41879
|
+
resizable: false,
|
|
41880
|
+
handleWidth: 5,
|
|
41881
|
+
cellMinWidth: 25,
|
|
41882
|
+
// TODO: fix
|
|
41883
|
+
View: TableView,
|
|
41884
|
+
lastColumnResizable: true,
|
|
41885
|
+
allowTableNodeSelection: false
|
|
41886
|
+
};
|
|
41887
|
+
},
|
|
41888
|
+
content: "tableRow+",
|
|
41889
|
+
tableRole: "table",
|
|
41890
|
+
isolating: true,
|
|
41891
|
+
group: "block",
|
|
41892
|
+
parseHTML() {
|
|
41893
|
+
return [{ tag: "table" }];
|
|
41894
|
+
},
|
|
41895
|
+
renderHTML({ node, HTMLAttributes }) {
|
|
41896
|
+
const { colgroup, tableWidth, tableMinWidth } = createColGroup(node, this.options.cellMinWidth);
|
|
41897
|
+
const table = [
|
|
41898
|
+
"table",
|
|
41899
|
+
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
|
|
41900
|
+
style: tableWidth ? `width: ${tableWidth}` : `minWidth: ${tableMinWidth}`
|
|
41901
|
+
}),
|
|
41902
|
+
colgroup,
|
|
41903
|
+
["tbody", 0]
|
|
41904
|
+
];
|
|
41905
|
+
return table;
|
|
41906
|
+
},
|
|
41907
|
+
addCommands() {
|
|
41908
|
+
return {
|
|
41909
|
+
insertTable: ({ rows = 3, cols = 3, withHeaderRow = true } = {}) => ({ tr: tr2, dispatch, editor }) => {
|
|
41910
|
+
const node = createTable(editor.schema, rows, cols, withHeaderRow);
|
|
41911
|
+
if (dispatch) {
|
|
41912
|
+
const offset2 = tr2.selection.anchor + 1;
|
|
41913
|
+
tr2.replaceSelectionWith(node).scrollIntoView().setSelection(TextSelection.near(tr2.doc.resolve(offset2)));
|
|
41914
|
+
}
|
|
41915
|
+
return true;
|
|
41916
|
+
},
|
|
41917
|
+
addColumnBefore: () => ({ state: state2, dispatch }) => {
|
|
41918
|
+
return addColumnBefore(state2, dispatch);
|
|
41919
|
+
},
|
|
41920
|
+
addColumnAfter: () => ({ state: state2, dispatch }) => {
|
|
41921
|
+
return addColumnAfter(state2, dispatch);
|
|
41922
|
+
},
|
|
41923
|
+
deleteColumn: () => ({ state: state2, dispatch }) => {
|
|
41924
|
+
return deleteColumn(state2, dispatch);
|
|
41925
|
+
},
|
|
41926
|
+
addRowBefore: () => ({ state: state2, dispatch }) => {
|
|
41927
|
+
return addRowBefore(state2, dispatch);
|
|
41928
|
+
},
|
|
41929
|
+
addRowAfter: () => ({ state: state2, dispatch }) => {
|
|
41930
|
+
return addRowAfter(state2, dispatch);
|
|
41931
|
+
},
|
|
41932
|
+
deleteRow: () => ({ state: state2, dispatch }) => {
|
|
41933
|
+
return deleteRow(state2, dispatch);
|
|
41934
|
+
},
|
|
41935
|
+
deleteTable: () => ({ state: state2, dispatch }) => {
|
|
41936
|
+
return deleteTable(state2, dispatch);
|
|
41937
|
+
},
|
|
41938
|
+
mergeCells: () => ({ state: state2, dispatch }) => {
|
|
41939
|
+
return mergeCells(state2, dispatch);
|
|
41940
|
+
},
|
|
41941
|
+
splitCell: () => ({ state: state2, dispatch }) => {
|
|
41942
|
+
return splitCell(state2, dispatch);
|
|
41943
|
+
},
|
|
41944
|
+
toggleHeaderColumn: () => ({ state: state2, dispatch }) => {
|
|
41945
|
+
return toggleHeader("column")(state2, dispatch);
|
|
41946
|
+
},
|
|
41947
|
+
toggleHeaderRow: () => ({ state: state2, dispatch }) => {
|
|
41948
|
+
return toggleHeader("row")(state2, dispatch);
|
|
41949
|
+
},
|
|
41950
|
+
toggleHeaderCell: () => ({ state: state2, dispatch }) => {
|
|
41951
|
+
return toggleHeaderCell(state2, dispatch);
|
|
41952
|
+
},
|
|
41953
|
+
mergeOrSplit: () => ({ state: state2, dispatch }) => {
|
|
41954
|
+
if (mergeCells(state2, dispatch)) {
|
|
41955
|
+
return true;
|
|
41956
|
+
}
|
|
41957
|
+
return splitCell(state2, dispatch);
|
|
41958
|
+
},
|
|
41959
|
+
setCellAttribute: (name, value) => ({ state: state2, dispatch }) => {
|
|
41960
|
+
return setCellAttr(name, value)(state2, dispatch);
|
|
41961
|
+
},
|
|
41962
|
+
goToNextCell: () => ({ state: state2, dispatch }) => {
|
|
41963
|
+
return goToNextCell(1)(state2, dispatch);
|
|
41964
|
+
},
|
|
41965
|
+
goToPreviousCell: () => ({ state: state2, dispatch }) => {
|
|
41966
|
+
return goToNextCell(-1)(state2, dispatch);
|
|
41967
|
+
},
|
|
41968
|
+
fixTables: () => ({ state: state2, dispatch }) => {
|
|
41969
|
+
if (dispatch) {
|
|
41970
|
+
fixTables(state2);
|
|
41971
|
+
}
|
|
41972
|
+
return true;
|
|
41973
|
+
},
|
|
41974
|
+
setCellSelection: (position) => ({ tr: tr2, dispatch }) => {
|
|
41975
|
+
if (dispatch) {
|
|
41976
|
+
const selection = CellSelection.create(tr2.doc, position.anchorCell, position.headCell);
|
|
41977
|
+
tr2.setSelection(selection);
|
|
41978
|
+
}
|
|
41979
|
+
return true;
|
|
41980
|
+
}
|
|
41981
|
+
};
|
|
41982
|
+
},
|
|
41983
|
+
addKeyboardShortcuts() {
|
|
41984
|
+
return {
|
|
41985
|
+
Tab: () => {
|
|
41986
|
+
if (this.editor.commands.goToNextCell()) {
|
|
41987
|
+
return true;
|
|
41988
|
+
}
|
|
41989
|
+
if (!this.editor.can().addRowAfter()) {
|
|
41990
|
+
return false;
|
|
41991
|
+
}
|
|
41992
|
+
return this.editor.chain().addRowAfter().goToNextCell().run();
|
|
41993
|
+
},
|
|
41994
|
+
"Shift-Tab": () => this.editor.commands.goToPreviousCell(),
|
|
41995
|
+
Backspace: deleteTableWhenAllCellsSelected,
|
|
41996
|
+
"Mod-Backspace": deleteTableWhenAllCellsSelected,
|
|
41997
|
+
Delete: deleteTableWhenAllCellsSelected,
|
|
41998
|
+
"Mod-Delete": deleteTableWhenAllCellsSelected
|
|
41999
|
+
};
|
|
42000
|
+
},
|
|
42001
|
+
addProseMirrorPlugins() {
|
|
42002
|
+
const isResizable = this.options.resizable && this.editor.isEditable;
|
|
42003
|
+
return [
|
|
42004
|
+
...isResizable ? [
|
|
42005
|
+
columnResizing({
|
|
42006
|
+
handleWidth: this.options.handleWidth,
|
|
42007
|
+
cellMinWidth: this.options.cellMinWidth,
|
|
42008
|
+
// @ts-ignore (incorrect type)
|
|
42009
|
+
View: this.options.View,
|
|
42010
|
+
// TODO: PR for @types/prosemirror-tables
|
|
42011
|
+
// @ts-ignore (incorrect type)
|
|
42012
|
+
lastColumnResizable: this.options.lastColumnResizable
|
|
42013
|
+
})
|
|
42014
|
+
] : [],
|
|
42015
|
+
tableEditing({
|
|
42016
|
+
allowTableNodeSelection: this.options.allowTableNodeSelection
|
|
42017
|
+
})
|
|
42018
|
+
];
|
|
42019
|
+
},
|
|
42020
|
+
extendNodeSchema(extension) {
|
|
42021
|
+
const context = {
|
|
42022
|
+
name: extension.name,
|
|
42023
|
+
options: extension.options,
|
|
42024
|
+
storage: extension.storage
|
|
42025
|
+
};
|
|
42026
|
+
return {
|
|
42027
|
+
tableRole: callOrReturn(getExtensionField(extension, "tableRole", context))
|
|
42028
|
+
};
|
|
42029
|
+
}
|
|
42030
|
+
});
|
|
42031
|
+
const TableRow = Node$2.create({
|
|
42032
|
+
name: "tableRow",
|
|
42033
|
+
addOptions() {
|
|
42034
|
+
return {
|
|
42035
|
+
HTMLAttributes: {}
|
|
42036
|
+
};
|
|
42037
|
+
},
|
|
42038
|
+
content: "(tableCell | tableHeader)*",
|
|
42039
|
+
tableRole: "row",
|
|
42040
|
+
parseHTML() {
|
|
42041
|
+
return [
|
|
42042
|
+
{ tag: "tr" }
|
|
42043
|
+
];
|
|
42044
|
+
},
|
|
42045
|
+
renderHTML({ HTMLAttributes }) {
|
|
42046
|
+
return ["tr", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
42047
|
+
}
|
|
42048
|
+
});
|
|
42049
|
+
const TableCell = Node$2.create({
|
|
42050
|
+
name: "tableCell",
|
|
42051
|
+
addOptions() {
|
|
42052
|
+
return {
|
|
42053
|
+
HTMLAttributes: {}
|
|
42054
|
+
};
|
|
42055
|
+
},
|
|
42056
|
+
content: "block+",
|
|
42057
|
+
addAttributes() {
|
|
42058
|
+
return {
|
|
42059
|
+
colspan: {
|
|
42060
|
+
default: 1
|
|
42061
|
+
},
|
|
42062
|
+
rowspan: {
|
|
42063
|
+
default: 1
|
|
42064
|
+
},
|
|
42065
|
+
colwidth: {
|
|
42066
|
+
default: null,
|
|
42067
|
+
parseHTML: (element) => {
|
|
42068
|
+
const colwidth = element.getAttribute("colwidth");
|
|
42069
|
+
const value = colwidth ? [parseInt(colwidth, 10)] : null;
|
|
42070
|
+
return value;
|
|
42071
|
+
}
|
|
42072
|
+
}
|
|
42073
|
+
};
|
|
42074
|
+
},
|
|
42075
|
+
tableRole: "cell",
|
|
42076
|
+
isolating: true,
|
|
42077
|
+
parseHTML() {
|
|
42078
|
+
return [
|
|
42079
|
+
{ tag: "td" }
|
|
42080
|
+
];
|
|
42081
|
+
},
|
|
42082
|
+
renderHTML({ HTMLAttributes }) {
|
|
42083
|
+
return ["td", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
42084
|
+
}
|
|
42085
|
+
});
|
|
42086
|
+
const TableHeader = Node$2.create({
|
|
42087
|
+
name: "tableHeader",
|
|
42088
|
+
addOptions() {
|
|
42089
|
+
return {
|
|
42090
|
+
HTMLAttributes: {}
|
|
42091
|
+
};
|
|
42092
|
+
},
|
|
42093
|
+
content: "block+",
|
|
42094
|
+
addAttributes() {
|
|
42095
|
+
return {
|
|
42096
|
+
colspan: {
|
|
42097
|
+
default: 1
|
|
42098
|
+
},
|
|
42099
|
+
rowspan: {
|
|
42100
|
+
default: 1
|
|
42101
|
+
},
|
|
42102
|
+
colwidth: {
|
|
42103
|
+
default: null,
|
|
42104
|
+
parseHTML: (element) => {
|
|
42105
|
+
const colwidth = element.getAttribute("colwidth");
|
|
42106
|
+
const value = colwidth ? [parseInt(colwidth, 10)] : null;
|
|
42107
|
+
return value;
|
|
42108
|
+
}
|
|
42109
|
+
}
|
|
42110
|
+
};
|
|
42111
|
+
},
|
|
42112
|
+
tableRole: "header_cell",
|
|
42113
|
+
isolating: true,
|
|
42114
|
+
parseHTML() {
|
|
42115
|
+
return [
|
|
42116
|
+
{ tag: "th" }
|
|
42117
|
+
];
|
|
42118
|
+
},
|
|
42119
|
+
renderHTML({ HTMLAttributes }) {
|
|
42120
|
+
return ["th", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
42121
|
+
}
|
|
42122
|
+
});
|
|
39443
42123
|
const _hoisted_1$d = { class: "RichText" };
|
|
39444
42124
|
const _hoisted_2$a = {
|
|
39445
42125
|
key: 0,
|
|
@@ -39613,6 +42293,11 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
39613
42293
|
command: () => focus2().setHardBreak().run(),
|
|
39614
42294
|
icon: "keyboard_return"
|
|
39615
42295
|
},
|
|
42296
|
+
{
|
|
42297
|
+
name: "Table",
|
|
42298
|
+
command: () => editor.value.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run(),
|
|
42299
|
+
icon: "table_chart"
|
|
42300
|
+
},
|
|
39616
42301
|
{
|
|
39617
42302
|
name: "Undo",
|
|
39618
42303
|
command: () => focus2().undo().run(),
|
|
@@ -39635,7 +42320,15 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
39635
42320
|
const emit2 = __emit;
|
|
39636
42321
|
function initEditor() {
|
|
39637
42322
|
editor.value = new Editor({
|
|
39638
|
-
extensions: [
|
|
42323
|
+
extensions: [
|
|
42324
|
+
StarterKit,
|
|
42325
|
+
Image,
|
|
42326
|
+
Youtube,
|
|
42327
|
+
Table,
|
|
42328
|
+
TableRow,
|
|
42329
|
+
TableCell,
|
|
42330
|
+
TableHeader
|
|
42331
|
+
],
|
|
39639
42332
|
content: props2.modelValue,
|
|
39640
42333
|
onUpdate: ({ editor: editor2 }) => emit2("update:modelValue", editor2.getHTML())
|
|
39641
42334
|
});
|
|
@@ -46096,7 +48789,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
46096
48789
|
}
|
|
46097
48790
|
return (_ctx, _cache) => {
|
|
46098
48791
|
const _directive_tooltip = resolveDirective("tooltip");
|
|
46099
|
-
return openBlock(), createBlock(unref(_sfc_main$
|
|
48792
|
+
return openBlock(), createBlock(unref(_sfc_main$v), {
|
|
46100
48793
|
class: normalizeClass(["flex column gap-05 pt-1 bgl_sidebar", { wideNav: unref(isOpen) }])
|
|
46101
48794
|
}, {
|
|
46102
48795
|
default: withCtx(() => [
|
|
@@ -46119,7 +48812,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
46119
48812
|
class: "nav-button px-075"
|
|
46120
48813
|
}, {
|
|
46121
48814
|
default: withCtx(() => [
|
|
46122
|
-
createVNode(unref(_sfc_main$
|
|
48815
|
+
createVNode(unref(_sfc_main$I), {
|
|
46123
48816
|
icon: nav2.icon,
|
|
46124
48817
|
size: 1.4
|
|
46125
48818
|
}, null, 8, ["icon"]),
|
|
@@ -46156,7 +48849,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
46156
48849
|
},
|
|
46157
48850
|
setup(__props) {
|
|
46158
48851
|
return (_ctx, _cache) => {
|
|
46159
|
-
return openBlock(), createBlock(unref(_sfc_main$
|
|
48852
|
+
return openBlock(), createBlock(unref(_sfc_main$v), { class: "hide m_grid gap-05 bgl_bottombar px-1 txt14 justify-content-start align-items-center overflow-x" }, {
|
|
46160
48853
|
default: withCtx(() => [
|
|
46161
48854
|
renderSlot(_ctx.$slots, "brand", {}, void 0, true),
|
|
46162
48855
|
(openBlock(true), createElementBlock(Fragment$1, null, renderList(_ctx.navLinks, (nav2, i2) => {
|
|
@@ -46167,7 +48860,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
46167
48860
|
class: "m_h-auto"
|
|
46168
48861
|
}, {
|
|
46169
48862
|
default: withCtx(() => [
|
|
46170
|
-
createVNode(unref(_sfc_main$
|
|
48863
|
+
createVNode(unref(_sfc_main$I), {
|
|
46171
48864
|
icon: nav2.icon,
|
|
46172
48865
|
size: 1.4,
|
|
46173
48866
|
class: "m-0"
|
|
@@ -46271,7 +48964,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
46271
48964
|
onClick: ($event) => selectTab(tab),
|
|
46272
48965
|
key: i2
|
|
46273
48966
|
}, [
|
|
46274
|
-
typeof tab !== "string" && tab.icon ? (openBlock(), createBlock(unref(_sfc_main$
|
|
48967
|
+
typeof tab !== "string" && tab.icon ? (openBlock(), createBlock(unref(_sfc_main$I), {
|
|
46275
48968
|
key: 0,
|
|
46276
48969
|
icon: tab.icon
|
|
46277
48970
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -46366,7 +49059,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
46366
49059
|
});
|
|
46367
49060
|
const TabbedLayout = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-fd61196d"]]);
|
|
46368
49061
|
export {
|
|
46369
|
-
_sfc_main$
|
|
49062
|
+
_sfc_main$s as Accordion,
|
|
46370
49063
|
AccordionItem,
|
|
46371
49064
|
Alert,
|
|
46372
49065
|
Avatar,
|
|
@@ -46378,7 +49071,7 @@ export {
|
|
|
46378
49071
|
BglVideo,
|
|
46379
49072
|
BottomMenu,
|
|
46380
49073
|
Btn,
|
|
46381
|
-
_sfc_main$
|
|
49074
|
+
_sfc_main$v as Card,
|
|
46382
49075
|
Carousel,
|
|
46383
49076
|
CheckInput,
|
|
46384
49077
|
Checkbox,
|
|
@@ -46388,18 +49081,19 @@ export {
|
|
|
46388
49081
|
_sfc_main$c as DatePicker,
|
|
46389
49082
|
kt$1 as Dropdown,
|
|
46390
49083
|
$el as FileUpload,
|
|
46391
|
-
_sfc_main$
|
|
49084
|
+
_sfc_main$I as Icon,
|
|
46392
49085
|
JSONInput,
|
|
46393
49086
|
Layout,
|
|
46394
49087
|
_sfc_main$7 as Lineart,
|
|
46395
|
-
_sfc_main$
|
|
46396
|
-
_sfc_main$
|
|
46397
|
-
_sfc_main$
|
|
46398
|
-
_sfc_main$
|
|
49088
|
+
_sfc_main$B as ListItem,
|
|
49089
|
+
_sfc_main$C as ListView,
|
|
49090
|
+
_sfc_main$I as MaterialIcon,
|
|
49091
|
+
_sfc_main$F as Modal,
|
|
49092
|
+
_sfc_main$n as ModalConfirm,
|
|
46399
49093
|
ModalForm,
|
|
46400
49094
|
ModalPlugin,
|
|
46401
49095
|
NavBar,
|
|
46402
|
-
_sfc_main$
|
|
49096
|
+
_sfc_main$A as PageTitle,
|
|
46403
49097
|
RadioPillsInput,
|
|
46404
49098
|
_sfc_main$8 as RichText,
|
|
46405
49099
|
RouterWrapper,
|
|
@@ -46412,7 +49106,7 @@ export {
|
|
|
46412
49106
|
_sfc_main$1 as TabsBody,
|
|
46413
49107
|
TabsNav,
|
|
46414
49108
|
TextInput,
|
|
46415
|
-
_sfc_main$
|
|
49109
|
+
_sfc_main$t as Title,
|
|
46416
49110
|
ToggleInput,
|
|
46417
49111
|
TopBar,
|
|
46418
49112
|
bagelFormUtils,
|