oasis-editor 0.0.129 → 0.0.131
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/{OasisEditorApp-CDBzb0Eg.js → OasisEditorApp-Dn2I2b-M.js} +232 -21
- package/dist/app/controllers/useEditorLayout.d.ts +2 -1
- package/dist/app/controllers/useEditorTableCornerResize.d.ts +56 -0
- package/dist/{index-XyL0Hpf4.js → index-BXo_oqOC.js} +304 -151
- package/dist/oasis-editor.css +1 -1
- package/dist/oasis-editor.js +1 -1
- package/dist/oasis-editor.umd.cjs +4 -4
- package/dist/ui/OasisEditorEditor.d.ts +3 -1
- package/dist/ui/app/EditorDragLayers.d.ts +2 -0
- package/dist/ui/app/buildEditorViewProps.d.ts +4 -1
- package/dist/ui/app/createEditorDocumentRuntime.d.ts +1 -0
- package/dist/ui/app/createEditorInteractionRuntime.d.ts +1 -0
- package/dist/ui/app/useEditorInteractionWiring.d.ts +2 -0
- package/dist/ui/canvas/CanvasSelectionGeometry.d.ts +9 -0
- package/dist/ui/components/Toolbar/primitives/ColorPicker.d.ts +2 -0
- package/dist/ui/components/Toolbar/primitives/GridPicker.d.ts +2 -0
- package/dist/ui/components/Toolbar/primitives/Select.d.ts +2 -0
- package/dist/ui/components/Toolbar/primitives/SplitButton.d.ts +1 -0
- package/dist/ui/components/Toolbar/schema/items.d.ts +9 -0
- package/dist/ui/editorUiTypes.d.ts +9 -0
- package/dist/ui/overlays/TableHandlesOverlay.d.ts +22 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { E as EMPTY_PROJECTION_CONTEXT, d as domTextMeasurer, g as getProjectedParagraphBlockHeight, e as estimateTableBlockHeight, p as projectParagraphLayout, a as getPageBodyBottom, b as getPageBodyTop, c as getPageContentWidth, F as FOOTNOTE_MARKER_GUTTER_PX, f as getParagraphText, h as getBlockParagraphs, i as getRunFootnoteReference, l as listReferencedEndnotes, j as getFootnoteDisplayMarker, k as createProjectionContext, m as getDocumentSections, n as getRunField, o as projectBlocksLayout, v as visitRun, q as assertNever, r as createSignal, s as createEditorStateFromDocument, t as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, u as fontSizePxToPt, w as probeLocalFontFamilies, x as createEditorParagraphFromRuns, y as isInlineObjectRun, z as createEditorStyledRun, A as getParagraphLength, B as getActiveZone, C as getActiveSectionIndex, D as getParagraphs, G as normalizeSelection, H as positionToParagraphOffset, I as paragraphOffsetToPosition, J as clampPosition, K as findParagraphIndex, L as createCollapsedSelection, M as isSelectionCollapsed, N as parseFontSizePtToPx, O as formatFontSizePt, P as createEditorParagraph, Q as resolveDefaultParagraphStyleId, R as findParagraphTableLocation, T as buildTableCellLayout, U as PT_PER_PX, V as createEditorTableCell, W as createEditorTableRow, X as createEditorTable, Y as PX_PER_POINT, Z as underlineStyleToCssDecorationStyle, _ as resolveImageSrc, $ as listKindForTag, a0 as isParagraphTag, a1 as collectInlineRuns, a2 as parseParagraphStyle, a3 as getRunImage, a4 as InlineShell, a5 as BalloonShell, a6 as DocumentShell, a7 as createMemo, a8 as getCaretRectFromSnapshot, a9 as getParagraphRectFromSnapshot, aa as createComponent, ab as CaretOverlay, ac as Show, ad as createRenderEffect, ae as style, af as
|
|
4
|
+
import { E as EMPTY_PROJECTION_CONTEXT, d as domTextMeasurer, g as getProjectedParagraphBlockHeight, e as estimateTableBlockHeight, p as projectParagraphLayout, a as getPageBodyBottom, b as getPageBodyTop, c as getPageContentWidth, F as FOOTNOTE_MARKER_GUTTER_PX, f as getParagraphText, h as getBlockParagraphs, i as getRunFootnoteReference, l as listReferencedEndnotes, j as getFootnoteDisplayMarker, k as createProjectionContext, m as getDocumentSections, n as getRunField, o as projectBlocksLayout, v as visitRun, q as assertNever, r as createSignal, s as createEditorStateFromDocument, t as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, u as fontSizePxToPt, w as probeLocalFontFamilies, x as createEditorParagraphFromRuns, y as isInlineObjectRun, z as createEditorStyledRun, A as getParagraphLength, B as getActiveZone, C as getActiveSectionIndex, D as getParagraphs, G as normalizeSelection, H as positionToParagraphOffset, I as paragraphOffsetToPosition, J as clampPosition, K as findParagraphIndex, L as createCollapsedSelection, M as isSelectionCollapsed, N as parseFontSizePtToPx, O as formatFontSizePt, P as createEditorParagraph, Q as resolveDefaultParagraphStyleId, R as findParagraphTableLocation, T as buildTableCellLayout, U as PT_PER_PX, V as createEditorTableCell, W as createEditorTableRow, X as createEditorTable, Y as PX_PER_POINT, Z as underlineStyleToCssDecorationStyle, _ as resolveImageSrc, $ as listKindForTag, a0 as isParagraphTag, a1 as collectInlineRuns, a2 as parseParagraphStyle, a3 as getRunImage, a4 as InlineShell, a5 as BalloonShell, a6 as DocumentShell, a7 as createMemo, a8 as getCaretRectFromSnapshot, a9 as getParagraphRectFromSnapshot, aa as createComponent, ab as CaretOverlay, ac as Show, ad as createRenderEffect, ae as style, af as setStyleProperty, ag as setAttribute, ah as memo, ai as template, aj as Button, ak as useI18n, al as createEffect, am as TextField, an as Dialog, ao as insert, ap as className, aq as Grid, ar as SelectField, as as StatusText, at as ColorField, au as UNDERLINE_STYLE_OPTIONS, av as Stack, aw as For, ax as ToggleChip, ay as FormField, az as Checkbox, aA as FieldGroup, aB as Tabs, aC as NumberField, aD as createStore, aE as reconcile, aF as RadioGroup, aG as Radio$1, aH as TextAreaField, aI as Text, aJ as SurfaceButton, aK as delegateEvents, aL as onMount, aM as onCleanup, aN as use, aO as PluginUiHost, aP as OasisEditorEditor, aQ as OasisBrandMark, aR as setPreciseFontPreference, aS as setWelcomeSeen, aT as enablePreciseFontMode, aU as TWIPS_PER_POINT, aV as PX_PER_INCH, aW as TWIPS_PER_INCH, aX as normalizeHex6, aY as TABLE_CONDITIONAL_FLAG_ATTRIBUTES, aZ as TABLE_BORDER_EDGE_KEYS, a_ as resolveEffectiveParagraphStyle, a$ as resolveEffectiveTextStyleForParagraph, b0 as EMU_PER_PT, b1 as OOXML_ROTATION_UNITS, b2 as OOXML_PERCENT_DENOMINATOR, b3 as parseHexColorToRgb255, b4 as EMU_PER_PX, b5 as getRunEndnoteReference, b6 as iterateFootnoteReferenceRuns, b7 as iterateEndnoteReferenceRuns, b8 as imageContentTypeDefaults, b9 as getRunFieldChar, ba as getRunFieldInstruction, bb as createEditorRun, bc as JSZip, bd as imageExtensionFromMime, be as pxToPt$1, bf as resolveFloatingObjectRect, bg as getTextBoxFloatingGeometry, bh as getPresetPathSegments, bi as buildListLabels, bj as DEFAULT_FONT_SIZE_PX, bk as resolveGradientAxis, bl as isDoubleUnderlineStyle, bm as isWavyUnderlineStyle, bn as underlineStyleLineWidthPx, bo as WAVY_UNDERLINE_WAVELENGTH_PX, bp as WAVY_UNDERLINE_AMPLITUDE_PX, bq as DOUBLE_UNDERLINE_OFFSET_PX, br as underlineStyleDashArray, bs as EMPHASIS_GLYPH, bt as rgb255ToHex, bu as getImageFloatingGeometry, bv as textStyleToFontSizePt, bw as resolveTextAlignmentBaselineOffset, bx as TEXT_BASELINE_RATIO, by as resolveOpenTypeFeatureTags, bz as resolveDecorationLineY, bA as DOUBLE_STRIKE_OFFSET_PX, bB as resolveListLabel, bC as getListLabelInset, bD as getAlignedListLabelInset, bE as getParagraphBorderInsets, bF as buildSegmentTable, bG as buildCanvasTableLayout, bH as resolveCanvasTableWidth, bI as resolveFloatingTableRect, bJ as paragraphBetweenBorderMatches, bK as normalizeFamily, bL as ROBOTO_FONT_FILES, bM as loadFontAsset, bN as OFFICE_COMPAT_FONT_FAMILIES, bO as BinaryReader, bP as buildSfnt, bQ as defaultFontDecoderRegistry, bR as SfntFontProgram, bS as collectPdfFontFamilies, bT as outlineFrom, bU as getPageHeaderZoneTop, bV as getPageColumnRects, bW as findFootnoteReference, bX as resolveImporterForFile, bY as roundTo, bZ as getDocumentSectionsCanonical, b_ as getDocumentParagraphsCanonical, b$ as getDocumentParagraphs, c0 as getDocumentPageSettings, c1 as getTableCellContentWidthForParagraph, c2 as layoutMetricsEpoch, c3 as bumpLayoutMetricsEpoch, c4 as createCanvasLayoutSnapshotProvider, c5 as on, c6 as debounce, c7 as unwrap, c8 as perfTimer, c9 as getRunTextBox, ca as createEditorDocument, cb as resolveResizedDimensions, cc as resolveTextBoxRenderHeight, cd as getToolbarStyleState, ce as VERTICAL_HIT_WEIGHT, cf as getCachedCanvasImage, cg as measureParagraphMinContentWidthPx, ch as getEditableBlocksForZone, ci as findParagraphLocation, cj as createSectionBoundaryParagraph, ck as normalizePageSettings, cl as DEFAULT_EDITOR_PAGE_SETTINGS, cm as markStart, cn as markEnd, co as getParagraphEntries, cp as getParagraphById, cq as createEditorFootnote, cr as createFootnoteReferenceRun, cs as renumberFootnotes, ct as getHeadingLevel, cu as preciseFontModeVersion, cv as isPreciseFontModeEnabled, cw as resolveNamedTextStyle, cx as togglePreciseFontMode, cy as nextFontSizePt, cz as previousFontSizePt, cA as fontSizePtToPx, cB as createDefaultToolbarPreset, cC as MenuRegistry, cD as createToolbarRegistry, cE as Editor, cF as resolveCommandRef, cG as commandRefName, cH as createOasisEditorClient, cI as createEditorZoom, cJ as startLongTaskObserver, cK as installGlobalReport, cL as applyStoredPreciseFontPreference, cM as getWelcomeSeen, cN as isLocalFontAccessSupported, cO as EDITOR_SCROLL_PADDING_PX, cP as Toolbar, cQ as OasisEditorLoading, cR as I18nProvider, cS as createTranslator, cT as registerDomStatsSurface, cU as createEditorLogger } from "./index-BXo_oqOC.js";
|
|
5
5
|
function projectHeaderFooterBlocksWithDependencies(blocks, deps, context = {}) {
|
|
6
6
|
const {
|
|
7
7
|
pageIndex,
|
|
@@ -31546,7 +31546,7 @@ function DropCaret(props) {
|
|
|
31546
31546
|
})
|
|
31547
31547
|
});
|
|
31548
31548
|
}
|
|
31549
|
-
var _tmpl$$f = /* @__PURE__ */ template(`<div class=oasis-editor-table-resize-guide>`), _tmpl$2$5 = /* @__PURE__ */ template(`<img class=oasis-editor-image-ghost>`), _tmpl$
|
|
31549
|
+
var _tmpl$$f = /* @__PURE__ */ template(`<div class=oasis-editor-table-resize-guide>`), _tmpl$2$5 = /* @__PURE__ */ template(`<div class=oasis-editor-table-resize-outline>`), _tmpl$3$2 = /* @__PURE__ */ template(`<img class=oasis-editor-image-ghost>`), _tmpl$4$1 = /* @__PURE__ */ template(`<div class=oasis-editor-table-ghost>`);
|
|
31550
31550
|
function EditorDragLayers(props) {
|
|
31551
31551
|
return [createComponent(Show, {
|
|
31552
31552
|
get when() {
|
|
@@ -31579,19 +31579,40 @@ function EditorDragLayers(props) {
|
|
|
31579
31579
|
});
|
|
31580
31580
|
return _el$;
|
|
31581
31581
|
})()
|
|
31582
|
+
}), createComponent(Show, {
|
|
31583
|
+
get when() {
|
|
31584
|
+
return props.tableCornerResize.previewRect();
|
|
31585
|
+
},
|
|
31586
|
+
children: (rect) => (() => {
|
|
31587
|
+
var _el$2 = _tmpl$2$5();
|
|
31588
|
+
createRenderEffect((_p$) => {
|
|
31589
|
+
var _v$4 = `${rect().left}px`, _v$5 = `${rect().top}px`, _v$6 = `${rect().width}px`, _v$7 = `${rect().height}px`;
|
|
31590
|
+
_v$4 !== _p$.e && setStyleProperty(_el$2, "left", _p$.e = _v$4);
|
|
31591
|
+
_v$5 !== _p$.t && setStyleProperty(_el$2, "top", _p$.t = _v$5);
|
|
31592
|
+
_v$6 !== _p$.a && setStyleProperty(_el$2, "width", _p$.a = _v$6);
|
|
31593
|
+
_v$7 !== _p$.o && setStyleProperty(_el$2, "height", _p$.o = _v$7);
|
|
31594
|
+
return _p$;
|
|
31595
|
+
}, {
|
|
31596
|
+
e: void 0,
|
|
31597
|
+
t: void 0,
|
|
31598
|
+
a: void 0,
|
|
31599
|
+
o: void 0
|
|
31600
|
+
});
|
|
31601
|
+
return _el$2;
|
|
31602
|
+
})()
|
|
31582
31603
|
}), createComponent(Show, {
|
|
31583
31604
|
get when() {
|
|
31584
31605
|
return memo(() => !!props.imageOps.dragging())() && props.imageOps.draggedImageInfo();
|
|
31585
31606
|
},
|
|
31586
31607
|
children: (info) => (() => {
|
|
31587
|
-
var _el$
|
|
31608
|
+
var _el$3 = _tmpl$3$2();
|
|
31588
31609
|
createRenderEffect((_p$) => {
|
|
31589
|
-
var _v$
|
|
31590
|
-
_v$
|
|
31591
|
-
_v$
|
|
31592
|
-
_v$
|
|
31593
|
-
_v$
|
|
31594
|
-
_v$
|
|
31610
|
+
var _v$8 = info().src, _v$9 = `${info().width}px`, _v$0 = `${info().height}px`, _v$1 = `${props.imageOps.mousePos().x - info().offsetX}px`, _v$10 = `${props.imageOps.mousePos().y - info().offsetY}px`;
|
|
31611
|
+
_v$8 !== _p$.e && setAttribute(_el$3, "src", _p$.e = _v$8);
|
|
31612
|
+
_v$9 !== _p$.t && setStyleProperty(_el$3, "width", _p$.t = _v$9);
|
|
31613
|
+
_v$0 !== _p$.a && setStyleProperty(_el$3, "height", _p$.a = _v$0);
|
|
31614
|
+
_v$1 !== _p$.o && setStyleProperty(_el$3, "left", _p$.o = _v$1);
|
|
31615
|
+
_v$10 !== _p$.i && setStyleProperty(_el$3, "top", _p$.i = _v$10);
|
|
31595
31616
|
return _p$;
|
|
31596
31617
|
}, {
|
|
31597
31618
|
e: void 0,
|
|
@@ -31600,20 +31621,20 @@ function EditorDragLayers(props) {
|
|
|
31600
31621
|
o: void 0,
|
|
31601
31622
|
i: void 0
|
|
31602
31623
|
});
|
|
31603
|
-
return _el$
|
|
31624
|
+
return _el$3;
|
|
31604
31625
|
})()
|
|
31605
31626
|
}), createComponent(Show, {
|
|
31606
31627
|
get when() {
|
|
31607
31628
|
return memo(() => !!props.tableDrag.dragging())() && props.tableDrag.draggedTableInfo();
|
|
31608
31629
|
},
|
|
31609
31630
|
children: (info) => (() => {
|
|
31610
|
-
var _el$
|
|
31631
|
+
var _el$4 = _tmpl$4$1();
|
|
31611
31632
|
createRenderEffect((_p$) => {
|
|
31612
|
-
var _v$
|
|
31613
|
-
_v$
|
|
31614
|
-
_v$
|
|
31615
|
-
_v$
|
|
31616
|
-
_v$
|
|
31633
|
+
var _v$11 = `${info().width}px`, _v$12 = `${info().height}px`, _v$13 = `${props.tableDrag.mousePos().x - info().offsetX}px`, _v$14 = `${props.tableDrag.mousePos().y - info().offsetY}px`;
|
|
31634
|
+
_v$11 !== _p$.e && setStyleProperty(_el$4, "width", _p$.e = _v$11);
|
|
31635
|
+
_v$12 !== _p$.t && setStyleProperty(_el$4, "height", _p$.t = _v$12);
|
|
31636
|
+
_v$13 !== _p$.a && setStyleProperty(_el$4, "left", _p$.a = _v$13);
|
|
31637
|
+
_v$14 !== _p$.o && setStyleProperty(_el$4, "top", _p$.o = _v$14);
|
|
31617
31638
|
return _p$;
|
|
31618
31639
|
}, {
|
|
31619
31640
|
e: void 0,
|
|
@@ -31621,7 +31642,7 @@ function EditorDragLayers(props) {
|
|
|
31621
31642
|
a: void 0,
|
|
31622
31643
|
o: void 0
|
|
31623
31644
|
});
|
|
31624
|
-
return _el$
|
|
31645
|
+
return _el$4;
|
|
31625
31646
|
})()
|
|
31626
31647
|
}), createComponent(Show, {
|
|
31627
31648
|
get when() {
|
|
@@ -35839,6 +35860,7 @@ function buildEditorViewProps(ctx) {
|
|
|
35839
35860
|
commentHighlights: overlayInput.commentHighlights,
|
|
35840
35861
|
selectedImageBox: overlayInput.selectedImageBox,
|
|
35841
35862
|
selectedTextBoxBox: overlayInput.selectedTextBoxBox,
|
|
35863
|
+
selectedTableBox: overlayInput.selectedTableBox,
|
|
35842
35864
|
layoutOptions: overlayInput.layoutOptions,
|
|
35843
35865
|
caretBox: overlayInput.caretBox,
|
|
35844
35866
|
inputBox: overlayInput.inputBox,
|
|
@@ -35889,6 +35911,7 @@ function buildEditorViewProps(ctx) {
|
|
|
35889
35911
|
onImageRotateHandleMouseDown: surface.handleImageRotateHandleMouseDown,
|
|
35890
35912
|
onTextBoxRotateHandleMouseDown: surface.handleTextBoxRotateHandleMouseDown,
|
|
35891
35913
|
onTableDragHandleMouseDown: surface.tableDrag.handleMouseDown,
|
|
35914
|
+
onTableCornerResizeHandleMouseDown: surface.tableCornerResize.handleMouseDown,
|
|
35892
35915
|
onRevisionMouseEnter: surface.revisionController.handleRevisionMouseEnter,
|
|
35893
35916
|
onRevisionMouseLeave: surface.revisionController.handleRevisionMouseLeave,
|
|
35894
35917
|
onEditorContextMenu: (event) => surface.handleEditorContextMenu(event)
|
|
@@ -44612,7 +44635,7 @@ function resolveCaretSlot(paragraphs, focusOffset) {
|
|
|
44612
44635
|
};
|
|
44613
44636
|
}
|
|
44614
44637
|
function computeCanvasSelectionGeometry(snapshot, state) {
|
|
44615
|
-
var _a2, _b2, _c, _d;
|
|
44638
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
44616
44639
|
const normalized = normalizeSelection(state);
|
|
44617
44640
|
const selectionBoxes = [];
|
|
44618
44641
|
const surfaceRect = snapshot.surfaceRect;
|
|
@@ -44799,12 +44822,38 @@ function computeCanvasSelectionGeometry(snapshot, state) {
|
|
|
44799
44822
|
height: caretHeight,
|
|
44800
44823
|
visible: focusParagraphSegments.length > 0 && !isMultiCellSelection && !selectedImageBox && !selectedTextBoxBox
|
|
44801
44824
|
};
|
|
44825
|
+
let selectedTableBox = null;
|
|
44826
|
+
const focusTableId = ((_f = (_e = (snapshot.paragraphsById.get(focusParagraphId) ?? [])[0]) == null ? void 0 : _e.tableCell) == null ? void 0 : _f.tableId) ?? null;
|
|
44827
|
+
if (focusTableId) {
|
|
44828
|
+
let left = Number.POSITIVE_INFINITY;
|
|
44829
|
+
let top = Number.POSITIVE_INFINITY;
|
|
44830
|
+
let right = Number.NEGATIVE_INFINITY;
|
|
44831
|
+
let bottom = Number.NEGATIVE_INFINITY;
|
|
44832
|
+
for (const paragraph of snapshot.paragraphs) {
|
|
44833
|
+
const cell = paragraph.tableCell;
|
|
44834
|
+
if (!cell || cell.tableId !== focusTableId) continue;
|
|
44835
|
+
left = Math.min(left, cell.left);
|
|
44836
|
+
top = Math.min(top, cell.top);
|
|
44837
|
+
right = Math.max(right, cell.left + cell.width);
|
|
44838
|
+
bottom = Math.max(bottom, cell.top + cell.height);
|
|
44839
|
+
}
|
|
44840
|
+
if (Number.isFinite(left) && right > left && bottom > top) {
|
|
44841
|
+
selectedTableBox = {
|
|
44842
|
+
tableId: focusTableId,
|
|
44843
|
+
left: left - surfaceRect.left,
|
|
44844
|
+
top: top - surfaceRect.top,
|
|
44845
|
+
width: right - left,
|
|
44846
|
+
height: bottom - top
|
|
44847
|
+
};
|
|
44848
|
+
}
|
|
44849
|
+
}
|
|
44802
44850
|
return {
|
|
44803
44851
|
selectionBoxes,
|
|
44804
44852
|
inputBox: { left: caretLeft, top: caretTop, height: caretHeight },
|
|
44805
44853
|
caretBox,
|
|
44806
44854
|
selectedImageBox,
|
|
44807
|
-
selectedTextBoxBox
|
|
44855
|
+
selectedTextBoxBox,
|
|
44856
|
+
selectedTableBox
|
|
44808
44857
|
};
|
|
44809
44858
|
}
|
|
44810
44859
|
function computeCommentHighlights(snapshot, state) {
|
|
@@ -45010,6 +45059,7 @@ function useEditorLayoutImpl(props) {
|
|
|
45010
45059
|
const [commentHighlights, setCommentHighlights] = createSignal([]);
|
|
45011
45060
|
const [selectedImageBox, setSelectedImageBox] = createSignal(null);
|
|
45012
45061
|
const [selectedTextBoxBox, setSelectedTextBoxBox] = createSignal(null);
|
|
45062
|
+
const [selectedTableBox, setSelectedTableBox] = createSignal(null);
|
|
45013
45063
|
const [caretBox, setCaretBox] = createSignal({
|
|
45014
45064
|
left: 0,
|
|
45015
45065
|
top: 0,
|
|
@@ -45044,6 +45094,7 @@ function useEditorLayoutImpl(props) {
|
|
|
45044
45094
|
setCommentHighlights([]);
|
|
45045
45095
|
setSelectedImageBox(null);
|
|
45046
45096
|
setSelectedTextBoxBox(null);
|
|
45097
|
+
setSelectedTableBox(null);
|
|
45047
45098
|
setCaretBox(
|
|
45048
45099
|
(current) => ({
|
|
45049
45100
|
...current,
|
|
@@ -45063,6 +45114,7 @@ function useEditorLayoutImpl(props) {
|
|
|
45063
45114
|
setCommentHighlights([]);
|
|
45064
45115
|
setSelectedImageBox(null);
|
|
45065
45116
|
setSelectedTextBoxBox(null);
|
|
45117
|
+
setSelectedTableBox(null);
|
|
45066
45118
|
setCaretBox(
|
|
45067
45119
|
(current) => ({
|
|
45068
45120
|
...current,
|
|
@@ -45076,6 +45128,7 @@ function useEditorLayoutImpl(props) {
|
|
|
45076
45128
|
setCommentHighlights(computeCommentHighlights(snapshot, props.state));
|
|
45077
45129
|
setSelectedImageBox(geometry.selectedImageBox);
|
|
45078
45130
|
setSelectedTextBoxBox(geometry.selectedTextBoxBox);
|
|
45131
|
+
setSelectedTableBox(geometry.selectedTableBox);
|
|
45079
45132
|
setInputBox(geometry.inputBox);
|
|
45080
45133
|
setCaretBox(geometry.caretBox);
|
|
45081
45134
|
};
|
|
@@ -45183,6 +45236,7 @@ function useEditorLayoutImpl(props) {
|
|
|
45183
45236
|
commentHighlights,
|
|
45184
45237
|
selectedImageBox,
|
|
45185
45238
|
selectedTextBoxBox,
|
|
45239
|
+
selectedTableBox,
|
|
45186
45240
|
caretBox,
|
|
45187
45241
|
preferredColumnX,
|
|
45188
45242
|
setPreferredColumnX,
|
|
@@ -45760,6 +45814,7 @@ function createEditorDocumentRuntimeImpl(deps) {
|
|
|
45760
45814
|
commentHighlights,
|
|
45761
45815
|
selectedImageBox,
|
|
45762
45816
|
selectedTextBoxBox,
|
|
45817
|
+
selectedTableBox,
|
|
45763
45818
|
caretBox,
|
|
45764
45819
|
preferredColumnX,
|
|
45765
45820
|
setPreferredColumnX,
|
|
@@ -45848,6 +45903,7 @@ function createEditorDocumentRuntimeImpl(deps) {
|
|
|
45848
45903
|
commentHighlights,
|
|
45849
45904
|
selectedImageBox,
|
|
45850
45905
|
selectedTextBoxBox,
|
|
45906
|
+
selectedTableBox,
|
|
45851
45907
|
caretBox,
|
|
45852
45908
|
preferredColumnX,
|
|
45853
45909
|
setPreferredColumnX,
|
|
@@ -49423,7 +49479,7 @@ function setHoverCursorClass(isCol) {
|
|
|
49423
49479
|
function setActiveCursorClass(isCol) {
|
|
49424
49480
|
setResizeCursorClass(isCol);
|
|
49425
49481
|
}
|
|
49426
|
-
const DRAG_THRESHOLD_PX = 2;
|
|
49482
|
+
const DRAG_THRESHOLD_PX$1 = 2;
|
|
49427
49483
|
function createEditorTableResize(deps) {
|
|
49428
49484
|
const [resizing, setResizing] = createSignal(null);
|
|
49429
49485
|
const handleMouseMove = (event) => {
|
|
@@ -49552,7 +49608,7 @@ function createEditorTableResize(deps) {
|
|
|
49552
49608
|
if (!currentResizing) return;
|
|
49553
49609
|
const z = ((_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)) ?? 1;
|
|
49554
49610
|
const delta = ((currentResizing.type === "column" ? event.clientX : event.clientY) - currentResizing.initialPos) / z;
|
|
49555
|
-
if (Math.abs(delta) >= DRAG_THRESHOLD_PX) {
|
|
49611
|
+
if (Math.abs(delta) >= DRAG_THRESHOLD_PX$1) {
|
|
49556
49612
|
deps.applyTransactionalState((current) => {
|
|
49557
49613
|
if (currentResizing.type === "row") {
|
|
49558
49614
|
return applyRowResize(current, currentResizing, delta);
|
|
@@ -49571,6 +49627,146 @@ function createEditorTableResize(deps) {
|
|
|
49571
49627
|
handleMouseDown
|
|
49572
49628
|
};
|
|
49573
49629
|
}
|
|
49630
|
+
const DRAG_THRESHOLD_PX = 2;
|
|
49631
|
+
function computeCornerScales(resize) {
|
|
49632
|
+
const rawX = (resize.bounds.width + (resize.currentClientX - resize.startClientX)) / resize.bounds.width;
|
|
49633
|
+
const rawY = (resize.bounds.height + (resize.currentClientY - resize.startClientY)) / resize.bounds.height;
|
|
49634
|
+
const widthValues = Object.values(resize.widthsPt);
|
|
49635
|
+
const minColumnPt = widthValues.length > 0 ? Math.min(...widthValues) : 1;
|
|
49636
|
+
const minScaleX = minColumnPt > 0 ? MIN_TABLE_SIZE_PT / minColumnPt : 0;
|
|
49637
|
+
const minRowPx = ptToPx(MIN_TABLE_SIZE_PT);
|
|
49638
|
+
const minRowHeightPx = resize.rowHeightsPx.length > 0 ? Math.min(...resize.rowHeightsPx) : minRowPx;
|
|
49639
|
+
const minScaleY = minRowHeightPx > 0 ? minRowPx / minRowHeightPx : 0;
|
|
49640
|
+
return {
|
|
49641
|
+
scaleX: Math.max(minScaleX, rawX),
|
|
49642
|
+
scaleY: Math.max(minScaleY, rawY)
|
|
49643
|
+
};
|
|
49644
|
+
}
|
|
49645
|
+
function applyTableCornerResize(state, resize, scaleX, scaleY) {
|
|
49646
|
+
const nextWidths = {};
|
|
49647
|
+
for (const key of Object.keys(resize.widthsPt)) {
|
|
49648
|
+
const index = Number(key);
|
|
49649
|
+
nextWidths[index] = Math.max(
|
|
49650
|
+
MIN_TABLE_SIZE_PT,
|
|
49651
|
+
resize.widthsPt[index] * scaleX
|
|
49652
|
+
);
|
|
49653
|
+
}
|
|
49654
|
+
const nextTotalPt = Object.values(nextWidths).reduce(
|
|
49655
|
+
(sum, value) => sum + value,
|
|
49656
|
+
0
|
|
49657
|
+
);
|
|
49658
|
+
let next = setTableColumnWidths(
|
|
49659
|
+
state,
|
|
49660
|
+
resize.tableId,
|
|
49661
|
+
nextWidths,
|
|
49662
|
+
nextTotalPt
|
|
49663
|
+
);
|
|
49664
|
+
resize.rowHeightsPx.forEach((heightPx, index) => {
|
|
49665
|
+
const nextHeightPt = Math.max(MIN_TABLE_SIZE_PT, pxToPt(heightPx * scaleY));
|
|
49666
|
+
next = setTableRowHeight(next, resize.tableId, index, nextHeightPt);
|
|
49667
|
+
});
|
|
49668
|
+
return next;
|
|
49669
|
+
}
|
|
49670
|
+
function createEditorTableCornerResize(deps) {
|
|
49671
|
+
const [resizing, setResizing] = createSignal(
|
|
49672
|
+
null
|
|
49673
|
+
);
|
|
49674
|
+
const previewRect = () => {
|
|
49675
|
+
const current = resizing();
|
|
49676
|
+
if (!current) return null;
|
|
49677
|
+
const { scaleX, scaleY } = computeCornerScales(current);
|
|
49678
|
+
return {
|
|
49679
|
+
left: current.bounds.left,
|
|
49680
|
+
top: current.bounds.top,
|
|
49681
|
+
width: current.bounds.width * scaleX,
|
|
49682
|
+
height: current.bounds.height * scaleY
|
|
49683
|
+
};
|
|
49684
|
+
};
|
|
49685
|
+
const handleWindowMouseMove = (event) => {
|
|
49686
|
+
setResizing(
|
|
49687
|
+
(current) => current ? {
|
|
49688
|
+
...current,
|
|
49689
|
+
currentClientX: event.clientX,
|
|
49690
|
+
currentClientY: event.clientY
|
|
49691
|
+
} : null
|
|
49692
|
+
);
|
|
49693
|
+
};
|
|
49694
|
+
const stop = () => {
|
|
49695
|
+
setResizing(null);
|
|
49696
|
+
window.removeEventListener("mousemove", handleWindowMouseMove);
|
|
49697
|
+
window.removeEventListener("mouseup", handleWindowMouseUp);
|
|
49698
|
+
document.body.style.cursor = "";
|
|
49699
|
+
};
|
|
49700
|
+
const handleWindowMouseUp = (event) => {
|
|
49701
|
+
const current = resizing();
|
|
49702
|
+
if (current) {
|
|
49703
|
+
const movedX = Math.abs(event.clientX - current.startClientX);
|
|
49704
|
+
const movedY = Math.abs(event.clientY - current.startClientY);
|
|
49705
|
+
if (movedX >= DRAG_THRESHOLD_PX || movedY >= DRAG_THRESHOLD_PX) {
|
|
49706
|
+
const settled = {
|
|
49707
|
+
...current,
|
|
49708
|
+
currentClientX: event.clientX,
|
|
49709
|
+
currentClientY: event.clientY
|
|
49710
|
+
};
|
|
49711
|
+
const { scaleX, scaleY } = computeCornerScales(settled);
|
|
49712
|
+
deps.applyTransactionalState(
|
|
49713
|
+
(state) => applyTableCornerResize(state, settled, scaleX, scaleY)
|
|
49714
|
+
);
|
|
49715
|
+
}
|
|
49716
|
+
}
|
|
49717
|
+
stop();
|
|
49718
|
+
};
|
|
49719
|
+
const handleMouseDown = (tableId, event) => {
|
|
49720
|
+
var _a2;
|
|
49721
|
+
const surface = deps.surfaceRef();
|
|
49722
|
+
if (!surface) return;
|
|
49723
|
+
const geometries = buildTableGeometries(
|
|
49724
|
+
surface,
|
|
49725
|
+
deps.state(),
|
|
49726
|
+
deps.documentLayout(),
|
|
49727
|
+
deps.canvasSnapshotProvider,
|
|
49728
|
+
(_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)
|
|
49729
|
+
);
|
|
49730
|
+
const geometry = geometries.find(
|
|
49731
|
+
(candidate) => candidate.tableId === tableId
|
|
49732
|
+
);
|
|
49733
|
+
const tableNode = getTableById(deps.state(), tableId);
|
|
49734
|
+
if (!geometry || !tableNode) return;
|
|
49735
|
+
const tableLayout = buildTableCellLayout(tableNode);
|
|
49736
|
+
const { widthsPt } = resolveColumnWidthsPt(
|
|
49737
|
+
tableNode,
|
|
49738
|
+
tableLayout,
|
|
49739
|
+
geometry
|
|
49740
|
+
);
|
|
49741
|
+
const rowHeightsPx = resolveRowHeightsPx(tableNode, tableLayout, geometry);
|
|
49742
|
+
const totalWidthPt = Object.values(widthsPt).reduce(
|
|
49743
|
+
(sum, value) => sum + value,
|
|
49744
|
+
0
|
|
49745
|
+
);
|
|
49746
|
+
setResizing({
|
|
49747
|
+
tableId,
|
|
49748
|
+
bounds: {
|
|
49749
|
+
left: geometry.bounds.left,
|
|
49750
|
+
top: geometry.bounds.top,
|
|
49751
|
+
width: Math.max(1, geometry.bounds.width),
|
|
49752
|
+
height: Math.max(1, geometry.bounds.height)
|
|
49753
|
+
},
|
|
49754
|
+
startClientX: event.clientX,
|
|
49755
|
+
startClientY: event.clientY,
|
|
49756
|
+
currentClientX: event.clientX,
|
|
49757
|
+
currentClientY: event.clientY,
|
|
49758
|
+
widthsPt,
|
|
49759
|
+
totalWidthPt,
|
|
49760
|
+
rowHeightsPx
|
|
49761
|
+
});
|
|
49762
|
+
document.body.style.cursor = "nwse-resize";
|
|
49763
|
+
window.addEventListener("mousemove", handleWindowMouseMove);
|
|
49764
|
+
window.addEventListener("mouseup", handleWindowMouseUp);
|
|
49765
|
+
event.preventDefault();
|
|
49766
|
+
event.stopPropagation();
|
|
49767
|
+
};
|
|
49768
|
+
return { resizing, previewRect, handleMouseDown };
|
|
49769
|
+
}
|
|
49574
49770
|
function createEditorTableDrag(deps) {
|
|
49575
49771
|
return createEditorTableDragImpl(deps);
|
|
49576
49772
|
}
|
|
@@ -50865,6 +51061,14 @@ function useEditorInteractionWiring(ctx) {
|
|
|
50865
51061
|
documentLayout: ctx.documentLayout,
|
|
50866
51062
|
canvasSnapshotProvider: ctx.canvasSnapshotProvider
|
|
50867
51063
|
});
|
|
51064
|
+
const tableCornerResize = createEditorTableCornerResize({
|
|
51065
|
+
state,
|
|
51066
|
+
applyTransactionalState: ctx.applyTransactionalState,
|
|
51067
|
+
surfaceRef: ctx.surfaceRef,
|
|
51068
|
+
zoomFactor: ctx.zoomFactor,
|
|
51069
|
+
documentLayout: ctx.documentLayout,
|
|
51070
|
+
canvasSnapshotProvider: ctx.canvasSnapshotProvider
|
|
51071
|
+
});
|
|
50868
51072
|
const tableDrag = createEditorTableDrag({
|
|
50869
51073
|
state,
|
|
50870
51074
|
applyTransactionalState: ctx.applyTransactionalState,
|
|
@@ -50943,6 +51147,7 @@ function useEditorInteractionWiring(ctx) {
|
|
|
50943
51147
|
});
|
|
50944
51148
|
return {
|
|
50945
51149
|
tableResize,
|
|
51150
|
+
tableCornerResize,
|
|
50946
51151
|
tableDrag,
|
|
50947
51152
|
revisionController,
|
|
50948
51153
|
textDrag,
|
|
@@ -51100,6 +51305,7 @@ function createEditorInteractionRuntimeImpl(deps) {
|
|
|
51100
51305
|
styleController,
|
|
51101
51306
|
onEditorMouseDown,
|
|
51102
51307
|
tableResize: wiring.tableResize,
|
|
51308
|
+
tableCornerResize: wiring.tableCornerResize,
|
|
51103
51309
|
tableDrag: wiring.tableDrag,
|
|
51104
51310
|
revisionController: wiring.revisionController,
|
|
51105
51311
|
textDrag: wiring.textDrag,
|
|
@@ -55017,6 +55223,7 @@ function OasisEditorApp(props = {}) {
|
|
|
55017
55223
|
commentHighlights,
|
|
55018
55224
|
selectedImageBox,
|
|
55019
55225
|
selectedTextBoxBox,
|
|
55226
|
+
selectedTableBox,
|
|
55020
55227
|
caretBox,
|
|
55021
55228
|
preferredColumnX,
|
|
55022
55229
|
setPreferredColumnX,
|
|
@@ -55063,6 +55270,7 @@ function OasisEditorApp(props = {}) {
|
|
|
55063
55270
|
styleController,
|
|
55064
55271
|
onEditorMouseDown,
|
|
55065
55272
|
tableResize,
|
|
55273
|
+
tableCornerResize,
|
|
55066
55274
|
tableDrag,
|
|
55067
55275
|
revisionController,
|
|
55068
55276
|
textDrag,
|
|
@@ -55162,6 +55370,7 @@ function OasisEditorApp(props = {}) {
|
|
|
55162
55370
|
commentHighlights,
|
|
55163
55371
|
selectedImageBox,
|
|
55164
55372
|
selectedTextBoxBox,
|
|
55373
|
+
selectedTableBox,
|
|
55165
55374
|
layoutOptions: layoutOptionsOverlay,
|
|
55166
55375
|
caretBox,
|
|
55167
55376
|
inputBox,
|
|
@@ -55180,6 +55389,7 @@ function OasisEditorApp(props = {}) {
|
|
|
55180
55389
|
surface: {
|
|
55181
55390
|
surfaceEvents: surfaceEventsWithTextDrag,
|
|
55182
55391
|
tableResize,
|
|
55392
|
+
tableCornerResize,
|
|
55183
55393
|
tableDrag,
|
|
55184
55394
|
revisionController,
|
|
55185
55395
|
handleDrop,
|
|
@@ -55324,6 +55534,7 @@ function OasisEditorApp(props = {}) {
|
|
|
55324
55534
|
return zoom.zoomFactor;
|
|
55325
55535
|
},
|
|
55326
55536
|
tableResize,
|
|
55537
|
+
tableCornerResize,
|
|
55327
55538
|
imageOps,
|
|
55328
55539
|
tableDrag,
|
|
55329
55540
|
textDrag
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EditorLayoutParagraph, EditorState, EditorLayoutDocument } from '../../core/model.js';
|
|
2
2
|
import { CaretBox, CommentHighlightBox, InputBox, SelectionBox } from '../../ui/editorUiTypes.js';
|
|
3
|
-
import { SelectedImageSelectionBox, SelectedTextBoxSelectionBox } from '../../ui/canvas/CanvasSelectionGeometry.js';
|
|
3
|
+
import { SelectedImageSelectionBox, SelectedTextBoxSelectionBox, SelectedTableBox } from '../../ui/canvas/CanvasSelectionGeometry.js';
|
|
4
4
|
|
|
5
5
|
interface UseEditorLayoutProps {
|
|
6
6
|
state: EditorState;
|
|
@@ -27,6 +27,7 @@ declare function useEditorLayoutImpl(props: UseEditorLayoutProps): {
|
|
|
27
27
|
commentHighlights: import('solid-js').Accessor<CommentHighlightBox[]>;
|
|
28
28
|
selectedImageBox: import('solid-js').Accessor<SelectedImageSelectionBox | null>;
|
|
29
29
|
selectedTextBoxBox: import('solid-js').Accessor<SelectedTextBoxSelectionBox | null>;
|
|
30
|
+
selectedTableBox: import('solid-js').Accessor<SelectedTableBox | null>;
|
|
30
31
|
caretBox: import('solid-js').Accessor<CaretBox>;
|
|
31
32
|
preferredColumnX: import('solid-js').Accessor<number | null>;
|
|
32
33
|
setPreferredColumnX: import('solid-js').Setter<number | null>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Accessor } from 'solid-js';
|
|
2
|
+
import { EditorLayoutDocument, EditorState } from '../../core/model.js';
|
|
3
|
+
import { CanvasLayoutSnapshotProvider } from '../../ui/canvas/canvasLayoutSnapshotProvider.js';
|
|
4
|
+
|
|
5
|
+
/** Live state of a bottom-right corner drag on a single table. */
|
|
6
|
+
export interface TableCornerResizeState {
|
|
7
|
+
tableId: string;
|
|
8
|
+
/** Table bounding box in client px at gesture start. */
|
|
9
|
+
bounds: {
|
|
10
|
+
left: number;
|
|
11
|
+
top: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
};
|
|
15
|
+
startClientX: number;
|
|
16
|
+
startClientY: number;
|
|
17
|
+
currentClientX: number;
|
|
18
|
+
currentClientY: number;
|
|
19
|
+
/** Column widths (pt) and total width (pt) captured at start. */
|
|
20
|
+
widthsPt: Record<number, number>;
|
|
21
|
+
totalWidthPt: number;
|
|
22
|
+
/** Rendered row heights (px) captured at start. */
|
|
23
|
+
rowHeightsPx: number[];
|
|
24
|
+
}
|
|
25
|
+
export interface TableCornerResizeOps {
|
|
26
|
+
resizing: Accessor<TableCornerResizeState | null>;
|
|
27
|
+
/** Preview outline in client/fixed coords while dragging (null otherwise). */
|
|
28
|
+
previewRect: Accessor<{
|
|
29
|
+
left: number;
|
|
30
|
+
top: number;
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
} | null>;
|
|
34
|
+
handleMouseDown: (tableId: string, event: MouseEvent) => void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Proportional width/height scale for the current drag, floored so no column
|
|
38
|
+
* shrinks below `MIN_TABLE_SIZE_PT` (pt) and no row below its px equivalent.
|
|
39
|
+
*/
|
|
40
|
+
export declare function computeCornerScales(resize: TableCornerResizeState): {
|
|
41
|
+
scaleX: number;
|
|
42
|
+
scaleY: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Pure producer: scale every column width by `scaleX` (preserving the scaled
|
|
46
|
+
* total) and every row height by `scaleY`. Exported for unit testing.
|
|
47
|
+
*/
|
|
48
|
+
export declare function applyTableCornerResize(state: EditorState, resize: TableCornerResizeState, scaleX: number, scaleY: number): EditorState;
|
|
49
|
+
export declare function createEditorTableCornerResize(deps: {
|
|
50
|
+
state: () => EditorState;
|
|
51
|
+
applyTransactionalState: (producer: (current: EditorState) => EditorState) => void;
|
|
52
|
+
surfaceRef: () => HTMLElement | undefined;
|
|
53
|
+
documentLayout: Accessor<EditorLayoutDocument>;
|
|
54
|
+
canvasSnapshotProvider: CanvasLayoutSnapshotProvider;
|
|
55
|
+
zoomFactor?: () => number;
|
|
56
|
+
}): TableCornerResizeOps;
|