@wavemaker/react-runtime 11.14.1-16.6404
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/actions/base-action.js +32 -0
- package/actions/login-action.js +53 -0
- package/actions/logout-action.js +41 -0
- package/actions/navigation-action.js +145 -0
- package/actions/notification-action.js +147 -0
- package/actions/timer-action.js +164 -0
- package/actions/toast-provider.js +111 -0
- package/actions/toast.js +115 -0
- package/actions/toast.service.js +94 -0
- package/actions/types/index.js +11 -0
- package/components/advanced/carousel/index.js +456 -0
- package/components/advanced/carousel/props.js +5 -0
- package/components/advanced/carousel/template.js +72 -0
- package/components/advanced/login/index.js +307 -0
- package/components/advanced/login/props.js +5 -0
- package/components/advanced/marquee/index.js +158 -0
- package/components/advanced/marquee/props.js +5 -0
- package/components/basic/anchor/index.js +239 -0
- package/components/basic/anchor/props.js +5 -0
- package/components/basic/audio/index.js +61 -0
- package/components/basic/html/index.js +158 -0
- package/components/basic/icon/index.js +85 -0
- package/components/basic/iframe/iframe.utils.js +10 -0
- package/components/basic/iframe/index.js +95 -0
- package/components/basic/label/index.js +139 -0
- package/components/basic/message/index.js +120 -0
- package/components/basic/message/props.js +5 -0
- package/components/basic/picture/index.js +117 -0
- package/components/basic/picture/props.js +5 -0
- package/components/basic/progress-bar/index.js +168 -0
- package/components/basic/progress-bar/props.js +18 -0
- package/components/basic/progress-circle/index.js +196 -0
- package/components/basic/progress-circle/props.js +16 -0
- package/components/basic/richtexteditor/index.js +533 -0
- package/components/basic/richtexteditor/props.js +5 -0
- package/components/basic/search/index.js +1023 -0
- package/components/basic/search/props.js +5 -0
- package/components/basic/search/providers.js +350 -0
- package/components/basic/spinner/index.js +202 -0
- package/components/basic/spinner/props.js +12 -0
- package/components/basic/tile/index.js +91 -0
- package/components/basic/tree/Components/TreeNodeComponent.js +142 -0
- package/components/basic/tree/index.js +503 -0
- package/components/basic/tree/props.js +5 -0
- package/components/basic/tree/utils.js +154 -0
- package/components/basic/video/index.js +85 -0
- package/components/basic/video/props.js +5 -0
- package/components/chart/components/barColumnChart/index.js +132 -0
- package/components/chart/components/barColumnChart/props.js +5 -0
- package/components/chart/components/bubbleChart/index.js +176 -0
- package/components/chart/components/bubbleChart/props.js +5 -0
- package/components/chart/components/chartLegend/components/ClassicLegendItem.js +39 -0
- package/components/chart/components/chartLegend/components/FuriousLegendItem.js +81 -0
- package/components/chart/components/chartLegend/index.js +69 -0
- package/components/chart/components/chartLegend/props.js +5 -0
- package/components/chart/components/chartLegend/utils.js +31 -0
- package/components/chart/components/chartTooltip/index.js +53 -0
- package/components/chart/components/chartTooltip/styles.js +37 -0
- package/components/chart/components/chartTooltip/utils.js +23 -0
- package/components/chart/components/cumulativeLineChart/index.js +113 -0
- package/components/chart/components/cumulativeLineChart/props.js +5 -0
- package/components/chart/components/cumulativeLineChart/utils.js +34 -0
- package/components/chart/components/index.js +40 -0
- package/components/chart/components/lineAreaChart/index.js +140 -0
- package/components/chart/components/lineAreaChart/props.js +5 -0
- package/components/chart/components/noDataMessage/index.js +27 -0
- package/components/chart/components/pieDonutChart/index.js +171 -0
- package/components/chart/components/pieDonutChart/props.js +5 -0
- package/components/chart/constant.js +72 -0
- package/components/chart/index.js +930 -0
- package/components/chart/props.js +5 -0
- package/components/chart/utils.js +691 -0
- package/components/common/AppSpinner.js +36 -0
- package/components/common/app-spinner.js +26 -0
- package/components/common/index.js +12 -0
- package/components/constants.js +1208 -0
- package/components/container/accordion/accordion-pane/index.js +108 -0
- package/components/container/accordion/accordion-pane/props.js +11 -0
- package/components/container/accordion/index.js +232 -0
- package/components/container/accordion/props.js +13 -0
- package/components/container/alignment-utils.js +183 -0
- package/components/container/index.js +188 -0
- package/components/container/layout-grid/grid-column/index.js +34 -0
- package/components/container/layout-grid/grid-row/index.js +24 -0
- package/components/container/layout-grid/index.js +33 -0
- package/components/container/linear-layout/index.js +72 -0
- package/components/container/linear-layout/linear-layout-item/index.js +43 -0
- package/components/container/panel/components/panel-header/index.js +144 -0
- package/components/container/panel/components/panel-header/props.js +5 -0
- package/components/container/panel/hooks.js +144 -0
- package/components/container/panel/index.js +286 -0
- package/components/container/panel/props.js +5 -0
- package/components/container/props.js +5 -0
- package/components/container/tabs/index.js +379 -0
- package/components/container/tabs/props.js +20 -0
- package/components/container/tabs/tab-pane/index.js +42 -0
- package/components/container/tabs/tab-pane/props.js +5 -0
- package/components/container/wizard/WizardContext.js +16 -0
- package/components/container/wizard/components/StepComponents.js +100 -0
- package/components/container/wizard/components/WizardStep.js +89 -0
- package/components/container/wizard/index.js +710 -0
- package/components/container/wizard/props.js +5 -0
- package/components/container/wizard/utils.js +133 -0
- package/components/container/wizard/wizard-action/index.js +22 -0
- package/components/container/wizard/wizard-step/index.js +94 -0
- package/components/data/card/card-actions/index.js +24 -0
- package/components/data/card/card-content/index.js +38 -0
- package/components/data/card/card-footer/index.js +24 -0
- package/components/data/card/index.js +246 -0
- package/components/data/card/props.js +5 -0
- package/components/data/form/base-form/constant.js +39 -0
- package/components/data/form/base-form/index.js +460 -0
- package/components/data/form/base-form/props.js +29 -0
- package/components/data/form/base-form/utils.js +42 -0
- package/components/data/form/dynamic-fields/index.js +196 -0
- package/components/data/form/dynamic-fields/props.js +5 -0
- package/components/data/form/dynamic-fields/utils.js +237 -0
- package/components/data/form/form-action/index.js +71 -0
- package/components/data/form/form-body/index.js +26 -0
- package/components/data/form/form-context.js +34 -0
- package/components/data/form/form-controller/props.js +19 -0
- package/components/data/form/form-controller/validation-contrustor.js +313 -0
- package/components/data/form/form-controller/withFormController.js +320 -0
- package/components/data/form/form-field/base-field.js +138 -0
- package/components/data/form/form-field/index.js +36 -0
- package/components/data/form/form-field/props.js +5 -0
- package/components/data/form/form-footer/index.js +26 -0
- package/components/data/form/form-header/index.js +56 -0
- package/components/data/form/index.js +39 -0
- package/components/data/form/props.js +5 -0
- package/components/data/list/components/GroupHeader.js +35 -0
- package/components/data/list/components/GroupedListItems.js +98 -0
- package/components/data/list/components/ListContainer.js +27 -0
- package/components/data/list/components/ListDND.js +241 -0
- package/components/data/list/components/ListHeader.js +59 -0
- package/components/data/list/components/ListItem.js +148 -0
- package/components/data/list/components/ListItemWithTemplate.js +59 -0
- package/components/data/list/components/ListItems.js +231 -0
- package/components/data/list/components/ListPagination.js +165 -0
- package/components/data/list/components/LoadMoreButton.js +39 -0
- package/components/data/list/components/NoDataMessage.js +22 -0
- package/components/data/list/components/StandardListItems.js +84 -0
- package/components/data/list/components/index.js +119 -0
- package/components/data/list/components/props.js +5 -0
- package/components/data/list/hooks/index.js +75 -0
- package/components/data/list/hooks/props.js +5 -0
- package/components/data/list/hooks/useCurrentPageItems.js +48 -0
- package/components/data/list/hooks/useGroupedData.js +37 -0
- package/components/data/list/hooks/useListData.js +60 -0
- package/components/data/list/hooks/useListEffects.js +285 -0
- package/components/data/list/hooks/useListEventHandlers.js +291 -0
- package/components/data/list/hooks/useListPagination.js +168 -0
- package/components/data/list/hooks/useListState.js +98 -0
- package/components/data/list/hooks/useListStateManager.js +195 -0
- package/components/data/list/hooks/usePaginatedGroupedData.js +121 -0
- package/components/data/list/index.js +611 -0
- package/components/data/list/props.js +5 -0
- package/components/data/list/templates/media-template.js +53 -0
- package/components/data/list/utils/constants.js +81 -0
- package/components/data/list/utils/list-helpers.js +173 -0
- package/components/data/list/utils/list-widget-methods.js +114 -0
- package/components/data/live-filter/index.js +279 -0
- package/components/data/live-filter/props.js +12 -0
- package/components/data/live-form/index.js +93 -0
- package/components/data/live-form/props.js +16 -0
- package/components/data/pagination/components/BasicPagination.js +77 -0
- package/components/data/pagination/components/ClassicPagination.js +191 -0
- package/components/data/pagination/components/InlinePagination.js +99 -0
- package/components/data/pagination/components/LoadingComponent.js +31 -0
- package/components/data/pagination/components/PageSizeSelector.js +175 -0
- package/components/data/pagination/components/PagerNavigation.js +105 -0
- package/components/data/pagination/components/TotalRecords.js +52 -0
- package/components/data/pagination/components/index.js +47 -0
- package/components/data/pagination/components/props.js +5 -0
- package/components/data/pagination/hooks/index.js +19 -0
- package/components/data/pagination/hooks/props.js +5 -0
- package/components/data/pagination/hooks/useNavigationSize.js +44 -0
- package/components/data/pagination/hooks/usePagination.js +796 -0
- package/components/data/pagination/index.js +322 -0
- package/components/data/table/components/AddNewRow.js +190 -0
- package/components/data/table/components/EditableCell.js +91 -0
- package/components/data/table/components/FieldValidationError.js +24 -0
- package/components/data/table/components/RowExpansionButton.js +74 -0
- package/components/data/table/components/TableBody.js +279 -0
- package/components/data/table/components/TableFilters.js +325 -0
- package/components/data/table/components/TableFooterActions.js +48 -0
- package/components/data/table/components/TableHeader.js +174 -0
- package/components/data/table/components/TablePanelHeading.js +68 -0
- package/components/data/table/components/index.js +74 -0
- package/components/data/table/hooks/index.js +219 -0
- package/components/data/table/hooks/useCellState.js +117 -0
- package/components/data/table/hooks/useDynamicColumns.js +85 -0
- package/components/data/table/hooks/useEditingState.js +47 -0
- package/components/data/table/hooks/useFormWidget.js +184 -0
- package/components/data/table/hooks/usePaginationState.js +60 -0
- package/components/data/table/hooks/usePanelStructure.js +40 -0
- package/components/data/table/hooks/useResponsiveColumns.js +34 -0
- package/components/data/table/hooks/useRowExpansion.js +110 -0
- package/components/data/table/hooks/useRowHandlers.js +38 -0
- package/components/data/table/hooks/useRowSelection.js +213 -0
- package/components/data/table/hooks/useServerSideSorting.js +165 -0
- package/components/data/table/hooks/useTableColumns.js +263 -0
- package/components/data/table/hooks/useTableData.js +154 -0
- package/components/data/table/hooks/useTableEdit.js +467 -0
- package/components/data/table/hooks/useTableEffects.js +139 -0
- package/components/data/table/hooks/useTableFilter.js +389 -0
- package/components/data/table/hooks/useTableInitialization.js +103 -0
- package/components/data/table/hooks/useTableState.js +69 -0
- package/components/data/table/hooks/useTableStateManager.js +558 -0
- package/components/data/table/index.js +1295 -0
- package/components/data/table/live-table/index.js +232 -0
- package/components/data/table/props.js +5 -0
- package/components/data/table/table-action/index.js +78 -0
- package/components/data/table/table-column/index.js +35 -0
- package/components/data/table/table-row/index.js +49 -0
- package/components/data/table/table-row-action/index.js +74 -0
- package/components/data/table/utils/buildSelectionColumns.js +173 -0
- package/components/data/table/utils/columnBuilder.js +209 -0
- package/components/data/table/utils/columnProxy.js +48 -0
- package/components/data/table/utils/columnWidthDistribution.js +98 -0
- package/components/data/table/utils/constants.js +80 -0
- package/components/data/table/utils/crud-handlers.js +518 -0
- package/components/data/table/utils/dynamic-columns.js +118 -0
- package/components/data/table/utils/index.js +607 -0
- package/components/data/table/utils/renderDisplayCell.js +183 -0
- package/components/data/table/utils/selectionUtils.js +166 -0
- package/components/data/table/utils/table-helpers.js +100 -0
- package/components/data/table/utils/validation.js +124 -0
- package/components/data/types.js +113 -0
- package/components/data/utils/field-data-utils.js +66 -0
- package/components/data/utils/filter-field-util.js +81 -0
- package/components/data/utils/index.js +216 -0
- package/components/dialogs/alert-dialog/index.js +80 -0
- package/components/dialogs/confirm-dialog/index.js +105 -0
- package/components/dialogs/dialog/index.js +56 -0
- package/components/dialogs/dialog-actions/index.js +18 -0
- package/components/dialogs/dialog-body/index.js +21 -0
- package/components/dialogs/dialog-content/index.js +30 -0
- package/components/dialogs/dialog-header/index.js +93 -0
- package/components/dialogs/iframe-dialog/index.js +114 -0
- package/components/dialogs/index.js +129 -0
- package/components/dialogs/login-dialog/index.js +369 -0
- package/components/dialogs/login-dialog/props.js +5 -0
- package/components/dialogs/page-dialog/index.js +96 -0
- package/components/dialogs/withDialogWrapper.js +108 -0
- package/components/form/button/index.js +216 -0
- package/components/form/button-group/index.js +60 -0
- package/components/input/calendar/index.js +546 -0
- package/components/input/calendar/props.js +5 -0
- package/components/input/calendar/utils.js +340 -0
- package/components/input/chips/SortableChip/index.js +115 -0
- package/components/input/chips/SortableChip/props.js +5 -0
- package/components/input/chips/index.js +488 -0
- package/components/input/chips/props.js +5 -0
- package/components/input/chips/utils.js +259 -0
- package/components/input/color-picker/index.js +678 -0
- package/components/input/color-picker/props.js +5 -0
- package/components/input/composite/index.js +137 -0
- package/components/input/currency/index.js +263 -0
- package/components/input/currency/props.js +5 -0
- package/components/input/default/checkbox/index.js +230 -0
- package/components/input/default/checkbox/props.js +5 -0
- package/components/input/default/checkboxset/index.js +476 -0
- package/components/input/default/checkboxset/props.js +5 -0
- package/components/input/default/radioset/index.js +379 -0
- package/components/input/default/radioset/props.js +5 -0
- package/components/input/default/switch/index.js +490 -0
- package/components/input/default/switch/prop.js +5 -0
- package/components/input/epoch/date/components/DatePickerPopover.js +220 -0
- package/components/input/epoch/date/index.js +520 -0
- package/components/input/epoch/date/props.js +5 -0
- package/components/input/epoch/date/styled.js +70 -0
- package/components/input/epoch/date/utils.js +108 -0
- package/components/input/epoch/datetime/index.js +656 -0
- package/components/input/epoch/datetime/props.js +5 -0
- package/components/input/epoch/datetime/styled.js +90 -0
- package/components/input/epoch/datetime/utils.js +244 -0
- package/components/input/epoch/time/index.js +412 -0
- package/components/input/epoch/time/props.js +5 -0
- package/components/input/epoch/time/utils.js +209 -0
- package/components/input/fileupload/Utils.js +134 -0
- package/components/input/fileupload/components/ListItems.js +140 -0
- package/components/input/fileupload/components/MultiUpload.js +85 -0
- package/components/input/fileupload/components/SingleUpload.js +65 -0
- package/components/input/fileupload/index.js +170 -0
- package/components/input/fileupload/props.js +5 -0
- package/components/input/fileupload/useFileUpload.js +400 -0
- package/components/input/number/index.js +295 -0
- package/components/input/number/props.js +5 -0
- package/components/input/rating/index.js +368 -0
- package/components/input/rating/props.js +5 -0
- package/components/input/select/index.js +344 -0
- package/components/input/select/props.js +5 -0
- package/components/input/slider/index.js +167 -0
- package/components/input/slider/props.js +5 -0
- package/components/input/text/index.js +434 -0
- package/components/input/text/props.js +5 -0
- package/components/input/text/util.js +179 -0
- package/components/input/textarea/index.js +347 -0
- package/components/input/textarea/props.js +5 -0
- package/components/layout/footer/index.js +30 -0
- package/components/layout/header/index.js +30 -0
- package/components/layout/leftnav/index.js +44 -0
- package/components/layout/rightnav/index.js +32 -0
- package/components/layout/topnav/index.js +34 -0
- package/components/navbar/index.js +41 -0
- package/components/navbar/nav/index.js +102 -0
- package/components/navbar/nav/props.js +5 -0
- package/components/navbar/nav-item/index.js +44 -0
- package/components/navigation/breadcrumb/index.js +56 -0
- package/components/navigation/breadcrumb/props.js +5 -0
- package/components/navigation/menu/components/ListItems.js +66 -0
- package/components/navigation/menu/constants.js +101 -0
- package/components/navigation/menu/index.js +807 -0
- package/components/navigation/menu/props.js +5 -0
- package/components/navigation/popover/index.js +209 -0
- package/components/navigation/popover/props.js +15 -0
- package/components/page/content/index.js +28 -0
- package/components/page/error-boundary/index.js +108 -0
- package/components/page/index.js +137 -0
- package/components/page/page-content/index.js +23 -0
- package/components/page/partial/index.js +36 -0
- package/components/page/partial-container/index.js +48 -0
- package/components/page/props.js +5 -0
- package/components/page/toast-container/index.js +33 -0
- package/components/prefab/container/index.js +46 -0
- package/components/prefab/index.js +67 -0
- package/context/AppContext.js +25 -0
- package/context/AppSpinnerProvider.js +43 -0
- package/context/LocalizationProvider.js +79 -0
- package/context/PrefabContext.js +66 -0
- package/context/WidgetProvider.js +187 -0
- package/core/app-config.js +1 -0
- package/core/app.service.js +357 -0
- package/core/appVariablesStore.js +20 -0
- package/core/appstore.js +88 -0
- package/core/constants/currency-constant.js +1071 -0
- package/core/constants/events.js +34 -0
- package/core/constants/index.js +27 -0
- package/core/dialog.service.js +76 -0
- package/core/event-notifier.js +151 -0
- package/core/formatter/date-formatters.js +222 -0
- package/core/formatter/index.js +131 -0
- package/core/formatter/number-formatters.js +142 -0
- package/core/formatter/security-formatters.js +323 -0
- package/core/formatter/string-formatters.js +52 -0
- package/core/formatter/types.js +18 -0
- package/core/formatters.js +24 -0
- package/core/proxy-service.js +412 -0
- package/core/script-registry.js +63 -0
- package/core/security.service.js +11 -0
- package/core/util/common.js +33 -0
- package/core/util/dom.js +107 -0
- package/core/util/index.js +136 -0
- package/core/util/security.js +184 -0
- package/core/util/utils.js +189 -0
- package/core/widget-observer.js +98 -0
- package/higherOrder/BaseApp.js +430 -0
- package/higherOrder/BaseAppProps.js +5 -0
- package/higherOrder/BaseDateTime.js +251 -0
- package/higherOrder/BasePage.js +715 -0
- package/higherOrder/BasePartial.js +124 -0
- package/higherOrder/BasePrefab.js +145 -0
- package/higherOrder/DataNav.js +377 -0
- package/higherOrder/helper.js +43 -0
- package/higherOrder/props.js +5 -0
- package/higherOrder/withBaseWrapper.js +183 -0
- package/hooks/useAccess.js +308 -0
- package/hooks/useAppConfig.js +42 -0
- package/hooks/useAuth.js +562 -0
- package/hooks/useDataSourceSubscription.js +125 -0
- package/hooks/useDebounce.js +76 -0
- package/hooks/useDeviceVisibility.js +49 -0
- package/hooks/useHttp.js +338 -0
- package/libs/index.js +20 -0
- package/mui-config/theme-provider.js +17 -0
- package/mui-config/theme.js +371 -0
- package/package-lock.json +10177 -0
- package/package.json +95 -0
- package/store/index.js +33 -0
- package/store/middleware/navigationMiddleware.js +48 -0
- package/store/slices/appConfigSlice.js +103 -0
- package/store/slices/authSlice.js +508 -0
- package/store/slices/i18nSlice.js +206 -0
- package/types/index.js +15 -0
- package/utils/dataset-util.js +174 -0
- package/utils/eval-expression.js +32 -0
- package/utils/form-state.util.js +140 -0
- package/utils/form-utils.js +187 -0
- package/utils/format-util.js +260 -0
- package/utils/page-params-util.js +24 -0
- package/utils/resource-url.js +27 -0
- package/utils/state-persistance.js +343 -0
- package/utils/style-utils.js +73 -0
- package/utils/transformedDataset-utils.js +633 -0
- package/utils/widget-cleanup-util.js +84 -0
- package/utils/widgets.js +99 -0
- package/variables/base-variable.js +173 -0
- package/variables/constants.js +27 -0
- package/variables/live-variable.js +166 -0
- package/variables/model-variable.js +77 -0
- package/variables/service-variable.js +307 -0
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _material = require("@mui/material");
|
|
13
|
+
var _styles = require("@mui/material/styles");
|
|
14
|
+
var _joditReact = _interopRequireDefault(require("jodit-react"));
|
|
15
|
+
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
16
|
+
var _withBaseWrapper = require("@wavemaker/react-runtime/higherOrder/withBaseWrapper");
|
|
17
|
+
var lodash = _interopRequireWildcard(require("lodash-es"));
|
|
18
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
19
|
+
var __jsx = _react["default"].createElement;
|
|
20
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
21
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
22
|
+
var EditorContainer = (0, _styles.styled)(_material.Box)(function (_ref) {
|
|
23
|
+
var theme = _ref.theme,
|
|
24
|
+
height = _ref.height;
|
|
25
|
+
return {
|
|
26
|
+
"& .jodit-workplace": {
|
|
27
|
+
height: height ? "".concat(height, " !important") : "auto"
|
|
28
|
+
},
|
|
29
|
+
"& .jodit-container": {
|
|
30
|
+
border: "1px solid ".concat(theme.palette.divider)
|
|
31
|
+
},
|
|
32
|
+
"& .jodit-react-container": {
|
|
33
|
+
// Remove only min-height and min-width
|
|
34
|
+
minHeight: "unset !important",
|
|
35
|
+
minWidth: "unset !important",
|
|
36
|
+
maxWidth: "unset !important"
|
|
37
|
+
},
|
|
38
|
+
"& .jodit-status-bar": {
|
|
39
|
+
border: "1px solid ".concat(theme.palette.divider),
|
|
40
|
+
borderTop: "none"
|
|
41
|
+
},
|
|
42
|
+
"& .jodit-toolbar": {
|
|
43
|
+
background: theme.palette.background.paper,
|
|
44
|
+
border: "1px solid ".concat(theme.palette.divider),
|
|
45
|
+
borderBottom: "none"
|
|
46
|
+
},
|
|
47
|
+
"& .jodit-toolbar__box": {
|
|
48
|
+
background: theme.palette.background.paper
|
|
49
|
+
},
|
|
50
|
+
"& .jodit-toolbar-button": {
|
|
51
|
+
margin: "2px"
|
|
52
|
+
},
|
|
53
|
+
"& div[contenteditable='true']": {
|
|
54
|
+
background: "var(--wm-note-editable-background)",
|
|
55
|
+
color: "var(--wm-note-editable-color)w"
|
|
56
|
+
},
|
|
57
|
+
// Reset problematic global styles that override rich text editor
|
|
58
|
+
"& .jodit-wysiwyg": {
|
|
59
|
+
padding: "unset !important",
|
|
60
|
+
margin: "unset !important"
|
|
61
|
+
},
|
|
62
|
+
"& .jodit-wysiwyg ul, & .jodit-wysiwyg li": {
|
|
63
|
+
paddingLeft: "2em !important",
|
|
64
|
+
margin: "1em 0 !important",
|
|
65
|
+
listStyleType: "unset"
|
|
66
|
+
},
|
|
67
|
+
// Override any global styles that might affect the editor
|
|
68
|
+
"& .jodit-container *": {
|
|
69
|
+
boxSizing: "border-box"
|
|
70
|
+
},
|
|
71
|
+
"& .jodit-wysiwyg ol": {
|
|
72
|
+
listStyleType: "decimal",
|
|
73
|
+
paddingLeft: "2em !important",
|
|
74
|
+
margin: "1em 0 !important"
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
var PreviewContainer = (0, _styles.styled)(_material.Box)(function (_ref2) {
|
|
79
|
+
var theme = _ref2.theme;
|
|
80
|
+
return {
|
|
81
|
+
marginTop: theme.spacing(2),
|
|
82
|
+
padding: theme.spacing(2),
|
|
83
|
+
// border: `1px solid ${theme.palette.divider}`,
|
|
84
|
+
borderRadius: theme.shape.borderRadius,
|
|
85
|
+
backgroundColor: theme.palette.background.paper,
|
|
86
|
+
color: theme.palette.text.primary,
|
|
87
|
+
minHeight: "100px",
|
|
88
|
+
overflowY: "auto",
|
|
89
|
+
"& img": {
|
|
90
|
+
maxWidth: "100%"
|
|
91
|
+
},
|
|
92
|
+
"& table": {
|
|
93
|
+
borderCollapse: "collapse",
|
|
94
|
+
width: "100%",
|
|
95
|
+
margin: theme.spacing(1, 0)
|
|
96
|
+
},
|
|
97
|
+
"& th, & td": {
|
|
98
|
+
border: "1px solid ".concat(theme.palette.divider),
|
|
99
|
+
padding: theme.spacing(0.5)
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
var HiddenInput = (0, _styles.styled)("input")({
|
|
104
|
+
display: "none"
|
|
105
|
+
});
|
|
106
|
+
var WmRichTextEditor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
107
|
+
var name = props.name,
|
|
108
|
+
className = props.className,
|
|
109
|
+
_props$placeholder = props.placeholder,
|
|
110
|
+
placeholder = _props$placeholder === void 0 ? "write here..." : _props$placeholder,
|
|
111
|
+
_props$tabindex = props.tabindex,
|
|
112
|
+
tabindex = _props$tabindex === void 0 ? 0 : _props$tabindex,
|
|
113
|
+
_props$datavalue = props.datavalue,
|
|
114
|
+
datavalue = _props$datavalue === void 0 ? "" : _props$datavalue,
|
|
115
|
+
_props$readonly = props.readonly,
|
|
116
|
+
readonly = _props$readonly === void 0 ? false : _props$readonly,
|
|
117
|
+
_props$disabled = props.disabled,
|
|
118
|
+
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
119
|
+
_props$showpreview = props.showpreview,
|
|
120
|
+
showpreview = _props$showpreview === void 0 ? false : _props$showpreview,
|
|
121
|
+
propWidth = props.width,
|
|
122
|
+
propHeight = props.height,
|
|
123
|
+
styles = props.styles,
|
|
124
|
+
onChange = props.onChange,
|
|
125
|
+
onBeforerender = props.onBeforerender,
|
|
126
|
+
hint = props.hint,
|
|
127
|
+
arialabel = props.arialabel,
|
|
128
|
+
listener = props.listener;
|
|
129
|
+
|
|
130
|
+
// Extract dimensions from props or styles, converting numbers to pixel strings
|
|
131
|
+
var getDimension = function getDimension(value) {
|
|
132
|
+
if (typeof value === "number") {
|
|
133
|
+
return "".concat(value, "px");
|
|
134
|
+
}
|
|
135
|
+
return value || "";
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// Prioritize styles prop over individual props
|
|
139
|
+
var width = getDimension((styles === null || styles === void 0 ? void 0 : styles.width) || propWidth) || "100%";
|
|
140
|
+
var height = getDimension((styles === null || styles === void 0 ? void 0 : styles.height) || propHeight);
|
|
141
|
+
|
|
142
|
+
// Memoize the actual value calculation
|
|
143
|
+
var actualValue = (0, _react.useMemo)(function () {
|
|
144
|
+
return datavalue;
|
|
145
|
+
}, [datavalue]);
|
|
146
|
+
var _useState = (0, _react.useState)(actualValue || ""),
|
|
147
|
+
content = _useState[0],
|
|
148
|
+
setContent = _useState[1];
|
|
149
|
+
var _useState2 = (0, _react.useState)(false),
|
|
150
|
+
isEditorLoaded = _useState2[0],
|
|
151
|
+
setIsEditorLoaded = _useState2[1];
|
|
152
|
+
var _useState3 = (0, _react.useState)([]),
|
|
153
|
+
operationStack = _useState3[0],
|
|
154
|
+
setOperationStack = _useState3[1];
|
|
155
|
+
var _useState4 = (0, _react.useState)(false),
|
|
156
|
+
isInternalChange = _useState4[0],
|
|
157
|
+
setIsInternalChange = _useState4[1];
|
|
158
|
+
var editorRef = (0, _react.useRef)(null);
|
|
159
|
+
var hiddenInputRef = (0, _react.useRef)(null);
|
|
160
|
+
var lastValueRef = (0, _react.useRef)(actualValue || "");
|
|
161
|
+
var isMountedRef = (0, _react.useRef)(true);
|
|
162
|
+
var widgetInstance = listener === null || listener === void 0 ? void 0 : listener.Widgets[name];
|
|
163
|
+
|
|
164
|
+
// Memoize editor options
|
|
165
|
+
var editorOptions = (0, _react.useMemo)(function () {
|
|
166
|
+
return {
|
|
167
|
+
toolbar: true,
|
|
168
|
+
placeholder: placeholder,
|
|
169
|
+
// minHeight: height ? (typeof height === 'string' && height.endsWith('px') ? parseInt(height, 10) : 100) : 100,
|
|
170
|
+
width: width,
|
|
171
|
+
readOnly: readonly,
|
|
172
|
+
disabled: readonly || disabled,
|
|
173
|
+
statusbar: true,
|
|
174
|
+
toolbarAdaptive: true,
|
|
175
|
+
askBeforePasteHTML: false,
|
|
176
|
+
askBeforePasteFromWord: false,
|
|
177
|
+
buttons: ["source", "|", "bold", "italic", "underline", "strikethrough", "|", "font", "fontsize", "brush", "paragraph", "|", "superscript", "subscript", "|", "ul", "ol", "|", "outdent", "indent", "|", "align", "undo", "redo", "|", "hr", "eraser", "fullsize", "|", "table", "link", "image", "video"],
|
|
178
|
+
removeButtons: ["about"],
|
|
179
|
+
showXPathInStatusbar: false,
|
|
180
|
+
showCharsCounter: false,
|
|
181
|
+
showWordsCounter: false,
|
|
182
|
+
toolbarSticky: false,
|
|
183
|
+
enableDragAndDropFileToEditor: true
|
|
184
|
+
};
|
|
185
|
+
}, [placeholder, height, width, readonly, disabled]);
|
|
186
|
+
|
|
187
|
+
// Memoize sanitizeHtml function
|
|
188
|
+
var sanitizeHtml = (0, _react.useCallback)(function (html) {
|
|
189
|
+
if (!html) return "";
|
|
190
|
+
return _dompurify["default"].sanitize(html, {
|
|
191
|
+
ADD_TAGS: ["iframe", "video", "source"],
|
|
192
|
+
ADD_ATTR: ["allow", "allowfullscreen", "frameborder", "scrolling", "controls", "src", "type", "width", "height"]
|
|
193
|
+
});
|
|
194
|
+
}, []);
|
|
195
|
+
|
|
196
|
+
// Memoize handleEditorChange
|
|
197
|
+
var handleEditorChange = (0, _react.useCallback)(function (newContent) {
|
|
198
|
+
var isFromUser = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
199
|
+
if (!isMountedRef.current || isInternalChange) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
var sanitizedContent = sanitizeHtml(newContent);
|
|
203
|
+
lastValueRef.current = sanitizedContent;
|
|
204
|
+
setContent(sanitizedContent);
|
|
205
|
+
if (hiddenInputRef.current) {
|
|
206
|
+
hiddenInputRef.current.value = sanitizedContent;
|
|
207
|
+
}
|
|
208
|
+
if (listener !== null && listener !== void 0 && listener.onChange) {
|
|
209
|
+
listener.onChange(props.name, {
|
|
210
|
+
datavalue: sanitizedContent
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}, [sanitizeHtml, isInternalChange]);
|
|
214
|
+
|
|
215
|
+
// Memoize handleEditorBlur
|
|
216
|
+
var handleEditorBlur = (0, _react.useCallback)(function (newContent, event) {
|
|
217
|
+
handleEditorChange(newContent, true);
|
|
218
|
+
}, [handleEditorChange]);
|
|
219
|
+
|
|
220
|
+
// Memoize performEditorOperation
|
|
221
|
+
var performEditorOperation = (0, _react.useCallback)(function (operation, value) {
|
|
222
|
+
var _editorRef$current;
|
|
223
|
+
if (!isEditorLoaded || !((_editorRef$current = editorRef.current) !== null && _editorRef$current !== void 0 && _editorRef$current.editor)) {
|
|
224
|
+
setOperationStack(function (prev) {
|
|
225
|
+
return [].concat((0, _toConsumableArray2["default"])(prev), [{
|
|
226
|
+
type: operation,
|
|
227
|
+
value: value
|
|
228
|
+
}]);
|
|
229
|
+
});
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
var editor = editorRef.current.editor;
|
|
233
|
+
try {
|
|
234
|
+
switch (operation) {
|
|
235
|
+
case "code":
|
|
236
|
+
if (value === undefined) {
|
|
237
|
+
return editor.isEmpty() ? "" : editor.value;
|
|
238
|
+
} else {
|
|
239
|
+
setIsInternalChange(true);
|
|
240
|
+
var sanitizedValue = sanitizeHtml(value);
|
|
241
|
+
editor.value = sanitizedValue;
|
|
242
|
+
setContent(sanitizedValue);
|
|
243
|
+
lastValueRef.current = sanitizedValue;
|
|
244
|
+
setTimeout(function () {
|
|
245
|
+
return setIsInternalChange(false);
|
|
246
|
+
}, 100);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
case "reset":
|
|
250
|
+
setIsInternalChange(true);
|
|
251
|
+
editor.value = "";
|
|
252
|
+
setContent("");
|
|
253
|
+
lastValueRef.current = "";
|
|
254
|
+
setTimeout(function () {
|
|
255
|
+
return setIsInternalChange(false);
|
|
256
|
+
}, 100);
|
|
257
|
+
return;
|
|
258
|
+
case "focus":
|
|
259
|
+
editor.focus();
|
|
260
|
+
return;
|
|
261
|
+
case "disable":
|
|
262
|
+
editor.disable();
|
|
263
|
+
return;
|
|
264
|
+
case "enable":
|
|
265
|
+
editor.enable();
|
|
266
|
+
return;
|
|
267
|
+
case "placeholder":
|
|
268
|
+
editor.options.placeholder = value;
|
|
269
|
+
return;
|
|
270
|
+
case "height":
|
|
271
|
+
editor.options.height = value;
|
|
272
|
+
if (editor.workplace) {
|
|
273
|
+
editor.workplace.style.height = typeof value === "number" ? "".concat(value, "px") : value;
|
|
274
|
+
}
|
|
275
|
+
return;
|
|
276
|
+
case "width":
|
|
277
|
+
editor.options.width = value;
|
|
278
|
+
if (editor.container) {
|
|
279
|
+
editor.container.style.width = typeof value === "number" ? "".concat(value, "px") : value;
|
|
280
|
+
}
|
|
281
|
+
return;
|
|
282
|
+
case "undo":
|
|
283
|
+
editor.history.undo();
|
|
284
|
+
return;
|
|
285
|
+
case "createRange":
|
|
286
|
+
return editor.selection.current();
|
|
287
|
+
default:
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
} catch (error) {
|
|
291
|
+
console.error("Error performing editor operation ".concat(operation, ":"), error);
|
|
292
|
+
}
|
|
293
|
+
}, [isEditorLoaded, sanitizeHtml]);
|
|
294
|
+
|
|
295
|
+
// Memoize handleOnBeforeRender
|
|
296
|
+
var handleOnBeforeRender = (0, _react.useCallback)(function () {
|
|
297
|
+
if (onBeforerender) {
|
|
298
|
+
var _editorRef$current2;
|
|
299
|
+
var syntheticEvent = {
|
|
300
|
+
target: {
|
|
301
|
+
value: ""
|
|
302
|
+
},
|
|
303
|
+
currentTarget: (_editorRef$current2 = editorRef.current) === null || _editorRef$current2 === void 0 || (_editorRef$current2 = _editorRef$current2.editor) === null || _editorRef$current2 === void 0 ? void 0 : _editorRef$current2.workplace
|
|
304
|
+
};
|
|
305
|
+
onBeforerender(syntheticEvent, widgetInstance);
|
|
306
|
+
}
|
|
307
|
+
}, [onBeforerender]);
|
|
308
|
+
|
|
309
|
+
// Create a debounced version of handleOnChange
|
|
310
|
+
var debouncedHandleOnChange = (0, _react.useMemo)(function () {
|
|
311
|
+
return lodash.debounce(function (newContent) {
|
|
312
|
+
var sanitizedContent = sanitizeHtml(newContent);
|
|
313
|
+
var tempDiv = document.createElement("div");
|
|
314
|
+
tempDiv.innerHTML = newContent;
|
|
315
|
+
var new_text_content = tempDiv.textContent || tempDiv.innerText || "";
|
|
316
|
+
if (name && widgetInstance) {
|
|
317
|
+
widgetInstance.displayValue = new_text_content;
|
|
318
|
+
}
|
|
319
|
+
if (onChange) {
|
|
320
|
+
var _editorRef$current3;
|
|
321
|
+
tempDiv.innerHTML = lastValueRef.current;
|
|
322
|
+
var old_text_context = tempDiv.textContent || tempDiv.innerText || "";
|
|
323
|
+
var syntheticEvent = {
|
|
324
|
+
target: {
|
|
325
|
+
value: new_text_content,
|
|
326
|
+
name: name
|
|
327
|
+
},
|
|
328
|
+
currentTarget: (_editorRef$current3 = editorRef.current) === null || _editorRef$current3 === void 0 || (_editorRef$current3 = _editorRef$current3.editor) === null || _editorRef$current3 === void 0 ? void 0 : _editorRef$current3.workplace
|
|
329
|
+
};
|
|
330
|
+
onChange(syntheticEvent, widgetInstance, new_text_content, old_text_context);
|
|
331
|
+
}
|
|
332
|
+
if (name && widgetInstance) {
|
|
333
|
+
widgetInstance.datavalue = new_text_content;
|
|
334
|
+
}
|
|
335
|
+
lastValueRef.current = sanitizedContent;
|
|
336
|
+
if (hiddenInputRef.current) {
|
|
337
|
+
hiddenInputRef.current.value = sanitizedContent;
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
}, [name, listener, onChange, sanitizeHtml]);
|
|
341
|
+
|
|
342
|
+
// Cleanup debounced function on unmount
|
|
343
|
+
(0, _react.useEffect)(function () {
|
|
344
|
+
return function () {
|
|
345
|
+
debouncedHandleOnChange.cancel();
|
|
346
|
+
};
|
|
347
|
+
}, [debouncedHandleOnChange]);
|
|
348
|
+
|
|
349
|
+
// Memoize handleEditorInit
|
|
350
|
+
var handleEditorInit = (0, _react.useCallback)(function () {
|
|
351
|
+
var _editorRef$current4;
|
|
352
|
+
setIsEditorLoaded(true);
|
|
353
|
+
if ((_editorRef$current4 = editorRef.current) !== null && _editorRef$current4 !== void 0 && _editorRef$current4.editor) {
|
|
354
|
+
if (height) {
|
|
355
|
+
var heightValue = typeof height === "string" && height.endsWith("px") ? parseInt(height, 10) : height;
|
|
356
|
+
performEditorOperation("height", heightValue);
|
|
357
|
+
}
|
|
358
|
+
if (width) {
|
|
359
|
+
performEditorOperation("width", width);
|
|
360
|
+
}
|
|
361
|
+
var editorElement = editorRef.current.editor.workplace;
|
|
362
|
+
if (editorElement) {
|
|
363
|
+
editorElement.setAttribute("aria-label", arialabel || "Rich Text Editor");
|
|
364
|
+
editorElement.setAttribute("role", "textbox");
|
|
365
|
+
editorElement.setAttribute("aria-multiline", "true");
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}, [arialabel, height, width, performEditorOperation]);
|
|
369
|
+
|
|
370
|
+
// Memoize the editor config
|
|
371
|
+
var editorConfig = (0, _react.useMemo)(function () {
|
|
372
|
+
return _objectSpread(_objectSpread({}, editorOptions), {}, {
|
|
373
|
+
tabIndex: tabindex,
|
|
374
|
+
events: {
|
|
375
|
+
change: debouncedHandleOnChange,
|
|
376
|
+
beforeInit: handleOnBeforeRender
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
}, [editorOptions, tabindex, debouncedHandleOnChange, handleOnBeforeRender]);
|
|
380
|
+
|
|
381
|
+
// Memoize the component's JSX
|
|
382
|
+
var editorJSX = (0, _react.useMemo)(function () {
|
|
383
|
+
return __jsx(_react["default"].Fragment, null, __jsx(EditorContainer, {
|
|
384
|
+
className: "app-richtexteditor clearfix ".concat(className),
|
|
385
|
+
title: hint,
|
|
386
|
+
style: {
|
|
387
|
+
width: width
|
|
388
|
+
},
|
|
389
|
+
height: styles === null || styles === void 0 ? void 0 : styles.height
|
|
390
|
+
}, __jsx(_joditReact["default"], {
|
|
391
|
+
ref: editorRef,
|
|
392
|
+
value: content.toString(),
|
|
393
|
+
config: editorConfig,
|
|
394
|
+
onBlur: handleEditorBlur,
|
|
395
|
+
onChange: function onChange() {} // Empty onChange as we handle it in config
|
|
396
|
+
,
|
|
397
|
+
onReady: handleEditorInit
|
|
398
|
+
}), __jsx(HiddenInput, {
|
|
399
|
+
ref: hiddenInputRef,
|
|
400
|
+
className: "model-holder",
|
|
401
|
+
disabled: disabled,
|
|
402
|
+
value: content.toString(),
|
|
403
|
+
name: name,
|
|
404
|
+
readOnly: true
|
|
405
|
+
})), showpreview && __jsx(PreviewContainer, {
|
|
406
|
+
className: "ta-preview",
|
|
407
|
+
style: {
|
|
408
|
+
width: width
|
|
409
|
+
},
|
|
410
|
+
dangerouslySetInnerHTML: {
|
|
411
|
+
__html: sanitizeHtml(content)
|
|
412
|
+
}
|
|
413
|
+
}));
|
|
414
|
+
}, [content, editorConfig, handleEditorBlur, handleEditorInit, hint, name, sanitizeHtml, showpreview, width]);
|
|
415
|
+
|
|
416
|
+
// Process operation stack after editor is loaded
|
|
417
|
+
(0, _react.useEffect)(function () {
|
|
418
|
+
if (isEditorLoaded && operationStack.length > 0) {
|
|
419
|
+
operationStack.forEach(function (operation) {
|
|
420
|
+
performEditorOperation(operation.type, operation.value);
|
|
421
|
+
});
|
|
422
|
+
setOperationStack([]);
|
|
423
|
+
}
|
|
424
|
+
}, [isEditorLoaded, operationStack, performEditorOperation]);
|
|
425
|
+
|
|
426
|
+
// Handle external value changes (two-way binding)
|
|
427
|
+
(0, _react.useEffect)(function () {
|
|
428
|
+
if (!isEditorLoaded || isInternalChange) {
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
var newValue = actualValue || "";
|
|
432
|
+
|
|
433
|
+
// Only update if the value has actually changed
|
|
434
|
+
if (newValue !== lastValueRef.current && newValue !== content) {
|
|
435
|
+
setIsInternalChange(true);
|
|
436
|
+
performEditorOperation("code", newValue);
|
|
437
|
+
setTimeout(function () {
|
|
438
|
+
return setIsInternalChange(false);
|
|
439
|
+
}, 100);
|
|
440
|
+
}
|
|
441
|
+
}, [actualValue, isEditorLoaded, content, performEditorOperation, isInternalChange]);
|
|
442
|
+
|
|
443
|
+
// Handle datavalue changes
|
|
444
|
+
(0, _react.useEffect)(function () {
|
|
445
|
+
if (datavalue != lastValueRef.current) {
|
|
446
|
+
setContent(datavalue);
|
|
447
|
+
lastValueRef.current = datavalue;
|
|
448
|
+
}
|
|
449
|
+
}, [datavalue]);
|
|
450
|
+
|
|
451
|
+
// Initialize editor and handle prop changes
|
|
452
|
+
(0, _react.useEffect)(function () {
|
|
453
|
+
var _editorRef$current5;
|
|
454
|
+
if ((_editorRef$current5 = editorRef.current) !== null && _editorRef$current5 !== void 0 && _editorRef$current5.editor && isEditorLoaded) {
|
|
455
|
+
// Handle readonly/disabled state changes
|
|
456
|
+
if (readonly || disabled) {
|
|
457
|
+
performEditorOperation("disable");
|
|
458
|
+
} else {
|
|
459
|
+
performEditorOperation("enable");
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// Handle placeholder changes
|
|
463
|
+
if (placeholder) {
|
|
464
|
+
performEditorOperation("placeholder", placeholder);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// Handle height changes
|
|
468
|
+
if (height) {
|
|
469
|
+
var heightValue = typeof height === "string" && height.endsWith("px") ? parseInt(height, 10) : height;
|
|
470
|
+
performEditorOperation("height", heightValue);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// Handle width changes
|
|
474
|
+
if (width) {
|
|
475
|
+
performEditorOperation("width", width);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}, [readonly, disabled, placeholder, height, width, performEditorOperation, isEditorLoaded]);
|
|
479
|
+
|
|
480
|
+
// Expose editor methods to parent components
|
|
481
|
+
(0, _react.useImperativeHandle)(ref, function () {
|
|
482
|
+
return {
|
|
483
|
+
// Get current HTML content
|
|
484
|
+
htmlcontent: function htmlcontent() {
|
|
485
|
+
return performEditorOperation("code");
|
|
486
|
+
},
|
|
487
|
+
// Get current selection position
|
|
488
|
+
getCurrentPosition: function getCurrentPosition() {
|
|
489
|
+
return performEditorOperation("createRange");
|
|
490
|
+
},
|
|
491
|
+
// Undo last operation
|
|
492
|
+
undo: function undo() {
|
|
493
|
+
return performEditorOperation("undo");
|
|
494
|
+
},
|
|
495
|
+
// Focus the editor
|
|
496
|
+
focus: function focus() {
|
|
497
|
+
return performEditorOperation("focus");
|
|
498
|
+
},
|
|
499
|
+
// Get editor instance
|
|
500
|
+
getEditor: function getEditor() {
|
|
501
|
+
var _editorRef$current6;
|
|
502
|
+
return (_editorRef$current6 = editorRef.current) === null || _editorRef$current6 === void 0 ? void 0 : _editorRef$current6.editor;
|
|
503
|
+
},
|
|
504
|
+
// Set editor content
|
|
505
|
+
setContent: function setContent(newContent) {
|
|
506
|
+
performEditorOperation("code", newContent);
|
|
507
|
+
},
|
|
508
|
+
// Perform custom editor operation
|
|
509
|
+
performOperation: function performOperation(operation, value) {
|
|
510
|
+
return performEditorOperation(operation, value);
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
// Clean up on unmount
|
|
516
|
+
(0, _react.useEffect)(function () {
|
|
517
|
+
isMountedRef.current = true;
|
|
518
|
+
return function () {
|
|
519
|
+
var _editorRef$current7;
|
|
520
|
+
isMountedRef.current = false;
|
|
521
|
+
if ((_editorRef$current7 = editorRef.current) !== null && _editorRef$current7 !== void 0 && _editorRef$current7.editor) {
|
|
522
|
+
try {
|
|
523
|
+
editorRef.current.editor.destruct();
|
|
524
|
+
} catch (error) {
|
|
525
|
+
console.error("Error destructing editor:", error);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
}, []);
|
|
530
|
+
return editorJSX;
|
|
531
|
+
});
|
|
532
|
+
WmRichTextEditor.displayName = "WmRichTextEditor";
|
|
533
|
+
var _default = exports["default"] = /*#__PURE__*/_react["default"].memo((0, _withBaseWrapper.withBaseWrapper)(WmRichTextEditor));
|