roosterjs-content-model-plugins 9.44.0 → 9.45.1

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.
Files changed (94) hide show
  1. package/lib/announce/tableSelectionUtils.js +6 -9
  2. package/lib/announce/tableSelectionUtils.js.map +1 -1
  3. package/lib/autoFormat/AutoFormatPlugin.js +4 -4
  4. package/lib/autoFormat/AutoFormatPlugin.js.map +1 -1
  5. package/lib/autoFormat/numbers/transformOrdinals.js +3 -2
  6. package/lib/autoFormat/numbers/transformOrdinals.js.map +1 -1
  7. package/lib/edit/deleteSteps/deleteList.js +39 -9
  8. package/lib/edit/deleteSteps/deleteList.js.map +1 -1
  9. package/lib/findReplace/FindReplacePlugin.js +5 -4
  10. package/lib/findReplace/FindReplacePlugin.js.map +1 -1
  11. package/lib/imageEdit/utils/generateDataURL.js +4 -2
  12. package/lib/imageEdit/utils/generateDataURL.js.map +1 -1
  13. package/lib/tableEdit/TableEditPlugin.js +4 -4
  14. package/lib/tableEdit/TableEditPlugin.js.map +1 -1
  15. package/lib/tableEdit/editors/TableEditor.d.ts +4 -0
  16. package/lib/tableEdit/editors/TableEditor.js +38 -1
  17. package/lib/tableEdit/editors/TableEditor.js.map +1 -1
  18. package/lib/tableEdit/editors/features/CellResizer.d.ts +1 -0
  19. package/lib/tableEdit/editors/features/CellResizer.js +83 -47
  20. package/lib/tableEdit/editors/features/CellResizer.js.map +1 -1
  21. package/lib/tableEdit/editors/features/TableEditFeatureName.d.ts +1 -1
  22. package/lib/tableEdit/editors/features/TableEditFeatureName.js.map +1 -1
  23. package/lib/tableEdit/editors/features/TableMover.js +2 -2
  24. package/lib/tableEdit/editors/features/TableMover.js.map +1 -1
  25. package/lib/tableEdit/editors/features/TableRowColumnSelector.d.ts +42 -0
  26. package/lib/tableEdit/editors/features/TableRowColumnSelector.js +223 -0
  27. package/lib/tableEdit/editors/features/TableRowColumnSelector.js.map +1 -0
  28. package/lib/tableEdit/editors/utils/getTableFromContentModel.js +1 -0
  29. package/lib/tableEdit/editors/utils/getTableFromContentModel.js.map +1 -1
  30. package/lib/touch/TouchPlugin.js +54 -52
  31. package/lib/touch/TouchPlugin.js.map +1 -1
  32. package/lib-amd/announce/tableSelectionUtils.js +6 -9
  33. package/lib-amd/announce/tableSelectionUtils.js.map +1 -1
  34. package/lib-amd/autoFormat/AutoFormatPlugin.js +4 -4
  35. package/lib-amd/autoFormat/AutoFormatPlugin.js.map +1 -1
  36. package/lib-amd/autoFormat/numbers/transformOrdinals.js +3 -2
  37. package/lib-amd/autoFormat/numbers/transformOrdinals.js.map +1 -1
  38. package/lib-amd/edit/deleteSteps/deleteList.js +39 -10
  39. package/lib-amd/edit/deleteSteps/deleteList.js.map +1 -1
  40. package/lib-amd/findReplace/FindReplacePlugin.js +5 -4
  41. package/lib-amd/findReplace/FindReplacePlugin.js.map +1 -1
  42. package/lib-amd/imageEdit/utils/generateDataURL.js +4 -2
  43. package/lib-amd/imageEdit/utils/generateDataURL.js.map +1 -1
  44. package/lib-amd/tableEdit/TableEditPlugin.js +4 -4
  45. package/lib-amd/tableEdit/TableEditPlugin.js.map +1 -1
  46. package/lib-amd/tableEdit/editors/TableEditor.d.ts +4 -0
  47. package/lib-amd/tableEdit/editors/TableEditor.js +38 -2
  48. package/lib-amd/tableEdit/editors/TableEditor.js.map +1 -1
  49. package/lib-amd/tableEdit/editors/features/CellResizer.d.ts +1 -0
  50. package/lib-amd/tableEdit/editors/features/CellResizer.js +83 -47
  51. package/lib-amd/tableEdit/editors/features/CellResizer.js.map +1 -1
  52. package/lib-amd/tableEdit/editors/features/TableEditFeatureName.d.ts +1 -1
  53. package/lib-amd/tableEdit/editors/features/TableEditFeatureName.js.map +1 -1
  54. package/lib-amd/tableEdit/editors/features/TableMover.js +2 -2
  55. package/lib-amd/tableEdit/editors/features/TableMover.js.map +1 -1
  56. package/lib-amd/tableEdit/editors/features/TableRowColumnSelector.d.ts +42 -0
  57. package/lib-amd/tableEdit/editors/features/TableRowColumnSelector.js +221 -0
  58. package/lib-amd/tableEdit/editors/features/TableRowColumnSelector.js.map +1 -0
  59. package/lib-amd/tableEdit/editors/utils/getTableFromContentModel.js +1 -0
  60. package/lib-amd/tableEdit/editors/utils/getTableFromContentModel.js.map +1 -1
  61. package/lib-amd/touch/TouchPlugin.js +54 -52
  62. package/lib-amd/touch/TouchPlugin.js.map +1 -1
  63. package/lib-mjs/announce/tableSelectionUtils.js +6 -9
  64. package/lib-mjs/announce/tableSelectionUtils.js.map +1 -1
  65. package/lib-mjs/autoFormat/AutoFormatPlugin.js +4 -4
  66. package/lib-mjs/autoFormat/AutoFormatPlugin.js.map +1 -1
  67. package/lib-mjs/autoFormat/numbers/transformOrdinals.js +3 -2
  68. package/lib-mjs/autoFormat/numbers/transformOrdinals.js.map +1 -1
  69. package/lib-mjs/edit/deleteSteps/deleteList.js +40 -10
  70. package/lib-mjs/edit/deleteSteps/deleteList.js.map +1 -1
  71. package/lib-mjs/findReplace/FindReplacePlugin.js +5 -4
  72. package/lib-mjs/findReplace/FindReplacePlugin.js.map +1 -1
  73. package/lib-mjs/imageEdit/utils/generateDataURL.js +4 -2
  74. package/lib-mjs/imageEdit/utils/generateDataURL.js.map +1 -1
  75. package/lib-mjs/tableEdit/TableEditPlugin.js +4 -4
  76. package/lib-mjs/tableEdit/TableEditPlugin.js.map +1 -1
  77. package/lib-mjs/tableEdit/editors/TableEditor.d.ts +4 -0
  78. package/lib-mjs/tableEdit/editors/TableEditor.js +38 -1
  79. package/lib-mjs/tableEdit/editors/TableEditor.js.map +1 -1
  80. package/lib-mjs/tableEdit/editors/features/CellResizer.d.ts +1 -0
  81. package/lib-mjs/tableEdit/editors/features/CellResizer.js +84 -48
  82. package/lib-mjs/tableEdit/editors/features/CellResizer.js.map +1 -1
  83. package/lib-mjs/tableEdit/editors/features/TableEditFeatureName.d.ts +1 -1
  84. package/lib-mjs/tableEdit/editors/features/TableEditFeatureName.js.map +1 -1
  85. package/lib-mjs/tableEdit/editors/features/TableMover.js +2 -2
  86. package/lib-mjs/tableEdit/editors/features/TableMover.js.map +1 -1
  87. package/lib-mjs/tableEdit/editors/features/TableRowColumnSelector.d.ts +42 -0
  88. package/lib-mjs/tableEdit/editors/features/TableRowColumnSelector.js +216 -0
  89. package/lib-mjs/tableEdit/editors/features/TableRowColumnSelector.js.map +1 -0
  90. package/lib-mjs/tableEdit/editors/utils/getTableFromContentModel.js +1 -0
  91. package/lib-mjs/tableEdit/editors/utils/getTableFromContentModel.js.map +1 -1
  92. package/lib-mjs/touch/TouchPlugin.js +54 -52
  93. package/lib-mjs/touch/TouchPlugin.js.map +1 -1
  94. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"TableMover.js","sourceRoot":"","sources":["../../../../../../packages/roosterjs-content-model-plugins/lib/tableEdit/editors/features/TableMover.ts"],"names":[],"mappings":";;;;IA4BA,IAAM,kBAAkB,GAAG,EAAE,CAAC;IAC9B;;OAEG;IACU,QAAA,cAAc,GAAG,cAAc,CAAC;IAC7C,IAAM,qBAAqB,GAAG,wBAAwB,CAAC;IAEvD;;;;OAIG;IACH,SAAgB,gBAAgB,CAC5B,KAAuB,EACvB,MAAe,EACf,KAAc,EACd,gBAAmD,EACnD,OAAmB,EACnB,KAAwC,EACxC,UAA+B,EAC/B,eAA6B,EAC7B,oBAAmD,EACnD,eAAyB;QAEzB,IAAM,IAAI,GAAG,IAAA,2CAAa,EAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAE1D,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,IAAI,EAAE,UAAkB,CAAC,EAAE;YACtD,OAAO,IAAI,CAAC;SACf;QAED,IAAM,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC,kBAAkB,EAAE,CAAC;QAC7D,IAAM,QAAQ,GAAG,KAAK,CAAC,aAAa,CAAC;QACrC,IAAM,iBAAiB,GAAG;YACtB,GAAG,EAAE,KAAK;YACV,KAAK,EAAE,6EAA6E;SACv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CAAC;oCACzC,IAAA,0CAAY,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;iCAC/B;6BACJ;yBACJ;wBACD,OAAO,kBAAgB,CAAC;qBAC3B;gBACL,CAAC,EACD;oBACI,qCAAqC;oBACrC,iBAAiB,EAAE;wBACf,IAAI,EAAE,OAAO;wBACb,WAAW,EAAE,CAAC;wBACd,QAAQ,EAAE,CAAC;wBACX,UAAU,EAAE,CAAC;wBACb,OAAO,EAAE,CAAC;wBACV,KAAK,EAAE,KAAK;qBACf;oBACD,OAAO,EAAE,YAAY;iBACxB,CACJ,CAAC;aACL;iBAAM;gBACH,yCAAyC;gBACzC,MAAM,CAAC,eAAe,CAAC,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,gBAAgB,mCAAI,IAAI,CAAC,CAAC;aAC/D;YACD,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YACzC,OAAO,kBAAgB,CAAC;SAC3B;IACL,CAAC;IAjGD,8BAiGC","sourcesContent":["import { createElement } from '../../../pluginUtils/CreateElement/createElement';\nimport { DragAndDropHelper } from '../../../pluginUtils/DragAndDrop/DragAndDropHelper';\nimport { formatInsertPointWithContentModel } from 'roosterjs-content-model-api';\nimport { getCMTableFromTable } from '../utils/getTableFromContentModel';\nimport type { TableEditFeature } from './TableEditFeature';\nimport type { OnTableEditorCreatedCallback } from '../../OnTableEditorCreatedCallback';\nimport type { DragAndDropHandler } from '../../../pluginUtils/DragAndDrop/DragAndDropHandler';\nimport {\n cloneModel,\n createContentModelDocument,\n createSelectionMarker,\n getFirstSelectedTable,\n isNodeOfType,\n mergeModel,\n mutateBlock,\n normalizeRect,\n setParagraphNotImplicit,\n setSelection,\n} from 'roosterjs-content-model-dom';\nimport type {\n DOMSelection,\n IEditor,\n ReadonlyContentModelTable,\n Rect,\n ShallowMutableContentModelDocument,\n} from 'roosterjs-content-model-types';\nimport { getNodePositionFromEvent } from '../../../utils/getNodePositionFromEvent';\n\nconst TABLE_MOVER_LENGTH = 12;\n/**\n * @internal\n */\nexport const TABLE_MOVER_ID = '_Table_Mover';\nconst TABLE_MOVER_STYLE_KEY = '_TableMoverCursorStyle';\n\n/**\n * @internal\n * Allows user to move table to another position\n * Contains the function to select whole table\n */\nexport function createTableMover(\n table: HTMLTableElement,\n editor: IEditor,\n isRTL: boolean,\n onFinishDragging: (table: HTMLTableElement) => void,\n onStart: () => void,\n onEnd: (disposeHandler: boolean) => void,\n contentDiv?: EventTarget | null,\n anchorContainer?: HTMLElement,\n onTableEditorCreated?: OnTableEditorCreatedCallback,\n disableMovement?: boolean\n): TableEditFeature | null {\n const rect = normalizeRect(table.getBoundingClientRect());\n\n if (!isTableTopVisible(editor, rect, contentDiv as Node)) {\n return null;\n }\n\n const zoomScale = editor.getDOMHelper().calculateZoomScale();\n const document = table.ownerDocument;\n const createElementData = {\n tag: 'div',\n style: 'position: fixed; cursor: move; user-select: none; border: 1px solid #808080',\n };\n\n const div = createElement(createElementData, document) as HTMLDivElement;\n\n div.id = TABLE_MOVER_ID;\n div.style.width = `${TABLE_MOVER_LENGTH}px`;\n div.style.height = `${TABLE_MOVER_LENGTH}px`;\n\n (anchorContainer || document.body).appendChild(div);\n\n const context: TableMoverContext = {\n table,\n zoomScale,\n rect,\n isRTL,\n editor,\n div,\n onFinishDragging,\n onStart,\n onEnd,\n disableMovement,\n };\n\n setDivPosition(context, div);\n\n const featureHandler = new TableMoverFeature(\n div,\n context,\n () => {},\n disableMovement\n ? { onDragEnd }\n : {\n onDragStart,\n onDragging,\n onDragEnd,\n },\n context.zoomScale,\n onTableEditorCreated,\n editor.getEnvironment().isMobileOrTablet\n );\n\n return { node: table, div, featureHandler };\n}\n\n/**\n * @internal\n * Exported for testing\n */\nexport interface TableMoverContext {\n table: HTMLTableElement;\n zoomScale: number;\n rect: Rect | null;\n isRTL: boolean;\n editor: IEditor;\n div: HTMLElement;\n onFinishDragging: (table: HTMLTableElement) => void;\n onStart: () => void;\n onEnd: (disposeHandler: boolean) => void;\n disableMovement?: boolean;\n}\n\n/**\n * @internal\n * Exported for testing\n */\nexport interface TableMoverInitValue {\n cmTable: ReadonlyContentModelTable | undefined;\n initialSelection: DOMSelection | null;\n tableRect: HTMLDivElement;\n}\n\nclass TableMoverFeature extends DragAndDropHelper<TableMoverContext, TableMoverInitValue> {\n private disposer: undefined | (() => void);\n\n constructor(\n div: HTMLElement,\n context: TableMoverContext,\n onSubmit: (\n context: TableMoverContext,\n trigger: HTMLElement,\n container?: HTMLElement\n ) => void,\n handler: DragAndDropHandler<TableMoverContext, TableMoverInitValue>,\n zoomScale: number,\n onTableEditorCreated?: OnTableEditorCreatedCallback,\n forceMobile?: boolean | undefined\n ) {\n super(div, context, onSubmit, handler, zoomScale, forceMobile);\n this.disposer = onTableEditorCreated?.('TableMover', div);\n }\n\n dispose(): void {\n this.disposer?.();\n this.disposer = undefined;\n super.dispose();\n }\n}\n\nfunction setDivPosition(context: TableMoverContext, trigger: HTMLElement) {\n const { rect } = context;\n if (rect) {\n trigger.style.top = `${rect.top - TABLE_MOVER_LENGTH}px`;\n trigger.style.left = `${rect.left - TABLE_MOVER_LENGTH - 2}px`;\n }\n}\n\nfunction isTableTopVisible(editor: IEditor, rect: Rect | null, contentDiv?: Node | null): boolean {\n const visibleViewport = editor.getVisibleViewport();\n if (isNodeOfType(contentDiv, 'ELEMENT_NODE') && visibleViewport && rect) {\n const containerRect = normalizeRect(contentDiv.getBoundingClientRect());\n\n return !!containerRect && containerRect.top <= rect.top && visibleViewport.top <= rect.top;\n }\n\n return true;\n}\n\nfunction setTableMoverCursor(editor: IEditor, state: boolean, type?: 'move' | 'copy') {\n editor?.setEditorStyle(TABLE_MOVER_STYLE_KEY, state ? 'cursor: ' + type ?? 'move' : null);\n}\n\n/**\n * @internal\n * Exported for testing\n */\nexport function onDragStart(context: TableMoverContext): TableMoverInitValue {\n context.onStart();\n\n const { editor, table, div } = context;\n\n setTableMoverCursor(editor, true, 'move');\n\n // Create table outline rectangle\n const trect = table.getBoundingClientRect();\n const createElementData = {\n tag: 'div',\n style: 'position: fixed; user-select: none; border: 1px solid #808080',\n };\n const tableRect = createElement(createElementData, document) as HTMLDivElement;\n tableRect.style.width = `${trect.width}px`;\n tableRect.style.height = `${trect.height}px`;\n tableRect.style.top = `${trect.top}px`;\n tableRect.style.left = `${trect.left}px`;\n div.parentNode?.appendChild(tableRect);\n\n // Get drag start selection\n const initialSelection = editor.getDOMSelection();\n\n // Get Table block in content model\n const cmTable = getCMTableFromTable(editor, table);\n\n return {\n cmTable,\n initialSelection,\n tableRect,\n };\n}\n\n/**\n * @internal\n * Exported for testing\n */\nexport function onDragging(\n context: TableMoverContext,\n event: MouseEvent,\n initValue: TableMoverInitValue\n) {\n const { tableRect } = initValue;\n const { editor } = context;\n\n // Move table outline rectangle\n tableRect.style.top = `${event.clientY + TABLE_MOVER_LENGTH}px`;\n tableRect.style.left = `${event.clientX + TABLE_MOVER_LENGTH}px`;\n\n const pos = getNodePositionFromEvent(editor, event.clientX, event.clientY);\n if (pos) {\n const range = editor.getDocument().createRange();\n range.setStart(pos.node, pos.offset);\n range.collapse(true);\n\n editor.setDOMSelection({ type: 'range', range, isReverted: false });\n return true;\n }\n return false;\n}\n\n/**\n * @internal\n * Exported for testing\n */\nexport function onDragEnd(\n context: TableMoverContext,\n event: MouseEvent,\n initValue: TableMoverInitValue | undefined\n) {\n const { editor, table, onFinishDragging: selectWholeTable, disableMovement } = context;\n const element = event.target;\n\n // Remove table outline rectangle\n initValue?.tableRect.remove();\n\n // Reset cursor\n setTableMoverCursor(editor, false);\n\n if (element == context.div) {\n // Table mover was only clicked, select whole table and do not dismiss the handler element.\n selectWholeTable(table);\n context.onEnd(false /* disposeHandler */);\n return true;\n } else {\n // Check if table was dragged on itself, element is not in editor, or movement is disabled\n if (\n table.contains(element as Node) ||\n !editor.getDOMHelper().isNodeInEditor(element as Node) ||\n disableMovement\n ) {\n editor.setDOMSelection(initValue?.initialSelection ?? null);\n context.onEnd(true /* disposeHandler */);\n return false;\n }\n\n let insertionSuccess: boolean = false;\n\n // Get position to insert table\n const insertPosition = getNodePositionFromEvent(editor, event.clientX, event.clientY);\n if (insertPosition) {\n // Move table to new position\n formatInsertPointWithContentModel(\n editor,\n insertPosition,\n (model, context, ip) => {\n // Remove old table\n const [oldTable, path] = getFirstSelectedTable(model);\n if (oldTable) {\n const index = path[0].blocks.indexOf(oldTable);\n mutateBlock(path[0]).blocks.splice(index, 1);\n }\n\n if (ip && initValue?.cmTable) {\n // Insert new table\n const doc: ShallowMutableContentModelDocument = createContentModelDocument();\n doc.blocks.push(oldTable ?? mutateBlock(initValue.cmTable));\n insertionSuccess = !!mergeModel(model, cloneModel(doc), context, {\n mergeFormat: 'none',\n insertPosition: ip,\n });\n\n if (insertionSuccess) {\n // After mergeModel, the new table should be selected\n const finalTable = getFirstSelectedTable(model)[0] ?? initValue.cmTable;\n if (finalTable) {\n // Add selection marker to the first cell of the table\n const firstCell = finalTable.rows[0].cells[0];\n const markerParagraph = firstCell?.blocks[0];\n\n if (markerParagraph?.blockType == 'Paragraph') {\n const marker = createSelectionMarker(model.format);\n\n mutateBlock(markerParagraph).segments.unshift(marker);\n setParagraphNotImplicit(markerParagraph);\n setSelection(model, marker);\n }\n }\n }\n return insertionSuccess;\n }\n },\n {\n // Select first cell of the old table\n selectionOverride: {\n type: 'table',\n firstColumn: 0,\n firstRow: 0,\n lastColumn: 0,\n lastRow: 0,\n table: table,\n },\n apiName: 'TableMover',\n }\n );\n } else {\n // No movement, restore initial selection\n editor.setDOMSelection(initValue?.initialSelection ?? null);\n }\n context.onEnd(true /* disposeHandler */);\n return insertionSuccess;\n }\n}\n"]}
