@widergy/energy-ui 3.192.2 → 3.193.0
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/CHANGELOG.md +33 -4
- package/dist/components/UTRichText/index.js +1 -1
- package/dist/components/UTRichText/modules/table/TableHandles.js +1 -0
- package/dist/components/UTRichText/modules/table/TableMenu/index.js +1 -0
- package/dist/components/UTRichText/modules/table/TableMenu/styles.module.scss +75 -0
- package/dist/components/UTRichText/modules/table/TableMenuOverlay.js +1 -0
- package/dist/components/UTRichText/modules/table/ToolbarButton.js +1 -1
- package/dist/components/UTRichText/modules/table/actions.js +1 -0
- package/dist/components/UTRichText/modules/table/autoScroll.js +1 -0
- package/dist/components/UTRichText/modules/table/columnWidths.js +1 -0
- package/dist/components/UTRichText/modules/table/dragGhost.js +1 -0
- package/dist/components/UTRichText/modules/table/dragHandle.js +1 -0
- package/dist/components/UTRichText/modules/table/emailStyles.js +1 -0
- package/dist/components/UTRichText/modules/table/extensions.js +1 -1
- package/dist/components/UTRichText/modules/table/guideLine.js +1 -0
- package/dist/components/UTRichText/modules/table/index.js +1 -1
- package/dist/components/UTRichText/modules/table/menu.js +1 -0
- package/dist/components/UTRichText/modules/table/pm.js +1 -0
- package/dist/components/UTRichText/modules/table/rowResizing.js +1 -0
- package/dist/components/UTRichText/modules/table/selection.js +1 -0
- package/dist/components/UTRichText/styles.module.scss +156 -10
- package/dist/components/UTRichText/utils/contentBuilders.js +1 -1
- package/dist/constants/testIds.js +1 -1
- package/dist/esm/components/UTRichText/index.js +1 -1
- package/dist/esm/components/UTRichText/modules/table/TableHandles.js +1 -0
- package/dist/esm/components/UTRichText/modules/table/TableMenu/index.js +1 -0
- package/dist/esm/components/UTRichText/modules/table/TableMenu/styles.module.scss +75 -0
- package/dist/esm/components/UTRichText/modules/table/TableMenuOverlay.js +1 -0
- package/dist/esm/components/UTRichText/modules/table/ToolbarButton.js +1 -1
- package/dist/esm/components/UTRichText/modules/table/actions.js +1 -0
- package/dist/esm/components/UTRichText/modules/table/autoScroll.js +1 -0
- package/dist/esm/components/UTRichText/modules/table/columnWidths.js +1 -0
- package/dist/esm/components/UTRichText/modules/table/dragGhost.js +1 -0
- package/dist/esm/components/UTRichText/modules/table/dragHandle.js +1 -0
- package/dist/esm/components/UTRichText/modules/table/emailStyles.js +1 -0
- package/dist/esm/components/UTRichText/modules/table/extensions.js +1 -1
- package/dist/esm/components/UTRichText/modules/table/guideLine.js +1 -0
- package/dist/esm/components/UTRichText/modules/table/index.js +1 -1
- package/dist/esm/components/UTRichText/modules/table/menu.js +1 -0
- package/dist/esm/components/UTRichText/modules/table/pm.js +1 -0
- package/dist/esm/components/UTRichText/modules/table/rowResizing.js +1 -0
- package/dist/esm/components/UTRichText/modules/table/selection.js +1 -0
- package/dist/esm/components/UTRichText/styles.module.scss +156 -10
- package/dist/esm/components/UTRichText/utils/contentBuilders.js +1 -1
- package/dist/esm/constants/testIds.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/utils/hooks/useCSSVariables/dimensionTokens.js +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/hooks/useCSSVariables/dimensionTokens.js +1 -1
- package/package.json +5 -1
- package/dist/components/UTRichText/modules/table/TableToolbar/index.js +0 -1
- package/dist/components/UTRichText/modules/table/TableToolbar/styles.module.scss +0 -13
- package/dist/esm/components/UTRichText/modules/table/TableToolbar/index.js +0 -1
- package/dist/esm/components/UTRichText/modules/table/TableToolbar/styles.module.scss +0 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TEST_IDS=exports.ID_CONSTANTS=void 0;const ID_CONSTANTS=exports.ID_CONSTANTS={ACTIONS:"actions",ADD_FILTER_BUTTON:"addFilterButton",AVATAR:"avatar",BOTTOM_NAV:"bottomNav",CANVAS:"canvas",CELL:"cell",CLEAR_BUTTON:"clearButton",CLIENT_FILTER:"clientFilter",COLLAPSED_PANEL_CONTENT:"collapsedPanelContent",COLLAPSE_BUTTON:"collapseButton",COLLAPSE_BUTTON_TOOLTIP:"collapseButtonTooltip",CREDIT_CARD:"creditCard",CUSTOM_SEARCH_ACTION:"customSearchAction",DATA_CATEGORY:"dataCategory",DATA_ELEMENT:"dataElement",DELETE_BUTTON:"deleteButton",DELETE_BUTTON_TOOLTIP:"deleteButtonTooltip",ADDITIONAL_CONTENT:"additionalContent",ADDITIONAL_CONTENT_BODY:"additionalContentBody",DESCRIPTION:"description",DIALOG:"dialog",EDIT_BUTTON:"editButton",EDIT_BUTTON_TOOLTIP:"editButtonTooltip",EXPANDED_PANEL_CONTENT:"expandedPanelContent",EXPANDED_PANEL_CONTENT_CATEGORY:"expandedPanelContentCategory",EXPANDED_PANEL_CONTENT_CATEGORY_EMPTY:"expandedPanelContentCategoryEmpty",EXPANDED_PANEL_CONTENT_CATEGORY_HEADER:"expandedPanelContentCategoryHeader",EXPANDED_PANEL_CONTENT_CATEGORY_ITEM:"expandedPanelContentCategoryItem",EXPANDED_PANEL_CONTENT_HEADER:"expandedPanelContentHeader",EXPAND_BUTTON:"expandButton",FILTER_GROUPING:"filterGrouping",GROUPING_PANEL:"groupingPanel",HEADER:"header",HELP_TEXT:"helpText",ICON:"icon",INVALID_PARAMS:"invalidParams",LABEL:"label",MAIN_BUTTON:"mainButton",NAME:"name",NAME_CONTAINER:"nameContainer",ONBOARDING:"onboarding",PAGINATION_NEXT:"paginationNext",PAGINATION_PREV:"paginationPrev",PANEL:"panel",PERSISTENT_FILTER:"persistentFilter",PINNED:"pinned",POPPER:"popper",SEARCH_BUTTON:"searchButton",SECONDARY_ACTION:"secondaryAction",SEARCH_BUTTON_TOOLTIP:"searchButtonTooltip",SEARCH_FIELD:"searchField",SELECTION_COMPONENT:"selectionComponent",SIDEBAR:"sidebar",SIDEBAR_BUTTON:"sidebarButton",STATUS_MESSAGE:"statusMessage",TABLE:"table",TERTIARY_ACTION:"tertiaryAction",TABLE_ROW:"tableRow",TITLE:"title",USER_FILTER:"userFilter",UT_RICH_TEXT:"UTRichText",UT_SNACKBAR:"UTSnackbar",VALIDATION_DATA:"validationData",WORKFLOW_CONTAINER:"workflowContainer"},TEST_IDS=exports.TEST_IDS={barChart:{bar:{tooltip:"barChart.bar.tooltip."},xAxis:{secondaryLabel:"barChart.xAxis.secondaryLabel.",mainLabel:"barChart.xAxis.mainLabel."}},breadcrumbs:{item:"breadcrumbs.item"},creditCard:{cardField:"".concat(ID_CONSTANTS.CREDIT_CARD,".cardField"),cvcField:"".concat(ID_CONSTANTS.CREDIT_CARD,".cvcField"),expires:"".concat(ID_CONSTANTS.CREDIT_CARD,".expires"),nameField:"".concat(ID_CONSTANTS.CREDIT_CARD,".nameField")},dataCategory:{container:"".concat(ID_CONSTANTS.DATA_CATEGORY,".container"),collapseButton:"".concat(ID_CONSTANTS.DATA_CATEGORY,".collapseButton"),item:"".concat(ID_CONSTANTS.DATA_CATEGORY,".item")},dataElement:{container:"".concat(ID_CONSTANTS.DATA_ELEMENT,".container"),collapseButton:"".concat(ID_CONSTANTS.DATA_ELEMENT,".collapseButton"),switchAction:"".concat(ID_CONSTANTS.DATA_ELEMENT,".actionSwitch"),buttonAction:"".concat(ID_CONSTANTS.DATA_ELEMENT,".actionButton")},dialog:{acceptButton:"".concat(ID_CONSTANTS.DIALOG,".acceptButton"),cancelButton:"".concat(ID_CONSTANTS.DIALOG,".cancelButton"),closeButton:"".concat(ID_CONSTANTS.DIALOG,".closeButton"),title:"".concat(ID_CONSTANTS.DIALOG,".title")},filterGrouping:{groupingPanel:{collapsedPanelContent:{expandButton:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.COLLAPSED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPAND_BUTTON)},expandedPanelContent:{expandedPanelContentCategory:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT_CATEGORY),expandedPanelContentHeader:{addFilterButton:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT_HEADER,".").concat(ID_CONSTANTS.ADD_FILTER_BUTTON),collapseButton:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT_HEADER,".").concat(ID_CONSTANTS.COLLAPSE_BUTTON),collapseButtonTooltip:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT_HEADER,".").concat(ID_CONSTANTS.COLLAPSE_BUTTON_TOOLTIP),customSearchAction:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT_HEADER,".").concat(ID_CONSTANTS.CUSTOM_SEARCH_ACTION),searchButton:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT_HEADER,".").concat(ID_CONSTANTS.SEARCH_BUTTON),searchButtonTooltip:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT_HEADER,".").concat(ID_CONSTANTS.SEARCH_BUTTON_TOOLTIP),searchField:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT_HEADER,".").concat(ID_CONSTANTS.SEARCH_FIELD),title:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT_HEADER,".").concat(ID_CONSTANTS.TITLE)}}}},onboarding:{close:"".concat(ID_CONSTANTS.ONBOARDING,".close"),description:"".concat(ID_CONSTANTS.ONBOARDING,".description"),nextButton:"".concat(ID_CONSTANTS.ONBOARDING,".nextButton"),prevButton:"".concat(ID_CONSTANTS.ONBOARDING,".prevButton"),title:"".concat(ID_CONSTANTS.ONBOARDING,".title")},panel:{additionalContent:{body:"".concat(ID_CONSTANTS.PANEL,".").concat(ID_CONSTANTS.ADDITIONAL_CONTENT,".").concat(ID_CONSTANTS.ADDITIONAL_CONTENT_BODY),sidebar:"".concat(ID_CONSTANTS.PANEL,".").concat(ID_CONSTANTS.ADDITIONAL_CONTENT,".").concat(ID_CONSTANTS.SIDEBAR),sidebarButton:"".concat(ID_CONSTANTS.PANEL,".").concat(ID_CONSTANTS.ADDITIONAL_CONTENT,".").concat(ID_CONSTANTS.SIDEBAR_BUTTON,".")},backButton:"".concat(ID_CONSTANTS.PANEL,".backButton"),closeButton:"".concat(ID_CONSTANTS.PANEL,".closeButton"),mainAction:"".concat(ID_CONSTANTS.PANEL,".mainAction"),mainButton:"".concat(ID_CONSTANTS.PANEL,".").concat(ID_CONSTANTS.MAIN_BUTTON),paginationNext:"".concat(ID_CONSTANTS.PANEL,".").concat(ID_CONSTANTS.PAGINATION_NEXT),paginationPrev:"".concat(ID_CONSTANTS.PANEL,".").concat(ID_CONSTANTS.PAGINATION_PREV),secondaryAction:"".concat(ID_CONSTANTS.PANEL,".secondaryAction"),title:"".concat(ID_CONSTANTS.PANEL,".title")},signature:"signature",snackBar:{closeButton:"snackbar.closeButton",label:"snackbar.label"},statusMessage:{chip:"".concat(ID_CONSTANTS.STATUS_MESSAGE,".chip"),description:"".concat(ID_CONSTANTS.STATUS_MESSAGE,".description"),flag:"".concat(ID_CONSTANTS.STATUS_MESSAGE,".flag"),helperText:"".concat(ID_CONSTANTS.STATUS_MESSAGE,".helperText"),icon:"".concat(ID_CONSTANTS.STATUS_MESSAGE,".icon"),title:"".concat(ID_CONSTANTS.STATUS_MESSAGE,".title")},table:{tableHeader:{title:"".concat(ID_CONSTANTS.TABLE,".tableHeader.title")}},tabs:{tab:"tabs.tab."},wrapperObservation:{actionIcon:"wrapperObservation.actionIcon."},UTLoading:{logoLoader:"UTLoading.logoLoader",spinner:"UTLoading.spinner"},UTRichText:{content:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".content"),field:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".field"),helpText:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".").concat(ID_CONSTANTS.HELP_TEXT),label:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".").concat(ID_CONSTANTS.LABEL),root:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".root"),submitButton:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".submitButton"),tableToolbar:{addColumnAfter:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableToolbar.addColumnAfter"),addColumnBefore:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableToolbar.addColumnBefore"),addRowAfter:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableToolbar.addRowAfter"),deleteColumn:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableToolbar.deleteColumn"),deleteRow:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableToolbar.deleteRow"),deleteTable:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableToolbar.deleteTable"),root:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableToolbar.root")},toolbar:{bold:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".toolbar.bold"),italic:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".toolbar.italic"),list:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".toolbar.list"),listNumbers:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".toolbar.listNumbers"),root:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".toolbar.root"),table:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".toolbar.table")},validation:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".").concat(ID_CONSTANTS.VALIDATION_DATA)},UTSnackbar:{closeButton:"".concat(ID_CONSTANTS.UT_SNACKBAR,".closeButton"),description:"".concat(ID_CONSTANTS.UT_SNACKBAR,".description"),label:"".concat(ID_CONSTANTS.UT_SNACKBAR,".label"),primaryActionButton:"".concat(ID_CONSTANTS.UT_SNACKBAR,".primaryActionButton"),root:"".concat(ID_CONSTANTS.UT_SNACKBAR,".root"),secondaryActionButton:"".concat(ID_CONSTANTS.UT_SNACKBAR,".secondaryActionButton")},UTDatePickerV1TestID:{calendar:"UTDatePickerV1.calendar",calendarPrevBtn:"UTDatePickerV1.calendarPrevBtn",calendarNextBtn:"UTDatePickerV1.calendarNextBtn",calendarMonthYear:"UTDatePickerV1.calendarMonthYear"},workflowContainer:{bottomNav:{backButton:"".concat(ID_CONSTANTS.WORKFLOW_CONTAINER,".").concat(ID_CONSTANTS.BOTTOM_NAV,".backButton"),nextButton:"".concat(ID_CONSTANTS.WORKFLOW_CONTAINER,".").concat(ID_CONSTANTS.BOTTOM_NAV,".nextButton"),primaryAction:"".concat(ID_CONSTANTS.WORKFLOW_CONTAINER,".").concat(ID_CONSTANTS.BOTTOM_NAV,".primaryAction"),secondaryAction:"".concat(ID_CONSTANTS.WORKFLOW_CONTAINER,".").concat(ID_CONSTANTS.BOTTOM_NAV,".secondaryAction")},header:{helpText:"".concat(ID_CONSTANTS.WORKFLOW_CONTAINER,".").concat(ID_CONSTANTS.HEADER,".helpText"),requiredFieldInfo:"".concat(ID_CONSTANTS.WORKFLOW_CONTAINER,".").concat(ID_CONSTANTS.HEADER,".requiredFieldInfo"),subtitle:"".concat(ID_CONSTANTS.WORKFLOW_CONTAINER,".").concat(ID_CONSTANTS.HEADER,".subtitle"),tagline:"".concat(ID_CONSTANTS.WORKFLOW_CONTAINER,".").concat(ID_CONSTANTS.HEADER,".tagline"),title:"".concat(ID_CONSTANTS.WORKFLOW_CONTAINER,".").concat(ID_CONSTANTS.HEADER,".title")}}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TEST_IDS=exports.ID_CONSTANTS=void 0;const ID_CONSTANTS=exports.ID_CONSTANTS={ACTIONS:"actions",ADD_FILTER_BUTTON:"addFilterButton",AVATAR:"avatar",BOTTOM_NAV:"bottomNav",CANVAS:"canvas",CELL:"cell",CLEAR_BUTTON:"clearButton",CLIENT_FILTER:"clientFilter",COLLAPSED_PANEL_CONTENT:"collapsedPanelContent",COLLAPSE_BUTTON:"collapseButton",COLLAPSE_BUTTON_TOOLTIP:"collapseButtonTooltip",CREDIT_CARD:"creditCard",CUSTOM_SEARCH_ACTION:"customSearchAction",DATA_CATEGORY:"dataCategory",DATA_ELEMENT:"dataElement",DELETE_BUTTON:"deleteButton",DELETE_BUTTON_TOOLTIP:"deleteButtonTooltip",ADDITIONAL_CONTENT:"additionalContent",ADDITIONAL_CONTENT_BODY:"additionalContentBody",DESCRIPTION:"description",DIALOG:"dialog",EDIT_BUTTON:"editButton",EDIT_BUTTON_TOOLTIP:"editButtonTooltip",EXPANDED_PANEL_CONTENT:"expandedPanelContent",EXPANDED_PANEL_CONTENT_CATEGORY:"expandedPanelContentCategory",EXPANDED_PANEL_CONTENT_CATEGORY_EMPTY:"expandedPanelContentCategoryEmpty",EXPANDED_PANEL_CONTENT_CATEGORY_HEADER:"expandedPanelContentCategoryHeader",EXPANDED_PANEL_CONTENT_CATEGORY_ITEM:"expandedPanelContentCategoryItem",EXPANDED_PANEL_CONTENT_HEADER:"expandedPanelContentHeader",EXPAND_BUTTON:"expandButton",FILTER_GROUPING:"filterGrouping",GROUPING_PANEL:"groupingPanel",HEADER:"header",HELP_TEXT:"helpText",ICON:"icon",INVALID_PARAMS:"invalidParams",LABEL:"label",MAIN_BUTTON:"mainButton",NAME:"name",NAME_CONTAINER:"nameContainer",ONBOARDING:"onboarding",PAGINATION_NEXT:"paginationNext",PAGINATION_PREV:"paginationPrev",PANEL:"panel",PERSISTENT_FILTER:"persistentFilter",PINNED:"pinned",POPPER:"popper",SEARCH_BUTTON:"searchButton",SECONDARY_ACTION:"secondaryAction",SEARCH_BUTTON_TOOLTIP:"searchButtonTooltip",SEARCH_FIELD:"searchField",SELECTION_COMPONENT:"selectionComponent",SIDEBAR:"sidebar",SIDEBAR_BUTTON:"sidebarButton",STATUS_MESSAGE:"statusMessage",TABLE:"table",TERTIARY_ACTION:"tertiaryAction",TABLE_ROW:"tableRow",TITLE:"title",USER_FILTER:"userFilter",UT_RICH_TEXT:"UTRichText",UT_SNACKBAR:"UTSnackbar",VALIDATION_DATA:"validationData",WORKFLOW_CONTAINER:"workflowContainer"},TEST_IDS=exports.TEST_IDS={barChart:{bar:{tooltip:"barChart.bar.tooltip."},xAxis:{secondaryLabel:"barChart.xAxis.secondaryLabel.",mainLabel:"barChart.xAxis.mainLabel."}},breadcrumbs:{item:"breadcrumbs.item"},creditCard:{cardField:"".concat(ID_CONSTANTS.CREDIT_CARD,".cardField"),cvcField:"".concat(ID_CONSTANTS.CREDIT_CARD,".cvcField"),expires:"".concat(ID_CONSTANTS.CREDIT_CARD,".expires"),nameField:"".concat(ID_CONSTANTS.CREDIT_CARD,".nameField")},dataCategory:{container:"".concat(ID_CONSTANTS.DATA_CATEGORY,".container"),collapseButton:"".concat(ID_CONSTANTS.DATA_CATEGORY,".collapseButton"),item:"".concat(ID_CONSTANTS.DATA_CATEGORY,".item")},dataElement:{container:"".concat(ID_CONSTANTS.DATA_ELEMENT,".container"),collapseButton:"".concat(ID_CONSTANTS.DATA_ELEMENT,".collapseButton"),switchAction:"".concat(ID_CONSTANTS.DATA_ELEMENT,".actionSwitch"),buttonAction:"".concat(ID_CONSTANTS.DATA_ELEMENT,".actionButton")},dialog:{acceptButton:"".concat(ID_CONSTANTS.DIALOG,".acceptButton"),cancelButton:"".concat(ID_CONSTANTS.DIALOG,".cancelButton"),closeButton:"".concat(ID_CONSTANTS.DIALOG,".closeButton"),title:"".concat(ID_CONSTANTS.DIALOG,".title")},filterGrouping:{groupingPanel:{collapsedPanelContent:{expandButton:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.COLLAPSED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPAND_BUTTON)},expandedPanelContent:{expandedPanelContentCategory:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT_CATEGORY),expandedPanelContentHeader:{addFilterButton:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT_HEADER,".").concat(ID_CONSTANTS.ADD_FILTER_BUTTON),collapseButton:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT_HEADER,".").concat(ID_CONSTANTS.COLLAPSE_BUTTON),collapseButtonTooltip:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT_HEADER,".").concat(ID_CONSTANTS.COLLAPSE_BUTTON_TOOLTIP),customSearchAction:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT_HEADER,".").concat(ID_CONSTANTS.CUSTOM_SEARCH_ACTION),searchButton:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT_HEADER,".").concat(ID_CONSTANTS.SEARCH_BUTTON),searchButtonTooltip:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT_HEADER,".").concat(ID_CONSTANTS.SEARCH_BUTTON_TOOLTIP),searchField:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT_HEADER,".").concat(ID_CONSTANTS.SEARCH_FIELD),title:"".concat(ID_CONSTANTS.FILTER_GROUPING,".").concat(ID_CONSTANTS.GROUPING_PANEL,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT,".").concat(ID_CONSTANTS.EXPANDED_PANEL_CONTENT_HEADER,".").concat(ID_CONSTANTS.TITLE)}}}},onboarding:{close:"".concat(ID_CONSTANTS.ONBOARDING,".close"),description:"".concat(ID_CONSTANTS.ONBOARDING,".description"),nextButton:"".concat(ID_CONSTANTS.ONBOARDING,".nextButton"),prevButton:"".concat(ID_CONSTANTS.ONBOARDING,".prevButton"),title:"".concat(ID_CONSTANTS.ONBOARDING,".title")},panel:{additionalContent:{body:"".concat(ID_CONSTANTS.PANEL,".").concat(ID_CONSTANTS.ADDITIONAL_CONTENT,".").concat(ID_CONSTANTS.ADDITIONAL_CONTENT_BODY),sidebar:"".concat(ID_CONSTANTS.PANEL,".").concat(ID_CONSTANTS.ADDITIONAL_CONTENT,".").concat(ID_CONSTANTS.SIDEBAR),sidebarButton:"".concat(ID_CONSTANTS.PANEL,".").concat(ID_CONSTANTS.ADDITIONAL_CONTENT,".").concat(ID_CONSTANTS.SIDEBAR_BUTTON,".")},backButton:"".concat(ID_CONSTANTS.PANEL,".backButton"),closeButton:"".concat(ID_CONSTANTS.PANEL,".closeButton"),mainAction:"".concat(ID_CONSTANTS.PANEL,".mainAction"),mainButton:"".concat(ID_CONSTANTS.PANEL,".").concat(ID_CONSTANTS.MAIN_BUTTON),paginationNext:"".concat(ID_CONSTANTS.PANEL,".").concat(ID_CONSTANTS.PAGINATION_NEXT),paginationPrev:"".concat(ID_CONSTANTS.PANEL,".").concat(ID_CONSTANTS.PAGINATION_PREV),secondaryAction:"".concat(ID_CONSTANTS.PANEL,".secondaryAction"),title:"".concat(ID_CONSTANTS.PANEL,".title")},signature:"signature",snackBar:{closeButton:"snackbar.closeButton",label:"snackbar.label"},statusMessage:{chip:"".concat(ID_CONSTANTS.STATUS_MESSAGE,".chip"),description:"".concat(ID_CONSTANTS.STATUS_MESSAGE,".description"),flag:"".concat(ID_CONSTANTS.STATUS_MESSAGE,".flag"),helperText:"".concat(ID_CONSTANTS.STATUS_MESSAGE,".helperText"),icon:"".concat(ID_CONSTANTS.STATUS_MESSAGE,".icon"),title:"".concat(ID_CONSTANTS.STATUS_MESSAGE,".title")},table:{tableHeader:{title:"".concat(ID_CONSTANTS.TABLE,".tableHeader.title")}},tabs:{tab:"tabs.tab."},wrapperObservation:{actionIcon:"wrapperObservation.actionIcon."},UTLoading:{logoLoader:"UTLoading.logoLoader",spinner:"UTLoading.spinner"},UTRichText:{content:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".content"),field:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".field"),helpText:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".").concat(ID_CONSTANTS.HELP_TEXT),label:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".").concat(ID_CONSTANTS.LABEL),root:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".root"),submitButton:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".submitButton"),tableHandle:{cell:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableHandle.cell"),column:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableHandle.column"),row:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableHandle.row"),table:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableHandle.table")},tableMenu:{cell:{addColumnAfter:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.cell.addColumnAfter"),addRowAfter:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.cell.addRowAfter"),clearCell:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.cell.clearCell"),deleteColumn:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.cell.deleteColumn"),deleteRow:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.cell.deleteRow"),root:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.cell.root")},column:{addColumnAfter:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.column.addColumnAfter"),addColumnBefore:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.column.addColumnBefore"),clearColumn:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.column.clearColumn"),deleteColumn:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.column.deleteColumn"),moveColumnLeft:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.column.moveColumnLeft"),moveColumnRight:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.column.moveColumnRight"),root:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.column.root"),toggleHeaderColumn:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.column.toggleHeaderColumn")},root:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.root"),row:{addRowAfter:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.row.addRowAfter"),addRowBefore:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.row.addRowBefore"),clearRow:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.row.clearRow"),deleteRow:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.row.deleteRow"),moveRowDown:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.row.moveRowDown"),moveRowUp:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.row.moveRowUp"),root:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.row.root"),toggleHeaderRow:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.row.toggleHeaderRow")},table:{clearTable:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.table.clearTable"),copyTable:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.table.copyTable"),deleteTable:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.table.deleteTable"),root:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.table.root"),toggleHeaderColumn:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.table.toggleHeaderColumn"),toggleHeaderRow:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".tableMenu.table.toggleHeaderRow")}},toolbar:{bold:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".toolbar.bold"),italic:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".toolbar.italic"),list:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".toolbar.list"),listNumbers:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".toolbar.listNumbers"),root:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".toolbar.root"),table:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".toolbar.table")},validation:"".concat(ID_CONSTANTS.UT_RICH_TEXT,".").concat(ID_CONSTANTS.VALIDATION_DATA)},UTSnackbar:{closeButton:"".concat(ID_CONSTANTS.UT_SNACKBAR,".closeButton"),description:"".concat(ID_CONSTANTS.UT_SNACKBAR,".description"),label:"".concat(ID_CONSTANTS.UT_SNACKBAR,".label"),primaryActionButton:"".concat(ID_CONSTANTS.UT_SNACKBAR,".primaryActionButton"),root:"".concat(ID_CONSTANTS.UT_SNACKBAR,".root"),secondaryActionButton:"".concat(ID_CONSTANTS.UT_SNACKBAR,".secondaryActionButton")},UTDatePickerV1TestID:{calendar:"UTDatePickerV1.calendar",calendarPrevBtn:"UTDatePickerV1.calendarPrevBtn",calendarNextBtn:"UTDatePickerV1.calendarNextBtn",calendarMonthYear:"UTDatePickerV1.calendarMonthYear"},workflowContainer:{bottomNav:{backButton:"".concat(ID_CONSTANTS.WORKFLOW_CONTAINER,".").concat(ID_CONSTANTS.BOTTOM_NAV,".backButton"),nextButton:"".concat(ID_CONSTANTS.WORKFLOW_CONTAINER,".").concat(ID_CONSTANTS.BOTTOM_NAV,".nextButton"),primaryAction:"".concat(ID_CONSTANTS.WORKFLOW_CONTAINER,".").concat(ID_CONSTANTS.BOTTOM_NAV,".primaryAction"),secondaryAction:"".concat(ID_CONSTANTS.WORKFLOW_CONTAINER,".").concat(ID_CONSTANTS.BOTTOM_NAV,".secondaryAction")},header:{helpText:"".concat(ID_CONSTANTS.WORKFLOW_CONTAINER,".").concat(ID_CONSTANTS.HEADER,".helpText"),requiredFieldInfo:"".concat(ID_CONSTANTS.WORKFLOW_CONTAINER,".").concat(ID_CONSTANTS.HEADER,".requiredFieldInfo"),subtitle:"".concat(ID_CONSTANTS.WORKFLOW_CONTAINER,".").concat(ID_CONSTANTS.HEADER,".subtitle"),tagline:"".concat(ID_CONSTANTS.WORKFLOW_CONTAINER,".").concat(ID_CONSTANTS.HEADER,".tagline"),title:"".concat(ID_CONSTANTS.WORKFLOW_CONTAINER,".").concat(ID_CONSTANTS.HEADER,".title")}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EditorContent,useEditorState}from"@tiptap/react";import isEmpty from"lodash/isEmpty";import{arrayOf,bool,func,object,objectOf,oneOf,oneOfType,string}from"prop-types";import React,{useCallback,useMemo,useRef,useState}from"react";import{mergeMultipleClassNames}from"../../utils/classesUtils.js";import UTFieldLabel from"../UTFieldLabel/index.js";import UTLabel from"../UTLabel/index.js";import UTValidation,{validationDataProptypes}from"../UTValidation/index.js";import{formatErrorToValidation}from"../UTValidation/utils.js";import EditorSkeleton from"./components/EditorSkeleton/index.js";import SubmitAction from"./components/SubmitAction/index.js";import Toolbar from"./components/Toolbar/index.js";import{DEFAULT_PROPS,MODULE_KEYS,TEST_IDS_RICH_TEXT,TITLE_VARIANTS}from"./constants.js";import useModuleResolution from"./hooks/useModuleResolution.js";import useRichTextEditor from"./hooks/useRichTextEditor.js";import{getFieldClassName}from"./utils.js";import styles from"./styles.module.scss";const UTRichText=e=>{var t;let{actions:o,classNames:a={},dataTestId:
|
|
1
|
+
import{EditorContent,useEditorState}from"@tiptap/react";import isEmpty from"lodash/isEmpty";import{arrayOf,bool,func,object,objectOf,oneOf,oneOfType,string}from"prop-types";import React,{useCallback,useMemo,useRef,useState}from"react";import{mergeMultipleClassNames}from"../../utils/classesUtils.js";import UTFieldLabel from"../UTFieldLabel/index.js";import UTLabel from"../UTLabel/index.js";import UTValidation,{validationDataProptypes}from"../UTValidation/index.js";import{formatErrorToValidation}from"../UTValidation/utils.js";import EditorSkeleton from"./components/EditorSkeleton/index.js";import SubmitAction from"./components/SubmitAction/index.js";import Toolbar from"./components/Toolbar/index.js";import{DEFAULT_PROPS,MODULE_KEYS,TEST_IDS_RICH_TEXT,TITLE_VARIANTS}from"./constants.js";import useModuleResolution from"./hooks/useModuleResolution.js";import useRichTextEditor from"./hooks/useRichTextEditor.js";import{getFieldClassName}from"./utils.js";import styles from"./styles.module.scss";const UTRichText=e=>{var t;let{actions:o,classNames:a={},dataTestId:l=TEST_IDS_RICH_TEXT.root,disabled:r=!1,error:s,helpText:i,loading:n=!1,moduleConfig:d={},modules:m,onBlur:c,onChange:u,onFocus:T,onSubmit:p,placeholder:E,readOnly:b=!1,required:f=!1,submitButtonProps:R,title:S,titleVariant:_=DEFAULT_PROPS.titleVariant,validations:I,value:y}=e;const[C,O]=useState(!1),g=useModuleResolution({moduleConfig:d,modules:m}),j=useMemo(()=>g.flat(),[g]),v=useMemo(()=>mergeMultipleClassNames(styles,a),[a]),h=useMemo(()=>j.map(e=>{var t;return{...e,extensions:null!==(t=e.resolvedExtensions)&&void 0!==t?t:e.extensions}}),[j]),x=useCallback(e=>{O(!0),null==T||T(e)},[T]),U=useCallback(e=>{O(!1),null==c||c(e)},[c]),D=useRef(!1),M=useCallback(()=>!(!D.current||!p)&&(p(),!0),[p]),N=useRichTextEditor({activeModules:h,ariaLabel:S,dataTestId:TEST_IDS_RICH_TEXT.content,disabled:r,editorClassName:styles.editorContent,onBlur:U,onChange:u,onFocus:x,onSubmit:M,placeholder:E,readOnly:b,value:y}),L=null===(t=useEditorState({editor:N,selector:e=>{let{editor:t}=e;return!t||t.isEmpty}}))||void 0===t||t,k=Boolean(p)&&!r&&!n&&!L;D.current=k;const F=useMemo(()=>isEmpty(I)?s?formatErrorToValidation(s):null:I,[s,I]);return React.createElement("div",{className:v.container,"data-testid":l},S&&React.createElement(UTFieldLabel,{actions:o,dataTestId:TEST_IDS_RICH_TEXT.label,readOnly:b,required:f,size:_},S),React.createElement("div",{className:getFieldClassName({classes:v,disabled:r,error:s,isFocused:C,readOnly:b}),"data-testid":TEST_IDS_RICH_TEXT.field},n?React.createElement(EditorSkeleton,null):React.createElement(React.Fragment,null,!b&&React.createElement(Toolbar,{dataTestId:TEST_IDS_RICH_TEXT.toolbar.root,disabled:r,editor:N,moduleGroups:g}),React.createElement("div",{className:v.scrollArea},React.createElement(EditorContent,{className:v.editorWrapper,editor:N})),N&&!b&&!r&&h.map(e=>{let{EditorOverlay:t,...o}=e;return t&&React.createElement(t,{editor:N,key:o.key,module:o})}),p&&!b&&React.createElement(SubmitAction,{dataTestId:TEST_IDS_RICH_TEXT.submitButton,disabled:!k,loading:n,onSubmit:p,submitButtonProps:R}))),i&&React.createElement(UTLabel,{className:v.helpText,colorTheme:"gray",dataTestId:TEST_IDS_RICH_TEXT.helpText,variant:"small",withMarkdown:!0},i),F&&React.createElement(UTValidation,{dataTestId:TEST_IDS_RICH_TEXT.validation,validationData:F}))};export const propTypes={actions:arrayOf(object),classNames:objectOf(string),dataTestId:string,disabled:bool,error:oneOfType([bool,string]),helpText:string,loading:bool,moduleConfig:objectOf(object),modules:arrayOf(oneOf(Object.values(MODULE_KEYS))),onBlur:func,onChange:func,onFocus:func,onSubmit:func,placeholder:string,readOnly:bool,required:bool,submitButtonProps:object,title:string,titleVariant:oneOf(Object.values(TITLE_VARIANTS)),validations:validationDataProptypes,value:object};UTRichText.propTypes=propTypes;export default UTRichText;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Extension}from"@tiptap/core";import{TEST_IDS_RICH_TEXT}from"../../constants.js";import{trackHandlePointer}from"./dragHandle";import{CellSelection,Decoration,DecorationSet,Plugin,PluginKey,Selection,TableMap}from"./pm";import{HANDLE_TYPES,getHandleCellPositions,rebuildSelection}from"./selection";export const tableHandlesKey=new PluginKey("tableHandles");const HANDLE_CLASS="table-handle",ACTIVE_CLASS="".concat(HANDLE_CLASS,"--active"),VISIBLE_CLASS="".concat(HANDLE_CLASS,"--visible"),SELECTED_CELL_CLASS="selectedCell",DRAG_SOURCE_CLASS="table-drag-source",EDITOR_CLASS="has-table-handles",HANDLE_LABELS={[HANDLE_TYPES.cell]:e=>{let{col:t,row:n}=e;return"Opciones de la celda: fila ".concat(n+1,", columna ").concat(t+1)},[HANDLE_TYPES.column]:e=>{let{index:t}=e;return"Opciones de la columna ".concat(t+1)},[HANDLE_TYPES.row]:e=>{let{index:t}=e;return"Opciones de la fila ".concat(t+1)},[HANDLE_TYPES.table]:()=>"Opciones de la tabla"};export const getTableIndex=(e,t)=>{let n=0;return e.nodesBetween(0,t,(e,a)=>("table"===e.type.name&&a<t&&(n+=1),"table"!==e.type.name)),n};const GRIP_DOTS={horizontal:[[5,9],[12,9],[19,9],[5,15],[12,15],[19,15]],vertical:[[9,5],[9,12],[9,19],[15,5],[15,12],[15,19]]},SVG_NS="http://www.w3.org/2000/svg",createChevronIcon=()=>{const e=document.createElementNS(SVG_NS,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","2"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.setAttribute("aria-hidden","true");const t=document.createElementNS(SVG_NS,"polyline");return t.setAttribute("points","6 9 12 15 18 9"),e.appendChild(t),e},createGripIcon=e=>{const t=document.createElementNS(SVG_NS,"svg");return t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","2"),t.setAttribute("aria-hidden","true"),GRIP_DOTS[e].forEach(e=>{let[n,a]=e;const o=document.createElementNS(SVG_NS,"circle");o.setAttribute("cx",n),o.setAttribute("cy",a),o.setAttribute("r","1"),t.appendChild(o)}),t},isSameHandle=(e,t)=>!!e&&!!t&&e.type===t.type&&e.tablePos===t.tablePos&&e.index===t.index;export const setActiveHandle=(e,t)=>{const n=e.state.tr.setMeta(tableHandlesKey,{active:t}),a=rebuildSelection(n.doc,t);a&&n.setSelection(a),e.dispatch(n)};export const clearActiveHandle=e=>{const{selection:t}=e.state,n=t instanceof CellSelection,a=tableHandlesKey.getState(e.state);if(!(null!=a&&a.active||null!=a&&a.dragSource||n))return;const o=e.state.tr.setMeta(tableHandlesKey,{active:null,dragSource:null});n&&o.setSelection(Selection.near(o.doc.resolve(t.$anchorCell.pos+1))),e.dispatch(o)};const setDragSource=(e,t)=>e.dispatch(e.state.tr.setMeta(tableHandlesKey,{active:null,dragSource:t}));export const getActiveHandle=e=>{var t,n;return null!==(t=null===(n=tableHandlesKey.getState(e))||void 0===n?void 0:n.active)&&void 0!==t?t:null};export const getActiveHandleElement=e=>e.dom.querySelector(".".concat(ACTIVE_CLASS));export const focusHandle=(e,t)=>{var n;const a=[".".concat(HANDLE_CLASS),'[data-table-pos="'.concat(t.tablePos,'"]'),'[data-handle-type="'.concat(t.type,'"]'),'[data-handle-index="'.concat(t.index,'"]')].join("");null===(n=e.dom.querySelector(a))||void 0===n||n.focus({preventScroll:!0})};const buildHandleWidget=(e,t,n,a)=>Decoration.widget(e,e=>{const o=document.createElement("div");return o.className="".concat(HANDLE_CLASS," ").concat(HANDLE_CLASS,"--").concat(t.type).concat(n?" ".concat(ACTIVE_CLASS):""),o.contentEditable="false",o.tabIndex=-1,o.setAttribute("aria-haspopup","menu"),o.setAttribute("role","button"),o.setAttribute("aria-label",HANDLE_LABELS[t.type](t)),o.dataset.testid=TEST_IDS_RICH_TEXT.tableHandle[t.type],o.dataset.tableIndex=String(a),o.dataset.handleType=t.type,o.dataset.handleIndex=String(t.index),o.dataset.tablePos=String(t.tablePos),t.type===HANDLE_TYPES.cell?(o.dataset.handleRow=String(t.row),o.dataset.handleCol=String(t.col),o.appendChild(createChevronIcon())):o.appendChild(createGripIcon(t.type===HANDLE_TYPES.column?"horizontal":"vertical")),o.addEventListener("mousedown",n=>{n.preventDefault(),n.stopPropagation(),0===n.button&&trackHandlePointer(e,t,n,{onClick:()=>setActiveHandle(e,t),onDragEnd:()=>clearActiveHandle(e),onDragStart:()=>setDragSource(e,t)})}),o.addEventListener("click",n=>{0===n.detail&&(n.preventDefault(),setActiveHandle(e,t))}),o.addEventListener("keydown",n=>{"Enter"!==n.key&&" "!==n.key||(n.preventDefault(),n.stopPropagation(),setActiveHandle(e,t))}),o},{ignoreSelection:!0,key:"".concat(HANDLE_CLASS,"-").concat(t.type,"-").concat(t.tablePos,"-").concat(t.index,"-").concat(a,"-").concat(n?1:0),side:-1,stopEvent:()=>!0}),buildDecorations=(e,t,n)=>{const a=[];let o=-1;e.descendants((e,n)=>{if("table"!==e.type.name)return!0;o+=1;const l=TableMap.get(e),c=n+1,r=(e,n)=>a.push(buildHandleWidget((e=>c+e+1)(e),n,isSameHandle(n,t),o)),s=(e,t,a)=>r(e,{index:a,tablePos:n,type:t});for(let e=0;e<l.width;e++)0!==e&&l.map[e]===l.map[e-1]||s(l.map[e],HANDLE_TYPES.column,e);for(let e=0;e<l.height;e++){const t=l.map[e*l.width];0!==e&&t===l.map[(e-1)*l.width]||s(t,HANDLE_TYPES.row,e)}s(l.map[0],HANDLE_TYPES.table,0);const d=new Set;for(let e=0;e<l.height;e++)for(let t=0;t<l.width;t++){const a=l.map[e*l.width+t];d.has(a)||(d.add(a),r(a,{col:t,index:a,row:e,tablePos:n,type:HANDLE_TYPES.cell}))}return!1});const l=n||t,c=n?DRAG_SOURCE_CLASS:"selectedCell";return l&&getHandleCellPositions(e,l).forEach(t=>{const n=e.nodeAt(t);n&&a.push(Decoration.node(t,t+n.nodeSize,{class:c}))}),DecorationSet.create(e,a)},mapActiveHandle=(e,t)=>{const{deleted:n,pos:a}=e.mapping.mapResult(t.tablePos);if(n)return null;const o={...t,tablePos:a};return getHandleCellPositions(e.doc,o).length?o:null},nextActiveHandle=(e,t)=>{const n=e.getMeta(tableHandlesKey);return n&&"active"in n?n.active:t?e.selectionSet?null:e.docChanged?mapActiveHandle(e,t):t:null},hoveredCellAt=(e,t)=>{var n;const a=null==t||null===(n=t.closest)||void 0===n?void 0:n.call(t,"td, th");if(!a||!e.dom.contains(a))return null;let o;try{o=e.state.doc.resolve(e.posAtDOM(a,0)-1)}catch{return null}const l=o.node(-1);if(!l||"table"!==l.type.name)return null;const{left:c,top:r}=TableMap.get(l).findCell(o.pos-o.start(-1));return{column:c,row:r,tablePos:o.before(-1)}},isSameCell=(e,t)=>e===t||!!e&&!!t&&e.tablePos===t.tablePos&&e.row===t.row&&e.column===t.column,createHoverView=e=>{let t=null;const n=()=>{if(e.dom.querySelectorAll(".".concat(VISIBLE_CLASS)).forEach(e=>e.classList.remove(VISIBLE_CLASS)),!t)return;const n=".".concat(HANDLE_CLASS,'[data-table-pos="').concat(t.tablePos,'"]');e.dom.querySelectorAll(["".concat(n,'[data-handle-type="').concat(HANDLE_TYPES.column,'"][data-handle-index="').concat(t.column,'"]'),"".concat(n,'[data-handle-type="').concat(HANDLE_TYPES.row,'"][data-handle-index="').concat(t.row,'"]'),"".concat(n,'[data-handle-type="').concat(HANDLE_TYPES.table,'"]'),"".concat(n,'[data-handle-type="').concat(HANDLE_TYPES.cell,'"][data-handle-row="').concat(t.row,'"][data-handle-col="').concat(t.column,'"]')].join(",")).forEach(e=>e.classList.add(VISIBLE_CLASS))},a=a=>{const o=hoveredCellAt(e,a.target);isSameCell(o,t)||(t=o,n())},o=()=>{t=null,n()};return e.dom.addEventListener("mousemove",a),e.dom.addEventListener("mouseleave",o),{update:n,destroy:()=>{e.dom.removeEventListener("mousemove",a),e.dom.removeEventListener("mouseleave",o)}}};export const TableHandles=Extension.create({name:"tableHandles",addProseMirrorPlugins:()=>[new Plugin({key:tableHandlesKey,state:{init:(e,t)=>({active:null,decorations:buildDecorations(t.doc,null,null),dragSource:null}),apply(e,t,n,a){const o=e.getMeta(tableHandlesKey),l=nextActiveHandle(e,t.active),c=o&&"dragSource"in o?o.dragSource:t.dragSource;return e.docChanged||l!==t.active||c!==t.dragSource?{active:l,decorations:buildDecorations(a.doc,l,c),dragSource:c}:t}},props:{attributes:{class:EDITOR_CLASS},decorations:e=>tableHandlesKey.getState(e).decorations,handleKeyDown:(e,t)=>!("Escape"!==t.key||!getActiveHandle(e.state))&&(clearActiveHandle(e),!0)},view:createHoverView})]});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},_extends.apply(null,arguments)}import{arrayOf,bool,func,object,objectOf,shape,string}from"prop-types";import React,{Fragment,useEffect,useRef}from"react";import UTIcon from"../../../../UTIcon/index.js";import UTLabel from"../../../../UTLabel/index.js";import UTPopper from"../../../../UTPopper/index.js";import UTSwitch from"../../../../UTSwitch/index.js";import styles from"./styles.module.scss";const MenuItem=e=>{let{item:t,onClose:n}=e;const o=void 0!==t.checked,r=()=>{t.disabled||(t.onSelect(),n())},a=e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),r())},s="".concat(styles.item," ").concat(t.disabled?styles.itemDisabled:""),l=React.createElement(React.Fragment,null,React.createElement(UTIcon,{className:styles.icon,colorTheme:"gray",name:t.icon}),React.createElement(UTLabel,{className:styles.label,colorTheme:t.disabled?"gray":"dark"},t.label));return o?React.createElement("div",{"aria-checked":t.checked,"aria-disabled":t.disabled||void 0,className:s,"data-testid":t.dataTestId,onClick:r,onKeyDown:a,role:"menuitemcheckbox",tabIndex:t.disabled?void 0:-1},l,React.createElement("span",{className:styles.switch},React.createElement(UTSwitch,{disabled:t.disabled,value:t.checked,version:"V1"}))):React.createElement("div",{"aria-disabled":t.disabled||void 0,className:s,"data-testid":t.dataTestId,onClick:r,onKeyDown:a,role:"menuitem",tabIndex:t.disabled?void 0:-1},l)};MenuItem.propTypes={item:shape({checked:bool,dataTestId:string,disabled:bool,icon:string,label:string,onSelect:func}),onClose:func};const VIEWPORT_MODIFIERS={flip:{boundariesElement:"viewport",padding:8},preventOverflow:{boundariesElement:"viewport",padding:8}},ITEM_SELECTOR='[role^="menuitem"][tabindex]',NAVIGATION_KEYS=["ArrowDown","ArrowUp","Home","End"],nextIndex=(e,t,n)=>"Home"===e?0:"End"===e?n-1:-1===t?"ArrowUp"===e?n-1:0:"ArrowDown"===e?(t+1)%n:(t-1+n)%n,MenuList=e=>{let{groups:t,items:n,label:o,menuProps:r,onClose:a,onEscape:s}=e;const l=useRef(null),c=()=>{var e,t;return Array.from(null!==(e=null===(t=l.current)||void 0===t?void 0:t.querySelectorAll(ITEM_SELECTOR))&&void 0!==e?e:[])};useEffect(()=>{var e;null===(e=c()[0])||void 0===e||e.focus({preventScroll:!0})},[]);return React.createElement("div",_extends({},r,{"aria-label":o,className:styles.menu,onKeyDown:e=>{if("Escape"===e.key)return e.preventDefault(),e.stopPropagation(),void s();if(!NAVIGATION_KEYS.includes(e.key))return;e.preventDefault();const t=c();t.length&&t[nextIndex(e.key,t.indexOf(document.activeElement),t.length)].focus()},onMouseLeave:()=>{var e;null!==(e=l.current)&&void 0!==e&&e.contains(document.activeElement)&&l.current.focus({preventScroll:!0})},onMouseMove:e=>{var t,n;const o=null===(t=(n=e.target).closest)||void 0===t?void 0:t.call(n,'[role^="menuitem"]'),r=null!=o&&o.matches(ITEM_SELECTOR)?o:l.current;r&&document.activeElement!==r&&r.focus({preventScroll:!0})},ref:l,role:"menu",tabIndex:-1}),t.map((e,t)=>React.createElement(Fragment,{key:e.join("|")},t>0&&React.createElement("div",{className:styles.separator,role:"separator"}),React.createElement("div",{className:styles.group,role:"none"},e.map(e=>React.createElement(MenuItem,{item:n[e],key:e,onClose:a}))))))};MenuList.propTypes={groups:arrayOf(arrayOf(string)).isRequired,items:objectOf(object).isRequired,label:string,menuProps:object,onClose:func.isRequired,onEscape:func.isRequired};const TableMenu=e=>{let{anchor:t,groups:n,items:o,label:r,menuProps:a,onClose:s,onEscape:l,placement:c="bottom-start",rootProps:i}=e;return React.createElement(UTPopper,_extends({},i,{anchor:t,className:styles.popper,classes:{paper:styles.paper},clickAwayListenerProps:{mouseEvent:"onMouseDown"},modifiers:VIEWPORT_MODIFIERS,onClose:s,placement:c}),React.createElement(MenuList,{groups:n,items:o,label:r,menuProps:a,onClose:s,onEscape:null!=l?l:s}))};TableMenu.propTypes={anchor:object,groups:arrayOf(arrayOf(string)).isRequired,items:objectOf(object).isRequired,label:string,menuProps:object,onClose:func.isRequired,onEscape:func,placement:string,rootProps:object};export default TableMenu;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
.popper {
|
|
2
|
+
z-index: 1300;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.paper {
|
|
6
|
+
border-radius: var(--UT-richText-table-menu-radius);
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.menu {
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
max-height: calc(100vh - 16px);
|
|
15
|
+
overflow-y: auto;
|
|
16
|
+
padding-bottom: var(--UT-richText-table-menu-padding-y);
|
|
17
|
+
padding-left: var(--UT-richText-table-menu-padding-x);
|
|
18
|
+
padding-right: var(--UT-richText-table-menu-padding-x);
|
|
19
|
+
padding-top: var(--UT-richText-table-menu-padding-y);
|
|
20
|
+
width: var(--UT-richText-table-menu-width);
|
|
21
|
+
|
|
22
|
+
&:focus {
|
|
23
|
+
outline: none;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.group {
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
padding: var(--UT-richText-table-menu-group-padding-y) 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.separator {
|
|
34
|
+
background-color: var(--light04);
|
|
35
|
+
height: 1px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.item {
|
|
39
|
+
align-items: center;
|
|
40
|
+
border-radius: var(--UT-richText-table-menu-radius);
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
display: flex;
|
|
43
|
+
grid-gap: var(--UT-richText-table-menu-item-gap);
|
|
44
|
+
padding-bottom: var(--UT-richText-table-menu-item-padding-y);
|
|
45
|
+
padding-left: var(--UT-richText-table-menu-item-gap);
|
|
46
|
+
padding-right: var(--UT-richText-table-menu-item-gap);
|
|
47
|
+
padding-top: var(--UT-richText-table-menu-item-padding-y);
|
|
48
|
+
user-select: none;
|
|
49
|
+
|
|
50
|
+
&:focus {
|
|
51
|
+
background-color: var(--light04);
|
|
52
|
+
outline: none;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.itemDisabled {
|
|
57
|
+
cursor: default;
|
|
58
|
+
opacity: 0.5;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.icon {
|
|
62
|
+
flex-shrink: 0;
|
|
63
|
+
height: var(--UT-richText-table-menu-item-icon-size);
|
|
64
|
+
width: var(--UT-richText-table-menu-item-icon-size);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.label {
|
|
68
|
+
flex: 1 1 auto;
|
|
69
|
+
min-width: 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.switch {
|
|
73
|
+
display: flex;
|
|
74
|
+
pointer-events: none;
|
|
75
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useEditorState}from"@tiptap/react";import{object,shape}from"prop-types";import React,{useCallback}from"react";import{TEST_IDS_RICH_TEXT}from"../../constants.js";import{buildTableMenu}from"./menu.js";import{clearActiveHandle,focusHandle,getActiveHandle,getActiveHandleElement,getTableIndex}from"./TableHandles.js";import TableMenu from"./TableMenu/index.js";const HANDLE_SELECTOR=".table-handle",TableMenuOverlay=e=>{var t;let{editor:l,module:a}=e;const{anchor:o,handle:n}=null!==(t=useEditorState({editor:l,equalityFn:(e,t)=>(null==e?void 0:e.anchor)===(null==t?void 0:t.anchor)&&(null==e?void 0:e.doc)===(null==t?void 0:t.doc)&&(null==e?void 0:e.handle)===(null==t?void 0:t.handle),selector:e=>{let{editor:t}=e;const l=t&&!t.isDestroyed?getActiveHandle(t.state):null;return{anchor:l?getActiveHandleElement(t.view):null,doc:null==t?void 0:t.state.doc,handle:l}}}))&&void 0!==t?t:{},r=n?buildTableMenu(l,n,a.config.actions):null,d=useCallback(e=>{var t,a;null!=e&&null!==(t=e.target)&&void 0!==t&&null!==(a=t.closest)&&void 0!==a&&a.call(t,".table-handle")||clearActiveHandle(l.view)},[l]),c=useCallback(()=>{const{view:e}=l,t=getActiveHandle(e.state);clearActiveHandle(e),t&&focusHandle(e,t)},[l]);if(!o||!r||0===r.groups.length)return null;const i=getTableIndex(l.state.doc,n.tablePos);return React.createElement(TableMenu,{anchor:o,groups:r.groups,items:r.items,key:"".concat(n.type,"-").concat(n.tablePos,"-").concat(n.index),label:o.getAttribute("aria-label"),menuProps:{"data-table-index":i,"data-testid":TEST_IDS_RICH_TEXT.tableMenu[n.type].root},onClose:d,onEscape:c,placement:"right-start",rootProps:{"data-table-index":i,"data-testid":TEST_IDS_RICH_TEXT.tableMenu.root}})};TableMenuOverlay.propTypes={editor:object,module:shape({config:object})};export default TableMenuOverlay;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bool,object,shape,string}from"prop-types";import React,{useCallback}from"react";import UTButton from"../../../UTButton/index.js";import UTTooltip from"../../../UTTooltip/index.js";import{TOOLBAR_BUTTON}from"../../constants.js";
|
|
1
|
+
import{bool,object,shape,string}from"prop-types";import React,{useCallback}from"react";import UTButton from"../../../UTButton/index.js";import UTTooltip from"../../../UTTooltip/index.js";import{TOOLBAR_BUTTON}from"../../constants.js";const INSERT_TABLE_DEFAULTS={cols:3,rows:3,withHeaderRow:!0},TableToolbarButton=t=>{var e;let{disabled:o,editor:a,module:n}=t;const{allowInsert:r}=n.config||n.defaultConfig,i=useCallback(()=>{if(!a.isActive("table"))return void a.chain().focus().insertTable(INSERT_TABLE_DEFAULTS).run();const{$from:t}=a.state.selection;for(let e=t.depth;e>0;e--)if("table"===t.node(e).type.name){const o=t.after(e);return void a.chain().insertContentAt(o,{type:"paragraph"}).setTextSelection(o+1).insertTable(INSERT_TABLE_DEFAULTS).run()}a.chain().focus().insertTable(INSERT_TABLE_DEFAULTS).run()},[a]);return r?React.createElement(UTTooltip,{arrow:!1,content:"Insertar tabla",tippyProps:{appendTo:()=>document.body,interactive:!1}},React.createElement("div",null,React.createElement(UTButton,{colorTheme:TOOLBAR_BUTTON.inactive.colorTheme,dataTestId:null===(e=n.testIds)||void 0===e?void 0:e.toolbarButton,disabled:o,LeftIcon:"IconTable",onClick:i,size:TOOLBAR_BUTTON.size,variant:TOOLBAR_BUTTON.inactive.variant}))):null};TableToolbarButton.propTypes={disabled:bool,editor:object,module:shape({config:object,defaultConfig:object,key:string,testIds:object})};export default TableToolbarButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const TABLE_ACTIONS={addColumnAfter:"addColumnAfter",addColumnBefore:"addColumnBefore",addRowAfter:"addRowAfter",addRowBefore:"addRowBefore",clearCell:"clearCell",clearColumn:"clearColumn",clearRow:"clearRow",clearTable:"clearTable",copyTable:"copyTable",deleteColumn:"deleteColumn",deleteRow:"deleteRow",deleteTable:"deleteTable",moveColumnLeft:"moveColumnLeft",moveColumnRight:"moveColumnRight",moveRowDown:"moveRowDown",moveRowUp:"moveRowUp",toggleHeaderColumn:"toggleHeaderColumn",toggleHeaderRow:"toggleHeaderRow"};export const DEFAULT_TABLE_ACTIONS=Object.values(TABLE_ACTIONS);export const TABLE_ACTION_PRESETS={contentOnly:[TABLE_ACTIONS.clearCell,TABLE_ACTIONS.clearRow,TABLE_ACTIONS.clearColumn,TABLE_ACTIONS.clearTable,TABLE_ACTIONS.copyTable],noDestructive:DEFAULT_TABLE_ACTIONS.filter(e=>e!==TABLE_ACTIONS.deleteTable&&e!==TABLE_ACTIONS.clearTable)};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const EDGE=32,MAX_STEP=24,SCROLL_KEYS={x:"scrollLeft",y:"scrollTop"};export const scrollParentOf=(t,n)=>{const e="y"===n?"overflowY":"overflowX";for(let n=null==t?void 0:t.parentElement;n;n=n.parentElement)if(/(auto|scroll)/.test(getComputedStyle(n)[e]))return n;return null};const CLAMP_INSET=8;export const clampToContainer=(t,n,e)=>{const{bottom:o,left:l,right:r,top:c}=t.getBoundingClientRect(),[u,i]="y"===n?[c,o]:[l,r];return Math.min(Math.max(e,u+8),i-8)};export const createAutoScroller=function(t,n){let{grow:e,onScroll:o}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const l=SCROLL_KEYS[n];let r=null,c=null;const u=()=>{if(c=null,null===r)return;const i=(()=>{const{bottom:e,left:o,right:l,top:c}=t.getBoundingClientRect(),[u,i]="y"===n?[c,e]:[o,l];return r>i-32?Math.min(24,Math.ceil((r-(i-32))/4)):r<u+32?-Math.min(24,Math.ceil((u+32-r)/4)):0})();if(!i)return;const a=!!e&&e(i),s=t[l];t[l]=s+i;const m=t[l]!==s;m&&o&&o(),(m||a)&&(c=requestAnimationFrame(u))};return{stop:()=>{r=null,null!==c&&cancelAnimationFrame(c),c=null},update:t=>{r=t,null===c&&(c=requestAnimationFrame(u))}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Extension}from"@tiptap/core";import{clampToContainer,createAutoScroller,scrollParentOf}from"./autoScroll";import{Plugin,PluginKey,TableMap,columnResizingPluginKey}from"./pm";export const columnRects=(e,t)=>{const n=e.state.doc.nodeAt(t),o=TableMap.get(n),r=t+1;return Array.from({length:o.width},(t,n)=>{const l=Array.from({length:o.height},(e,t)=>o.map[t*o.width+n]),s=l.find(e=>{const{left:t,right:n}=o.findCell(e);return n-t===1});return e.nodeDOM(r+(null!=s?s:l[0])).getBoundingClientRect()})};const tablePosAround=(e,t)=>{const n=e.resolve(t);for(let{depth:e}=n;e>0;e--)if("table"===n.node(e).type.name)return n.before(e);return null},hasWidth=e=>Array.isArray(e.attrs.colwidth)&&e.attrs.colwidth.every(e=>e>0),freezeColumnWidths=(e,t)=>{const n=e.state.doc.nodeAt(t),o=TableMap.get(n),r=Array.from(new Set(o.map));if(r.every(e=>hasWidth(n.nodeAt(e))))return;const l=columnRects(e,t).map(e=>Math.round(e.width)),s=t+1,{tr:i}=e.state;r.forEach(e=>{const t=n.nodeAt(e),{left:r,right:a}=o.findCell(e);i.setNodeMarkup(s+e,null,{...t.attrs,colwidth:l.slice(r,a)})}),e.dispatch(i.setMeta("addToHistory",!1))},fixedWidths=e=>{const t=TableMap.get(e);return Array.from(new Set(t.map)).every(t=>hasWidth(e.nodeAt(t)))?Array.from({length:t.width},(n,o)=>{const r=t.map[o];return e.nodeAt(r).attrs.colwidth[o-t.findCell(r).left]}):null},syncTableWidths=e=>{e.state.doc.descendants((t,n)=>{if("table"!==t.type.name)return!0;const o=e.nodeDOM(n),r=o&&("TABLE"===o.nodeName?o:o.querySelector("table")),l=fixedWidths(t);return r&&(r.style.width=l?"".concat(l.reduce((e,t)=>e+t,0),"px"):""),!1})},FORWARDED=Symbol("columnResizeForwarded"),followColumnResize=(e,t)=>{const n=e.nodeDOM(t),o=n&&("TABLE"===n.nodeName?n:n.querySelector("table")),r=scrollParentOf(o,"x");if(!r)return;const l=r.scrollLeft;let s=null,i=0;const a=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=clampToContainer(r,"x",s)+r.scrollLeft-l+t,o=new MouseEvent(e,{bubbles:!0,clientX:n,clientY:i});o[FORWARDED]=!0,window.dispatchEvent(o)},d=createAutoScroller(r,"x",{grow:e=>(a("mousemove",e),e>0),onScroll:()=>a("mousemove")}),c=e=>{e[FORWARDED]||(e.stopImmediatePropagation(),s=e.clientX,i=e.clientY,a("mousemove"),d.update(s))},u=e=>{e[FORWARDED]||(e.stopImmediatePropagation(),d.stop(),window.removeEventListener("mousemove",c,!0),window.removeEventListener("mouseup",u,!0),null===s&&(s=e.clientX),a("mouseup"))};window.addEventListener("mousemove",c,!0),window.addEventListener("mouseup",u,!0)};export const ColumnWidths=Extension.create({name:"columnWidths",addProseMirrorPlugins:()=>[new Plugin({key:new PluginKey("columnWidths"),view:e=>{const t=t=>{if(0!==t.button||!e.editable)return;const n=columnResizingPluginKey.getState(e.state);if(null==n||!n.dragging||n.activeHandle<0)return;const o=tablePosAround(e.state.doc,n.activeHandle);null!==o&&(freezeColumnWidths(e,o),followColumnResize(e,o))};return e.dom.addEventListener("mousedown",t),syncTableWidths(e),{destroy:()=>e.dom.removeEventListener("mousedown",t),update:()=>syncTableWidths(e)}}})]});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{TableMap}from"./pm";import{HANDLE_TYPES}from"./selection";const COPIED_STYLES=["backgroundColor","borderBottom","borderLeft","borderRight","borderTop","color","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","textAlign","verticalAlign"],SHADOW="0px 2px 1px -1px rgba(0,0,0,0.2), 0px 1px 1px 0px rgba(0,0,0,0.14), 0px 1px 3px 0px rgba(0,0,0,0.12)",cloneCell=e=>{const{height:t,width:o}=e.getBoundingClientRect(),n=getComputedStyle(e),r=e.cloneNode(!0);return r.removeAttribute("class"),r.querySelectorAll(".table-handle, .column-resize-handle").forEach(e=>e.remove()),r.querySelectorAll("*").forEach(e=>{e.style.margin="0"}),COPIED_STYLES.forEach(e=>{r.style[e]=n[e]}),Object.assign(r.style,{boxSizing:"border-box",height:"".concat(t,"px"),position:"static",width:"".concat(o,"px")}),r},appendRow=(e,t)=>{const o=document.createElement("tr");t.forEach(e=>o.appendChild(cloneCell(e))),e.appendChild(o)};export const createDragGhost=(e,t,o,n,r)=>{const l=t.type===HANDLE_TYPES.row,a=document.createElement("table");Object.assign(a.style,{borderCollapse:"collapse",boxShadow:SHADOW,left:"0",margin:"0",opacity:"0.85",pointerEvents:"none",position:"fixed",tableLayout:"fixed",top:"0",zIndex:"1400"});const p=document.createElement("tbody");let i;if(a.appendChild(p),l){const e=o.rows[t.index];i=e.getBoundingClientRect(),appendRow(p,Array.from(e.cells))}else{const n=TableMap.get(e.state.doc.nodeAt(t.tablePos)),r=t.tablePos+1,l=Array.from(new Set(Array.from({length:n.height},(e,o)=>n.map[o*n.width+t.index])),t=>e.nodeDOM(r+t));l.forEach(e=>appendRow(p,[e])),i={left:l[0].getBoundingClientRect().left,top:o.getBoundingClientRect().top}}document.body.appendChild(a);const c=n-i.left,d=r-i.top,s=(e,t)=>{const o=l?i.left:e-c,n=l?t-d:i.top;a.style.transform="translate(".concat(o,"px, ").concat(n,"px)")};return s(n,r),{move:s,remove:()=>a.remove()}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createAutoScroller,scrollParentOf}from"./autoScroll";import{hasHeaderColumn,hasHeaderRow}from"./extensions";import{columnRects}from"./columnWidths";import{createDragGhost}from"./dragGhost";import{createGuideLine}from"./guideLine";import{moveTableColumn,moveTableRow}from"./pm";import{HANDLE_TYPES,rebuildSelection}from"./selection";const DRAG_THRESHOLD=4,MOVE_COMMANDS={[HANDLE_TYPES.column]:moveTableColumn,[HANDLE_TYPES.row]:moveTableRow};export const isHeaderLocked=(e,t)=>0===t.index&&(t.type===HANDLE_TYPES.row&&hasHeaderRow(e,t.tablePos)||t.type===HANDLE_TYPES.column&&hasHeaderColumn(e,t.tablePos));const firstMovableIndex=(e,t)=>(t.type===HANDLE_TYPES.row?hasHeaderRow:hasHeaderColumn)(e,t.tablePos)?1:0,tableElementAt=(e,t)=>{const o=e.nodeDOM(t);return o?"TABLE"===o.nodeName?o:o.querySelector("table"):null},trackRects=(e,t,o)=>t.type===HANDLE_TYPES.row?Array.from(o.rows,e=>e.getBoundingClientRect()):columnRects(e,t.tablePos),canMove=(e,t,o)=>{if(o===t.index)return!1;const n=rebuildSelection(e.state.doc,t);if(!n)return!1;const r=e.state.apply(e.state.tr.setSelection(n));return MOVE_COMMANDS[t.type]({from:t.index,select:!1,to:o})(r)},beginDrag=(e,t,o,n)=>{const r=tableElementAt(e,t.tablePos);if(!r)return null;const l=t.type===HANDLE_TYPES.row,a=firstMovableIndex(e.state,t),c=createGuideLine(e);c.element.dataset.dropIndex="";let s=null,i=null;const d=createDragGhost(e,t,r,o,n),u=trackRects(e,t,r)[t.index],m=l?u.top:u.left,p=l?u.height:u.width,E=l?n:o,f=l?"y":"x",v=scrollParentOf(r,f);let h=null;const D=o=>{d.move(o.clientX,o.clientY);const n=trackRects(e,t,r),u=(l?o.clientY:o.clientX)-E,f=m+u+(u>0?p:0),v=Math.max(a,n.filter(e=>(e=>l?e.top+e.height/2:e.left+e.width/2)(e)<f).length);if(v===i)return;i=v;const h=v>t.index?v-1:v;if(s=canMove(e,t,h)?h:null,null===s)return c.hide(),void(c.element.dataset.dropIndex="");c.element.dataset.dropIndex=String(s);const D=0===v?n[0]:n[v-1],S=l?0===v?D.top:D.bottom:0===v?D.left:D.right;l?c.horizontal(r,S):c.vertical(r,S)},S=v&&createAutoScroller(v,f,{onScroll:()=>{i=null,D(h)}}),b=()=>{null==S||S.stop(),c.remove(),d.remove()};return{cancel:b,drop:()=>{if(b(),null===s)return;const o=rebuildSelection(e.state.doc,t);o&&(e.dispatch(e.state.tr.setSelection(o)),MOVE_COMMANDS[t.type]({from:t.index,to:s})(e.state,e.dispatch))},update:e=>{h=e,D(e),null==S||S.update(l?e.clientY:e.clientX)}}};export const trackHandlePointer=(e,t,o,n)=>{let{onClick:r,onDragEnd:l,onDragStart:a}=n;const c=!!MOVE_COMMANDS[t.type]&&!isHeaderLocked(e.state,t),s=o.clientX,i=o.clientY,{body:d}=document,u=d.style.cursor;let m=null,p=!1;const E={},f=()=>{document.removeEventListener("mousemove",E.move),document.removeEventListener("mouseup",E.up),document.removeEventListener("keydown",E.keyDown,!0),d.style.cursor=u};E.move=o=>{if(!m){if(Math.hypot(o.clientX-s,o.clientY-i)<4)return;if(p=!0,!c)return;if(m=beginDrag(e,t,s,i),!m)return;d.style.cursor="grabbing",a()}m.update(o)},E.up=()=>{f(),m?(m.drop(),l(),e.focus()):p||r()},E.keyDown=e=>{"Escape"===e.key&&m&&(e.preventDefault(),e.stopPropagation(),f(),m.cancel(),l())},document.addEventListener("mousemove",E.move),document.addEventListener("mouseup",E.up),document.addEventListener("keydown",E.keyDown,!0)};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const HEADER_CELL_EMAIL_STYLE="border: 1px solid #CCCCCC; padding: 8px 12px; text-align: left; font-family: inherit; font-weight: 600; background-color: #F5F5F5;";export const DATA_CELL_EMAIL_STYLE="border: 1px solid #CCCCCC; padding: 8px 12px; text-align: left; font-family: inherit;";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Extension}from"@tiptap/core";import{Table,TableCell,TableHeader,TableRow}from"@tiptap/extension-table";import{
|
|
1
|
+
import{Extension}from"@tiptap/core";import{Table,TableCell,TableHeader,TableRow}from"@tiptap/extension-table";import{DATA_CELL_EMAIL_STYLE,HEADER_CELL_EMAIL_STYLE}from"./emailStyles";import{DOMSerializer,Decoration,DecorationSet,Plugin,TableMap,moveTableColumn,moveTableRow,selectedRect,toggleHeader}from"./pm";const buildMoveCommand=(e,t)=>l=>r=>{let a,{dispatch:o,state:n}=r;try{a=selectedRect(n)}catch{return!1}const s="row"===e?a.top:a.left,i="row"===e?a.map.height:a.map.width,d=s+l;return!(d<0||d>=i)&&t({from:s,to:d})(n,o)};export const TableMove=Extension.create({name:"tableMove",addCommands:()=>({moveColumn:buildMoveCommand("column",moveTableColumn),moveRow:buildMoveCommand("row",moveTableRow)})});const CELL_MIN_WIDTH=72;export const EnergyTable=Table.extend({addAttributes(){var e;return{...null===(e=this.parent)||void 0===e?void 0:e.call(this),style:{default:null,parseHTML:e=>e.getAttribute("style")||null,renderHTML:e=>e.style?{style:e.style}:{}}}},addKeyboardShortcuts(){var e;return{...null===(e=this.parent)||void 0===e?void 0:e.call(this),"Mod-Alt-t":()=>this.editor.commands.insertTable({cols:3,rows:3,withHeaderRow:!0})}}}).configure({cellMinWidth:72,resizable:!0});export const EnergyTableRow=TableRow.extend({addAttributes(){var e;return{...null===(e=this.parent)||void 0===e?void 0:e.call(this),style:{default:null,parseHTML:e=>e.getAttribute("style")||null,renderHTML:e=>e.style?{style:e.style}:{}}}}});export const EnergyTableHeader=TableHeader.extend({addAttributes(){var e;return{...null===(e=this.parent)||void 0===e?void 0:e.call(this),style:{default:null,parseHTML:e=>e.getAttribute("style")||null,renderHTML:e=>e.style?{style:e.style}:{}}}}});export const EnergyTableCell=TableCell.extend({addAttributes(){var e;return{...null===(e=this.parent)||void 0===e?void 0:e.call(this),style:{default:null,parseHTML:e=>e.getAttribute("style")||null,renderHTML:e=>e.style?{style:e.style}:{}}}}});const uniqueCells=e=>Array.from(new Set(e)),isHeaderCell=(e,t)=>{var l;return"tableHeader"===(null===(l=e.nodeAt(t))||void 0===l?void 0:l.type.name)};export const hasHeaderRow=(e,t)=>{const l=e.doc.nodeAt(t);if(!l||"table"!==l.type.name)return!1;const r=TableMap.get(l);return 0!==r.height&&0!==r.width&&uniqueCells(r.map.slice(0,r.width)).every(e=>isHeaderCell(l,e))};export const hasHeaderColumn=(e,t)=>{const l=e.doc.nodeAt(t);if(!l||"table"!==l.type.name)return!1;const r=TableMap.get(l);if(0===r.height||0===r.width)return!1;const a=hasHeaderRow(e,t)?1:0;if(a>=r.height)return!1;const o=Array.from({length:r.height-a},(e,t)=>{const l=a+t;return r.map[l*r.width]});return uniqueCells(o).every(e=>isHeaderCell(l,e))};export const tableToTabSeparated=e=>{const t=[];return e.forEach(e=>{const l=[];e.forEach(e=>l.push(e.textContent.replace(/\n/g," "))),t.push(l.join("\t"))}),t.join("\n")};const tableToHtml=(e,t)=>{const l=DOMSerializer.fromSchema(t),r=document.createElement("div");return r.appendChild(l.serializeNode(e)),r.innerHTML},clearCells=(e,t,l,r,a)=>{if(!a)return!0;const{tr:o}=r;return uniqueCells(e).forEach(e=>{const r=t.nodeAt(e);if(!r)return;const a=r.type.createAndFill().content;r.content.size<=a.size||o.replaceWith(o.mapping.map(l+e+1),o.mapping.map(l+e+r.nodeSize-1),a)}),o.docChanged&&a(o.scrollIntoView()),!0},buildClearCommand=e=>()=>t=>{let l,{state:r,dispatch:a}=t;try{l=selectedRect(r)}catch{return!1}return clearCells(e(l),l.table,l.tableStart,r,a)},normalizeStyle=e=>(e||"").replace(/\s+/g,"").toLowerCase(),HEADER_STYLE=normalizeStyle(HEADER_CELL_EMAIL_STYLE),DATA_STYLE=normalizeStyle(DATA_CELL_EMAIL_STYLE),swapCellEmailStyles=(e,t)=>{const l=e.doc.nodeAt(t);l&&"table"===l.type.name&&l.descendants((l,r)=>{if("tableHeader"!==l.type.name&&"tableCell"!==l.type.name)return!0;const a="tableHeader"===l.type.name;return normalizeStyle(l.attrs.style)===(a?DATA_STYLE:HEADER_STYLE)&&e.setNodeMarkup(t+1+r,null,{...l.attrs,style:a?HEADER_CELL_EMAIL_STYLE:DATA_CELL_EMAIL_STYLE}),!1})},buildToggleHeader=e=>t=>{let l,{state:r,dispatch:a}=t;try{l=selectedRect(r)}catch{return!1}const o=l.tableStart-1;return toggleHeader(e)(r,a&&(e=>{swapCellEmailStyles(e,o),a(e)}))};export const TableActions=Extension.create({name:"tableActions",addCommands:()=>({clearCell:buildClearCommand(e=>e.map.cellsInRect(e)),clearRow:buildClearCommand(e=>{let{map:t,top:l}=e;const r=[];for(let e=0;e<t.width;e++)r.push(t.map[l*t.width+e]);return r}),clearColumn:buildClearCommand(e=>{let{map:t,left:l}=e;const r=[];for(let e=0;e<t.height;e++)r.push(t.map[e*t.width+l]);return r}),clearTable:buildClearCommand(e=>{let{map:t}=e;return t.map}),copyTable:()=>e=>{let t,{state:l,dispatch:r}=e;try{t=selectedRect(l)}catch{return!1}if(!r)return!0;const{table:a}=t,o=tableToTabSeparated(a),n=tableToHtml(a,l.schema);return(async()=>{var e;if(!window.ClipboardItem||null===(e=navigator.clipboard)||void 0===e||!e.write)throw new Error("ClipboardItem unsupported");await navigator.clipboard.write([new window.ClipboardItem({"text/html":new Blob([n],{type:"text/html"}),"text/plain":new Blob([o],{type:"text/plain"})})])})().catch(()=>navigator.clipboard.writeText(o)).catch(()=>{}),!0},toggleHeaderColumn:()=>buildToggleHeader("column"),toggleHeaderRow:()=>buildToggleHeader("row")})});export const CellFocus=Extension.create({name:"cellFocus",addProseMirrorPlugins:()=>[new Plugin({state:{init:()=>!1,apply(e,t){const l=e.getMeta("cellFocus");return void 0!==l?l:t}},props:{handleDOMEvents:{focus:e=>(e.dispatch(e.state.tr.setMeta("cellFocus",!0)),!1),blur:e=>(e.dispatch(e.state.tr.setMeta("cellFocus",!1)),!1)},decorations(e){if(!this.getState(e))return DecorationSet.empty;const{doc:t,selection:l}=e,{$from:r}=l,a=[];for(let e=r.depth;e>0;e--){const t=r.node(e);if("tableCell"===t.type.name||"tableHeader"===t.type.name){const l=r.before(e);a.push(Decoration.node(l,l+t.nodeSize,{class:"focused-cell"}));break}}return DecorationSet.create(t,a)}}})]});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const visibleRectOf=t=>{let{bottom:e,left:o,right:n,top:i}=t.getBoundingClientRect();for(let c=t.parentElement;c&&c!==document.body;c=c.parentElement){const{overflowX:t,overflowY:l}=getComputedStyle(c),a=c.getBoundingClientRect();"visible"!==t&&(o=Math.max(o,a.left),n=Math.min(n,a.right)),"visible"!==l&&(i=Math.max(i,a.top),e=Math.min(e,a.bottom))}return{bottom:e,left:o,right:n,top:i}};export const createGuideLine=t=>{const e=getComputedStyle(t.dom),o=e.getPropertyValue("--UT-richText-table-drop-indicator-width").trim()||"2px",n=document.createElement("div");Object.assign(n.style,{backgroundColor:e.getPropertyValue("--actionAccent04").trim(),display:"none",pointerEvents:"none",position:"fixed",zIndex:"1400"}),document.body.appendChild(n);const i=()=>{n.style.display="none"};return{element:n,hide:i,horizontal:(t,e)=>{const{bottom:c,left:l,right:a,top:r}=visibleRectOf(t);e<r||e>c||a<=l?i():Object.assign(n.style,{display:"block",height:o,left:"".concat(l,"px"),top:"calc(".concat(e,"px - ").concat(o," / 2)"),width:"".concat(a-l,"px")})},remove:()=>n.remove(),vertical:(t,e)=>{const{bottom:c,left:l,right:a,top:r}=visibleRectOf(t);e<l||e>a||c<=r?i():Object.assign(n.style,{display:"block",height:"".concat(c-r,"px"),left:"calc(".concat(e,"px - ").concat(o," / 2)"),top:"".concat(r,"px"),width:o})}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MODULE_KEYS,TEST_IDS_RICH_TEXT}from"../../constants.js";import TableToolbarButton from"./ToolbarButton.js";import{CellFocus,EnergyTable,EnergyTableCell,EnergyTableHeader,EnergyTableRow}from"./extensions.js";export default{defaultConfig:{allowInsert:!0,allowStructureEdit:!0},extensions:e=>[EnergyTable,EnergyTableRow,EnergyTableHeader,EnergyTableCell,CellFocus],key:MODULE_KEYS.table,testIds:{toolbarButton:TEST_IDS_RICH_TEXT.toolbar.table},ToolbarButton:TableToolbarButton,toolbarButton:{isActive:
|
|
1
|
+
import{MODULE_KEYS,TEST_IDS_RICH_TEXT}from"../../constants.js";import{DEFAULT_TABLE_ACTIONS}from"./actions.js";import TableToolbarButton from"./ToolbarButton.js";import{CellFocus,EnergyTable,EnergyTableCell,EnergyTableHeader,EnergyTableRow,TableActions,TableMove}from"./extensions.js";import{TableHandles}from"./TableHandles.js";import TableMenuOverlay from"./TableMenuOverlay.js";import{ColumnWidths}from"./columnWidths.js";import{RowResizing}from"./rowResizing.js";export default{defaultConfig:{actions:DEFAULT_TABLE_ACTIONS,allowInsert:!0,allowStructureEdit:!0},extensions:e=>[EnergyTable,EnergyTableRow,EnergyTableHeader,EnergyTableCell,CellFocus,TableMove,TableActions,RowResizing,ColumnWidths,...e.allowStructureEdit&&e.actions.length>0?[TableHandles]:[]],EditorOverlay:TableMenuOverlay,key:MODULE_KEYS.table,testIds:{toolbarButton:TEST_IDS_RICH_TEXT.toolbar.table},ToolbarButton:TableToolbarButton,toolbarButton:{isActive:()=>!1}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{TEST_IDS_RICH_TEXT}from"../../constants.js";import{TABLE_ACTIONS}from"./actions";import{hasHeaderColumn,hasHeaderRow}from"./extensions";import{TableMap}from"./pm";import{HANDLE_TYPES,getHandleCellPositions,runWithStoredSelection}from"./selection";const firstMovableRow=(e,o)=>hasHeaderRow(e,o.tablePos)?1:0,firstMovableColumn=(e,o)=>hasHeaderColumn(e,o.tablePos)?1:0,CLEAR_ONE="Borrar contenido de la celda",clearCellsLabel=(e,o)=>getHandleCellPositions(e.doc,o).length>1?"Borrar contenido de las celdas":CLEAR_ONE,clearTableLabel=(e,o)=>getHandleCellPositions(e.doc,o).length>1?"Borrar contenido de la tabla":CLEAR_ONE,tableSize=(e,o)=>{const l=e.doc.nodeAt(o.tablePos);if(!l||"table"!==l.type.name)return{height:0,width:0};const{height:a,width:n}=TableMap.get(l);return{height:a,width:n}};export const TABLE_ACTION_REGISTRY={[TABLE_ACTIONS.clearCell]:{icon:"IconCircleX",label:CLEAR_ONE,run:e=>e.commands.clearCell()},[TABLE_ACTIONS.clearColumn]:{icon:"IconCircleX",label:clearCellsLabel,run:e=>e.commands.clearColumn()},[TABLE_ACTIONS.clearRow]:{icon:"IconCircleX",label:clearCellsLabel,run:e=>e.commands.clearRow()},[TABLE_ACTIONS.clearTable]:{icon:"IconCircleX",label:clearTableLabel,run:e=>e.commands.clearTable()},[TABLE_ACTIONS.copyTable]:{icon:"IconCopy",label:"Copiar tabla",run:e=>e.commands.copyTable()},[TABLE_ACTIONS.toggleHeaderColumn]:{checked:(e,o)=>hasHeaderColumn(e,o.tablePos),icon:"IconTableColumn",label:"Columna de encabezado",run:e=>e.commands.toggleHeaderColumn(),visible:e=>e.type===HANDLE_TYPES.table||e.type===HANDLE_TYPES.column&&0===e.index},[TABLE_ACTIONS.toggleHeaderRow]:{checked:(e,o)=>hasHeaderRow(e,o.tablePos),icon:"IconTableRow",label:"Fila de encabezado",run:e=>e.commands.toggleHeaderRow(),visible:e=>e.type===HANDLE_TYPES.table||e.type===HANDLE_TYPES.row&&0===e.index},[TABLE_ACTIONS.addColumnAfter]:{icon:"IconColumnInsertRight",label:"Añadir columna a la derecha",run:e=>e.commands.addColumnAfter()},[TABLE_ACTIONS.addColumnBefore]:{icon:"IconColumnInsertLeft",label:"Añadir columna a la izquierda",run:e=>e.commands.addColumnBefore()},[TABLE_ACTIONS.addRowAfter]:{icon:"IconRowInsertBottom",label:"Añadir fila abajo",run:e=>e.commands.addRowAfter()},[TABLE_ACTIONS.addRowBefore]:{icon:"IconRowInsertTop",label:"Añadir fila arriba",run:e=>e.commands.addRowBefore()},[TABLE_ACTIONS.deleteColumn]:{enabled:(e,o)=>tableSize(e,o).width>1,icon:"IconTrash",label:"Borrar columna",run:e=>e.commands.deleteColumn()},[TABLE_ACTIONS.deleteRow]:{enabled:(e,o)=>tableSize(e,o).height>1,icon:"IconTrash",label:"Borrar fila",run:e=>e.commands.deleteRow()},[TABLE_ACTIONS.deleteTable]:{icon:"IconTrash",label:"Borrar tabla",run:e=>e.commands.deleteTable()},[TABLE_ACTIONS.moveColumnLeft]:{enabled:(e,o)=>o.index>firstMovableColumn(e,o),icon:"IconArrowLeft",label:"Mover columna a la izquierda",run:e=>e.commands.moveColumn(-1)},[TABLE_ACTIONS.moveColumnRight]:{enabled:(e,o)=>o.index>=firstMovableColumn(e,o)&&o.index<tableSize(e,o).width-1,icon:"IconArrowRight",label:"Mover columna a la derecha",run:e=>e.commands.moveColumn(1)},[TABLE_ACTIONS.moveRowDown]:{enabled:(e,o)=>o.index>=firstMovableRow(e,o)&&o.index<tableSize(e,o).height-1,icon:"IconArrowDown",label:"Mover fila abajo",run:e=>e.commands.moveRow(1)},[TABLE_ACTIONS.moveRowUp]:{enabled:(e,o)=>o.index>firstMovableRow(e,o),icon:"IconArrowUp",label:"Mover fila arriba",run:e=>e.commands.moveRow(-1)}};export const MENU_GROUPS={[HANDLE_TYPES.cell]:[[TABLE_ACTIONS.addColumnAfter,TABLE_ACTIONS.addRowAfter],[TABLE_ACTIONS.clearCell,TABLE_ACTIONS.deleteColumn,TABLE_ACTIONS.deleteRow]],[HANDLE_TYPES.column]:[[TABLE_ACTIONS.toggleHeaderColumn],[TABLE_ACTIONS.addColumnBefore,TABLE_ACTIONS.addColumnAfter,TABLE_ACTIONS.moveColumnLeft,TABLE_ACTIONS.moveColumnRight],[TABLE_ACTIONS.clearColumn,TABLE_ACTIONS.deleteColumn]],[HANDLE_TYPES.row]:[[TABLE_ACTIONS.toggleHeaderRow],[TABLE_ACTIONS.addRowBefore,TABLE_ACTIONS.addRowAfter,TABLE_ACTIONS.moveRowUp,TABLE_ACTIONS.moveRowDown],[TABLE_ACTIONS.clearRow,TABLE_ACTIONS.deleteRow]],[HANDLE_TYPES.table]:[[TABLE_ACTIONS.toggleHeaderColumn,TABLE_ACTIONS.toggleHeaderRow],[TABLE_ACTIONS.copyTable],[TABLE_ACTIONS.clearTable,TABLE_ACTIONS.deleteTable]]};export const buildTableMenu=(e,o,l)=>{const a=new Set(l),n={};return{groups:MENU_GROUPS[o.type].map(l=>l.filter(l=>{const r=TABLE_ACTION_REGISTRY[l];return!(!a.has(l)||!r)&&(!(r.visible&&!r.visible(o))&&(n[l]={checked:r.checked?r.checked(e.state,o):void 0,dataTestId:TEST_IDS_RICH_TEXT.tableMenu[o.type][l],disabled:!!r.enabled&&!r.enabled(e.state,o),icon:r.icon,label:"function"==typeof r.label?r.label(e.state,o):r.label,onSelect:()=>runWithStoredSelection(e,o,r.run)},!0))})).filter(e=>e.length>0),items:n}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{Plugin,PluginKey,Selection}from"prosemirror-state";export{DOMSerializer}from"prosemirror-model";export{Decoration,DecorationSet}from"prosemirror-view";export{CellSelection,TableMap,columnResizingPluginKey,deleteCellSelection,moveTableColumn,moveTableRow,selectedRect,toggleHeader}from"prosemirror-tables";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Extension}from"@tiptap/core";import{clampToContainer,createAutoScroller,scrollParentOf}from"./autoScroll";import{createGuideLine}from"./guideLine";import{Decoration,DecorationSet,Plugin,PluginKey}from"./pm";export const rowResizingKey=new PluginKey("rowResizing");const EDGE=5,CURSOR_CLASS="row-resize-cursor",COLUMN_CURSOR_CLASS="resize-cursor",rowEdgeAt=(e,t)=>{var o,n;const r=null===(o=t.target)||void 0===o||null===(n=o.closest)||void 0===n?void 0:n.call(o,"td, th");if(!r||!e.dom.contains(r))return null;const i=r.parentElement,{bottom:l,top:s}=i.getBoundingClientRect();return Math.abs(t.clientY-l)<=5?i:Math.abs(t.clientY-s)<=5?i.previousElementSibling:null},rowPosOf=(e,t)=>{try{var o;const n=e.posAtDOM(t,0)-1;return"tableRow"===(null===(o=e.state.doc.nodeAt(n))||void 0===o?void 0:o.type.name)?n:null}catch{return null}},verticalExtras=e=>{const t=getComputedStyle(e);return["paddingTop","paddingBottom","borderTopWidth","borderBottomWidth"].reduce((e,o)=>e+(parseFloat(t[o])||0),0)},contentHeight=e=>Math.max(...Array.from(e.cells,e=>Array.from(e.children).filter(e=>"absolute"!==getComputedStyle(e).position).reduce((e,t)=>e+t.getBoundingClientRect().height,0)+verticalExtras(e)));export const withHeight=(e,t)=>[...(e||"").split(";").map(e=>e.trim()).filter(e=>e&&!/^height\s*:/i.test(e)),"height: ".concat(t,"px")].join("; ");const setPreview=(e,t)=>e.dispatch(e.state.tr.setMeta(rowResizingKey,{preview:t})),startResize=(e,t,o)=>{const n=rowPosOf(e,t);if(null===n)return!1;const r=o.clientY,i=t.getBoundingClientRect().height,l=contentHeight(t),s=createGuideLine(e),c=scrollParentOf(t,"y"),a=c?c.scrollTop:0;let u=r,d=i;const m=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;const t=c?clampToContainer(c,"y",u):u,o=c?c.scrollTop-a+e:0;return Math.round(Math.max(l,i+t-r+o))},p=()=>{const t=e.nodeDOM(n);t&&s.horizontal(t.closest("table"),t.getBoundingClientRect().bottom)},g=t=>t!==d&&(d=t,setPreview(e,{height:d,pos:n}),p(),!0),v=c&&createAutoScroller(c,"y",{grow:e=>g(m(e)),onScroll:()=>{g(m()),p()}}),h=e=>{u=e.clientY,g(m()),null==v||v.update(u)},w=()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",w),null==v||v.stop(),s.remove();const t=e.state.doc.nodeAt(n),o=e.state.tr.setMeta(rowResizingKey,{preview:null});t&&Math.abs(d-i)>=1&&o.setNodeMarkup(n,null,{...t.attrs,style:withHeight(t.attrs.style,d)}),e.dispatch(o)};return p(),document.addEventListener("mousemove",h),document.addEventListener("mouseup",w),!0},previewDecorations=(e,t)=>{const o=t&&e.nodeAt(t.pos);return o&&"tableRow"===o.type.name?DecorationSet.create(e,[Decoration.node(t.pos,t.pos+o.nodeSize,{style:"height: ".concat(t.height,"px")})]):DecorationSet.empty};export const RowResizing=Extension.create({name:"rowResizing",addProseMirrorPlugins(){let e=null,t=null,o=null;const n=(o,n)=>{var r;(e=n,o.dom.classList.toggle(CURSOR_CLASS,!!n),n)?(t=t||createGuideLine(o),t.horizontal(n.closest("table"),n.getBoundingClientRect().bottom)):null===(r=t)||void 0===r||r.hide()};return[new Plugin({key:rowResizingKey,state:{init:()=>null,apply:(e,t)=>{const o=e.getMeta(rowResizingKey);return o?o.preview:t}},view:r=>{const i=()=>{if(!e||!o)return;const t=document.elementFromPoint(o.clientX,o.clientY);n(r,rowEdgeAt(r,{clientY:o.clientY,target:t}))};return document.addEventListener("scroll",i,!0),{destroy:()=>{var e;document.removeEventListener("scroll",i,!0),null===(e=t)||void 0===e||e.remove(),t=null}}},props:{decorations:e=>previewDecorations(e.doc,rowResizingKey.getState(e)),handleDOMEvents:{mouseleave:e=>(o=null,n(e,null),!1),mousedown:(t,o)=>!(!e||0!==o.button||!t.editable)&&(!!startResize(t,e,o)&&(o.preventDefault(),n(t,null),!0)),mousemove:(t,r)=>{if(o={clientX:r.clientX,clientY:r.clientY},!t.editable||r.buttons||t.dom.classList.contains("resize-cursor"))return e&&n(t,null),!1;const i=rowEdgeAt(t,r);return(i||i!==e)&&n(t,i),!1}}}})]}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{CellSelection,TableMap}from"./pm";export const HANDLE_TYPES={cell:"cell",column:"column",row:"row",table:"table"};export const buildHandleRef=(t,e)=>{var l;return{index:null!==(l=e.index)&&void 0!==l?l:0,tablePos:e.tablePos,type:e.type}};export const getHandleCellPositions=(t,e)=>{const{index:l,tablePos:o,type:n}=e,r=t.nodeAt(o);if(!r||"table"!==r.type.name)return[];const i=TableMap.get(r);if(n===HANDLE_TYPES.row&&l>=i.height)return[];if(n===HANDLE_TYPES.column&&l>=i.width)return[];if(n===HANDLE_TYPES.cell&&!i.map.includes(l))return[];const c=o+1;if(n===HANDLE_TYPES.cell)return[c+l];let s;return s=n===HANDLE_TYPES.row?{bottom:l+1,left:0,right:i.width,top:l}:n===HANDLE_TYPES.column?{bottom:i.height,left:l,right:l+1,top:0}:{bottom:i.height,left:0,right:i.width,top:0},i.cellsInRect(s).map(t=>c+t)};export const rebuildSelection=(t,e)=>{const l=getHandleCellPositions(t,e);if(!l.length)return null;try{return CellSelection.create(t,l[0],l[l.length-1])}catch{return null}};export const runWithStoredSelection=(t,e,l)=>{const{view:o}=t,n=rebuildSelection(o.state.doc,e);n&&o.dispatch(o.state.tr.setSelection(n)),l(t),o.focus()};
|
|
@@ -119,6 +119,8 @@
|
|
|
119
119
|
th {
|
|
120
120
|
border: 1px solid var(--light05);
|
|
121
121
|
min-width: var(--UT-textEditor-table-cell-min-width, 40px);
|
|
122
|
+
// sass-lint:disable-block no-important
|
|
123
|
+
overflow: visible !important;
|
|
122
124
|
padding: var(--UT-textEditor-table-cell-padding-y, 6px) var(--UT-textEditor-table-cell-padding-x, 8px);
|
|
123
125
|
position: relative;
|
|
124
126
|
vertical-align: top;
|
|
@@ -126,10 +128,6 @@
|
|
|
126
128
|
> * {
|
|
127
129
|
margin: 0;
|
|
128
130
|
}
|
|
129
|
-
|
|
130
|
-
&:hover :global(.column-resize-handle) {
|
|
131
|
-
opacity: 1;
|
|
132
|
-
}
|
|
133
131
|
}
|
|
134
132
|
|
|
135
133
|
th {
|
|
@@ -182,26 +180,174 @@
|
|
|
182
180
|
|
|
183
181
|
:global(.column-resize-handle) {
|
|
184
182
|
background-color: var(--actionAccent04);
|
|
185
|
-
bottom: -
|
|
183
|
+
bottom: -1px;
|
|
186
184
|
opacity: 0;
|
|
187
185
|
pointer-events: none;
|
|
188
186
|
position: absolute;
|
|
189
187
|
right: -1px;
|
|
190
|
-
top: -
|
|
188
|
+
top: -1px;
|
|
191
189
|
transition: opacity 0.15s ease;
|
|
192
190
|
width: 2px;
|
|
193
191
|
z-index: 10;
|
|
194
192
|
}
|
|
195
193
|
|
|
196
|
-
|
|
194
|
+
&:global(.resize-cursor) {
|
|
197
195
|
cursor: col-resize;
|
|
196
|
+
|
|
197
|
+
:global(.column-resize-handle) {
|
|
198
|
+
opacity: 1;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
&:global(.row-resize-cursor) {
|
|
203
|
+
cursor: row-resize;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
&:global(.has-table-handles) :global(.tableWrapper) {
|
|
207
|
+
padding-left: calc(var(--UT-richText-table-grip-height-active) + var(--gap-sm));
|
|
208
|
+
padding-top: calc(var(--UT-richText-table-grip-height-active) / 2);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
&[contenteditable='false'] :global(.table-handle) {
|
|
212
|
+
display: none;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
:global(.table-handle) {
|
|
216
|
+
align-items: center;
|
|
217
|
+
background-color: var(--light05);
|
|
218
|
+
border-radius: var(--UT-richText-table-grip-radius);
|
|
219
|
+
box-sizing: border-box;
|
|
220
|
+
color: var(--light01);
|
|
221
|
+
cursor: pointer;
|
|
222
|
+
display: flex;
|
|
223
|
+
justify-content: center;
|
|
224
|
+
opacity: 0;
|
|
225
|
+
position: absolute;
|
|
226
|
+
transform: translate(-50%, -50%);
|
|
227
|
+
transition: opacity 0.15s ease;
|
|
228
|
+
user-select: none;
|
|
229
|
+
z-index: 4;
|
|
230
|
+
|
|
231
|
+
&:hover {
|
|
232
|
+
background-color: var(--gray04);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
&:global(.table-handle--visible) {
|
|
236
|
+
opacity: 1;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
&:focus {
|
|
240
|
+
opacity: 1;
|
|
241
|
+
outline: 2px solid var(--actionAccent04);
|
|
242
|
+
outline-offset: 1px;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
svg {
|
|
246
|
+
height: var(--UT-richText-table-grip-icon-size);
|
|
247
|
+
width: var(--UT-richText-table-grip-icon-size);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
:global(.table-handle--column),
|
|
252
|
+
:global(.table-handle--row) {
|
|
253
|
+
svg {
|
|
254
|
+
display: none;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
&:hover,
|
|
258
|
+
&:global(.table-handle--active) {
|
|
259
|
+
background-color: var(--actionAccent04);
|
|
260
|
+
|
|
261
|
+
svg {
|
|
262
|
+
display: block;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
:global(.table-handle--column) {
|
|
268
|
+
height: var(--UT-richText-table-grip-height);
|
|
269
|
+
left: 50%;
|
|
270
|
+
top: 0;
|
|
271
|
+
width: var(--UT-richText-table-grip-width);
|
|
272
|
+
|
|
273
|
+
&:hover {
|
|
274
|
+
height: var(--UT-richText-table-grip-height-active);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
:global(.table-handle--row) {
|
|
279
|
+
height: var(--UT-richText-table-grip-width);
|
|
280
|
+
left: 0;
|
|
281
|
+
top: 50%;
|
|
282
|
+
width: var(--UT-richText-table-grip-height);
|
|
283
|
+
|
|
284
|
+
&:hover {
|
|
285
|
+
width: var(--UT-richText-table-grip-height-active);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
:global(.table-handle--cell) {
|
|
290
|
+
height: var(--UT-richText-table-cell-handle-size);
|
|
291
|
+
right: 2px;
|
|
292
|
+
top: 2px;
|
|
293
|
+
transform: none;
|
|
294
|
+
width: var(--UT-richText-table-cell-handle-size);
|
|
295
|
+
z-index: 5;
|
|
296
|
+
|
|
297
|
+
svg {
|
|
298
|
+
height: var(--UT-richText-table-cell-handle-icon-size);
|
|
299
|
+
width: var(--UT-richText-table-cell-handle-icon-size);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
:global(.table-handle--table) {
|
|
304
|
+
background-color: var(--light01);
|
|
305
|
+
border: 1px solid var(--light05);
|
|
306
|
+
color: var(--gray04);
|
|
307
|
+
height: var(--UT-richText-table-grip-width);
|
|
308
|
+
left: calc(-1 * (var(--UT-richText-table-grip-height-active) + var(--gap-sm)));
|
|
309
|
+
top: 0;
|
|
310
|
+
transform: none;
|
|
311
|
+
width: var(--UT-richText-table-grip-height-active);
|
|
312
|
+
|
|
313
|
+
&:hover {
|
|
314
|
+
background-color: var(--light03);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
:global(.table-handle--active) {
|
|
319
|
+
background-color: var(--actionAccent04);
|
|
320
|
+
opacity: 1;
|
|
321
|
+
|
|
322
|
+
&:hover {
|
|
323
|
+
background-color: var(--actionAccent04);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
&:global(.table-handle--column) {
|
|
327
|
+
height: var(--UT-richText-table-grip-height-active);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
&:global(.table-handle--row) {
|
|
331
|
+
width: var(--UT-richText-table-grip-height-active);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
&:global(.table-handle--table) {
|
|
335
|
+
border-color: var(--actionAccent04);
|
|
336
|
+
color: var(--light01);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
:global(.table-drag-source) {
|
|
341
|
+
opacity: 0.4;
|
|
198
342
|
}
|
|
199
343
|
|
|
200
|
-
.selectedCell {
|
|
344
|
+
:global(.selectedCell) {
|
|
201
345
|
&::after {
|
|
202
|
-
background: var(--actionAccent01);
|
|
346
|
+
background-color: var(--actionAccent01);
|
|
347
|
+
box-shadow: inset 0 0 0 1px var(--actionAccent04);
|
|
203
348
|
content: '';
|
|
204
|
-
inset:
|
|
349
|
+
inset: -1px;
|
|
350
|
+
mix-blend-mode: multiply;
|
|
205
351
|
pointer-events: none;
|
|
206
352
|
position: absolute;
|
|
207
353
|
z-index: 2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getSchema}from"@tiptap/core";import{generateHTML,generateJSON}from"@tiptap/html";import isEmpty from"lodash/isEmpty";import{buildBaseExtensions}from"../constants.js";import{dedupeExtensions}from"../utils.js";import{buildModuleGroups}from"./moduleResolution.js";export const buildSerializationExtensions=function(){let{moduleConfig:e,modules:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return dedupeExtensions([...buildBaseExtensions({}),...buildModuleGroups(t,e).flat().flatMap(e=>e.resolvedExtensions)])};const buildEmptyParagraph=()=>({type:"paragraph"}),buildPlainInlineContent=e=>e?[{type:"text",text:e}]:[],buildInlineNodes=(e,t)=>(e||[]).reduce((e,n)=>{var o;if("text"===n.type||null!==(o=t.nodes[n.type])&&void 0!==o&&o.isInline)return[...e,n];const l=buildInlineNodes(n.content,t);return isEmpty(l)?e:isEmpty(e)?l:[...e,{type:"hardBreak"},...l]},[]),buildInlineHTMLContent=(e,t)=>{let{extensions:n,schema:o}=t;if(!e)return[];const{content:l}=generateJSON("<p>".concat(e,"</p>"),n);return buildInlineNodes(l,o)},buildInlineContentResolver=function(){let{inlineHTML:e,moduleConfig:t,modules:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e)return buildPlainInlineContent;const o=buildSerializationExtensions({moduleConfig:t,modules:n}),l=getSchema(o);return e=>buildInlineHTMLContent(e,{extensions:o,schema:l})},PARAGRAPH_SEPARATOR=/(?:\r?\n){2,}/,LINE_SEPARATOR=/\r?\n/,buildParagraphContent=(e,t)=>e.split(LINE_SEPARATOR).map(t).reduce((e,t)=>isEmpty(t)?e:isEmpty(e)?t:[...e,{type:"hardBreak"},...t],[]);export const buildParagraphNodes=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return[buildEmptyParagraph()];const n=buildInlineContentResolver(t);return e.split(PARAGRAPH_SEPARATOR).map(e=>{const t=buildParagraphContent(e,n);return isEmpty(t)?buildEmptyParagraph():{type:"paragraph",content:t}})};export const buildNodesFromHTML=function(e){let{moduleConfig:t,modules:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return[buildEmptyParagraph()];const{content:o}=generateJSON(e,buildSerializationExtensions({moduleConfig:t,modules:n}));return isEmpty(o)?[buildEmptyParagraph()]:o};const TABLE_HEADER_TYPE="tableHeader",TABLE_EMAIL_STYLE="border-collapse: collapse; width: 100%; border-spacing: 0;",
|
|
1
|
+
import{getSchema}from"@tiptap/core";import{generateHTML,generateJSON}from"@tiptap/html";import isEmpty from"lodash/isEmpty";import{buildBaseExtensions}from"../constants.js";import{dedupeExtensions}from"../utils.js";import{DATA_CELL_EMAIL_STYLE,HEADER_CELL_EMAIL_STYLE}from"../modules/table/emailStyles.js";import{buildModuleGroups}from"./moduleResolution.js";export const buildSerializationExtensions=function(){let{moduleConfig:e,modules:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return dedupeExtensions([...buildBaseExtensions({}),...buildModuleGroups(t,e).flat().flatMap(e=>e.resolvedExtensions)])};const buildEmptyParagraph=()=>({type:"paragraph"}),buildPlainInlineContent=e=>e?[{type:"text",text:e}]:[],buildInlineNodes=(e,t)=>(e||[]).reduce((e,n)=>{var o;if("text"===n.type||null!==(o=t.nodes[n.type])&&void 0!==o&&o.isInline)return[...e,n];const l=buildInlineNodes(n.content,t);return isEmpty(l)?e:isEmpty(e)?l:[...e,{type:"hardBreak"},...l]},[]),buildInlineHTMLContent=(e,t)=>{let{extensions:n,schema:o}=t;if(!e)return[];const{content:l}=generateJSON("<p>".concat(e,"</p>"),n);return buildInlineNodes(l,o)},buildInlineContentResolver=function(){let{inlineHTML:e,moduleConfig:t,modules:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e)return buildPlainInlineContent;const o=buildSerializationExtensions({moduleConfig:t,modules:n}),l=getSchema(o);return e=>buildInlineHTMLContent(e,{extensions:o,schema:l})},PARAGRAPH_SEPARATOR=/(?:\r?\n){2,}/,LINE_SEPARATOR=/\r?\n/,buildParagraphContent=(e,t)=>e.split(LINE_SEPARATOR).map(t).reduce((e,t)=>isEmpty(t)?e:isEmpty(e)?t:[...e,{type:"hardBreak"},...t],[]);export const buildParagraphNodes=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return[buildEmptyParagraph()];const n=buildInlineContentResolver(t);return e.split(PARAGRAPH_SEPARATOR).map(e=>{const t=buildParagraphContent(e,n);return isEmpty(t)?buildEmptyParagraph():{type:"paragraph",content:t}})};export const buildNodesFromHTML=function(e){let{moduleConfig:t,modules:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return[buildEmptyParagraph()];const{content:o}=generateJSON(e,buildSerializationExtensions({moduleConfig:t,modules:n}));return isEmpty(o)?[buildEmptyParagraph()]:o};const TABLE_HEADER_TYPE="tableHeader",TABLE_EMAIL_STYLE="border-collapse: collapse; width: 100%; border-spacing: 0;",buildParagraph=(e,t)=>({type:"paragraph",content:e?t(String(e)):[]});export const buildTableNode=e=>{let{cellColwidth:t,headers:n,inlineHTML:o,moduleConfig:l,modules:i,rows:r}=e;const a=buildInlineContentResolver({inlineHTML:o,moduleConfig:l,modules:i});return{type:"table",attrs:{style:TABLE_EMAIL_STYLE},content:[{type:"tableRow",content:n.map(e=>({type:"tableHeader",attrs:{colspan:1,colwidth:t?[t]:null,rowspan:1,style:HEADER_CELL_EMAIL_STYLE},content:[buildParagraph(e,a)]}))},...r.map(e=>({type:"tableRow",content:e.map(e=>({type:"tableCell",attrs:{colspan:1,colwidth:t?[t]:null,rowspan:1,style:DATA_CELL_EMAIL_STYLE},content:[buildParagraph(e,a)]}))}))]}};const serializeInlineContent=(e,t)=>(e||[]).map(e=>generateHTML({type:"doc",content:[e]},t).replace(/^<p>|<\/p>$/g,"")).filter(Boolean).join("<br>");export const readTableNode=function(e){var t;let{moduleConfig:n,modules:o}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const l=buildSerializationExtensions({moduleConfig:n,modules:o}),i=e=>serializeInlineContent(e.content,l),r=(null==e?void 0:e.content)||[],a="tableHeader"===(null===(t=r[0])||void 0===t||null===(t=t.content)||void 0===t||null===(t=t[0])||void 0===t?void 0:t.type),[s,d]=a?[r[0],r.slice(1)]:[null,r],u=((null==s?void 0:s.content)||[]).map(e=>{var t;return null===(t=e.attrs)||void 0===t||null===(t=t.colwidth)||void 0===t?void 0:t[0]}),[p]=u;return{cellColwidth:u.every(e=>e===p)&&null!=p?p:void 0,headers:((null==s?void 0:s.content)||[]).map(i),inlineHTML:!0,rows:d.map(e=>(e.content||[]).map(i))}};export const serializeToHTML=function(e){let{moduleConfig:t,modules:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return generateHTML(e,buildSerializationExtensions({moduleConfig:t,modules:n}))};
|