@unipin/angular-applet 18.9.7 → 21.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -10
- package/common/assets/sprites/flagGlobal.png +0 -0
- package/common/assets/sprites/flagSprite42.webp +0 -0
- package/common/assets/styles/freakflags.scss +263 -0
- package/common/assets/styles/theme.css +69 -0
- package/fesm2022/unipin-angular-applet-accordion.mjs +242 -0
- package/fesm2022/unipin-angular-applet-accordion.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-alert-dialog.mjs +267 -0
- package/fesm2022/unipin-angular-applet-alert-dialog.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-alert.mjs +94 -0
- package/fesm2022/unipin-angular-applet-alert.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-auth.mjs +707 -0
- package/fesm2022/unipin-angular-applet-auth.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-avatar.mjs +41 -0
- package/fesm2022/unipin-angular-applet-avatar.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-badge.mjs +50 -0
- package/fesm2022/unipin-angular-applet-badge.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-buttons.mjs +263 -0
- package/fesm2022/unipin-angular-applet-buttons.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-calendar.mjs +492 -0
- package/fesm2022/unipin-angular-applet-calendar.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-collapsible.mjs +97 -0
- package/fesm2022/unipin-angular-applet-collapsible.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-common.mjs +342 -0
- package/fesm2022/unipin-angular-applet-common.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-containers.mjs +472 -0
- package/fesm2022/unipin-angular-applet-containers.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-dialog.mjs +535 -0
- package/fesm2022/unipin-angular-applet-dialog.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-forms.mjs +1699 -0
- package/fesm2022/unipin-angular-applet-forms.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-froala.mjs +298 -0
- package/fesm2022/unipin-angular-applet-froala.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-grids.mjs +105 -0
- package/fesm2022/unipin-angular-applet-grids.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-infinite-scroll.mjs +86 -0
- package/fesm2022/unipin-angular-applet-infinite-scroll.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-json-viewer.mjs +71 -0
- package/fesm2022/unipin-angular-applet-json-viewer.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-loading-dialog.mjs +252 -0
- package/fesm2022/unipin-angular-applet-loading-dialog.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-markdown.mjs +703 -0
- package/fesm2022/unipin-angular-applet-markdown.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-micro-frontend.mjs +75 -0
- package/fesm2022/unipin-angular-applet-micro-frontend.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-popover.mjs +333 -0
- package/fesm2022/unipin-angular-applet-popover.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-progress-bar.mjs +38 -0
- package/fesm2022/unipin-angular-applet-progress-bar.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-skeleton.mjs +32 -0
- package/fesm2022/unipin-angular-applet-skeleton.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-spinner.mjs +144 -0
- package/fesm2022/unipin-angular-applet-spinner.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-swipeable.mjs +270 -0
- package/fesm2022/unipin-angular-applet-swipeable.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-tabs.mjs +142 -0
- package/fesm2022/unipin-angular-applet-tabs.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet-tooltip.mjs +118 -0
- package/fesm2022/unipin-angular-applet-tooltip.mjs.map +1 -0
- package/fesm2022/unipin-angular-applet.mjs +5 -4617
- package/fesm2022/unipin-angular-applet.mjs.map +1 -1
- package/package.json +132 -29
- package/types/unipin-angular-applet-accordion.d.ts +60 -0
- package/types/unipin-angular-applet-alert-dialog.d.ts +35 -0
- package/types/unipin-angular-applet-alert.d.ts +34 -0
- package/types/unipin-angular-applet-auth.d.ts +225 -0
- package/types/unipin-angular-applet-avatar.d.ts +16 -0
- package/types/unipin-angular-applet-badge.d.ts +20 -0
- package/types/unipin-angular-applet-buttons.d.ts +37 -0
- package/types/unipin-angular-applet-calendar.d.ts +44 -0
- package/types/unipin-angular-applet-collapsible.d.ts +35 -0
- package/types/unipin-angular-applet-common.d.ts +94 -0
- package/types/unipin-angular-applet-containers.d.ts +179 -0
- package/types/unipin-angular-applet-dialog.d.ts +180 -0
- package/types/unipin-angular-applet-forms.d.ts +412 -0
- package/types/unipin-angular-applet-froala.d.ts +85 -0
- package/types/unipin-angular-applet-grids.d.ts +22 -0
- package/types/unipin-angular-applet-infinite-scroll.d.ts +51 -0
- package/types/unipin-angular-applet-json-viewer.d.ts +30 -0
- package/types/unipin-angular-applet-loading-dialog.d.ts +19 -0
- package/types/unipin-angular-applet-markdown.d.ts +119 -0
- package/types/unipin-angular-applet-micro-frontend.d.ts +11 -0
- package/types/unipin-angular-applet-popover.d.ts +58 -0
- package/types/unipin-angular-applet-progress-bar.d.ts +14 -0
- package/types/unipin-angular-applet-skeleton.d.ts +11 -0
- package/types/unipin-angular-applet-spinner.d.ts +12 -0
- package/types/unipin-angular-applet-swipeable.d.ts +66 -0
- package/types/unipin-angular-applet-tabs.d.ts +40 -0
- package/types/unipin-angular-applet-tooltip.d.ts +32 -0
- package/types/unipin-angular-applet.d.ts +3 -0
- package/esm2022/graphql/generated.mjs +0 -938
- package/esm2022/lib/components/approval/detail/approval-detail.component.mjs +0 -78
- package/esm2022/lib/components/approval/form/approval-form.component.mjs +0 -128
- package/esm2022/lib/components/approval/index.mjs +0 -5
- package/esm2022/lib/components/approval/list/approval-list.component.mjs +0 -114
- package/esm2022/lib/components/approval/list/provide-approval-entities.util.mjs +0 -9
- package/esm2022/lib/components/approval/services/approval.service.mjs +0 -46
- package/esm2022/lib/components/audit/detail/audit-detail.component.mjs +0 -123
- package/esm2022/lib/components/audit/index.mjs +0 -3
- package/esm2022/lib/components/audit/list/audit-list.component.mjs +0 -81
- package/esm2022/lib/components/audit/service/audit.service.mjs +0 -49
- package/esm2022/lib/components/audit/types/audit-detail-form.type.mjs +0 -2
- package/esm2022/lib/components/buttons/group/btn-group.component.mjs +0 -43
- package/esm2022/lib/components/buttons/group/interfaces/btn-group-config.interface.mjs +0 -2
- package/esm2022/lib/components/buttons/index.mjs +0 -3
- package/esm2022/lib/components/buttons/loading/btn-loading.component.mjs +0 -48
- package/esm2022/lib/components/containers/applet-container/applet-container.component.mjs +0 -55
- package/esm2022/lib/components/containers/applet-container/provide-applet-config.util.mjs +0 -9
- package/esm2022/lib/components/containers/colum-header-container/column-header-container.component.mjs +0 -23
- package/esm2022/lib/components/containers/column-container/column-container.component.mjs +0 -79
- package/esm2022/lib/components/containers/column-container/directives/lazy-route.directive.mjs +0 -57
- package/esm2022/lib/components/containers/index.mjs +0 -7
- package/esm2022/lib/components/containers/list-container/index.mjs +0 -3
- package/esm2022/lib/components/containers/list-container/interfaces/list-container-config.interface.mjs +0 -2
- package/esm2022/lib/components/containers/list-container/list-pagination-container/list-pagination-container.component.mjs +0 -58
- package/esm2022/lib/components/containers/list-container/list-snapshot-container/list-snapshot-container.component.mjs +0 -57
- package/esm2022/lib/components/containers/modal-container/modal-container.component.mjs +0 -40
- package/esm2022/lib/components/filter/filter.component.mjs +0 -222
- package/esm2022/lib/components/filter/index.mjs +0 -2
- package/esm2022/lib/components/filter/interfaces/filter-config.interface.mjs +0 -2
- package/esm2022/lib/components/filter/interfaces/filter-field.interface.mjs +0 -2
- package/esm2022/lib/components/filter/interfaces/filter-search-event.interface.mjs +0 -2
- package/esm2022/lib/components/forms/country-input/form-country-input.component.mjs +0 -122
- package/esm2022/lib/components/forms/currency-input/form-currency-input.component.mjs +0 -157
- package/esm2022/lib/components/forms/date/form-date.component.mjs +0 -117
- package/esm2022/lib/components/forms/image-picker/directives/drag-n-drop.directive.mjs +0 -49
- package/esm2022/lib/components/forms/image-picker/form-image-picker.component.mjs +0 -68
- package/esm2022/lib/components/forms/index.mjs +0 -12
- package/esm2022/lib/components/forms/input/form-input.component.mjs +0 -98
- package/esm2022/lib/components/forms/number/form-number.component.mjs +0 -97
- package/esm2022/lib/components/forms/number/pipes/locale-number.pipe.mjs +0 -33
- package/esm2022/lib/components/forms/password/form-password.component.mjs +0 -100
- package/esm2022/lib/components/forms/rate-group-code-input/form-rate-group-code-input.component.mjs +0 -135
- package/esm2022/lib/components/forms/searchable-select/form-searchable-select.component.mjs +0 -138
- package/esm2022/lib/components/forms/select/form-select.component.mjs +0 -119
- package/esm2022/lib/components/forms/textarea/form-textarea.component.mjs +0 -88
- package/esm2022/lib/components/grids/grid-pagination/grid-pagination.component.mjs +0 -111
- package/esm2022/lib/components/grids/grid-snapshot/grid-snapshot.component.mjs +0 -109
- package/esm2022/lib/components/grids/index.mjs +0 -4
- package/esm2022/lib/components/grids/interfaces/grid-config.interface.mjs +0 -2
- package/esm2022/lib/components/grids/services/grid.service.mjs +0 -25
- package/esm2022/lib/components/index.mjs +0 -9
- package/esm2022/lib/components/infinite-scroll/directive/infinite-scroll.directive.mjs +0 -43
- package/esm2022/lib/components/infinite-scroll/index.mjs +0 -3
- package/esm2022/lib/components/infinite-scroll/infinite-scroll.component.mjs +0 -36
- package/esm2022/lib/components/tabs/index.mjs +0 -3
- package/esm2022/lib/components/tabs/tab-content/tab-content.component.mjs +0 -37
- package/esm2022/lib/components/tabs/tab-group/tab-group.component.mjs +0 -47
- package/esm2022/lib/guards/auth/auth.guard.mjs +0 -10
- package/esm2022/lib/guards/index.mjs +0 -2
- package/esm2022/lib/interceptors/header/header.interceptor.mjs +0 -29
- package/esm2022/lib/interceptors/index.mjs +0 -3
- package/esm2022/lib/interceptors/refresh-token/refresh-token.interceptor.mjs +0 -83
- package/esm2022/lib/interfaces/index.mjs +0 -2
- package/esm2022/lib/interfaces/user/user.interface.mjs +0 -2
- package/esm2022/lib/modules/index.mjs +0 -3
- package/esm2022/lib/modules/micro-frontend/index.mjs +0 -2
- package/esm2022/lib/modules/micro-frontend/utils/mf-bootstrap.util.mjs +0 -55
- package/esm2022/lib/modules/micro-frontend/utils/mf-global-state.util.mjs +0 -14
- package/esm2022/lib/modules/permission/directive/permission.directive.mjs +0 -41
- package/esm2022/lib/modules/permission/guards/permission.guard.mjs +0 -26
- package/esm2022/lib/modules/permission/index.mjs +0 -7
- package/esm2022/lib/modules/permission/pages/401/unauthorized.page.mjs +0 -15
- package/esm2022/lib/modules/permission/pages/loading/loading.page.mjs +0 -65
- package/esm2022/lib/modules/permission/pages/loading/provide-loading-config.util.mjs +0 -9
- package/esm2022/lib/modules/permission/services/permission.service.mjs +0 -50
- package/esm2022/lib/resolvers/auth/auth.resolver.mjs +0 -87
- package/esm2022/lib/resolvers/index.mjs +0 -2
- package/esm2022/lib/services/auth/auth.service.mjs +0 -171
- package/esm2022/lib/services/country/country.service.mjs +0 -43
- package/esm2022/lib/services/currency/currency.service.mjs +0 -40
- package/esm2022/lib/services/index.mjs +0 -6
- package/esm2022/lib/services/profile/profile.service.mjs +0 -82
- package/esm2022/lib/services/rate-group-code/rate-group-code.service.mjs +0 -31
- package/esm2022/lib/utils/contrast-color-generator/contrast-color-generator.util.mjs +0 -16
- package/esm2022/lib/utils/form-error-message/form-error-message.util.mjs +0 -21
- package/esm2022/lib/utils/format-capitalize/format-capitalize.util.mjs +0 -18
- package/esm2022/lib/utils/index.mjs +0 -5
- package/esm2022/lib/utils/redirect-to-first-menu/redirect-to-first-menu.util.mjs +0 -9
- package/esm2022/public-api.mjs +0 -10
- package/esm2022/unipin-angular-applet.mjs +0 -2
- package/graphql/generated.d.ts +0 -16225
- package/index.d.ts +0 -2
- package/lib/components/approval/detail/approval-detail.component.d.ts +0 -26
- package/lib/components/approval/form/approval-form.component.d.ts +0 -33
- package/lib/components/approval/index.d.ts +0 -4
- package/lib/components/approval/list/approval-list.component.d.ts +0 -33
- package/lib/components/approval/list/provide-approval-entities.util.d.ts +0 -3
- package/lib/components/approval/services/approval.service.d.ts +0 -18
- package/lib/components/audit/detail/audit-detail.component.d.ts +0 -33
- package/lib/components/audit/index.d.ts +0 -2
- package/lib/components/audit/list/audit-list.component.d.ts +0 -31
- package/lib/components/audit/service/audit.service.d.ts +0 -15
- package/lib/components/audit/types/audit-detail-form.type.d.ts +0 -12
- package/lib/components/buttons/group/btn-group.component.d.ts +0 -18
- package/lib/components/buttons/group/interfaces/btn-group-config.interface.d.ts +0 -11
- package/lib/components/buttons/index.d.ts +0 -3
- package/lib/components/buttons/loading/btn-loading.component.d.ts +0 -19
- package/lib/components/containers/applet-container/applet-container.component.d.ts +0 -22
- package/lib/components/containers/applet-container/provide-applet-config.util.d.ts +0 -15
- package/lib/components/containers/colum-header-container/column-header-container.component.d.ts +0 -7
- package/lib/components/containers/column-container/column-container.component.d.ts +0 -26
- package/lib/components/containers/column-container/directives/lazy-route.directive.d.ts +0 -17
- package/lib/components/containers/index.d.ts +0 -6
- package/lib/components/containers/list-container/index.d.ts +0 -3
- package/lib/components/containers/list-container/interfaces/list-container-config.interface.d.ts +0 -9
- package/lib/components/containers/list-container/list-pagination-container/list-pagination-container.component.d.ts +0 -23
- package/lib/components/containers/list-container/list-snapshot-container/list-snapshot-container.component.d.ts +0 -23
- package/lib/components/containers/modal-container/modal-container.component.d.ts +0 -16
- package/lib/components/filter/filter.component.d.ts +0 -44
- package/lib/components/filter/index.d.ts +0 -4
- package/lib/components/filter/interfaces/filter-config.interface.d.ts +0 -5
- package/lib/components/filter/interfaces/filter-field.interface.d.ts +0 -24
- package/lib/components/filter/interfaces/filter-search-event.interface.d.ts +0 -4
- package/lib/components/forms/country-input/form-country-input.component.d.ts +0 -41
- package/lib/components/forms/currency-input/form-currency-input.component.d.ts +0 -52
- package/lib/components/forms/date/form-date.component.d.ts +0 -33
- package/lib/components/forms/image-picker/directives/drag-n-drop.directive.d.ts +0 -10
- package/lib/components/forms/image-picker/form-image-picker.component.d.ts +0 -21
- package/lib/components/forms/index.d.ts +0 -11
- package/lib/components/forms/input/form-input.component.d.ts +0 -31
- package/lib/components/forms/number/form-number.component.d.ts +0 -27
- package/lib/components/forms/number/pipes/locale-number.pipe.d.ts +0 -8
- package/lib/components/forms/password/form-password.component.d.ts +0 -27
- package/lib/components/forms/rate-group-code-input/form-rate-group-code-input.component.d.ts +0 -41
- package/lib/components/forms/searchable-select/form-searchable-select.component.d.ts +0 -42
- package/lib/components/forms/select/form-select.component.d.ts +0 -34
- package/lib/components/forms/textarea/form-textarea.component.d.ts +0 -26
- package/lib/components/grids/grid-pagination/grid-pagination.component.d.ts +0 -33
- package/lib/components/grids/grid-snapshot/grid-snapshot.component.d.ts +0 -36
- package/lib/components/grids/index.d.ts +0 -4
- package/lib/components/grids/interfaces/grid-config.interface.d.ts +0 -16
- package/lib/components/grids/services/grid.service.d.ts +0 -12
- package/lib/components/index.d.ts +0 -8
- package/lib/components/infinite-scroll/directive/infinite-scroll.directive.d.ts +0 -15
- package/lib/components/infinite-scroll/index.d.ts +0 -2
- package/lib/components/infinite-scroll/infinite-scroll.component.d.ts +0 -12
- package/lib/components/tabs/index.d.ts +0 -6
- package/lib/components/tabs/tab-content/tab-content.component.d.ts +0 -14
- package/lib/components/tabs/tab-group/tab-group.component.d.ts +0 -18
- package/lib/guards/auth/auth.guard.d.ts +0 -1
- package/lib/guards/index.d.ts +0 -1
- package/lib/interceptors/header/header.interceptor.d.ts +0 -9
- package/lib/interceptors/index.d.ts +0 -2
- package/lib/interceptors/refresh-token/refresh-token.interceptor.d.ts +0 -14
- package/lib/interfaces/index.d.ts +0 -1
- package/lib/interfaces/user/user.interface.d.ts +0 -27
- package/lib/modules/index.d.ts +0 -2
- package/lib/modules/micro-frontend/index.d.ts +0 -1
- package/lib/modules/micro-frontend/utils/mf-bootstrap.util.d.ts +0 -9
- package/lib/modules/micro-frontend/utils/mf-global-state.util.d.ts +0 -4
- package/lib/modules/permission/directive/permission.directive.d.ts +0 -16
- package/lib/modules/permission/guards/permission.guard.d.ts +0 -2
- package/lib/modules/permission/index.d.ts +0 -6
- package/lib/modules/permission/pages/401/unauthorized.page.d.ts +0 -5
- package/lib/modules/permission/pages/loading/loading.page.d.ts +0 -18
- package/lib/modules/permission/pages/loading/provide-loading-config.util.d.ts +0 -10
- package/lib/modules/permission/services/permission.service.d.ts +0 -21
- package/lib/resolvers/auth/auth.resolver.d.ts +0 -14
- package/lib/resolvers/index.d.ts +0 -1
- package/lib/services/auth/auth.service.d.ts +0 -39
- package/lib/services/country/country.service.d.ts +0 -16
- package/lib/services/currency/currency.service.d.ts +0 -16
- package/lib/services/index.d.ts +0 -5
- package/lib/services/profile/profile.service.d.ts +0 -12
- package/lib/services/rate-group-code/rate-group-code.service.d.ts +0 -14
- package/lib/utils/contrast-color-generator/contrast-color-generator.util.d.ts +0 -4
- package/lib/utils/form-error-message/form-error-message.util.d.ts +0 -2
- package/lib/utils/format-capitalize/format-capitalize.util.d.ts +0 -1
- package/lib/utils/index.d.ts +0 -4
- package/lib/utils/redirect-to-first-menu/redirect-to-first-menu.util.d.ts +0 -2
- package/public-api.d.ts +0 -11
- package/src/assets/scss/forms.scss +0 -65
- package/src/assets/scss/grid.scss +0 -7505
- package/src/assets/scss/select.scss +0 -328
|
@@ -0,0 +1,703 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { signal, effect, Directive, Inject, Injectable, model, input, viewChild, booleanAttribute, computed, forwardRef, HostListener, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { NgIcon, provideIcons } from '@ng-icons/core';
|
|
4
|
+
import { matChecklistRound, matFormatListBulletedRound, matFormatListNumberedRound, matFormatUnderlinedRound, matFormatItalicRound, matFormatQuoteRound, matFormatBoldRound } from '@ng-icons/material-icons/round';
|
|
5
|
+
import { up, compressImage } from '@unipin/angular-applet/common';
|
|
6
|
+
import { UpButtonDirective } from '@unipin/angular-applet/buttons';
|
|
7
|
+
import { UpFieldControlComponent, UpFieldControl } from '@unipin/angular-applet/forms';
|
|
8
|
+
import { marked } from 'marked';
|
|
9
|
+
import * as i1 from '@angular/common/http';
|
|
10
|
+
import { HttpHeaders } from '@angular/common/http';
|
|
11
|
+
import { UNIPIN_GQL_CONFIG } from '@unipin/angular-gql';
|
|
12
|
+
|
|
13
|
+
function toggleBold(textarea, selection) {
|
|
14
|
+
const { word, start, end } = getWordAtCursor(textarea.value, selection.start);
|
|
15
|
+
let newText;
|
|
16
|
+
//add with selection
|
|
17
|
+
if (selection.start < selection.end &&
|
|
18
|
+
!selection.word.startsWith('**') &&
|
|
19
|
+
!selection.word.endsWith('**')) {
|
|
20
|
+
newText = textarea.value.slice(0, selection.start) + `**${selection.word}**` + textarea.value.slice(selection.end);
|
|
21
|
+
setTimeout(() => {
|
|
22
|
+
textarea.setSelectionRange(selection.end + 2, selection.end + 2);
|
|
23
|
+
textarea.focus();
|
|
24
|
+
});
|
|
25
|
+
return newText;
|
|
26
|
+
}
|
|
27
|
+
//add without selection
|
|
28
|
+
if (selection.start === selection.end &&
|
|
29
|
+
!word.startsWith('**') &&
|
|
30
|
+
!word.endsWith('**')) {
|
|
31
|
+
newText = textarea.value.slice(0, start) + `**${word}**` + textarea.value.slice(end);
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
textarea.setSelectionRange(end + 2, end + 2);
|
|
34
|
+
textarea.focus();
|
|
35
|
+
});
|
|
36
|
+
return newText;
|
|
37
|
+
}
|
|
38
|
+
//remove without selection
|
|
39
|
+
if (word.startsWith('**') &&
|
|
40
|
+
word.endsWith('**')) {
|
|
41
|
+
newText = textarea.value.slice(0, start) + word.slice(2, -2) + textarea.value.slice(end);
|
|
42
|
+
setTimeout(() => {
|
|
43
|
+
textarea.setSelectionRange(selection.start, selection.end);
|
|
44
|
+
textarea.focus();
|
|
45
|
+
});
|
|
46
|
+
return newText;
|
|
47
|
+
}
|
|
48
|
+
//remove with selection
|
|
49
|
+
if (selection.word.startsWith('**') &&
|
|
50
|
+
selection.word.endsWith('**')) {
|
|
51
|
+
newText = textarea.value.slice(0, selection.start) + selection.word.slice(2, -2) + textarea.value.slice(selection.end);
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
textarea.setSelectionRange(selection.start, selection.start);
|
|
54
|
+
textarea.focus();
|
|
55
|
+
});
|
|
56
|
+
return newText;
|
|
57
|
+
}
|
|
58
|
+
return textarea.value;
|
|
59
|
+
}
|
|
60
|
+
function toggleUnderline(textarea, selection) {
|
|
61
|
+
const { word, start, end } = getWordAtCursor(textarea.value, selection.start);
|
|
62
|
+
let newText;
|
|
63
|
+
//add with selection
|
|
64
|
+
if (selection.start < selection.end &&
|
|
65
|
+
!selection.word.startsWith('++') &&
|
|
66
|
+
!selection.word.endsWith('++')) {
|
|
67
|
+
newText = textarea.value.slice(0, selection.start) + `++${selection.word}++` + textarea.value.slice(selection.end);
|
|
68
|
+
setTimeout(() => {
|
|
69
|
+
textarea.setSelectionRange(selection.end + 2, selection.end + 2);
|
|
70
|
+
textarea.focus();
|
|
71
|
+
});
|
|
72
|
+
return newText;
|
|
73
|
+
}
|
|
74
|
+
//add without selection
|
|
75
|
+
if (selection.start === selection.end &&
|
|
76
|
+
!word.startsWith('++') &&
|
|
77
|
+
!word.endsWith('++')) {
|
|
78
|
+
newText = textarea.value.slice(0, start) + `++${word}++` + textarea.value.slice(end);
|
|
79
|
+
setTimeout(() => {
|
|
80
|
+
textarea.setSelectionRange(end + 2, end + 2);
|
|
81
|
+
textarea.focus();
|
|
82
|
+
});
|
|
83
|
+
return newText;
|
|
84
|
+
}
|
|
85
|
+
//remove without selection
|
|
86
|
+
if (word.startsWith('++') && word.endsWith('++')) {
|
|
87
|
+
newText = textarea.value.slice(0, start) + word.slice(2, -2) + textarea.value.slice(end);
|
|
88
|
+
setTimeout(() => {
|
|
89
|
+
textarea.setSelectionRange(selection.start, selection.end);
|
|
90
|
+
textarea.focus();
|
|
91
|
+
});
|
|
92
|
+
return newText;
|
|
93
|
+
}
|
|
94
|
+
//remove with selection
|
|
95
|
+
if (selection.word.startsWith('++') &&
|
|
96
|
+
selection.word.endsWith('++')) {
|
|
97
|
+
newText = textarea.value.slice(0, selection.start) + selection.word.slice(2, -2) + textarea.value.slice(selection.end);
|
|
98
|
+
setTimeout(() => {
|
|
99
|
+
textarea.setSelectionRange(selection.start, selection.start);
|
|
100
|
+
textarea.focus();
|
|
101
|
+
});
|
|
102
|
+
return newText;
|
|
103
|
+
}
|
|
104
|
+
return textarea.value;
|
|
105
|
+
}
|
|
106
|
+
function toggleItalic(textarea, selection) {
|
|
107
|
+
const { word, start, end } = getWordAtCursor(textarea.value, selection.start);
|
|
108
|
+
let newText;
|
|
109
|
+
//add with selection
|
|
110
|
+
if (selection.start < selection.end &&
|
|
111
|
+
!selection.word.startsWith('_') &&
|
|
112
|
+
!selection.word.endsWith('_')) {
|
|
113
|
+
newText = textarea.value.slice(0, selection.start) + `_${selection.word}_` + textarea.value.slice(selection.end);
|
|
114
|
+
setTimeout(() => {
|
|
115
|
+
textarea.setSelectionRange(selection.end + 2, selection.end + 2);
|
|
116
|
+
textarea.focus();
|
|
117
|
+
});
|
|
118
|
+
return newText;
|
|
119
|
+
}
|
|
120
|
+
//add without selection
|
|
121
|
+
if (selection.start === selection.end && !word.startsWith('_') && !word.endsWith('_')) {
|
|
122
|
+
newText = textarea.value.slice(0, start) + `_${word}_` + textarea.value.slice(end);
|
|
123
|
+
setTimeout(() => {
|
|
124
|
+
textarea.setSelectionRange(end + 1, end + 1);
|
|
125
|
+
textarea.focus();
|
|
126
|
+
});
|
|
127
|
+
return newText;
|
|
128
|
+
}
|
|
129
|
+
//remove without selection
|
|
130
|
+
if (word.startsWith('_') && word.endsWith('_')) {
|
|
131
|
+
newText = textarea.value.slice(0, start) + word.slice(1, -1) + textarea.value.slice(end);
|
|
132
|
+
setTimeout(() => {
|
|
133
|
+
textarea.setSelectionRange(selection.start, selection.end);
|
|
134
|
+
textarea.focus();
|
|
135
|
+
});
|
|
136
|
+
return newText;
|
|
137
|
+
}
|
|
138
|
+
//remove with selection
|
|
139
|
+
if (selection.word.startsWith('_') && selection.word.endsWith('_')) {
|
|
140
|
+
newText = textarea.value.slice(0, selection.start) + selection.word.slice(1, -1) + textarea.value.slice(selection.end);
|
|
141
|
+
setTimeout(() => {
|
|
142
|
+
textarea.setSelectionRange(selection.start, selection.start);
|
|
143
|
+
textarea.focus();
|
|
144
|
+
});
|
|
145
|
+
return newText;
|
|
146
|
+
}
|
|
147
|
+
return textarea.value;
|
|
148
|
+
}
|
|
149
|
+
function toggleUnorderedList(text, cursorPos) {
|
|
150
|
+
const lines = text.split('\n');
|
|
151
|
+
let currentLineIndex = 0;
|
|
152
|
+
let charCount = 0;
|
|
153
|
+
for (let i = 0; i < lines.length; i++) {
|
|
154
|
+
charCount += lines[i].length + 1;
|
|
155
|
+
if (charCount > cursorPos) {
|
|
156
|
+
currentLineIndex = i;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const line = lines[currentLineIndex];
|
|
161
|
+
if (line.startsWith('- ')) {
|
|
162
|
+
lines[currentLineIndex] = line.slice(2);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
lines[currentLineIndex] = `- ${line}`;
|
|
166
|
+
}
|
|
167
|
+
return lines.join('\n');
|
|
168
|
+
}
|
|
169
|
+
function toggleOrderedList(text, cursorPos) {
|
|
170
|
+
const lines = text.split('\n');
|
|
171
|
+
let currentLineIndex = 0;
|
|
172
|
+
let charCount = 0;
|
|
173
|
+
for (let i = 0; i < lines.length; i++) {
|
|
174
|
+
charCount += lines[i].length + 1;
|
|
175
|
+
if (charCount > cursorPos) {
|
|
176
|
+
currentLineIndex = i;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const line = lines[currentLineIndex];
|
|
181
|
+
const match = line.match(/^(\d+)\.\s(.*)$/);
|
|
182
|
+
if (match) {
|
|
183
|
+
lines[currentLineIndex] = match[2];
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
let number = 1;
|
|
187
|
+
for (let i = 0; i < currentLineIndex; i++) {
|
|
188
|
+
const prevMatch = lines[i].match(/^(\d+)\.\s/);
|
|
189
|
+
if (prevMatch) {
|
|
190
|
+
number = parseInt(prevMatch[1], 10) + 1;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
lines[currentLineIndex] = `${number}. ${line}`;
|
|
194
|
+
}
|
|
195
|
+
return lines.join('\n');
|
|
196
|
+
}
|
|
197
|
+
function toggleTaskList(text, cursorPos) {
|
|
198
|
+
const lines = text.split('\n');
|
|
199
|
+
let currentLineIndex = 0;
|
|
200
|
+
let charCount = 0;
|
|
201
|
+
for (let i = 0; i < lines.length; i++) {
|
|
202
|
+
charCount += lines[i].length + 1;
|
|
203
|
+
if (charCount > cursorPos) {
|
|
204
|
+
currentLineIndex = i;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const line = lines[currentLineIndex];
|
|
209
|
+
if (/^- \[ \]\s/.test(line)) {
|
|
210
|
+
lines[currentLineIndex] = line.replace(/^- \[ \]\s/, '- [x] ');
|
|
211
|
+
}
|
|
212
|
+
else if (/^- \[x\]\s/.test(line)) {
|
|
213
|
+
lines[currentLineIndex] = line.replace(/^- \[x\]\s/, '');
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
lines[currentLineIndex] = `- [ ] ${line}`;
|
|
217
|
+
}
|
|
218
|
+
return lines.join('\n');
|
|
219
|
+
}
|
|
220
|
+
function toggleHeading(textarea, selection) {
|
|
221
|
+
const lines = textarea.value.split('\n');
|
|
222
|
+
let charCount = 0;
|
|
223
|
+
let lineIndex = 0;
|
|
224
|
+
for (let i = 0; i < lines.length; i++) {
|
|
225
|
+
charCount += lines[i].length + 1;
|
|
226
|
+
if (selection.start < charCount) {
|
|
227
|
+
lineIndex = i;
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
let lineContent = lines[lineIndex];
|
|
232
|
+
if (lineContent.startsWith('### ')) {
|
|
233
|
+
lines[lineIndex] = lineContent.slice(4);
|
|
234
|
+
selection.start -= 4;
|
|
235
|
+
selection.end -= 4;
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
lines[lineIndex] = `### ${lineContent}`;
|
|
239
|
+
selection.start += 4;
|
|
240
|
+
selection.end += 4;
|
|
241
|
+
}
|
|
242
|
+
const newText = lines.join('\n');
|
|
243
|
+
setTimeout(() => {
|
|
244
|
+
textarea.focus();
|
|
245
|
+
textarea.setSelectionRange(selection.start, selection.end);
|
|
246
|
+
});
|
|
247
|
+
return newText;
|
|
248
|
+
}
|
|
249
|
+
function toggleBlockQuote(textarea, selection) {
|
|
250
|
+
const lines = textarea.value.split('\n');
|
|
251
|
+
let charCount = 0;
|
|
252
|
+
let lineIndex = 0;
|
|
253
|
+
for (let i = 0; i < lines.length; i++) {
|
|
254
|
+
charCount += lines[i].length + 1;
|
|
255
|
+
if (selection.start < charCount) {
|
|
256
|
+
lineIndex = i;
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
let lineContent = lines[lineIndex];
|
|
261
|
+
if (lineContent.startsWith('> ')) {
|
|
262
|
+
lines[lineIndex] = lineContent.slice(2);
|
|
263
|
+
selection.start -= 2;
|
|
264
|
+
selection.end -= 2;
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
lines[lineIndex] = `> ${lineContent}`;
|
|
268
|
+
selection.start += 2;
|
|
269
|
+
selection.end += 2;
|
|
270
|
+
}
|
|
271
|
+
const newText = lines.join('\n');
|
|
272
|
+
setTimeout(() => {
|
|
273
|
+
textarea.focus();
|
|
274
|
+
textarea.setSelectionRange(selection.start, selection.end);
|
|
275
|
+
});
|
|
276
|
+
return newText;
|
|
277
|
+
}
|
|
278
|
+
function getWordAtCursor(text, cursorPosition) {
|
|
279
|
+
if (!text || cursorPosition < 0 || cursorPosition > text.length) {
|
|
280
|
+
return {
|
|
281
|
+
start: cursorPosition,
|
|
282
|
+
end: cursorPosition,
|
|
283
|
+
word: ''
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
let start = cursorPosition;
|
|
287
|
+
while (start > 0 && !isWordSeparator(text[start - 1])) {
|
|
288
|
+
start--;
|
|
289
|
+
}
|
|
290
|
+
let end = cursorPosition;
|
|
291
|
+
while (end < text.length && !isWordSeparator(text[end])) {
|
|
292
|
+
end++;
|
|
293
|
+
}
|
|
294
|
+
return {
|
|
295
|
+
start,
|
|
296
|
+
end,
|
|
297
|
+
word: text.substring(start, end)
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
function isWordSeparator(char) {
|
|
301
|
+
return /\s|\t|\n|\r|,|\.|!|\?|:|;|\(|\)/.test(char);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
class UpMarkdownDirective {
|
|
305
|
+
constructor(el, renderer) {
|
|
306
|
+
this.el = el;
|
|
307
|
+
this.renderer = renderer;
|
|
308
|
+
this.markdown = signal('', ...(ngDevMode ? [{ debugName: "markdown" }] : []));
|
|
309
|
+
this.class = `
|
|
310
|
+
[&_h1]:text-4xl [&_h1]:font-bold [&_h1]:mt-0 [&_h1]:mb-4 [&_h1]:border-b [&_h1]:border-[#eeeeee]
|
|
311
|
+
[&_h2]:text-2xl [&_h2]:font-bold [&_h2]:mt-0 [&_h2]:mb-4 [&_h2]:border-b [&_h2]:border-[#eeeeee]
|
|
312
|
+
[&_h3]:text-xl [&_h3]:font-bold [&_h3]:mt-0 [&_h3]:mb-4 [&_h3]:border-b [&_h3]:border-[#eeeeee]
|
|
313
|
+
[&_h4]:text-base [&_h4]:font-bold [&_h4]:mt-0 [&_h4]:mb-4 [&_h4]:border-b [&_h4]:border-[#eeeeee]
|
|
314
|
+
[&_h5]:text-sm [&_h5]:font-bold [&_h5]:mt-0 [&_h5]:mb-4 [&_h5]:border-b [&_h5]:border-[#eeeeee]
|
|
315
|
+
[&_h6]:text-xs [&_h6]:font-bold [&_h6]:mt-0 [&_h6]:mb-4 [&_h6]:border-b [&_h6]:border-[#eeeeee]
|
|
316
|
+
|
|
317
|
+
[&_p]:mt-0 [&_p]:mb-4
|
|
318
|
+
|
|
319
|
+
[&_ul]:mt-0 [&_ul]:pl-5 [&_ul]:list-disc [&_ul]:mb-4
|
|
320
|
+
[&_ol]:mt-0 [&_ol]:pl-5 [&_ol]:list-decimal [&_ol]:mb-4
|
|
321
|
+
|
|
322
|
+
[&_blockquote]:pl-3 [&_blockquote]:border-l-2 [&_blockquote]:border-[var(--color-primary)] [&_blockquote]:text-gray-700
|
|
323
|
+
|
|
324
|
+
[&_a]:text-[var(--color-primary)] [&_a]:underline
|
|
325
|
+
`;
|
|
326
|
+
this.observer = new MutationObserver(() => {
|
|
327
|
+
this.markdown.set(this.el.nativeElement.innerHTML || '');
|
|
328
|
+
});
|
|
329
|
+
this.observer.observe(this.el.nativeElement, {
|
|
330
|
+
subtree: true,
|
|
331
|
+
childList: true,
|
|
332
|
+
characterData: true,
|
|
333
|
+
});
|
|
334
|
+
effect(() => {
|
|
335
|
+
const native = (this.el.nativeElement);
|
|
336
|
+
this.markdown.set(native.innerHTML);
|
|
337
|
+
this.renderer.setProperty(native, 'innerHTML', marked(this.markdown()
|
|
338
|
+
.replace(/>/g, '>')
|
|
339
|
+
.replace(/\+\+(.*?)\+\+/g, '<u>$1</u>')));
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
ngOnDestroy() {
|
|
343
|
+
this.observer.disconnect();
|
|
344
|
+
}
|
|
345
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: UpMarkdownDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
346
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.0", type: UpMarkdownDirective, isStandalone: true, selector: "[upMarkdown]", host: { properties: { "class": "class" } }, exportAs: ["upMarkdown"], ngImport: i0 }); }
|
|
347
|
+
}
|
|
348
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: UpMarkdownDirective, decorators: [{
|
|
349
|
+
type: Directive,
|
|
350
|
+
args: [{
|
|
351
|
+
standalone: true,
|
|
352
|
+
exportAs: 'upMarkdown',
|
|
353
|
+
selector: '[upMarkdown]',
|
|
354
|
+
host: {
|
|
355
|
+
'[class]': 'class',
|
|
356
|
+
}
|
|
357
|
+
}]
|
|
358
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }] });
|
|
359
|
+
|
|
360
|
+
class MarkdownService {
|
|
361
|
+
constructor(config, http) {
|
|
362
|
+
this.config = config;
|
|
363
|
+
this.http = http;
|
|
364
|
+
}
|
|
365
|
+
uploadImage(file) {
|
|
366
|
+
const formData = new FormData();
|
|
367
|
+
formData.append('operations', JSON.stringify({
|
|
368
|
+
query: `
|
|
369
|
+
mutation ($attachment: Upload!) {
|
|
370
|
+
fileMgmtSysMsFileUpload(attachment: $attachment, isPublic: true) {
|
|
371
|
+
guid
|
|
372
|
+
fileName
|
|
373
|
+
publicUrl
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
`
|
|
377
|
+
}));
|
|
378
|
+
formData.append('file', file);
|
|
379
|
+
formData.append('map', JSON.stringify({
|
|
380
|
+
file: ['variables.attachment']
|
|
381
|
+
}));
|
|
382
|
+
return this.http.post(this.config.uri, formData, {
|
|
383
|
+
headers: new HttpHeaders({
|
|
384
|
+
'x-apollo-operation-name': 'fileUpload'
|
|
385
|
+
})
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: MarkdownService, deps: [{ token: UNIPIN_GQL_CONFIG }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
389
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: MarkdownService, providedIn: 'root' }); }
|
|
390
|
+
}
|
|
391
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: MarkdownService, decorators: [{
|
|
392
|
+
type: Injectable,
|
|
393
|
+
args: [{
|
|
394
|
+
providedIn: 'root'
|
|
395
|
+
}]
|
|
396
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
397
|
+
type: Inject,
|
|
398
|
+
args: [UNIPIN_GQL_CONFIG]
|
|
399
|
+
}] }, { type: i1.HttpClient }] });
|
|
400
|
+
|
|
401
|
+
class UpMarkdownInputComponent extends UpFieldControlComponent {
|
|
402
|
+
constructor(markdownService) {
|
|
403
|
+
super();
|
|
404
|
+
this.markdownService = markdownService;
|
|
405
|
+
this.value = model('', ...(ngDevMode ? [{ debugName: "value" }] : []));
|
|
406
|
+
this.placeholder = input('', ...(ngDevMode ? [{ debugName: "placeholder" }] : []));
|
|
407
|
+
this.mode = model('write', ...(ngDevMode ? [{ debugName: "mode" }] : []));
|
|
408
|
+
this.inlineClass = input('', ...(ngDevMode ? [{ debugName: "inlineClass", alias: 'class' }] : [{ alias: 'class' }]));
|
|
409
|
+
this.textarea = viewChild('textarea', ...(ngDevMode ? [{ debugName: "textarea" }] : []));
|
|
410
|
+
this.buttons = [
|
|
411
|
+
{ icon: 'customHeading', action: 'heading' },
|
|
412
|
+
{ icon: 'matFormatBoldRound', action: 'bold' },
|
|
413
|
+
{ icon: 'matFormatItalicRound', action: 'italic' },
|
|
414
|
+
{ icon: 'matFormatUnderlinedRound', action: 'underline' },
|
|
415
|
+
{ icon: 'matFormatQuoteRound', action: 'blockQuote' },
|
|
416
|
+
{ icon: 'matFormatListNumberedRound', action: 'ol' },
|
|
417
|
+
{ icon: 'matFormatListBulletedRound', action: 'ul' },
|
|
418
|
+
{ icon: 'matChecklistRound', action: 'taskList' },
|
|
419
|
+
];
|
|
420
|
+
this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{
|
|
421
|
+
transform: booleanAttribute
|
|
422
|
+
}]));
|
|
423
|
+
this.contextGuid = input('', ...(ngDevMode ? [{ debugName: "contextGuid" }] : []));
|
|
424
|
+
this.contextType = input('', ...(ngDevMode ? [{ debugName: "contextType" }] : []));
|
|
425
|
+
this.isTouched = false;
|
|
426
|
+
this._computedClass = computed(() => {
|
|
427
|
+
return up('peer placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex flex-col min-h-48 size-full min-w-0 rounded-md border bg-transparent text-base shadow-xs transition-[color,box-shadow] outline-none md:text-sm overflow-hidden', 'has-[textarea:focus-visible]:border-ring has-[textarea:focus-visible]:ring-ring/50 has-[textarea:focus-visible]:ring-[3px] has-[textarea:focus-visible]:outline-none', this.error() ? 'ring-destructive/20 dark:ring-destructive/40 border-destructive has-[textarea:focus-visible]:ring-destructive/50' : '', this.inlineClass());
|
|
428
|
+
}, ...(ngDevMode ? [{ debugName: "_computedClass" }] : []));
|
|
429
|
+
this.sub = null;
|
|
430
|
+
/**
|
|
431
|
+
* Callback function to handle value changes in the markdown input component.
|
|
432
|
+
* @type {(_val: any) => void}
|
|
433
|
+
*/
|
|
434
|
+
this._onChange = (_val) => { };
|
|
435
|
+
/**
|
|
436
|
+
* Callback function to handle touch events in the markdown input component.
|
|
437
|
+
* @type {() => void}
|
|
438
|
+
*/
|
|
439
|
+
this._onTouched = () => { };
|
|
440
|
+
if (this.ngControl !== null) {
|
|
441
|
+
this.ngControl.valueAccessor = this;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Handles keyboard events and button actions for the markdown input.
|
|
446
|
+
*
|
|
447
|
+
* @param {KeyboardEvent} event - The keyboard event.
|
|
448
|
+
*/
|
|
449
|
+
handleStyleWithKeyboard(event) {
|
|
450
|
+
if (!this.textarea() ||
|
|
451
|
+
this.textarea().nativeElement.tagName !== 'TEXTAREA') {
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
if (event.ctrlKey ||
|
|
455
|
+
event.metaKey) {
|
|
456
|
+
let result = null;
|
|
457
|
+
if (event.key.toLowerCase() === 'b') {
|
|
458
|
+
result = this.setStyle('bold', this.textarea().nativeElement);
|
|
459
|
+
}
|
|
460
|
+
if (event.key.toLowerCase() === 'i') {
|
|
461
|
+
result = this.setStyle('italic', this.textarea().nativeElement);
|
|
462
|
+
}
|
|
463
|
+
if (event.key.toLowerCase() === 'u') {
|
|
464
|
+
result = this.setStyle('underline', this.textarea().nativeElement);
|
|
465
|
+
}
|
|
466
|
+
if (result !== null) {
|
|
467
|
+
this.value.set(result);
|
|
468
|
+
this._onChange(result);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
ngOnDestroy() {
|
|
473
|
+
this.sub?.unsubscribe();
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Registers a callback function to be called when the password input value changes.
|
|
477
|
+
* @param {(_val: any) => void} fn - Callback function for value changes.
|
|
478
|
+
*/
|
|
479
|
+
registerOnChange(fn) {
|
|
480
|
+
this._onChange = fn;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Registers a callback function to be called when the password input is touched.
|
|
484
|
+
* @param {() => void} fn - Callback function for touch events.
|
|
485
|
+
*/
|
|
486
|
+
registerOnTouched(fn) {
|
|
487
|
+
this._onTouched = fn;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Writes a new value to the markdown input.
|
|
491
|
+
* @param {*} val - The new value to be set.
|
|
492
|
+
*/
|
|
493
|
+
writeValue(val) {
|
|
494
|
+
this.value.set(val ?? '');
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Event handler to handle touch status.
|
|
498
|
+
*
|
|
499
|
+
* @returns {void}
|
|
500
|
+
*/
|
|
501
|
+
touch() {
|
|
502
|
+
if (!this.isTouched) {
|
|
503
|
+
this._onTouched();
|
|
504
|
+
this.isTouched = true;
|
|
505
|
+
}
|
|
506
|
+
this.value.set(this.textarea().nativeElement.value);
|
|
507
|
+
}
|
|
508
|
+
change(event) {
|
|
509
|
+
const value = event.target.value;
|
|
510
|
+
if (!this.isTouched) {
|
|
511
|
+
this._onTouched();
|
|
512
|
+
this.isTouched = true;
|
|
513
|
+
}
|
|
514
|
+
this._onChange(value);
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Handles button actions for the markdown input.
|
|
518
|
+
*
|
|
519
|
+
* @param {string} action - The action to perform.
|
|
520
|
+
* @returns {void}
|
|
521
|
+
*/
|
|
522
|
+
applyStyle(action) {
|
|
523
|
+
const textarea = this.textarea()?.nativeElement;
|
|
524
|
+
if (!textarea) {
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
const result = this.setStyle(action, textarea);
|
|
528
|
+
if (result !== null) {
|
|
529
|
+
this.value.set(result);
|
|
530
|
+
this._onChange(result);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
changeSelection(event) {
|
|
534
|
+
const target = event.target;
|
|
535
|
+
const word = target.value.substring(target.selectionStart, target.selectionEnd);
|
|
536
|
+
this.selection = {
|
|
537
|
+
word,
|
|
538
|
+
end: target.selectionEnd,
|
|
539
|
+
start: target.selectionStart,
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
async pasteImage(event) {
|
|
543
|
+
const cursor = this.selection?.start;
|
|
544
|
+
const items = event.clipboardData?.items;
|
|
545
|
+
const textarea = this.textarea()?.nativeElement;
|
|
546
|
+
if (!items ||
|
|
547
|
+
cursor === undefined ||
|
|
548
|
+
cursor === null ||
|
|
549
|
+
!textarea) {
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
for (let i = 0; i < items.length; i++) {
|
|
553
|
+
if (items[i].type.startsWith('image/')) {
|
|
554
|
+
const file = await compressImage({
|
|
555
|
+
quality: 0.8,
|
|
556
|
+
file: items[i].getAsFile(),
|
|
557
|
+
});
|
|
558
|
+
if (!file) {
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
const errorImageText = `<!-- Upload image failed -->`;
|
|
562
|
+
const errorImageSizeText = `<!-- Image size must be less than 5MB -->`;
|
|
563
|
+
const uploadText = `<!-- Uploading "${file?.name.replace(/ /g, '-')}"... -->`;
|
|
564
|
+
textarea.value = textarea.value.substring(0, cursor) + uploadText;
|
|
565
|
+
this.value.set(textarea.value);
|
|
566
|
+
this._onChange(textarea.value);
|
|
567
|
+
setTimeout(() => {
|
|
568
|
+
textarea.setSelectionRange(cursor + uploadText.length, cursor + uploadText.length);
|
|
569
|
+
textarea.focus();
|
|
570
|
+
});
|
|
571
|
+
if (file?.size &&
|
|
572
|
+
file?.size > 5 * 1024 * 1024) {
|
|
573
|
+
this.replaceAndSetCursor(textarea, {
|
|
574
|
+
searchValue: uploadText,
|
|
575
|
+
replaceValue: errorImageSizeText
|
|
576
|
+
}, {
|
|
577
|
+
start: cursor + errorImageSizeText.length,
|
|
578
|
+
end: cursor + errorImageSizeText.length
|
|
579
|
+
});
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
this.sub?.unsubscribe();
|
|
583
|
+
this.sub = this.markdownService.uploadImage(file).subscribe({
|
|
584
|
+
error: () => {
|
|
585
|
+
this.replaceAndSetCursor(textarea, {
|
|
586
|
+
searchValue: uploadText,
|
|
587
|
+
replaceValue: errorImageText
|
|
588
|
+
}, {
|
|
589
|
+
start: cursor + errorImageText.length,
|
|
590
|
+
end: cursor + errorImageText.length
|
|
591
|
+
});
|
|
592
|
+
},
|
|
593
|
+
next: ({ data: { fileMgmtSysMsFileUpload } }) => {
|
|
594
|
+
this.imageData = fileMgmtSysMsFileUpload;
|
|
595
|
+
const markdownImageText = `})`;
|
|
596
|
+
this.replaceAndSetCursor(textarea, {
|
|
597
|
+
searchValue: uploadText,
|
|
598
|
+
replaceValue: markdownImageText
|
|
599
|
+
}, {
|
|
600
|
+
start: cursor + markdownImageText.length,
|
|
601
|
+
end: cursor + markdownImageText.length
|
|
602
|
+
});
|
|
603
|
+
},
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
replaceAndSetCursor(textarea, textReplace, cursorPosition) {
|
|
609
|
+
this.value.set(textarea.value.replace(textReplace.searchValue, textReplace.replaceValue));
|
|
610
|
+
this._onChange(textarea.value.replace(textReplace.searchValue, textReplace.replaceValue));
|
|
611
|
+
setTimeout(() => {
|
|
612
|
+
textarea.setSelectionRange(cursorPosition.start, cursorPosition.end);
|
|
613
|
+
textarea.focus();
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
setStyle(action, textarea) {
|
|
617
|
+
if (!textarea ||
|
|
618
|
+
textarea.tagName !== 'TEXTAREA' ||
|
|
619
|
+
!this.selection) {
|
|
620
|
+
return null;
|
|
621
|
+
}
|
|
622
|
+
switch (action) {
|
|
623
|
+
case 'bold':
|
|
624
|
+
return toggleBold(textarea, this.selection);
|
|
625
|
+
case 'italic':
|
|
626
|
+
return toggleItalic(textarea, this.selection);
|
|
627
|
+
case 'underline':
|
|
628
|
+
return toggleUnderline(textarea, this.selection);
|
|
629
|
+
case 'ul':
|
|
630
|
+
return toggleUnorderedList(textarea.value, this.selection.start);
|
|
631
|
+
case 'ol':
|
|
632
|
+
return toggleOrderedList(textarea.value, this.selection.start);
|
|
633
|
+
case 'heading':
|
|
634
|
+
return toggleHeading(textarea, this.selection);
|
|
635
|
+
case 'taskList':
|
|
636
|
+
return toggleTaskList(textarea.value, this.selection.start);
|
|
637
|
+
case 'blockQuote':
|
|
638
|
+
return toggleBlockQuote(textarea, this.selection);
|
|
639
|
+
default:
|
|
640
|
+
return null;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: UpMarkdownInputComponent, deps: [{ token: MarkdownService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
644
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.0", type: UpMarkdownInputComponent, isStandalone: true, selector: "up-markdown-input", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, inlineClass: { classPropertyName: "inlineClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, contextGuid: { classPropertyName: "contextGuid", publicName: "contextGuid", isSignal: true, isRequired: false, transformFunction: null }, contextType: { classPropertyName: "contextType", publicName: "contextType", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", mode: "modeChange" }, host: { listeners: { "document:keyup": "handleStyleWithKeyboard($event)" }, properties: { "class": "_computedClass()" } }, providers: [
|
|
645
|
+
{
|
|
646
|
+
provide: UpFieldControl,
|
|
647
|
+
useExisting: forwardRef(() => UpMarkdownInputComponent)
|
|
648
|
+
},
|
|
649
|
+
provideIcons({
|
|
650
|
+
matFormatBoldRound,
|
|
651
|
+
matFormatQuoteRound,
|
|
652
|
+
matFormatItalicRound,
|
|
653
|
+
matFormatUnderlinedRound,
|
|
654
|
+
matFormatListNumberedRound,
|
|
655
|
+
matFormatListBulletedRound,
|
|
656
|
+
matChecklistRound,
|
|
657
|
+
customHeading: `
|
|
658
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
|
659
|
+
<path d="M6 4v16h3V13h6v7h3V4h-3v7H9V4H6z" transform="scale(0.8) translate(3,2)"/>
|
|
660
|
+
</svg>
|
|
661
|
+
`
|
|
662
|
+
}),
|
|
663
|
+
], viewQueries: [{ propertyName: "textarea", first: true, predicate: ["textarea"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"shrink-0 w-full flex flex-col-reverse md:flex-row md:items-center justify-between gap-1 bg-[#f5f7f6]\">\n <div class=\"flex items-center h-full\">\n <button\n upButton\n variant=\"ghost\"\n class=\"transition-none rounded-none rounded-t-md\"\n [class]=\"\n mode() !== 'write'? '' : 'border-r border-input bg-white'\n \"\n (click)=\"mode.set('write')\"\n >\n Write\n </button>\n\n <button\n upButton\n variant=\"ghost\"\n class=\"transition-none rounded-none rounded-t-md\"\n [class]=\"\n mode() !== 'preview'? '' : 'border-x border-input bg-white'\n \"\n (click)=\"mode.set('preview')\"\n >\n Preview\n </button>\n </div>\n\n @if (mode() === 'write') {\n <div class=\"flex justify-start md:justify-end items-center gap-0.5\">\n @for (btn of buttons; track btn.action) {\n <button\n upButton\n size=\"sm\"\n variant=\"ghost\"\n class=\"p-0 px-2 py-1\"\n [disabled]=\"disabled()\"\n (click)=\"applyStyle(btn.action)\"\n >\n <ng-icon\n size=\"16px\" \n [name]=\"btn.icon\"\n />\n </button>\n }\n </div>\n }\n</div>\n\n<div class=\"grow relative\">\n @if (mode() === 'preview') {\n <div\n upMarkdown\n class=\"size-full absolute top-0 left-0 bg-white p-2 outline-none text-wrap break-words overflow-y-auto\"\n [innerHTML]=\"(value() || 'Nothing to preview')\"\n ></div>\n }\n @else {\n <textarea\n #textarea\n class=\"size-full absolute top-0 left-0 bg-white p-2 outline-none resize-none\" \n [value]=\"value()\"\n [disabled]=\"disabled()\"\n [placeholder]=\"placeholder()\"\n (blur)=\"touch()\"\n (input)=\"change($event)\"\n (paste)=\"pasteImage($event)\"\n (keyup)=\"changeSelection($event)\"\n (mouseup)=\"changeSelection($event)\"\n ></textarea>\n }\n</div>\n", dependencies: [{ kind: "component", type: NgIcon, selector: "ng-icon", inputs: ["name", "svg", "size", "strokeWidth", "color"] }, { kind: "directive", type: UpMarkdownDirective, selector: "[upMarkdown]", exportAs: ["upMarkdown"] }, { kind: "directive", type: UpButtonDirective, selector: "[upButton]", inputs: ["size", "variant", "class"], exportAs: ["upButton"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
664
|
+
}
|
|
665
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: UpMarkdownInputComponent, decorators: [{
|
|
666
|
+
type: Component,
|
|
667
|
+
args: [{ standalone: true, selector: 'up-markdown-input', changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
668
|
+
'[class]': '_computedClass()',
|
|
669
|
+
}, providers: [
|
|
670
|
+
{
|
|
671
|
+
provide: UpFieldControl,
|
|
672
|
+
useExisting: forwardRef(() => UpMarkdownInputComponent)
|
|
673
|
+
},
|
|
674
|
+
provideIcons({
|
|
675
|
+
matFormatBoldRound,
|
|
676
|
+
matFormatQuoteRound,
|
|
677
|
+
matFormatItalicRound,
|
|
678
|
+
matFormatUnderlinedRound,
|
|
679
|
+
matFormatListNumberedRound,
|
|
680
|
+
matFormatListBulletedRound,
|
|
681
|
+
matChecklistRound,
|
|
682
|
+
customHeading: `
|
|
683
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
|
684
|
+
<path d="M6 4v16h3V13h6v7h3V4h-3v7H9V4H6z" transform="scale(0.8) translate(3,2)"/>
|
|
685
|
+
</svg>
|
|
686
|
+
`
|
|
687
|
+
}),
|
|
688
|
+
], imports: [
|
|
689
|
+
NgIcon,
|
|
690
|
+
UpMarkdownDirective,
|
|
691
|
+
UpButtonDirective
|
|
692
|
+
], template: "<div class=\"shrink-0 w-full flex flex-col-reverse md:flex-row md:items-center justify-between gap-1 bg-[#f5f7f6]\">\n <div class=\"flex items-center h-full\">\n <button\n upButton\n variant=\"ghost\"\n class=\"transition-none rounded-none rounded-t-md\"\n [class]=\"\n mode() !== 'write'? '' : 'border-r border-input bg-white'\n \"\n (click)=\"mode.set('write')\"\n >\n Write\n </button>\n\n <button\n upButton\n variant=\"ghost\"\n class=\"transition-none rounded-none rounded-t-md\"\n [class]=\"\n mode() !== 'preview'? '' : 'border-x border-input bg-white'\n \"\n (click)=\"mode.set('preview')\"\n >\n Preview\n </button>\n </div>\n\n @if (mode() === 'write') {\n <div class=\"flex justify-start md:justify-end items-center gap-0.5\">\n @for (btn of buttons; track btn.action) {\n <button\n upButton\n size=\"sm\"\n variant=\"ghost\"\n class=\"p-0 px-2 py-1\"\n [disabled]=\"disabled()\"\n (click)=\"applyStyle(btn.action)\"\n >\n <ng-icon\n size=\"16px\" \n [name]=\"btn.icon\"\n />\n </button>\n }\n </div>\n }\n</div>\n\n<div class=\"grow relative\">\n @if (mode() === 'preview') {\n <div\n upMarkdown\n class=\"size-full absolute top-0 left-0 bg-white p-2 outline-none text-wrap break-words overflow-y-auto\"\n [innerHTML]=\"(value() || 'Nothing to preview')\"\n ></div>\n }\n @else {\n <textarea\n #textarea\n class=\"size-full absolute top-0 left-0 bg-white p-2 outline-none resize-none\" \n [value]=\"value()\"\n [disabled]=\"disabled()\"\n [placeholder]=\"placeholder()\"\n (blur)=\"touch()\"\n (input)=\"change($event)\"\n (paste)=\"pasteImage($event)\"\n (keyup)=\"changeSelection($event)\"\n (mouseup)=\"changeSelection($event)\"\n ></textarea>\n }\n</div>\n" }]
|
|
693
|
+
}], ctorParameters: () => [{ type: MarkdownService }], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], mode: [{ type: i0.Input, args: [{ isSignal: true, alias: "mode", required: false }] }, { type: i0.Output, args: ["modeChange"] }], inlineClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], textarea: [{ type: i0.ViewChild, args: ['textarea', { isSignal: true }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], contextGuid: [{ type: i0.Input, args: [{ isSignal: true, alias: "contextGuid", required: false }] }], contextType: [{ type: i0.Input, args: [{ isSignal: true, alias: "contextType", required: false }] }], handleStyleWithKeyboard: [{
|
|
694
|
+
type: HostListener,
|
|
695
|
+
args: ['document:keyup', ['$event']]
|
|
696
|
+
}] } });
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Generated bundle index. Do not edit.
|
|
700
|
+
*/
|
|
701
|
+
|
|
702
|
+
export { UpMarkdownDirective, UpMarkdownInputComponent };
|
|
703
|
+
//# sourceMappingURL=unipin-angular-applet-markdown.mjs.map
|