1
+ {"version":3,"file":"TableMover.js","sourceRoot":"","sources":["../../../../../../packages/roosterjs-content-model-plugins/lib/tableEdit/editors/features/TableMover.ts"],"names":[],"mappings":";;;;IA4BA,IAAM,kBAAkB,GAAG,EAAE,CAAC;IAC9B;;OAEG;IACU,QAAA,cAAc,GAAG,cAAc,CA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ACL,CAAC;IAjGD,8BAiGC","sourcesContent":["import { createElement } from '../../../pluginUtils/CreateElement/createElement';\nimport { DragAndDropHelper } from '../../../pluginUtils/DragAndDrop/DragAndDropHelper';\nimport { formatInsertPointWithContentModel } from 'roosterjs-content-model-api';\nimport { getCMTableFromTable } from '../utils/getTableFromContentModel';\nimport { getNodePositionFromEvent } from '../../../utils/getNodePositionFromEvent';\nimport type { TableEditFeature } from './TableEditFeature';\nimport type { OnTableEditorCreatedCallback } from '../../OnTableEditorCreatedCallback';\nimport type { DragAndDropHandler } from '../../../pluginUtils/DragAndDrop/DragAndDropHandler';\nimport {\n cloneModel,\n createContentModelDocument,\n createSelectionMarker,\n getFirstSelectedTable,\n isNodeOfType,\n mergeModel,\n mutateBlock,\n normalizeRect,\n setParagraphNotImplicit,\n setSelection,\n} from 'roosterjs-content-model-dom';\nimport type {\n DOMSelection,\n IEditor,\n ReadonlyContentModelTable,\n Rect,\n ShallowMutableContentModelDocument,\n} from 'roosterjs-content-model-types';\n\nconst TABLE_MOVER_LENGTH = 12;\n/**\n * @internal\n */\nexport const TABLE_MOVER_ID = '_Table_Mover';\nconst TABLE_MOVER_STYLE_KEY = '_TableMoverCursorStyle';\n\n/**\n * @internal\n * Allows user to move table to another position\n * Contains the function to select whole table\n */\nexport function createTableMover(\n table: HTMLTableElement,\n editor: IEditor,\n isRTL: boolean,\n onFinishDragging: (table: HTMLTableElement) => void,\n onStart: () => void,\n onEnd: (disposeHandler: boolean) => void,\n contentDiv?: EventTarget | null,\n anchorContainer?: HTMLElement,\n onTableEditorCreated?: OnTableEditorCreatedCallback,\n disableMovement?: boolean\n): TableEditFeature | null {\n const rect = normalizeRect(table.getBoundingClientRect());\n\n if (!isTableTopVisible(editor, rect, contentDiv as Node)) {\n return null;\n }\n\n const zoomScale = editor.getDOMHelper().calculateZoomScale();\n const document = table.ownerDocument;\n const createElementData = {\n tag: 'div',\n style: 'position: fixed; cursor: move; user-select: none; border: 1px solid #808080',\n };\n\n const div = createElement(createElementData, document) as HTMLDivElement;\n\n div.id = TABLE_MOVER_ID;\n div.style.width = `${TABLE_MOVER_LENGTH}px`;\n div.style.height = `${TABLE_MOVER_LENGTH}px`;\n\n (anchorContainer || document.body).appendChild(div);\n\n const context: TableMoverContext = {\n table,\n zoomScale,\n rect,\n isRTL,\n editor,\n div,\n onFinishDragging,\n onStart,\n onEnd,\n disableMovement,\n };\n\n setDivPosition(context, div);\n\n const featureHandler = new TableMoverFeature(\n div,\n context,\n () => {},\n disableMovement\n ? { onDragEnd }\n : {\n onDragStart,\n onDragging,\n onDragEnd,\n },\n context.zoomScale,\n onTableEditorCreated,\n editor.getEnvironment().isMobileOrTablet\n );\n\n return { node: table, div, featureHandler };\n}\n\n/**\n * @internal\n * Exported for testing\n */\nexport interface TableMoverContext {\n table: HTMLTableElement;\n zoomScale: number;\n rect: Rect | null;\n isRTL: boolean;\n editor: IEditor;\n div: HTMLElement;\n onFinishDragging: (table: HTMLTableElement) => void;\n onStart: () => void;\n onEnd: (disposeHandler: boolean) => void;\n disableMovement?: boolean;\n}\n\n/**\n * @internal\n * Exported for testing\n */\nexport interface TableMoverInitValue {\n cmTable: ReadonlyContentModelTable | undefined;\n initialSelection: DOMSelection | null;\n tableRect: HTMLDivElement;\n}\n\nclass TableMoverFeature extends DragAndDropHelper<TableMoverContext, TableMoverInitValue> {\n private disposer: undefined | (() => void);\n\n constructor(\n div: HTMLElement,\n context: TableMoverContext,\n onSubmit: (\n context: TableMoverContext,\n trigger: HTMLElement,\n container?: HTMLElement\n ) => void,\n handler: DragAndDropHandler<TableMoverContext, TableMoverInitValue>,\n zoomScale: number,\n onTableEditorCreated?: OnTableEditorCreatedCallback,\n forceMobile?: boolean | undefined\n ) {\n super(div, context, onSubmit, handler, zoomScale, forceMobile);\n this.disposer = onTableEditorCreated?.('TableMover', div);\n }\n\n dispose(): void {\n this.disposer?.();\n this.disposer = undefined;\n super.dispose();\n }\n}\n\nfunction setDivPosition(context: TableMoverContext, trigger: HTMLElement) {\n const { rect } = context;\n if (rect) {\n trigger.style.top = `${rect.top - TABLE_MOVER_LENGTH}px`;\n trigger.style.left = `${rect.left - TABLE_MOVER_LENGTH - 2}px`;\n }\n}\n\nfunction isTableTopVisible(editor: IEditor, rect: Rect | null, contentDiv?: Node | null): boolean {\n const visibleViewport = editor.getVisibleViewport();\n if (isNodeOfType(contentDiv, 'ELEMENT_NODE') && visibleViewport && rect) {\n const containerRect = normalizeRect(contentDiv.getBoundingClientRect());\n\n return !!containerRect && containerRect.top <= rect.top && visibleViewport.top <= rect.top;\n }\n\n return true;\n}\n\nfunction setTableMoverCursor(editor: IEditor, state: boolean, type?: 'move' | 'copy') {\n editor?.setEditorStyle(TABLE_MOVER_STYLE_KEY, state ? 'cursor: ' + type ?? 'move' : null);\n}\n\n/**\n * @internal\n * Exported for testing\n */\nexport function onDragStart(context: TableMoverContext): TableMoverInitValue {\n context.onStart();\n\n const { editor, table, div } = context;\n\n setTableMoverCursor(editor, true, 'move');\n\n // Create table outline rectangle\n const trect = table.getBoundingClientRect();\n const createElementData = {\n tag: 'div',\n style: 'position: fixed; user-select: none; border: 1px solid #808080',\n };\n const tableRect = createElement(createElementData, editor.getDocument()) as HTMLDivElement;\n tableRect.style.width = `${trect.width}px`;\n tableRect.style.height = `${trect.height}px`;\n tableRect.style.top = `${trect.top}px`;\n tableRect.style.left = `${trect.left}px`;\n div.parentNode?.appendChild(tableRect);\n\n // Get drag start selection\n const initialSelection = editor.getDOMSelection();\n\n // Get Table block in content model\n const cmTable = getCMTableFromTable(editor, table);\n\n return {\n cmTable,\n initialSelection,\n tableRect,\n };\n}\n\n/**\n * @internal\n * Exported for testing\n */\nexport function onDragging(\n context: TableMoverContext,\n event: MouseEvent,\n initValue: TableMoverInitValue\n) {\n const { tableRect } = initValue;\n const { editor } = context;\n\n // Move table outline rectangle\n tableRect.style.top = `${event.clientY + TABLE_MOVER_LENGTH}px`;\n tableRect.style.left = `${event.clientX + TABLE_MOVER_LENGTH}px`;\n\n const pos = getNodePositionFromEvent(editor, event.clientX, event.clientY);\n if (pos) {\n const range = editor.getDocument().createRange();\n range.setStart(pos.node, pos.offset);\n range.collapse(true);\n\n editor.setDOMSelection({ type: 'range', range, isReverted: false });\n return true;\n }\n return false;\n}\n\n/**\n * @internal\n * Exported for testing\n */\nexport function onDragEnd(\n context: TableMoverContext,\n event: MouseEvent,\n initValue: TableMoverInitValue | undefined\n) {\n const { editor, table, onFinishDragging: selectWholeTable, disableMovement } = context;\n const element = event.target;\n\n // Remove table outline rectangle\n initValue?.tableRect.remove();\n\n // Reset cursor\n setTableMoverCursor(editor, false);\n\n if (element == context.div) {\n // Table mover was only clicked, select whole table and do not dismiss the handler element.\n selectWholeTable(table);\n context.onEnd(false /* disposeHandler */);\n return true;\n } else {\n // Check if table was dragged on itself, element is not in editor, or movement is disabled\n if (\n table.contains(element as Node) ||\n !editor.getDOMHelper().isNodeInEditor(element as Node) ||\n disableMovement\n ) {\n editor.setDOMSelection(initValue?.initialSelection ?? null);\n context.onEnd(true /* disposeHandler */);\n return false;\n }\n\n let insertionSuccess: boolean = false;\n\n // Get position to insert table\n const insertPosition = getNodePositionFromEvent(editor, event.clientX, event.clientY);\n if (insertPosition) {\n // Move table to new position\n formatInsertPointWithContentModel(\n editor,\n insertPosition,\n (model, context, ip) => {\n // Remove old table\n const [oldTable, path] = getFirstSelectedTable(model);\n if (oldTable) {\n const index = path[0].blocks.indexOf(oldTable);\n mutateBlock(path[0]).blocks.splice(index, 1);\n }\n\n if (ip && initValue?.cmTable) {\n // Insert new table\n const doc: ShallowMutableContentModelDocument = createContentModelDocument();\n doc.blocks.push(oldTable ?? mutateBlock(initValue.cmTable));\n insertionSuccess = !!mergeModel(model, cloneModel(doc), context, {\n mergeFormat: 'none',\n insertPosition: ip,\n });\n\n if (insertionSuccess) {\n // After mergeModel, the new table should be selected\n const finalTable = getFirstSelectedTable(model)[0] ?? initValue.cmTable;\n if (finalTable) {\n // Add selection marker to the first cell of the table\n const firstCell = finalTable.rows[0].cells[0];\n const markerParagraph = firstCell?.blocks[0];\n\n if (markerParagraph?.blockType == 'Paragraph') {\n const marker = createSelectionMarker(model.format);\n\n mutateBlock(markerParagraph).segments.unshift(marker);\n setParagraphNotImplicit(markerParagraph);\n setSelection(model, marker);\n }\n }\n }\n return insertionSuccess;\n }\n },\n {\n // Select first cell of the old table\n selectionOverride: {\n type: 'table',\n firstColumn: 0,\n firstRow: 0,\n lastColumn: 0,\n lastRow: 0,\n table: table,\n },\n apiName: 'TableMover',\n }\n );\n } else {\n // No movement, restore initial selection\n editor.setDOMSelection(initValue?.initialSelection ?? null);\n }\n context.onEnd(true /* disposeHandler */);\n return insertionSuccess;\n }\n}\n"]}
@@ -0,0 +1,42 @@
1
+ import type { TableEditFeature } from './TableEditFeature';
2
+ import type { OnTableEditorCreatedCallback } from '../../OnTableEditorCreatedCallback';
3
+ import type { DOMSelection, IEditor, ParsedTable, ReadonlyContentModelTable } from 'roosterjs-content-model-types';
4
+ /**
5
+ * @internal
6
+ */
7
+ export declare function createTableRowColumnSelector(editor: IEditor, table: HTMLTableElement, isRowSelector: boolean, anchorContainer?: HTMLElement, onTableEditorCreated?: OnTableEditorCreatedCallback): TableEditFeature | null;
8
+ /**
9
+ * @internal
10
+ * Exported for testing
11
+ */
12
+ export interface TableRowColumnSelectorContext {
13
+ table: HTMLTableElement;
14
+ zoomScale: number;
15
+ editor: IEditor;
16
+ div: HTMLElement;
17
+ isRow: boolean;
18
+ }
19
+ /**
20
+ * @internal
21
+ */
22
+ export interface TableRowColumnSelectorInitValue {
23
+ cmTable: ReadonlyContentModelTable | undefined;
24
+ initialSelection: DOMSelection | null;
25
+ parsedTable: ParsedTable;
26
+ startIndex: number;
27
+ }
28
+ /**
29
+ * @internal
30
+ * Exported for testing
31
+ */
32
+ export declare function onDragStart(context: TableRowColumnSelectorContext, event: MouseEvent): TableRowColumnSelectorInitValue;
33
+ /**
34
+ * @internal
35
+ * Exported for testing
36
+ */
37
+ export declare function onDragging(context: TableRowColumnSelectorContext, event: MouseEvent, initValue: TableRowColumnSelectorInitValue | undefined): boolean;
38
+ /**
39
+ * @internal
40
+ * Exported for testing
41
+ */
42
+ export declare function onDragEnd(context: TableRowColumnSelectorContext, event: MouseEvent, initValue: TableRowColumnSelectorInitValue | undefined): boolean;
@@ -0,0 +1,221 @@
1
+ define(["require", "exports", "tslib", "../../../pluginUtils/CreateElement/createElement", "../../../pluginUtils/DragAndDrop/DragAndDropHelper", "roosterjs-content-model-dom"], function (require, exports, tslib_1, createElement_1, DragAndDropHelper_1, roosterjs_content_model_dom_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.onDragEnd = exports.onDragging = exports.onDragStart = exports.createTableRowColumnSelector = void 0;
5
+ var STABLE_DOWN_ARROW_CURSOR = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij48dGV4dCB4PSI4IiB5PSIxMiIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZm9udC1zaXplPSIxNCIgZmlsbD0iYmxhY2siPiYjMTI5MDk1OzwvdGV4dD48L3N2Zz4=';
6
+ var STABLE_RIGHT_ARROW_CURSOR = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij48dGV4dCB4PSI4IiB5PSIxMiIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZm9udC1zaXplPSIxNCIgZmlsbD0iYmxhY2siIHRyYW5zZm9ybT0icm90YXRlKC05MCA4IDgpIj4mIzEyOTA5NTs8L3RleHQ+PC9zdmc+';
7
+ /**
8
+ * @internal
9
+ */
10
+ function createTableRowColumnSelector(editor, table, isRowSelector, anchorContainer, onTableEditorCreated) {
11
+ var _a;
12
+ var doc = editor.getDocument();
13
+ var zoomScale = editor.getDOMHelper().calculateZoomScale();
14
+ var containerDiv = doc.createElement('div');
15
+ containerDiv.style.cssText = 'position: fixed; pointer-events: none;';
16
+ var cells = isRowSelector
17
+ ? Array.from(table.rows)
18
+ .map(function (row) { return row.cells[0]; })
19
+ .filter(function (cell) { return cell; })
20
+ : Array.from(((_a = table.rows[0]) === null || _a === void 0 ? void 0 : _a.cells) || []);
21
+ var handlers = [];
22
+ cells.forEach(function (cell) {
23
+ var cellRect = (0, roosterjs_content_model_dom_1.normalizeRect)(cell.getBoundingClientRect());
24
+ if (cellRect) {
25
+ var createElementData = getInsertElementData(cellRect, isRowSelector);
26
+ var cellDiv = (0, createElement_1.createElement)(createElementData, doc);
27
+ containerDiv.appendChild(cellDiv);
28
+ var context = {
29
+ table: table,
30
+ zoomScale: zoomScale,
31
+ editor: editor,
32
+ div: cellDiv,
33
+ isRow: isRowSelector,
34
+ };
35
+ var handler = new TableRowColumnSelectorHandler(cellDiv, isRowSelector, context, {
36
+ onDragStart: onDragStart,
37
+ onDragging: onDragging,
38
+ onDragEnd: onDragEnd,
39
+ }, zoomScale, onTableEditorCreated, editor.getEnvironment().isMobileOrTablet);
40
+ handlers.push(handler);
41
+ }
42
+ });
43
+ (anchorContainer || doc.body).appendChild(containerDiv);
44
+ var compositeHandler = {
45
+ dispose: function () {
46
+ handlers.forEach(function (h) { return h.dispose(); });
47
+ },
48
+ };
49
+ return { div: containerDiv, featureHandler: compositeHandler, node: table };
50
+ }
51
+ exports.createTableRowColumnSelector = createTableRowColumnSelector;
52
+ var TableRowColumnSelectorHandler = /** @class */ (function (_super) {
53
+ (0, tslib_1.__extends)(TableRowColumnSelectorHandler, _super);
54
+ function TableRowColumnSelectorHandler(div, isRow, context, handler, zoomScale, onTableEditorCreated, forceMobile) {
55
+ var _this = _super.call(this, div, context, function () { }, handler, zoomScale, forceMobile) || this;
56
+ _this.isRow = isRow;
57
+ _this.disposer = onTableEditorCreated === null || onTableEditorCreated === void 0 ? void 0 : onTableEditorCreated(_this.isRow ? 'TableRowSelector' : 'TableColumnSelector', div);
58
+ return _this;
59
+ }
60
+ TableRowColumnSelectorHandler.prototype.dispose = function () {
61
+ var _a;
62
+ (_a = this.disposer) === null || _a === void 0 ? void 0 : _a.call(this);
63
+ this.disposer = undefined;
64
+ };
65
+ return TableRowColumnSelectorHandler;
66
+ }(DragAndDropHelper_1.DragAndDropHelper));
67
+ /**
68
+ * @internal
69
+ * Helper function to calculate current row/column index from mouse coordinates during drag
70
+ */
71
+ function getCurrentIndexFromMouse(table, x, y, isRow) {
72
+ if (isRow) {
73
+ for (var i = 0; i < table.rows.length; i++) {
74
+ var row = table.rows[i];
75
+ for (var j = 0; j < row.cells.length; j++) {
76
+ var cell = row.cells[j];
77
+ var cellRect = (0, roosterjs_content_model_dom_1.normalizeRect)(cell.getBoundingClientRect());
78
+ if (cellRect && y >= cellRect.top && y <= cellRect.bottom) {
79
+ return i;
80
+ }
81
+ }
82
+ }
83
+ return Math.max(0, table.rows.length - 1);
84
+ }
85
+ else {
86
+ if (!table.rows[0]) {
87
+ return 0;
88
+ }
89
+ var firstRow = table.rows[0];
90
+ for (var i = 0; i < firstRow.cells.length; i++) {
91
+ var cell = firstRow.cells[i];
92
+ var cellRect = (0, roosterjs_content_model_dom_1.normalizeRect)(cell.getBoundingClientRect());
93
+ if (cellRect && x >= cellRect.left && x <= cellRect.right) {
94
+ return i;
95
+ }
96
+ }
97
+ return firstRow.cells.length - 1;
98
+ }
99
+ }
100
+ /**
101
+ * @internal
102
+ * Exported for testing
103
+ */
104
+ function onDragStart(context, event) {
105
+ var table = context.table, editor = context.editor, isRow = context.isRow;
106
+ editor.setDOMSelection(null);
107
+ var parsedTable = (0, roosterjs_content_model_dom_1.parseTableCells)(table);
108
+ var startIndex = getCurrentIndexFromMouse(table, event.clientX, event.clientY, isRow);
109
+ if (isRow) {
110
+ var columnNumber = parsedTable[startIndex].length - 1;
111
+ var initialSelection = {
112
+ type: 'table',
113
+ table: table,
114
+ firstRow: startIndex,
115
+ lastRow: startIndex,
116
+ firstColumn: 0,
117
+ lastColumn: columnNumber,
118
+ };
119
+ return {
120
+ cmTable: undefined,
121
+ initialSelection: initialSelection,
122
+ parsedTable: parsedTable,
123
+ startIndex: startIndex,
124
+ };
125
+ }
126
+ else {
127
+ var rowNumber = parsedTable.length - 1;
128
+ var initialSelection = {
129
+ type: 'table',
130
+ table: table,
131
+ firstRow: 0,
132
+ lastRow: rowNumber,
133
+ firstColumn: startIndex,
134
+ lastColumn: startIndex,
135
+ };
136
+ return {
137
+ cmTable: undefined,
138
+ initialSelection: initialSelection,
139
+ parsedTable: parsedTable,
140
+ startIndex: startIndex,
141
+ };
142
+ }
143
+ }
144
+ exports.onDragStart = onDragStart;
145
+ /**
146
+ * @internal
147
+ * Exported for testing
148
+ */
149
+ function onDragging(context, event, initValue) {
150
+ if (!initValue) {
151
+ return false;
152
+ }
153
+ var table = context.table, editor = context.editor, isRow = context.isRow;
154
+ var parsedTable = initValue.parsedTable, startIndex = initValue.startIndex;
155
+ var currentIndex = getCurrentIndexFromMouse(table, event.clientX, event.clientY, isRow);
156
+ if (isRow) {
157
+ var columnNumber = parsedTable[startIndex].length - 1;
158
+ var firstRow = Math.min(startIndex, currentIndex);
159
+ var lastRow = Math.max(startIndex, currentIndex);
160
+ editor.setDOMSelection({
161
+ type: 'table',
162
+ table: table,
163
+ firstRow: firstRow,
164
+ firstColumn: 0,
165
+ lastRow: lastRow,
166
+ lastColumn: columnNumber,
167
+ });
168
+ }
169
+ else {
170
+ var firstColumn = Math.min(startIndex, currentIndex);
171
+ var lastColumn = Math.max(startIndex, currentIndex);
172
+ var rowNumber = parsedTable.length - 1;
173
+ editor.setDOMSelection({
174
+ type: 'table',
175
+ table: table,
176
+ firstRow: 0,
177
+ firstColumn: firstColumn,
178
+ lastColumn: lastColumn,
179
+ lastRow: rowNumber,
180
+ });
181
+ }
182
+ return true;
183
+ }
184
+ exports.onDragging = onDragging;
185
+ /**
186
+ * @internal
187
+ * Exported for testing
188
+ */
189
+ function onDragEnd(context, event, initValue) {
190
+ if (!initValue) {
191
+ return false;
192
+ }
193
+ var editor = context.editor;
194
+ var selection = editor.getDOMSelection();
195
+ if ((selection === null || selection === void 0 ? void 0 : selection.type) !== 'table') {
196
+ editor.setDOMSelection(initValue.initialSelection);
197
+ }
198
+ return true;
199
+ }
200
+ exports.onDragEnd = onDragEnd;
201
+ function getInsertElementData(rect, isRowSelector) {
202
+ var MIN_DISTANCE_FROM_BOUNDARY = 5;
203
+ var GAP_FROM_CELL = 5;
204
+ var cellLength = isRowSelector ? rect.bottom - rect.top : rect.right - rect.left;
205
+ var maxSelectorSize = Math.max(16, cellLength - MIN_DISTANCE_FROM_BOUNDARY * 2);
206
+ var SELECTOR_SIZE = cellLength >= 32 ? Math.min(cellLength - 16, maxSelectorSize) : 16;
207
+ var centerOffset = (cellLength - SELECTOR_SIZE) / 2;
208
+ var size = isRowSelector
209
+ ? "width: 5px; height: " + SELECTOR_SIZE + "px; top: " + (rect.top + centerOffset) + "px; left: " + (rect.left - 5 - GAP_FROM_CELL) + "px"
210
+ : "width: " + SELECTOR_SIZE + "px; height: 5px; top: " + (rect.top - 5 - GAP_FROM_CELL) + "px; left: " + (rect.left + centerOffset) + "px";
211
+ var cursor = isRowSelector
212
+ ? "url(\"" + STABLE_RIGHT_ARROW_CURSOR + "\"), auto"
213
+ : "url(\"" + STABLE_DOWN_ARROW_CURSOR + "\") , auto";
214
+ var outerDivStyle = "position: fixed; " + size + "; background-color: transparent; cursor: " + cursor + "; pointer-events: auto;";
215
+ return {
216
+ tag: 'div',
217
+ style: outerDivStyle,
218
+ };
219
+ }
220
+ });
221
+ //# sourceMappingURL=TableRowColumnSelector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableRowColumnSelector.js","sourceRoot":"","sources":["../../../../../../packages/roosterjs-content-model-plugins/lib/tableEdit/editors/features/TableRowColumnSelector.ts"],"names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GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,UAAU,GAAG,0BAA0B,GAAG,CAAC,CAAC,CAAC;QAClF,IAAM,aAAa,GAAG,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,GAAG,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAEzF,IAAM,YAAY,GAAG,CAAC,UAAU,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;QAEtD,IAAM,IAAI,GAAG,aAAa;YACtB,CAAC,CAAC,yBAAuB,aAAa,kBAAY,IAAI,CAAC,GAAG,GAAG,YAAY,oBACnE,IAAI,CAAC,IAAI,GAAG,CAAC,GAAG,aAAa,QAC7B;YACN,CAAC,CAAC,YAAU,aAAa,+BAAyB,IAAI,CAAC,GAAG,GAAG,CAAC,GAAG,aAAa,oBACxE,IAAI,CAAC,IAAI,GAAG,YAAY,QACxB,CAAC;QAEX,IAAM,MAAM,GAAG,aAAa;YACxB,CAAC,CAAC,WAAQ,yBAAyB,cAAU;YAC7C,CAAC,CAAC,WAAQ,wBAAwB,eAAW,CAAC;QAElD,IAAM,aAAa,GAAG,sBAAoB,IAAI,iDAA4C,MAAM,4BAAyB,CAAC;QAC1H,OAAO;YACH,GAAG,EAAE,KAAK;YACV,KAAK,EAAE,aAAa;SACvB,CAAC;IACN,CAAC","sourcesContent":["import { createElement } from '../../../pluginUtils/CreateElement/createElement';\nimport { DragAndDropHelper } from '../../../pluginUtils/DragAndDrop/DragAndDropHelper';\nimport { normalizeRect, parseTableCells } from 'roosterjs-content-model-dom';\nimport type { CreateElementData } from '../../../pluginUtils/CreateElement/CreateElementData';\nimport type { DragAndDropHandler } from '../../../pluginUtils/DragAndDrop/DragAndDropHandler';\nimport type { Disposable } from '../../../pluginUtils/Disposable';\nimport type { TableEditFeature } from './TableEditFeature';\nimport type { OnTableEditorCreatedCallback } from '../../OnTableEditorCreatedCallback';\nimport type {\n DOMSelection,\n IEditor,\n ParsedTable,\n ReadonlyContentModelTable,\n Rect,\n TableSelection,\n} from 'roosterjs-content-model-types';\n\nconst STABLE_DOWN_ARROW_CURSOR =\n 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij48dGV4dCB4PSI4IiB5PSIxMiIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZm9udC1zaXplPSIxNCIgZmlsbD0iYmxhY2siPiYjMTI5MDk1OzwvdGV4dD48L3N2Zz4=';\n\nconst STABLE_RIGHT_ARROW_CURSOR =\n 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij48dGV4dCB4PSI4IiB5PSIxMiIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZm9udC1zaXplPSIxNCIgZmlsbD0iYmxhY2siIHRyYW5zZm9ybT0icm90YXRlKC05MCA4IDgpIj4mIzEyOTA5NTs8L3RleHQ+PC9zdmc+';\n\n/**\n * @internal\n */\nexport function createTableRowColumnSelector(\n editor: IEditor,\n table: HTMLTableElement,\n isRowSelector: boolean,\n anchorContainer?: HTMLElement,\n onTableEditorCreated?: OnTableEditorCreatedCallback\n): TableEditFeature | null {\n const doc = editor.getDocument();\n const zoomScale = editor.getDOMHelper().calculateZoomScale();\n\n const containerDiv = doc.createElement('div');\n containerDiv.style.cssText = 'position: fixed; pointer-events: none;';\n\n const cells = isRowSelector\n ? Array.from(table.rows)\n .map(row => row.cells[0])\n .filter(cell => cell)\n : Array.from(table.rows[0]?.cells || []);\n\n const handlers: TableRowColumnSelectorHandler[] = [];\n\n cells.forEach(cell => {\n const cellRect = normalizeRect(cell.getBoundingClientRect());\n if (cellRect) {\n const createElementData = getInsertElementData(cellRect, isRowSelector);\n const cellDiv = createElement(createElementData, doc) as HTMLDivElement;\n containerDiv.appendChild(cellDiv);\n\n const context: TableRowColumnSelectorContext = {\n table,\n zoomScale,\n editor,\n div: cellDiv,\n isRow: isRowSelector,\n };\n\n const handler = new TableRowColumnSelectorHandler(\n cellDiv,\n isRowSelector,\n context,\n {\n onDragStart,\n onDragging,\n onDragEnd,\n },\n zoomScale,\n onTableEditorCreated,\n editor.getEnvironment().isMobileOrTablet\n );\n handlers.push(handler);\n }\n });\n\n (anchorContainer || doc.body).appendChild(containerDiv);\n\n const compositeHandler: Disposable = {\n dispose: () => {\n handlers.forEach(h => h.dispose());\n },\n };\n\n return { div: containerDiv, featureHandler: compositeHandler, node: table };\n}\n\n/**\n * @internal\n * Exported for testing\n */\nexport interface TableRowColumnSelectorContext {\n table: HTMLTableElement;\n zoomScale: number;\n editor: IEditor;\n div: HTMLElement;\n isRow: boolean;\n}\n\n/**\n * @internal\n */\nexport interface TableRowColumnSelectorInitValue {\n cmTable: ReadonlyContentModelTable | undefined;\n initialSelection: DOMSelection | null;\n parsedTable: ParsedTable;\n startIndex: number;\n}\n\nclass TableRowColumnSelectorHandler\n extends DragAndDropHelper<TableRowColumnSelectorContext, TableRowColumnSelectorInitValue>\n implements Disposable {\n private disposer: undefined | (() => void);\n constructor(\n div: HTMLDivElement,\n private isRow: boolean,\n context: TableRowColumnSelectorContext,\n handler: DragAndDropHandler<TableRowColumnSelectorContext, TableRowColumnSelectorInitValue>,\n zoomScale: number,\n onTableEditorCreated?: OnTableEditorCreatedCallback,\n forceMobile?: boolean | undefined\n ) {\n super(div, context, () => {}, handler, zoomScale, forceMobile);\n this.disposer = onTableEditorCreated?.(\n this.isRow ? 'TableRowSelector' : 'TableColumnSelector',\n div\n );\n }\n\n dispose() {\n this.disposer?.();\n this.disposer = undefined;\n }\n}\n\n/**\n * @internal\n * Helper function to calculate current row/column index from mouse coordinates during drag\n */\nfunction getCurrentIndexFromMouse(\n table: HTMLTableElement,\n x: number,\n y: number,\n isRow: boolean\n): number {\n if (isRow) {\n for (let i = 0; i < table.rows.length; i++) {\n const row = table.rows[i];\n\n for (let j = 0; j < row.cells.length; j++) {\n const cell = row.cells[j];\n const cellRect = normalizeRect(cell.getBoundingClientRect());\n if (cellRect && y >= cellRect.top && y <= cellRect.bottom) {\n return i;\n }\n }\n }\n return Math.max(0, table.rows.length - 1);\n } else {\n if (!table.rows[0]) {\n return 0;\n }\n const firstRow = table.rows[0];\n for (let i = 0; i < firstRow.cells.length; i++) {\n const cell = firstRow.cells[i];\n const cellRect = normalizeRect(cell.getBoundingClientRect());\n if (cellRect && x >= cellRect.left && x <= cellRect.right) {\n return i;\n }\n }\n return firstRow.cells.length - 1;\n }\n}\n\n/**\n * @internal\n * Exported for testing\n */\nexport function onDragStart(\n context: TableRowColumnSelectorContext,\n event: MouseEvent\n): TableRowColumnSelectorInitValue {\n const { table, editor, isRow } = context;\n editor.setDOMSelection(null);\n\n const parsedTable = parseTableCells(table);\n\n const startIndex = getCurrentIndexFromMouse(table, event.clientX, event.clientY, isRow);\n\n if (isRow) {\n const columnNumber = parsedTable[startIndex].length - 1;\n const initialSelection: TableSelection = {\n type: 'table',\n table,\n firstRow: startIndex,\n lastRow: startIndex,\n firstColumn: 0,\n lastColumn: columnNumber,\n };\n\n return {\n cmTable: undefined,\n initialSelection,\n\n parsedTable,\n startIndex,\n };\n } else {\n const rowNumber = parsedTable.length - 1;\n const initialSelection: TableSelection = {\n type: 'table',\n table,\n firstRow: 0,\n lastRow: rowNumber,\n firstColumn: startIndex,\n lastColumn: startIndex,\n };\n\n return {\n cmTable: undefined,\n initialSelection,\n\n parsedTable,\n startIndex,\n };\n }\n}\n\n/**\n * @internal\n * Exported for testing\n */\nexport function onDragging(\n context: TableRowColumnSelectorContext,\n event: MouseEvent,\n initValue: TableRowColumnSelectorInitValue | undefined\n): boolean {\n if (!initValue) {\n return false;\n }\n\n const { table, editor, isRow } = context;\n const { parsedTable, startIndex } = initValue;\n\n const currentIndex = getCurrentIndexFromMouse(table, event.clientX, event.clientY, isRow);\n\n if (isRow) {\n const columnNumber = parsedTable[startIndex].length - 1;\n const firstRow = Math.min(startIndex, currentIndex);\n const lastRow = Math.max(startIndex, currentIndex);\n\n editor.setDOMSelection({\n type: 'table',\n table: table,\n firstRow,\n firstColumn: 0,\n lastRow,\n lastColumn: columnNumber,\n });\n } else {\n const firstColumn = Math.min(startIndex, currentIndex);\n const lastColumn = Math.max(startIndex, currentIndex);\n const rowNumber = parsedTable.length - 1;\n\n editor.setDOMSelection({\n type: 'table',\n table: table,\n firstRow: 0,\n firstColumn,\n lastColumn,\n lastRow: rowNumber,\n });\n }\n\n return true;\n}\n\n/**\n * @internal\n * Exported for testing\n */\nexport function onDragEnd(\n context: TableRowColumnSelectorContext,\n event: MouseEvent,\n initValue: TableRowColumnSelectorInitValue | undefined\n): boolean {\n if (!initValue) {\n return false;\n }\n\n const { editor } = context;\n const selection = editor.getDOMSelection();\n\n if (selection?.type !== 'table') {\n editor.setDOMSelection(initValue.initialSelection);\n }\n\n return true;\n}\n\nfunction getInsertElementData(rect: Rect, isRowSelector: boolean): CreateElementData {\n const MIN_DISTANCE_FROM_BOUNDARY = 5;\n const GAP_FROM_CELL = 5;\n const cellLength = isRowSelector ? rect.bottom - rect.top : rect.right - rect.left;\n\n const maxSelectorSize = Math.max(16, cellLength - MIN_DISTANCE_FROM_BOUNDARY * 2);\n const SELECTOR_SIZE = cellLength >= 32 ? Math.min(cellLength - 16, maxSelectorSize) : 16;\n\n const centerOffset = (cellLength - SELECTOR_SIZE) / 2;\n\n const size = isRowSelector\n ? `width: 5px; height: ${SELECTOR_SIZE}px; top: ${rect.top + centerOffset}px; left: ${\n rect.left - 5 - GAP_FROM_CELL\n }px`\n : `width: ${SELECTOR_SIZE}px; height: 5px; top: ${rect.top - 5 - GAP_FROM_CELL}px; left: ${\n rect.left + centerOffset\n }px`;\n\n const cursor = isRowSelector\n ? `url(\"${STABLE_RIGHT_ARROW_CURSOR}\"), auto`\n : `url(\"${STABLE_DOWN_ARROW_CURSOR}\") , auto`;\n\n const outerDivStyle = `position: fixed; ${size}; background-color: transparent; cursor: ${cursor}; pointer-events: auto;`;\n return {\n tag: 'div',\n style: outerDivStyle,\n };\n}\n"]}
@@ -11,6 +11,7 @@ define(["require", "exports", "roosterjs-content-model-dom"], function (require,
11
11
  var context = (0, roosterjs_content_model_dom_1.createDomToModelContext)({
12
12
  zoomScale: editor.getDOMHelper().calculateZoomScale(),
13
13
  recalculateTableSize: true,
14
+ allowCacheElement: true, // We need this cache so we can retrieve TD element and update TD width and height when resizing table
14
15
  });
15
16
  context.elementProcessors.element(model, table, context);
16
17
  var firstBlock = model.blocks[0];
@@ -1 +1 @@
1
- {"version":3,"file":"getTableFromContentModel.js","sourceRoot":"","sources":["../../../../../../packages/roosterjs-content-model-plugins/lib/tableEdit/editors/utils/getTableFromContentModel.ts"],"names":[],"mappings":";;;;IAGA;;;OAGG;IACH,SAAgB,mBAAmB,CAAC,MAAe,EAAE,KAAuB;QACxE,IAAM,KAAK,GAAG,IAAA,wDAA0B,GAAE,CAAC;QAC3C,IAAM,OAAO,GAAG,IAAA,qDAAuB,EAAC;YACpC,SAAS,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC,kBAAkB,EAAE;YACrD,oBAAoB,EAAE,IAAI;SAC7B,CAAC,CAAC;QAEH,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAEzD,IAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAEnC,OAAO,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,SAAS,KAAI,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;IACrE,CAAC;IAZD,kDAYC","sourcesContent":["import { createContentModelDocument, createDomToModelContext } from 'roosterjs-content-model-dom';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Get ContentModelTable from a table element if it is present in the content model\n */\nexport function getCMTableFromTable(editor: IEditor, table: HTMLTableElement) {\n const model = createContentModelDocument();\n const context = createDomToModelContext({\n zoomScale: editor.getDOMHelper().calculateZoomScale(),\n recalculateTableSize: true,\n });\n\n context.elementProcessors.element(model, table, context);\n\n const firstBlock = model.blocks[0];\n\n return firstBlock?.blockType == 'Table' ? firstBlock : undefined;\n}\n"]}
1
+ {"version":3,"file":"getTableFromContentModel.js","sourceRoot":"","sources":["../../../../../../packages/roosterjs-content-model-plugins/lib/tableEdit/editors/utils/getTableFromContentModel.ts"],"names":[],"mappings":";;;;IAGA;;;OAGG;IACH,SAAgB,mBAAmB,CAAC,MAAe,EAAE,KAAuB;QACxE,IAAM,KAAK,GAAG,IAAA,wDAA0B,GAAE,CAAC;QAC3C,IAAM,OAAO,GAAG,IAAA,qDAAuB,EAAC;YACpC,SAAS,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC,kBAAkB,EAAE;YACrD,oBAAoB,EAAE,IAAI;YAC1B,iBAAiB,EAAE,IAAI,EAAE,sGAAsG;SAClI,CAAC,CAAC;QAEH,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAEzD,IAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAEnC,OAAO,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,SAAS,KAAI,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;IACrE,CAAC;IAbD,kDAaC","sourcesContent":["import { createContentModelDocument, createDomToModelContext } from 'roosterjs-content-model-dom';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Get ContentModelTable from a table element if it is present in the content model\n */\nexport function getCMTableFromTable(editor: IEditor, table: HTMLTableElement) {\n const model = createContentModelDocument();\n const context = createDomToModelContext({\n zoomScale: editor.getDOMHelper().calculateZoomScale(),\n recalculateTableSize: true,\n allowCacheElement: true, // We need this cache so we can retrieve TD element and update TD width and height when resizing table\n });\n\n context.elementProcessors.element(model, table, context);\n\n const firstBlock = model.blocks[0];\n\n return firstBlock?.blockType == 'Table' ? firstBlock : undefined;\n}\n"]}
@@ -50,7 +50,7 @@ define(["require", "exports", "../utils/getNodePositionFromEvent"], function (re
50
50
  */
51
51
  TouchPlugin.prototype.onPluginEvent = function (event) {
52
52
  var _this = this;
53
- var _a, _b, _c, _d;
53
+ var _a, _b, _c;
54
54
  if (!this.editor) {
55
55
  return;
56
56
  }
@@ -59,57 +59,59 @@ define(["require", "exports", "../utils/getNodePositionFromEvent"], function (re
59
59
  this.isDblClicked = false;
60
60
  this.isTouchPenPointerEvent = true;
61
61
  event.originalEvent.preventDefault();
62
- var targetWindow = ((_a = this.editor.getDocument()) === null || _a === void 0 ? void 0 : _a.defaultView) || window;
63
- if (this.timer) {
64
- targetWindow.clearTimeout(this.timer);
65
- }
66
- this.timer = targetWindow.setTimeout(function () {
67
- _this.timer = 0;
68
- if (_this.editor) {
69
- if (!_this.isDblClicked) {
70
- _this.editor.focus();
71
- var caretPosition = (0, getNodePositionFromEvent_1.getNodePositionFromEvent)(_this.editor, event.rawEvent.x, event.rawEvent.y);
72
- var newRange = _this.editor.getDocument().createRange();
73
- if (caretPosition) {
74
- var node = caretPosition.node, offset = caretPosition.offset;
75
- // Place cursor at same position of browser handler by default
76
- newRange.setStart(node, offset);
77
- newRange.setEnd(node, offset);
78
- var nodeTextContent = node.textContent || '';
79
- var charAtSelection = nodeTextContent[offset];
80
- if (node.nodeType === Node.TEXT_NODE &&
81
- charAtSelection &&
82
- !SPACE_MATCHING_REGEX.test(charAtSelection) &&
83
- !PUNCTUATION_MATCHING_REGEX.test(charAtSelection)) {
84
- var _a = findWordBoundaries(nodeTextContent, offset), wordStart = _a.wordStart, wordEnd = _a.wordEnd;
85
- // Move cursor to the calculated offset
86
- var leftCursorWordLength = offset - wordStart;
87
- var rightCursorWordLength = wordEnd - offset;
88
- var movingOffset = leftCursorWordLength >= rightCursorWordLength
89
- ? rightCursorWordLength
90
- : -leftCursorWordLength;
91
- movingOffset =
92
- Math.abs(movingOffset) > MAX_TOUCH_MOVE_DISTANCE
93
- ? 0
94
- : movingOffset;
95
- var newOffsetPosition = offset + movingOffset;
96
- if (movingOffset !== 0 &&
97
- nodeTextContent.length >= newOffsetPosition) {
98
- newRange.setStart(node, newOffsetPosition);
99
- newRange.setEnd(node, newOffsetPosition);
62
+ var targetWindow = this.editor.getDocument().defaultView;
63
+ if (targetWindow) {
64
+ if (this.timer) {
65
+ targetWindow.clearTimeout(this.timer);
66
+ }
67
+ this.timer = targetWindow.setTimeout(function () {
68
+ _this.timer = 0;
69
+ if (_this.editor) {
70
+ if (!_this.isDblClicked) {
71
+ _this.editor.focus();
72
+ var caretPosition = (0, getNodePositionFromEvent_1.getNodePositionFromEvent)(_this.editor, event.rawEvent.x, event.rawEvent.y);
73
+ var newRange = _this.editor.getDocument().createRange();
74
+ if (caretPosition) {
75
+ var node = caretPosition.node, offset = caretPosition.offset;
76
+ // Place cursor at same position of browser handler by default
77
+ newRange.setStart(node, offset);
78
+ newRange.setEnd(node, offset);
79
+ var nodeTextContent = node.textContent || '';
80
+ var charAtSelection = nodeTextContent[offset];
81
+ if (node.nodeType === Node.TEXT_NODE &&
82
+ charAtSelection &&
83
+ !SPACE_MATCHING_REGEX.test(charAtSelection) &&
84
+ !PUNCTUATION_MATCHING_REGEX.test(charAtSelection)) {
85
+ var _a = findWordBoundaries(nodeTextContent, offset), wordStart = _a.wordStart, wordEnd = _a.wordEnd;
86
+ // Move cursor to the calculated offset
87
+ var leftCursorWordLength = offset - wordStart;
88
+ var rightCursorWordLength = wordEnd - offset;
89
+ var movingOffset = leftCursorWordLength >= rightCursorWordLength
90
+ ? rightCursorWordLength
91
+ : -leftCursorWordLength;
92
+ movingOffset =
93
+ Math.abs(movingOffset) > MAX_TOUCH_MOVE_DISTANCE
94
+ ? 0
95
+ : movingOffset;
96
+ var newOffsetPosition = offset + movingOffset;
97
+ if (movingOffset !== 0 &&
98
+ nodeTextContent.length >= newOffsetPosition) {
99
+ newRange.setStart(node, newOffsetPosition);
100
+ newRange.setEnd(node, newOffsetPosition);
101
+ }
100
102
  }
101
103
  }
104
+ _this.editor.setDOMSelection({
105
+ type: 'range',
106
+ range: newRange,
107
+ isReverted: false,
108
+ });
109
+ // reset values
110
+ _this.isTouchPenPointerEvent = false;
102
111
  }
103
- _this.editor.setDOMSelection({
104
- type: 'range',
105
- range: newRange,
106
- isReverted: false,
107
- });
108
- // reset values
109
- _this.isTouchPenPointerEvent = false;
110
112
  }
111
- }
112
- }, POINTER_DETECTION_DELAY);
113
+ }, POINTER_DETECTION_DELAY);
114
+ }
113
115
  break;
114
116
  case 'doubleClick':
115
117
  if (this.isTouchPenPointerEvent) {
@@ -125,7 +127,7 @@ define(["require", "exports", "../utils/getNodePositionFromEvent"], function (re
125
127
  var char = nodeTextContent.charAt(offset);
126
128
  // Check if the clicked character is a punctuation mark, then highlight that character only
127
129
  if (PUNCTUATION_MATCHING_REGEX.test(char)) {
128
- var newRange = (_b = this.editor.getDocument()) === null || _b === void 0 ? void 0 : _b.createRange();
130
+ var newRange = (_a = this.editor.getDocument()) === null || _a === void 0 ? void 0 : _a.createRange();
129
131
  if (newRange) {
130
132
  newRange.setStart(node, offset);
131
133
  newRange.setEnd(node, offset + 1);
@@ -147,7 +149,7 @@ define(["require", "exports", "../utils/getNodePositionFromEvent"], function (re
147
149
  SPACE_MATCHING_REGEX.test(nodeTextContent.charAt(start - 1))) {
148
150
  start--;
149
151
  }
150
- var newRange = (_c = this.editor.getDocument()) === null || _c === void 0 ? void 0 : _c.createRange();
152
+ var newRange = (_b = this.editor.getDocument()) === null || _b === void 0 ? void 0 : _b.createRange();
151
153
  if (newRange) {
152
154
  newRange.setStart(node, start);
153
155
  newRange.setEnd(node, start + 1);
@@ -160,8 +162,8 @@ define(["require", "exports", "../utils/getNodePositionFromEvent"], function (re
160
162
  }
161
163
  }
162
164
  else {
163
- var _e = findWordBoundaries(nodeTextContent, offset), wordStart = _e.wordStart, wordEnd = _e.wordEnd;
164
- var newRange = (_d = this.editor.getDocument()) === null || _d === void 0 ? void 0 : _d.createRange();
165
+ var _d = findWordBoundaries(nodeTextContent, offset), wordStart = _d.wordStart, wordEnd = _d.wordEnd;
166
+ var newRange = (_c = this.editor.getDocument()) === null || _c === void 0 ? void 0 : _c.createRange();
165
167
  if (newRange) {
166
168
  newRange.setStart(node, wordStart);
167
169
  newRange.setEnd(node, wordEnd);