@jvs-milkdown/components 1.2.2 → 1.2.4
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/lib/__internal__/components/icon.d.ts +24 -0
- package/lib/__internal__/components/icon.d.ts.map +1 -0
- package/lib/__internal__/components/image-input.d.ts +17 -0
- package/lib/__internal__/components/image-input.d.ts.map +1 -0
- package/lib/__internal__/keep-alive.d.ts +2 -0
- package/lib/__internal__/keep-alive.d.ts.map +1 -0
- package/lib/__internal__/meta.d.ts +3 -0
- package/lib/__internal__/meta.d.ts.map +1 -0
- package/lib/__tests__/setup.d.ts +2 -0
- package/lib/__tests__/setup.d.ts.map +1 -0
- package/lib/code-block/config.d.ts +25 -0
- package/lib/code-block/config.d.ts.map +1 -0
- package/lib/code-block/index.d.ts +5 -0
- package/lib/code-block/index.d.ts.map +1 -0
- package/lib/code-block/view/components/code-block.d.ts +18 -0
- package/lib/code-block/view/components/code-block.d.ts.map +1 -0
- package/lib/code-block/view/components/copy-button.d.ts +9 -0
- package/lib/code-block/view/components/copy-button.d.ts.map +1 -0
- package/lib/code-block/view/components/language-picker.d.ts +5 -0
- package/lib/code-block/view/components/language-picker.d.ts.map +1 -0
- package/lib/code-block/view/components/preview-panel.d.ts +9 -0
- package/lib/code-block/view/components/preview-panel.d.ts.map +1 -0
- package/lib/code-block/view/index.d.ts +3 -0
- package/lib/code-block/view/index.d.ts.map +1 -0
- package/lib/code-block/view/loader.d.ts +13 -0
- package/lib/code-block/view/loader.d.ts.map +1 -0
- package/lib/code-block/view/node-view.d.ts +43 -0
- package/lib/code-block/view/node-view.d.ts.map +1 -0
- package/lib/image-block/config.d.ts +21 -0
- package/lib/image-block/config.d.ts.map +1 -0
- package/lib/image-block/convert-plugin.d.ts +2 -0
- package/lib/image-block/convert-plugin.d.ts.map +1 -0
- package/lib/image-block/index.d.ts +9 -0
- package/lib/image-block/index.d.ts.map +1 -0
- package/lib/image-block/index.js +1 -1
- package/lib/image-block/index.js.map +1 -1
- package/lib/image-block/paste-rule.d.ts +2 -0
- package/lib/image-block/paste-rule.d.ts.map +1 -0
- package/lib/image-block/remark-plugin.d.ts +2 -0
- package/lib/image-block/remark-plugin.d.ts.map +1 -0
- package/lib/image-block/schema.d.ts +3 -0
- package/lib/image-block/schema.d.ts.map +1 -0
- package/lib/image-block/view/components/__tests__/image-viewer.onImageLoadError.spec.d.ts +2 -0
- package/lib/image-block/view/components/__tests__/image-viewer.onImageLoadError.spec.d.ts.map +1 -0
- package/lib/image-block/view/components/image-block.d.ts +27 -0
- package/lib/image-block/view/components/image-block.d.ts.map +1 -0
- package/lib/image-block/view/components/image-viewer.d.ts +3 -0
- package/lib/image-block/view/components/image-viewer.d.ts.map +1 -0
- package/lib/image-block/view/index.d.ts +3 -0
- package/lib/image-block/view/index.d.ts.map +1 -0
- package/lib/image-inline/components/image-inline.d.ts +18 -0
- package/lib/image-inline/components/image-inline.d.ts.map +1 -0
- package/lib/image-inline/config.d.ts +11 -0
- package/lib/image-inline/config.d.ts.map +1 -0
- package/lib/image-inline/index.d.ts +5 -0
- package/lib/image-inline/index.d.ts.map +1 -0
- package/lib/image-inline/view.d.ts +3 -0
- package/lib/image-inline/view.d.ts.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/link-tooltip/command.d.ts +2 -0
- package/lib/link-tooltip/command.d.ts.map +1 -0
- package/lib/link-tooltip/configure.d.ts +3 -0
- package/lib/link-tooltip/configure.d.ts.map +1 -0
- package/lib/link-tooltip/edit/component.d.ts +11 -0
- package/lib/link-tooltip/edit/component.d.ts.map +1 -0
- package/lib/link-tooltip/edit/edit-configure.d.ts +3 -0
- package/lib/link-tooltip/edit/edit-configure.d.ts.map +1 -0
- package/lib/link-tooltip/edit/edit-view.d.ts +15 -0
- package/lib/link-tooltip/edit/edit-view.d.ts.map +1 -0
- package/lib/link-tooltip/index.d.ts +7 -0
- package/lib/link-tooltip/index.d.ts.map +1 -0
- package/lib/link-tooltip/index.js +1 -2
- package/lib/link-tooltip/index.js.map +1 -1
- package/lib/link-tooltip/preview/component.d.ts +11 -0
- package/lib/link-tooltip/preview/component.d.ts.map +1 -0
- package/lib/link-tooltip/preview/preview-configure.d.ts +3 -0
- package/lib/link-tooltip/preview/preview-configure.d.ts.map +1 -0
- package/lib/link-tooltip/preview/preview-view.d.ts +14 -0
- package/lib/link-tooltip/preview/preview-view.d.ts.map +1 -0
- package/lib/link-tooltip/slices.d.ts +34 -0
- package/lib/link-tooltip/slices.d.ts.map +1 -0
- package/lib/link-tooltip/tooltips.d.ts +3 -0
- package/lib/link-tooltip/tooltips.d.ts.map +1 -0
- package/lib/link-tooltip/utils.d.ts +14 -0
- package/lib/link-tooltip/utils.d.ts.map +1 -0
- package/lib/list-item-block/component.d.ts +19 -0
- package/lib/list-item-block/component.d.ts.map +1 -0
- package/lib/list-item-block/config.d.ts +13 -0
- package/lib/list-item-block/config.d.ts.map +1 -0
- package/lib/list-item-block/index.d.ts +6 -0
- package/lib/list-item-block/index.d.ts.map +1 -0
- package/lib/list-item-block/view.d.ts +3 -0
- package/lib/list-item-block/view.d.ts.map +1 -0
- package/lib/table-block/config.d.ts +8 -0
- package/lib/table-block/config.d.ts.map +1 -0
- package/lib/table-block/dnd/calc-drag-over.d.ts +3 -0
- package/lib/table-block/dnd/calc-drag-over.d.ts.map +1 -0
- package/lib/table-block/dnd/create-drag-handler.d.ts +5 -0
- package/lib/table-block/dnd/create-drag-handler.d.ts.map +1 -0
- package/lib/table-block/dnd/drag-over-handler.d.ts +3 -0
- package/lib/table-block/dnd/drag-over-handler.d.ts.map +1 -0
- package/lib/table-block/dnd/prepare-dnd-context.d.ts +3 -0
- package/lib/table-block/dnd/prepare-dnd-context.d.ts.map +1 -0
- package/lib/table-block/dnd/preview.d.ts +3 -0
- package/lib/table-block/dnd/preview.d.ts.map +1 -0
- package/lib/table-block/index.d.ts +5 -0
- package/lib/table-block/index.d.ts.map +1 -0
- package/lib/table-block/index.js +68 -10
- package/lib/table-block/index.js.map +1 -1
- package/lib/table-block/view/component.d.ts +16 -0
- package/lib/table-block/view/component.d.ts.map +1 -0
- package/lib/table-block/view/drag.d.ts +10 -0
- package/lib/table-block/view/drag.d.ts.map +1 -0
- package/lib/table-block/view/index.d.ts +2 -0
- package/lib/table-block/view/index.d.ts.map +1 -0
- package/lib/table-block/view/operation.d.ts +15 -0
- package/lib/table-block/view/operation.d.ts.map +1 -0
- package/lib/table-block/view/pointer.d.ts +7 -0
- package/lib/table-block/view/pointer.d.ts.map +1 -0
- package/lib/table-block/view/types.d.ts +28 -0
- package/lib/table-block/view/types.d.ts.map +1 -0
- package/lib/table-block/view/utils.d.ts +12 -0
- package/lib/table-block/view/utils.d.ts.map +1 -0
- package/lib/table-block/view/view.d.ts +22 -0
- package/lib/table-block/view/view.d.ts.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/image-block/convert-plugin.ts +1 -1
- package/src/image-block/paste-rule.ts +1 -21
- package/src/link-tooltip/edit/component.tsx +0 -1
- package/src/table-block/view/component.tsx +31 -13
- package/src/table-block/view/operation.ts +62 -0
- package/src/table-block/view/utils.ts +4 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type RenderType = 'add_row' | 'add_col' | 'delete_row' | 'delete_col' | 'align_col_left' | 'align_col_center' | 'align_col_right' | 'col_drag_handle' | 'row_drag_handle' | 'merge_cells' | 'split_cell';
|
|
2
|
+
export interface TableBlockConfig {
|
|
3
|
+
renderButton: (renderType: RenderType) => string;
|
|
4
|
+
}
|
|
5
|
+
export declare const tableBlockConfig: import("@jvs-milkdown/utils").$Ctx<{
|
|
6
|
+
renderButton: (renderType: RenderType) => string;
|
|
7
|
+
}, "tableBlockConfigCtx">;
|
|
8
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/table-block/config.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,SAAS,GACT,YAAY,GACZ,YAAY,GACZ,gBAAgB,GAChB,kBAAkB,GAClB,iBAAiB,GACjB,iBAAiB,GACjB,iBAAiB,GACjB,aAAa,GACb,YAAY,CAAA;AAEhB,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,MAAM,CAAA;CACjD;AA+BD,eAAO,MAAM,gBAAgB;kBAhCb,CAAC,UAAU,EAAE,UAAU,KAAK,MAAM;yBAmCjD,CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function getDragOverColumn(table: Element, pointerX: number): [element: Element, index: number] | undefined;
|
|
2
|
+
export declare function getDragOverRow(table: Element, pointerY: number): [element: Element, index: number] | undefined;
|
|
3
|
+
//# sourceMappingURL=calc-drag-over.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calc-drag-over.d.ts","sourceRoot":"","sources":["../../../src/table-block/dnd/calc-drag-over.ts"],"names":[],"mappings":"AA6BA,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,MAAM,GACf,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,SAAS,CAK/C;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,MAAM,GACf,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,SAAS,CAG/C"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Ctx } from '@jvs-milkdown/ctx';
|
|
2
|
+
import type { Refs } from '../view/types';
|
|
3
|
+
export declare function createDragRowHandler(refs: Refs, ctx?: Ctx): (event: DragEvent) => void;
|
|
4
|
+
export declare function createDragColHandler(refs: Refs, ctx?: Ctx): (event: DragEvent) => void;
|
|
5
|
+
//# sourceMappingURL=create-drag-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-drag-handler.d.ts","sourceRoot":"","sources":["../../../src/table-block/dnd/create-drag-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAI5C,OAAO,KAAK,EAAe,IAAI,EAAE,MAAM,eAAe,CAAA;AAKtD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,GAAG,IAChD,OAAO,SAAS,UAazB;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,GAAG,IAChD,OAAO,SAAS,UAczB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drag-over-handler.d.ts","sourceRoot":"","sources":["../../../src/table-block/dnd/drag-over-handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAMzC,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,CAAC,EAAE,SAAS,KAAK,IAAI,CAmIxE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare-dnd-context.d.ts","sourceRoot":"","sources":["../../../src/table-block/dnd/prepare-dnd-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAEtD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,WAAW,GAAG,SAAS,CAmCrE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../src/table-block/dnd/preview.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,WAAW,EAAE,WAAW,QAEpD;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,GAAG,GAAG,GAAG,EACf,OAAO,EAAE,WAAW,EACpB,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,WAAW,EACzB,KAAK,EAAE,MAAM,QAgDd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/table-block/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAKvD,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AAExB,eAAO,MAAM,UAAU,EAAE,cAAc,EAAuC,CAAA"}
|
package/lib/table-block/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { $ctx, $view } from '@jvs-milkdown/utils';
|
|
|
2
2
|
import { selectColCommand, moveColCommand, selectRowCommand, moveRowCommand, mergeCellsCommand, setAlignCommand, deleteSelectedCellsCommand, addRowWithAlignment, tableSchema } from '@jvs-milkdown/preset-gfm';
|
|
3
3
|
import { h, defineComponent, ref, onMounted, watch, onBeforeUnmount, shallowRef, createApp, triggerRef } from 'vue';
|
|
4
4
|
import { computePosition, offset } from '@floating-ui/dom';
|
|
5
|
-
import { findTable, CellSelection, selectedRect, splitCellWithType, TableMap, addColumn, mergeCells, splitCell } from '@jvs-milkdown/prose/tables';
|
|
5
|
+
import { findTable, CellSelection, selectedRect, splitCellWithType, TableMap, removeColumn, removeRow, addColumn, mergeCells, splitCell } from '@jvs-milkdown/prose/tables';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
import DOMPurify from 'dompurify';
|
|
8
8
|
import { editorViewCtx, commandsCtx } from '@jvs-milkdown/core';
|
|
@@ -577,6 +577,56 @@ function useOperation(refs, ctx, getPos) {
|
|
|
577
577
|
ctx.get(editorViewCtx).focus();
|
|
578
578
|
});
|
|
579
579
|
};
|
|
580
|
+
const deleteRowByIndex = (index) => {
|
|
581
|
+
if (!ctx || !ctx.get(editorViewCtx).editable) return;
|
|
582
|
+
const view = ctx.get(editorViewCtx);
|
|
583
|
+
const tablePos = getPos == null ? void 0 : getPos();
|
|
584
|
+
if (tablePos == null) return;
|
|
585
|
+
const table = view.state.doc.nodeAt(tablePos);
|
|
586
|
+
if (!table) return;
|
|
587
|
+
const tableStart = tablePos + 1;
|
|
588
|
+
const map = TableMap.get(table);
|
|
589
|
+
const tr = view.state.tr;
|
|
590
|
+
const rect = {
|
|
591
|
+
map,
|
|
592
|
+
tableStart,
|
|
593
|
+
table,
|
|
594
|
+
left: 0,
|
|
595
|
+
right: map.width,
|
|
596
|
+
top: 0,
|
|
597
|
+
bottom: map.height
|
|
598
|
+
};
|
|
599
|
+
removeRow(tr, rect, index);
|
|
600
|
+
view.dispatch(tr);
|
|
601
|
+
requestAnimationFrame(() => {
|
|
602
|
+
ctx.get(editorViewCtx).focus();
|
|
603
|
+
});
|
|
604
|
+
};
|
|
605
|
+
const deleteColByIndex = (index) => {
|
|
606
|
+
if (!ctx || !ctx.get(editorViewCtx).editable) return;
|
|
607
|
+
const view = ctx.get(editorViewCtx);
|
|
608
|
+
const tablePos = getPos == null ? void 0 : getPos();
|
|
609
|
+
if (tablePos == null) return;
|
|
610
|
+
const table = view.state.doc.nodeAt(tablePos);
|
|
611
|
+
if (!table) return;
|
|
612
|
+
const tableStart = tablePos + 1;
|
|
613
|
+
const map = TableMap.get(table);
|
|
614
|
+
const tr = view.state.tr;
|
|
615
|
+
const rect = {
|
|
616
|
+
map,
|
|
617
|
+
tableStart,
|
|
618
|
+
table,
|
|
619
|
+
left: 0,
|
|
620
|
+
right: map.width,
|
|
621
|
+
top: 0,
|
|
622
|
+
bottom: map.height
|
|
623
|
+
};
|
|
624
|
+
removeColumn(tr, rect, index);
|
|
625
|
+
view.dispatch(tr);
|
|
626
|
+
requestAnimationFrame(() => {
|
|
627
|
+
ctx.get(editorViewCtx).focus();
|
|
628
|
+
});
|
|
629
|
+
};
|
|
580
630
|
const onAlign = (direction) => (e) => {
|
|
581
631
|
if (!ctx) return;
|
|
582
632
|
if (!ctx.get(editorViewCtx).editable) return;
|
|
@@ -656,6 +706,8 @@ function useOperation(refs, ctx, getPos) {
|
|
|
656
706
|
selectCol,
|
|
657
707
|
selectRow,
|
|
658
708
|
deleteSelected,
|
|
709
|
+
deleteRowByIndex,
|
|
710
|
+
deleteColByIndex,
|
|
659
711
|
onAlign,
|
|
660
712
|
onMergeCells,
|
|
661
713
|
onSplitCell
|
|
@@ -830,7 +882,8 @@ const TableBlock = defineComponent({
|
|
|
830
882
|
addColByIndex,
|
|
831
883
|
selectCol,
|
|
832
884
|
selectRow,
|
|
833
|
-
|
|
885
|
+
deleteRowByIndex,
|
|
886
|
+
deleteColByIndex,
|
|
834
887
|
onAlign,
|
|
835
888
|
onMergeCells,
|
|
836
889
|
onSplitCell
|
|
@@ -980,14 +1033,19 @@ const TableBlock = defineComponent({
|
|
|
980
1033
|
const isCellSelection = (sel) => sel && typeof sel.isColSelection === "function" && typeof sel.forEachCell === "function";
|
|
981
1034
|
if (isCellSelection(selection)) {
|
|
982
1035
|
const selAny = selection;
|
|
1036
|
+
const rect = selectedRect(view.state);
|
|
983
1037
|
if (selAny.isColSelection()) {
|
|
984
|
-
|
|
985
|
-
|
|
1038
|
+
if (activeColIndex.value >= rect.left && activeColIndex.value < rect.right) ; else {
|
|
1039
|
+
const $headCell = selAny.$headCell;
|
|
1040
|
+
activeColIndex.value = $headCell ? $headCell.index($headCell.depth) : -1;
|
|
1041
|
+
}
|
|
986
1042
|
activeRowIndex.value = -1;
|
|
987
1043
|
} else if (selAny.isRowSelection()) {
|
|
988
|
-
|
|
1044
|
+
if (activeRowIndex.value >= rect.top && activeRowIndex.value < rect.bottom) ; else {
|
|
1045
|
+
const $headCell = selAny.$headCell;
|
|
1046
|
+
activeRowIndex.value = $headCell ? $headCell.index($headCell.depth - 1) : -1;
|
|
1047
|
+
}
|
|
989
1048
|
activeColIndex.value = -1;
|
|
990
|
-
activeRowIndex.value = $headCell ? $headCell.index($headCell.depth - 1) : -1;
|
|
991
1049
|
} else {
|
|
992
1050
|
activeColIndex.value = -1;
|
|
993
1051
|
activeRowIndex.value = -1;
|
|
@@ -1168,9 +1226,9 @@ const TableBlock = defineComponent({
|
|
|
1168
1226
|
"button",
|
|
1169
1227
|
{
|
|
1170
1228
|
type: "button",
|
|
1171
|
-
onPointerdown: (
|
|
1229
|
+
onPointerdown: () => {
|
|
1172
1230
|
hoverIndex.value = [0, i];
|
|
1173
|
-
|
|
1231
|
+
deleteColByIndex(i);
|
|
1174
1232
|
}
|
|
1175
1233
|
},
|
|
1176
1234
|
/* @__PURE__ */ h(Icon, { icon: config.renderButton("delete_col") })
|
|
@@ -1235,9 +1293,9 @@ const TableBlock = defineComponent({
|
|
|
1235
1293
|
"button",
|
|
1236
1294
|
{
|
|
1237
1295
|
type: "button",
|
|
1238
|
-
onPointerdown: (
|
|
1296
|
+
onPointerdown: () => {
|
|
1239
1297
|
hoverIndex.value = [i, 0];
|
|
1240
|
-
|
|
1298
|
+
deleteRowByIndex(i);
|
|
1241
1299
|
}
|
|
1242
1300
|
},
|
|
1243
1301
|
/* @__PURE__ */ h(Icon, { icon: config.renderButton("delete_row") })
|