@ojiepermana/angular 22.1.11 → 22.1.13
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 +32 -26
- package/chart/README.md +272 -0
- package/component/README.md +89 -0
- package/component/accordion/README.md +195 -0
- package/component/alert/README.md +184 -0
- package/component/alert-dialog/README.md +255 -0
- package/component/aspect-ratio/README.md +116 -0
- package/component/avatar/README.md +182 -0
- package/component/badge/README.md +143 -0
- package/component/breadcrumb/README.md +223 -0
- package/component/button/README.md +141 -0
- package/component/button-group/README.md +214 -0
- package/component/calendar/README.md +137 -0
- package/component/card/README.md +232 -0
- package/component/carousel/README.md +276 -0
- package/component/checkbox/README.md +153 -0
- package/component/collapsible/README.md +216 -0
- package/component/combobox/README.md +202 -0
- package/component/command/README.md +287 -0
- package/component/composer/README.md +241 -0
- package/component/context-menu/README.md +268 -0
- package/component/date-picker/README.md +202 -0
- package/component/dialog/README.md +276 -0
- package/component/drawer/README.md +147 -0
- package/component/dropdown-menu/README.md +336 -0
- package/component/editor/README.md +152 -0
- package/component/empty/README.md +193 -0
- package/component/form/README.md +216 -0
- package/component/hover-card/README.md +150 -0
- package/component/icon/README.md +25 -0
- package/component/input/README.md +160 -0
- package/component/input-group/README.md +245 -0
- package/component/input-otp/README.md +331 -0
- package/component/item/README.md +254 -0
- package/component/kanban/README.md +81 -0
- package/component/kbd/README.md +141 -0
- package/component/label/README.md +137 -0
- package/component/menubar/README.md +270 -0
- package/component/native-select/README.md +176 -0
- package/component/navigation-menu/README.md +165 -0
- package/component/pagination/README.md +151 -0
- package/component/pillbox/README.md +68 -0
- package/component/popover/README.md +54 -0
- package/component/progress/README.md +160 -0
- package/component/radio/README.md +212 -0
- package/component/resizable/README.md +178 -0
- package/component/scroll-area/README.md +150 -0
- package/component/select/README.md +228 -0
- package/component/separator/README.md +175 -0
- package/component/sheet/README.md +190 -0
- package/component/skeleton/README.md +158 -0
- package/component/slider/README.md +207 -0
- package/component/spinner/README.md +160 -0
- package/component/switch/README.md +170 -0
- package/component/table/README.md +292 -0
- package/component/tabs/README.md +220 -0
- package/component/textarea/README.md +169 -0
- package/component/timeline/README.md +94 -0
- package/component/toast/README.md +173 -0
- package/component/toggle/README.md +133 -0
- package/component/toggle-group/README.md +234 -0
- package/component/tooltip/README.md +230 -0
- package/fesm2022/ojiepermana-angular-chart-area.mjs +289 -3
- package/fesm2022/ojiepermana-angular-chart-bar.mjs +722 -3
- package/fesm2022/ojiepermana-angular-chart-core.mjs +1482 -3
- package/fesm2022/ojiepermana-angular-chart-line.mjs +294 -3
- package/fesm2022/ojiepermana-angular-chart-pie.mjs +291 -3
- package/fesm2022/ojiepermana-angular-chart-primitives.mjs +1301 -3
- package/fesm2022/ojiepermana-angular-chart-radar.mjs +421 -3
- package/fesm2022/ojiepermana-angular-chart-radial.mjs +295 -3
- package/fesm2022/ojiepermana-angular-chart-scatter.mjs +306 -3
- package/fesm2022/ojiepermana-angular-chart.mjs +12 -3
- package/fesm2022/ojiepermana-angular-component-accordion.mjs +267 -3
- package/fesm2022/ojiepermana-angular-component-alert-dialog.mjs +359 -3
- package/fesm2022/ojiepermana-angular-component-alert.mjs +101 -3
- package/fesm2022/ojiepermana-angular-component-aspect-ratio.mjs +31 -3
- package/fesm2022/ojiepermana-angular-component-avatar.mjs +139 -3
- package/fesm2022/ojiepermana-angular-component-badge.mjs +57 -3
- package/fesm2022/ojiepermana-angular-component-breadcrumb.mjs +192 -3
- package/fesm2022/ojiepermana-angular-component-button-group.mjs +95 -3
- package/fesm2022/ojiepermana-angular-component-button.mjs +73 -3
- package/fesm2022/ojiepermana-angular-component-calendar.mjs +718 -3
- package/fesm2022/ojiepermana-angular-component-card.mjs +167 -3
- package/fesm2022/ojiepermana-angular-component-carousel.mjs +326 -3
- package/fesm2022/ojiepermana-angular-component-checkbox.mjs +190 -3
- package/fesm2022/ojiepermana-angular-component-collapsible.mjs +117 -3
- package/fesm2022/ojiepermana-angular-component-combobox.mjs +327 -3
- package/fesm2022/ojiepermana-angular-component-command.mjs +351 -3
- package/fesm2022/ojiepermana-angular-component-composer.mjs +359 -3
- package/fesm2022/ojiepermana-angular-component-context-menu.mjs +158 -3
- package/fesm2022/ojiepermana-angular-component-date-picker.mjs +482 -3
- package/fesm2022/ojiepermana-angular-component-dialog.mjs +400 -3
- package/fesm2022/ojiepermana-angular-component-drawer.mjs +1 -3
- package/fesm2022/ojiepermana-angular-component-dropdown-menu.mjs +689 -3
- package/fesm2022/ojiepermana-angular-component-editor.mjs +511 -3
- package/fesm2022/ojiepermana-angular-component-empty.mjs +134 -3
- package/fesm2022/ojiepermana-angular-component-form.mjs +438 -3
- package/fesm2022/ojiepermana-angular-component-hover-card.mjs +273 -3
- package/fesm2022/ojiepermana-angular-component-icon.mjs +139 -3
- package/fesm2022/ojiepermana-angular-component-input-group.mjs +176 -3
- package/fesm2022/ojiepermana-angular-component-input-otp.mjs +550 -3
- package/fesm2022/ojiepermana-angular-component-input.mjs +52 -3
- package/fesm2022/ojiepermana-angular-component-item.mjs +264 -3
- package/fesm2022/ojiepermana-angular-component-kanban.mjs +310 -3
- package/fesm2022/ojiepermana-angular-component-kbd.mjs +48 -3
- package/fesm2022/ojiepermana-angular-component-label.mjs +27 -3
- package/fesm2022/ojiepermana-angular-component-menubar.mjs +327 -3
- package/fesm2022/ojiepermana-angular-component-native-select.mjs +62 -3
- package/fesm2022/ojiepermana-angular-component-navigation-menu.mjs +378 -3
- package/fesm2022/ojiepermana-angular-component-pagination.mjs +238 -3
- package/fesm2022/ojiepermana-angular-component-pillbox.mjs +999 -3
- package/fesm2022/ojiepermana-angular-component-popover.mjs +201 -3
- package/fesm2022/ojiepermana-angular-component-progress.mjs +57 -3
- package/fesm2022/ojiepermana-angular-component-radio.mjs +180 -3
- package/fesm2022/ojiepermana-angular-component-resizable.mjs +493 -3
- package/fesm2022/ojiepermana-angular-component-scroll-area.mjs +51 -3
- package/fesm2022/ojiepermana-angular-component-segmented-control.mjs +227 -3
- package/fesm2022/ojiepermana-angular-component-select.mjs +609 -3
- package/fesm2022/ojiepermana-angular-component-separator.mjs +31 -3
- package/fesm2022/ojiepermana-angular-component-sheet.mjs +407 -3
- package/fesm2022/ojiepermana-angular-component-skeleton.mjs +25 -3
- package/fesm2022/ojiepermana-angular-component-slider.mjs +456 -3
- package/fesm2022/ojiepermana-angular-component-spinner.mjs +56 -3
- package/fesm2022/ojiepermana-angular-component-switch.mjs +145 -3
- package/fesm2022/ojiepermana-angular-component-table.mjs +155 -3
- package/fesm2022/ojiepermana-angular-component-tabs.mjs +315 -3
- package/fesm2022/ojiepermana-angular-component-textarea.mjs +46 -3
- package/fesm2022/ojiepermana-angular-component-timeline.mjs +237 -3
- package/fesm2022/ojiepermana-angular-component-toast.mjs +241 -3
- package/fesm2022/ojiepermana-angular-component-toggle-group.mjs +290 -3
- package/fesm2022/ojiepermana-angular-component-toggle.mjs +76 -3
- package/fesm2022/ojiepermana-angular-component-tooltip.mjs +519 -3
- package/fesm2022/ojiepermana-angular-component-utils-core.mjs +310 -3
- package/fesm2022/ojiepermana-angular-component-utils-overlay.mjs +62 -3
- package/fesm2022/ojiepermana-angular-component-utils-scale.mjs +34 -3
- package/fesm2022/ojiepermana-angular-component-utils.mjs +3 -2
- package/fesm2022/ojiepermana-angular-component.mjs +4 -4
- package/fesm2022/ojiepermana-angular-navigation-core.mjs +21 -3
- package/fesm2022/ojiepermana-angular-navigation-icon.mjs +20 -3
- package/fesm2022/ojiepermana-angular-navigation-navigation-badge-count.component-CDBxQ8rk.mjs +91 -0
- package/fesm2022/ojiepermana-angular-navigation-navigation-dockbar-menu.component-DBQHdvGa.mjs +512 -0
- package/fesm2022/ojiepermana-angular-navigation-navigation-entry-grid.component-Cd-jh6tg.mjs +623 -0
- package/fesm2022/ojiepermana-angular-navigation-navigation-flyout-menu.component-BCGvhoYj.mjs +404 -0
- package/fesm2022/ojiepermana-angular-navigation-navigation-horizontal.component-Dk_03e-6.mjs +466 -0
- package/fesm2022/ojiepermana-angular-navigation-ojiepermana-angular-navigation-DNKU6viC.mjs +2642 -0
- package/fesm2022/ojiepermana-angular-navigation-service.mjs +725 -3
- package/fesm2022/ojiepermana-angular-navigation-types.mjs +65 -4
- package/fesm2022/ojiepermana-angular-navigation.mjs +4 -10
- package/fesm2022/ojiepermana-angular-sdk.mjs +204 -4
- package/fesm2022/ojiepermana-angular-theme-component-settings.mjs +1387 -3
- package/fesm2022/ojiepermana-angular-theme-layout-services.mjs +331 -3
- package/fesm2022/ojiepermana-angular-theme-layout-types.mjs +45 -4
- package/fesm2022/ojiepermana-angular-theme-layout-wrapper.mjs +1044 -3
- package/fesm2022/ojiepermana-angular-theme-layout.mjs +729 -3
- package/fesm2022/ojiepermana-angular-theme-page-core.mjs +381 -3
- package/fesm2022/ojiepermana-angular-theme-page-filter.mjs +267 -3
- package/fesm2022/ojiepermana-angular-theme-page-root.mjs +361 -3
- package/fesm2022/ojiepermana-angular-theme-page-side.mjs +198 -3
- package/fesm2022/ojiepermana-angular-theme-page-slots.mjs +110 -3
- package/fesm2022/ojiepermana-angular-theme-page.mjs +7 -2
- package/fesm2022/ojiepermana-angular-theme-shell-services.mjs +338 -3
- package/fesm2022/ojiepermana-angular-theme-shell-types.mjs +160 -4
- package/fesm2022/ojiepermana-angular-theme-shell.mjs +811 -3
- package/fesm2022/ojiepermana-angular-theme-styles.mjs +783 -3
- package/fesm2022/ojiepermana-angular-theme.mjs +4 -4
- package/fesm2022/ojiepermana-angular.mjs +6 -11
- package/navigation/README.md +374 -0
- package/package.json +81 -20
- package/sdk/README.md +212 -0
- package/sdk/schematics/collection.json +20 -0
- package/sdk/schematics/init/index.js +83 -0
- package/sdk/schematics/init/schema.json +19 -0
- package/sdk/schematics/ng-add/index.js +147 -0
- package/sdk/schematics/ng-add/schema.json +14 -0
- package/sdk/schematics/package.json +3 -0
- package/sdk/schematics/sdk/index.js +175 -0
- package/sdk/schematics/sdk/schema.json +19 -0
- package/sdk/sdk.config.example.json +24 -0
- package/sdk/src/config/loader.js +43 -0
- package/sdk/src/config/schema.js +59 -0
- package/sdk/src/emit/client.js +251 -0
- package/sdk/src/emit/metadata.js +310 -0
- package/sdk/src/emit/models.js +104 -0
- package/sdk/src/emit/navigation.js +56 -0
- package/sdk/src/emit/operations.js +118 -0
- package/sdk/src/emit/public-api.js +54 -0
- package/sdk/src/emit/services.js +110 -0
- package/sdk/src/engine.js +67 -0
- package/sdk/src/layout/per-domain.js +360 -0
- package/sdk/src/package.json +3 -0
- package/sdk/src/parser/bundle.js +25 -0
- package/sdk/src/parser/ir.js +429 -0
- package/sdk/src/parser/types.js +7 -0
- package/sdk/src/render/template.js +152 -0
- package/sdk/src/writer/index.js +286 -0
- package/theme/README.md +126 -0
- package/theme/component/settings/README.md +135 -0
- package/theme/layout/README.md +539 -0
- package/theme/page/README.md +453 -0
- package/theme/shell/README.md +340 -0
- package/theme/styles/README.md +178 -0
- package/theme/styles/css/base/components.css +553 -0
- package/theme/styles/css/base/index.css +14 -0
- package/theme/styles/css/base/package.css +9 -0
- package/theme/styles/css/base/prefers-dark.css +86 -0
- package/theme/styles/css/base/print.css +62 -0
- package/theme/styles/css/base/status.css +38 -0
- package/theme/styles/css/base/tailwind.css +165 -0
- package/theme/styles/css/base/theme.css +374 -0
- package/theme/styles/css/base/tokens.css +361 -0
- package/theme/styles/css/color/amber.css +72 -0
- package/theme/styles/css/color/blue.css +72 -0
- package/theme/styles/css/color/brand.css +38 -0
- package/theme/styles/css/color/cyan.css +72 -0
- package/theme/styles/css/color/emerald.css +72 -0
- package/theme/styles/css/color/fuchsia.css +72 -0
- package/theme/styles/css/color/green.css +72 -0
- package/theme/styles/css/color/index.css +19 -0
- package/theme/styles/css/color/indigo.css +72 -0
- package/theme/styles/css/color/lime.css +72 -0
- package/theme/styles/css/color/orange.css +72 -0
- package/theme/styles/css/color/pink.css +72 -0
- package/theme/styles/css/color/purple.css +72 -0
- package/theme/styles/css/color/red.css +72 -0
- package/theme/styles/css/color/rose.css +72 -0
- package/theme/styles/css/color/sky.css +72 -0
- package/theme/styles/css/color/teal.css +72 -0
- package/theme/styles/css/color/violet.css +72 -0
- package/theme/styles/css/color/yellow.css +72 -0
- package/theme/styles/css/index.css +18 -0
- package/theme/styles/css/neutral/gray.css +63 -0
- package/theme/styles/css/neutral/index.css +11 -0
- package/theme/styles/css/neutral/mauve.css +63 -0
- package/theme/styles/css/neutral/mist.css +63 -0
- package/theme/styles/css/neutral/neutral.css +63 -0
- package/theme/styles/css/neutral/olive.css +63 -0
- package/theme/styles/css/neutral/slate.css +63 -0
- package/theme/styles/css/neutral/stone.css +63 -0
- package/theme/styles/css/neutral/taupe.css +63 -0
- package/theme/styles/css/neutral/zinc.css +63 -0
- package/theme/styles/css/radius/index.css +30 -0
- package/theme/styles/css/space/index.css +20 -0
- package/types/ojiepermana-angular-chart-area.d.ts +76 -1
- package/types/ojiepermana-angular-chart-bar.d.ts +201 -1
- package/types/ojiepermana-angular-chart-core.d.ts +811 -1
- package/types/ojiepermana-angular-chart-line.d.ts +75 -1
- package/types/ojiepermana-angular-chart-pie.d.ts +131 -1
- package/types/ojiepermana-angular-chart-primitives.d.ts +291 -1
- package/types/ojiepermana-angular-chart-radar.d.ts +116 -1
- package/types/ojiepermana-angular-chart-radial.d.ts +116 -1
- package/types/ojiepermana-angular-chart-scatter.d.ts +125 -1
- package/types/ojiepermana-angular-chart.d.ts +2 -1
- package/types/ojiepermana-angular-component-accordion.d.ts +85 -1
- package/types/ojiepermana-angular-component-alert-dialog.d.ts +140 -1
- package/types/ojiepermana-angular-component-alert.d.ts +42 -1
- package/types/ojiepermana-angular-component-aspect-ratio.d.ts +12 -1
- package/types/ojiepermana-angular-component-avatar.d.ts +56 -1
- package/types/ojiepermana-angular-component-badge.d.ts +24 -1
- package/types/ojiepermana-angular-component-breadcrumb.d.ts +46 -1
- package/types/ojiepermana-angular-component-button-group.d.ts +26 -1
- package/types/ojiepermana-angular-component-button.d.ts +27 -1
- package/types/ojiepermana-angular-component-calendar.d.ts +111 -1
- package/types/ojiepermana-angular-component-card.d.ts +69 -1
- package/types/ojiepermana-angular-component-carousel.d.ts +86 -1
- package/types/ojiepermana-angular-component-checkbox.d.ts +42 -1
- package/types/ojiepermana-angular-component-collapsible.d.ts +42 -1
- package/types/ojiepermana-angular-component-combobox.d.ts +60 -1
- package/types/ojiepermana-angular-component-command.d.ts +130 -1
- package/types/ojiepermana-angular-component-composer.d.ts +90 -1
- package/types/ojiepermana-angular-component-context-menu.d.ts +54 -1
- package/types/ojiepermana-angular-component-date-picker.d.ts +109 -1
- package/types/ojiepermana-angular-component-dialog.d.ts +136 -1
- package/types/ojiepermana-angular-component-drawer.d.ts +1 -1
- package/types/ojiepermana-angular-component-dropdown-menu.d.ts +248 -1
- package/types/ojiepermana-angular-component-editor.d.ts +135 -1
- package/types/ojiepermana-angular-component-empty.d.ts +50 -1
- package/types/ojiepermana-angular-component-form.d.ts +159 -1
- package/types/ojiepermana-angular-component-hover-card.d.ts +75 -1
- package/types/ojiepermana-angular-component-icon.d.ts +89 -1
- package/types/ojiepermana-angular-component-input-group.d.ts +51 -1
- package/types/ojiepermana-angular-component-input-otp.d.ts +155 -1
- package/types/ojiepermana-angular-component-input.d.ts +21 -1
- package/types/ojiepermana-angular-component-item.d.ts +93 -1
- package/types/ojiepermana-angular-component-kanban.d.ts +70 -1
- package/types/ojiepermana-angular-component-kbd.d.ts +16 -1
- package/types/ojiepermana-angular-component-label.d.ts +11 -1
- package/types/ojiepermana-angular-component-menubar.d.ts +93 -1
- package/types/ojiepermana-angular-component-native-select.d.ts +26 -1
- package/types/ojiepermana-angular-component-navigation-menu.d.ts +104 -1
- package/types/ojiepermana-angular-component-pagination.d.ts +33 -1
- package/types/ojiepermana-angular-component-pillbox.d.ts +222 -1
- package/types/ojiepermana-angular-component-popover.d.ts +66 -1
- package/types/ojiepermana-angular-component-progress.d.ts +17 -1
- package/types/ojiepermana-angular-component-radio.d.ts +60 -1
- package/types/ojiepermana-angular-component-resizable.d.ts +117 -1
- package/types/ojiepermana-angular-component-scroll-area.d.ts +19 -1
- package/types/ojiepermana-angular-component-segmented-control.d.ts +58 -1
- package/types/ojiepermana-angular-component-select.d.ts +122 -1
- package/types/ojiepermana-angular-component-separator.d.ts +14 -1
- package/types/ojiepermana-angular-component-sheet.d.ts +130 -1
- package/types/ojiepermana-angular-component-skeleton.d.ts +10 -1
- package/types/ojiepermana-angular-component-slider.d.ts +83 -1
- package/types/ojiepermana-angular-component-spinner.d.ts +13 -1
- package/types/ojiepermana-angular-component-switch.d.ts +44 -1
- package/types/ojiepermana-angular-component-table.d.ts +57 -1
- package/types/ojiepermana-angular-component-tabs.d.ts +124 -1
- package/types/ojiepermana-angular-component-textarea.d.ts +17 -1
- package/types/ojiepermana-angular-component-timeline.d.ts +64 -1
- package/types/ojiepermana-angular-component-toast.d.ts +64 -1
- package/types/ojiepermana-angular-component-toggle-group.d.ts +90 -1
- package/types/ojiepermana-angular-component-toggle.d.ts +25 -1
- package/types/ojiepermana-angular-component-tooltip.d.ts +143 -1
- package/types/ojiepermana-angular-component-utils-core.d.ts +184 -1
- package/types/ojiepermana-angular-component-utils-overlay.d.ts +21 -1
- package/types/ojiepermana-angular-component-utils-scale.d.ts +19 -1
- package/types/ojiepermana-angular-component-utils.d.ts +2 -1
- package/types/ojiepermana-angular-component.d.ts +2 -1
- package/types/ojiepermana-angular-navigation-core.d.ts +59 -1
- package/types/ojiepermana-angular-navigation-icon.d.ts +12 -1
- package/types/ojiepermana-angular-navigation-service.d.ts +116 -1
- package/types/ojiepermana-angular-navigation-types.d.ts +144 -1
- package/types/ojiepermana-angular-navigation.d.ts +507 -1
- package/types/ojiepermana-angular-sdk.d.ts +89 -1
- package/types/ojiepermana-angular-theme-component-settings.d.ts +154 -1
- package/types/ojiepermana-angular-theme-layout-services.d.ts +147 -1
- package/types/ojiepermana-angular-theme-layout-types.d.ts +40 -1
- package/types/ojiepermana-angular-theme-layout-wrapper.d.ts +299 -1
- package/types/ojiepermana-angular-theme-layout.d.ts +129 -1
- package/types/ojiepermana-angular-theme-page-core.d.ts +157 -1
- package/types/ojiepermana-angular-theme-page-filter.d.ts +77 -1
- package/types/ojiepermana-angular-theme-page-root.d.ts +88 -1
- package/types/ojiepermana-angular-theme-page-side.d.ts +50 -1
- package/types/ojiepermana-angular-theme-page-slots.d.ts +40 -1
- package/types/ojiepermana-angular-theme-page.d.ts +5 -1
- package/types/ojiepermana-angular-theme-shell-services.d.ts +193 -1
- package/types/ojiepermana-angular-theme-shell-types.d.ts +105 -1
- package/types/ojiepermana-angular-theme-shell.d.ts +100 -1
- package/types/ojiepermana-angular-theme-styles.d.ts +319 -1
- package/types/ojiepermana-angular-theme.d.ts +2 -1
- package/types/ojiepermana-angular.d.ts +5 -5
|
@@ -1,7 +1,515 @@
|
|
|
1
|
-
|
|
1
|
+
import { DOCUMENT } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { InjectionToken, inject, SecurityContext, input, booleanAttribute, output, computed, Component, ElementRef, signal, forwardRef } from '@angular/core';
|
|
4
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
5
|
+
import { cn } from '@ojiepermana/angular/component/utils/core';
|
|
6
|
+
import { DomSanitizer } from '@angular/platform-browser';
|
|
2
7
|
|
|
3
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Override this token when an application needs a stricter allow-list than
|
|
10
|
+
* Angular's platform HTML sanitizer.
|
|
11
|
+
*/
|
|
12
|
+
const EDITOR_HTML_SANITIZER = new InjectionToken('EDITOR_HTML_SANITIZER', {
|
|
13
|
+
providedIn: 'root',
|
|
14
|
+
factory: () => {
|
|
15
|
+
const sanitizer = inject(DomSanitizer);
|
|
16
|
+
return (html) => sanitizer.sanitize(SecurityContext.HTML, html) ?? '';
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const DEFAULT_EDITOR_TOOLBAR = 'heading | bold italic underline strike | bullet ordered blockquote link align ~ undo redo';
|
|
21
|
+
const EDITOR_BASE = 'block w-full min-w-0 text-sm text-foreground';
|
|
22
|
+
const EDITOR_SHELL_BASE = [
|
|
23
|
+
'relative min-w-0 overflow-hidden rounded-md border border-input bg-background shadow-sm',
|
|
24
|
+
'transition-[border-color,box-shadow] focus-within:border-ring focus-within:ring-1 focus-within:ring-ring',
|
|
25
|
+
'aria-[invalid=true]:border-destructive aria-[invalid=true]:focus-within:ring-destructive',
|
|
26
|
+
'data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50',
|
|
27
|
+
].join(' ');
|
|
28
|
+
const EDITOR_TOOLBAR_BASE = [
|
|
29
|
+
'flex min-h-11 min-w-0 flex-wrap items-center gap-1 border-b border-[hsl(var(--border)/var(--opacity-70))] bg-[hsl(var(--muted)/var(--opacity-30))] px-2 py-1.5',
|
|
30
|
+
'data-[disabled=true]:pointer-events-none',
|
|
31
|
+
].join(' ');
|
|
32
|
+
const EDITOR_TOOL_BUTTON_BASE = [
|
|
33
|
+
'inline-flex size-8 shrink-0 items-center justify-center rounded-md text-sm font-medium text-muted-foreground',
|
|
34
|
+
'transition-colors hover:bg-accent hover:text-accent-foreground',
|
|
35
|
+
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
|
36
|
+
'disabled:pointer-events-none disabled:opacity-50',
|
|
37
|
+
'aria-pressed:bg-accent aria-pressed:text-accent-foreground',
|
|
38
|
+
].join(' ');
|
|
39
|
+
const EDITOR_SELECT_BASE = [
|
|
40
|
+
'h-8 rounded-md border border-transparent bg-transparent px-2 text-sm font-medium text-muted-foreground outline-none',
|
|
41
|
+
'transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:ring-2 focus-visible:ring-ring',
|
|
42
|
+
'disabled:pointer-events-none disabled:opacity-50',
|
|
43
|
+
].join(' ');
|
|
44
|
+
const EDITOR_CONTENT_BASE = [
|
|
45
|
+
'block min-h-50 max-h-125 w-full overflow-y-auto px-4 py-3 text-sm leading-6 outline-none',
|
|
46
|
+
'[&_p]:my-2 [&_h1]:mb-2 [&_h1]:mt-4 [&_h1]:text-2xl [&_h1]:font-semibold [&_h2]:mb-2 [&_h2]:mt-4 [&_h2]:text-xl [&_h2]:font-semibold [&_h3]:mb-2 [&_h3]:mt-4 [&_h3]:text-lg [&_h3]:font-semibold',
|
|
47
|
+
'[&_blockquote]:my-3 [&_blockquote]:border-l-2 [&_blockquote]:border-border [&_blockquote]:pl-3 [&_blockquote]:text-muted-foreground [&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-6 [&_ol]:my-2 [&_ol]:list-decimal [&_ol]:pl-6 [&_pre]:my-3 [&_pre]:overflow-x-auto [&_pre]:rounded-md [&_pre]:bg-muted [&_pre]:p-3 [&_pre]:font-mono [&_pre]:text-xs',
|
|
48
|
+
'data-[empty=true]:before:pointer-events-none data-[empty=true]:before:text-muted-foreground data-[empty=true]:before:content-[attr(data-placeholder)]',
|
|
49
|
+
'data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50',
|
|
50
|
+
].join(' ');
|
|
51
|
+
const toolbarButtons = {
|
|
52
|
+
bold: { label: 'B', ariaLabel: 'Bold' },
|
|
53
|
+
italic: { label: 'I', ariaLabel: 'Italic' },
|
|
54
|
+
underline: { label: 'U', ariaLabel: 'Underline' },
|
|
55
|
+
strike: { label: 'S', ariaLabel: 'Strikethrough' },
|
|
56
|
+
bullet: { label: 'UL', ariaLabel: 'Bulleted list' },
|
|
57
|
+
ordered: { label: '1.', ariaLabel: 'Numbered list' },
|
|
58
|
+
blockquote: { label: 'Q', ariaLabel: 'Block quote' },
|
|
59
|
+
subscript: { label: 'Sub', ariaLabel: 'Subscript' },
|
|
60
|
+
superscript: { label: 'Sup', ariaLabel: 'Superscript' },
|
|
61
|
+
highlight: { label: 'H', ariaLabel: 'Highlight' },
|
|
62
|
+
link: { label: 'Link', ariaLabel: 'Insert link' },
|
|
63
|
+
code: { label: '</>', ariaLabel: 'Code block' },
|
|
64
|
+
undo: { label: 'Undo', ariaLabel: 'Undo' },
|
|
65
|
+
redo: { label: 'Redo', ariaLabel: 'Redo' },
|
|
66
|
+
};
|
|
67
|
+
/** document.execCommand name (+ optional value) for each editor command. */
|
|
68
|
+
const EDITOR_EXEC_COMMANDS = {
|
|
69
|
+
paragraph: ['formatBlock', 'p'],
|
|
70
|
+
'heading-1': ['formatBlock', 'h1'],
|
|
71
|
+
'heading-2': ['formatBlock', 'h2'],
|
|
72
|
+
'heading-3': ['formatBlock', 'h3'],
|
|
73
|
+
bold: ['bold'],
|
|
74
|
+
italic: ['italic'],
|
|
75
|
+
underline: ['underline'],
|
|
76
|
+
strike: ['strikeThrough'],
|
|
77
|
+
bullet: ['insertUnorderedList'],
|
|
78
|
+
ordered: ['insertOrderedList'],
|
|
79
|
+
blockquote: ['formatBlock', 'blockquote'],
|
|
80
|
+
subscript: ['subscript'],
|
|
81
|
+
superscript: ['superscript'],
|
|
82
|
+
highlight: ['backColor'],
|
|
83
|
+
link: ['createLink', '#'],
|
|
84
|
+
code: ['formatBlock', 'pre'],
|
|
85
|
+
'align-left': ['justifyLeft'],
|
|
86
|
+
'align-center': ['justifyCenter'],
|
|
87
|
+
'align-right': ['justifyRight'],
|
|
88
|
+
undo: ['undo'],
|
|
89
|
+
redo: ['redo'],
|
|
90
|
+
};
|
|
91
|
+
/** Keeps the text selection alive while clicking toolbar controls. */
|
|
92
|
+
const preserveEditorSelection = (event) => {
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
};
|
|
95
|
+
const parseToolbarItems = (items) => {
|
|
96
|
+
const tokens = items.split(/\s+/).filter(Boolean);
|
|
97
|
+
return tokens.flatMap((token, index) => {
|
|
98
|
+
if (token === '|') {
|
|
99
|
+
return [{ type: 'separator', track: `separator-${index}` }];
|
|
100
|
+
}
|
|
101
|
+
if (token === '~') {
|
|
102
|
+
return [{ type: 'spacer', track: `spacer-${index}` }];
|
|
103
|
+
}
|
|
104
|
+
if (token === 'heading') {
|
|
105
|
+
return [{ type: 'heading', track: `heading-${index}` }];
|
|
106
|
+
}
|
|
107
|
+
if (token === 'align') {
|
|
108
|
+
return [{ type: 'align', track: `align-${index}` }];
|
|
109
|
+
}
|
|
110
|
+
const command = token;
|
|
111
|
+
const button = toolbarButtons[command];
|
|
112
|
+
if (!button) {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
return [{ type: 'button', command, label: button.label, ariaLabel: button.ariaLabel }];
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
class EditorComponent {
|
|
119
|
+
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
120
|
+
invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
121
|
+
class = input('', /* @ts-ignore */
|
|
122
|
+
...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
123
|
+
commandSelected = output();
|
|
124
|
+
content = null;
|
|
125
|
+
classes = computed(() => cn(EDITOR_BASE, this.class()), /* @ts-ignore */
|
|
126
|
+
...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
127
|
+
shellClasses = computed(() => cn(EDITOR_SHELL_BASE), /* @ts-ignore */
|
|
128
|
+
...(ngDevMode ? [{ debugName: "shellClasses" }] : /* istanbul ignore next */ []));
|
|
129
|
+
execute(command, source = 'api', originalEvent) {
|
|
130
|
+
if (this.disabled()) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
this.content?.execute(command);
|
|
134
|
+
this.commandSelected.emit({ command, source, originalEvent });
|
|
135
|
+
}
|
|
136
|
+
registerContent(content) {
|
|
137
|
+
this.content = content;
|
|
138
|
+
}
|
|
139
|
+
unregisterContent(content) {
|
|
140
|
+
if (this.content === content) {
|
|
141
|
+
this.content = null;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: EditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
145
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.4", type: EditorComponent, isStandalone: true, selector: "Editor", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { commandSelected: "commandSelected" }, host: { properties: { "class": "classes()", "attr.data-slot": "\"editor\"", "attr.data-disabled": "disabled() ? \"true\" : null", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-invalid": "invalid() ? \"true\" : null", "attr.inert": "disabled() ? \"\" : null" } }, ngImport: i0, template: "<div\n data-slot=\"editor-shell\"\n [class]=\"shellClasses()\"\n [attr.data-disabled]=\"disabled() ? 'true' : null\"\n [attr.aria-invalid]=\"invalid() ? 'true' : null\"\n>\n <ng-content select=\"EditorToolbar\" />\n <ng-content select=\"EditorContent\" />\n</div>\n" });
|
|
146
|
+
}
|
|
147
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: EditorComponent, decorators: [{
|
|
148
|
+
type: Component,
|
|
149
|
+
args: [{ selector: 'Editor', host: {
|
|
150
|
+
'[class]': 'classes()',
|
|
151
|
+
'[attr.data-slot]': '"editor"',
|
|
152
|
+
'[attr.data-disabled]': 'disabled() ? "true" : null',
|
|
153
|
+
'[attr.aria-disabled]': 'disabled() ? "true" : null',
|
|
154
|
+
'[attr.aria-invalid]': 'invalid() ? "true" : null',
|
|
155
|
+
'[attr.inert]': 'disabled() ? "" : null',
|
|
156
|
+
}, template: "<div\n data-slot=\"editor-shell\"\n [class]=\"shellClasses()\"\n [attr.data-disabled]=\"disabled() ? 'true' : null\"\n [attr.aria-invalid]=\"invalid() ? 'true' : null\"\n>\n <ng-content select=\"EditorToolbar\" />\n <ng-content select=\"EditorContent\" />\n</div>\n" }]
|
|
157
|
+
}], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], commandSelected: [{ type: i0.Output, args: ["commandSelected"] }] } });
|
|
158
|
+
class EditorToolbarComponent {
|
|
159
|
+
editor = inject(EditorComponent, { optional: true });
|
|
160
|
+
items = input(DEFAULT_EDITOR_TOOLBAR, /* @ts-ignore */
|
|
161
|
+
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
162
|
+
disabledInput = input(false, { ...(ngDevMode ? { debugName: "disabledInput" } : /* istanbul ignore next */ {}), alias: 'disabled', transform: booleanAttribute });
|
|
163
|
+
ariaLabel = input('Formatting', { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
164
|
+
class = input('', /* @ts-ignore */
|
|
165
|
+
...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
166
|
+
buttonClasses = EDITOR_TOOL_BUTTON_BASE;
|
|
167
|
+
selectClasses = EDITOR_SELECT_BASE;
|
|
168
|
+
disabled = computed(() => this.disabledInput() || this.editor?.disabled() === true, /* @ts-ignore */
|
|
169
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
170
|
+
parts = computed(() => parseToolbarItems(this.items()), /* @ts-ignore */
|
|
171
|
+
...(ngDevMode ? [{ debugName: "parts" }] : /* istanbul ignore next */ []));
|
|
172
|
+
classes = computed(() => cn(EDITOR_TOOLBAR_BASE, this.class()), /* @ts-ignore */
|
|
173
|
+
...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
174
|
+
execute(command, event) {
|
|
175
|
+
this.editor?.execute(command, 'toolbar', event);
|
|
176
|
+
}
|
|
177
|
+
handleSelect(event) {
|
|
178
|
+
const select = event.target;
|
|
179
|
+
this.editor?.execute(select.value, 'toolbar', event);
|
|
180
|
+
select.selectedIndex = 0;
|
|
181
|
+
}
|
|
182
|
+
preserveSelection = preserveEditorSelection;
|
|
183
|
+
trackPart(part, index) {
|
|
184
|
+
if (part.type === 'button') {
|
|
185
|
+
return `${part.command}-${index}`;
|
|
186
|
+
}
|
|
187
|
+
return part.track;
|
|
188
|
+
}
|
|
189
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: EditorToolbarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
190
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.4", type: EditorToolbarComponent, isStandalone: true, selector: "EditorToolbar", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, disabledInput: { classPropertyName: "disabledInput", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "toolbar" }, properties: { "class": "classes()", "attr.data-slot": "\"editor-toolbar\"", "attr.aria-label": "ariaLabel()", "attr.data-disabled": "disabled() ? \"true\" : null" } }, ngImport: i0, template: "@for (part of parts(); track trackPart(part, $index)) {\n @switch (part.type) {\n @case ('heading') {\n <select\n [class]=\"selectClasses\"\n [disabled]=\"disabled()\"\n aria-label=\"Text style\"\n (change)=\"handleSelect($event)\"\n >\n <option value=\"paragraph\">Text</option>\n <option value=\"heading-1\">Heading 1</option>\n <option value=\"heading-2\">Heading 2</option>\n <option value=\"heading-3\">Heading 3</option>\n </select>\n }\n @case ('align') {\n <select\n [class]=\"selectClasses\"\n [disabled]=\"disabled()\"\n aria-label=\"Text alignment\"\n (change)=\"handleSelect($event)\"\n >\n <option value=\"align-left\">Left</option>\n <option value=\"align-center\">Center</option>\n <option value=\"align-right\">Right</option>\n </select>\n }\n @case ('separator') {\n <span\n data-slot=\"editor-separator\"\n class=\"mx-1 h-6 w-px shrink-0 bg-border\"\n role=\"separator\"\n aria-orientation=\"vertical\"\n ></span>\n }\n @case ('spacer') {\n <span data-slot=\"editor-spacer\" class=\"min-w-2 flex-1\"></span>\n }\n @case ('button') {\n <button\n type=\"button\"\n data-slot=\"editor-button\"\n [class]=\"buttonClasses\"\n [disabled]=\"disabled()\"\n [attr.aria-label]=\"part.ariaLabel\"\n [attr.title]=\"part.ariaLabel\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"execute(part.command, $event)\"\n >\n @if (part.command === 'undo') {\n <svg\n aria-hidden=\"true\"\n class=\"size-4\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.75\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n >\n <path d=\"M9 14 4 9l5-5\" />\n <path d=\"M4 9h10a6 6 0 0 1 0 12h-2\" />\n </svg>\n } @else if (part.command === 'redo') {\n <svg\n aria-hidden=\"true\"\n class=\"size-4\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.75\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n >\n <path d=\"m15 14 5-5-5-5\" />\n <path d=\"M20 9H10a6 6 0 0 0 0 12h2\" />\n </svg>\n } @else {\n <span aria-hidden=\"true\">{{ part.label }}</span>\n }\n </button>\n }\n }\n}\n<ng-content />\n" });
|
|
191
|
+
}
|
|
192
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: EditorToolbarComponent, decorators: [{
|
|
193
|
+
type: Component,
|
|
194
|
+
args: [{ selector: 'EditorToolbar', host: {
|
|
195
|
+
'[class]': 'classes()',
|
|
196
|
+
'[attr.data-slot]': '"editor-toolbar"',
|
|
197
|
+
role: 'toolbar',
|
|
198
|
+
'[attr.aria-label]': 'ariaLabel()',
|
|
199
|
+
'[attr.data-disabled]': 'disabled() ? "true" : null',
|
|
200
|
+
}, template: "@for (part of parts(); track trackPart(part, $index)) {\n @switch (part.type) {\n @case ('heading') {\n <select\n [class]=\"selectClasses\"\n [disabled]=\"disabled()\"\n aria-label=\"Text style\"\n (change)=\"handleSelect($event)\"\n >\n <option value=\"paragraph\">Text</option>\n <option value=\"heading-1\">Heading 1</option>\n <option value=\"heading-2\">Heading 2</option>\n <option value=\"heading-3\">Heading 3</option>\n </select>\n }\n @case ('align') {\n <select\n [class]=\"selectClasses\"\n [disabled]=\"disabled()\"\n aria-label=\"Text alignment\"\n (change)=\"handleSelect($event)\"\n >\n <option value=\"align-left\">Left</option>\n <option value=\"align-center\">Center</option>\n <option value=\"align-right\">Right</option>\n </select>\n }\n @case ('separator') {\n <span\n data-slot=\"editor-separator\"\n class=\"mx-1 h-6 w-px shrink-0 bg-border\"\n role=\"separator\"\n aria-orientation=\"vertical\"\n ></span>\n }\n @case ('spacer') {\n <span data-slot=\"editor-spacer\" class=\"min-w-2 flex-1\"></span>\n }\n @case ('button') {\n <button\n type=\"button\"\n data-slot=\"editor-button\"\n [class]=\"buttonClasses\"\n [disabled]=\"disabled()\"\n [attr.aria-label]=\"part.ariaLabel\"\n [attr.title]=\"part.ariaLabel\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"execute(part.command, $event)\"\n >\n @if (part.command === 'undo') {\n <svg\n aria-hidden=\"true\"\n class=\"size-4\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.75\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n >\n <path d=\"M9 14 4 9l5-5\" />\n <path d=\"M4 9h10a6 6 0 0 1 0 12h-2\" />\n </svg>\n } @else if (part.command === 'redo') {\n <svg\n aria-hidden=\"true\"\n class=\"size-4\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.75\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n >\n <path d=\"m15 14 5-5-5-5\" />\n <path d=\"M20 9H10a6 6 0 0 0 0 12h2\" />\n </svg>\n } @else {\n <span aria-hidden=\"true\">{{ part.label }}</span>\n }\n </button>\n }\n }\n}\n<ng-content />\n" }]
|
|
201
|
+
}], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], disabledInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
202
|
+
class EditorButtonComponent {
|
|
203
|
+
editor = inject(EditorComponent, { optional: true });
|
|
204
|
+
command = input(null, /* @ts-ignore */
|
|
205
|
+
...(ngDevMode ? [{ debugName: "command" }] : /* istanbul ignore next */ []));
|
|
206
|
+
pressed = input(null, /* @ts-ignore */
|
|
207
|
+
...(ngDevMode ? [{ debugName: "pressed" }] : /* istanbul ignore next */ []));
|
|
208
|
+
disabledInput = input(false, { ...(ngDevMode ? { debugName: "disabledInput" } : /* istanbul ignore next */ {}), alias: 'disabled', transform: booleanAttribute });
|
|
209
|
+
tooltip = input('', /* @ts-ignore */
|
|
210
|
+
...(ngDevMode ? [{ debugName: "tooltip" }] : /* istanbul ignore next */ []));
|
|
211
|
+
class = input('', /* @ts-ignore */
|
|
212
|
+
...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
213
|
+
disabled = computed(() => this.disabledInput() || this.editor?.disabled() === true, /* @ts-ignore */
|
|
214
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
215
|
+
classes = computed(() => cn(EDITOR_TOOL_BUTTON_BASE, this.class()), /* @ts-ignore */
|
|
216
|
+
...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
217
|
+
handleClick(event) {
|
|
218
|
+
const command = this.command();
|
|
219
|
+
if (!command) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
this.editor?.execute(command, 'toolbar', event);
|
|
223
|
+
}
|
|
224
|
+
preserveSelection = preserveEditorSelection;
|
|
225
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: EditorButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
226
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.4", type: EditorButtonComponent, isStandalone: true, selector: "button[EditorButton]", inputs: { command: { classPropertyName: "command", publicName: "command", isSignal: true, isRequired: false, transformFunction: null }, pressed: { classPropertyName: "pressed", publicName: "pressed", isSignal: true, isRequired: false, transformFunction: null }, disabledInput: { classPropertyName: "disabledInput", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, tooltip: { classPropertyName: "tooltip", publicName: "tooltip", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "type": "button" }, listeners: { "mousedown": "preserveSelection($event)", "click": "handleClick($event)" }, properties: { "class": "classes()", "attr.data-slot": "\"editor-button\"", "attr.title": "tooltip() || null", "attr.aria-pressed": "pressed() === null ? null : pressed()", "disabled": "disabled() || null" } }, ngImport: i0, template: `<ng-content />`, isInline: true });
|
|
227
|
+
}
|
|
228
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: EditorButtonComponent, decorators: [{
|
|
229
|
+
type: Component,
|
|
230
|
+
args: [{
|
|
231
|
+
selector: 'button[EditorButton]',
|
|
232
|
+
host: {
|
|
233
|
+
'[class]': 'classes()',
|
|
234
|
+
'[attr.data-slot]': '"editor-button"',
|
|
235
|
+
'[attr.title]': 'tooltip() || null',
|
|
236
|
+
'[attr.aria-pressed]': 'pressed() === null ? null : pressed()',
|
|
237
|
+
'[disabled]': 'disabled() || null',
|
|
238
|
+
type: 'button',
|
|
239
|
+
'(mousedown)': 'preserveSelection($event)',
|
|
240
|
+
'(click)': 'handleClick($event)',
|
|
241
|
+
},
|
|
242
|
+
template: `<ng-content />`,
|
|
243
|
+
}]
|
|
244
|
+
}], propDecorators: { command: [{ type: i0.Input, args: [{ isSignal: true, alias: "command", required: false }] }], pressed: [{ type: i0.Input, args: [{ isSignal: true, alias: "pressed", required: false }] }], disabledInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], tooltip: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltip", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
245
|
+
class EditorSeparatorComponent {
|
|
246
|
+
class = input('', /* @ts-ignore */
|
|
247
|
+
...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
248
|
+
classes = computed(() => cn('mx-1 h-6 w-px shrink-0 bg-border', this.class()), /* @ts-ignore */
|
|
249
|
+
...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
250
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: EditorSeparatorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
251
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.4", type: EditorSeparatorComponent, isStandalone: true, selector: "EditorSeparator", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "separator", "aria-orientation": "vertical" }, properties: { "class": "classes()", "attr.data-slot": "\"editor-separator\"" } }, ngImport: i0, template: '', isInline: true });
|
|
252
|
+
}
|
|
253
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: EditorSeparatorComponent, decorators: [{
|
|
254
|
+
type: Component,
|
|
255
|
+
args: [{
|
|
256
|
+
selector: 'EditorSeparator',
|
|
257
|
+
host: {
|
|
258
|
+
'[class]': 'classes()',
|
|
259
|
+
'[attr.data-slot]': '"editor-separator"',
|
|
260
|
+
role: 'separator',
|
|
261
|
+
'aria-orientation': 'vertical',
|
|
262
|
+
},
|
|
263
|
+
template: '',
|
|
264
|
+
}]
|
|
265
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
266
|
+
class EditorSpacerComponent {
|
|
267
|
+
class = input('', /* @ts-ignore */
|
|
268
|
+
...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
269
|
+
classes = computed(() => cn('min-w-2 flex-1', this.class()), /* @ts-ignore */
|
|
270
|
+
...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
271
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: EditorSpacerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
272
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.4", type: EditorSpacerComponent, isStandalone: true, selector: "EditorSpacer", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "classes()", "attr.data-slot": "\"editor-spacer\"" } }, ngImport: i0, template: '', isInline: true });
|
|
273
|
+
}
|
|
274
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: EditorSpacerComponent, decorators: [{
|
|
275
|
+
type: Component,
|
|
276
|
+
args: [{
|
|
277
|
+
selector: 'EditorSpacer',
|
|
278
|
+
host: {
|
|
279
|
+
'[class]': 'classes()',
|
|
280
|
+
'[attr.data-slot]': '"editor-spacer"',
|
|
281
|
+
},
|
|
282
|
+
template: '',
|
|
283
|
+
}]
|
|
284
|
+
}], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
285
|
+
class EditorContentComponent {
|
|
286
|
+
el = inject(ElementRef);
|
|
287
|
+
editor = inject(EditorComponent, { optional: true });
|
|
288
|
+
document = inject(DOCUMENT);
|
|
289
|
+
sanitizeHtml = inject(EDITOR_HTML_SANITIZER);
|
|
290
|
+
placeholder = input('Write something...', /* @ts-ignore */
|
|
291
|
+
...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
292
|
+
ariaLabel = input('Rich text editor', { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
293
|
+
disabledInput = input(false, { ...(ngDevMode ? { debugName: "disabledInput" } : /* istanbul ignore next */ {}), alias: 'disabled', transform: booleanAttribute });
|
|
294
|
+
invalidInput = input(false, { ...(ngDevMode ? { debugName: "invalidInput" } : /* istanbul ignore next */ {}), alias: 'aria-invalid', transform: booleanAttribute });
|
|
295
|
+
class = input('', /* @ts-ignore */
|
|
296
|
+
...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
297
|
+
disabledState = signal(false, /* @ts-ignore */
|
|
298
|
+
...(ngDevMode ? [{ debugName: "disabledState" }] : /* istanbul ignore next */ []));
|
|
299
|
+
empty = signal(true, /* @ts-ignore */
|
|
300
|
+
...(ngDevMode ? [{ debugName: "empty" }] : /* istanbul ignore next */ []));
|
|
301
|
+
disabled = computed(() => this.disabledInput() || this.disabledState() || this.editor?.disabled() === true, /* @ts-ignore */
|
|
302
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
303
|
+
invalid = computed(() => this.invalidInput() || this.editor?.invalid() === true, /* @ts-ignore */
|
|
304
|
+
...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
|
|
305
|
+
classes = computed(() => cn(EDITOR_CONTENT_BASE, this.class()), /* @ts-ignore */
|
|
306
|
+
...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
307
|
+
lastKnownValue = '';
|
|
308
|
+
onChange = () => { };
|
|
309
|
+
onTouched = () => { };
|
|
310
|
+
ngAfterViewInit() {
|
|
311
|
+
this.editor?.registerContent(this);
|
|
312
|
+
this.setSanitizedValue(this.el.nativeElement.innerHTML);
|
|
313
|
+
queueMicrotask(() => this.syncEmptyState());
|
|
314
|
+
}
|
|
315
|
+
ngOnDestroy() {
|
|
316
|
+
this.editor?.unregisterContent(this);
|
|
317
|
+
}
|
|
318
|
+
writeValue(value) {
|
|
319
|
+
this.setSanitizedValue(value ?? '');
|
|
320
|
+
queueMicrotask(() => this.syncEmptyState());
|
|
321
|
+
}
|
|
322
|
+
registerOnChange(fn) {
|
|
323
|
+
this.onChange = fn;
|
|
324
|
+
}
|
|
325
|
+
registerOnTouched(fn) {
|
|
326
|
+
this.onTouched = fn;
|
|
327
|
+
}
|
|
328
|
+
setDisabledState(isDisabled) {
|
|
329
|
+
this.disabledState.set(isDisabled);
|
|
330
|
+
}
|
|
331
|
+
execute(command) {
|
|
332
|
+
if (this.disabled()) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
this.el.nativeElement.focus();
|
|
336
|
+
const [name, value] = EDITOR_EXEC_COMMANDS[command];
|
|
337
|
+
this.exec(name, command === 'highlight' ? this.highlightColor() : value);
|
|
338
|
+
this.handleInput();
|
|
339
|
+
}
|
|
340
|
+
focus() {
|
|
341
|
+
this.el.nativeElement.focus();
|
|
342
|
+
}
|
|
343
|
+
handleInput() {
|
|
344
|
+
const element = this.el.nativeElement;
|
|
345
|
+
const unsafeHtml = element.innerHTML;
|
|
346
|
+
const safeHtml = this.sanitizeHtml(unsafeHtml);
|
|
347
|
+
if (safeHtml !== unsafeHtml) {
|
|
348
|
+
element.innerHTML = safeHtml;
|
|
349
|
+
}
|
|
350
|
+
// Read back after assignment: the browser normalizes markup, so the
|
|
351
|
+
// DOM-normalized form is the canonical value emitted to consumers.
|
|
352
|
+
const html = element.innerHTML;
|
|
353
|
+
this.syncEmptyState();
|
|
354
|
+
if (html === this.lastKnownValue) {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
this.lastKnownValue = html;
|
|
358
|
+
this.onChange(html);
|
|
359
|
+
}
|
|
360
|
+
setSanitizedValue(value) {
|
|
361
|
+
this.el.nativeElement.innerHTML = this.sanitizeHtml(value);
|
|
362
|
+
this.lastKnownValue = this.el.nativeElement.innerHTML;
|
|
363
|
+
}
|
|
364
|
+
handleBlur() {
|
|
365
|
+
this.onTouched();
|
|
366
|
+
}
|
|
367
|
+
handleKeydown(event) {
|
|
368
|
+
if (this.disabled()) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
const command = this.shortcutCommand(event);
|
|
372
|
+
if (!command) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
event.preventDefault();
|
|
376
|
+
if (this.editor) {
|
|
377
|
+
this.editor.execute(command, 'shortcut', event);
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
this.execute(command);
|
|
381
|
+
}
|
|
382
|
+
exec(command, value) {
|
|
383
|
+
if (typeof this.document.execCommand !== 'function') {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
this.document.execCommand(command, false, value);
|
|
387
|
+
}
|
|
388
|
+
highlightColor() {
|
|
389
|
+
const highlight = this.document.defaultView
|
|
390
|
+
?.getComputedStyle(this.document.documentElement)
|
|
391
|
+
.getPropertyValue('--editor-highlight')
|
|
392
|
+
.trim();
|
|
393
|
+
return highlight ? `hsl(${highlight})` : 'hsl(48 96% 80%)';
|
|
394
|
+
}
|
|
395
|
+
syncEmptyState() {
|
|
396
|
+
const element = this.el.nativeElement;
|
|
397
|
+
const html = element.innerHTML
|
|
398
|
+
.replace(/<br\s*\/?>/gi, '')
|
|
399
|
+
.replace(/ /g, '')
|
|
400
|
+
.trim();
|
|
401
|
+
const text = element.textContent?.replace(/\u00a0/g, '').trim() ?? '';
|
|
402
|
+
this.empty.set(html.length === 0 && text.length === 0);
|
|
403
|
+
}
|
|
404
|
+
shortcutCommand(event) {
|
|
405
|
+
const modifier = event.metaKey || event.ctrlKey;
|
|
406
|
+
if (!modifier) {
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
const key = event.key.toLowerCase();
|
|
410
|
+
// The digit rows are matched on the PHYSICAL key. `event.key` carries the
|
|
411
|
+
// shifted or option-modified character -- `&`/`*` on a US layout, `/`/`(`
|
|
412
|
+
// on DE/FR, `¡`/`™` for Option+1/2 on macOS -- so it is never the digit.
|
|
413
|
+
const code = event.code;
|
|
414
|
+
if (event.altKey && !event.shiftKey) {
|
|
415
|
+
if (code === 'Digit0') {
|
|
416
|
+
return 'paragraph';
|
|
417
|
+
}
|
|
418
|
+
if (code === 'Digit1') {
|
|
419
|
+
return 'heading-1';
|
|
420
|
+
}
|
|
421
|
+
if (code === 'Digit2') {
|
|
422
|
+
return 'heading-2';
|
|
423
|
+
}
|
|
424
|
+
if (code === 'Digit3') {
|
|
425
|
+
return 'heading-3';
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
if (event.shiftKey && !event.altKey) {
|
|
429
|
+
if (code === 'Digit7') {
|
|
430
|
+
return 'ordered';
|
|
431
|
+
}
|
|
432
|
+
if (code === 'Digit8') {
|
|
433
|
+
return 'bullet';
|
|
434
|
+
}
|
|
435
|
+
switch (key) {
|
|
436
|
+
case 'x':
|
|
437
|
+
return 'strike';
|
|
438
|
+
case 'b':
|
|
439
|
+
return 'blockquote';
|
|
440
|
+
case 'h':
|
|
441
|
+
return 'highlight';
|
|
442
|
+
case 'l':
|
|
443
|
+
return 'align-left';
|
|
444
|
+
case 'e':
|
|
445
|
+
return 'align-center';
|
|
446
|
+
case 'r':
|
|
447
|
+
return 'align-right';
|
|
448
|
+
case 'z':
|
|
449
|
+
return 'redo';
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
if (event.altKey || event.shiftKey) {
|
|
453
|
+
return null;
|
|
454
|
+
}
|
|
455
|
+
switch (key) {
|
|
456
|
+
case 'b':
|
|
457
|
+
return 'bold';
|
|
458
|
+
case 'i':
|
|
459
|
+
return 'italic';
|
|
460
|
+
case 'u':
|
|
461
|
+
return 'underline';
|
|
462
|
+
case 'e':
|
|
463
|
+
return 'code';
|
|
464
|
+
case 'z':
|
|
465
|
+
return 'undo';
|
|
466
|
+
default:
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: EditorContentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
471
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.4", type: EditorContentComponent, isStandalone: true, selector: "EditorContent", inputs: { placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, disabledInput: { classPropertyName: "disabledInput", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, invalidInput: { classPropertyName: "invalidInput", publicName: "aria-invalid", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "input": "handleInput()", "blur": "handleBlur()", "keydown": "handleKeydown($event)" }, properties: { "class": "classes()", "attr.data-slot": "\"editor-content\"", "attr.contenteditable": "disabled() ? \"false\" : \"true\"", "attr.role": "\"textbox\"", "attr.aria-multiline": "\"true\"", "attr.aria-label": "ariaLabel()", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-invalid": "invalid() ? \"true\" : null", "attr.data-disabled": "disabled() ? \"true\" : null", "attr.data-empty": "empty() ? \"true\" : null", "attr.data-placeholder": "placeholder()", "attr.tabindex": "disabled() ? null : \"0\"" } }, providers: [
|
|
472
|
+
{
|
|
473
|
+
provide: NG_VALUE_ACCESSOR,
|
|
474
|
+
useExisting: forwardRef(() => EditorContentComponent),
|
|
475
|
+
multi: true,
|
|
476
|
+
},
|
|
477
|
+
], ngImport: i0, template: `<ng-content />`, isInline: true });
|
|
478
|
+
}
|
|
479
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: EditorContentComponent, decorators: [{
|
|
480
|
+
type: Component,
|
|
481
|
+
args: [{
|
|
482
|
+
selector: 'EditorContent',
|
|
483
|
+
providers: [
|
|
484
|
+
{
|
|
485
|
+
provide: NG_VALUE_ACCESSOR,
|
|
486
|
+
useExisting: forwardRef(() => EditorContentComponent),
|
|
487
|
+
multi: true,
|
|
488
|
+
},
|
|
489
|
+
],
|
|
490
|
+
host: {
|
|
491
|
+
'[class]': 'classes()',
|
|
492
|
+
'[attr.data-slot]': '"editor-content"',
|
|
493
|
+
'[attr.contenteditable]': 'disabled() ? "false" : "true"',
|
|
494
|
+
'[attr.role]': '"textbox"',
|
|
495
|
+
'[attr.aria-multiline]': '"true"',
|
|
496
|
+
'[attr.aria-label]': 'ariaLabel()',
|
|
497
|
+
'[attr.aria-disabled]': 'disabled() ? "true" : null',
|
|
498
|
+
'[attr.aria-invalid]': 'invalid() ? "true" : null',
|
|
499
|
+
'[attr.data-disabled]': 'disabled() ? "true" : null',
|
|
500
|
+
'[attr.data-empty]': 'empty() ? "true" : null',
|
|
501
|
+
'[attr.data-placeholder]': 'placeholder()',
|
|
502
|
+
'[attr.tabindex]': 'disabled() ? null : "0"',
|
|
503
|
+
'(input)': 'handleInput()',
|
|
504
|
+
'(blur)': 'handleBlur()',
|
|
505
|
+
'(keydown)': 'handleKeydown($event)',
|
|
506
|
+
},
|
|
507
|
+
template: `<ng-content />`,
|
|
508
|
+
}]
|
|
509
|
+
}], propDecorators: { placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], disabledInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], invalidInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-invalid", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
4
510
|
|
|
5
511
|
/**
|
|
6
512
|
* Generated bundle index. Do not edit.
|
|
7
|
-
*/
|
|
513
|
+
*/
|
|
514
|
+
|
|
515
|
+
export { EDITOR_HTML_SANITIZER, EditorButtonComponent, EditorComponent, EditorContentComponent, EditorSeparatorComponent, EditorSpacerComponent, EditorToolbarComponent };
|