From b846b28802cb3f901c4e3b815f29427eed6d0209 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Wed, 23 Aug 2023 11:20:52 +0200 Subject: [PATCH] Reduced css and js which was not used --- Moonlight/Moonlight.csproj | 97 + Moonlight/Pages/_Layout.cshtml | 5 +- .../Shared/Components/Partials/Navbar.razor | 33 + .../Components/Partials/PageHeader.razor | 1 + .../Shared/Components/Partials/Sidebar.razor | 221 +- .../Components/Partials/SidebarMenu.razor | 216 - Moonlight/Shared/Layouts/DefaultLayout.razor | 307 + Moonlight/Shared/Layouts/MainLayout.razor | 210 +- Moonlight/wwwroot/assets/js/scripts.bundle.js | 7841 -- Moonlight/wwwroot/assets/js/theme.js | 14 - Moonlight/wwwroot/assets/js/widgets.bundle.js | 17949 ---- .../ckeditor/ckeditor-balloon-block.bundle.js | 7 - .../ckeditor/ckeditor-balloon.bundle.js | 7 - .../ckeditor/ckeditor-classic.bundle.js | 7 - .../ckeditor/ckeditor-document.bundle.js | 7 - .../custom/ckeditor/ckeditor-inline.bundle.js | 7 - .../custom/cookiealert/cookiealert.bundle.css | 36 - .../custom/cookiealert/cookiealert.bundle.js | 56 - .../plugins/custom/cropper/cropper.bundle.css | 300 - .../plugins/custom/cropper/cropper.bundle.js | 3631 - .../custom/datatables/datatables.bundle.css | 1576 - .../custom/datatables/datatables.bundle.js | 20068 ---- .../custom/draggable/draggable.bundle.js | 42713 -------- .../custom/flotcharts/flotcharts.bundle.js | 1698 - .../formrepeater/formrepeater.bundle.js | 1007 - .../custom/fslightbox/fslightbox.bundle.js | 1 - .../fullcalendar/fullcalendar.bundle.css | 1323 - .../fullcalendar/fullcalendar.bundle.js | 15010 --- .../plugins/custom/jkanban/jkanban.bundle.css | 147 - .../plugins/custom/jkanban/jkanban.bundle.js | 1 - .../custom/jstree/images/jstree/32px.png | Bin 2387 -> 0 bytes .../custom/jstree/images/jstree/throbber.gif | Bin 1464 -> 0 bytes .../plugins/custom/jstree/jstree.bundle.css | 1327 - .../plugins/custom/jstree/jstree.bundle.js | 8681 -- .../plugins/custom/leaflet/leaflet.bundle.css | 905 - .../plugins/custom/leaflet/leaflet.bundle.js | 24 - .../plugins/custom/prismjs/prismjs.bundle.css | 192 - .../plugins/custom/prismjs/prismjs.bundle.js | 3485 - .../tinymce/skins/content/dark/content.css | 84 - .../skins/content/dark/content.min.css | 73 - .../tinymce/skins/content/default/content.css | 78 - .../skins/content/default/content.min.css | 67 - .../skins/content/document/content.css | 81 - .../skins/content/document/content.min.css | 70 - .../tinymce/skins/content/writer/content.css | 79 - .../skins/content/writer/content.min.css | 68 - .../tinymce/skins/ui/oxide-dark/content.css | 846 - .../skins/ui/oxide-dark/content.inline.css | 857 - .../ui/oxide-dark/content.inline.min.css | 726 - .../skins/ui/oxide-dark/content.min.css | 722 - .../skins/ui/oxide-dark/content.mobile.css | 34 - .../ui/oxide-dark/content.mobile.min.css | 32 - .../tinymce/skins/ui/oxide-dark/skin.css | 3620 - .../tinymce/skins/ui/oxide-dark/skin.min.css | 3485 - .../skins/ui/oxide-dark/skin.mobile.css | 791 - .../skins/ui/oxide-dark/skin.mobile.min.css | 748 - .../skins/ui/oxide-dark/skin.shadowdom.css | 42 - .../ui/oxide-dark/skin.shadowdom.min.css | 40 - .../custom/tinymce/skins/ui/oxide/content.css | 865 - .../tinymce/skins/ui/oxide/content.inline.css | 857 - .../skins/ui/oxide/content.inline.min.css | 726 - .../tinymce/skins/ui/oxide/content.min.css | 734 - .../tinymce/skins/ui/oxide/content.mobile.css | 34 - .../skins/ui/oxide/content.mobile.min.css | 32 - .../custom/tinymce/skins/ui/oxide/skin.css | 3620 - .../tinymce/skins/ui/oxide/skin.min.css | 3485 - .../tinymce/skins/ui/oxide/skin.mobile.css | 791 - .../skins/ui/oxide/skin.mobile.min.css | 748 - .../tinymce/skins/ui/oxide/skin.shadowdom.css | 42 - .../skins/ui/oxide/skin.shadowdom.min.css | 40 - .../plugins/custom/tinymce/tinymce.bundle.js | 83705 ---------------- .../plugins/custom/typedjs/typedjs.bundle.js | 1052 - .../vis-timeline/vis-timeline.bundle.css | 1240 - .../vis-timeline/vis-timeline.bundle.js | 64 - .../fonts/@fortawesome/fa-brands-400.ttf | Bin 181852 -> 0 bytes .../fonts/@fortawesome/fa-brands-400.woff2 | Bin 105536 -> 0 bytes .../fonts/@fortawesome/fa-regular-400.ttf | Bin 60520 -> 0 bytes .../fonts/@fortawesome/fa-regular-400.woff2 | Bin 23940 -> 0 bytes .../fonts/@fortawesome/fa-solid-900.ttf | Bin 388460 -> 0 bytes .../fonts/@fortawesome/fa-solid-900.woff2 | Bin 154228 -> 0 bytes .../fonts/@fortawesome/fa-v4compatibility.ttf | Bin 10556 -> 0 bytes .../@fortawesome/fa-v4compatibility.woff2 | Bin 4960 -> 0 bytes .../bootstrap-icons/bootstrap-icons.woff | Bin 137216 -> 0 bytes .../bootstrap-icons/bootstrap-icons.woff2 | Bin 102380 -> 0 bytes .../global/fonts/fonticon/fonticon.css | 235 - .../global/fonts/fonticon/fonticon.eot | Bin 23872 -> 0 bytes .../global/fonts/fonticon/fonticon.svg | 225 - .../global/fonts/fonticon/fonticon.ttf | Bin 23704 -> 0 bytes .../global/fonts/fonticon/fonticon.woff | Bin 13260 -> 0 bytes .../global/fonts/fonticon/fonticon.woff2 | Bin 11244 -> 0 bytes .../fonts/line-awesome/la-brands-400.eot | Bin 156260 -> 0 bytes .../fonts/line-awesome/la-brands-400.svg | 1313 - .../fonts/line-awesome/la-brands-400.ttf | Bin 156072 -> 0 bytes .../fonts/line-awesome/la-brands-400.woff | Bin 98673 -> 0 bytes .../fonts/line-awesome/la-brands-400.woff2 | Bin 84772 -> 0 bytes .../fonts/line-awesome/la-regular-400.eot | Bin 33916 -> 0 bytes .../fonts/line-awesome/la-regular-400.svg | 467 - .../fonts/line-awesome/la-regular-400.ttf | Bin 33724 -> 0 bytes .../fonts/line-awesome/la-regular-400.woff | Bin 15489 -> 0 bytes .../fonts/line-awesome/la-regular-400.woff2 | Bin 12900 -> 0 bytes .../fonts/line-awesome/la-solid-900.eot | Bin 226312 -> 0 bytes .../fonts/line-awesome/la-solid-900.svg | 2894 - .../fonts/line-awesome/la-solid-900.ttf | Bin 226128 -> 0 bytes .../fonts/line-awesome/la-solid-900.woff | Bin 125421 -> 0 bytes .../fonts/line-awesome/la-solid-900.woff2 | Bin 96752 -> 0 bytes .../assets/plugins/global/plugins.bundle.css | 34646 ------- .../assets/plugins/global/plugins.bundle.js | 71787 ------------- .../global/sourcemaps/tiny-slider.css.map | 1 - 108 files changed, 743 insertions(+), 350513 deletions(-) create mode 100644 Moonlight/Shared/Layouts/DefaultLayout.razor delete mode 100644 Moonlight/wwwroot/assets/js/scripts.bundle.js delete mode 100644 Moonlight/wwwroot/assets/js/theme.js delete mode 100644 Moonlight/wwwroot/assets/js/widgets.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/ckeditor/ckeditor-balloon-block.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/ckeditor/ckeditor-balloon.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/ckeditor/ckeditor-classic.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/ckeditor/ckeditor-document.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/ckeditor/ckeditor-inline.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/cookiealert/cookiealert.bundle.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/cookiealert/cookiealert.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/cropper/cropper.bundle.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/cropper/cropper.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/datatables/datatables.bundle.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/datatables/datatables.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/draggable/draggable.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/flotcharts/flotcharts.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/formrepeater/formrepeater.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/fslightbox/fslightbox.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/fullcalendar/fullcalendar.bundle.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/fullcalendar/fullcalendar.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/jkanban/jkanban.bundle.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/jkanban/jkanban.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/jstree/images/jstree/32px.png delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/jstree/images/jstree/throbber.gif delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/jstree/jstree.bundle.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/jstree/jstree.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/leaflet/leaflet.bundle.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/leaflet/leaflet.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/prismjs/prismjs.bundle.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/prismjs/prismjs.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/content/dark/content.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/content/dark/content.min.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/content/default/content.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/content/default/content.min.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/content/document/content.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/content/document/content.min.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/content/writer/content.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/content/writer/content.min.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide-dark/content.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide-dark/content.inline.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide-dark/content.inline.min.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide-dark/content.min.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide-dark/content.mobile.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide-dark/content.mobile.min.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide-dark/skin.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide-dark/skin.min.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide-dark/skin.mobile.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide-dark/skin.mobile.min.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide-dark/skin.shadowdom.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide/content.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide/content.inline.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide/content.inline.min.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide/content.min.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide/content.mobile.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide/content.mobile.min.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide/skin.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide/skin.min.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide/skin.mobile.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide/skin.mobile.min.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide/skin.shadowdom.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/skins/ui/oxide/skin.shadowdom.min.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/tinymce/tinymce.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/typedjs/typedjs.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/vis-timeline/vis-timeline.bundle.css delete mode 100644 Moonlight/wwwroot/assets/plugins/custom/vis-timeline/vis-timeline.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/@fortawesome/fa-brands-400.ttf delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/@fortawesome/fa-brands-400.woff2 delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/@fortawesome/fa-regular-400.ttf delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/@fortawesome/fa-regular-400.woff2 delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/@fortawesome/fa-solid-900.ttf delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/@fortawesome/fa-solid-900.woff2 delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/@fortawesome/fa-v4compatibility.ttf delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/@fortawesome/fa-v4compatibility.woff2 delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/bootstrap-icons/bootstrap-icons.woff delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/bootstrap-icons/bootstrap-icons.woff2 delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/fonticon/fonticon.css delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/fonticon/fonticon.eot delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/fonticon/fonticon.svg delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/fonticon/fonticon.ttf delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/fonticon/fonticon.woff delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/fonticon/fonticon.woff2 delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/line-awesome/la-brands-400.eot delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/line-awesome/la-brands-400.svg delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/line-awesome/la-brands-400.ttf delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/line-awesome/la-brands-400.woff delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/line-awesome/la-brands-400.woff2 delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/line-awesome/la-regular-400.eot delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/line-awesome/la-regular-400.svg delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/line-awesome/la-regular-400.ttf delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/line-awesome/la-regular-400.woff delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/line-awesome/la-regular-400.woff2 delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/line-awesome/la-solid-900.eot delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/line-awesome/la-solid-900.svg delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/line-awesome/la-solid-900.ttf delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/line-awesome/la-solid-900.woff delete mode 100644 Moonlight/wwwroot/assets/plugins/global/fonts/line-awesome/la-solid-900.woff2 delete mode 100644 Moonlight/wwwroot/assets/plugins/global/plugins.bundle.css delete mode 100644 Moonlight/wwwroot/assets/plugins/global/plugins.bundle.js delete mode 100644 Moonlight/wwwroot/assets/plugins/global/sourcemaps/tiny-slider.css.map diff --git a/Moonlight/Moonlight.csproj b/Moonlight/Moonlight.csproj index 32af48e2..7055763d 100644 --- a/Moonlight/Moonlight.csproj +++ b/Moonlight/Moonlight.csproj @@ -84,6 +84,103 @@ <_ContentIncludedByDefault Remove="Shared\Components\AuditLogEntrys\AuditLogEntryChangePowerState.razor" /> <_ContentIncludedByDefault Remove="Shared\Components\AuditLogEntrys\AuditLogEntryLogin.razor" /> <_ContentIncludedByDefault Remove="Shared\Components\AuditLogEntrys\AuditLogEntryRegister.razor" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\ckeditor\ckeditor-balloon-block.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\ckeditor\ckeditor-balloon.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\ckeditor\ckeditor-classic.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\ckeditor\ckeditor-document.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\ckeditor\ckeditor-inline.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\cookiealert\cookiealert.bundle.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\cookiealert\cookiealert.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\cropper\cropper.bundle.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\cropper\cropper.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\datatables\datatables.bundle.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\datatables\datatables.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\draggable\draggable.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\flotcharts\flotcharts.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\formrepeater\formrepeater.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\fslightbox\fslightbox.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\fullcalendar\fullcalendar.bundle.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\fullcalendar\fullcalendar.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\jkanban\jkanban.bundle.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\jkanban\jkanban.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\jstree\images\jstree\32px.png" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\jstree\images\jstree\throbber.gif" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\jstree\jstree.bundle.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\jstree\jstree.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\leaflet\leaflet.bundle.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\leaflet\leaflet.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\prismjs\prismjs.bundle.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\prismjs\prismjs.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\content\dark\content.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\content\dark\content.min.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\content\default\content.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\content\default\content.min.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\content\document\content.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\content\document\content.min.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\content\writer\content.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\content\writer\content.min.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\content.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\content.inline.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\content.inline.min.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\content.min.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\content.mobile.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\content.mobile.min.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\skin.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\skin.min.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\skin.mobile.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\skin.mobile.min.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\skin.shadowdom.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\skin.shadowdom.min.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\content.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\content.inline.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\content.inline.min.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\content.min.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\content.mobile.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\content.mobile.min.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\skin.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\skin.min.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\skin.mobile.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\skin.mobile.min.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\skin.shadowdom.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\skin.shadowdom.min.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\tinymce.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\typedjs\typedjs.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\vis-timeline\vis-timeline.bundle.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\vis-timeline\vis-timeline.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\@fortawesome\fa-brands-400.ttf" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\@fortawesome\fa-brands-400.woff2" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\@fortawesome\fa-regular-400.ttf" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\@fortawesome\fa-regular-400.woff2" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\@fortawesome\fa-solid-900.ttf" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\@fortawesome\fa-solid-900.woff2" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\@fortawesome\fa-v4compatibility.ttf" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\@fortawesome\fa-v4compatibility.woff2" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\bootstrap-icons\bootstrap-icons.woff" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\bootstrap-icons\bootstrap-icons.woff2" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\fonticon\fonticon.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\fonticon\fonticon.eot" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\fonticon\fonticon.svg" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\fonticon\fonticon.ttf" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\fonticon\fonticon.woff" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\fonticon\fonticon.woff2" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-brands-400.eot" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-brands-400.svg" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-brands-400.ttf" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-brands-400.woff" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-brands-400.woff2" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-regular-400.eot" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-regular-400.svg" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-regular-400.ttf" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-regular-400.woff" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-regular-400.woff2" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-solid-900.eot" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-solid-900.svg" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-solid-900.ttf" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-solid-900.woff" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-solid-900.woff2" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\plugins.bundle.css" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\plugins.bundle.js" /> + <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\sourcemaps\tiny-slider.css.map" /> diff --git a/Moonlight/Pages/_Layout.cshtml b/Moonlight/Pages/_Layout.cshtml index bc6c6044..f60fc1e6 100644 --- a/Moonlight/Pages/_Layout.cshtml +++ b/Moonlight/Pages/_Layout.cshtml @@ -96,7 +96,9 @@ - + + + @@ -113,7 +115,6 @@ - '; - }; - var dataToHtml = function (editor, dataIn) { - var data = global$8.extend({}, dataIn); - if (!data.source) { - global$8.extend(data, htmlToData(getScripts(editor), data.embed)); - if (!data.source) { - return ''; - } - } - if (!data.altsource) { - data.altsource = ''; - } - if (!data.poster) { - data.poster = ''; - } - data.source = editor.convertURL(data.source, 'source'); - data.altsource = editor.convertURL(data.altsource, 'source'); - data.sourcemime = guess(data.source); - data.altsourcemime = guess(data.altsource); - data.poster = editor.convertURL(data.poster, 'poster'); - var pattern = matchPattern(data.source); - if (pattern) { - data.source = pattern.url; - data.type = pattern.type; - data.allowfullscreen = pattern.allowFullscreen; - data.width = data.width || String(pattern.w); - data.height = data.height || String(pattern.h); - } - if (data.embed) { - return updateHtml(data.embed, data, true); - } else { - var videoScript = getVideoScriptMatch(getScripts(editor), data.source); - if (videoScript) { - data.type = 'script'; - data.width = String(videoScript.width); - data.height = String(videoScript.height); - } - var audioTemplateCallback = getAudioTemplateCallback(editor); - var videoTemplateCallback = getVideoTemplateCallback(editor); - data.width = data.width || '300'; - data.height = data.height || '150'; - global$8.each(data, function (value, key) { - data[key] = editor.dom.encode('' + value); - }); - if (data.type === 'iframe') { - return getIframeHtml(data); - } else if (data.sourcemime === 'application/x-shockwave-flash') { - return getFlashHtml(data); - } else if (data.sourcemime.indexOf('audio') !== -1) { - return getAudioHtml(data, audioTemplateCallback); - } else if (data.type === 'script') { - return getScriptHtml(data); - } else { - return getVideoHtml(data, videoTemplateCallback); - } - } - }; - - var isMediaElement = function (element) { - return element.hasAttribute('data-mce-object') || element.hasAttribute('data-ephox-embed-iri'); - }; - var setup$2 = function (editor) { - editor.on('click keyup touchend', function () { - var selectedNode = editor.selection.getNode(); - if (selectedNode && editor.dom.hasClass(selectedNode, 'mce-preview-object')) { - if (editor.dom.getAttrib(selectedNode, 'data-mce-selected')) { - selectedNode.setAttribute('data-mce-selected', '2'); - } - } - }); - editor.on('ObjectSelected', function (e) { - var objectType = e.target.getAttribute('data-mce-object'); - if (objectType === 'script') { - e.preventDefault(); - } - }); - editor.on('ObjectResized', function (e) { - var target = e.target; - if (target.getAttribute('data-mce-object')) { - var html = target.getAttribute('data-mce-html'); - if (html) { - html = unescape(html); - target.setAttribute('data-mce-html', escape(updateHtml(html, { - width: String(e.width), - height: String(e.height) - }))); - } - } - }); - }; - - var global$3 = tinymce.util.Tools.resolve('tinymce.util.Promise'); - - var cache = {}; - var embedPromise = function (data, dataToHtml, handler) { - return new global$3(function (res, rej) { - var wrappedResolve = function (response) { - if (response.html) { - cache[data.source] = response; - } - return res({ - url: data.source, - html: response.html ? response.html : dataToHtml(data) - }); - }; - if (cache[data.source]) { - wrappedResolve(cache[data.source]); - } else { - handler({ url: data.source }, wrappedResolve, rej); - } - }); - }; - var defaultPromise = function (data, dataToHtml) { - return global$3.resolve({ - html: dataToHtml(data), - url: data.source - }); - }; - var loadedData = function (editor) { - return function (data) { - return dataToHtml(editor, data); - }; - }; - var getEmbedHtml = function (editor, data) { - var embedHandler = getUrlResolver(editor); - return embedHandler ? embedPromise(data, loadedData(editor), embedHandler) : defaultPromise(data, loadedData(editor)); - }; - var isCached = function (url) { - return has(cache, url); - }; - - var extractMeta = function (sourceInput, data) { - return get$1(data, sourceInput).bind(function (mainData) { - return get$1(mainData, 'meta'); - }); - }; - var getValue = function (data, metaData, sourceInput) { - return function (prop) { - var _a; - var getFromData = function () { - return get$1(data, prop); - }; - var getFromMetaData = function () { - return get$1(metaData, prop); - }; - var getNonEmptyValue = function (c) { - return get$1(c, 'value').bind(function (v) { - return v.length > 0 ? Optional.some(v) : Optional.none(); - }); - }; - var getFromValueFirst = function () { - return getFromData().bind(function (child) { - return isObject(child) ? getNonEmptyValue(child).orThunk(getFromMetaData) : getFromMetaData().orThunk(function () { - return Optional.from(child); - }); - }); - }; - var getFromMetaFirst = function () { - return getFromMetaData().orThunk(function () { - return getFromData().bind(function (child) { - return isObject(child) ? getNonEmptyValue(child) : Optional.from(child); - }); - }); - }; - return _a = {}, _a[prop] = (prop === sourceInput ? getFromValueFirst() : getFromMetaFirst()).getOr(''), _a; - }; - }; - var getDimensions = function (data, metaData) { - var dimensions = {}; - get$1(data, 'dimensions').each(function (dims) { - each$1([ - 'width', - 'height' - ], function (prop) { - get$1(metaData, prop).orThunk(function () { - return get$1(dims, prop); - }).each(function (value) { - return dimensions[prop] = value; - }); - }); - }); - return dimensions; - }; - var unwrap = function (data, sourceInput) { - var metaData = sourceInput ? extractMeta(sourceInput, data).getOr({}) : {}; - var get = getValue(data, metaData, sourceInput); - return __assign(__assign(__assign(__assign(__assign({}, get('source')), get('altsource')), get('poster')), get('embed')), getDimensions(data, metaData)); - }; - var wrap = function (data) { - var wrapped = __assign(__assign({}, data), { - source: { value: get$1(data, 'source').getOr('') }, - altsource: { value: get$1(data, 'altsource').getOr('') }, - poster: { value: get$1(data, 'poster').getOr('') } - }); - each$1([ - 'width', - 'height' - ], function (prop) { - get$1(data, prop).each(function (value) { - var dimensions = wrapped.dimensions || {}; - dimensions[prop] = value; - wrapped.dimensions = dimensions; - }); - }); - return wrapped; - }; - var handleError = function (editor) { - return function (error) { - var errorMessage = error && error.msg ? 'Media embed handler error: ' + error.msg : 'Media embed handler threw unknown error.'; - editor.notificationManager.open({ - type: 'error', - text: errorMessage - }); - }; - }; - var snippetToData = function (editor, embedSnippet) { - return htmlToData(getScripts(editor), embedSnippet); - }; - var getEditorData = function (editor) { - var element = editor.selection.getNode(); - var snippet = isMediaElement(element) ? editor.serializer.serialize(element, { selection: true }) : ''; - return __assign({ embed: snippet }, htmlToData(getScripts(editor), snippet)); - }; - var addEmbedHtml = function (api, editor) { - return function (response) { - if (isString(response.url) && response.url.trim().length > 0) { - var html = response.html; - var snippetData = snippetToData(editor, html); - var nuData = __assign(__assign({}, snippetData), { - source: response.url, - embed: html - }); - api.setData(wrap(nuData)); - } - }; - }; - var selectPlaceholder = function (editor, beforeObjects) { - var afterObjects = editor.dom.select('*[data-mce-object]'); - for (var i = 0; i < beforeObjects.length; i++) { - for (var y = afterObjects.length - 1; y >= 0; y--) { - if (beforeObjects[i] === afterObjects[y]) { - afterObjects.splice(y, 1); - } - } - } - editor.selection.select(afterObjects[0]); - }; - var handleInsert = function (editor, html) { - var beforeObjects = editor.dom.select('*[data-mce-object]'); - editor.insertContent(html); - selectPlaceholder(editor, beforeObjects); - editor.nodeChanged(); - }; - var submitForm = function (prevData, newData, editor) { - newData.embed = updateHtml(newData.embed, newData); - if (newData.embed && (prevData.source === newData.source || isCached(newData.source))) { - handleInsert(editor, newData.embed); - } else { - getEmbedHtml(editor, newData).then(function (response) { - handleInsert(editor, response.html); - }).catch(handleError(editor)); - } - }; - var showDialog = function (editor) { - var editorData = getEditorData(editor); - var currentData = Cell(editorData); - var initialData = wrap(editorData); - var handleSource = function (prevData, api) { - var serviceData = unwrap(api.getData(), 'source'); - if (prevData.source !== serviceData.source) { - addEmbedHtml(win, editor)({ - url: serviceData.source, - html: '' - }); - getEmbedHtml(editor, serviceData).then(addEmbedHtml(win, editor)).catch(handleError(editor)); - } - }; - var handleEmbed = function (api) { - var data = unwrap(api.getData()); - var dataFromEmbed = snippetToData(editor, data.embed); - api.setData(wrap(dataFromEmbed)); - }; - var handleUpdate = function (api, sourceInput) { - var data = unwrap(api.getData(), sourceInput); - var embed = dataToHtml(editor, data); - api.setData(wrap(__assign(__assign({}, data), { embed: embed }))); - }; - var mediaInput = [{ - name: 'source', - type: 'urlinput', - filetype: 'media', - label: 'Source' - }]; - var sizeInput = !hasDimensions(editor) ? [] : [{ - type: 'sizeinput', - name: 'dimensions', - label: 'Constrain proportions', - constrain: true - }]; - var generalTab = { - title: 'General', - name: 'general', - items: flatten([ - mediaInput, - sizeInput - ]) - }; - var embedTextarea = { - type: 'textarea', - name: 'embed', - label: 'Paste your embed code below:' - }; - var embedTab = { - title: 'Embed', - items: [embedTextarea] - }; - var advancedFormItems = []; - if (hasAltSource(editor)) { - advancedFormItems.push({ - name: 'altsource', - type: 'urlinput', - filetype: 'media', - label: 'Alternative source URL' - }); - } - if (hasPoster(editor)) { - advancedFormItems.push({ - name: 'poster', - type: 'urlinput', - filetype: 'image', - label: 'Media poster (Image URL)' - }); - } - var advancedTab = { - title: 'Advanced', - name: 'advanced', - items: advancedFormItems - }; - var tabs = [ - generalTab, - embedTab - ]; - if (advancedFormItems.length > 0) { - tabs.push(advancedTab); - } - var body = { - type: 'tabpanel', - tabs: tabs - }; - var win = editor.windowManager.open({ - title: 'Insert/Edit Media', - size: 'normal', - body: body, - buttons: [ - { - type: 'cancel', - name: 'cancel', - text: 'Cancel' - }, - { - type: 'submit', - name: 'save', - text: 'Save', - primary: true - } - ], - onSubmit: function (api) { - var serviceData = unwrap(api.getData()); - submitForm(currentData.get(), serviceData, editor); - api.close(); - }, - onChange: function (api, detail) { - switch (detail.name) { - case 'source': - handleSource(currentData.get(), api); - break; - case 'embed': - handleEmbed(api); - break; - case 'dimensions': - case 'altsource': - case 'poster': - handleUpdate(api, detail.name); - break; - } - currentData.set(unwrap(api.getData())); - }, - initialData: initialData - }); - }; - - var get = function (editor) { - var showDialog$1 = function () { - showDialog(editor); - }; - return { showDialog: showDialog$1 }; - }; - - var register$1 = function (editor) { - var showDialog$1 = function () { - showDialog(editor); - }; - editor.addCommand('mceMedia', showDialog$1); - }; - - var global$2 = tinymce.util.Tools.resolve('tinymce.html.Node'); - - var global$1 = tinymce.util.Tools.resolve('tinymce.Env'); - - var global = tinymce.util.Tools.resolve('tinymce.html.DomParser'); - - var sanitize = function (editor, html) { - if (shouldFilterHtml(editor) === false) { - return html; - } - var writer = global$4(); - var blocked; - global$6({ - validate: false, - allow_conditional_comments: false, - comment: function (text) { - if (!blocked) { - writer.comment(text); - } - }, - cdata: function (text) { - if (!blocked) { - writer.cdata(text); - } - }, - text: function (text, raw) { - if (!blocked) { - writer.text(text, raw); - } - }, - start: function (name, attrs, empty) { - blocked = true; - if (name === 'script' || name === 'noscript' || name === 'svg') { - return; - } - for (var i = attrs.length - 1; i >= 0; i--) { - var attrName = attrs[i].name; - if (attrName.indexOf('on') === 0) { - delete attrs.map[attrName]; - attrs.splice(i, 1); - } - if (attrName === 'style') { - attrs[i].value = editor.dom.serializeStyle(editor.dom.parseStyle(attrs[i].value), name); - } - } - writer.start(name, attrs, empty); - blocked = false; - }, - end: function (name) { - if (blocked) { - return; - } - writer.end(name); - } - }, global$5({})).parse(html); - return writer.getContent(); - }; - - var isLiveEmbedNode = function (node) { - var name = node.name; - return name === 'iframe' || name === 'video' || name === 'audio'; - }; - var getDimension = function (node, styles, dimension, defaultValue) { - if (defaultValue === void 0) { - defaultValue = null; - } - var value = node.attr(dimension); - if (isNonNullable(value)) { - return value; - } else if (!has(styles, dimension)) { - return defaultValue; - } else { - return null; - } - }; - var setDimensions = function (node, previewNode, styles) { - var useDefaults = previewNode.name === 'img' || node.name === 'video'; - var defaultWidth = useDefaults ? '300' : null; - var fallbackHeight = node.name === 'audio' ? '30' : '150'; - var defaultHeight = useDefaults ? fallbackHeight : null; - previewNode.attr({ - width: getDimension(node, styles, 'width', defaultWidth), - height: getDimension(node, styles, 'height', defaultHeight) - }); - }; - var appendNodeContent = function (editor, nodeName, previewNode, html) { - var newNode = global({ - forced_root_block: false, - validate: false - }, editor.schema).parse(html, { context: nodeName }); - while (newNode.firstChild) { - previewNode.append(newNode.firstChild); - } - }; - var createPlaceholderNode = function (editor, node) { - var name = node.name; - var placeHolder = new global$2('img', 1); - placeHolder.shortEnded = true; - retainAttributesAndInnerHtml(editor, node, placeHolder); - setDimensions(node, placeHolder, {}); - placeHolder.attr({ - 'style': node.attr('style'), - 'src': global$1.transparentSrc, - 'data-mce-object': name, - 'class': 'mce-object mce-object-' + name - }); - return placeHolder; - }; - var createPreviewNode = function (editor, node) { - var name = node.name; - var previewWrapper = new global$2('span', 1); - previewWrapper.attr({ - 'contentEditable': 'false', - 'style': node.attr('style'), - 'data-mce-object': name, - 'class': 'mce-preview-object mce-object-' + name - }); - retainAttributesAndInnerHtml(editor, node, previewWrapper); - var styles = editor.dom.parseStyle(node.attr('style')); - var previewNode = new global$2(name, 1); - setDimensions(node, previewNode, styles); - previewNode.attr({ - src: node.attr('src'), - style: node.attr('style'), - class: node.attr('class') - }); - if (name === 'iframe') { - previewNode.attr({ - allowfullscreen: node.attr('allowfullscreen'), - frameborder: '0' - }); - } else { - var attrs = [ - 'controls', - 'crossorigin', - 'currentTime', - 'loop', - 'muted', - 'poster', - 'preload' - ]; - each$1(attrs, function (attrName) { - previewNode.attr(attrName, node.attr(attrName)); - }); - var sanitizedHtml = previewWrapper.attr('data-mce-html'); - if (isNonNullable(sanitizedHtml)) { - appendNodeContent(editor, name, previewNode, unescape(sanitizedHtml)); - } - } - var shimNode = new global$2('span', 1); - shimNode.attr('class', 'mce-shim'); - previewWrapper.append(previewNode); - previewWrapper.append(shimNode); - return previewWrapper; - }; - var retainAttributesAndInnerHtml = function (editor, sourceNode, targetNode) { - var attribs = sourceNode.attributes; - var ai = attribs.length; - while (ai--) { - var attrName = attribs[ai].name; - var attrValue = attribs[ai].value; - if (attrName !== 'width' && attrName !== 'height' && attrName !== 'style') { - if (attrName === 'data' || attrName === 'src') { - attrValue = editor.convertURL(attrValue, attrName); - } - targetNode.attr('data-mce-p-' + attrName, attrValue); - } - } - var innerHtml = sourceNode.firstChild && sourceNode.firstChild.value; - if (innerHtml) { - targetNode.attr('data-mce-html', escape(sanitize(editor, innerHtml))); - targetNode.firstChild = null; - } - }; - var isPageEmbedWrapper = function (node) { - var nodeClass = node.attr('class'); - return nodeClass && /\btiny-pageembed\b/.test(nodeClass); - }; - var isWithinEmbedWrapper = function (node) { - while (node = node.parent) { - if (node.attr('data-ephox-embed-iri') || isPageEmbedWrapper(node)) { - return true; - } - } - return false; - }; - var placeHolderConverter = function (editor) { - return function (nodes) { - var i = nodes.length; - var node; - var videoScript; - while (i--) { - node = nodes[i]; - if (!node.parent) { - continue; - } - if (node.parent.attr('data-mce-object')) { - continue; - } - if (node.name === 'script') { - videoScript = getVideoScriptMatch(getScripts(editor), node.attr('src')); - if (!videoScript) { - continue; - } - } - if (videoScript) { - if (videoScript.width) { - node.attr('width', videoScript.width.toString()); - } - if (videoScript.height) { - node.attr('height', videoScript.height.toString()); - } - } - if (isLiveEmbedNode(node) && hasLiveEmbeds(editor) && global$1.ceFalse) { - if (!isWithinEmbedWrapper(node)) { - node.replace(createPreviewNode(editor, node)); - } - } else { - if (!isWithinEmbedWrapper(node)) { - node.replace(createPlaceholderNode(editor, node)); - } - } - } - }; - }; - - var setup$1 = function (editor) { - editor.on('preInit', function () { - var specialElements = editor.schema.getSpecialElements(); - global$8.each('video audio iframe object'.split(' '), function (name) { - specialElements[name] = new RegExp(']*>', 'gi'); - }); - var boolAttrs = editor.schema.getBoolAttrs(); - global$8.each('webkitallowfullscreen mozallowfullscreen allowfullscreen'.split(' '), function (name) { - boolAttrs[name] = {}; - }); - editor.parser.addNodeFilter('iframe,video,audio,object,embed,script', placeHolderConverter(editor)); - editor.serializer.addAttributeFilter('data-mce-object', function (nodes, name) { - var i = nodes.length; - var node; - var realElm; - var ai; - var attribs; - var innerHtml; - var innerNode; - var realElmName; - var className; - while (i--) { - node = nodes[i]; - if (!node.parent) { - continue; - } - realElmName = node.attr(name); - realElm = new global$2(realElmName, 1); - if (realElmName !== 'audio' && realElmName !== 'script') { - className = node.attr('class'); - if (className && className.indexOf('mce-preview-object') !== -1) { - realElm.attr({ - width: node.firstChild.attr('width'), - height: node.firstChild.attr('height') - }); - } else { - realElm.attr({ - width: node.attr('width'), - height: node.attr('height') - }); - } - } - realElm.attr({ style: node.attr('style') }); - attribs = node.attributes; - ai = attribs.length; - while (ai--) { - var attrName = attribs[ai].name; - if (attrName.indexOf('data-mce-p-') === 0) { - realElm.attr(attrName.substr(11), attribs[ai].value); - } - } - if (realElmName === 'script') { - realElm.attr('type', 'text/javascript'); - } - innerHtml = node.attr('data-mce-html'); - if (innerHtml) { - innerNode = new global$2('#text', 3); - innerNode.raw = true; - innerNode.value = sanitize(editor, unescape(innerHtml)); - realElm.append(innerNode); - } - node.replace(realElm); - } - }); - }); - editor.on('SetContent', function () { - editor.$('span.mce-preview-object').each(function (index, elm) { - var $elm = editor.$(elm); - if ($elm.find('span.mce-shim').length === 0) { - $elm.append(''); - } - }); - }); - }; - - var setup = function (editor) { - editor.on('ResolveName', function (e) { - var name; - if (e.target.nodeType === 1 && (name = e.target.getAttribute('data-mce-object'))) { - e.name = name; - } - }); - }; - - var register = function (editor) { - var onAction = function () { - return editor.execCommand('mceMedia'); - }; - editor.ui.registry.addToggleButton('media', { - tooltip: 'Insert/edit media', - icon: 'embed', - onAction: onAction, - onSetup: function (buttonApi) { - var selection = editor.selection; - buttonApi.setActive(isMediaElement(selection.getNode())); - return selection.selectorChangedWithUnbind('img[data-mce-object],span[data-mce-object],div[data-ephox-embed-iri]', buttonApi.setActive).unbind; - } - }); - editor.ui.registry.addMenuItem('media', { - icon: 'embed', - text: 'Media...', - onAction: onAction - }); - }; - - function Plugin () { - global$9.add('media', function (editor) { - register$1(editor); - register(editor); - setup(editor); - setup$1(editor); - setup$2(editor); - return get(editor); - }); - } - - Plugin(); - -}()); - -/** - * Copyright (c) Tiny Technologies, Inc. All rights reserved. - * Licensed under the LGPL or a commercial license. - * For LGPL see License.txt in the project root for license information. - * For commercial licenses see https://www.tiny.cloud/ - * - * Version: 5.10.5 (2022-05-25) - */ -(function () { - 'use strict'; - - var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - var getKeyboardSpaces = function (editor) { - var spaces = editor.getParam('nonbreaking_force_tab', 0); - if (typeof spaces === 'boolean') { - return spaces === true ? 3 : 0; - } else { - return spaces; - } - }; - var wrapNbsps = function (editor) { - return editor.getParam('nonbreaking_wrap', true, 'boolean'); - }; - - var stringRepeat = function (string, repeats) { - var str = ''; - for (var index = 0; index < repeats; index++) { - str += string; - } - return str; - }; - var isVisualCharsEnabled = function (editor) { - return editor.plugins.visualchars ? editor.plugins.visualchars.isEnabled() : false; - }; - var insertNbsp = function (editor, times) { - var classes = function () { - return isVisualCharsEnabled(editor) ? 'mce-nbsp-wrap mce-nbsp' : 'mce-nbsp-wrap'; - }; - var nbspSpan = function () { - return '' + stringRepeat(' ', times) + ''; - }; - var shouldWrap = wrapNbsps(editor); - var html = shouldWrap || editor.plugins.visualchars ? nbspSpan() : stringRepeat(' ', times); - editor.undoManager.transact(function () { - return editor.insertContent(html); - }); - }; - - var register$1 = function (editor) { - editor.addCommand('mceNonBreaking', function () { - insertNbsp(editor, 1); - }); - }; - - var global = tinymce.util.Tools.resolve('tinymce.util.VK'); - - var setup = function (editor) { - var spaces = getKeyboardSpaces(editor); - if (spaces > 0) { - editor.on('keydown', function (e) { - if (e.keyCode === global.TAB && !e.isDefaultPrevented()) { - if (e.shiftKey) { - return; - } - e.preventDefault(); - e.stopImmediatePropagation(); - insertNbsp(editor, spaces); - } - }); - } - }; - - var register = function (editor) { - var onAction = function () { - return editor.execCommand('mceNonBreaking'); - }; - editor.ui.registry.addButton('nonbreaking', { - icon: 'non-breaking', - tooltip: 'Nonbreaking space', - onAction: onAction - }); - editor.ui.registry.addMenuItem('nonbreaking', { - icon: 'non-breaking', - text: 'Nonbreaking space', - onAction: onAction - }); - }; - - function Plugin () { - global$1.add('nonbreaking', function (editor) { - register$1(editor); - register(editor); - setup(editor); - }); - } - - Plugin(); - -}()); - -/** - * Copyright (c) Tiny Technologies, Inc. All rights reserved. - * Licensed under the LGPL or a commercial license. - * For LGPL see License.txt in the project root for license information. - * For commercial licenses see https://www.tiny.cloud/ - * - * Version: 5.10.5 (2022-05-25) - */ -(function () { - 'use strict'; - - var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - var global = tinymce.util.Tools.resolve('tinymce.util.Tools'); - - var getNonEditableClass = function (editor) { - return editor.getParam('noneditable_noneditable_class', 'mceNonEditable'); - }; - var getEditableClass = function (editor) { - return editor.getParam('noneditable_editable_class', 'mceEditable'); - }; - var getNonEditableRegExps = function (editor) { - var nonEditableRegExps = editor.getParam('noneditable_regexp', []); - if (nonEditableRegExps && nonEditableRegExps.constructor === RegExp) { - return [nonEditableRegExps]; - } else { - return nonEditableRegExps; - } - }; - - var hasClass = function (checkClassName) { - return function (node) { - return (' ' + node.attr('class') + ' ').indexOf(checkClassName) !== -1; - }; - }; - var replaceMatchWithSpan = function (editor, content, cls) { - return function (match) { - var args = arguments, index = args[args.length - 2]; - var prevChar = index > 0 ? content.charAt(index - 1) : ''; - if (prevChar === '"') { - return match; - } - if (prevChar === '>') { - var findStartTagIndex = content.lastIndexOf('<', index); - if (findStartTagIndex !== -1) { - var tagHtml = content.substring(findStartTagIndex, index); - if (tagHtml.indexOf('contenteditable="false"') !== -1) { - return match; - } - } - } - return '' + editor.dom.encode(typeof args[1] === 'string' ? args[1] : args[0]) + ''; - }; - }; - var convertRegExpsToNonEditable = function (editor, nonEditableRegExps, e) { - var i = nonEditableRegExps.length, content = e.content; - if (e.format === 'raw') { - return; - } - while (i--) { - content = content.replace(nonEditableRegExps[i], replaceMatchWithSpan(editor, content, getNonEditableClass(editor))); - } - e.content = content; - }; - var setup = function (editor) { - var contentEditableAttrName = 'contenteditable'; - var editClass = ' ' + global.trim(getEditableClass(editor)) + ' '; - var nonEditClass = ' ' + global.trim(getNonEditableClass(editor)) + ' '; - var hasEditClass = hasClass(editClass); - var hasNonEditClass = hasClass(nonEditClass); - var nonEditableRegExps = getNonEditableRegExps(editor); - editor.on('PreInit', function () { - if (nonEditableRegExps.length > 0) { - editor.on('BeforeSetContent', function (e) { - convertRegExpsToNonEditable(editor, nonEditableRegExps, e); - }); - } - editor.parser.addAttributeFilter('class', function (nodes) { - var i = nodes.length, node; - while (i--) { - node = nodes[i]; - if (hasEditClass(node)) { - node.attr(contentEditableAttrName, 'true'); - } else if (hasNonEditClass(node)) { - node.attr(contentEditableAttrName, 'false'); - } - } - }); - editor.serializer.addAttributeFilter(contentEditableAttrName, function (nodes) { - var i = nodes.length, node; - while (i--) { - node = nodes[i]; - if (!hasEditClass(node) && !hasNonEditClass(node)) { - continue; - } - if (nonEditableRegExps.length > 0 && node.attr('data-mce-content')) { - node.name = '#text'; - node.type = 3; - node.raw = true; - node.value = node.attr('data-mce-content'); - } else { - node.attr(contentEditableAttrName, null); - } - } - }); - }); - }; - - function Plugin () { - global$1.add('noneditable', function (editor) { - setup(editor); - }); - } - - Plugin(); - -}()); - -/** - * Copyright (c) Tiny Technologies, Inc. All rights reserved. - * Licensed under the LGPL or a commercial license. - * For LGPL see License.txt in the project root for license information. - * For commercial licenses see https://www.tiny.cloud/ - * - * Version: 5.10.5 (2022-05-25) - */ -(function () { - 'use strict'; - - var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - var global = tinymce.util.Tools.resolve('tinymce.Env'); - - var getSeparatorHtml = function (editor) { - return editor.getParam('pagebreak_separator', ''); - }; - var shouldSplitBlock = function (editor) { - return editor.getParam('pagebreak_split_block', false); - }; - - var pageBreakClass = 'mce-pagebreak'; - var getPlaceholderHtml = function (shouldSplitBlock) { - var html = ''; - return shouldSplitBlock ? '

' + html + '

' : html; - }; - var setup$1 = function (editor) { - var separatorHtml = getSeparatorHtml(editor); - var shouldSplitBlock$1 = function () { - return shouldSplitBlock(editor); - }; - var pageBreakSeparatorRegExp = new RegExp(separatorHtml.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function (a) { - return '\\' + a; - }), 'gi'); - editor.on('BeforeSetContent', function (e) { - e.content = e.content.replace(pageBreakSeparatorRegExp, getPlaceholderHtml(shouldSplitBlock$1())); - }); - editor.on('PreInit', function () { - editor.serializer.addNodeFilter('img', function (nodes) { - var i = nodes.length, node, className; - while (i--) { - node = nodes[i]; - className = node.attr('class'); - if (className && className.indexOf(pageBreakClass) !== -1) { - var parentNode = node.parent; - if (editor.schema.getBlockElements()[parentNode.name] && shouldSplitBlock$1()) { - parentNode.type = 3; - parentNode.value = separatorHtml; - parentNode.raw = true; - node.remove(); - continue; - } - node.type = 3; - node.value = separatorHtml; - node.raw = true; - } - } - }); - }); - }; - - var register$1 = function (editor) { - editor.addCommand('mcePageBreak', function () { - editor.insertContent(getPlaceholderHtml(shouldSplitBlock(editor))); - }); - }; - - var setup = function (editor) { - editor.on('ResolveName', function (e) { - if (e.target.nodeName === 'IMG' && editor.dom.hasClass(e.target, pageBreakClass)) { - e.name = 'pagebreak'; - } - }); - }; - - var register = function (editor) { - var onAction = function () { - return editor.execCommand('mcePageBreak'); - }; - editor.ui.registry.addButton('pagebreak', { - icon: 'page-break', - tooltip: 'Page break', - onAction: onAction - }); - editor.ui.registry.addMenuItem('pagebreak', { - text: 'Page break', - icon: 'page-break', - onAction: onAction - }); - }; - - function Plugin () { - global$1.add('pagebreak', function (editor) { - register$1(editor); - register(editor); - setup$1(editor); - setup(editor); - }); - } - - Plugin(); - -}()); - -/** - * Copyright (c) Tiny Technologies, Inc. All rights reserved. - * Licensed under the LGPL or a commercial license. - * For LGPL see License.txt in the project root for license information. - * For commercial licenses see https://www.tiny.cloud/ - * - * Version: 5.10.5 (2022-05-25) - */ -(function () { - 'use strict'; - - var Cell = function (initial) { - var value = initial; - var get = function () { - return value; - }; - var set = function (v) { - value = v; - }; - return { - get: get, - set: set - }; - }; - - var global$b = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - var hasProPlugin = function (editor) { - if (editor.hasPlugin('powerpaste', true)) { - if (typeof window.console !== 'undefined' && window.console.log) { - window.console.log('PowerPaste is incompatible with Paste plugin! Remove \'paste\' from the \'plugins\' option.'); - } - return true; - } else { - return false; - } - }; - - var get = function (clipboard) { - return { clipboard: clipboard }; - }; - - var typeOf = function (x) { - var t = typeof x; - if (x === null) { - return 'null'; - } else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) { - return 'array'; - } else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) { - return 'string'; - } else { - return t; - } - }; - var isType = function (type) { - return function (value) { - return typeOf(value) === type; - }; - }; - var isSimpleType = function (type) { - return function (value) { - return typeof value === type; - }; - }; - var isArray = isType('array'); - var isNullable = function (a) { - return a === null || a === undefined; - }; - var isNonNullable = function (a) { - return !isNullable(a); - }; - var isFunction = isSimpleType('function'); - - var noop = function () { - }; - var constant = function (value) { - return function () { - return value; - }; - }; - var identity = function (x) { - return x; - }; - var never = constant(false); - var always = constant(true); - - var none = function () { - return NONE; - }; - var NONE = function () { - var call = function (thunk) { - return thunk(); - }; - var id = identity; - var me = { - fold: function (n, _s) { - return n(); - }, - isSome: never, - isNone: always, - getOr: id, - getOrThunk: call, - getOrDie: function (msg) { - throw new Error(msg || 'error: getOrDie called on none.'); - }, - getOrNull: constant(null), - getOrUndefined: constant(undefined), - or: id, - orThunk: call, - map: none, - each: noop, - bind: none, - exists: never, - forall: always, - filter: function () { - return none(); - }, - toArray: function () { - return []; - }, - toString: constant('none()') - }; - return me; - }(); - var some = function (a) { - var constant_a = constant(a); - var self = function () { - return me; - }; - var bind = function (f) { - return f(a); - }; - var me = { - fold: function (n, s) { - return s(a); - }, - isSome: always, - isNone: never, - getOr: constant_a, - getOrThunk: constant_a, - getOrDie: constant_a, - getOrNull: constant_a, - getOrUndefined: constant_a, - or: self, - orThunk: self, - map: function (f) { - return some(f(a)); - }, - each: function (f) { - f(a); - }, - bind: bind, - exists: bind, - forall: bind, - filter: function (f) { - return f(a) ? me : NONE; - }, - toArray: function () { - return [a]; - }, - toString: function () { - return 'some(' + a + ')'; - } - }; - return me; - }; - var from$1 = function (value) { - return value === null || value === undefined ? NONE : some(value); - }; - var Optional = { - some: some, - none: none, - from: from$1 - }; - - var nativeSlice = Array.prototype.slice; - var nativePush = Array.prototype.push; - var exists = function (xs, pred) { - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - if (pred(x, i)) { - return true; - } - } - return false; - }; - var map = function (xs, f) { - var len = xs.length; - var r = new Array(len); - for (var i = 0; i < len; i++) { - var x = xs[i]; - r[i] = f(x, i); - } - return r; - }; - var each = function (xs, f) { - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - f(x, i); - } - }; - var filter$1 = function (xs, pred) { - var r = []; - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - if (pred(x, i)) { - r.push(x); - } - } - return r; - }; - var foldl = function (xs, f, acc) { - each(xs, function (x, i) { - acc = f(acc, x, i); - }); - return acc; - }; - var flatten = function (xs) { - var r = []; - for (var i = 0, len = xs.length; i < len; ++i) { - if (!isArray(xs[i])) { - throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs); - } - nativePush.apply(r, xs[i]); - } - return r; - }; - var bind = function (xs, f) { - return flatten(map(xs, f)); - }; - var from = isFunction(Array.from) ? Array.from : function (x) { - return nativeSlice.call(x); - }; - - var __assign = function () { - __assign = Object.assign || function __assign(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) - if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); - }; - - var singleton = function (doRevoke) { - var subject = Cell(Optional.none()); - var revoke = function () { - return subject.get().each(doRevoke); - }; - var clear = function () { - revoke(); - subject.set(Optional.none()); - }; - var isSet = function () { - return subject.get().isSome(); - }; - var get = function () { - return subject.get(); - }; - var set = function (s) { - revoke(); - subject.set(Optional.some(s)); - }; - return { - clear: clear, - isSet: isSet, - get: get, - set: set - }; - }; - var value = function () { - var subject = singleton(noop); - var on = function (f) { - return subject.get().each(f); - }; - return __assign(__assign({}, subject), { on: on }); - }; - - var checkRange = function (str, substr, start) { - return substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr; - }; - var startsWith = function (str, prefix) { - return checkRange(str, prefix, 0); - }; - var endsWith = function (str, suffix) { - return checkRange(str, suffix, str.length - suffix.length); - }; - var repeat = function (s, count) { - return count <= 0 ? '' : new Array(count + 1).join(s); - }; - - var global$a = tinymce.util.Tools.resolve('tinymce.Env'); - - var global$9 = tinymce.util.Tools.resolve('tinymce.util.Delay'); - - var global$8 = tinymce.util.Tools.resolve('tinymce.util.Promise'); - - var global$7 = tinymce.util.Tools.resolve('tinymce.util.VK'); - - var firePastePreProcess = function (editor, html, internal, isWordHtml) { - return editor.fire('PastePreProcess', { - content: html, - internal: internal, - wordContent: isWordHtml - }); - }; - var firePastePostProcess = function (editor, node, internal, isWordHtml) { - return editor.fire('PastePostProcess', { - node: node, - internal: internal, - wordContent: isWordHtml - }); - }; - var firePastePlainTextToggle = function (editor, state) { - return editor.fire('PastePlainTextToggle', { state: state }); - }; - var firePaste = function (editor, ieFake) { - return editor.fire('paste', { ieFake: ieFake }); - }; - - var global$6 = tinymce.util.Tools.resolve('tinymce.util.Tools'); - - var shouldBlockDrop = function (editor) { - return editor.getParam('paste_block_drop', false); - }; - var shouldPasteDataImages = function (editor) { - return editor.getParam('paste_data_images', false); - }; - var shouldFilterDrop = function (editor) { - return editor.getParam('paste_filter_drop', true); - }; - var getPreProcess = function (editor) { - return editor.getParam('paste_preprocess'); - }; - var getPostProcess = function (editor) { - return editor.getParam('paste_postprocess'); - }; - var getWebkitStyles = function (editor) { - return editor.getParam('paste_webkit_styles'); - }; - var shouldRemoveWebKitStyles = function (editor) { - return editor.getParam('paste_remove_styles_if_webkit', true); - }; - var shouldMergeFormats = function (editor) { - return editor.getParam('paste_merge_formats', true); - }; - var isSmartPasteEnabled = function (editor) { - return editor.getParam('smart_paste', true); - }; - var isPasteAsTextEnabled = function (editor) { - return editor.getParam('paste_as_text', false); - }; - var getRetainStyleProps = function (editor) { - return editor.getParam('paste_retain_style_properties'); - }; - var getWordValidElements = function (editor) { - var defaultValidElements = '-strong/b,-em/i,-u,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,' + '-p/div,-a[href|name],sub,sup,strike,br,del,table[width],tr,' + 'td[colspan|rowspan|width],th[colspan|rowspan|width],thead,tfoot,tbody'; - return editor.getParam('paste_word_valid_elements', defaultValidElements); - }; - var shouldConvertWordFakeLists = function (editor) { - return editor.getParam('paste_convert_word_fake_lists', true); - }; - var shouldUseDefaultFilters = function (editor) { - return editor.getParam('paste_enable_default_filters', true); - }; - var getValidate = function (editor) { - return editor.getParam('validate'); - }; - var getAllowHtmlDataUrls = function (editor) { - return editor.getParam('allow_html_data_urls', false, 'boolean'); - }; - var getPasteDataImages = function (editor) { - return editor.getParam('paste_data_images', false, 'boolean'); - }; - var getImagesDataImgFilter = function (editor) { - return editor.getParam('images_dataimg_filter'); - }; - var getImagesReuseFilename = function (editor) { - return editor.getParam('images_reuse_filename'); - }; - var getForcedRootBlock = function (editor) { - return editor.getParam('forced_root_block'); - }; - var getForcedRootBlockAttrs = function (editor) { - return editor.getParam('forced_root_block_attrs'); - }; - var getTabSpaces = function (editor) { - return editor.getParam('paste_tab_spaces', 4, 'number'); - }; - var getAllowedImageFileTypes = function (editor) { - var defaultImageFileTypes = 'jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp'; - return global$6.explode(editor.getParam('images_file_types', defaultImageFileTypes, 'string')); - }; - - var internalMimeType = 'x-tinymce/html'; - var internalMark = ''; - var mark = function (html) { - return internalMark + html; - }; - var unmark = function (html) { - return html.replace(internalMark, ''); - }; - var isMarked = function (html) { - return html.indexOf(internalMark) !== -1; - }; - var internalHtmlMime = constant(internalMimeType); - - var hasOwnProperty = Object.hasOwnProperty; - var has = function (obj, key) { - return hasOwnProperty.call(obj, key); - }; - - var global$5 = tinymce.util.Tools.resolve('tinymce.html.Entities'); - - var isPlainText = function (text) { - return !/<(?:\/?(?!(?:div|p|br|span)>)\w+|(?:(?!(?:span style="white-space:\s?pre;?">)|br\s?\/>))\w+\s[^>]+)>/i.test(text); - }; - var toBRs = function (text) { - return text.replace(/\r?\n/g, '
'); - }; - var openContainer = function (rootTag, rootAttrs) { - var attrs = []; - var tag = '<' + rootTag; - if (typeof rootAttrs === 'object') { - for (var key in rootAttrs) { - if (has(rootAttrs, key)) { - attrs.push(key + '="' + global$5.encodeAllRaw(rootAttrs[key]) + '"'); - } - } - if (attrs.length) { - tag += ' ' + attrs.join(' '); - } - } - return tag + '>'; - }; - var toBlockElements = function (text, rootTag, rootAttrs) { - var blocks = text.split(/\n\n/); - var tagOpen = openContainer(rootTag, rootAttrs); - var tagClose = ''; - var paragraphs = global$6.map(blocks, function (p) { - return p.split(/\n/).join('
'); - }); - var stitch = function (p) { - return tagOpen + p + tagClose; - }; - return paragraphs.length === 1 ? paragraphs[0] : global$6.map(paragraphs, stitch).join(''); - }; - var convert = function (text, rootTag, rootAttrs) { - return rootTag ? toBlockElements(text, rootTag === true ? 'p' : rootTag, rootAttrs) : toBRs(text); - }; - - var global$4 = tinymce.util.Tools.resolve('tinymce.html.DomParser'); - - var global$3 = tinymce.util.Tools.resolve('tinymce.html.Serializer'); - - var nbsp = '\xA0'; - - var global$2 = tinymce.util.Tools.resolve('tinymce.html.Node'); - - var global$1 = tinymce.util.Tools.resolve('tinymce.html.Schema'); - - var isRegExp = function (val) { - return val.constructor === RegExp; - }; - var filter = function (content, items) { - global$6.each(items, function (v) { - if (isRegExp(v)) { - content = content.replace(v, ''); - } else { - content = content.replace(v[0], v[1]); - } - }); - return content; - }; - var innerText = function (html) { - var schema = global$1(); - var domParser = global$4({}, schema); - var text = ''; - var shortEndedElements = schema.getShortEndedElements(); - var ignoreElements = global$6.makeMap('script noscript style textarea video audio iframe object', ' '); - var blockElements = schema.getBlockElements(); - var walk = function (node) { - var name = node.name, currentNode = node; - if (name === 'br') { - text += '\n'; - return; - } - if (name === 'wbr') { - return; - } - if (shortEndedElements[name]) { - text += ' '; - } - if (ignoreElements[name]) { - text += ' '; - return; - } - if (node.type === 3) { - text += node.value; - } - if (!node.shortEnded) { - if (node = node.firstChild) { - do { - walk(node); - } while (node = node.next); - } - } - if (blockElements[name] && currentNode.next) { - text += '\n'; - if (name === 'p') { - text += '\n'; - } - } - }; - html = filter(html, [//g]); - walk(domParser.parse(html)); - return text; - }; - var trimHtml = function (html) { - var trimSpaces = function (all, s1, s2) { - if (!s1 && !s2) { - return ' '; - } - return nbsp; - }; - html = filter(html, [ - /^[\s\S]*]*>\s*|\s*<\/body[^>]*>[\s\S]*$/ig, - /|/g, - [ - /( ?)\u00a0<\/span>( ?)/g, - trimSpaces - ], - /
/g, - /
$/i - ]); - return html; - }; - var createIdGenerator = function (prefix) { - var count = 0; - return function () { - return prefix + count++; - }; - }; - var getImageMimeType = function (ext) { - var lowerExt = ext.toLowerCase(); - var mimeOverrides = { - jpg: 'jpeg', - jpe: 'jpeg', - jfi: 'jpeg', - jif: 'jpeg', - jfif: 'jpeg', - pjpeg: 'jpeg', - pjp: 'jpeg', - svg: 'svg+xml' - }; - return global$6.hasOwn(mimeOverrides, lowerExt) ? 'image/' + mimeOverrides[lowerExt] : 'image/' + lowerExt; - }; - - var isWordContent = function (content) { - return / 1) { - currentListNode.attr('start', '' + start); - } - paragraphNode.wrap(currentListNode); - } else { - currentListNode.append(paragraphNode); - } - paragraphNode.name = 'li'; - if (level > lastLevel && prevListNode) { - prevListNode.lastChild.append(currentListNode); - } - lastLevel = level; - removeIgnoredNodes(paragraphNode); - trimListStart(paragraphNode, /^\u00a0+/); - trimListStart(paragraphNode, /^\s*([\u2022\u00b7\u00a7\u25CF]|\w+\.)/); - trimListStart(paragraphNode, /^\u00a0+/); - }; - var elements = []; - var child = node.firstChild; - while (typeof child !== 'undefined' && child !== null) { - elements.push(child); - child = child.walk(); - if (child !== null) { - while (typeof child !== 'undefined' && child.parent !== node) { - child = child.walk(); - } - } - } - for (var i = 0; i < elements.length; i++) { - node = elements[i]; - if (node.name === 'p' && node.firstChild) { - var nodeText = getText(node); - if (isBulletList(nodeText)) { - convertParagraphToLi(node, 'ul'); - continue; - } - if (isNumericList(nodeText)) { - var matches = /([0-9]+)\./.exec(nodeText); - var start = 1; - if (matches) { - start = parseInt(matches[1], 10); - } - convertParagraphToLi(node, 'ol', start); - continue; - } - if (node._listLevel) { - convertParagraphToLi(node, 'ul', 1); - continue; - } - currentListNode = null; - } else { - prevListNode = currentListNode; - currentListNode = null; - } - } - }; - var filterStyles = function (editor, validStyles, node, styleValue) { - var outputStyles = {}; - var styles = editor.dom.parseStyle(styleValue); - global$6.each(styles, function (value, name) { - switch (name) { - case 'mso-list': - var matches = /\w+ \w+([0-9]+)/i.exec(styleValue); - if (matches) { - node._listLevel = parseInt(matches[1], 10); - } - if (/Ignore/i.test(value) && node.firstChild) { - node._listIgnore = true; - node.firstChild._listIgnore = true; - } - break; - case 'horiz-align': - name = 'text-align'; - break; - case 'vert-align': - name = 'vertical-align'; - break; - case 'font-color': - case 'mso-foreground': - name = 'color'; - break; - case 'mso-background': - case 'mso-highlight': - name = 'background'; - break; - case 'font-weight': - case 'font-style': - if (value !== 'normal') { - outputStyles[name] = value; - } - return; - case 'mso-element': - if (/^(comment|comment-list)$/i.test(value)) { - node.remove(); - return; - } - break; - } - if (name.indexOf('mso-comment') === 0) { - node.remove(); - return; - } - if (name.indexOf('mso-') === 0) { - return; - } - if (getRetainStyleProps(editor) === 'all' || validStyles && validStyles[name]) { - outputStyles[name] = value; - } - }); - if (/(bold)/i.test(outputStyles['font-weight'])) { - delete outputStyles['font-weight']; - node.wrap(new global$2('b', 1)); - } - if (/(italic)/i.test(outputStyles['font-style'])) { - delete outputStyles['font-style']; - node.wrap(new global$2('i', 1)); - } - var outputStyle = editor.dom.serializeStyle(outputStyles, node.name); - if (outputStyle) { - return outputStyle; - } - return null; - }; - var filterWordContent = function (editor, content) { - var validStyles; - var retainStyleProperties = getRetainStyleProps(editor); - if (retainStyleProperties) { - validStyles = global$6.makeMap(retainStyleProperties.split(/[, ]/)); - } - content = filter(content, [ - /
/gi, - /]+id="?docs-internal-[^>]*>/gi, - //gi, - /<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi, - [ - /<(\/?)s>/gi, - '<$1strike>' - ], - [ - / /gi, - nbsp - ], - [ - /([\s\u00a0]*)<\/span>/gi, - function (str, spaces) { - return spaces.length > 0 ? spaces.replace(/./, ' ').slice(Math.floor(spaces.length / 2)).split('').join(nbsp) : ''; - } - ] - ]); - var validElements = getWordValidElements(editor); - var schema = global$1({ - valid_elements: validElements, - valid_children: '-li[p]' - }); - global$6.each(schema.elements, function (rule) { - if (!rule.attributes.class) { - rule.attributes.class = {}; - rule.attributesOrder.push('class'); - } - if (!rule.attributes.style) { - rule.attributes.style = {}; - rule.attributesOrder.push('style'); - } - }); - var domParser = global$4({}, schema); - domParser.addAttributeFilter('style', function (nodes) { - var i = nodes.length, node; - while (i--) { - node = nodes[i]; - node.attr('style', filterStyles(editor, validStyles, node, node.attr('style'))); - if (node.name === 'span' && node.parent && !node.attributes.length) { - node.unwrap(); - } - } - }); - domParser.addAttributeFilter('class', function (nodes) { - var i = nodes.length, node, className; - while (i--) { - node = nodes[i]; - className = node.attr('class'); - if (/^(MsoCommentReference|MsoCommentText|msoDel)$/i.test(className)) { - node.remove(); - } - node.attr('class', null); - } - }); - domParser.addNodeFilter('del', function (nodes) { - var i = nodes.length; - while (i--) { - nodes[i].remove(); - } - }); - domParser.addNodeFilter('a', function (nodes) { - var i = nodes.length, node, href, name; - while (i--) { - node = nodes[i]; - href = node.attr('href'); - name = node.attr('name'); - if (href && href.indexOf('#_msocom_') !== -1) { - node.remove(); - continue; - } - if (href && href.indexOf('file://') === 0) { - href = href.split('#')[1]; - if (href) { - href = '#' + href; - } - } - if (!href && !name) { - node.unwrap(); - } else { - if (name && !/^_?(?:toc|edn|ftn)/i.test(name)) { - node.unwrap(); - continue; - } - node.attr({ - href: href, - name: name - }); - } - } - }); - var rootNode = domParser.parse(content); - if (shouldConvertWordFakeLists(editor)) { - convertFakeListsToProperLists(rootNode); - } - content = global$3({ validate: getValidate(editor) }, schema).serialize(rootNode); - return content; - }; - var preProcess$1 = function (editor, content) { - return shouldUseDefaultFilters(editor) ? filterWordContent(editor, content) : content; - }; - - var preProcess = function (editor, html) { - var parser = global$4({}, editor.schema); - parser.addNodeFilter('meta', function (nodes) { - global$6.each(nodes, function (node) { - node.remove(); - }); - }); - var fragment = parser.parse(html, { - forced_root_block: false, - isRootContent: true - }); - return global$3({ validate: getValidate(editor) }, editor.schema).serialize(fragment); - }; - var processResult = function (content, cancelled) { - return { - content: content, - cancelled: cancelled - }; - }; - var postProcessFilter = function (editor, html, internal, isWordHtml) { - var tempBody = editor.dom.create('div', { style: 'display:none' }, html); - var postProcessArgs = firePastePostProcess(editor, tempBody, internal, isWordHtml); - return processResult(postProcessArgs.node.innerHTML, postProcessArgs.isDefaultPrevented()); - }; - var filterContent = function (editor, content, internal, isWordHtml) { - var preProcessArgs = firePastePreProcess(editor, content, internal, isWordHtml); - var filteredContent = preProcess(editor, preProcessArgs.content); - if (editor.hasEventListeners('PastePostProcess') && !preProcessArgs.isDefaultPrevented()) { - return postProcessFilter(editor, filteredContent, internal, isWordHtml); - } else { - return processResult(filteredContent, preProcessArgs.isDefaultPrevented()); - } - }; - var process = function (editor, html, internal) { - var isWordHtml = isWordContent(html); - var content = isWordHtml ? preProcess$1(editor, html) : html; - return filterContent(editor, content, internal, isWordHtml); - }; - - var pasteHtml$1 = function (editor, html) { - editor.insertContent(html, { - merge: shouldMergeFormats(editor), - paste: true - }); - return true; - }; - var isAbsoluteUrl = function (url) { - return /^https?:\/\/[\w\?\-\/+=.&%@~#]+$/i.test(url); - }; - var isImageUrl = function (editor, url) { - return isAbsoluteUrl(url) && exists(getAllowedImageFileTypes(editor), function (type) { - return endsWith(url.toLowerCase(), '.' + type.toLowerCase()); - }); - }; - var createImage = function (editor, url, pasteHtmlFn) { - editor.undoManager.extra(function () { - pasteHtmlFn(editor, url); - }, function () { - editor.insertContent(''); - }); - return true; - }; - var createLink = function (editor, url, pasteHtmlFn) { - editor.undoManager.extra(function () { - pasteHtmlFn(editor, url); - }, function () { - editor.execCommand('mceInsertLink', false, url); - }); - return true; - }; - var linkSelection = function (editor, html, pasteHtmlFn) { - return editor.selection.isCollapsed() === false && isAbsoluteUrl(html) ? createLink(editor, html, pasteHtmlFn) : false; - }; - var insertImage = function (editor, html, pasteHtmlFn) { - return isImageUrl(editor, html) ? createImage(editor, html, pasteHtmlFn) : false; - }; - var smartInsertContent = function (editor, html) { - global$6.each([ - linkSelection, - insertImage, - pasteHtml$1 - ], function (action) { - return action(editor, html, pasteHtml$1) !== true; - }); - }; - var insertContent = function (editor, html, pasteAsText) { - if (pasteAsText || isSmartPasteEnabled(editor) === false) { - pasteHtml$1(editor, html); - } else { - smartInsertContent(editor, html); - } - }; - - var isCollapsibleWhitespace = function (c) { - return ' \f\t\x0B'.indexOf(c) !== -1; - }; - var isNewLineChar = function (c) { - return c === '\n' || c === '\r'; - }; - var isNewline = function (text, idx) { - return idx < text.length && idx >= 0 ? isNewLineChar(text[idx]) : false; - }; - var normalizeWhitespace = function (editor, text) { - var tabSpace = repeat(' ', getTabSpaces(editor)); - var normalizedText = text.replace(/\t/g, tabSpace); - var result = foldl(normalizedText, function (acc, c) { - if (isCollapsibleWhitespace(c) || c === nbsp) { - if (acc.pcIsSpace || acc.str === '' || acc.str.length === normalizedText.length - 1 || isNewline(normalizedText, acc.str.length + 1)) { - return { - pcIsSpace: false, - str: acc.str + nbsp - }; - } else { - return { - pcIsSpace: true, - str: acc.str + ' ' - }; - } - } else { - return { - pcIsSpace: isNewLineChar(c), - str: acc.str + c - }; - } - }, { - pcIsSpace: false, - str: '' - }); - return result.str; - }; - - var doPaste = function (editor, content, internal, pasteAsText) { - var args = process(editor, content, internal); - if (args.cancelled === false) { - insertContent(editor, args.content, pasteAsText); - } - }; - var pasteHtml = function (editor, html, internalFlag) { - var internal = internalFlag ? internalFlag : isMarked(html); - doPaste(editor, unmark(html), internal, false); - }; - var pasteText = function (editor, text) { - var encodedText = editor.dom.encode(text).replace(/\r\n/g, '\n'); - var normalizedText = normalizeWhitespace(editor, encodedText); - var html = convert(normalizedText, getForcedRootBlock(editor), getForcedRootBlockAttrs(editor)); - doPaste(editor, html, false, true); - }; - var getDataTransferItems = function (dataTransfer) { - var items = {}; - var mceInternalUrlPrefix = 'data:text/mce-internal,'; - if (dataTransfer) { - if (dataTransfer.getData) { - var legacyText = dataTransfer.getData('Text'); - if (legacyText && legacyText.length > 0) { - if (legacyText.indexOf(mceInternalUrlPrefix) === -1) { - items['text/plain'] = legacyText; - } - } - } - if (dataTransfer.types) { - for (var i = 0; i < dataTransfer.types.length; i++) { - var contentType = dataTransfer.types[i]; - try { - items[contentType] = dataTransfer.getData(contentType); - } catch (ex) { - items[contentType] = ''; - } - } - } - } - return items; - }; - var getClipboardContent = function (editor, clipboardEvent) { - return getDataTransferItems(clipboardEvent.clipboardData || editor.getDoc().dataTransfer); - }; - var hasContentType = function (clipboardContent, mimeType) { - return mimeType in clipboardContent && clipboardContent[mimeType].length > 0; - }; - var hasHtmlOrText = function (content) { - return hasContentType(content, 'text/html') || hasContentType(content, 'text/plain'); - }; - var parseDataUri = function (uri) { - var matches = /data:([^;]+);base64,([a-z0-9\+\/=]+)/i.exec(uri); - if (matches) { - return { - type: matches[1], - data: decodeURIComponent(matches[2]) - }; - } else { - return { - type: null, - data: null - }; - } - }; - var isValidDataUriImage = function (editor, imgElm) { - var filter = getImagesDataImgFilter(editor); - return filter ? filter(imgElm) : true; - }; - var extractFilename = function (editor, str) { - var m = str.match(/([\s\S]+?)(?:\.[a-z0-9.]+)$/i); - return isNonNullable(m) ? editor.dom.encode(m[1]) : null; - }; - var uniqueId = createIdGenerator('mceclip'); - var pasteImage = function (editor, imageItem) { - var _a = parseDataUri(imageItem.uri), base64 = _a.data, type = _a.type; - var id = uniqueId(); - var file = imageItem.blob; - var img = new Image(); - img.src = imageItem.uri; - if (isValidDataUriImage(editor, img)) { - var blobCache = editor.editorUpload.blobCache; - var blobInfo = void 0; - var existingBlobInfo = blobCache.getByData(base64, type); - if (!existingBlobInfo) { - var useFileName = getImagesReuseFilename(editor) && isNonNullable(file.name); - var name_1 = useFileName ? extractFilename(editor, file.name) : id; - var filename = useFileName ? file.name : undefined; - blobInfo = blobCache.create(id, file, base64, name_1, filename); - blobCache.add(blobInfo); - } else { - blobInfo = existingBlobInfo; - } - pasteHtml(editor, '', false); - } else { - pasteHtml(editor, '', false); - } - }; - var isClipboardEvent = function (event) { - return event.type === 'paste'; - }; - var isDataTransferItem = function (item) { - return isNonNullable(item.getAsFile); - }; - var readFilesAsDataUris = function (items) { - return global$8.all(map(items, function (item) { - return new global$8(function (resolve) { - var blob = isDataTransferItem(item) ? item.getAsFile() : item; - var reader = new window.FileReader(); - reader.onload = function () { - resolve({ - blob: blob, - uri: reader.result - }); - }; - reader.readAsDataURL(blob); - }); - })); - }; - var isImage = function (editor) { - var allowedExtensions = getAllowedImageFileTypes(editor); - return function (file) { - return startsWith(file.type, 'image/') && exists(allowedExtensions, function (extension) { - return getImageMimeType(extension) === file.type; - }); - }; - }; - var getImagesFromDataTransfer = function (editor, dataTransfer) { - var items = dataTransfer.items ? bind(from(dataTransfer.items), function (item) { - return item.kind === 'file' ? [item.getAsFile()] : []; - }) : []; - var files = dataTransfer.files ? from(dataTransfer.files) : []; - return filter$1(items.length > 0 ? items : files, isImage(editor)); - }; - var pasteImageData = function (editor, e, rng) { - var dataTransfer = isClipboardEvent(e) ? e.clipboardData : e.dataTransfer; - if (getPasteDataImages(editor) && dataTransfer) { - var images = getImagesFromDataTransfer(editor, dataTransfer); - if (images.length > 0) { - e.preventDefault(); - readFilesAsDataUris(images).then(function (fileResults) { - if (rng) { - editor.selection.setRng(rng); - } - each(fileResults, function (result) { - pasteImage(editor, result); - }); - }); - return true; - } - } - return false; - }; - var isBrokenAndroidClipboardEvent = function (e) { - var clipboardData = e.clipboardData; - return navigator.userAgent.indexOf('Android') !== -1 && clipboardData && clipboardData.items && clipboardData.items.length === 0; - }; - var isKeyboardPasteEvent = function (e) { - return global$7.metaKeyPressed(e) && e.keyCode === 86 || e.shiftKey && e.keyCode === 45; - }; - var registerEventHandlers = function (editor, pasteBin, pasteFormat) { - var keyboardPasteEvent = value(); - var keyboardPastePressed = value(); - var keyboardPastePlainTextState; - editor.on('keyup', keyboardPastePressed.clear); - editor.on('keydown', function (e) { - var removePasteBinOnKeyUp = function (e) { - if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) { - pasteBin.remove(); - } - }; - if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) { - keyboardPastePlainTextState = e.shiftKey && e.keyCode === 86; - if (keyboardPastePlainTextState && global$a.webkit && navigator.userAgent.indexOf('Version/') !== -1) { - return; - } - e.stopImmediatePropagation(); - keyboardPasteEvent.set(e); - keyboardPastePressed.set(true); - if (global$a.ie && keyboardPastePlainTextState) { - e.preventDefault(); - firePaste(editor, true); - return; - } - pasteBin.remove(); - pasteBin.create(); - editor.once('keyup', removePasteBinOnKeyUp); - editor.once('paste', function () { - editor.off('keyup', removePasteBinOnKeyUp); - }); - } - }); - var insertClipboardContent = function (editor, clipboardContent, isKeyBoardPaste, plainTextMode, internal) { - var content; - if (hasContentType(clipboardContent, 'text/html')) { - content = clipboardContent['text/html']; - } else { - content = pasteBin.getHtml(); - internal = internal ? internal : isMarked(content); - if (pasteBin.isDefaultContent(content)) { - plainTextMode = true; - } - } - content = trimHtml(content); - pasteBin.remove(); - var isPlainTextHtml = internal === false && isPlainText(content); - var isAbsoluteUrl$1 = isAbsoluteUrl(content); - if (!content.length || isPlainTextHtml && !isAbsoluteUrl$1) { - plainTextMode = true; - } - if (plainTextMode || isAbsoluteUrl$1) { - if (hasContentType(clipboardContent, 'text/plain') && isPlainTextHtml) { - content = clipboardContent['text/plain']; - } else { - content = innerText(content); - } - } - if (pasteBin.isDefaultContent(content)) { - if (!isKeyBoardPaste) { - editor.windowManager.alert('Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents.'); - } - return; - } - if (plainTextMode) { - pasteText(editor, content); - } else { - pasteHtml(editor, content, internal); - } - }; - var getLastRng = function () { - return pasteBin.getLastRng() || editor.selection.getRng(); - }; - editor.on('paste', function (e) { - var isKeyboardPaste = keyboardPasteEvent.isSet() || keyboardPastePressed.isSet(); - if (isKeyboardPaste) { - keyboardPasteEvent.clear(); - } - var clipboardContent = getClipboardContent(editor, e); - var plainTextMode = pasteFormat.get() === 'text' || keyboardPastePlainTextState; - var internal = hasContentType(clipboardContent, internalHtmlMime()); - keyboardPastePlainTextState = false; - if (e.isDefaultPrevented() || isBrokenAndroidClipboardEvent(e)) { - pasteBin.remove(); - return; - } - if (!hasHtmlOrText(clipboardContent) && pasteImageData(editor, e, getLastRng())) { - pasteBin.remove(); - return; - } - if (!isKeyboardPaste) { - e.preventDefault(); - } - if (global$a.ie && (!isKeyboardPaste || e.ieFake) && !hasContentType(clipboardContent, 'text/html')) { - pasteBin.create(); - editor.dom.bind(pasteBin.getEl(), 'paste', function (e) { - e.stopPropagation(); - }); - editor.getDoc().execCommand('Paste', false, null); - clipboardContent['text/html'] = pasteBin.getHtml(); - } - if (hasContentType(clipboardContent, 'text/html')) { - e.preventDefault(); - if (!internal) { - internal = isMarked(clipboardContent['text/html']); - } - insertClipboardContent(editor, clipboardContent, isKeyboardPaste, plainTextMode, internal); - } else { - global$9.setEditorTimeout(editor, function () { - insertClipboardContent(editor, clipboardContent, isKeyboardPaste, plainTextMode, internal); - }, 0); - } - }); - }; - var registerEventsAndFilters = function (editor, pasteBin, pasteFormat) { - registerEventHandlers(editor, pasteBin, pasteFormat); - var src; - editor.parser.addNodeFilter('img', function (nodes, name, args) { - var isPasteInsert = function (args) { - return args.data && args.data.paste === true; - }; - var remove = function (node) { - if (!node.attr('data-mce-object') && src !== global$a.transparentSrc) { - node.remove(); - } - }; - var isWebKitFakeUrl = function (src) { - return src.indexOf('webkit-fake-url') === 0; - }; - var isDataUri = function (src) { - return src.indexOf('data:') === 0; - }; - if (!getPasteDataImages(editor) && isPasteInsert(args)) { - var i = nodes.length; - while (i--) { - src = nodes[i].attr('src'); - if (!src) { - continue; - } - if (isWebKitFakeUrl(src)) { - remove(nodes[i]); - } else if (!getAllowHtmlDataUrls(editor) && isDataUri(src)) { - remove(nodes[i]); - } - } - } - }); - }; - - var getPasteBinParent = function (editor) { - return global$a.ie && editor.inline ? document.body : editor.getBody(); - }; - var isExternalPasteBin = function (editor) { - return getPasteBinParent(editor) !== editor.getBody(); - }; - var delegatePasteEvents = function (editor, pasteBinElm, pasteBinDefaultContent) { - if (isExternalPasteBin(editor)) { - editor.dom.bind(pasteBinElm, 'paste keyup', function (_e) { - if (!isDefault(editor, pasteBinDefaultContent)) { - editor.fire('paste'); - } - }); - } - }; - var create = function (editor, lastRngCell, pasteBinDefaultContent) { - var dom = editor.dom, body = editor.getBody(); - lastRngCell.set(editor.selection.getRng()); - var pasteBinElm = editor.dom.add(getPasteBinParent(editor), 'div', { - 'id': 'mcepastebin', - 'class': 'mce-pastebin', - 'contentEditable': true, - 'data-mce-bogus': 'all', - 'style': 'position: fixed; top: 50%; width: 10px; height: 10px; overflow: hidden; opacity: 0' - }, pasteBinDefaultContent); - if (global$a.ie || global$a.gecko) { - dom.setStyle(pasteBinElm, 'left', dom.getStyle(body, 'direction', true) === 'rtl' ? 65535 : -65535); - } - dom.bind(pasteBinElm, 'beforedeactivate focusin focusout', function (e) { - e.stopPropagation(); - }); - delegatePasteEvents(editor, pasteBinElm, pasteBinDefaultContent); - pasteBinElm.focus(); - editor.selection.select(pasteBinElm, true); - }; - var remove = function (editor, lastRngCell) { - if (getEl(editor)) { - var pasteBinClone = void 0; - var lastRng = lastRngCell.get(); - while (pasteBinClone = editor.dom.get('mcepastebin')) { - editor.dom.remove(pasteBinClone); - editor.dom.unbind(pasteBinClone); - } - if (lastRng) { - editor.selection.setRng(lastRng); - } - } - lastRngCell.set(null); - }; - var getEl = function (editor) { - return editor.dom.get('mcepastebin'); - }; - var getHtml = function (editor) { - var copyAndRemove = function (toElm, fromElm) { - toElm.appendChild(fromElm); - editor.dom.remove(fromElm, true); - }; - var pasteBinClones = global$6.grep(getPasteBinParent(editor).childNodes, function (elm) { - return elm.id === 'mcepastebin'; - }); - var pasteBinElm = pasteBinClones.shift(); - global$6.each(pasteBinClones, function (pasteBinClone) { - copyAndRemove(pasteBinElm, pasteBinClone); - }); - var dirtyWrappers = editor.dom.select('div[id=mcepastebin]', pasteBinElm); - for (var i = dirtyWrappers.length - 1; i >= 0; i--) { - var cleanWrapper = editor.dom.create('div'); - pasteBinElm.insertBefore(cleanWrapper, dirtyWrappers[i]); - copyAndRemove(cleanWrapper, dirtyWrappers[i]); - } - return pasteBinElm ? pasteBinElm.innerHTML : ''; - }; - var isDefaultContent = function (pasteBinDefaultContent, content) { - return content === pasteBinDefaultContent; - }; - var isPasteBin = function (elm) { - return elm && elm.id === 'mcepastebin'; - }; - var isDefault = function (editor, pasteBinDefaultContent) { - var pasteBinElm = getEl(editor); - return isPasteBin(pasteBinElm) && isDefaultContent(pasteBinDefaultContent, pasteBinElm.innerHTML); - }; - var PasteBin = function (editor) { - var lastRng = Cell(null); - var pasteBinDefaultContent = '%MCEPASTEBIN%'; - return { - create: function () { - return create(editor, lastRng, pasteBinDefaultContent); - }, - remove: function () { - return remove(editor, lastRng); - }, - getEl: function () { - return getEl(editor); - }, - getHtml: function () { - return getHtml(editor); - }, - getLastRng: lastRng.get, - isDefault: function () { - return isDefault(editor, pasteBinDefaultContent); - }, - isDefaultContent: function (content) { - return isDefaultContent(pasteBinDefaultContent, content); - } - }; - }; - - var Clipboard = function (editor, pasteFormat) { - var pasteBin = PasteBin(editor); - editor.on('PreInit', function () { - return registerEventsAndFilters(editor, pasteBin, pasteFormat); - }); - return { - pasteFormat: pasteFormat, - pasteHtml: function (html, internalFlag) { - return pasteHtml(editor, html, internalFlag); - }, - pasteText: function (text) { - return pasteText(editor, text); - }, - pasteImageData: function (e, rng) { - return pasteImageData(editor, e, rng); - }, - getDataTransferItems: getDataTransferItems, - hasHtmlOrText: hasHtmlOrText, - hasContentType: hasContentType - }; - }; - - var togglePlainTextPaste = function (editor, clipboard) { - if (clipboard.pasteFormat.get() === 'text') { - clipboard.pasteFormat.set('html'); - firePastePlainTextToggle(editor, false); - } else { - clipboard.pasteFormat.set('text'); - firePastePlainTextToggle(editor, true); - } - editor.focus(); - }; - - var register$2 = function (editor, clipboard) { - editor.addCommand('mceTogglePlainTextPaste', function () { - togglePlainTextPaste(editor, clipboard); - }); - editor.addCommand('mceInsertClipboardContent', function (ui, value) { - if (value.content) { - clipboard.pasteHtml(value.content, value.internal); - } - if (value.text) { - clipboard.pasteText(value.text); - } - }); - }; - - var hasWorkingClipboardApi = function (clipboardData) { - return global$a.iOS === false && typeof (clipboardData === null || clipboardData === void 0 ? void 0 : clipboardData.setData) === 'function'; - }; - var setHtml5Clipboard = function (clipboardData, html, text) { - if (hasWorkingClipboardApi(clipboardData)) { - try { - clipboardData.clearData(); - clipboardData.setData('text/html', html); - clipboardData.setData('text/plain', text); - clipboardData.setData(internalHtmlMime(), html); - return true; - } catch (e) { - return false; - } - } else { - return false; - } - }; - var setClipboardData = function (evt, data, fallback, done) { - if (setHtml5Clipboard(evt.clipboardData, data.html, data.text)) { - evt.preventDefault(); - done(); - } else { - fallback(data.html, done); - } - }; - var fallback = function (editor) { - return function (html, done) { - var markedHtml = mark(html); - var outer = editor.dom.create('div', { - 'contenteditable': 'false', - 'data-mce-bogus': 'all' - }); - var inner = editor.dom.create('div', { contenteditable: 'true' }, markedHtml); - editor.dom.setStyles(outer, { - position: 'fixed', - top: '0', - left: '-3000px', - width: '1000px', - overflow: 'hidden' - }); - outer.appendChild(inner); - editor.dom.add(editor.getBody(), outer); - var range = editor.selection.getRng(); - inner.focus(); - var offscreenRange = editor.dom.createRng(); - offscreenRange.selectNodeContents(inner); - editor.selection.setRng(offscreenRange); - global$9.setTimeout(function () { - editor.selection.setRng(range); - outer.parentNode.removeChild(outer); - done(); - }, 0); - }; - }; - var getData = function (editor) { - return { - html: editor.selection.getContent({ contextual: true }), - text: editor.selection.getContent({ format: 'text' }) - }; - }; - var isTableSelection = function (editor) { - return !!editor.dom.getParent(editor.selection.getStart(), 'td[data-mce-selected],th[data-mce-selected]', editor.getBody()); - }; - var hasSelectedContent = function (editor) { - return !editor.selection.isCollapsed() || isTableSelection(editor); - }; - var cut = function (editor) { - return function (evt) { - if (hasSelectedContent(editor)) { - setClipboardData(evt, getData(editor), fallback(editor), function () { - if (global$a.browser.isChrome() || global$a.browser.isFirefox()) { - var rng_1 = editor.selection.getRng(); - global$9.setEditorTimeout(editor, function () { - editor.selection.setRng(rng_1); - editor.execCommand('Delete'); - }, 0); - } else { - editor.execCommand('Delete'); - } - }); - } - }; - }; - var copy = function (editor) { - return function (evt) { - if (hasSelectedContent(editor)) { - setClipboardData(evt, getData(editor), fallback(editor), noop); - } - }; - }; - var register$1 = function (editor) { - editor.on('cut', cut(editor)); - editor.on('copy', copy(editor)); - }; - - var global = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils'); - - var getCaretRangeFromEvent = function (editor, e) { - return global.getCaretRangeFromPoint(e.clientX, e.clientY, editor.getDoc()); - }; - var isPlainTextFileUrl = function (content) { - var plainTextContent = content['text/plain']; - return plainTextContent ? plainTextContent.indexOf('file://') === 0 : false; - }; - var setFocusedRange = function (editor, rng) { - editor.focus(); - editor.selection.setRng(rng); - }; - var setup$2 = function (editor, clipboard, draggingInternallyState) { - if (shouldBlockDrop(editor)) { - editor.on('dragend dragover draggesture dragdrop drop drag', function (e) { - e.preventDefault(); - e.stopPropagation(); - }); - } - if (!shouldPasteDataImages(editor)) { - editor.on('drop', function (e) { - var dataTransfer = e.dataTransfer; - if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) { - e.preventDefault(); - } - }); - } - editor.on('drop', function (e) { - var rng = getCaretRangeFromEvent(editor, e); - if (e.isDefaultPrevented() || draggingInternallyState.get()) { - return; - } - var dropContent = clipboard.getDataTransferItems(e.dataTransfer); - var internal = clipboard.hasContentType(dropContent, internalHtmlMime()); - if ((!clipboard.hasHtmlOrText(dropContent) || isPlainTextFileUrl(dropContent)) && clipboard.pasteImageData(e, rng)) { - return; - } - if (rng && shouldFilterDrop(editor)) { - var content_1 = dropContent['mce-internal'] || dropContent['text/html'] || dropContent['text/plain']; - if (content_1) { - e.preventDefault(); - global$9.setEditorTimeout(editor, function () { - editor.undoManager.transact(function () { - if (dropContent['mce-internal']) { - editor.execCommand('Delete'); - } - setFocusedRange(editor, rng); - content_1 = trimHtml(content_1); - if (!dropContent['text/html']) { - clipboard.pasteText(content_1); - } else { - clipboard.pasteHtml(content_1, internal); - } - }); - }); - } - } - }); - editor.on('dragstart', function (_e) { - draggingInternallyState.set(true); - }); - editor.on('dragover dragend', function (e) { - if (shouldPasteDataImages(editor) && draggingInternallyState.get() === false) { - e.preventDefault(); - setFocusedRange(editor, getCaretRangeFromEvent(editor, e)); - } - if (e.type === 'dragend') { - draggingInternallyState.set(false); - } - }); - }; - - var setup$1 = function (editor) { - var plugin = editor.plugins.paste; - var preProcess = getPreProcess(editor); - if (preProcess) { - editor.on('PastePreProcess', function (e) { - preProcess.call(plugin, plugin, e); - }); - } - var postProcess = getPostProcess(editor); - if (postProcess) { - editor.on('PastePostProcess', function (e) { - postProcess.call(plugin, plugin, e); - }); - } - }; - - var addPreProcessFilter = function (editor, filterFunc) { - editor.on('PastePreProcess', function (e) { - e.content = filterFunc(editor, e.content, e.internal, e.wordContent); - }); - }; - var addPostProcessFilter = function (editor, filterFunc) { - editor.on('PastePostProcess', function (e) { - filterFunc(editor, e.node); - }); - }; - var removeExplorerBrElementsAfterBlocks = function (editor, html) { - if (!isWordContent(html)) { - return html; - } - var blockElements = []; - global$6.each(editor.schema.getBlockElements(), function (block, blockName) { - blockElements.push(blockName); - }); - var explorerBlocksRegExp = new RegExp('(?:
 [\\s\\r\\n]+|
)*(<\\/?(' + blockElements.join('|') + ')[^>]*>)(?:
 [\\s\\r\\n]+|
)*', 'g'); - html = filter(html, [[ - explorerBlocksRegExp, - '$1' - ]]); - html = filter(html, [ - [ - /

/g, - '

' - ], - [ - /
/g, - ' ' - ], - [ - /

/g, - '
' - ] - ]); - return html; - }; - var removeWebKitStyles = function (editor, content, internal, isWordHtml) { - if (isWordHtml || internal) { - return content; - } - var webKitStylesSetting = getWebkitStyles(editor); - var webKitStyles; - if (shouldRemoveWebKitStyles(editor) === false || webKitStylesSetting === 'all') { - return content; - } - if (webKitStylesSetting) { - webKitStyles = webKitStylesSetting.split(/[, ]/); - } - if (webKitStyles) { - var dom_1 = editor.dom, node_1 = editor.selection.getNode(); - content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, function (all, before, value, after) { - var inputStyles = dom_1.parseStyle(dom_1.decode(value)); - var outputStyles = {}; - if (webKitStyles === 'none') { - return before + after; - } - for (var i = 0; i < webKitStyles.length; i++) { - var inputValue = inputStyles[webKitStyles[i]], currentValue = dom_1.getStyle(node_1, webKitStyles[i], true); - if (/color/.test(webKitStyles[i])) { - inputValue = dom_1.toHex(inputValue); - currentValue = dom_1.toHex(currentValue); - } - if (currentValue !== inputValue) { - outputStyles[webKitStyles[i]] = inputValue; - } - } - var outputStyle = dom_1.serializeStyle(outputStyles, 'span'); - if (outputStyle) { - return before + ' style="' + outputStyle + '"' + after; - } - return before + after; - }); - } else { - content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, '$1$3'); - } - content = content.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi, function (all, before, value, after) { - return before + ' style="' + value + '"' + after; - }); - return content; - }; - var removeUnderlineAndFontInAnchor = function (editor, root) { - editor.$('a', root).find('font,u').each(function (i, node) { - editor.dom.remove(node, true); - }); - }; - var setup = function (editor) { - if (global$a.webkit) { - addPreProcessFilter(editor, removeWebKitStyles); - } - if (global$a.ie) { - addPreProcessFilter(editor, removeExplorerBrElementsAfterBlocks); - addPostProcessFilter(editor, removeUnderlineAndFontInAnchor); - } - }; - - var makeSetupHandler = function (editor, clipboard) { - return function (api) { - api.setActive(clipboard.pasteFormat.get() === 'text'); - var pastePlainTextToggleHandler = function (e) { - return api.setActive(e.state); - }; - editor.on('PastePlainTextToggle', pastePlainTextToggleHandler); - return function () { - return editor.off('PastePlainTextToggle', pastePlainTextToggleHandler); - }; - }; - }; - var register = function (editor, clipboard) { - var onAction = function () { - return editor.execCommand('mceTogglePlainTextPaste'); - }; - editor.ui.registry.addToggleButton('pastetext', { - active: false, - icon: 'paste-text', - tooltip: 'Paste as text', - onAction: onAction, - onSetup: makeSetupHandler(editor, clipboard) - }); - editor.ui.registry.addToggleMenuItem('pastetext', { - text: 'Paste as text', - icon: 'paste-text', - onAction: onAction, - onSetup: makeSetupHandler(editor, clipboard) - }); - }; - - function Plugin () { - global$b.add('paste', function (editor) { - if (hasProPlugin(editor) === false) { - var draggingInternallyState = Cell(false); - var pasteFormat = Cell(isPasteAsTextEnabled(editor) ? 'text' : 'html'); - var clipboard = Clipboard(editor, pasteFormat); - setup(editor); - register(editor, clipboard); - register$2(editor, clipboard); - setup$1(editor); - register$1(editor); - setup$2(editor, clipboard, draggingInternallyState); - return get(clipboard); - } - }); - } - - Plugin(); - -}()); - -/** - * Copyright (c) Tiny Technologies, Inc. All rights reserved. - * Licensed under the LGPL or a commercial license. - * For LGPL see License.txt in the project root for license information. - * For commercial licenses see https://www.tiny.cloud/ - * - * Version: 5.10.5 (2022-05-25) - */ -(function () { - 'use strict'; - - var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - var global = tinymce.util.Tools.resolve('tinymce.Env'); - - var register$1 = function (editor) { - editor.addCommand('mcePrint', function () { - if (global.browser.isIE()) { - editor.getDoc().execCommand('print', false, null); - } else { - editor.getWin().print(); - } - }); - }; - - var register = function (editor) { - var onAction = function () { - return editor.execCommand('mcePrint'); - }; - editor.ui.registry.addButton('print', { - icon: 'print', - tooltip: 'Print', - onAction: onAction - }); - editor.ui.registry.addMenuItem('print', { - text: 'Print...', - icon: 'print', - onAction: onAction - }); - }; - - function Plugin () { - global$1.add('print', function (editor) { - register$1(editor); - register(editor); - editor.addShortcut('Meta+P', '', 'mcePrint'); - }); - } - - Plugin(); - -}()); - -/** - * Copyright (c) Tiny Technologies, Inc. All rights reserved. - * Licensed under the LGPL or a commercial license. - * For LGPL see License.txt in the project root for license information. - * For commercial licenses see https://www.tiny.cloud/ - * - * Version: 5.10.5 (2022-05-25) - */ -(function () { - 'use strict'; - - var global$2 = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - var global$1 = tinymce.util.Tools.resolve('tinymce.Env'); - - var global = tinymce.util.Tools.resolve('tinymce.util.Tools'); - - var getContentStyle = function (editor) { - return editor.getParam('content_style', '', 'string'); - }; - var shouldUseContentCssCors = function (editor) { - return editor.getParam('content_css_cors', false, 'boolean'); - }; - var getBodyClassByHash = function (editor) { - var bodyClass = editor.getParam('body_class', '', 'hash'); - return bodyClass[editor.id] || ''; - }; - var getBodyClass = function (editor) { - var bodyClass = editor.getParam('body_class', '', 'string'); - if (bodyClass.indexOf('=') === -1) { - return bodyClass; - } else { - return getBodyClassByHash(editor); - } - }; - var getBodyIdByHash = function (editor) { - var bodyId = editor.getParam('body_id', '', 'hash'); - return bodyId[editor.id] || bodyId; - }; - var getBodyId = function (editor) { - var bodyId = editor.getParam('body_id', 'tinymce', 'string'); - if (bodyId.indexOf('=') === -1) { - return bodyId; - } else { - return getBodyIdByHash(editor); - } - }; - - var getPreviewHtml = function (editor) { - var headHtml = ''; - var encode = editor.dom.encode; - var contentStyle = getContentStyle(editor); - headHtml += ''; - var cors = shouldUseContentCssCors(editor) ? ' crossorigin="anonymous"' : ''; - global.each(editor.contentCSS, function (url) { - headHtml += ''; - }); - if (contentStyle) { - headHtml += ''; - } - var bodyId = getBodyId(editor); - var bodyClass = getBodyClass(editor); - var isMetaKeyPressed = global$1.mac ? 'e.metaKey' : 'e.ctrlKey && !e.altKey'; - var preventClicksOnLinksScript = ' '; - var directionality = editor.getBody().dir; - var dirAttr = directionality ? ' dir="' + encode(directionality) + '"' : ''; - var previewHtml = '' + '' + '' + headHtml + '' + '' + editor.getContent() + preventClicksOnLinksScript + '' + ''; - return previewHtml; - }; - - var open = function (editor) { - var content = getPreviewHtml(editor); - var dataApi = editor.windowManager.open({ - title: 'Preview', - size: 'large', - body: { - type: 'panel', - items: [{ - name: 'preview', - type: 'iframe', - sandboxed: true - }] - }, - buttons: [{ - type: 'cancel', - name: 'close', - text: 'Close', - primary: true - }], - initialData: { preview: content } - }); - dataApi.focus('close'); - }; - - var register$1 = function (editor) { - editor.addCommand('mcePreview', function () { - open(editor); - }); - }; - - var register = function (editor) { - var onAction = function () { - return editor.execCommand('mcePreview'); - }; - editor.ui.registry.addButton('preview', { - icon: 'preview', - tooltip: 'Preview', - onAction: onAction - }); - editor.ui.registry.addMenuItem('preview', { - icon: 'preview', - text: 'Preview', - onAction: onAction - }); - }; - - function Plugin () { - global$2.add('preview', function (editor) { - register$1(editor); - register(editor); - }); - } - - Plugin(); - -}()); - -/** - * Copyright (c) Tiny Technologies, Inc. All rights reserved. - * Licensed under the LGPL or a commercial license. - * For LGPL see License.txt in the project root for license information. - * For commercial licenses see https://www.tiny.cloud/ - * - * Version: 5.10.5 (2022-05-25) - */ -(function () { - 'use strict'; - - var global$2 = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); - - var global = tinymce.util.Tools.resolve('tinymce.util.Tools'); - - var enableWhenDirty = function (editor) { - return editor.getParam('save_enablewhendirty', true); - }; - var hasOnSaveCallback = function (editor) { - return !!editor.getParam('save_onsavecallback'); - }; - var hasOnCancelCallback = function (editor) { - return !!editor.getParam('save_oncancelcallback'); - }; - - var displayErrorMessage = function (editor, message) { - editor.notificationManager.open({ - text: message, - type: 'error' - }); - }; - var save = function (editor) { - var formObj = global$1.DOM.getParent(editor.id, 'form'); - if (enableWhenDirty(editor) && !editor.isDirty()) { - return; - } - editor.save(); - if (hasOnSaveCallback(editor)) { - editor.execCallback('save_onsavecallback', editor); - editor.nodeChanged(); - return; - } - if (formObj) { - editor.setDirty(false); - if (!formObj.onsubmit || formObj.onsubmit()) { - if (typeof formObj.submit === 'function') { - formObj.submit(); - } else { - displayErrorMessage(editor, 'Error: Form submit field collision.'); - } - } - editor.nodeChanged(); - } else { - displayErrorMessage(editor, 'Error: No form element found.'); - } - }; - var cancel = function (editor) { - var h = global.trim(editor.startContent); - if (hasOnCancelCallback(editor)) { - editor.execCallback('save_oncancelcallback', editor); - return; - } - editor.resetContent(h); - }; - - var register$1 = function (editor) { - editor.addCommand('mceSave', function () { - save(editor); - }); - editor.addCommand('mceCancel', function () { - cancel(editor); - }); - }; - - var stateToggle = function (editor) { - return function (api) { - var handler = function () { - api.setDisabled(enableWhenDirty(editor) && !editor.isDirty()); - }; - handler(); - editor.on('NodeChange dirty', handler); - return function () { - return editor.off('NodeChange dirty', handler); - }; - }; - }; - var register = function (editor) { - editor.ui.registry.addButton('save', { - icon: 'save', - tooltip: 'Save', - disabled: true, - onAction: function () { - return editor.execCommand('mceSave'); - }, - onSetup: stateToggle(editor) - }); - editor.ui.registry.addButton('cancel', { - icon: 'cancel', - tooltip: 'Cancel', - disabled: true, - onAction: function () { - return editor.execCommand('mceCancel'); - }, - onSetup: stateToggle(editor) - }); - editor.addShortcut('Meta+S', '', 'mceSave'); - }; - - function Plugin () { - global$2.add('save', function (editor) { - register(editor); - register$1(editor); - }); - } - - Plugin(); - -}()); - -/** - * Copyright (c) Tiny Technologies, Inc. All rights reserved. - * Licensed under the LGPL or a commercial license. - * For LGPL see License.txt in the project root for license information. - * For commercial licenses see https://www.tiny.cloud/ - * - * Version: 5.10.5 (2022-05-25) - */ -(function () { - 'use strict'; - - var global$3 = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - var unique = 0; - var generate = function (prefix) { - var date = new Date(); - var time = date.getTime(); - var random = Math.floor(Math.random() * 1000000000); - unique++; - return prefix + '_' + random + unique + String(time); - }; - - var createTableHtml = function (cols, rows) { - var html = ''; - html += ''; - for (var y = 0; y < rows; y++) { - html += ''; - for (var x = 0; x < cols; x++) { - html += ''; - } - html += ''; - } - html += ''; - html += '

'; - return html; - }; - var getInsertedElement = function (editor) { - var elms = editor.dom.select('*[data-mce-id]'); - return elms[0]; - }; - var insertTableHtml = function (editor, cols, rows) { - editor.undoManager.transact(function () { - editor.insertContent(createTableHtml(cols, rows)); - var tableElm = getInsertedElement(editor); - tableElm.removeAttribute('data-mce-id'); - var cellElm = editor.dom.select('td,th', tableElm); - editor.selection.setCursorLocation(cellElm[0], 0); - }); - }; - var insertTable = function (editor, cols, rows) { - editor.plugins.table ? editor.plugins.table.insertTable(cols, rows) : insertTableHtml(editor, cols, rows); - }; - var insertBlob = function (editor, base64, blob) { - var blobCache = editor.editorUpload.blobCache; - var blobInfo = blobCache.create(generate('mceu'), blob, base64); - blobCache.add(blobInfo); - editor.insertContent(editor.dom.createHTML('img', { src: blobInfo.blobUri() })); - }; - - var global$2 = tinymce.util.Tools.resolve('tinymce.util.Promise'); - - var blobToBase64 = function (blob) { - return new global$2(function (resolve) { - var reader = new FileReader(); - reader.onloadend = function () { - resolve(reader.result.split(',')[1]); - }; - reader.readAsDataURL(blob); - }); - }; - - var global$1 = tinymce.util.Tools.resolve('tinymce.Env'); - - var global = tinymce.util.Tools.resolve('tinymce.util.Delay'); - - var pickFile = function (editor) { - return new global$2(function (resolve) { - var fileInput = document.createElement('input'); - fileInput.type = 'file'; - fileInput.accept = 'image/*'; - fileInput.style.position = 'fixed'; - fileInput.style.left = '0'; - fileInput.style.top = '0'; - fileInput.style.opacity = '0.001'; - document.body.appendChild(fileInput); - var changeHandler = function (e) { - resolve(Array.prototype.slice.call(e.target.files)); - }; - fileInput.addEventListener('change', changeHandler); - var cancelHandler = function (e) { - var cleanup = function () { - resolve([]); - fileInput.parentNode.removeChild(fileInput); - }; - if (global$1.os.isAndroid() && e.type !== 'remove') { - global.setEditorTimeout(editor, cleanup, 0); - } else { - cleanup(); - } - editor.off('focusin remove', cancelHandler); - }; - editor.on('focusin remove', cancelHandler); - fileInput.click(); - }); - }; - - var setupButtons = function (editor) { - editor.ui.registry.addButton('quickimage', { - icon: 'image', - tooltip: 'Insert image', - onAction: function () { - pickFile(editor).then(function (files) { - if (files.length > 0) { - var blob_1 = files[0]; - blobToBase64(blob_1).then(function (base64) { - insertBlob(editor, base64, blob_1); - }); - } - }); - } - }); - editor.ui.registry.addButton('quicktable', { - icon: 'table', - tooltip: 'Insert table', - onAction: function () { - insertTable(editor, 2, 2); - } - }); - }; - - var typeOf = function (x) { - var t = typeof x; - if (x === null) { - return 'null'; - } else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) { - return 'array'; - } else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) { - return 'string'; - } else { - return t; - } - }; - var isType = function (type) { - return function (value) { - return typeOf(value) === type; - }; - }; - var isSimpleType = function (type) { - return function (value) { - return typeof value === type; - }; - }; - var eq = function (t) { - return function (a) { - return t === a; - }; - }; - var isString = isType('string'); - var isObject = isType('object'); - var isArray = isType('array'); - var isBoolean = isSimpleType('boolean'); - var isUndefined = eq(undefined); - var isFunction = isSimpleType('function'); - - var noop = function () { - }; - var constant = function (value) { - return function () { - return value; - }; - }; - var identity = function (x) { - return x; - }; - var never = constant(false); - var always = constant(true); - - var none = function () { - return NONE; - }; - var NONE = function () { - var call = function (thunk) { - return thunk(); - }; - var id = identity; - var me = { - fold: function (n, _s) { - return n(); - }, - isSome: never, - isNone: always, - getOr: id, - getOrThunk: call, - getOrDie: function (msg) { - throw new Error(msg || 'error: getOrDie called on none.'); - }, - getOrNull: constant(null), - getOrUndefined: constant(undefined), - or: id, - orThunk: call, - map: none, - each: noop, - bind: none, - exists: never, - forall: always, - filter: function () { - return none(); - }, - toArray: function () { - return []; - }, - toString: constant('none()') - }; - return me; - }(); - var some = function (a) { - var constant_a = constant(a); - var self = function () { - return me; - }; - var bind = function (f) { - return f(a); - }; - var me = { - fold: function (n, s) { - return s(a); - }, - isSome: always, - isNone: never, - getOr: constant_a, - getOrThunk: constant_a, - getOrDie: constant_a, - getOrNull: constant_a, - getOrUndefined: constant_a, - or: self, - orThunk: self, - map: function (f) { - return some(f(a)); - }, - each: function (f) { - f(a); - }, - bind: bind, - exists: bind, - forall: bind, - filter: function (f) { - return f(a) ? me : NONE; - }, - toArray: function () { - return [a]; - }, - toString: function () { - return 'some(' + a + ')'; - } - }; - return me; - }; - var from = function (value) { - return value === null || value === undefined ? NONE : some(value); - }; - var Optional = { - some: some, - none: none, - from: from - }; - - function ClosestOrAncestor (is, ancestor, scope, a, isRoot) { - if (is(scope, a)) { - return Optional.some(scope); - } else if (isFunction(isRoot) && isRoot(scope)) { - return Optional.none(); - } else { - return ancestor(scope, a, isRoot); - } - } - - var ELEMENT = 1; - - var fromHtml = function (html, scope) { - var doc = scope || document; - var div = doc.createElement('div'); - div.innerHTML = html; - if (!div.hasChildNodes() || div.childNodes.length > 1) { - console.error('HTML does not have a single root node', html); - throw new Error('HTML must have a single root node'); - } - return fromDom(div.childNodes[0]); - }; - var fromTag = function (tag, scope) { - var doc = scope || document; - var node = doc.createElement(tag); - return fromDom(node); - }; - var fromText = function (text, scope) { - var doc = scope || document; - var node = doc.createTextNode(text); - return fromDom(node); - }; - var fromDom = function (node) { - if (node === null || node === undefined) { - throw new Error('Node cannot be null or undefined'); - } - return { dom: node }; - }; - var fromPoint = function (docElm, x, y) { - return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom); - }; - var SugarElement = { - fromHtml: fromHtml, - fromTag: fromTag, - fromText: fromText, - fromDom: fromDom, - fromPoint: fromPoint - }; - - var is = function (element, selector) { - var dom = element.dom; - if (dom.nodeType !== ELEMENT) { - return false; - } else { - var elem = dom; - if (elem.matches !== undefined) { - return elem.matches(selector); - } else if (elem.msMatchesSelector !== undefined) { - return elem.msMatchesSelector(selector); - } else if (elem.webkitMatchesSelector !== undefined) { - return elem.webkitMatchesSelector(selector); - } else if (elem.mozMatchesSelector !== undefined) { - return elem.mozMatchesSelector(selector); - } else { - throw new Error('Browser lacks native selectors'); - } - } - }; - - typeof window !== 'undefined' ? window : Function('return this;')(); - - var name = function (element) { - var r = element.dom.nodeName; - return r.toLowerCase(); - }; - - var ancestor$1 = function (scope, predicate, isRoot) { - var element = scope.dom; - var stop = isFunction(isRoot) ? isRoot : never; - while (element.parentNode) { - element = element.parentNode; - var el = SugarElement.fromDom(element); - if (predicate(el)) { - return Optional.some(el); - } else if (stop(el)) { - break; - } - } - return Optional.none(); - }; - var closest$1 = function (scope, predicate, isRoot) { - var is = function (s, test) { - return test(s); - }; - return ClosestOrAncestor(is, ancestor$1, scope, predicate, isRoot); - }; - - var ancestor = function (scope, selector, isRoot) { - return ancestor$1(scope, function (e) { - return is(e, selector); - }, isRoot); - }; - var closest = function (scope, selector, isRoot) { - var is$1 = function (element, selector) { - return is(element, selector); - }; - return ClosestOrAncestor(is$1, ancestor, scope, selector, isRoot); - }; - - var validDefaultOrDie = function (value, predicate) { - if (predicate(value)) { - return true; - } - throw new Error('Default value doesn\'t match requested type.'); - }; - var items = function (value, defaultValue) { - if (isArray(value) || isObject(value)) { - throw new Error('expected a string but found: ' + value); - } - if (isUndefined(value)) { - return defaultValue; - } - if (isBoolean(value)) { - return value === false ? '' : defaultValue; - } - return value; - }; - var getToolbarItemsOr_ = function (predicate) { - return function (editor, name, defaultValue) { - validDefaultOrDie(defaultValue, predicate); - var value = editor.getParam(name, defaultValue); - return items(value, defaultValue); - }; - }; - var getToolbarItemsOr = getToolbarItemsOr_(isString); - - var getTextSelectionToolbarItems = function (editor) { - return getToolbarItemsOr(editor, 'quickbars_selection_toolbar', 'bold italic | quicklink h2 h3 blockquote'); - }; - var getInsertToolbarItems = function (editor) { - return getToolbarItemsOr(editor, 'quickbars_insert_toolbar', 'quickimage quicktable'); - }; - var getImageToolbarItems = function (editor) { - return getToolbarItemsOr(editor, 'quickbars_image_toolbar', 'alignleft aligncenter alignright'); - }; - - var addToEditor$1 = function (editor) { - var insertToolbarItems = getInsertToolbarItems(editor); - if (insertToolbarItems.trim().length > 0) { - editor.ui.registry.addContextToolbar('quickblock', { - predicate: function (node) { - var sugarNode = SugarElement.fromDom(node); - var textBlockElementsMap = editor.schema.getTextBlockElements(); - var isRoot = function (elem) { - return elem.dom === editor.getBody(); - }; - return closest(sugarNode, 'table', isRoot).fold(function () { - return closest$1(sugarNode, function (elem) { - return name(elem) in textBlockElementsMap && editor.dom.isEmpty(elem.dom); - }, isRoot).isSome(); - }, never); - }, - items: insertToolbarItems, - position: 'line', - scope: 'editor' - }); - } - }; - - var addToEditor = function (editor) { - var isEditable = function (node) { - return editor.dom.getContentEditableParent(node) !== 'false'; - }; - var isImage = function (node) { - return node.nodeName === 'IMG' || node.nodeName === 'FIGURE' && /image/i.test(node.className); - }; - var imageToolbarItems = getImageToolbarItems(editor); - if (imageToolbarItems.trim().length > 0) { - editor.ui.registry.addContextToolbar('imageselection', { - predicate: isImage, - items: imageToolbarItems, - position: 'node' - }); - } - var textToolbarItems = getTextSelectionToolbarItems(editor); - if (textToolbarItems.trim().length > 0) { - editor.ui.registry.addContextToolbar('textselection', { - predicate: function (node) { - return !isImage(node) && !editor.selection.isCollapsed() && isEditable(node); - }, - items: textToolbarItems, - position: 'selection', - scope: 'editor' - }); - } - }; - - function Plugin () { - global$3.add('quickbars', function (editor) { - setupButtons(editor); - addToEditor$1(editor); - addToEditor(editor); - }); - } - - Plugin(); - -}()); - -/** - * Copyright (c) Tiny Technologies, Inc. All rights reserved. - * Licensed under the LGPL or a commercial license. - * For LGPL see License.txt in the project root for license information. - * For commercial licenses see https://www.tiny.cloud/ - * - * Version: 5.10.5 (2022-05-25) - */ -(function () { - 'use strict'; - - var Cell = function (initial) { - var value = initial; - var get = function () { - return value; - }; - var set = function (v) { - value = v; - }; - return { - get: get, - set: set - }; - }; - - var global$3 = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - var __assign = function () { - __assign = Object.assign || function __assign(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) - if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); - }; - - var typeOf = function (x) { - var t = typeof x; - if (x === null) { - return 'null'; - } else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) { - return 'array'; - } else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) { - return 'string'; - } else { - return t; - } - }; - var isType$1 = function (type) { - return function (value) { - return typeOf(value) === type; - }; - }; - var isSimpleType = function (type) { - return function (value) { - return typeof value === type; - }; - }; - var isString = isType$1('string'); - var isArray = isType$1('array'); - var isBoolean = isSimpleType('boolean'); - var isNumber = isSimpleType('number'); - - var noop = function () { - }; - var constant = function (value) { - return function () { - return value; - }; - }; - var identity = function (x) { - return x; - }; - var never = constant(false); - var always = constant(true); - - var punctuationStr = '[!-#%-*,-\\/:;?@\\[-\\]_{}\xA1\xAB\xB7\xBB\xBF;\xB7\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1361-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u3008\u3009\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30\u2E31\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uff3f\uFF5B\uFF5D\uFF5F-\uFF65]'; - - var punctuation$1 = constant(punctuationStr); - - var none = function () { - return NONE; - }; - var NONE = function () { - var call = function (thunk) { - return thunk(); - }; - var id = identity; - var me = { - fold: function (n, _s) { - return n(); - }, - isSome: never, - isNone: always, - getOr: id, - getOrThunk: call, - getOrDie: function (msg) { - throw new Error(msg || 'error: getOrDie called on none.'); - }, - getOrNull: constant(null), - getOrUndefined: constant(undefined), - or: id, - orThunk: call, - map: none, - each: noop, - bind: none, - exists: never, - forall: always, - filter: function () { - return none(); - }, - toArray: function () { - return []; - }, - toString: constant('none()') - }; - return me; - }(); - var some = function (a) { - var constant_a = constant(a); - var self = function () { - return me; - }; - var bind = function (f) { - return f(a); - }; - var me = { - fold: function (n, s) { - return s(a); - }, - isSome: always, - isNone: never, - getOr: constant_a, - getOrThunk: constant_a, - getOrDie: constant_a, - getOrNull: constant_a, - getOrUndefined: constant_a, - or: self, - orThunk: self, - map: function (f) { - return some(f(a)); - }, - each: function (f) { - f(a); - }, - bind: bind, - exists: bind, - forall: bind, - filter: function (f) { - return f(a) ? me : NONE; - }, - toArray: function () { - return [a]; - }, - toString: function () { - return 'some(' + a + ')'; - } - }; - return me; - }; - var from = function (value) { - return value === null || value === undefined ? NONE : some(value); - }; - var Optional = { - some: some, - none: none, - from: from - }; - - var punctuation = punctuation$1; - - var global$2 = tinymce.util.Tools.resolve('tinymce.Env'); - - var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools'); - - var nativeSlice = Array.prototype.slice; - var nativePush = Array.prototype.push; - var map = function (xs, f) { - var len = xs.length; - var r = new Array(len); - for (var i = 0; i < len; i++) { - var x = xs[i]; - r[i] = f(x, i); - } - return r; - }; - var each = function (xs, f) { - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - f(x, i); - } - }; - var eachr = function (xs, f) { - for (var i = xs.length - 1; i >= 0; i--) { - var x = xs[i]; - f(x, i); - } - }; - var groupBy = function (xs, f) { - if (xs.length === 0) { - return []; - } else { - var wasType = f(xs[0]); - var r = []; - var group = []; - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - var type = f(x); - if (type !== wasType) { - r.push(group); - group = []; - } - wasType = type; - group.push(x); - } - if (group.length !== 0) { - r.push(group); - } - return r; - } - }; - var foldl = function (xs, f, acc) { - each(xs, function (x, i) { - acc = f(acc, x, i); - }); - return acc; - }; - var flatten = function (xs) { - var r = []; - for (var i = 0, len = xs.length; i < len; ++i) { - if (!isArray(xs[i])) { - throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs); - } - nativePush.apply(r, xs[i]); - } - return r; - }; - var bind = function (xs, f) { - return flatten(map(xs, f)); - }; - var sort = function (xs, comparator) { - var copy = nativeSlice.call(xs, 0); - copy.sort(comparator); - return copy; - }; - - var hasOwnProperty = Object.hasOwnProperty; - var has = function (obj, key) { - return hasOwnProperty.call(obj, key); - }; - - typeof window !== 'undefined' ? window : Function('return this;')(); - - var DOCUMENT = 9; - var DOCUMENT_FRAGMENT = 11; - var ELEMENT = 1; - var TEXT = 3; - - var type = function (element) { - return element.dom.nodeType; - }; - var isType = function (t) { - return function (element) { - return type(element) === t; - }; - }; - var isText$1 = isType(TEXT); - - var rawSet = function (dom, key, value) { - if (isString(value) || isBoolean(value) || isNumber(value)) { - dom.setAttribute(key, value + ''); - } else { - console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom); - throw new Error('Attribute value was not simple'); - } - }; - var set = function (element, key, value) { - rawSet(element.dom, key, value); - }; - - var compareDocumentPosition = function (a, b, match) { - return (a.compareDocumentPosition(b) & match) !== 0; - }; - var documentPositionPreceding = function (a, b) { - return compareDocumentPosition(a, b, Node.DOCUMENT_POSITION_PRECEDING); - }; - - var fromHtml = function (html, scope) { - var doc = scope || document; - var div = doc.createElement('div'); - div.innerHTML = html; - if (!div.hasChildNodes() || div.childNodes.length > 1) { - console.error('HTML does not have a single root node', html); - throw new Error('HTML must have a single root node'); - } - return fromDom(div.childNodes[0]); - }; - var fromTag = function (tag, scope) { - var doc = scope || document; - var node = doc.createElement(tag); - return fromDom(node); - }; - var fromText = function (text, scope) { - var doc = scope || document; - var node = doc.createTextNode(text); - return fromDom(node); - }; - var fromDom = function (node) { - if (node === null || node === undefined) { - throw new Error('Node cannot be null or undefined'); - } - return { dom: node }; - }; - var fromPoint = function (docElm, x, y) { - return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom); - }; - var SugarElement = { - fromHtml: fromHtml, - fromTag: fromTag, - fromText: fromText, - fromDom: fromDom, - fromPoint: fromPoint - }; - - var bypassSelector = function (dom) { - return dom.nodeType !== ELEMENT && dom.nodeType !== DOCUMENT && dom.nodeType !== DOCUMENT_FRAGMENT || dom.childElementCount === 0; - }; - var all = function (selector, scope) { - var base = scope === undefined ? document : scope.dom; - return bypassSelector(base) ? [] : map(base.querySelectorAll(selector), SugarElement.fromDom); - }; - - var parent = function (element) { - return Optional.from(element.dom.parentNode).map(SugarElement.fromDom); - }; - var children = function (element) { - return map(element.dom.childNodes, SugarElement.fromDom); - }; - var spot = function (element, offset) { - return { - element: element, - offset: offset - }; - }; - var leaf = function (element, offset) { - var cs = children(element); - return cs.length > 0 && offset < cs.length ? spot(cs[offset], 0) : spot(element, offset); - }; - - var before = function (marker, element) { - var parent$1 = parent(marker); - parent$1.each(function (v) { - v.dom.insertBefore(element.dom, marker.dom); - }); - }; - var append = function (parent, element) { - parent.dom.appendChild(element.dom); - }; - var wrap = function (element, wrapper) { - before(element, wrapper); - append(wrapper, element); - }; - - var NodeValue = function (is, name) { - var get = function (element) { - if (!is(element)) { - throw new Error('Can only get ' + name + ' value of a ' + name + ' node'); - } - return getOption(element).getOr(''); - }; - var getOption = function (element) { - return is(element) ? Optional.from(element.dom.nodeValue) : Optional.none(); - }; - var set = function (element, value) { - if (!is(element)) { - throw new Error('Can only set raw ' + name + ' value of a ' + name + ' node'); - } - element.dom.nodeValue = value; - }; - return { - get: get, - getOption: getOption, - set: set - }; - }; - - var api = NodeValue(isText$1, 'text'); - var get$1 = function (element) { - return api.get(element); - }; - - var descendants = function (scope, selector) { - return all(selector, scope); - }; - - var global = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker'); - - var isSimpleBoundary = function (dom, node) { - return dom.isBlock(node) || has(dom.schema.getShortEndedElements(), node.nodeName); - }; - var isContentEditableFalse = function (dom, node) { - return dom.getContentEditable(node) === 'false'; - }; - var isContentEditableTrueInCef = function (dom, node) { - return dom.getContentEditable(node) === 'true' && dom.getContentEditableParent(node.parentNode) === 'false'; - }; - var isHidden = function (dom, node) { - return !dom.isBlock(node) && has(dom.schema.getWhiteSpaceElements(), node.nodeName); - }; - var isBoundary = function (dom, node) { - return isSimpleBoundary(dom, node) || isContentEditableFalse(dom, node) || isHidden(dom, node) || isContentEditableTrueInCef(dom, node); - }; - var isText = function (node) { - return node.nodeType === 3; - }; - var nuSection = function () { - return { - sOffset: 0, - fOffset: 0, - elements: [] - }; - }; - var toLeaf = function (node, offset) { - return leaf(SugarElement.fromDom(node), offset); - }; - var walk = function (dom, walkerFn, startNode, callbacks, endNode, skipStart) { - if (skipStart === void 0) { - skipStart = true; - } - var next = skipStart ? walkerFn(false) : startNode; - while (next) { - var isCefNode = isContentEditableFalse(dom, next); - if (isCefNode || isHidden(dom, next)) { - var stopWalking = isCefNode ? callbacks.cef(next) : callbacks.boundary(next); - if (stopWalking) { - break; - } else { - next = walkerFn(true); - continue; - } - } else if (isSimpleBoundary(dom, next)) { - if (callbacks.boundary(next)) { - break; - } - } else if (isText(next)) { - callbacks.text(next); - } - if (next === endNode) { - break; - } else { - next = walkerFn(false); - } - } - }; - var collectTextToBoundary = function (dom, section, node, rootNode, forwards) { - if (isBoundary(dom, node)) { - return; - } - var rootBlock = dom.getParent(rootNode, dom.isBlock); - var walker = new global(node, rootBlock); - var walkerFn = forwards ? walker.next.bind(walker) : walker.prev.bind(walker); - walk(dom, walkerFn, node, { - boundary: always, - cef: always, - text: function (next) { - if (forwards) { - section.fOffset += next.length; - } else { - section.sOffset += next.length; - } - section.elements.push(SugarElement.fromDom(next)); - } - }); - }; - var collect = function (dom, rootNode, startNode, endNode, callbacks, skipStart) { - if (skipStart === void 0) { - skipStart = true; - } - var walker = new global(startNode, rootNode); - var sections = []; - var current = nuSection(); - collectTextToBoundary(dom, current, startNode, rootNode, false); - var finishSection = function () { - if (current.elements.length > 0) { - sections.push(current); - current = nuSection(); - } - return false; - }; - walk(dom, walker.next.bind(walker), startNode, { - boundary: finishSection, - cef: function (node) { - finishSection(); - if (callbacks) { - sections.push.apply(sections, callbacks.cef(node)); - } - return false; - }, - text: function (next) { - current.elements.push(SugarElement.fromDom(next)); - if (callbacks) { - callbacks.text(next, current); - } - } - }, endNode, skipStart); - if (endNode) { - collectTextToBoundary(dom, current, endNode, rootNode, true); - } - finishSection(); - return sections; - }; - var collectRangeSections = function (dom, rng) { - var start = toLeaf(rng.startContainer, rng.startOffset); - var startNode = start.element.dom; - var end = toLeaf(rng.endContainer, rng.endOffset); - var endNode = end.element.dom; - return collect(dom, rng.commonAncestorContainer, startNode, endNode, { - text: function (node, section) { - if (node === endNode) { - section.fOffset += node.length - end.offset; - } else if (node === startNode) { - section.sOffset += start.offset; - } - }, - cef: function (node) { - var sections = bind(descendants(SugarElement.fromDom(node), '*[contenteditable=true]'), function (e) { - var ceTrueNode = e.dom; - return collect(dom, ceTrueNode, ceTrueNode); - }); - return sort(sections, function (a, b) { - return documentPositionPreceding(a.elements[0].dom, b.elements[0].dom) ? 1 : -1; - }); - } - }, false); - }; - var fromRng = function (dom, rng) { - return rng.collapsed ? [] : collectRangeSections(dom, rng); - }; - var fromNode = function (dom, node) { - var rng = dom.createRng(); - rng.selectNode(node); - return fromRng(dom, rng); - }; - var fromNodes = function (dom, nodes) { - return bind(nodes, function (node) { - return fromNode(dom, node); - }); - }; - - var find$2 = function (text, pattern, start, finish) { - if (start === void 0) { - start = 0; - } - if (finish === void 0) { - finish = text.length; - } - var regex = pattern.regex; - regex.lastIndex = start; - var results = []; - var match; - while (match = regex.exec(text)) { - var matchedText = match[pattern.matchIndex]; - var matchStart = match.index + match[0].indexOf(matchedText); - var matchFinish = matchStart + matchedText.length; - if (matchFinish > finish) { - break; - } - results.push({ - start: matchStart, - finish: matchFinish - }); - regex.lastIndex = matchFinish; - } - return results; - }; - var extract = function (elements, matches) { - var nodePositions = foldl(elements, function (acc, element) { - var content = get$1(element); - var start = acc.last; - var finish = start + content.length; - var positions = bind(matches, function (match, matchIdx) { - if (match.start < finish && match.finish > start) { - return [{ - element: element, - start: Math.max(start, match.start) - start, - finish: Math.min(finish, match.finish) - start, - matchId: matchIdx - }]; - } else { - return []; - } - }); - return { - results: acc.results.concat(positions), - last: finish - }; - }, { - results: [], - last: 0 - }).results; - return groupBy(nodePositions, function (position) { - return position.matchId; - }); - }; - - var find$1 = function (pattern, sections) { - return bind(sections, function (section) { - var elements = section.elements; - var content = map(elements, get$1).join(''); - var positions = find$2(content, pattern, section.sOffset, content.length - section.fOffset); - return extract(elements, positions); - }); - }; - var mark = function (matches, replacementNode) { - eachr(matches, function (match, idx) { - eachr(match, function (pos) { - var wrapper = SugarElement.fromDom(replacementNode.cloneNode(false)); - set(wrapper, 'data-mce-index', idx); - var textNode = pos.element.dom; - if (textNode.length === pos.finish && pos.start === 0) { - wrap(pos.element, wrapper); - } else { - if (textNode.length !== pos.finish) { - textNode.splitText(pos.finish); - } - var matchNode = textNode.splitText(pos.start); - wrap(SugarElement.fromDom(matchNode), wrapper); - } - }); - }); - }; - var findAndMark = function (dom, pattern, node, replacementNode) { - var textSections = fromNode(dom, node); - var matches = find$1(pattern, textSections); - mark(matches, replacementNode); - return matches.length; - }; - var findAndMarkInSelection = function (dom, pattern, selection, replacementNode) { - var bookmark = selection.getBookmark(); - var nodes = dom.select('td[data-mce-selected],th[data-mce-selected]'); - var textSections = nodes.length > 0 ? fromNodes(dom, nodes) : fromRng(dom, selection.getRng()); - var matches = find$1(pattern, textSections); - mark(matches, replacementNode); - selection.moveToBookmark(bookmark); - return matches.length; - }; - - var getElmIndex = function (elm) { - var value = elm.getAttribute('data-mce-index'); - if (typeof value === 'number') { - return '' + value; - } - return value; - }; - var markAllMatches = function (editor, currentSearchState, pattern, inSelection) { - var marker = editor.dom.create('span', { 'data-mce-bogus': 1 }); - marker.className = 'mce-match-marker'; - var node = editor.getBody(); - done(editor, currentSearchState, false); - if (inSelection) { - return findAndMarkInSelection(editor.dom, pattern, editor.selection, marker); - } else { - return findAndMark(editor.dom, pattern, node, marker); - } - }; - var unwrap = function (node) { - var parentNode = node.parentNode; - if (node.firstChild) { - parentNode.insertBefore(node.firstChild, node); - } - node.parentNode.removeChild(node); - }; - var findSpansByIndex = function (editor, index) { - var spans = []; - var nodes = global$1.toArray(editor.getBody().getElementsByTagName('span')); - if (nodes.length) { - for (var i = 0; i < nodes.length; i++) { - var nodeIndex = getElmIndex(nodes[i]); - if (nodeIndex === null || !nodeIndex.length) { - continue; - } - if (nodeIndex === index.toString()) { - spans.push(nodes[i]); - } - } - } - return spans; - }; - var moveSelection = function (editor, currentSearchState, forward) { - var searchState = currentSearchState.get(); - var testIndex = searchState.index; - var dom = editor.dom; - forward = forward !== false; - if (forward) { - if (testIndex + 1 === searchState.count) { - testIndex = 0; - } else { - testIndex++; - } - } else { - if (testIndex - 1 === -1) { - testIndex = searchState.count - 1; - } else { - testIndex--; - } - } - dom.removeClass(findSpansByIndex(editor, searchState.index), 'mce-match-marker-selected'); - var spans = findSpansByIndex(editor, testIndex); - if (spans.length) { - dom.addClass(findSpansByIndex(editor, testIndex), 'mce-match-marker-selected'); - editor.selection.scrollIntoView(spans[0]); - return testIndex; - } - return -1; - }; - var removeNode = function (dom, node) { - var parent = node.parentNode; - dom.remove(node); - if (dom.isEmpty(parent)) { - dom.remove(parent); - } - }; - var escapeSearchText = function (text, wholeWord) { - var escapedText = text.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&').replace(/\s/g, '[^\\S\\r\\n\\uFEFF]'); - var wordRegex = '(' + escapedText + ')'; - return wholeWord ? '(?:^|\\s|' + punctuation() + ')' + wordRegex + ('(?=$|\\s|' + punctuation() + ')') : wordRegex; - }; - var find = function (editor, currentSearchState, text, matchCase, wholeWord, inSelection) { - var selection = editor.selection; - var escapedText = escapeSearchText(text, wholeWord); - var isForwardSelection = selection.isForward(); - var pattern = { - regex: new RegExp(escapedText, matchCase ? 'g' : 'gi'), - matchIndex: 1 - }; - var count = markAllMatches(editor, currentSearchState, pattern, inSelection); - if (global$2.browser.isSafari()) { - selection.setRng(selection.getRng(), isForwardSelection); - } - if (count) { - var newIndex = moveSelection(editor, currentSearchState, true); - currentSearchState.set({ - index: newIndex, - count: count, - text: text, - matchCase: matchCase, - wholeWord: wholeWord, - inSelection: inSelection - }); - } - return count; - }; - var next = function (editor, currentSearchState) { - var index = moveSelection(editor, currentSearchState, true); - currentSearchState.set(__assign(__assign({}, currentSearchState.get()), { index: index })); - }; - var prev = function (editor, currentSearchState) { - var index = moveSelection(editor, currentSearchState, false); - currentSearchState.set(__assign(__assign({}, currentSearchState.get()), { index: index })); - }; - var isMatchSpan = function (node) { - var matchIndex = getElmIndex(node); - return matchIndex !== null && matchIndex.length > 0; - }; - var replace = function (editor, currentSearchState, text, forward, all) { - var searchState = currentSearchState.get(); - var currentIndex = searchState.index; - var currentMatchIndex, nextIndex = currentIndex; - forward = forward !== false; - var node = editor.getBody(); - var nodes = global$1.grep(global$1.toArray(node.getElementsByTagName('span')), isMatchSpan); - for (var i = 0; i < nodes.length; i++) { - var nodeIndex = getElmIndex(nodes[i]); - var matchIndex = currentMatchIndex = parseInt(nodeIndex, 10); - if (all || matchIndex === searchState.index) { - if (text.length) { - nodes[i].firstChild.nodeValue = text; - unwrap(nodes[i]); - } else { - removeNode(editor.dom, nodes[i]); - } - while (nodes[++i]) { - matchIndex = parseInt(getElmIndex(nodes[i]), 10); - if (matchIndex === currentMatchIndex) { - removeNode(editor.dom, nodes[i]); - } else { - i--; - break; - } - } - if (forward) { - nextIndex--; - } - } else if (currentMatchIndex > currentIndex) { - nodes[i].setAttribute('data-mce-index', String(currentMatchIndex - 1)); - } - } - currentSearchState.set(__assign(__assign({}, searchState), { - count: all ? 0 : searchState.count - 1, - index: nextIndex - })); - if (forward) { - next(editor, currentSearchState); - } else { - prev(editor, currentSearchState); - } - return !all && currentSearchState.get().count > 0; - }; - var done = function (editor, currentSearchState, keepEditorSelection) { - var startContainer, endContainer; - var searchState = currentSearchState.get(); - var nodes = global$1.toArray(editor.getBody().getElementsByTagName('span')); - for (var i = 0; i < nodes.length; i++) { - var nodeIndex = getElmIndex(nodes[i]); - if (nodeIndex !== null && nodeIndex.length) { - if (nodeIndex === searchState.index.toString()) { - if (!startContainer) { - startContainer = nodes[i].firstChild; - } - endContainer = nodes[i].firstChild; - } - unwrap(nodes[i]); - } - } - currentSearchState.set(__assign(__assign({}, searchState), { - index: -1, - count: 0, - text: '' - })); - if (startContainer && endContainer) { - var rng = editor.dom.createRng(); - rng.setStart(startContainer, 0); - rng.setEnd(endContainer, endContainer.data.length); - if (keepEditorSelection !== false) { - editor.selection.setRng(rng); - } - return rng; - } - }; - var hasNext = function (editor, currentSearchState) { - return currentSearchState.get().count > 1; - }; - var hasPrev = function (editor, currentSearchState) { - return currentSearchState.get().count > 1; - }; - - var get = function (editor, currentState) { - var done$1 = function (keepEditorSelection) { - return done(editor, currentState, keepEditorSelection); - }; - var find$1 = function (text, matchCase, wholeWord, inSelection) { - if (inSelection === void 0) { - inSelection = false; - } - return find(editor, currentState, text, matchCase, wholeWord, inSelection); - }; - var next$1 = function () { - return next(editor, currentState); - }; - var prev$1 = function () { - return prev(editor, currentState); - }; - var replace$1 = function (text, forward, all) { - return replace(editor, currentState, text, forward, all); - }; - return { - done: done$1, - find: find$1, - next: next$1, - prev: prev$1, - replace: replace$1 - }; - }; - - var singleton = function (doRevoke) { - var subject = Cell(Optional.none()); - var revoke = function () { - return subject.get().each(doRevoke); - }; - var clear = function () { - revoke(); - subject.set(Optional.none()); - }; - var isSet = function () { - return subject.get().isSome(); - }; - var get = function () { - return subject.get(); - }; - var set = function (s) { - revoke(); - subject.set(Optional.some(s)); - }; - return { - clear: clear, - isSet: isSet, - get: get, - set: set - }; - }; - var value = function () { - var subject = singleton(noop); - var on = function (f) { - return subject.get().each(f); - }; - return __assign(__assign({}, subject), { on: on }); - }; - - var open = function (editor, currentSearchState) { - var dialogApi = value(); - editor.undoManager.add(); - var selectedText = global$1.trim(editor.selection.getContent({ format: 'text' })); - var updateButtonStates = function (api) { - var updateNext = hasNext(editor, currentSearchState) ? api.enable : api.disable; - updateNext('next'); - var updatePrev = hasPrev(editor, currentSearchState) ? api.enable : api.disable; - updatePrev('prev'); - }; - var updateSearchState = function (api) { - var data = api.getData(); - var current = currentSearchState.get(); - currentSearchState.set(__assign(__assign({}, current), { - matchCase: data.matchcase, - wholeWord: data.wholewords, - inSelection: data.inselection - })); - }; - var disableAll = function (api, disable) { - var buttons = [ - 'replace', - 'replaceall', - 'prev', - 'next' - ]; - var toggle = disable ? api.disable : api.enable; - each(buttons, toggle); - }; - var notFoundAlert = function (api) { - editor.windowManager.alert('Could not find the specified string.', function () { - api.focus('findtext'); - }); - }; - var focusButtonIfRequired = function (api, name) { - if (global$2.browser.isSafari() && global$2.deviceType.isTouch() && (name === 'find' || name === 'replace' || name === 'replaceall')) { - api.focus(name); - } - }; - var reset = function (api) { - done(editor, currentSearchState, false); - disableAll(api, true); - updateButtonStates(api); - }; - var doFind = function (api) { - var data = api.getData(); - var last = currentSearchState.get(); - if (!data.findtext.length) { - reset(api); - return; - } - if (last.text === data.findtext && last.matchCase === data.matchcase && last.wholeWord === data.wholewords) { - next(editor, currentSearchState); - } else { - var count = find(editor, currentSearchState, data.findtext, data.matchcase, data.wholewords, data.inselection); - if (count <= 0) { - notFoundAlert(api); - } - disableAll(api, count === 0); - } - updateButtonStates(api); - }; - var initialState = currentSearchState.get(); - var initialData = { - findtext: selectedText, - replacetext: '', - wholewords: initialState.wholeWord, - matchcase: initialState.matchCase, - inselection: initialState.inSelection - }; - var spec = { - title: 'Find and Replace', - size: 'normal', - body: { - type: 'panel', - items: [ - { - type: 'bar', - items: [ - { - type: 'input', - name: 'findtext', - placeholder: 'Find', - maximized: true, - inputMode: 'search' - }, - { - type: 'button', - name: 'prev', - text: 'Previous', - icon: 'action-prev', - disabled: true, - borderless: true - }, - { - type: 'button', - name: 'next', - text: 'Next', - icon: 'action-next', - disabled: true, - borderless: true - } - ] - }, - { - type: 'input', - name: 'replacetext', - placeholder: 'Replace with', - inputMode: 'search' - } - ] - }, - buttons: [ - { - type: 'menu', - name: 'options', - icon: 'preferences', - tooltip: 'Preferences', - align: 'start', - items: [ - { - type: 'togglemenuitem', - name: 'matchcase', - text: 'Match case' - }, - { - type: 'togglemenuitem', - name: 'wholewords', - text: 'Find whole words only' - }, - { - type: 'togglemenuitem', - name: 'inselection', - text: 'Find in selection' - } - ] - }, - { - type: 'custom', - name: 'find', - text: 'Find', - primary: true - }, - { - type: 'custom', - name: 'replace', - text: 'Replace', - disabled: true - }, - { - type: 'custom', - name: 'replaceall', - text: 'Replace all', - disabled: true - } - ], - initialData: initialData, - onChange: function (api, details) { - if (details.name === 'findtext' && currentSearchState.get().count > 0) { - reset(api); - } - }, - onAction: function (api, details) { - var data = api.getData(); - switch (details.name) { - case 'find': - doFind(api); - break; - case 'replace': - if (!replace(editor, currentSearchState, data.replacetext)) { - reset(api); - } else { - updateButtonStates(api); - } - break; - case 'replaceall': - replace(editor, currentSearchState, data.replacetext, true, true); - reset(api); - break; - case 'prev': - prev(editor, currentSearchState); - updateButtonStates(api); - break; - case 'next': - next(editor, currentSearchState); - updateButtonStates(api); - break; - case 'matchcase': - case 'wholewords': - case 'inselection': - updateSearchState(api); - reset(api); - break; - } - focusButtonIfRequired(api, details.name); - }, - onSubmit: function (api) { - doFind(api); - focusButtonIfRequired(api, 'find'); - }, - onClose: function () { - editor.focus(); - done(editor, currentSearchState); - editor.undoManager.add(); - } - }; - dialogApi.set(editor.windowManager.open(spec, { inline: 'toolbar' })); - }; - - var register$1 = function (editor, currentSearchState) { - editor.addCommand('SearchReplace', function () { - open(editor, currentSearchState); - }); - }; - - var showDialog = function (editor, currentSearchState) { - return function () { - open(editor, currentSearchState); - }; - }; - var register = function (editor, currentSearchState) { - editor.ui.registry.addMenuItem('searchreplace', { - text: 'Find and replace...', - shortcut: 'Meta+F', - onAction: showDialog(editor, currentSearchState), - icon: 'search' - }); - editor.ui.registry.addButton('searchreplace', { - tooltip: 'Find and replace', - onAction: showDialog(editor, currentSearchState), - icon: 'search' - }); - editor.shortcuts.add('Meta+F', '', showDialog(editor, currentSearchState)); - }; - - function Plugin () { - global$3.add('searchreplace', function (editor) { - var currentSearchState = Cell({ - index: -1, - count: 0, - text: '', - matchCase: false, - wholeWord: false, - inSelection: false - }); - register$1(editor, currentSearchState); - register(editor, currentSearchState); - return get(editor, currentSearchState); - }); - } - - Plugin(); - -}()); - -/** - * Copyright (c) Tiny Technologies, Inc. All rights reserved. - * Licensed under the LGPL or a commercial license. - * For LGPL see License.txt in the project root for license information. - * For commercial licenses see https://www.tiny.cloud/ - * - * Version: 5.10.5 (2022-05-25) - */ -(function () { - 'use strict'; - - var Cell = function (initial) { - var value = initial; - var get = function () { - return value; - }; - var set = function (v) { - value = v; - }; - return { - get: get, - set: set - }; - }; - - var global$3 = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - var hasProPlugin = function (editor) { - if (editor.hasPlugin('tinymcespellchecker', true)) { - if (typeof window.console !== 'undefined' && window.console.log) { - window.console.log('Spell Checker Pro is incompatible with Spell Checker plugin! ' + 'Remove \'spellchecker\' from the \'plugins\' option.'); - } - return true; - } else { - return false; - } - }; - - var hasOwnProperty = Object.hasOwnProperty; - var isEmpty = function (r) { - for (var x in r) { - if (hasOwnProperty.call(r, x)) { - return false; - } - } - return true; - }; - - var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools'); - - var global$1 = tinymce.util.Tools.resolve('tinymce.util.URI'); - - var global = tinymce.util.Tools.resolve('tinymce.util.XHR'); - - var fireSpellcheckStart = function (editor) { - return editor.fire('SpellcheckStart'); - }; - var fireSpellcheckEnd = function (editor) { - return editor.fire('SpellcheckEnd'); - }; - - var getLanguages = function (editor) { - var defaultLanguages = 'English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr_FR,German=de,Italian=it,Polish=pl,Portuguese=pt_BR,Spanish=es,Swedish=sv'; - return editor.getParam('spellchecker_languages', defaultLanguages); - }; - var getLanguage = function (editor) { - var defaultLanguage = editor.getParam('language', 'en'); - return editor.getParam('spellchecker_language', defaultLanguage); - }; - var getRpcUrl = function (editor) { - return editor.getParam('spellchecker_rpc_url'); - }; - var getSpellcheckerCallback = function (editor) { - return editor.getParam('spellchecker_callback'); - }; - var getSpellcheckerWordcharPattern = function (editor) { - var defaultPattern = new RegExp('[^' + '\\s!"#$%&()*+,-./:;<=>?@[\\]^_{|}`' + '\xA7\xA9\xAB\xAE\xB1\xB6\xB7\xB8\xBB' + '\xBC\xBD\xBE\xBF\xD7\xF7\xA4\u201D\u201C\u201E\xA0\u2002\u2003\u2009' + ']+', 'g'); - return editor.getParam('spellchecker_wordchar_pattern', defaultPattern); - }; - - var isContentEditableFalse = function (node) { - return node && node.nodeType === 1 && node.contentEditable === 'false'; - }; - var DomTextMatcher = function (node, editor) { - var m, matches = []; - var dom = editor.dom; - var blockElementsMap = editor.schema.getBlockElements(); - var hiddenTextElementsMap = editor.schema.getWhiteSpaceElements(); - var shortEndedElementsMap = editor.schema.getShortEndedElements(); - var createMatch = function (m, data) { - if (!m[0]) { - throw new Error('findAndReplaceDOMText cannot handle zero-length matches'); - } - return { - start: m.index, - end: m.index + m[0].length, - text: m[0], - data: data - }; - }; - var getText = function (node) { - if (node.nodeType === 3) { - return node.data; - } - if (hiddenTextElementsMap[node.nodeName] && !blockElementsMap[node.nodeName]) { - return ''; - } - if (isContentEditableFalse(node)) { - return '\n'; - } - var txt = ''; - if (blockElementsMap[node.nodeName] || shortEndedElementsMap[node.nodeName]) { - txt += '\n'; - } - if (node = node.firstChild) { - do { - txt += getText(node); - } while (node = node.nextSibling); - } - return txt; - }; - var stepThroughMatches = function (node, matches, replaceFn) { - var startNode, endNode, startNodeIndex, endNodeIndex, innerNodes = [], atIndex = 0, curNode = node, matchLocation, matchIndex = 0; - matches = matches.slice(0); - matches.sort(function (a, b) { - return a.start - b.start; - }); - matchLocation = matches.shift(); - out: - while (true) { - if (blockElementsMap[curNode.nodeName] || shortEndedElementsMap[curNode.nodeName] || isContentEditableFalse(curNode)) { - atIndex++; - } - if (curNode.nodeType === 3) { - if (!endNode && curNode.length + atIndex >= matchLocation.end) { - endNode = curNode; - endNodeIndex = matchLocation.end - atIndex; - } else if (startNode) { - innerNodes.push(curNode); - } - if (!startNode && curNode.length + atIndex > matchLocation.start) { - startNode = curNode; - startNodeIndex = matchLocation.start - atIndex; - } - atIndex += curNode.length; - } - if (startNode && endNode) { - curNode = replaceFn({ - startNode: startNode, - startNodeIndex: startNodeIndex, - endNode: endNode, - endNodeIndex: endNodeIndex, - innerNodes: innerNodes, - match: matchLocation.text, - matchIndex: matchIndex - }); - atIndex -= endNode.length - endNodeIndex; - startNode = null; - endNode = null; - innerNodes = []; - matchLocation = matches.shift(); - matchIndex++; - if (!matchLocation) { - break; - } - } else if ((!hiddenTextElementsMap[curNode.nodeName] || blockElementsMap[curNode.nodeName]) && curNode.firstChild) { - if (!isContentEditableFalse(curNode)) { - curNode = curNode.firstChild; - continue; - } - } else if (curNode.nextSibling) { - curNode = curNode.nextSibling; - continue; - } - while (true) { - if (curNode.nextSibling) { - curNode = curNode.nextSibling; - break; - } else if (curNode.parentNode !== node) { - curNode = curNode.parentNode; - } else { - break out; - } - } - } - }; - var genReplacer = function (callback) { - var makeReplacementNode = function (fill, matchIndex) { - var match = matches[matchIndex]; - if (!match.stencil) { - match.stencil = callback(match); - } - var clone = match.stencil.cloneNode(false); - clone.setAttribute('data-mce-index', '' + matchIndex); - if (fill) { - clone.appendChild(dom.doc.createTextNode(fill)); - } - return clone; - }; - return function (range) { - var before; - var after; - var parentNode; - var startNode = range.startNode; - var endNode = range.endNode; - var matchIndex = range.matchIndex; - var doc = dom.doc; - if (startNode === endNode) { - var node_1 = startNode; - parentNode = node_1.parentNode; - if (range.startNodeIndex > 0) { - before = doc.createTextNode(node_1.data.substring(0, range.startNodeIndex)); - parentNode.insertBefore(before, node_1); - } - var el = makeReplacementNode(range.match, matchIndex); - parentNode.insertBefore(el, node_1); - if (range.endNodeIndex < node_1.length) { - after = doc.createTextNode(node_1.data.substring(range.endNodeIndex)); - parentNode.insertBefore(after, node_1); - } - node_1.parentNode.removeChild(node_1); - return el; - } - before = doc.createTextNode(startNode.data.substring(0, range.startNodeIndex)); - after = doc.createTextNode(endNode.data.substring(range.endNodeIndex)); - var elA = makeReplacementNode(startNode.data.substring(range.startNodeIndex), matchIndex); - for (var i = 0, l = range.innerNodes.length; i < l; ++i) { - var innerNode = range.innerNodes[i]; - var innerEl = makeReplacementNode(innerNode.data, matchIndex); - innerNode.parentNode.replaceChild(innerEl, innerNode); - } - var elB = makeReplacementNode(endNode.data.substring(0, range.endNodeIndex), matchIndex); - parentNode = startNode.parentNode; - parentNode.insertBefore(before, startNode); - parentNode.insertBefore(elA, startNode); - parentNode.removeChild(startNode); - parentNode = endNode.parentNode; - parentNode.insertBefore(elB, endNode); - parentNode.insertBefore(after, endNode); - parentNode.removeChild(endNode); - return elB; - }; - }; - var unwrapElement = function (element) { - var parentNode = element.parentNode; - while (element.childNodes.length > 0) { - parentNode.insertBefore(element.childNodes[0], element); - } - parentNode.removeChild(element); - }; - var hasClass = function (elm) { - return elm.className.indexOf('mce-spellchecker-word') !== -1; - }; - var getWrappersByIndex = function (index) { - var elements = node.getElementsByTagName('*'), wrappers = []; - index = typeof index === 'number' ? '' + index : null; - for (var i = 0; i < elements.length; i++) { - var element = elements[i], dataIndex = element.getAttribute('data-mce-index'); - if (dataIndex !== null && dataIndex.length && hasClass(element)) { - if (dataIndex === index || index === null) { - wrappers.push(element); - } - } - } - return wrappers; - }; - var indexOf = function (match) { - var i = matches.length; - while (i--) { - if (matches[i] === match) { - return i; - } - } - return -1; - }; - function filter(callback) { - var filteredMatches = []; - each(function (match, i) { - if (callback(match, i)) { - filteredMatches.push(match); - } - }); - matches = filteredMatches; - return this; - } - function each(callback) { - for (var i = 0, l = matches.length; i < l; i++) { - if (callback(matches[i], i) === false) { - break; - } - } - return this; - } - function wrap(callback) { - if (matches.length) { - stepThroughMatches(node, matches, genReplacer(callback)); - } - return this; - } - function find(regex, data) { - if (text && regex.global) { - while (m = regex.exec(text)) { - matches.push(createMatch(m, data)); - } - } - return this; - } - function unwrap(match) { - var i; - var elements = getWrappersByIndex(match ? indexOf(match) : null); - i = elements.length; - while (i--) { - unwrapElement(elements[i]); - } - return this; - } - var matchFromElement = function (element) { - return matches[element.getAttribute('data-mce-index')]; - }; - var elementFromMatch = function (match) { - return getWrappersByIndex(indexOf(match))[0]; - }; - function add(start, length, data) { - matches.push({ - start: start, - end: start + length, - text: text.substr(start, length), - data: data - }); - return this; - } - var rangeFromMatch = function (match) { - var wrappers = getWrappersByIndex(indexOf(match)); - var rng = editor.dom.createRng(); - rng.setStartBefore(wrappers[0]); - rng.setEndAfter(wrappers[wrappers.length - 1]); - return rng; - }; - var replace = function (match, text) { - var rng = rangeFromMatch(match); - rng.deleteContents(); - if (text.length > 0) { - rng.insertNode(editor.dom.doc.createTextNode(text)); - } - return rng; - }; - function reset() { - matches.splice(0, matches.length); - unwrap(); - return this; - } - var text = getText(node); - return { - text: text, - matches: matches, - each: each, - filter: filter, - reset: reset, - matchFromElement: matchFromElement, - elementFromMatch: elementFromMatch, - find: find, - add: add, - wrap: wrap, - unwrap: unwrap, - replace: replace, - rangeFromMatch: rangeFromMatch, - indexOf: indexOf - }; - }; - - var getTextMatcher = function (editor, textMatcherState) { - if (!textMatcherState.get()) { - var textMatcher = DomTextMatcher(editor.getBody(), editor); - textMatcherState.set(textMatcher); - } - return textMatcherState.get(); - }; - var defaultSpellcheckCallback = function (editor, pluginUrl, currentLanguageState) { - return function (method, text, doneCallback, errorCallback) { - var data = { - method: method, - lang: currentLanguageState.get() - }; - var postData = ''; - data[method === 'addToDictionary' ? 'word' : 'text'] = text; - global$2.each(data, function (value, key) { - if (postData) { - postData += '&'; - } - postData += key + '=' + encodeURIComponent(value); - }); - global.send({ - url: new global$1(pluginUrl).toAbsolute(getRpcUrl(editor)), - type: 'post', - content_type: 'application/x-www-form-urlencoded', - data: postData, - success: function (result) { - var parseResult = JSON.parse(result); - if (!parseResult) { - var message = editor.translate('Server response wasn\'t proper JSON.'); - errorCallback(message); - } else if (parseResult.error) { - errorCallback(parseResult.error); - } else { - doneCallback(parseResult); - } - }, - error: function () { - var message = editor.translate('The spelling service was not found: (') + getRpcUrl(editor) + editor.translate(')'); - errorCallback(message); - } - }); - }; - }; - var sendRpcCall = function (editor, pluginUrl, currentLanguageState, name, data, successCallback, errorCallback) { - var userSpellcheckCallback = getSpellcheckerCallback(editor); - var spellCheckCallback = userSpellcheckCallback ? userSpellcheckCallback : defaultSpellcheckCallback(editor, pluginUrl, currentLanguageState); - spellCheckCallback.call(editor.plugins.spellchecker, name, data, successCallback, errorCallback); - }; - var spellcheck = function (editor, pluginUrl, startedState, textMatcherState, lastSuggestionsState, currentLanguageState) { - if (finish(editor, startedState, textMatcherState)) { - return; - } - var errorCallback = function (message) { - editor.notificationManager.open({ - text: message, - type: 'error' - }); - editor.setProgressState(false); - finish(editor, startedState, textMatcherState); - }; - var successCallback = function (data) { - markErrors(editor, startedState, textMatcherState, lastSuggestionsState, data); - }; - editor.setProgressState(true); - sendRpcCall(editor, pluginUrl, currentLanguageState, 'spellcheck', getTextMatcher(editor, textMatcherState).text, successCallback, errorCallback); - editor.focus(); - }; - var checkIfFinished = function (editor, startedState, textMatcherState) { - if (!editor.dom.select('span.mce-spellchecker-word').length) { - finish(editor, startedState, textMatcherState); - } - }; - var addToDictionary = function (editor, pluginUrl, startedState, textMatcherState, currentLanguageState, word, spans) { - editor.setProgressState(true); - sendRpcCall(editor, pluginUrl, currentLanguageState, 'addToDictionary', word, function () { - editor.setProgressState(false); - editor.dom.remove(spans, true); - checkIfFinished(editor, startedState, textMatcherState); - }, function (message) { - editor.notificationManager.open({ - text: message, - type: 'error' - }); - editor.setProgressState(false); - }); - }; - var ignoreWord = function (editor, startedState, textMatcherState, word, spans, all) { - editor.selection.collapse(); - if (all) { - global$2.each(editor.dom.select('span.mce-spellchecker-word'), function (span) { - if (span.getAttribute('data-mce-word') === word) { - editor.dom.remove(span, true); - } - }); - } else { - editor.dom.remove(spans, true); - } - checkIfFinished(editor, startedState, textMatcherState); - }; - var finish = function (editor, startedState, textMatcherState) { - var bookmark = editor.selection.getBookmark(); - getTextMatcher(editor, textMatcherState).reset(); - editor.selection.moveToBookmark(bookmark); - textMatcherState.set(null); - if (startedState.get()) { - startedState.set(false); - fireSpellcheckEnd(editor); - return true; - } - }; - var getElmIndex = function (elm) { - var value = elm.getAttribute('data-mce-index'); - if (typeof value === 'number') { - return '' + value; - } - return value; - }; - var findSpansByIndex = function (editor, index) { - var spans = []; - var nodes = global$2.toArray(editor.getBody().getElementsByTagName('span')); - if (nodes.length) { - for (var i = 0; i < nodes.length; i++) { - var nodeIndex = getElmIndex(nodes[i]); - if (nodeIndex === null || !nodeIndex.length) { - continue; - } - if (nodeIndex === index.toString()) { - spans.push(nodes[i]); - } - } - } - return spans; - }; - var markErrors = function (editor, startedState, textMatcherState, lastSuggestionsState, data) { - var hasDictionarySupport = !!data.dictionary; - var suggestions = data.words; - editor.setProgressState(false); - if (isEmpty(suggestions)) { - var message = editor.translate('No misspellings found.'); - editor.notificationManager.open({ - text: message, - type: 'info' - }); - startedState.set(false); - return; - } - lastSuggestionsState.set({ - suggestions: suggestions, - hasDictionarySupport: hasDictionarySupport - }); - var bookmark = editor.selection.getBookmark(); - getTextMatcher(editor, textMatcherState).find(getSpellcheckerWordcharPattern(editor)).filter(function (match) { - return !!suggestions[match.text]; - }).wrap(function (match) { - return editor.dom.create('span', { - 'class': 'mce-spellchecker-word', - 'aria-invalid': 'spelling', - 'data-mce-bogus': 1, - 'data-mce-word': match.text - }); - }); - editor.selection.moveToBookmark(bookmark); - startedState.set(true); - fireSpellcheckStart(editor); - }; - - var get = function (editor, startedState, lastSuggestionsState, textMatcherState, currentLanguageState) { - var getWordCharPattern = function () { - return getSpellcheckerWordcharPattern(editor); - }; - var markErrors$1 = function (data) { - markErrors(editor, startedState, textMatcherState, lastSuggestionsState, data); - }; - return { - getTextMatcher: textMatcherState.get, - getWordCharPattern: getWordCharPattern, - markErrors: markErrors$1, - getLanguage: currentLanguageState.get - }; - }; - - var register$1 = function (editor, pluginUrl, startedState, textMatcherState, lastSuggestionsState, currentLanguageState) { - editor.addCommand('mceSpellCheck', function () { - spellcheck(editor, pluginUrl, startedState, textMatcherState, lastSuggestionsState, currentLanguageState); - }); - }; - - var __assign = function () { - __assign = Object.assign || function __assign(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) - if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); - }; - - var spellcheckerEvents = 'SpellcheckStart SpellcheckEnd'; - var buildMenuItems = function (listName, languageValues) { - var items = []; - global$2.each(languageValues, function (languageValue) { - items.push({ - selectable: true, - text: languageValue.name, - data: languageValue.value - }); - }); - return items; - }; - var getItems = function (editor) { - return global$2.map(getLanguages(editor).split(','), function (langPair) { - var langPairs = langPair.split('='); - return { - name: langPairs[0], - value: langPairs[1] - }; - }); - }; - var register = function (editor, pluginUrl, startedState, textMatcherState, currentLanguageState, lastSuggestionsState) { - var languageMenuItems = buildMenuItems('Language', getItems(editor)); - var startSpellchecking = function () { - spellcheck(editor, pluginUrl, startedState, textMatcherState, lastSuggestionsState, currentLanguageState); - }; - var buttonArgs = { - tooltip: 'Spellcheck', - onAction: startSpellchecking, - icon: 'spell-check', - onSetup: function (buttonApi) { - var setButtonState = function () { - buttonApi.setActive(startedState.get()); - }; - editor.on(spellcheckerEvents, setButtonState); - return function () { - editor.off(spellcheckerEvents, setButtonState); - }; - } - }; - var splitButtonArgs = __assign(__assign({}, buttonArgs), { - type: 'splitbutton', - select: function (value) { - return value === currentLanguageState.get(); - }, - fetch: function (callback) { - var items = global$2.map(languageMenuItems, function (languageItem) { - return { - type: 'choiceitem', - value: languageItem.data, - text: languageItem.text - }; - }); - callback(items); - }, - onItemAction: function (splitButtonApi, value) { - currentLanguageState.set(value); - } - }); - if (languageMenuItems.length > 1) { - editor.ui.registry.addSplitButton('spellchecker', splitButtonArgs); - } else { - editor.ui.registry.addToggleButton('spellchecker', buttonArgs); - } - editor.ui.registry.addToggleMenuItem('spellchecker', { - text: 'Spellcheck', - icon: 'spell-check', - onSetup: function (menuApi) { - menuApi.setActive(startedState.get()); - var setMenuItemCheck = function () { - menuApi.setActive(startedState.get()); - }; - editor.on(spellcheckerEvents, setMenuItemCheck); - return function () { - editor.off(spellcheckerEvents, setMenuItemCheck); - }; - }, - onAction: startSpellchecking - }); - }; - - var ignoreAll = true; - var getSuggestions = function (editor, pluginUrl, lastSuggestionsState, startedState, textMatcherState, currentLanguageState, word, spans) { - var items = []; - var suggestions = lastSuggestionsState.get().suggestions[word]; - global$2.each(suggestions, function (suggestion) { - items.push({ - text: suggestion, - onAction: function () { - editor.insertContent(editor.dom.encode(suggestion)); - editor.dom.remove(spans); - checkIfFinished(editor, startedState, textMatcherState); - } - }); - }); - var hasDictionarySupport = lastSuggestionsState.get().hasDictionarySupport; - if (hasDictionarySupport) { - items.push({ type: 'separator' }); - items.push({ - text: 'Add to dictionary', - onAction: function () { - addToDictionary(editor, pluginUrl, startedState, textMatcherState, currentLanguageState, word, spans); - } - }); - } - items.push.apply(items, [ - { type: 'separator' }, - { - text: 'Ignore', - onAction: function () { - ignoreWord(editor, startedState, textMatcherState, word, spans); - } - }, - { - text: 'Ignore all', - onAction: function () { - ignoreWord(editor, startedState, textMatcherState, word, spans, ignoreAll); - } - } - ]); - return items; - }; - var setup = function (editor, pluginUrl, lastSuggestionsState, startedState, textMatcherState, currentLanguageState) { - var update = function (element) { - var target = element; - if (target.className === 'mce-spellchecker-word') { - var spans = findSpansByIndex(editor, getElmIndex(target)); - if (spans.length > 0) { - var rng = editor.dom.createRng(); - rng.setStartBefore(spans[0]); - rng.setEndAfter(spans[spans.length - 1]); - editor.selection.setRng(rng); - return getSuggestions(editor, pluginUrl, lastSuggestionsState, startedState, textMatcherState, currentLanguageState, target.getAttribute('data-mce-word'), spans); - } - } else { - return []; - } - }; - editor.ui.registry.addContextMenu('spellchecker', { update: update }); - }; - - function Plugin () { - global$3.add('spellchecker', function (editor, pluginUrl) { - if (hasProPlugin(editor) === false) { - var startedState = Cell(false); - var currentLanguageState = Cell(getLanguage(editor)); - var textMatcherState = Cell(null); - var lastSuggestionsState = Cell(null); - register(editor, pluginUrl, startedState, textMatcherState, currentLanguageState, lastSuggestionsState); - setup(editor, pluginUrl, lastSuggestionsState, startedState, textMatcherState, currentLanguageState); - register$1(editor, pluginUrl, startedState, textMatcherState, lastSuggestionsState, currentLanguageState); - return get(editor, startedState, lastSuggestionsState, textMatcherState, currentLanguageState); - } - }); - } - - Plugin(); - -}()); - -/** - * Copyright (c) Tiny Technologies, Inc. All rights reserved. - * Licensed under the LGPL or a commercial license. - * For LGPL see License.txt in the project root for license information. - * For commercial licenses see https://www.tiny.cloud/ - * - * Version: 5.10.5 (2022-05-25) - */ -(function () { - 'use strict'; - - var global$6 = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - var global$5 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); - - var global$4 = tinymce.util.Tools.resolve('tinymce.EditorManager'); - - var global$3 = tinymce.util.Tools.resolve('tinymce.Env'); - - var global$2 = tinymce.util.Tools.resolve('tinymce.util.Delay'); - - var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools'); - - var global = tinymce.util.Tools.resolve('tinymce.util.VK'); - - var getTabFocusElements = function (editor) { - return editor.getParam('tabfocus_elements', ':prev,:next'); - }; - var getTabFocus = function (editor) { - return editor.getParam('tab_focus', getTabFocusElements(editor)); - }; - - var DOM = global$5.DOM; - var tabCancel = function (e) { - if (e.keyCode === global.TAB && !e.ctrlKey && !e.altKey && !e.metaKey) { - e.preventDefault(); - } - }; - var setup = function (editor) { - var tabHandler = function (e) { - var x; - if (e.keyCode !== global.TAB || e.ctrlKey || e.altKey || e.metaKey || e.isDefaultPrevented()) { - return; - } - var find = function (direction) { - var el = DOM.select(':input:enabled,*[tabindex]:not(iframe)'); - var canSelectRecursive = function (e) { - var castElem = e; - return e.nodeName === 'BODY' || castElem.type !== 'hidden' && castElem.style.display !== 'none' && castElem.style.visibility !== 'hidden' && canSelectRecursive(e.parentNode); - }; - var canSelect = function (el) { - return /INPUT|TEXTAREA|BUTTON/.test(el.tagName) && global$4.get(e.id) && el.tabIndex !== -1 && canSelectRecursive(el); - }; - global$1.each(el, function (e, i) { - if (e.id === editor.id) { - x = i; - return false; - } - }); - if (direction > 0) { - for (var i = x + 1; i < el.length; i++) { - if (canSelect(el[i])) { - return el[i]; - } - } - } else { - for (var i = x - 1; i >= 0; i--) { - if (canSelect(el[i])) { - return el[i]; - } - } - } - return null; - }; - var v = global$1.explode(getTabFocus(editor)); - if (v.length === 1) { - v[1] = v[0]; - v[0] = ':prev'; - } - var el; - if (e.shiftKey) { - if (v[0] === ':prev') { - el = find(-1); - } else { - el = DOM.get(v[0]); - } - } else { - if (v[1] === ':next') { - el = find(1); - } else { - el = DOM.get(v[1]); - } - } - if (el) { - var focusEditor = global$4.get(el.id || el.name); - if (el.id && focusEditor) { - focusEditor.focus(); - } else { - global$2.setTimeout(function () { - if (!global$3.webkit) { - window.focus(); - } - el.focus(); - }, 10); - } - e.preventDefault(); - } - }; - editor.on('init', function () { - if (editor.inline) { - DOM.setAttrib(editor.getBody(), 'tabIndex', null); - } - editor.on('keyup', tabCancel); - if (global$3.gecko) { - editor.on('keypress keydown', tabHandler); - } else { - editor.on('keydown', tabHandler); - } - }); - }; - - function Plugin () { - global$6.add('tabfocus', function (editor) { - setup(editor); - }); - } - - Plugin(); - -}()); - -/** - * Copyright (c) Tiny Technologies, Inc. All rights reserved. - * Licensed under the LGPL or a commercial license. - * For LGPL see License.txt in the project root for license information. - * For commercial licenses see https://www.tiny.cloud/ - * - * Version: 5.10.5 (2022-05-25) - */ -(function () { - 'use strict'; - - var typeOf = function (x) { - var t = typeof x; - if (x === null) { - return 'null'; - } else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) { - return 'array'; - } else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) { - return 'string'; - } else { - return t; - } - }; - var isType$1 = function (type) { - return function (value) { - return typeOf(value) === type; - }; - }; - var isSimpleType = function (type) { - return function (value) { - return typeof value === type; - }; - }; - var eq$2 = function (t) { - return function (a) { - return t === a; - }; - }; - var isString = isType$1('string'); - var isObject = isType$1('object'); - var isArray = isType$1('array'); - var isNull = eq$2(null); - var isBoolean = isSimpleType('boolean'); - var isUndefined = eq$2(undefined); - var isNullable = function (a) { - return a === null || a === undefined; - }; - var isNonNullable = function (a) { - return !isNullable(a); - }; - var isFunction = isSimpleType('function'); - var isNumber = isSimpleType('number'); - - var noop = function () { - }; - var compose = function (fa, fb) { - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - return fa(fb.apply(null, args)); - }; - }; - var compose1 = function (fbc, fab) { - return function (a) { - return fbc(fab(a)); - }; - }; - var constant = function (value) { - return function () { - return value; - }; - }; - var identity = function (x) { - return x; - }; - var tripleEquals = function (a, b) { - return a === b; - }; - function curry(fn) { - var initialArgs = []; - for (var _i = 1; _i < arguments.length; _i++) { - initialArgs[_i - 1] = arguments[_i]; - } - return function () { - var restArgs = []; - for (var _i = 0; _i < arguments.length; _i++) { - restArgs[_i] = arguments[_i]; - } - var all = initialArgs.concat(restArgs); - return fn.apply(null, all); - }; - } - var not = function (f) { - return function (t) { - return !f(t); - }; - }; - var die = function (msg) { - return function () { - throw new Error(msg); - }; - }; - var never = constant(false); - var always = constant(true); - - var none$2 = function () { - return NONE; - }; - var NONE = function () { - var call = function (thunk) { - return thunk(); - }; - var id = identity; - var me = { - fold: function (n, _s) { - return n(); - }, - isSome: never, - isNone: always, - getOr: id, - getOrThunk: call, - getOrDie: function (msg) { - throw new Error(msg || 'error: getOrDie called on none.'); - }, - getOrNull: constant(null), - getOrUndefined: constant(undefined), - or: id, - orThunk: call, - map: none$2, - each: noop, - bind: none$2, - exists: never, - forall: always, - filter: function () { - return none$2(); - }, - toArray: function () { - return []; - }, - toString: constant('none()') - }; - return me; - }(); - var some = function (a) { - var constant_a = constant(a); - var self = function () { - return me; - }; - var bind = function (f) { - return f(a); - }; - var me = { - fold: function (n, s) { - return s(a); - }, - isSome: always, - isNone: never, - getOr: constant_a, - getOrThunk: constant_a, - getOrDie: constant_a, - getOrNull: constant_a, - getOrUndefined: constant_a, - or: self, - orThunk: self, - map: function (f) { - return some(f(a)); - }, - each: function (f) { - f(a); - }, - bind: bind, - exists: bind, - forall: bind, - filter: function (f) { - return f(a) ? me : NONE; - }, - toArray: function () { - return [a]; - }, - toString: function () { - return 'some(' + a + ')'; - } - }; - return me; - }; - var from$1 = function (value) { - return value === null || value === undefined ? NONE : some(value); - }; - var Optional = { - some: some, - none: none$2, - from: from$1 - }; - - var nativeSlice = Array.prototype.slice; - var nativeIndexOf = Array.prototype.indexOf; - var nativePush = Array.prototype.push; - var rawIndexOf = function (ts, t) { - return nativeIndexOf.call(ts, t); - }; - var contains$2 = function (xs, x) { - return rawIndexOf(xs, x) > -1; - }; - var exists = function (xs, pred) { - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - if (pred(x, i)) { - return true; - } - } - return false; - }; - var range$1 = function (num, f) { - var r = []; - for (var i = 0; i < num; i++) { - r.push(f(i)); - } - return r; - }; - var map$1 = function (xs, f) { - var len = xs.length; - var r = new Array(len); - for (var i = 0; i < len; i++) { - var x = xs[i]; - r[i] = f(x, i); - } - return r; - }; - var each$2 = function (xs, f) { - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - f(x, i); - } - }; - var eachr = function (xs, f) { - for (var i = xs.length - 1; i >= 0; i--) { - var x = xs[i]; - f(x, i); - } - }; - var partition = function (xs, pred) { - var pass = []; - var fail = []; - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - var arr = pred(x, i) ? pass : fail; - arr.push(x); - } - return { - pass: pass, - fail: fail - }; - }; - var filter$2 = function (xs, pred) { - var r = []; - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - if (pred(x, i)) { - r.push(x); - } - } - return r; - }; - var foldr = function (xs, f, acc) { - eachr(xs, function (x, i) { - acc = f(acc, x, i); - }); - return acc; - }; - var foldl = function (xs, f, acc) { - each$2(xs, function (x, i) { - acc = f(acc, x, i); - }); - return acc; - }; - var findUntil = function (xs, pred, until) { - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - if (pred(x, i)) { - return Optional.some(x); - } else if (until(x, i)) { - break; - } - } - return Optional.none(); - }; - var find$1 = function (xs, pred) { - return findUntil(xs, pred, never); - }; - var findIndex = function (xs, pred) { - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - if (pred(x, i)) { - return Optional.some(i); - } - } - return Optional.none(); - }; - var flatten$1 = function (xs) { - var r = []; - for (var i = 0, len = xs.length; i < len; ++i) { - if (!isArray(xs[i])) { - throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs); - } - nativePush.apply(r, xs[i]); - } - return r; - }; - var bind$2 = function (xs, f) { - return flatten$1(map$1(xs, f)); - }; - var forall = function (xs, pred) { - for (var i = 0, len = xs.length; i < len; ++i) { - var x = xs[i]; - if (pred(x, i) !== true) { - return false; - } - } - return true; - }; - var reverse = function (xs) { - var r = nativeSlice.call(xs, 0); - r.reverse(); - return r; - }; - var mapToObject = function (xs, f) { - var r = {}; - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - r[String(x)] = f(x, i); - } - return r; - }; - var pure = function (x) { - return [x]; - }; - var sort$1 = function (xs, comparator) { - var copy = nativeSlice.call(xs, 0); - copy.sort(comparator); - return copy; - }; - var get$d = function (xs, i) { - return i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none(); - }; - var head = function (xs) { - return get$d(xs, 0); - }; - var last$2 = function (xs) { - return get$d(xs, xs.length - 1); - }; - var findMap = function (arr, f) { - for (var i = 0; i < arr.length; i++) { - var r = f(arr[i], i); - if (r.isSome()) { - return r; - } - } - return Optional.none(); - }; - - var __assign = function () { - __assign = Object.assign || function __assign(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) - if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); - }; - function __spreadArray(to, from, pack) { - if (pack || arguments.length === 2) - for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) - ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); - } - - var cached = function (f) { - var called = false; - var r; - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - if (!called) { - called = true; - r = f.apply(null, args); - } - return r; - }; - }; - - var DeviceType = function (os, browser, userAgent, mediaMatch) { - var isiPad = os.isiOS() && /ipad/i.test(userAgent) === true; - var isiPhone = os.isiOS() && !isiPad; - var isMobile = os.isiOS() || os.isAndroid(); - var isTouch = isMobile || mediaMatch('(pointer:coarse)'); - var isTablet = isiPad || !isiPhone && isMobile && mediaMatch('(min-device-width:768px)'); - var isPhone = isiPhone || isMobile && !isTablet; - var iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false; - var isDesktop = !isPhone && !isTablet && !iOSwebview; - return { - isiPad: constant(isiPad), - isiPhone: constant(isiPhone), - isTablet: constant(isTablet), - isPhone: constant(isPhone), - isTouch: constant(isTouch), - isAndroid: os.isAndroid, - isiOS: os.isiOS, - isWebView: constant(iOSwebview), - isDesktop: constant(isDesktop) - }; - }; - - var firstMatch = function (regexes, s) { - for (var i = 0; i < regexes.length; i++) { - var x = regexes[i]; - if (x.test(s)) { - return x; - } - } - return undefined; - }; - var find = function (regexes, agent) { - var r = firstMatch(regexes, agent); - if (!r) { - return { - major: 0, - minor: 0 - }; - } - var group = function (i) { - return Number(agent.replace(r, '$' + i)); - }; - return nu$2(group(1), group(2)); - }; - var detect$6 = function (versionRegexes, agent) { - var cleanedAgent = String(agent).toLowerCase(); - if (versionRegexes.length === 0) { - return unknown$2(); - } - return find(versionRegexes, cleanedAgent); - }; - var unknown$2 = function () { - return nu$2(0, 0); - }; - var nu$2 = function (major, minor) { - return { - major: major, - minor: minor - }; - }; - var Version = { - nu: nu$2, - detect: detect$6, - unknown: unknown$2 - }; - - var detectBrowser$1 = function (browsers, userAgentData) { - return findMap(userAgentData.brands, function (uaBrand) { - var lcBrand = uaBrand.brand.toLowerCase(); - return find$1(browsers, function (browser) { - var _a; - return lcBrand === ((_a = browser.brand) === null || _a === void 0 ? void 0 : _a.toLowerCase()); - }).map(function (info) { - return { - current: info.name, - version: Version.nu(parseInt(uaBrand.version, 10), 0) - }; - }); - }); - }; - - var detect$5 = function (candidates, userAgent) { - var agent = String(userAgent).toLowerCase(); - return find$1(candidates, function (candidate) { - return candidate.search(agent); - }); - }; - var detectBrowser = function (browsers, userAgent) { - return detect$5(browsers, userAgent).map(function (browser) { - var version = Version.detect(browser.versionRegexes, userAgent); - return { - current: browser.name, - version: version - }; - }); - }; - var detectOs = function (oses, userAgent) { - return detect$5(oses, userAgent).map(function (os) { - var version = Version.detect(os.versionRegexes, userAgent); - return { - current: os.name, - version: version - }; - }); - }; - - var removeFromStart = function (str, numChars) { - return str.substring(numChars); - }; - - var checkRange = function (str, substr, start) { - return substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr; - }; - var removeLeading = function (str, prefix) { - return startsWith(str, prefix) ? removeFromStart(str, prefix.length) : str; - }; - var contains$1 = function (str, substr) { - return str.indexOf(substr) !== -1; - }; - var startsWith = function (str, prefix) { - return checkRange(str, prefix, 0); - }; - var endsWith = function (str, suffix) { - return checkRange(str, suffix, str.length - suffix.length); - }; - var blank = function (r) { - return function (s) { - return s.replace(r, ''); - }; - }; - var trim = blank(/^\s+|\s+$/g); - var isNotEmpty = function (s) { - return s.length > 0; - }; - var isEmpty$1 = function (s) { - return !isNotEmpty(s); - }; - var toFloat = function (value) { - var num = parseFloat(value); - return isNaN(num) ? Optional.none() : Optional.some(num); - }; - - var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/; - var checkContains = function (target) { - return function (uastring) { - return contains$1(uastring, target); - }; - }; - var browsers = [ - { - name: 'Edge', - versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/], - search: function (uastring) { - return contains$1(uastring, 'edge/') && contains$1(uastring, 'chrome') && contains$1(uastring, 'safari') && contains$1(uastring, 'applewebkit'); - } - }, - { - name: 'Chrome', - brand: 'Chromium', - versionRegexes: [ - /.*?chrome\/([0-9]+)\.([0-9]+).*/, - normalVersionRegex - ], - search: function (uastring) { - return contains$1(uastring, 'chrome') && !contains$1(uastring, 'chromeframe'); - } - }, - { - name: 'IE', - versionRegexes: [ - /.*?msie\ ?([0-9]+)\.([0-9]+).*/, - /.*?rv:([0-9]+)\.([0-9]+).*/ - ], - search: function (uastring) { - return contains$1(uastring, 'msie') || contains$1(uastring, 'trident'); - } - }, - { - name: 'Opera', - versionRegexes: [ - normalVersionRegex, - /.*?opera\/([0-9]+)\.([0-9]+).*/ - ], - search: checkContains('opera') - }, - { - name: 'Firefox', - versionRegexes: [/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/], - search: checkContains('firefox') - }, - { - name: 'Safari', - versionRegexes: [ - normalVersionRegex, - /.*?cpu os ([0-9]+)_([0-9]+).*/ - ], - search: function (uastring) { - return (contains$1(uastring, 'safari') || contains$1(uastring, 'mobile/')) && contains$1(uastring, 'applewebkit'); - } - } - ]; - var oses = [ - { - name: 'Windows', - search: checkContains('win'), - versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/] - }, - { - name: 'iOS', - search: function (uastring) { - return contains$1(uastring, 'iphone') || contains$1(uastring, 'ipad'); - }, - versionRegexes: [ - /.*?version\/\ ?([0-9]+)\.([0-9]+).*/, - /.*cpu os ([0-9]+)_([0-9]+).*/, - /.*cpu iphone os ([0-9]+)_([0-9]+).*/ - ] - }, - { - name: 'Android', - search: checkContains('android'), - versionRegexes: [/.*?android\ ?([0-9]+)\.([0-9]+).*/] - }, - { - name: 'OSX', - search: checkContains('mac os x'), - versionRegexes: [/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/] - }, - { - name: 'Linux', - search: checkContains('linux'), - versionRegexes: [] - }, - { - name: 'Solaris', - search: checkContains('sunos'), - versionRegexes: [] - }, - { - name: 'FreeBSD', - search: checkContains('freebsd'), - versionRegexes: [] - }, - { - name: 'ChromeOS', - search: checkContains('cros'), - versionRegexes: [/.*?chrome\/([0-9]+)\.([0-9]+).*/] - } - ]; - var PlatformInfo = { - browsers: constant(browsers), - oses: constant(oses) - }; - - var edge = 'Edge'; - var chrome = 'Chrome'; - var ie = 'IE'; - var opera = 'Opera'; - var firefox = 'Firefox'; - var safari = 'Safari'; - var unknown$1 = function () { - return nu$1({ - current: undefined, - version: Version.unknown() - }); - }; - var nu$1 = function (info) { - var current = info.current; - var version = info.version; - var isBrowser = function (name) { - return function () { - return current === name; - }; - }; - return { - current: current, - version: version, - isEdge: isBrowser(edge), - isChrome: isBrowser(chrome), - isIE: isBrowser(ie), - isOpera: isBrowser(opera), - isFirefox: isBrowser(firefox), - isSafari: isBrowser(safari) - }; - }; - var Browser = { - unknown: unknown$1, - nu: nu$1, - edge: constant(edge), - chrome: constant(chrome), - ie: constant(ie), - opera: constant(opera), - firefox: constant(firefox), - safari: constant(safari) - }; - - var windows = 'Windows'; - var ios = 'iOS'; - var android = 'Android'; - var linux = 'Linux'; - var osx = 'OSX'; - var solaris = 'Solaris'; - var freebsd = 'FreeBSD'; - var chromeos = 'ChromeOS'; - var unknown = function () { - return nu({ - current: undefined, - version: Version.unknown() - }); - }; - var nu = function (info) { - var current = info.current; - var version = info.version; - var isOS = function (name) { - return function () { - return current === name; - }; - }; - return { - current: current, - version: version, - isWindows: isOS(windows), - isiOS: isOS(ios), - isAndroid: isOS(android), - isOSX: isOS(osx), - isLinux: isOS(linux), - isSolaris: isOS(solaris), - isFreeBSD: isOS(freebsd), - isChromeOS: isOS(chromeos) - }; - }; - var OperatingSystem = { - unknown: unknown, - nu: nu, - windows: constant(windows), - ios: constant(ios), - android: constant(android), - linux: constant(linux), - osx: constant(osx), - solaris: constant(solaris), - freebsd: constant(freebsd), - chromeos: constant(chromeos) - }; - - var detect$4 = function (userAgent, userAgentDataOpt, mediaMatch) { - var browsers = PlatformInfo.browsers(); - var oses = PlatformInfo.oses(); - var browser = userAgentDataOpt.bind(function (userAgentData) { - return detectBrowser$1(browsers, userAgentData); - }).orThunk(function () { - return detectBrowser(browsers, userAgent); - }).fold(Browser.unknown, Browser.nu); - var os = detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu); - var deviceType = DeviceType(os, browser, userAgent, mediaMatch); - return { - browser: browser, - os: os, - deviceType: deviceType - }; - }; - var PlatformDetection = { detect: detect$4 }; - - var mediaMatch = function (query) { - return window.matchMedia(query).matches; - }; - var platform = cached(function () { - return PlatformDetection.detect(navigator.userAgent, Optional.from(navigator.userAgentData), mediaMatch); - }); - var detect$3 = function () { - return platform(); - }; - - var compareDocumentPosition = function (a, b, match) { - return (a.compareDocumentPosition(b) & match) !== 0; - }; - var documentPositionContainedBy = function (a, b) { - return compareDocumentPosition(a, b, Node.DOCUMENT_POSITION_CONTAINED_BY); - }; - - var COMMENT = 8; - var DOCUMENT = 9; - var DOCUMENT_FRAGMENT = 11; - var ELEMENT = 1; - var TEXT = 3; - - var fromHtml$1 = function (html, scope) { - var doc = scope || document; - var div = doc.createElement('div'); - div.innerHTML = html; - if (!div.hasChildNodes() || div.childNodes.length > 1) { - console.error('HTML does not have a single root node', html); - throw new Error('HTML must have a single root node'); - } - return fromDom$1(div.childNodes[0]); - }; - var fromTag = function (tag, scope) { - var doc = scope || document; - var node = doc.createElement(tag); - return fromDom$1(node); - }; - var fromText = function (text, scope) { - var doc = scope || document; - var node = doc.createTextNode(text); - return fromDom$1(node); - }; - var fromDom$1 = function (node) { - if (node === null || node === undefined) { - throw new Error('Node cannot be null or undefined'); - } - return { dom: node }; - }; - var fromPoint$1 = function (docElm, x, y) { - return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom$1); - }; - var SugarElement = { - fromHtml: fromHtml$1, - fromTag: fromTag, - fromText: fromText, - fromDom: fromDom$1, - fromPoint: fromPoint$1 - }; - - var is$2 = function (element, selector) { - var dom = element.dom; - if (dom.nodeType !== ELEMENT) { - return false; - } else { - var elem = dom; - if (elem.matches !== undefined) { - return elem.matches(selector); - } else if (elem.msMatchesSelector !== undefined) { - return elem.msMatchesSelector(selector); - } else if (elem.webkitMatchesSelector !== undefined) { - return elem.webkitMatchesSelector(selector); - } else if (elem.mozMatchesSelector !== undefined) { - return elem.mozMatchesSelector(selector); - } else { - throw new Error('Browser lacks native selectors'); - } - } - }; - var bypassSelector = function (dom) { - return dom.nodeType !== ELEMENT && dom.nodeType !== DOCUMENT && dom.nodeType !== DOCUMENT_FRAGMENT || dom.childElementCount === 0; - }; - var all$1 = function (selector, scope) { - var base = scope === undefined ? document : scope.dom; - return bypassSelector(base) ? [] : map$1(base.querySelectorAll(selector), SugarElement.fromDom); - }; - var one = function (selector, scope) { - var base = scope === undefined ? document : scope.dom; - return bypassSelector(base) ? Optional.none() : Optional.from(base.querySelector(selector)).map(SugarElement.fromDom); - }; - - var eq$1 = function (e1, e2) { - return e1.dom === e2.dom; - }; - var regularContains = function (e1, e2) { - var d1 = e1.dom; - var d2 = e2.dom; - return d1 === d2 ? false : d1.contains(d2); - }; - var ieContains = function (e1, e2) { - return documentPositionContainedBy(e1.dom, e2.dom); - }; - var contains = function (e1, e2) { - return detect$3().browser.isIE() ? ieContains(e1, e2) : regularContains(e1, e2); - }; - var is$1 = is$2; - - var keys = Object.keys; - var hasOwnProperty = Object.hasOwnProperty; - var each$1 = function (obj, f) { - var props = keys(obj); - for (var k = 0, len = props.length; k < len; k++) { - var i = props[k]; - var x = obj[i]; - f(x, i); - } - }; - var map = function (obj, f) { - return tupleMap(obj, function (x, i) { - return { - k: i, - v: f(x, i) - }; - }); - }; - var tupleMap = function (obj, f) { - var r = {}; - each$1(obj, function (x, i) { - var tuple = f(x, i); - r[tuple.k] = tuple.v; - }); - return r; - }; - var objAcc = function (r) { - return function (x, i) { - r[i] = x; - }; - }; - var internalFilter = function (obj, pred, onTrue, onFalse) { - var r = {}; - each$1(obj, function (x, i) { - (pred(x, i) ? onTrue : onFalse)(x, i); - }); - return r; - }; - var filter$1 = function (obj, pred) { - var t = {}; - internalFilter(obj, pred, objAcc(t), noop); - return t; - }; - var mapToArray = function (obj, f) { - var r = []; - each$1(obj, function (value, name) { - r.push(f(value, name)); - }); - return r; - }; - var values = function (obj) { - return mapToArray(obj, identity); - }; - var size = function (obj) { - return keys(obj).length; - }; - var get$c = function (obj, key) { - return has$1(obj, key) ? Optional.from(obj[key]) : Optional.none(); - }; - var has$1 = function (obj, key) { - return hasOwnProperty.call(obj, key); - }; - var hasNonNullableKey = function (obj, key) { - return has$1(obj, key) && obj[key] !== undefined && obj[key] !== null; - }; - var isEmpty = function (r) { - for (var x in r) { - if (hasOwnProperty.call(r, x)) { - return false; - } - } - return true; - }; - - var validSectionList = [ - 'tfoot', - 'thead', - 'tbody', - 'colgroup' - ]; - var isValidSection = function (parentName) { - return contains$2(validSectionList, parentName); - }; - var grid = function (rows, columns) { - return { - rows: rows, - columns: columns - }; - }; - var address = function (row, column) { - return { - row: row, - column: column - }; - }; - var detail = function (element, rowspan, colspan) { - return { - element: element, - rowspan: rowspan, - colspan: colspan - }; - }; - var detailnew = function (element, rowspan, colspan, isNew) { - return { - element: element, - rowspan: rowspan, - colspan: colspan, - isNew: isNew - }; - }; - var extended = function (element, rowspan, colspan, row, column, isLocked) { - return { - element: element, - rowspan: rowspan, - colspan: colspan, - row: row, - column: column, - isLocked: isLocked - }; - }; - var rowdetail = function (element, cells, section) { - return { - element: element, - cells: cells, - section: section - }; - }; - var rowdetailnew = function (element, cells, section, isNew) { - return { - element: element, - cells: cells, - section: section, - isNew: isNew - }; - }; - var elementnew = function (element, isNew, isLocked) { - return { - element: element, - isNew: isNew, - isLocked: isLocked - }; - }; - var rowcells = function (element, cells, section, isNew) { - return { - element: element, - cells: cells, - section: section, - isNew: isNew - }; - }; - var bounds = function (startRow, startCol, finishRow, finishCol) { - return { - startRow: startRow, - startCol: startCol, - finishRow: finishRow, - finishCol: finishCol - }; - }; - var columnext = function (element, colspan, column) { - return { - element: element, - colspan: colspan, - column: column - }; - }; - var colgroup = function (element, columns) { - return { - element: element, - columns: columns - }; - }; - - typeof window !== 'undefined' ? window : Function('return this;')(); - - var name = function (element) { - var r = element.dom.nodeName; - return r.toLowerCase(); - }; - var type$1 = function (element) { - return element.dom.nodeType; - }; - var isType = function (t) { - return function (element) { - return type$1(element) === t; - }; - }; - var isComment = function (element) { - return type$1(element) === COMMENT || name(element) === '#comment'; - }; - var isElement = isType(ELEMENT); - var isText = isType(TEXT); - var isDocument = isType(DOCUMENT); - var isDocumentFragment = isType(DOCUMENT_FRAGMENT); - var isTag = function (tag) { - return function (e) { - return isElement(e) && name(e) === tag; - }; - }; - - var owner = function (element) { - return SugarElement.fromDom(element.dom.ownerDocument); - }; - var documentOrOwner = function (dos) { - return isDocument(dos) ? dos : owner(dos); - }; - var defaultView = function (element) { - return SugarElement.fromDom(documentOrOwner(element).dom.defaultView); - }; - var parent = function (element) { - return Optional.from(element.dom.parentNode).map(SugarElement.fromDom); - }; - var parentElement = function (element) { - return Optional.from(element.dom.parentElement).map(SugarElement.fromDom); - }; - var parents = function (element, isRoot) { - var stop = isFunction(isRoot) ? isRoot : never; - var dom = element.dom; - var ret = []; - while (dom.parentNode !== null && dom.parentNode !== undefined) { - var rawParent = dom.parentNode; - var p = SugarElement.fromDom(rawParent); - ret.push(p); - if (stop(p) === true) { - break; - } else { - dom = rawParent; - } - } - return ret; - }; - var prevSibling = function (element) { - return Optional.from(element.dom.previousSibling).map(SugarElement.fromDom); - }; - var nextSibling = function (element) { - return Optional.from(element.dom.nextSibling).map(SugarElement.fromDom); - }; - var children$3 = function (element) { - return map$1(element.dom.childNodes, SugarElement.fromDom); - }; - var child$3 = function (element, index) { - var cs = element.dom.childNodes; - return Optional.from(cs[index]).map(SugarElement.fromDom); - }; - var firstChild = function (element) { - return child$3(element, 0); - }; - - var isShadowRoot = function (dos) { - return isDocumentFragment(dos) && isNonNullable(dos.dom.host); - }; - var supported = isFunction(Element.prototype.attachShadow) && isFunction(Node.prototype.getRootNode); - var isSupported$1 = constant(supported); - var getRootNode = supported ? function (e) { - return SugarElement.fromDom(e.dom.getRootNode()); - } : documentOrOwner; - var getShadowRoot = function (e) { - var r = getRootNode(e); - return isShadowRoot(r) ? Optional.some(r) : Optional.none(); - }; - var getShadowHost = function (e) { - return SugarElement.fromDom(e.dom.host); - }; - var getOriginalEventTarget = function (event) { - if (isSupported$1() && isNonNullable(event.target)) { - var el = SugarElement.fromDom(event.target); - if (isElement(el) && isOpenShadowHost(el)) { - if (event.composed && event.composedPath) { - var composedPath = event.composedPath(); - if (composedPath) { - return head(composedPath); - } - } - } - } - return Optional.from(event.target); - }; - var isOpenShadowHost = function (element) { - return isNonNullable(element.dom.shadowRoot); - }; - - var inBody = function (element) { - var dom = isText(element) ? element.dom.parentNode : element.dom; - if (dom === undefined || dom === null || dom.ownerDocument === null) { - return false; - } - var doc = dom.ownerDocument; - return getShadowRoot(SugarElement.fromDom(dom)).fold(function () { - return doc.body.contains(dom); - }, compose1(inBody, getShadowHost)); - }; - var body$1 = function () { - return getBody$1(SugarElement.fromDom(document)); - }; - var getBody$1 = function (doc) { - var b = doc.dom.body; - if (b === null || b === undefined) { - throw new Error('Body is not available yet'); - } - return SugarElement.fromDom(b); - }; - - var ancestors$4 = function (scope, predicate, isRoot) { - return filter$2(parents(scope, isRoot), predicate); - }; - var children$2 = function (scope, predicate) { - return filter$2(children$3(scope), predicate); - }; - var descendants$1 = function (scope, predicate) { - var result = []; - each$2(children$3(scope), function (x) { - if (predicate(x)) { - result = result.concat([x]); - } - result = result.concat(descendants$1(x, predicate)); - }); - return result; - }; - - var ancestors$3 = function (scope, selector, isRoot) { - return ancestors$4(scope, function (e) { - return is$2(e, selector); - }, isRoot); - }; - var children$1 = function (scope, selector) { - return children$2(scope, function (e) { - return is$2(e, selector); - }); - }; - var descendants = function (scope, selector) { - return all$1(selector, scope); - }; - - function ClosestOrAncestor (is, ancestor, scope, a, isRoot) { - if (is(scope, a)) { - return Optional.some(scope); - } else if (isFunction(isRoot) && isRoot(scope)) { - return Optional.none(); - } else { - return ancestor(scope, a, isRoot); - } - } - - var ancestor$2 = function (scope, predicate, isRoot) { - var element = scope.dom; - var stop = isFunction(isRoot) ? isRoot : never; - while (element.parentNode) { - element = element.parentNode; - var el = SugarElement.fromDom(element); - if (predicate(el)) { - return Optional.some(el); - } else if (stop(el)) { - break; - } - } - return Optional.none(); - }; - var closest$2 = function (scope, predicate, isRoot) { - var is = function (s, test) { - return test(s); - }; - return ClosestOrAncestor(is, ancestor$2, scope, predicate, isRoot); - }; - var child$2 = function (scope, predicate) { - var pred = function (node) { - return predicate(SugarElement.fromDom(node)); - }; - var result = find$1(scope.dom.childNodes, pred); - return result.map(SugarElement.fromDom); - }; - var descendant$1 = function (scope, predicate) { - var descend = function (node) { - for (var i = 0; i < node.childNodes.length; i++) { - var child_1 = SugarElement.fromDom(node.childNodes[i]); - if (predicate(child_1)) { - return Optional.some(child_1); - } - var res = descend(node.childNodes[i]); - if (res.isSome()) { - return res; - } - } - return Optional.none(); - }; - return descend(scope.dom); - }; - - var ancestor$1 = function (scope, selector, isRoot) { - return ancestor$2(scope, function (e) { - return is$2(e, selector); - }, isRoot); - }; - var child$1 = function (scope, selector) { - return child$2(scope, function (e) { - return is$2(e, selector); - }); - }; - var descendant = function (scope, selector) { - return one(selector, scope); - }; - var closest$1 = function (scope, selector, isRoot) { - var is = function (element, selector) { - return is$2(element, selector); - }; - return ClosestOrAncestor(is, ancestor$1, scope, selector, isRoot); - }; - - var rawSet = function (dom, key, value) { - if (isString(value) || isBoolean(value) || isNumber(value)) { - dom.setAttribute(key, value + ''); - } else { - console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom); - throw new Error('Attribute value was not simple'); - } - }; - var set$2 = function (element, key, value) { - rawSet(element.dom, key, value); - }; - var setAll$1 = function (element, attrs) { - var dom = element.dom; - each$1(attrs, function (v, k) { - rawSet(dom, k, v); - }); - }; - var setOptions = function (element, attrs) { - each$1(attrs, function (v, k) { - v.fold(function () { - remove$7(element, k); - }, function (value) { - rawSet(element.dom, k, value); - }); - }); - }; - var get$b = function (element, key) { - var v = element.dom.getAttribute(key); - return v === null ? undefined : v; - }; - var getOpt = function (element, key) { - return Optional.from(get$b(element, key)); - }; - var remove$7 = function (element, key) { - element.dom.removeAttribute(key); - }; - var clone$2 = function (element) { - return foldl(element.dom.attributes, function (acc, attr) { - acc[attr.name] = attr.value; - return acc; - }, {}); - }; - - var is = function (lhs, rhs, comparator) { - if (comparator === void 0) { - comparator = tripleEquals; - } - return lhs.exists(function (left) { - return comparator(left, rhs); - }); - }; - var cat = function (arr) { - var r = []; - var push = function (x) { - r.push(x); - }; - for (var i = 0; i < arr.length; i++) { - arr[i].each(push); - } - return r; - }; - var lift2 = function (oa, ob, f) { - return oa.isSome() && ob.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie())) : Optional.none(); - }; - var bindFrom = function (a, f) { - return a !== undefined && a !== null ? f(a) : Optional.none(); - }; - var flatten = function (oot) { - return oot.bind(identity); - }; - var someIf = function (b, a) { - return b ? Optional.some(a) : Optional.none(); - }; - - var isSupported = function (dom) { - return dom.style !== undefined && isFunction(dom.style.getPropertyValue); - }; - - var internalSet = function (dom, property, value) { - if (!isString(value)) { - console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom); - throw new Error('CSS value must be a string: ' + value); - } - if (isSupported(dom)) { - dom.style.setProperty(property, value); - } - }; - var internalRemove = function (dom, property) { - if (isSupported(dom)) { - dom.style.removeProperty(property); - } - }; - var set$1 = function (element, property, value) { - var dom = element.dom; - internalSet(dom, property, value); - }; - var setAll = function (element, css) { - var dom = element.dom; - each$1(css, function (v, k) { - internalSet(dom, k, v); - }); - }; - var get$a = function (element, property) { - var dom = element.dom; - var styles = window.getComputedStyle(dom); - var r = styles.getPropertyValue(property); - return r === '' && !inBody(element) ? getUnsafeProperty(dom, property) : r; - }; - var getUnsafeProperty = function (dom, property) { - return isSupported(dom) ? dom.style.getPropertyValue(property) : ''; - }; - var getRaw$2 = function (element, property) { - var dom = element.dom; - var raw = getUnsafeProperty(dom, property); - return Optional.from(raw).filter(function (r) { - return r.length > 0; - }); - }; - var remove$6 = function (element, property) { - var dom = element.dom; - internalRemove(dom, property); - if (is(getOpt(element, 'style').map(trim), '')) { - remove$7(element, 'style'); - } - }; - var copy$2 = function (source, target) { - var sourceDom = source.dom; - var targetDom = target.dom; - if (isSupported(sourceDom) && isSupported(targetDom)) { - targetDom.style.cssText = sourceDom.style.cssText; - } - }; - - var getAttrValue = function (cell, name, fallback) { - if (fallback === void 0) { - fallback = 0; - } - return getOpt(cell, name).map(function (value) { - return parseInt(value, 10); - }).getOr(fallback); - }; - var getSpan = function (cell, type) { - return getAttrValue(cell, type, 1); - }; - var hasColspan = function (cellOrCol) { - if (isTag('col')(cellOrCol)) { - return getAttrValue(cellOrCol, 'span', 1) > 1; - } else { - return getSpan(cellOrCol, 'colspan') > 1; - } - }; - var hasRowspan = function (cell) { - return getSpan(cell, 'rowspan') > 1; - }; - var getCssValue = function (element, property) { - return parseInt(get$a(element, property), 10); - }; - var minWidth = constant(10); - var minHeight = constant(10); - - var firstLayer = function (scope, selector) { - return filterFirstLayer(scope, selector, always); - }; - var filterFirstLayer = function (scope, selector, predicate) { - return bind$2(children$3(scope), function (x) { - if (is$2(x, selector)) { - return predicate(x) ? [x] : []; - } else { - return filterFirstLayer(x, selector, predicate); - } - }); - }; - - var lookup = function (tags, element, isRoot) { - if (isRoot === void 0) { - isRoot = never; - } - if (isRoot(element)) { - return Optional.none(); - } - if (contains$2(tags, name(element))) { - return Optional.some(element); - } - var isRootOrUpperTable = function (elm) { - return is$2(elm, 'table') || isRoot(elm); - }; - return ancestor$1(element, tags.join(','), isRootOrUpperTable); - }; - var cell = function (element, isRoot) { - return lookup([ - 'td', - 'th' - ], element, isRoot); - }; - var cells$1 = function (ancestor) { - return firstLayer(ancestor, 'th,td'); - }; - var columns$1 = function (ancestor) { - if (is$2(ancestor, 'colgroup')) { - return children$1(ancestor, 'col'); - } else { - return bind$2(columnGroups(ancestor), function (columnGroup) { - return children$1(columnGroup, 'col'); - }); - } - }; - var table = function (element, isRoot) { - return closest$1(element, 'table', isRoot); - }; - var rows$1 = function (ancestor) { - return firstLayer(ancestor, 'tr'); - }; - var columnGroups = function (ancestor) { - return table(ancestor).fold(constant([]), function (table) { - return children$1(table, 'colgroup'); - }); - }; - - var fromRowsOrColGroups = function (elems, getSection) { - return map$1(elems, function (row) { - if (name(row) === 'colgroup') { - var cells = map$1(columns$1(row), function (column) { - var colspan = getAttrValue(column, 'span', 1); - return detail(column, 1, colspan); - }); - return rowdetail(row, cells, 'colgroup'); - } else { - var cells = map$1(cells$1(row), function (cell) { - var rowspan = getAttrValue(cell, 'rowspan', 1); - var colspan = getAttrValue(cell, 'colspan', 1); - return detail(cell, rowspan, colspan); - }); - return rowdetail(row, cells, getSection(row)); - } - }); - }; - var getParentSection = function (group) { - return parent(group).map(function (parent) { - var parentName = name(parent); - return isValidSection(parentName) ? parentName : 'tbody'; - }).getOr('tbody'); - }; - var fromTable$1 = function (table) { - var rows = rows$1(table); - var columnGroups$1 = columnGroups(table); - var elems = __spreadArray(__spreadArray([], columnGroups$1, true), rows, true); - return fromRowsOrColGroups(elems, getParentSection); - }; - var fromPastedRows = function (elems, section) { - return fromRowsOrColGroups(elems, function () { - return section; - }); - }; - - var addCells = function (gridRow, index, cells) { - var existingCells = gridRow.cells; - var before = existingCells.slice(0, index); - var after = existingCells.slice(index); - var newCells = before.concat(cells).concat(after); - return setCells(gridRow, newCells); - }; - var addCell = function (gridRow, index, cell) { - return addCells(gridRow, index, [cell]); - }; - var mutateCell = function (gridRow, index, cell) { - var cells = gridRow.cells; - cells[index] = cell; - }; - var setCells = function (gridRow, cells) { - return rowcells(gridRow.element, cells, gridRow.section, gridRow.isNew); - }; - var mapCells = function (gridRow, f) { - var cells = gridRow.cells; - var r = map$1(cells, f); - return rowcells(gridRow.element, r, gridRow.section, gridRow.isNew); - }; - var getCell = function (gridRow, index) { - return gridRow.cells[index]; - }; - var getCellElement = function (gridRow, index) { - return getCell(gridRow, index).element; - }; - var cellLength = function (gridRow) { - return gridRow.cells.length; - }; - var extractGridDetails = function (grid) { - var result = partition(grid, function (row) { - return row.section === 'colgroup'; - }); - return { - rows: result.fail, - cols: result.pass - }; - }; - var clone$1 = function (gridRow, cloneRow, cloneCell) { - var newCells = map$1(gridRow.cells, cloneCell); - return rowcells(cloneRow(gridRow.element), newCells, gridRow.section, true); - }; - - var LOCKED_COL_ATTR = 'data-snooker-locked-cols'; - var getLockedColumnsFromTable = function (table) { - return getOpt(table, LOCKED_COL_ATTR).bind(function (lockedColStr) { - return Optional.from(lockedColStr.match(/\d+/g)); - }).map(function (lockedCols) { - return mapToObject(lockedCols, always); - }); - }; - var getLockedColumnsFromGrid = function (grid) { - var locked = foldl(extractGridDetails(grid).rows, function (acc, row) { - each$2(row.cells, function (cell, idx) { - if (cell.isLocked) { - acc[idx] = true; - } - }); - return acc; - }, {}); - var lockedArr = mapToArray(locked, function (_val, key) { - return parseInt(key, 10); - }); - return sort$1(lockedArr); - }; - - var key = function (row, column) { - return row + ',' + column; - }; - var getAt = function (warehouse, row, column) { - return Optional.from(warehouse.access[key(row, column)]); - }; - var findItem = function (warehouse, item, comparator) { - var filtered = filterItems(warehouse, function (detail) { - return comparator(item, detail.element); - }); - return filtered.length > 0 ? Optional.some(filtered[0]) : Optional.none(); - }; - var filterItems = function (warehouse, predicate) { - var all = bind$2(warehouse.all, function (r) { - return r.cells; - }); - return filter$2(all, predicate); - }; - var generateColumns = function (rowData) { - var columnsGroup = {}; - var index = 0; - each$2(rowData.cells, function (column) { - var colspan = column.colspan; - range$1(colspan, function (columnIndex) { - var colIndex = index + columnIndex; - columnsGroup[colIndex] = columnext(column.element, colspan, colIndex); - }); - index += colspan; - }); - return columnsGroup; - }; - var generate$1 = function (list) { - var access = {}; - var cells = []; - var tableOpt = head(list).map(function (rowData) { - return rowData.element; - }).bind(table); - var lockedColumns = tableOpt.bind(getLockedColumnsFromTable).getOr({}); - var maxRows = 0; - var maxColumns = 0; - var rowCount = 0; - var _a = partition(list, function (rowData) { - return rowData.section === 'colgroup'; - }), colgroupRows = _a.pass, rows = _a.fail; - each$2(rows, function (rowData) { - var currentRow = []; - each$2(rowData.cells, function (rowCell) { - var start = 0; - while (access[key(rowCount, start)] !== undefined) { - start++; - } - var isLocked = hasNonNullableKey(lockedColumns, start.toString()); - var current = extended(rowCell.element, rowCell.rowspan, rowCell.colspan, rowCount, start, isLocked); - for (var occupiedColumnPosition = 0; occupiedColumnPosition < rowCell.colspan; occupiedColumnPosition++) { - for (var occupiedRowPosition = 0; occupiedRowPosition < rowCell.rowspan; occupiedRowPosition++) { - var rowPosition = rowCount + occupiedRowPosition; - var columnPosition = start + occupiedColumnPosition; - var newpos = key(rowPosition, columnPosition); - access[newpos] = current; - maxColumns = Math.max(maxColumns, columnPosition + 1); - } - } - currentRow.push(current); - }); - maxRows++; - cells.push(rowdetail(rowData.element, currentRow, rowData.section)); - rowCount++; - }); - var _b = last$2(colgroupRows).map(function (rowData) { - var columns = generateColumns(rowData); - var colgroup$1 = colgroup(rowData.element, values(columns)); - return { - colgroups: [colgroup$1], - columns: columns - }; - }).getOrThunk(function () { - return { - colgroups: [], - columns: {} - }; - }), columns = _b.columns, colgroups = _b.colgroups; - var grid$1 = grid(maxRows, maxColumns); - return { - grid: grid$1, - access: access, - all: cells, - columns: columns, - colgroups: colgroups - }; - }; - var fromTable = function (table) { - var list = fromTable$1(table); - return generate$1(list); - }; - var justCells = function (warehouse) { - return bind$2(warehouse.all, function (w) { - return w.cells; - }); - }; - var justColumns = function (warehouse) { - return values(warehouse.columns); - }; - var hasColumns = function (warehouse) { - return keys(warehouse.columns).length > 0; - }; - var getColumnAt = function (warehouse, columnIndex) { - return Optional.from(warehouse.columns[columnIndex]); - }; - var Warehouse = { - fromTable: fromTable, - generate: generate$1, - getAt: getAt, - findItem: findItem, - filterItems: filterItems, - justCells: justCells, - justColumns: justColumns, - hasColumns: hasColumns, - getColumnAt: getColumnAt - }; - - var inSelection = function (bounds, detail) { - var leftEdge = detail.column; - var rightEdge = detail.column + detail.colspan - 1; - var topEdge = detail.row; - var bottomEdge = detail.row + detail.rowspan - 1; - return leftEdge <= bounds.finishCol && rightEdge >= bounds.startCol && (topEdge <= bounds.finishRow && bottomEdge >= bounds.startRow); - }; - var isWithin = function (bounds, detail) { - return detail.column >= bounds.startCol && detail.column + detail.colspan - 1 <= bounds.finishCol && detail.row >= bounds.startRow && detail.row + detail.rowspan - 1 <= bounds.finishRow; - }; - var isRectangular = function (warehouse, bounds) { - var isRect = true; - var detailIsWithin = curry(isWithin, bounds); - for (var i = bounds.startRow; i <= bounds.finishRow; i++) { - for (var j = bounds.startCol; j <= bounds.finishCol; j++) { - isRect = isRect && Warehouse.getAt(warehouse, i, j).exists(detailIsWithin); - } - } - return isRect ? Optional.some(bounds) : Optional.none(); - }; - - var getBounds = function (detailA, detailB) { - return bounds(Math.min(detailA.row, detailB.row), Math.min(detailA.column, detailB.column), Math.max(detailA.row + detailA.rowspan - 1, detailB.row + detailB.rowspan - 1), Math.max(detailA.column + detailA.colspan - 1, detailB.column + detailB.colspan - 1)); - }; - var getAnyBox = function (warehouse, startCell, finishCell) { - var startCoords = Warehouse.findItem(warehouse, startCell, eq$1); - var finishCoords = Warehouse.findItem(warehouse, finishCell, eq$1); - return startCoords.bind(function (sc) { - return finishCoords.map(function (fc) { - return getBounds(sc, fc); - }); - }); - }; - var getBox$1 = function (warehouse, startCell, finishCell) { - return getAnyBox(warehouse, startCell, finishCell).bind(function (bounds) { - return isRectangular(warehouse, bounds); - }); - }; - - var moveBy$1 = function (warehouse, cell, row, column) { - return Warehouse.findItem(warehouse, cell, eq$1).bind(function (detail) { - var startRow = row > 0 ? detail.row + detail.rowspan - 1 : detail.row; - var startCol = column > 0 ? detail.column + detail.colspan - 1 : detail.column; - var dest = Warehouse.getAt(warehouse, startRow + row, startCol + column); - return dest.map(function (d) { - return d.element; - }); - }); - }; - var intercepts$1 = function (warehouse, start, finish) { - return getAnyBox(warehouse, start, finish).map(function (bounds) { - var inside = Warehouse.filterItems(warehouse, curry(inSelection, bounds)); - return map$1(inside, function (detail) { - return detail.element; - }); - }); - }; - var parentCell = function (warehouse, innerCell) { - var isContainedBy = function (c1, c2) { - return contains(c2, c1); - }; - return Warehouse.findItem(warehouse, innerCell, isContainedBy).map(function (detail) { - return detail.element; - }); - }; - - var moveBy = function (cell, deltaRow, deltaColumn) { - return table(cell).bind(function (table) { - var warehouse = getWarehouse(table); - return moveBy$1(warehouse, cell, deltaRow, deltaColumn); - }); - }; - var intercepts = function (table, first, last) { - var warehouse = getWarehouse(table); - return intercepts$1(warehouse, first, last); - }; - var nestedIntercepts = function (table, first, firstTable, last, lastTable) { - var warehouse = getWarehouse(table); - var optStartCell = eq$1(table, firstTable) ? Optional.some(first) : parentCell(warehouse, first); - var optLastCell = eq$1(table, lastTable) ? Optional.some(last) : parentCell(warehouse, last); - return optStartCell.bind(function (startCell) { - return optLastCell.bind(function (lastCell) { - return intercepts$1(warehouse, startCell, lastCell); - }); - }); - }; - var getBox = function (table, first, last) { - var warehouse = getWarehouse(table); - return getBox$1(warehouse, first, last); - }; - var getWarehouse = Warehouse.fromTable; - - var before$4 = function (marker, element) { - var parent$1 = parent(marker); - parent$1.each(function (v) { - v.dom.insertBefore(element.dom, marker.dom); - }); - }; - var after$5 = function (marker, element) { - var sibling = nextSibling(marker); - sibling.fold(function () { - var parent$1 = parent(marker); - parent$1.each(function (v) { - append$1(v, element); - }); - }, function (v) { - before$4(v, element); - }); - }; - var prepend = function (parent, element) { - var firstChild$1 = firstChild(parent); - firstChild$1.fold(function () { - append$1(parent, element); - }, function (v) { - parent.dom.insertBefore(element.dom, v.dom); - }); - }; - var append$1 = function (parent, element) { - parent.dom.appendChild(element.dom); - }; - var appendAt = function (parent, element, index) { - child$3(parent, index).fold(function () { - append$1(parent, element); - }, function (v) { - before$4(v, element); - }); - }; - var wrap = function (element, wrapper) { - before$4(element, wrapper); - append$1(wrapper, element); - }; - - var before$3 = function (marker, elements) { - each$2(elements, function (x) { - before$4(marker, x); - }); - }; - var after$4 = function (marker, elements) { - each$2(elements, function (x, i) { - var e = i === 0 ? marker : elements[i - 1]; - after$5(e, x); - }); - }; - var append = function (parent, elements) { - each$2(elements, function (x) { - append$1(parent, x); - }); - }; - - var empty = function (element) { - element.dom.textContent = ''; - each$2(children$3(element), function (rogue) { - remove$5(rogue); - }); - }; - var remove$5 = function (element) { - var dom = element.dom; - if (dom.parentNode !== null) { - dom.parentNode.removeChild(dom); - } - }; - var unwrap = function (wrapper) { - var children = children$3(wrapper); - if (children.length > 0) { - before$3(wrapper, children); - } - remove$5(wrapper); - }; - - var NodeValue = function (is, name) { - var get = function (element) { - if (!is(element)) { - throw new Error('Can only get ' + name + ' value of a ' + name + ' node'); - } - return getOption(element).getOr(''); - }; - var getOption = function (element) { - return is(element) ? Optional.from(element.dom.nodeValue) : Optional.none(); - }; - var set = function (element, value) { - if (!is(element)) { - throw new Error('Can only set raw ' + name + ' value of a ' + name + ' node'); - } - element.dom.nodeValue = value; - }; - return { - get: get, - getOption: getOption, - set: set - }; - }; - - var api$2 = NodeValue(isText, 'text'); - var get$9 = function (element) { - return api$2.get(element); - }; - var getOption = function (element) { - return api$2.getOption(element); - }; - var set = function (element, value) { - return api$2.set(element, value); - }; - - var TagBoundaries = [ - 'body', - 'p', - 'div', - 'article', - 'aside', - 'figcaption', - 'figure', - 'footer', - 'header', - 'nav', - 'section', - 'ol', - 'ul', - 'li', - 'table', - 'thead', - 'tbody', - 'tfoot', - 'caption', - 'tr', - 'td', - 'th', - 'h1', - 'h2', - 'h3', - 'h4', - 'h5', - 'h6', - 'blockquote', - 'pre', - 'address' - ]; - - function DomUniverse () { - var clone = function (element) { - return SugarElement.fromDom(element.dom.cloneNode(false)); - }; - var document = function (element) { - return documentOrOwner(element).dom; - }; - var isBoundary = function (element) { - if (!isElement(element)) { - return false; - } - if (name(element) === 'body') { - return true; - } - return contains$2(TagBoundaries, name(element)); - }; - var isEmptyTag = function (element) { - if (!isElement(element)) { - return false; - } - return contains$2([ - 'br', - 'img', - 'hr', - 'input' - ], name(element)); - }; - var isNonEditable = function (element) { - return isElement(element) && get$b(element, 'contenteditable') === 'false'; - }; - var comparePosition = function (element, other) { - return element.dom.compareDocumentPosition(other.dom); - }; - var copyAttributesTo = function (source, destination) { - var as = clone$2(source); - setAll$1(destination, as); - }; - var isSpecial = function (element) { - var tag = name(element); - return contains$2([ - 'script', - 'noscript', - 'iframe', - 'noframes', - 'noembed', - 'title', - 'style', - 'textarea', - 'xmp' - ], tag); - }; - var getLanguage = function (element) { - return isElement(element) ? getOpt(element, 'lang') : Optional.none(); - }; - return { - up: constant({ - selector: ancestor$1, - closest: closest$1, - predicate: ancestor$2, - all: parents - }), - down: constant({ - selector: descendants, - predicate: descendants$1 - }), - styles: constant({ - get: get$a, - getRaw: getRaw$2, - set: set$1, - remove: remove$6 - }), - attrs: constant({ - get: get$b, - set: set$2, - remove: remove$7, - copyTo: copyAttributesTo - }), - insert: constant({ - before: before$4, - after: after$5, - afterAll: after$4, - append: append$1, - appendAll: append, - prepend: prepend, - wrap: wrap - }), - remove: constant({ - unwrap: unwrap, - remove: remove$5 - }), - create: constant({ - nu: SugarElement.fromTag, - clone: clone, - text: SugarElement.fromText - }), - query: constant({ - comparePosition: comparePosition, - prevSibling: prevSibling, - nextSibling: nextSibling - }), - property: constant({ - children: children$3, - name: name, - parent: parent, - document: document, - isText: isText, - isComment: isComment, - isElement: isElement, - isSpecial: isSpecial, - getLanguage: getLanguage, - getText: get$9, - setText: set, - isBoundary: isBoundary, - isEmptyTag: isEmptyTag, - isNonEditable: isNonEditable - }), - eq: eq$1, - is: is$1 - }; - } - - var all = function (universe, look, elements, f) { - var head = elements[0]; - var tail = elements.slice(1); - return f(universe, look, head, tail); - }; - var oneAll = function (universe, look, elements) { - return elements.length > 0 ? all(universe, look, elements, unsafeOne) : Optional.none(); - }; - var unsafeOne = function (universe, look, head, tail) { - var start = look(universe, head); - return foldr(tail, function (b, a) { - var current = look(universe, a); - return commonElement(universe, b, current); - }, start); - }; - var commonElement = function (universe, start, end) { - return start.bind(function (s) { - return end.filter(curry(universe.eq, s)); - }); - }; - - var eq = function (universe, item) { - return curry(universe.eq, item); - }; - var ancestors$2 = function (universe, start, end, isRoot) { - if (isRoot === void 0) { - isRoot = never; - } - var ps1 = [start].concat(universe.up().all(start)); - var ps2 = [end].concat(universe.up().all(end)); - var prune = function (path) { - var index = findIndex(path, isRoot); - return index.fold(function () { - return path; - }, function (ind) { - return path.slice(0, ind + 1); - }); - }; - var pruned1 = prune(ps1); - var pruned2 = prune(ps2); - var shared = find$1(pruned1, function (x) { - return exists(pruned2, eq(universe, x)); - }); - return { - firstpath: pruned1, - secondpath: pruned2, - shared: shared - }; - }; - - var sharedOne$1 = oneAll; - var ancestors$1 = ancestors$2; - - var universe$3 = DomUniverse(); - var sharedOne = function (look, elements) { - return sharedOne$1(universe$3, function (_universe, element) { - return look(element); - }, elements); - }; - var ancestors = function (start, finish, isRoot) { - return ancestors$1(universe$3, start, finish, isRoot); - }; - - var lookupTable = function (container) { - return ancestor$1(container, 'table'); - }; - var identify = function (start, finish, isRoot) { - var getIsRoot = function (rootTable) { - return function (element) { - return isRoot !== undefined && isRoot(element) || eq$1(element, rootTable); - }; - }; - if (eq$1(start, finish)) { - return Optional.some({ - boxes: Optional.some([start]), - start: start, - finish: finish - }); - } else { - return lookupTable(start).bind(function (startTable) { - return lookupTable(finish).bind(function (finishTable) { - if (eq$1(startTable, finishTable)) { - return Optional.some({ - boxes: intercepts(startTable, start, finish), - start: start, - finish: finish - }); - } else if (contains(startTable, finishTable)) { - var ancestorCells = ancestors$3(finish, 'td,th', getIsRoot(startTable)); - var finishCell = ancestorCells.length > 0 ? ancestorCells[ancestorCells.length - 1] : finish; - return Optional.some({ - boxes: nestedIntercepts(startTable, start, startTable, finish, finishTable), - start: start, - finish: finishCell - }); - } else if (contains(finishTable, startTable)) { - var ancestorCells = ancestors$3(start, 'td,th', getIsRoot(finishTable)); - var startCell = ancestorCells.length > 0 ? ancestorCells[ancestorCells.length - 1] : start; - return Optional.some({ - boxes: nestedIntercepts(finishTable, start, startTable, finish, finishTable), - start: start, - finish: startCell - }); - } else { - return ancestors(start, finish).shared.bind(function (lca) { - return closest$1(lca, 'table', isRoot).bind(function (lcaTable) { - var finishAncestorCells = ancestors$3(finish, 'td,th', getIsRoot(lcaTable)); - var finishCell = finishAncestorCells.length > 0 ? finishAncestorCells[finishAncestorCells.length - 1] : finish; - var startAncestorCells = ancestors$3(start, 'td,th', getIsRoot(lcaTable)); - var startCell = startAncestorCells.length > 0 ? startAncestorCells[startAncestorCells.length - 1] : start; - return Optional.some({ - boxes: nestedIntercepts(lcaTable, start, startTable, finish, finishTable), - start: startCell, - finish: finishCell - }); - }); - }); - } - }); - }); - } - }; - var retrieve$1 = function (container, selector) { - var sels = descendants(container, selector); - return sels.length > 0 ? Optional.some(sels) : Optional.none(); - }; - var getLast = function (boxes, lastSelectedSelector) { - return find$1(boxes, function (box) { - return is$2(box, lastSelectedSelector); - }); - }; - var getEdges = function (container, firstSelectedSelector, lastSelectedSelector) { - return descendant(container, firstSelectedSelector).bind(function (first) { - return descendant(container, lastSelectedSelector).bind(function (last) { - return sharedOne(lookupTable, [ - first, - last - ]).map(function (table) { - return { - first: first, - last: last, - table: table - }; - }); - }); - }); - }; - var expandTo = function (finish, firstSelectedSelector) { - return ancestor$1(finish, 'table').bind(function (table) { - return descendant(table, firstSelectedSelector).bind(function (start) { - return identify(start, finish).bind(function (identified) { - return identified.boxes.map(function (boxes) { - return { - boxes: boxes, - start: identified.start, - finish: identified.finish - }; - }); - }); - }); - }); - }; - var shiftSelection = function (boxes, deltaRow, deltaColumn, firstSelectedSelector, lastSelectedSelector) { - return getLast(boxes, lastSelectedSelector).bind(function (last) { - return moveBy(last, deltaRow, deltaColumn).bind(function (finish) { - return expandTo(finish, firstSelectedSelector); - }); - }); - }; - - var retrieve = function (container, selector) { - return retrieve$1(container, selector); - }; - var retrieveBox = function (container, firstSelectedSelector, lastSelectedSelector) { - return getEdges(container, firstSelectedSelector, lastSelectedSelector).bind(function (edges) { - var isRoot = function (ancestor) { - return eq$1(container, ancestor); - }; - var sectionSelector = 'thead,tfoot,tbody,table'; - var firstAncestor = ancestor$1(edges.first, sectionSelector, isRoot); - var lastAncestor = ancestor$1(edges.last, sectionSelector, isRoot); - return firstAncestor.bind(function (fA) { - return lastAncestor.bind(function (lA) { - return eq$1(fA, lA) ? getBox(edges.table, edges.first, edges.last) : Optional.none(); - }); - }); - }); - }; - - var generate = function (cases) { - if (!isArray(cases)) { - throw new Error('cases must be an array'); - } - if (cases.length === 0) { - throw new Error('there must be at least one case'); - } - var constructors = []; - var adt = {}; - each$2(cases, function (acase, count) { - var keys$1 = keys(acase); - if (keys$1.length !== 1) { - throw new Error('one and only one name per case'); - } - var key = keys$1[0]; - var value = acase[key]; - if (adt[key] !== undefined) { - throw new Error('duplicate key detected:' + key); - } else if (key === 'cata') { - throw new Error('cannot have a case named cata (sorry)'); - } else if (!isArray(value)) { - throw new Error('case arguments must be an array'); - } - constructors.push(key); - adt[key] = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var argLength = args.length; - if (argLength !== value.length) { - throw new Error('Wrong number of arguments to case ' + key + '. Expected ' + value.length + ' (' + value + '), got ' + argLength); - } - var match = function (branches) { - var branchKeys = keys(branches); - if (constructors.length !== branchKeys.length) { - throw new Error('Wrong number of arguments to match. Expected: ' + constructors.join(',') + '\nActual: ' + branchKeys.join(',')); - } - var allReqd = forall(constructors, function (reqKey) { - return contains$2(branchKeys, reqKey); - }); - if (!allReqd) { - throw new Error('Not all branches were specified when using match. Specified: ' + branchKeys.join(', ') + '\nRequired: ' + constructors.join(', ')); - } - return branches[key].apply(null, args); - }; - return { - fold: function () { - var foldArgs = []; - for (var _i = 0; _i < arguments.length; _i++) { - foldArgs[_i] = arguments[_i]; - } - if (foldArgs.length !== cases.length) { - throw new Error('Wrong number of arguments to fold. Expected ' + cases.length + ', got ' + foldArgs.length); - } - var target = foldArgs[count]; - return target.apply(null, args); - }, - match: match, - log: function (label) { - console.log(label, { - constructors: constructors, - constructor: key, - params: args - }); - } - }; - }; - }); - return adt; - }; - var Adt = { generate: generate }; - - var type = Adt.generate([ - { none: [] }, - { multiple: ['elements'] }, - { single: ['element'] } - ]); - var cata$2 = function (subject, onNone, onMultiple, onSingle) { - return subject.fold(onNone, onMultiple, onSingle); - }; - var none$1 = type.none; - var multiple = type.multiple; - var single = type.single; - - var Selections = function (lazyRoot, getStart, selectedSelector) { - var get = function () { - return retrieve(lazyRoot(), selectedSelector).fold(function () { - return getStart().fold(none$1, single); - }, function (cells) { - return multiple(cells); - }); - }; - return { get: get }; - }; - - var global$3 = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - var clone = function (original, isDeep) { - return SugarElement.fromDom(original.dom.cloneNode(isDeep)); - }; - var shallow = function (original) { - return clone(original, false); - }; - var deep = function (original) { - return clone(original, true); - }; - var shallowAs = function (original, tag) { - var nu = SugarElement.fromTag(tag); - var attributes = clone$2(original); - setAll$1(nu, attributes); - return nu; - }; - var copy$1 = function (original, tag) { - var nu = shallowAs(original, tag); - var cloneChildren = children$3(deep(original)); - append(nu, cloneChildren); - return nu; - }; - var mutate$1 = function (original, tag) { - var nu = shallowAs(original, tag); - before$4(original, nu); - var children = children$3(original); - append(nu, children); - remove$5(original); - return nu; - }; - - var Dimension = function (name, getOffset) { - var set = function (element, h) { - if (!isNumber(h) && !h.match(/^[0-9]+$/)) { - throw new Error(name + '.set accepts only positive integer values. Value was ' + h); - } - var dom = element.dom; - if (isSupported(dom)) { - dom.style[name] = h + 'px'; - } - }; - var get = function (element) { - var r = getOffset(element); - if (r <= 0 || r === null) { - var css = get$a(element, name); - return parseFloat(css) || 0; - } - return r; - }; - var getOuter = get; - var aggregate = function (element, properties) { - return foldl(properties, function (acc, property) { - var val = get$a(element, property); - var value = val === undefined ? 0 : parseInt(val, 10); - return isNaN(value) ? acc : acc + value; - }, 0); - }; - var max = function (element, value, properties) { - var cumulativeInclusions = aggregate(element, properties); - var absoluteMax = value > cumulativeInclusions ? value - cumulativeInclusions : 0; - return absoluteMax; - }; - return { - set: set, - get: get, - getOuter: getOuter, - aggregate: aggregate, - max: max - }; - }; - - var needManualCalc = function () { - var browser = detect$3().browser; - return browser.isIE() || browser.isEdge(); - }; - var toNumber = function (px, fallback) { - return toFloat(px).getOr(fallback); - }; - var getProp = function (element, name, fallback) { - return toNumber(get$a(element, name), fallback); - }; - var getBoxSizing = function (element) { - return get$a(element, 'box-sizing'); - }; - var calcContentBoxSize = function (element, size, upper, lower) { - var paddingUpper = getProp(element, 'padding-' + upper, 0); - var paddingLower = getProp(element, 'padding-' + lower, 0); - var borderUpper = getProp(element, 'border-' + upper + '-width', 0); - var borderLower = getProp(element, 'border-' + lower + '-width', 0); - return size - paddingUpper - paddingLower - borderUpper - borderLower; - }; - var getCalculatedHeight = function (element, boxSizing) { - var dom = element.dom; - var height = dom.getBoundingClientRect().height || dom.offsetHeight; - return boxSizing === 'border-box' ? height : calcContentBoxSize(element, height, 'top', 'bottom'); - }; - var getCalculatedWidth = function (element, boxSizing) { - var dom = element.dom; - var width = dom.getBoundingClientRect().width || dom.offsetWidth; - return boxSizing === 'border-box' ? width : calcContentBoxSize(element, width, 'left', 'right'); - }; - var getHeight$1 = function (element) { - return needManualCalc() ? getCalculatedHeight(element, getBoxSizing(element)) : getProp(element, 'height', element.dom.offsetHeight); - }; - var getWidth = function (element) { - return needManualCalc() ? getCalculatedWidth(element, getBoxSizing(element)) : getProp(element, 'width', element.dom.offsetWidth); - }; - var getInnerWidth = function (element) { - return getCalculatedWidth(element, 'content-box'); - }; - - var api$1 = Dimension('width', function (element) { - return element.dom.offsetWidth; - }); - var get$8 = function (element) { - return api$1.get(element); - }; - var getOuter$2 = function (element) { - return api$1.getOuter(element); - }; - var getInner = getInnerWidth; - var getRuntime$1 = getWidth; - - var columns = function (warehouse, isValidCell) { - if (isValidCell === void 0) { - isValidCell = always; - } - var grid = warehouse.grid; - var cols = range$1(grid.columns, identity); - var rowsArr = range$1(grid.rows, identity); - return map$1(cols, function (col) { - var getBlock = function () { - return bind$2(rowsArr, function (r) { - return Warehouse.getAt(warehouse, r, col).filter(function (detail) { - return detail.column === col; - }).toArray(); - }); - }; - var isValid = function (detail) { - return detail.colspan === 1 && isValidCell(detail.element); - }; - var getFallback = function () { - return Warehouse.getAt(warehouse, 0, col); - }; - return decide(getBlock, isValid, getFallback); - }); - }; - var decide = function (getBlock, isValid, getFallback) { - var inBlock = getBlock(); - var validInBlock = find$1(inBlock, isValid); - var detailOption = validInBlock.orThunk(function () { - return Optional.from(inBlock[0]).orThunk(getFallback); - }); - return detailOption.map(function (detail) { - return detail.element; - }); - }; - var rows = function (warehouse) { - var grid = warehouse.grid; - var rowsArr = range$1(grid.rows, identity); - var cols = range$1(grid.columns, identity); - return map$1(rowsArr, function (row) { - var getBlock = function () { - return bind$2(cols, function (c) { - return Warehouse.getAt(warehouse, row, c).filter(function (detail) { - return detail.row === row; - }).fold(constant([]), function (detail) { - return [detail]; - }); - }); - }; - var isSingle = function (detail) { - return detail.rowspan === 1; - }; - var getFallback = function () { - return Warehouse.getAt(warehouse, row, 0); - }; - return decide(getBlock, isSingle, getFallback); - }); - }; - - var deduce = function (xs, index) { - if (index < 0 || index >= xs.length - 1) { - return Optional.none(); - } - var current = xs[index].fold(function () { - var rest = reverse(xs.slice(0, index)); - return findMap(rest, function (a, i) { - return a.map(function (aa) { - return { - value: aa, - delta: i + 1 - }; - }); - }); - }, function (c) { - return Optional.some({ - value: c, - delta: 0 - }); - }); - var next = xs[index + 1].fold(function () { - var rest = xs.slice(index + 1); - return findMap(rest, function (a, i) { - return a.map(function (aa) { - return { - value: aa, - delta: i + 1 - }; - }); - }); - }, function (n) { - return Optional.some({ - value: n, - delta: 1 - }); - }); - return current.bind(function (c) { - return next.map(function (n) { - var extras = n.delta + c.delta; - return Math.abs(n.value - c.value) / extras; - }); - }); - }; - - var onDirection = function (isLtr, isRtl) { - return function (element) { - return getDirection(element) === 'rtl' ? isRtl : isLtr; - }; - }; - var getDirection = function (element) { - return get$a(element, 'direction') === 'rtl' ? 'rtl' : 'ltr'; - }; - - var api = Dimension('height', function (element) { - var dom = element.dom; - return inBody(element) ? dom.getBoundingClientRect().height : dom.offsetHeight; - }); - var get$7 = function (element) { - return api.get(element); - }; - var getOuter$1 = function (element) { - return api.getOuter(element); - }; - var getRuntime = getHeight$1; - - var r = function (left, top) { - var translate = function (x, y) { - return r(left + x, top + y); - }; - return { - left: left, - top: top, - translate: translate - }; - }; - var SugarPosition = r; - - var boxPosition = function (dom) { - var box = dom.getBoundingClientRect(); - return SugarPosition(box.left, box.top); - }; - var firstDefinedOrZero = function (a, b) { - if (a !== undefined) { - return a; - } else { - return b !== undefined ? b : 0; - } - }; - var absolute = function (element) { - var doc = element.dom.ownerDocument; - var body = doc.body; - var win = doc.defaultView; - var html = doc.documentElement; - if (body === element.dom) { - return SugarPosition(body.offsetLeft, body.offsetTop); - } - var scrollTop = firstDefinedOrZero(win === null || win === void 0 ? void 0 : win.pageYOffset, html.scrollTop); - var scrollLeft = firstDefinedOrZero(win === null || win === void 0 ? void 0 : win.pageXOffset, html.scrollLeft); - var clientTop = firstDefinedOrZero(html.clientTop, body.clientTop); - var clientLeft = firstDefinedOrZero(html.clientLeft, body.clientLeft); - return viewport(element).translate(scrollLeft - clientLeft, scrollTop - clientTop); - }; - var viewport = function (element) { - var dom = element.dom; - var doc = dom.ownerDocument; - var body = doc.body; - if (body === dom) { - return SugarPosition(body.offsetLeft, body.offsetTop); - } - if (!inBody(element)) { - return SugarPosition(0, 0); - } - return boxPosition(dom); - }; - - var rowInfo = function (row, y) { - return { - row: row, - y: y - }; - }; - var colInfo = function (col, x) { - return { - col: col, - x: x - }; - }; - var rtlEdge = function (cell) { - var pos = absolute(cell); - return pos.left + getOuter$2(cell); - }; - var ltrEdge = function (cell) { - return absolute(cell).left; - }; - var getLeftEdge = function (index, cell) { - return colInfo(index, ltrEdge(cell)); - }; - var getRightEdge = function (index, cell) { - return colInfo(index, rtlEdge(cell)); - }; - var getTop$1 = function (cell) { - return absolute(cell).top; - }; - var getTopEdge = function (index, cell) { - return rowInfo(index, getTop$1(cell)); - }; - var getBottomEdge = function (index, cell) { - return rowInfo(index, getTop$1(cell) + getOuter$1(cell)); - }; - var findPositions = function (getInnerEdge, getOuterEdge, array) { - if (array.length === 0) { - return []; - } - var lines = map$1(array.slice(1), function (cellOption, index) { - return cellOption.map(function (cell) { - return getInnerEdge(index, cell); - }); - }); - var lastLine = array[array.length - 1].map(function (cell) { - return getOuterEdge(array.length - 1, cell); - }); - return lines.concat([lastLine]); - }; - var negate = function (step) { - return -step; - }; - var height = { - delta: identity, - positions: function (optElements) { - return findPositions(getTopEdge, getBottomEdge, optElements); - }, - edge: getTop$1 - }; - var ltr$1 = { - delta: identity, - edge: ltrEdge, - positions: function (optElements) { - return findPositions(getLeftEdge, getRightEdge, optElements); - } - }; - var rtl$1 = { - delta: negate, - edge: rtlEdge, - positions: function (optElements) { - return findPositions(getRightEdge, getLeftEdge, optElements); - } - }; - var detect$2 = onDirection(ltr$1, rtl$1); - var width = { - delta: function (amount, table) { - return detect$2(table).delta(amount, table); - }, - positions: function (cols, table) { - return detect$2(table).positions(cols, table); - }, - edge: function (cell) { - return detect$2(cell).edge(cell); - } - }; - - var units = { - unsupportedLength: [ - 'em', - 'ex', - 'cap', - 'ch', - 'ic', - 'rem', - 'lh', - 'rlh', - 'vw', - 'vh', - 'vi', - 'vb', - 'vmin', - 'vmax', - 'cm', - 'mm', - 'Q', - 'in', - 'pc', - 'pt', - 'px' - ], - fixed: [ - 'px', - 'pt' - ], - relative: ['%'], - empty: [''] - }; - var pattern = function () { - var decimalDigits = '[0-9]+'; - var signedInteger = '[+-]?' + decimalDigits; - var exponentPart = '[eE]' + signedInteger; - var dot = '\\.'; - var opt = function (input) { - return '(?:' + input + ')?'; - }; - var unsignedDecimalLiteral = [ - 'Infinity', - decimalDigits + dot + opt(decimalDigits) + opt(exponentPart), - dot + decimalDigits + opt(exponentPart), - decimalDigits + opt(exponentPart) - ].join('|'); - var float = '[+-]?(?:' + unsignedDecimalLiteral + ')'; - return new RegExp('^(' + float + ')(.*)$'); - }(); - var isUnit = function (unit, accepted) { - return exists(accepted, function (acc) { - return exists(units[acc], function (check) { - return unit === check; - }); - }); - }; - var parse = function (input, accepted) { - var match = Optional.from(pattern.exec(input)); - return match.bind(function (array) { - var value = Number(array[1]); - var unitRaw = array[2]; - if (isUnit(unitRaw, accepted)) { - return Optional.some({ - value: value, - unit: unitRaw - }); - } else { - return Optional.none(); - } - }); - }; - - var rPercentageBasedSizeRegex = /(\d+(\.\d+)?)%/; - var rPixelBasedSizeRegex = /(\d+(\.\d+)?)px|em/; - var isCol$2 = isTag('col'); - var getPercentSize = function (elm, outerGetter, innerGetter) { - var relativeParent = parentElement(elm).getOrThunk(function () { - return getBody$1(owner(elm)); - }); - return outerGetter(elm) / innerGetter(relativeParent) * 100; - }; - var setPixelWidth = function (cell, amount) { - set$1(cell, 'width', amount + 'px'); - }; - var setPercentageWidth = function (cell, amount) { - set$1(cell, 'width', amount + '%'); - }; - var setHeight = function (cell, amount) { - set$1(cell, 'height', amount + 'px'); - }; - var getHeightValue = function (cell) { - return getRuntime(cell) + 'px'; - }; - var convert = function (cell, number, getter, setter) { - var newSize = table(cell).map(function (table) { - var total = getter(table); - return Math.floor(number / 100 * total); - }).getOr(number); - setter(cell, newSize); - return newSize; - }; - var normalizePixelSize = function (value, cell, getter, setter) { - var number = parseFloat(value); - return endsWith(value, '%') && name(cell) !== 'table' ? convert(cell, number, getter, setter) : number; - }; - var getTotalHeight = function (cell) { - var value = getHeightValue(cell); - if (!value) { - return get$7(cell); - } - return normalizePixelSize(value, cell, get$7, setHeight); - }; - var get$6 = function (cell, type, f) { - var v = f(cell); - var span = getSpan(cell, type); - return v / span; - }; - var getRaw$1 = function (element, prop) { - return getRaw$2(element, prop).orThunk(function () { - return getOpt(element, prop).map(function (val) { - return val + 'px'; - }); - }); - }; - var getRawWidth$1 = function (element) { - return getRaw$1(element, 'width'); - }; - var getRawHeight = function (element) { - return getRaw$1(element, 'height'); - }; - var getPercentageWidth = function (cell) { - return getPercentSize(cell, get$8, getInner); - }; - var getPixelWidth$1 = function (cell) { - return isCol$2(cell) ? get$8(cell) : getRuntime$1(cell); - }; - var getHeight = function (cell) { - return get$6(cell, 'rowspan', getTotalHeight); - }; - var getGenericWidth = function (cell) { - var width = getRawWidth$1(cell); - return width.bind(function (w) { - return parse(w, [ - 'fixed', - 'relative', - 'empty' - ]); - }); - }; - var setGenericWidth = function (cell, amount, unit) { - set$1(cell, 'width', amount + unit); - }; - var getPixelTableWidth = function (table) { - return get$8(table) + 'px'; - }; - var getPercentTableWidth = function (table) { - return getPercentSize(table, get$8, getInner) + '%'; - }; - var isPercentSizing$1 = function (table) { - return getRawWidth$1(table).exists(function (size) { - return rPercentageBasedSizeRegex.test(size); - }); - }; - var isPixelSizing$1 = function (table) { - return getRawWidth$1(table).exists(function (size) { - return rPixelBasedSizeRegex.test(size); - }); - }; - var isNoneSizing$1 = function (table) { - return getRawWidth$1(table).isNone(); - }; - var percentageBasedSizeRegex = constant(rPercentageBasedSizeRegex); - - var isCol$1 = isTag('col'); - var getRawW = function (cell) { - return getRawWidth$1(cell).getOrThunk(function () { - return getPixelWidth$1(cell) + 'px'; - }); - }; - var getRawH = function (cell) { - return getRawHeight(cell).getOrThunk(function () { - return getHeight(cell) + 'px'; - }); - }; - var justCols = function (warehouse) { - return map$1(Warehouse.justColumns(warehouse), function (column) { - return Optional.from(column.element); - }); - }; - var isValidColumn = function (cell) { - var browser = detect$3().browser; - var supportsColWidths = browser.isChrome() || browser.isFirefox(); - return isCol$1(cell) ? supportsColWidths : true; - }; - var getDimension = function (cellOpt, index, backups, filter, getter, fallback) { - return cellOpt.filter(filter).fold(function () { - return fallback(deduce(backups, index)); - }, function (cell) { - return getter(cell); - }); - }; - var getWidthFrom = function (warehouse, table, getWidth, fallback) { - var columnCells = columns(warehouse); - var columns$1 = Warehouse.hasColumns(warehouse) ? justCols(warehouse) : columnCells; - var backups = [Optional.some(width.edge(table))].concat(map$1(width.positions(columnCells, table), function (pos) { - return pos.map(function (p) { - return p.x; - }); - })); - var colFilter = not(hasColspan); - return map$1(columns$1, function (cellOption, c) { - return getDimension(cellOption, c, backups, colFilter, function (column) { - if (isValidColumn(column)) { - return getWidth(column); - } else { - var cell = bindFrom(columnCells[c], identity); - return getDimension(cell, c, backups, colFilter, function (cell) { - return fallback(Optional.some(get$8(cell))); - }, fallback); - } - }, fallback); - }); - }; - var getDeduced = function (deduced) { - return deduced.map(function (d) { - return d + 'px'; - }).getOr(''); - }; - var getRawWidths = function (warehouse, table) { - return getWidthFrom(warehouse, table, getRawW, getDeduced); - }; - var getPercentageWidths = function (warehouse, table, tableSize) { - return getWidthFrom(warehouse, table, getPercentageWidth, function (deduced) { - return deduced.fold(function () { - return tableSize.minCellWidth(); - }, function (cellWidth) { - return cellWidth / tableSize.pixelWidth() * 100; - }); - }); - }; - var getPixelWidths = function (warehouse, table, tableSize) { - return getWidthFrom(warehouse, table, getPixelWidth$1, function (deduced) { - return deduced.getOrThunk(tableSize.minCellWidth); - }); - }; - var getHeightFrom = function (warehouse, table, direction, getHeight, fallback) { - var rows$1 = rows(warehouse); - var backups = [Optional.some(direction.edge(table))].concat(map$1(direction.positions(rows$1, table), function (pos) { - return pos.map(function (p) { - return p.y; - }); - })); - return map$1(rows$1, function (cellOption, c) { - return getDimension(cellOption, c, backups, not(hasRowspan), getHeight, fallback); - }); - }; - var getPixelHeights = function (warehouse, table, direction) { - return getHeightFrom(warehouse, table, direction, getHeight, function (deduced) { - return deduced.getOrThunk(minHeight); - }); - }; - var getRawHeights = function (warehouse, table, direction) { - return getHeightFrom(warehouse, table, direction, getRawH, getDeduced); - }; - - var widthLookup = function (table, getter) { - return function () { - if (inBody(table)) { - return getter(table); - } else { - return parseFloat(getRaw$2(table, 'width').getOr('0')); - } - }; - }; - var noneSize = function (table) { - var getWidth = widthLookup(table, get$8); - var zero = constant(0); - var getWidths = function (warehouse, tableSize) { - return getPixelWidths(warehouse, table, tableSize); - }; - return { - width: getWidth, - pixelWidth: getWidth, - getWidths: getWidths, - getCellDelta: zero, - singleColumnWidth: constant([0]), - minCellWidth: zero, - setElementWidth: noop, - adjustTableWidth: noop, - isRelative: true, - label: 'none' - }; - }; - var percentageSize = function (table) { - var getFloatWidth = widthLookup(table, function (elem) { - return parseFloat(getPercentTableWidth(elem)); - }); - var getWidth = widthLookup(table, get$8); - var getCellDelta = function (delta) { - return delta / getWidth() * 100; - }; - var singleColumnWidth = function (w, _delta) { - return [100 - w]; - }; - var minCellWidth = function () { - return minWidth() / getWidth() * 100; - }; - var adjustTableWidth = function (delta) { - var currentWidth = getFloatWidth(); - var change = delta / 100 * currentWidth; - var newWidth = currentWidth + change; - setPercentageWidth(table, newWidth); - }; - var getWidths = function (warehouse, tableSize) { - return getPercentageWidths(warehouse, table, tableSize); - }; - return { - width: getFloatWidth, - pixelWidth: getWidth, - getWidths: getWidths, - getCellDelta: getCellDelta, - singleColumnWidth: singleColumnWidth, - minCellWidth: minCellWidth, - setElementWidth: setPercentageWidth, - adjustTableWidth: adjustTableWidth, - isRelative: true, - label: 'percent' - }; - }; - var pixelSize = function (table) { - var getWidth = widthLookup(table, get$8); - var getCellDelta = identity; - var singleColumnWidth = function (w, delta) { - var newNext = Math.max(minWidth(), w + delta); - return [newNext - w]; - }; - var adjustTableWidth = function (delta) { - var newWidth = getWidth() + delta; - setPixelWidth(table, newWidth); - }; - var getWidths = function (warehouse, tableSize) { - return getPixelWidths(warehouse, table, tableSize); - }; - return { - width: getWidth, - pixelWidth: getWidth, - getWidths: getWidths, - getCellDelta: getCellDelta, - singleColumnWidth: singleColumnWidth, - minCellWidth: minWidth, - setElementWidth: setPixelWidth, - adjustTableWidth: adjustTableWidth, - isRelative: false, - label: 'pixel' - }; - }; - var chooseSize = function (element, width) { - var percentMatch = percentageBasedSizeRegex().exec(width); - if (percentMatch !== null) { - return percentageSize(element); - } else { - return pixelSize(element); - } - }; - var getTableSize = function (table) { - var width = getRawWidth$1(table); - return width.fold(function () { - return noneSize(table); - }, function (w) { - return chooseSize(table, w); - }); - }; - var TableSize = { - getTableSize: getTableSize, - pixelSize: pixelSize, - percentageSize: percentageSize, - noneSize: noneSize - }; - - var statsStruct = function (minRow, minCol, maxRow, maxCol, allCells, selectedCells) { - return { - minRow: minRow, - minCol: minCol, - maxRow: maxRow, - maxCol: maxCol, - allCells: allCells, - selectedCells: selectedCells - }; - }; - var findSelectedStats = function (house, isSelected) { - var totalColumns = house.grid.columns; - var totalRows = house.grid.rows; - var minRow = totalRows; - var minCol = totalColumns; - var maxRow = 0; - var maxCol = 0; - var allCells = []; - var selectedCells = []; - each$1(house.access, function (detail) { - allCells.push(detail); - if (isSelected(detail)) { - selectedCells.push(detail); - var startRow = detail.row; - var endRow = startRow + detail.rowspan - 1; - var startCol = detail.column; - var endCol = startCol + detail.colspan - 1; - if (startRow < minRow) { - minRow = startRow; - } else if (endRow > maxRow) { - maxRow = endRow; - } - if (startCol < minCol) { - minCol = startCol; - } else if (endCol > maxCol) { - maxCol = endCol; - } - } - }); - return statsStruct(minRow, minCol, maxRow, maxCol, allCells, selectedCells); - }; - var makeCell = function (list, seenSelected, rowIndex) { - var row = list[rowIndex].element; - var td = SugarElement.fromTag('td'); - append$1(td, SugarElement.fromTag('br')); - var f = seenSelected ? append$1 : prepend; - f(row, td); - }; - var fillInGaps = function (list, house, stats, isSelected) { - var totalColumns = house.grid.columns; - var totalRows = house.grid.rows; - for (var i = 0; i < totalRows; i++) { - var seenSelected = false; - for (var j = 0; j < totalColumns; j++) { - if (!(i < stats.minRow || i > stats.maxRow || j < stats.minCol || j > stats.maxCol)) { - var needCell = Warehouse.getAt(house, i, j).filter(isSelected).isNone(); - if (needCell) { - makeCell(list, seenSelected, i); - } else { - seenSelected = true; - } - } - } - } - }; - var clean = function (replica, stats, house, widthDelta) { - each$1(house.columns, function (col) { - if (col.column < stats.minCol || col.column > stats.maxCol) { - remove$5(col.element); - } - }); - var emptyRows = filter$2(firstLayer(replica, 'tr'), function (row) { - return row.dom.childElementCount === 0; - }); - each$2(emptyRows, remove$5); - if (stats.minCol === stats.maxCol || stats.minRow === stats.maxRow) { - each$2(firstLayer(replica, 'th,td'), function (cell) { - remove$7(cell, 'rowspan'); - remove$7(cell, 'colspan'); - }); - } - remove$7(replica, LOCKED_COL_ATTR); - remove$7(replica, 'data-snooker-col-series'); - var tableSize = TableSize.getTableSize(replica); - tableSize.adjustTableWidth(widthDelta); - }; - var getTableWidthDelta = function (table, warehouse, tableSize, stats) { - if (stats.minCol === 0 && warehouse.grid.columns === stats.maxCol + 1) { - return 0; - } - var colWidths = getPixelWidths(warehouse, table, tableSize); - var allColsWidth = foldl(colWidths, function (acc, width) { - return acc + width; - }, 0); - var selectedColsWidth = foldl(colWidths.slice(stats.minCol, stats.maxCol + 1), function (acc, width) { - return acc + width; - }, 0); - var newWidth = selectedColsWidth / allColsWidth * tableSize.pixelWidth(); - var delta = newWidth - tableSize.pixelWidth(); - return tableSize.getCellDelta(delta); - }; - var extract$1 = function (table, selectedSelector) { - var isSelected = function (detail) { - return is$2(detail.element, selectedSelector); - }; - var replica = deep(table); - var list = fromTable$1(replica); - var tableSize = TableSize.getTableSize(table); - var replicaHouse = Warehouse.generate(list); - var replicaStats = findSelectedStats(replicaHouse, isSelected); - var selector = 'th:not(' + selectedSelector + ')' + ',td:not(' + selectedSelector + ')'; - var unselectedCells = filterFirstLayer(replica, 'th,td', function (cell) { - return is$2(cell, selector); - }); - each$2(unselectedCells, remove$5); - fillInGaps(list, replicaHouse, replicaStats, isSelected); - var house = Warehouse.fromTable(table); - var widthDelta = getTableWidthDelta(table, house, tableSize, replicaStats); - clean(replica, replicaStats, replicaHouse, widthDelta); - return replica; - }; - - var nbsp = '\xA0'; - - var getEnd = function (element) { - return name(element) === 'img' ? 1 : getOption(element).fold(function () { - return children$3(element).length; - }, function (v) { - return v.length; - }); - }; - var isTextNodeWithCursorPosition = function (el) { - return getOption(el).filter(function (text) { - return text.trim().length !== 0 || text.indexOf(nbsp) > -1; - }).isSome(); - }; - var elementsWithCursorPosition = [ - 'img', - 'br' - ]; - var isCursorPosition = function (elem) { - var hasCursorPosition = isTextNodeWithCursorPosition(elem); - return hasCursorPosition || contains$2(elementsWithCursorPosition, name(elem)); - }; - - var first = function (element) { - return descendant$1(element, isCursorPosition); - }; - var last$1 = function (element) { - return descendantRtl(element, isCursorPosition); - }; - var descendantRtl = function (scope, predicate) { - var descend = function (element) { - var children = children$3(element); - for (var i = children.length - 1; i >= 0; i--) { - var child = children[i]; - if (predicate(child)) { - return Optional.some(child); - } - var res = descend(child); - if (res.isSome()) { - return res; - } - } - return Optional.none(); - }; - return descend(scope); - }; - - var transferableAttributes = { - scope: [ - 'row', - 'col' - ] - }; - var createCell = function (doc) { - return function () { - var td = SugarElement.fromTag('td', doc.dom); - append$1(td, SugarElement.fromTag('br', doc.dom)); - return td; - }; - }; - var createCol = function (doc) { - return function () { - return SugarElement.fromTag('col', doc.dom); - }; - }; - var createColgroup = function (doc) { - return function () { - return SugarElement.fromTag('colgroup', doc.dom); - }; - }; - var createRow$1 = function (doc) { - return function () { - return SugarElement.fromTag('tr', doc.dom); - }; - }; - var replace$1 = function (cell, tag, attrs) { - var replica = copy$1(cell, tag); - each$1(attrs, function (v, k) { - if (v === null) { - remove$7(replica, k); - } else { - set$2(replica, k, v); - } - }); - return replica; - }; - var pasteReplace = function (cell) { - return cell; - }; - var cloneFormats = function (oldCell, newCell, formats) { - var first$1 = first(oldCell); - return first$1.map(function (firstText) { - var formatSelector = formats.join(','); - var parents = ancestors$3(firstText, formatSelector, function (element) { - return eq$1(element, oldCell); - }); - return foldr(parents, function (last, parent) { - var clonedFormat = shallow(parent); - remove$7(clonedFormat, 'contenteditable'); - append$1(last, clonedFormat); - return clonedFormat; - }, newCell); - }).getOr(newCell); - }; - var cloneAppropriateAttributes = function (original, clone) { - each$1(transferableAttributes, function (validAttributes, attributeName) { - return getOpt(original, attributeName).filter(function (attribute) { - return contains$2(validAttributes, attribute); - }).each(function (attribute) { - return set$2(clone, attributeName, attribute); - }); - }); - }; - var cellOperations = function (mutate, doc, formatsToClone) { - var cloneCss = function (prev, clone) { - copy$2(prev.element, clone); - remove$6(clone, 'height'); - if (prev.colspan !== 1) { - remove$6(clone, 'width'); - } - }; - var newCell = function (prev) { - var td = SugarElement.fromTag(name(prev.element), doc.dom); - var formats = formatsToClone.getOr([ - 'strong', - 'em', - 'b', - 'i', - 'span', - 'font', - 'h1', - 'h2', - 'h3', - 'h4', - 'h5', - 'h6', - 'p', - 'div' - ]); - var lastNode = formats.length > 0 ? cloneFormats(prev.element, td, formats) : td; - append$1(lastNode, SugarElement.fromTag('br')); - cloneCss(prev, td); - cloneAppropriateAttributes(prev.element, td); - mutate(prev.element, td); - return td; - }; - var newCol = function (prev) { - var col = SugarElement.fromTag(name(prev.element), doc.dom); - cloneCss(prev, col); - mutate(prev.element, col); - return col; - }; - return { - col: newCol, - colgroup: createColgroup(doc), - row: createRow$1(doc), - cell: newCell, - replace: replace$1, - colGap: createCol(doc), - gap: createCell(doc) - }; - }; - var paste$1 = function (doc) { - return { - col: createCol(doc), - colgroup: createColgroup(doc), - row: createRow$1(doc), - cell: createCell(doc), - replace: pasteReplace, - colGap: createCol(doc), - gap: createCell(doc) - }; - }; - - var fromHtml = function (html, scope) { - var doc = scope || document; - var div = doc.createElement('div'); - div.innerHTML = html; - return children$3(SugarElement.fromDom(div)); - }; - var fromDom = function (nodes) { - return map$1(nodes, SugarElement.fromDom); - }; - - var getNodeName = function (elm) { - return elm.nodeName.toLowerCase(); - }; - var getBody = function (editor) { - return SugarElement.fromDom(editor.getBody()); - }; - var getPixelWidth = function (elm) { - return elm.getBoundingClientRect().width; - }; - var getPixelHeight = function (elm) { - return elm.getBoundingClientRect().height; - }; - var getIsRoot = function (editor) { - return function (element) { - return eq$1(element, getBody(editor)); - }; - }; - var removePxSuffix = function (size) { - return size ? size.replace(/px$/, '') : ''; - }; - var addPxSuffix = function (size) { - return /^\d+(\.\d+)?$/.test(size) ? size + 'px' : size; - }; - var removeDataStyle = function (table) { - remove$7(table, 'data-mce-style'); - var removeStyleAttribute = function (element) { - return remove$7(element, 'data-mce-style'); - }; - each$2(cells$1(table), removeStyleAttribute); - each$2(columns$1(table), removeStyleAttribute); - each$2(rows$1(table), removeStyleAttribute); - }; - var getRawWidth = function (editor, elm) { - var raw = editor.dom.getStyle(elm, 'width') || editor.dom.getAttrib(elm, 'width'); - return Optional.from(raw).filter(isNotEmpty); - }; - var isPercentage$1 = function (value) { - return /^(\d+(\.\d+)?)%$/.test(value); - }; - var isPixel = function (value) { - return /^(\d+(\.\d+)?)px$/.test(value); - }; - var getSelectionStart = function (editor) { - return SugarElement.fromDom(editor.selection.getStart()); - }; - var getSelectionEnd = function (editor) { - return SugarElement.fromDom(editor.selection.getEnd()); - }; - - var selection = function (selections) { - return cata$2(selections.get(), constant([]), identity, pure); - }; - var unmergable = function (selections) { - var hasSpan = function (elem, type) { - return getOpt(elem, type).exists(function (span) { - return parseInt(span, 10) > 1; - }); - }; - var hasRowOrColSpan = function (elem) { - return hasSpan(elem, 'rowspan') || hasSpan(elem, 'colspan'); - }; - var candidates = selection(selections); - return candidates.length > 0 && forall(candidates, hasRowOrColSpan) ? Optional.some(candidates) : Optional.none(); - }; - var mergable = function (table, selections, ephemera) { - return cata$2(selections.get(), Optional.none, function (cells) { - if (cells.length <= 1) { - return Optional.none(); - } else { - return retrieveBox(table, ephemera.firstSelectedSelector, ephemera.lastSelectedSelector).map(function (bounds) { - return { - bounds: bounds, - cells: cells - }; - }); - } - }, Optional.none); - }; - - var strSelected = 'data-mce-selected'; - var strSelectedSelector = 'td[' + strSelected + '],th[' + strSelected + ']'; - var strAttributeSelector = '[' + strSelected + ']'; - var strFirstSelected = 'data-mce-first-selected'; - var strFirstSelectedSelector = 'td[' + strFirstSelected + '],th[' + strFirstSelected + ']'; - var strLastSelected = 'data-mce-last-selected'; - var strLastSelectedSelector = 'td[' + strLastSelected + '],th[' + strLastSelected + ']'; - var attributeSelector = strAttributeSelector; - var ephemera = { - selected: strSelected, - selectedSelector: strSelectedSelector, - firstSelected: strFirstSelected, - firstSelectedSelector: strFirstSelectedSelector, - lastSelected: strLastSelected, - lastSelectedSelector: strLastSelectedSelector - }; - - var noMenu = function (cell) { - return { - element: cell, - mergable: Optional.none(), - unmergable: Optional.none(), - selection: [cell] - }; - }; - var forMenu = function (selections, table, cell) { - return { - element: cell, - mergable: mergable(table, selections, ephemera), - unmergable: unmergable(selections), - selection: selection(selections) - }; - }; - var paste = function (element, clipboard, generators) { - return { - element: element, - clipboard: clipboard, - generators: generators - }; - }; - var pasteRows = function (selections, cell, clipboard, generators) { - return { - selection: selection(selections), - clipboard: clipboard, - generators: generators - }; - }; - - var getSelectionCellFallback = function (element) { - return table(element).bind(function (table) { - return retrieve(table, ephemera.firstSelectedSelector); - }).fold(constant(element), function (cells) { - return cells[0]; - }); - }; - var getSelectionFromSelector = function (selector) { - return function (initCell, isRoot) { - var cellName = name(initCell); - var cell = cellName === 'col' || cellName === 'colgroup' ? getSelectionCellFallback(initCell) : initCell; - return closest$1(cell, selector, isRoot); - }; - }; - var getSelectionCellOrCaption = getSelectionFromSelector('th,td,caption'); - var getSelectionCell = getSelectionFromSelector('th,td'); - var getCellsFromSelection = function (selections) { - return selection(selections); - }; - var getRowsFromSelection = function (selected, selector) { - var cellOpt = getSelectionCell(selected); - var rowsOpt = cellOpt.bind(function (cell) { - return table(cell); - }).map(function (table) { - return rows$1(table); - }); - return lift2(cellOpt, rowsOpt, function (cell, rows) { - return filter$2(rows, function (row) { - return exists(fromDom(row.dom.cells), function (rowCell) { - return get$b(rowCell, selector) === '1' || eq$1(rowCell, cell); - }); - }); - }).getOr([]); - }; - - var extractSelected = function (cells) { - return table(cells[0]).map(function (table) { - var replica = extract$1(table, attributeSelector); - removeDataStyle(replica); - return [replica]; - }); - }; - var serializeElements = function (editor, elements) { - return map$1(elements, function (elm) { - return editor.selection.serializer.serialize(elm.dom, {}); - }).join(''); - }; - var getTextContent = function (elements) { - return map$1(elements, function (element) { - return element.dom.innerText; - }).join(''); - }; - var registerEvents = function (editor, selections, actions) { - editor.on('BeforeGetContent', function (e) { - var multiCellContext = function (cells) { - e.preventDefault(); - extractSelected(cells).each(function (elements) { - e.content = e.format === 'text' ? getTextContent(elements) : serializeElements(editor, elements); - }); - }; - if (e.selection === true) { - cata$2(selections.get(), noop, multiCellContext, noop); - } - }); - editor.on('BeforeSetContent', function (e) { - if (e.selection === true && e.paste === true) { - var selectedCells = getCellsFromSelection(selections); - head(selectedCells).each(function (cell) { - table(cell).each(function (table) { - var elements = filter$2(fromHtml(e.content), function (content) { - return name(content) !== 'meta'; - }); - var isTable = isTag('table'); - if (elements.length === 1 && isTable(elements[0])) { - e.preventDefault(); - var doc = SugarElement.fromDom(editor.getDoc()); - var generators = paste$1(doc); - var targets = paste(cell, elements[0], generators); - actions.pasteCells(table, targets).each(function () { - editor.focus(); - }); - } - }); - }); - } - }); - }; - - var adt$7 = Adt.generate([ - { none: [] }, - { only: ['index'] }, - { - left: [ - 'index', - 'next' - ] - }, - { - middle: [ - 'prev', - 'index', - 'next' - ] - }, - { - right: [ - 'prev', - 'index' - ] - } - ]); - var ColumnContext = __assign({}, adt$7); - - var neighbours = function (input, index) { - if (input.length === 0) { - return ColumnContext.none(); - } - if (input.length === 1) { - return ColumnContext.only(0); - } - if (index === 0) { - return ColumnContext.left(0, 1); - } - if (index === input.length - 1) { - return ColumnContext.right(index - 1, index); - } - if (index > 0 && index < input.length - 1) { - return ColumnContext.middle(index - 1, index, index + 1); - } - return ColumnContext.none(); - }; - var determine = function (input, column, step, tableSize, resize) { - var result = input.slice(0); - var context = neighbours(input, column); - var onNone = constant(map$1(result, constant(0))); - var onOnly = function (index) { - return tableSize.singleColumnWidth(result[index], step); - }; - var onLeft = function (index, next) { - return resize.calcLeftEdgeDeltas(result, index, next, step, tableSize.minCellWidth(), tableSize.isRelative); - }; - var onMiddle = function (prev, index, next) { - return resize.calcMiddleDeltas(result, prev, index, next, step, tableSize.minCellWidth(), tableSize.isRelative); - }; - var onRight = function (prev, index) { - return resize.calcRightEdgeDeltas(result, prev, index, step, tableSize.minCellWidth(), tableSize.isRelative); - }; - return context.fold(onNone, onOnly, onLeft, onMiddle, onRight); - }; - - var total = function (start, end, measures) { - var r = 0; - for (var i = start; i < end; i++) { - r += measures[i] !== undefined ? measures[i] : 0; - } - return r; - }; - var recalculateWidthForCells = function (warehouse, widths) { - var all = Warehouse.justCells(warehouse); - return map$1(all, function (cell) { - var width = total(cell.column, cell.column + cell.colspan, widths); - return { - element: cell.element, - width: width, - colspan: cell.colspan - }; - }); - }; - var recalculateWidthForColumns = function (warehouse, widths) { - var groups = Warehouse.justColumns(warehouse); - return map$1(groups, function (column, index) { - return { - element: column.element, - width: widths[index], - colspan: column.colspan - }; - }); - }; - var recalculateHeightForCells = function (warehouse, heights) { - var all = Warehouse.justCells(warehouse); - return map$1(all, function (cell) { - var height = total(cell.row, cell.row + cell.rowspan, heights); - return { - element: cell.element, - height: height, - rowspan: cell.rowspan - }; - }); - }; - var matchRowHeight = function (warehouse, heights) { - return map$1(warehouse.all, function (row, i) { - return { - element: row.element, - height: heights[i] - }; - }); - }; - - var sumUp = function (newSize) { - return foldr(newSize, function (b, a) { - return b + a; - }, 0); - }; - var recalculate = function (warehouse, widths) { - if (Warehouse.hasColumns(warehouse)) { - return recalculateWidthForColumns(warehouse, widths); - } else { - return recalculateWidthForCells(warehouse, widths); - } - }; - var recalculateAndApply = function (warehouse, widths, tableSize) { - var newSizes = recalculate(warehouse, widths); - each$2(newSizes, function (cell) { - tableSize.setElementWidth(cell.element, cell.width); - }); - }; - var adjustWidth = function (table, delta, index, resizing, tableSize) { - var warehouse = Warehouse.fromTable(table); - var step = tableSize.getCellDelta(delta); - var widths = tableSize.getWidths(warehouse, tableSize); - var isLastColumn = index === warehouse.grid.columns - 1; - var clampedStep = resizing.clampTableDelta(widths, index, step, tableSize.minCellWidth(), isLastColumn); - var deltas = determine(widths, index, clampedStep, tableSize, resizing); - var newWidths = map$1(deltas, function (dx, i) { - return dx + widths[i]; - }); - recalculateAndApply(warehouse, newWidths, tableSize); - resizing.resizeTable(tableSize.adjustTableWidth, clampedStep, isLastColumn); - }; - var adjustHeight = function (table, delta, index, direction) { - var warehouse = Warehouse.fromTable(table); - var heights = getPixelHeights(warehouse, table, direction); - var newHeights = map$1(heights, function (dy, i) { - return index === i ? Math.max(delta + dy, minHeight()) : dy; - }); - var newCellSizes = recalculateHeightForCells(warehouse, newHeights); - var newRowSizes = matchRowHeight(warehouse, newHeights); - each$2(newRowSizes, function (row) { - setHeight(row.element, row.height); - }); - each$2(newCellSizes, function (cell) { - setHeight(cell.element, cell.height); - }); - var total = sumUp(newHeights); - setHeight(table, total); - }; - var adjustAndRedistributeWidths$1 = function (_table, list, details, tableSize, resizeBehaviour) { - var warehouse = Warehouse.generate(list); - var sizes = tableSize.getWidths(warehouse, tableSize); - var tablePixelWidth = tableSize.pixelWidth(); - var _a = resizeBehaviour.calcRedestributedWidths(sizes, tablePixelWidth, details.pixelDelta, tableSize.isRelative), newSizes = _a.newSizes, delta = _a.delta; - recalculateAndApply(warehouse, newSizes, tableSize); - tableSize.adjustTableWidth(delta); - }; - var adjustWidthTo = function (_table, list, _info, tableSize) { - var warehouse = Warehouse.generate(list); - var widths = tableSize.getWidths(warehouse, tableSize); - recalculateAndApply(warehouse, widths, tableSize); - }; - - var zero = function (array) { - return map$1(array, constant(0)); - }; - var surround = function (sizes, startIndex, endIndex, results, f) { - return f(sizes.slice(0, startIndex)).concat(results).concat(f(sizes.slice(endIndex))); - }; - var clampDeltaHelper = function (predicate) { - return function (sizes, index, delta, minCellSize) { - if (!predicate(delta)) { - return delta; - } else { - var newSize = Math.max(minCellSize, sizes[index] - Math.abs(delta)); - var diff = Math.abs(newSize - sizes[index]); - return delta >= 0 ? diff : -diff; - } - }; - }; - var clampNegativeDelta = clampDeltaHelper(function (delta) { - return delta < 0; - }); - var clampDelta = clampDeltaHelper(always); - var resizeTable = function () { - var calcFixedDeltas = function (sizes, index, next, delta, minCellSize) { - var clampedDelta = clampNegativeDelta(sizes, index, delta, minCellSize); - return surround(sizes, index, next + 1, [ - clampedDelta, - 0 - ], zero); - }; - var calcRelativeDeltas = function (sizes, index, delta, minCellSize) { - var ratio = (100 + delta) / 100; - var newThis = Math.max(minCellSize, (sizes[index] + delta) / ratio); - return map$1(sizes, function (size, idx) { - var newSize = idx === index ? newThis : size / ratio; - return newSize - size; - }); - }; - var calcLeftEdgeDeltas = function (sizes, index, next, delta, minCellSize, isRelative) { - if (isRelative) { - return calcRelativeDeltas(sizes, index, delta, minCellSize); - } else { - return calcFixedDeltas(sizes, index, next, delta, minCellSize); - } - }; - var calcMiddleDeltas = function (sizes, _prev, index, next, delta, minCellSize, isRelative) { - return calcLeftEdgeDeltas(sizes, index, next, delta, minCellSize, isRelative); - }; - var resizeTable = function (resizer, delta) { - return resizer(delta); - }; - var calcRightEdgeDeltas = function (sizes, _prev, index, delta, minCellSize, isRelative) { - if (isRelative) { - return calcRelativeDeltas(sizes, index, delta, minCellSize); - } else { - var clampedDelta = clampNegativeDelta(sizes, index, delta, minCellSize); - return zero(sizes.slice(0, index)).concat([clampedDelta]); - } - }; - var calcRedestributedWidths = function (sizes, totalWidth, pixelDelta, isRelative) { - if (isRelative) { - var tableWidth = totalWidth + pixelDelta; - var ratio_1 = tableWidth / totalWidth; - var newSizes = map$1(sizes, function (size) { - return size / ratio_1; - }); - return { - delta: ratio_1 * 100 - 100, - newSizes: newSizes - }; - } else { - return { - delta: pixelDelta, - newSizes: sizes - }; - } - }; - return { - resizeTable: resizeTable, - clampTableDelta: clampNegativeDelta, - calcLeftEdgeDeltas: calcLeftEdgeDeltas, - calcMiddleDeltas: calcMiddleDeltas, - calcRightEdgeDeltas: calcRightEdgeDeltas, - calcRedestributedWidths: calcRedestributedWidths - }; - }; - var preserveTable = function () { - var calcLeftEdgeDeltas = function (sizes, index, next, delta, minCellSize) { - var idx = delta >= 0 ? next : index; - var clampedDelta = clampDelta(sizes, idx, delta, minCellSize); - return surround(sizes, index, next + 1, [ - clampedDelta, - -clampedDelta - ], zero); - }; - var calcMiddleDeltas = function (sizes, _prev, index, next, delta, minCellSize) { - return calcLeftEdgeDeltas(sizes, index, next, delta, minCellSize); - }; - var resizeTable = function (resizer, delta, isLastColumn) { - if (isLastColumn) { - resizer(delta); - } - }; - var calcRightEdgeDeltas = function (sizes, _prev, _index, delta, _minCellSize, isRelative) { - if (isRelative) { - return zero(sizes); - } else { - var diff = delta / sizes.length; - return map$1(sizes, constant(diff)); - } - }; - var clampTableDelta = function (sizes, index, delta, minCellSize, isLastColumn) { - if (isLastColumn) { - if (delta >= 0) { - return delta; - } else { - var maxDelta = foldl(sizes, function (a, b) { - return a + b - minCellSize; - }, 0); - return Math.max(-maxDelta, delta); - } - } else { - return clampNegativeDelta(sizes, index, delta, minCellSize); - } - }; - var calcRedestributedWidths = function (sizes, _totalWidth, _pixelDelta, _isRelative) { - return { - delta: 0, - newSizes: sizes - }; - }; - return { - resizeTable: resizeTable, - clampTableDelta: clampTableDelta, - calcLeftEdgeDeltas: calcLeftEdgeDeltas, - calcMiddleDeltas: calcMiddleDeltas, - calcRightEdgeDeltas: calcRightEdgeDeltas, - calcRedestributedWidths: calcRedestributedWidths - }; - }; - - var only = function (element, isResizable) { - var parent = Optional.from(element.dom.documentElement).map(SugarElement.fromDom).getOr(element); - return { - parent: constant(parent), - view: constant(element), - origin: constant(SugarPosition(0, 0)), - isResizable: isResizable - }; - }; - var detached = function (editable, chrome, isResizable) { - var origin = function () { - return absolute(chrome); - }; - return { - parent: constant(chrome), - view: constant(editable), - origin: origin, - isResizable: isResizable - }; - }; - var body = function (editable, chrome, isResizable) { - return { - parent: constant(chrome), - view: constant(editable), - origin: constant(SugarPosition(0, 0)), - isResizable: isResizable - }; - }; - var ResizeWire = { - only: only, - detached: detached, - body: body - }; - - var adt$6 = Adt.generate([ - { invalid: ['raw'] }, - { pixels: ['value'] }, - { percent: ['value'] } - ]); - var validateFor = function (suffix, type, value) { - var rawAmount = value.substring(0, value.length - suffix.length); - var amount = parseFloat(rawAmount); - return rawAmount === amount.toString() ? type(amount) : adt$6.invalid(value); - }; - var from = function (value) { - if (endsWith(value, '%')) { - return validateFor('%', adt$6.percent, value); - } - if (endsWith(value, 'px')) { - return validateFor('px', adt$6.pixels, value); - } - return adt$6.invalid(value); - }; - var Size = __assign(__assign({}, adt$6), { from: from }); - - var redistributeToPercent = function (widths, totalWidth) { - return map$1(widths, function (w) { - var colType = Size.from(w); - return colType.fold(function () { - return w; - }, function (px) { - var ratio = px / totalWidth * 100; - return ratio + '%'; - }, function (pc) { - return pc + '%'; - }); - }); - }; - var redistributeToPx = function (widths, totalWidth, newTotalWidth) { - var scale = newTotalWidth / totalWidth; - return map$1(widths, function (w) { - var colType = Size.from(w); - return colType.fold(function () { - return w; - }, function (px) { - return px * scale + 'px'; - }, function (pc) { - return pc / 100 * newTotalWidth + 'px'; - }); - }); - }; - var redistributeEmpty = function (newWidthType, columns) { - var f = newWidthType.fold(function () { - return constant(''); - }, function (pixels) { - var num = pixels / columns; - return constant(num + 'px'); - }, function () { - var num = 100 / columns; - return constant(num + '%'); - }); - return range$1(columns, f); - }; - var redistributeValues = function (newWidthType, widths, totalWidth) { - return newWidthType.fold(function () { - return widths; - }, function (px) { - return redistributeToPx(widths, totalWidth, px); - }, function (_pc) { - return redistributeToPercent(widths, totalWidth); - }); - }; - var redistribute$1 = function (widths, totalWidth, newWidth) { - var newType = Size.from(newWidth); - var floats = forall(widths, function (s) { - return s === '0px'; - }) ? redistributeEmpty(newType, widths.length) : redistributeValues(newType, widths, totalWidth); - return normalize(floats); - }; - var sum = function (values, fallback) { - if (values.length === 0) { - return fallback; - } - return foldr(values, function (rest, v) { - return Size.from(v).fold(constant(0), identity, identity) + rest; - }, 0); - }; - var roundDown = function (num, unit) { - var floored = Math.floor(num); - return { - value: floored + unit, - remainder: num - floored - }; - }; - var add$3 = function (value, amount) { - return Size.from(value).fold(constant(value), function (px) { - return px + amount + 'px'; - }, function (pc) { - return pc + amount + '%'; - }); - }; - var normalize = function (values) { - if (values.length === 0) { - return values; - } - var scan = foldr(values, function (rest, value) { - var info = Size.from(value).fold(function () { - return { - value: value, - remainder: 0 - }; - }, function (num) { - return roundDown(num, 'px'); - }, function (num) { - return { - value: num + '%', - remainder: 0 - }; - }); - return { - output: [info.value].concat(rest.output), - remainder: rest.remainder + info.remainder - }; - }, { - output: [], - remainder: 0 - }); - var r = scan.output; - return r.slice(0, r.length - 1).concat([add$3(r[r.length - 1], Math.round(scan.remainder))]); - }; - var validate = Size.from; - - var redistributeToW = function (newWidths, cells, unit) { - each$2(cells, function (cell) { - var widths = newWidths.slice(cell.column, cell.colspan + cell.column); - var w = sum(widths, minWidth()); - set$1(cell.element, 'width', w + unit); - }); - }; - var redistributeToColumns = function (newWidths, columns, unit) { - each$2(columns, function (column, index) { - var width = sum([newWidths[index]], minWidth()); - set$1(column.element, 'width', width + unit); - }); - }; - var redistributeToH = function (newHeights, rows, cells, unit) { - each$2(cells, function (cell) { - var heights = newHeights.slice(cell.row, cell.rowspan + cell.row); - var h = sum(heights, minHeight()); - set$1(cell.element, 'height', h + unit); - }); - each$2(rows, function (row, i) { - set$1(row.element, 'height', newHeights[i]); - }); - }; - var getUnit = function (newSize) { - return validate(newSize).fold(constant('px'), constant('px'), constant('%')); - }; - var redistribute = function (table, optWidth, optHeight) { - var warehouse = Warehouse.fromTable(table); - var rows = warehouse.all; - var cells = Warehouse.justCells(warehouse); - var columns = Warehouse.justColumns(warehouse); - optWidth.each(function (newWidth) { - var widthUnit = getUnit(newWidth); - var totalWidth = get$8(table); - var oldWidths = getRawWidths(warehouse, table); - var nuWidths = redistribute$1(oldWidths, totalWidth, newWidth); - if (Warehouse.hasColumns(warehouse)) { - redistributeToColumns(nuWidths, columns, widthUnit); - } else { - redistributeToW(nuWidths, cells, widthUnit); - } - set$1(table, 'width', newWidth); - }); - optHeight.each(function (newHeight) { - var hUnit = getUnit(newHeight); - var totalHeight = get$7(table); - var oldHeights = getRawHeights(warehouse, table, height); - var nuHeights = redistribute$1(oldHeights, totalHeight, newHeight); - redistributeToH(nuHeights, rows, cells, hUnit); - set$1(table, 'height', newHeight); - }); - }; - var isPercentSizing = isPercentSizing$1; - var isPixelSizing = isPixelSizing$1; - var isNoneSizing = isNoneSizing$1; - - var getGridSize = function (table) { - var warehouse = Warehouse.fromTable(table); - return warehouse.grid; - }; - - var Event = function (fields) { - var handlers = []; - var bind = function (handler) { - if (handler === undefined) { - throw new Error('Event bind error: undefined handler'); - } - handlers.push(handler); - }; - var unbind = function (handler) { - handlers = filter$2(handlers, function (h) { - return h !== handler; - }); - }; - var trigger = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var event = {}; - each$2(fields, function (name, i) { - event[name] = args[i]; - }); - each$2(handlers, function (handler) { - handler(event); - }); - }; - return { - bind: bind, - unbind: unbind, - trigger: trigger - }; - }; - - var create$4 = function (typeDefs) { - var registry = map(typeDefs, function (event) { - return { - bind: event.bind, - unbind: event.unbind - }; - }); - var trigger = map(typeDefs, function (event) { - return event.trigger; - }); - return { - registry: registry, - trigger: trigger - }; - }; - - var last = function (fn, rate) { - var timer = null; - var cancel = function () { - if (!isNull(timer)) { - clearTimeout(timer); - timer = null; - } - }; - var throttle = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - cancel(); - timer = setTimeout(function () { - timer = null; - fn.apply(null, args); - }, rate); - }; - return { - cancel: cancel, - throttle: throttle - }; - }; - - var sort = function (arr) { - return arr.slice(0).sort(); - }; - var reqMessage = function (required, keys) { - throw new Error('All required keys (' + sort(required).join(', ') + ') were not specified. Specified keys were: ' + sort(keys).join(', ') + '.'); - }; - var unsuppMessage = function (unsupported) { - throw new Error('Unsupported keys for object: ' + sort(unsupported).join(', ')); - }; - var validateStrArr = function (label, array) { - if (!isArray(array)) { - throw new Error('The ' + label + ' fields must be an array. Was: ' + array + '.'); - } - each$2(array, function (a) { - if (!isString(a)) { - throw new Error('The value ' + a + ' in the ' + label + ' fields was not a string.'); - } - }); - }; - var invalidTypeMessage = function (incorrect, type) { - throw new Error('All values need to be of type: ' + type + '. Keys (' + sort(incorrect).join(', ') + ') were not.'); - }; - var checkDupes = function (everything) { - var sorted = sort(everything); - var dupe = find$1(sorted, function (s, i) { - return i < sorted.length - 1 && s === sorted[i + 1]; - }); - dupe.each(function (d) { - throw new Error('The field: ' + d + ' occurs more than once in the combined fields: [' + sorted.join(', ') + '].'); - }); - }; - - var base = function (handleUnsupported, required) { - return baseWith(handleUnsupported, required, { - validate: isFunction, - label: 'function' - }); - }; - var baseWith = function (handleUnsupported, required, pred) { - if (required.length === 0) { - throw new Error('You must specify at least one required field.'); - } - validateStrArr('required', required); - checkDupes(required); - return function (obj) { - var keys$1 = keys(obj); - var allReqd = forall(required, function (req) { - return contains$2(keys$1, req); - }); - if (!allReqd) { - reqMessage(required, keys$1); - } - handleUnsupported(required, keys$1); - var invalidKeys = filter$2(required, function (key) { - return !pred.validate(obj[key], key); - }); - if (invalidKeys.length > 0) { - invalidTypeMessage(invalidKeys, pred.label); - } - return obj; - }; - }; - var handleExact = function (required, keys) { - var unsupported = filter$2(keys, function (key) { - return !contains$2(required, key); - }); - if (unsupported.length > 0) { - unsuppMessage(unsupported); - } - }; - var exactly = function (required) { - return base(handleExact, required); - }; - - var DragMode = exactly([ - 'compare', - 'extract', - 'mutate', - 'sink' - ]); - var DragSink = exactly([ - 'element', - 'start', - 'stop', - 'destroy' - ]); - var DragApi = exactly([ - 'forceDrop', - 'drop', - 'move', - 'delayDrop' - ]); - - var InDrag = function () { - var previous = Optional.none(); - var reset = function () { - previous = Optional.none(); - }; - var update = function (mode, nu) { - var result = previous.map(function (old) { - return mode.compare(old, nu); - }); - previous = Optional.some(nu); - return result; - }; - var onEvent = function (event, mode) { - var dataOption = mode.extract(event); - dataOption.each(function (data) { - var offset = update(mode, data); - offset.each(function (d) { - events.trigger.move(d); - }); - }); - }; - var events = create$4({ move: Event(['info']) }); - return { - onEvent: onEvent, - reset: reset, - events: events.registry - }; - }; - - var NoDrag = function () { - var events = create$4({ move: Event(['info']) }); - return { - onEvent: noop, - reset: noop, - events: events.registry - }; - }; - - var Movement = function () { - var noDragState = NoDrag(); - var inDragState = InDrag(); - var dragState = noDragState; - var on = function () { - dragState.reset(); - dragState = inDragState; - }; - var off = function () { - dragState.reset(); - dragState = noDragState; - }; - var onEvent = function (event, mode) { - dragState.onEvent(event, mode); - }; - var isOn = function () { - return dragState === inDragState; - }; - return { - on: on, - off: off, - isOn: isOn, - onEvent: onEvent, - events: inDragState.events - }; - }; - - var setup = function (mutation, mode, settings) { - var active = false; - var events = create$4({ - start: Event([]), - stop: Event([]) - }); - var movement = Movement(); - var drop = function () { - sink.stop(); - if (movement.isOn()) { - movement.off(); - events.trigger.stop(); - } - }; - var throttledDrop = last(drop, 200); - var go = function (parent) { - sink.start(parent); - movement.on(); - events.trigger.start(); - }; - var mousemove = function (event) { - throttledDrop.cancel(); - movement.onEvent(event, mode); - }; - movement.events.move.bind(function (event) { - mode.mutate(mutation, event.info); - }); - var on = function () { - active = true; - }; - var off = function () { - active = false; - }; - var runIfActive = function (f) { - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - if (active) { - f.apply(null, args); - } - }; - }; - var sink = mode.sink(DragApi({ - forceDrop: drop, - drop: runIfActive(drop), - move: runIfActive(mousemove), - delayDrop: runIfActive(throttledDrop.throttle) - }), settings); - var destroy = function () { - sink.destroy(); - }; - return { - element: sink.element, - go: go, - on: on, - off: off, - destroy: destroy, - events: events.registry - }; - }; - - var mkEvent = function (target, x, y, stop, prevent, kill, raw) { - return { - target: target, - x: x, - y: y, - stop: stop, - prevent: prevent, - kill: kill, - raw: raw - }; - }; - var fromRawEvent$1 = function (rawEvent) { - var target = SugarElement.fromDom(getOriginalEventTarget(rawEvent).getOr(rawEvent.target)); - var stop = function () { - return rawEvent.stopPropagation(); - }; - var prevent = function () { - return rawEvent.preventDefault(); - }; - var kill = compose(prevent, stop); - return mkEvent(target, rawEvent.clientX, rawEvent.clientY, stop, prevent, kill, rawEvent); - }; - var handle$2 = function (filter, handler) { - return function (rawEvent) { - if (filter(rawEvent)) { - handler(fromRawEvent$1(rawEvent)); - } - }; - }; - var binder = function (element, event, filter, handler, useCapture) { - var wrapped = handle$2(filter, handler); - element.dom.addEventListener(event, wrapped, useCapture); - return { unbind: curry(unbind, element, event, wrapped, useCapture) }; - }; - var bind$1 = function (element, event, filter, handler) { - return binder(element, event, filter, handler, false); - }; - var unbind = function (element, event, handler, useCapture) { - element.dom.removeEventListener(event, handler, useCapture); - }; - - var filter = always; - var bind = function (element, event, handler) { - return bind$1(element, event, filter, handler); - }; - var fromRawEvent = fromRawEvent$1; - - var read = function (element, attr) { - var value = get$b(element, attr); - return value === undefined || value === '' ? [] : value.split(' '); - }; - var add$2 = function (element, attr, id) { - var old = read(element, attr); - var nu = old.concat([id]); - set$2(element, attr, nu.join(' ')); - return true; - }; - var remove$4 = function (element, attr, id) { - var nu = filter$2(read(element, attr), function (v) { - return v !== id; - }); - if (nu.length > 0) { - set$2(element, attr, nu.join(' ')); - } else { - remove$7(element, attr); - } - return false; - }; - - var supports = function (element) { - return element.dom.classList !== undefined; - }; - var get$5 = function (element) { - return read(element, 'class'); - }; - var add$1 = function (element, clazz) { - return add$2(element, 'class', clazz); - }; - var remove$3 = function (element, clazz) { - return remove$4(element, 'class', clazz); - }; - - var add = function (element, clazz) { - if (supports(element)) { - element.dom.classList.add(clazz); - } else { - add$1(element, clazz); - } - }; - var cleanClass = function (element) { - var classList = supports(element) ? element.dom.classList : get$5(element); - if (classList.length === 0) { - remove$7(element, 'class'); - } - }; - var remove$2 = function (element, clazz) { - if (supports(element)) { - var classList = element.dom.classList; - classList.remove(clazz); - } else { - remove$3(element, clazz); - } - cleanClass(element); - }; - var has = function (element, clazz) { - return supports(element) && element.dom.classList.contains(clazz); - }; - - var css = function (namespace) { - var dashNamespace = namespace.replace(/\./g, '-'); - var resolve = function (str) { - return dashNamespace + '-' + str; - }; - return { resolve: resolve }; - }; - - var styles$1 = css('ephox-dragster'); - var resolve$1 = styles$1.resolve; - - var Blocker = function (options) { - var settings = __assign({ layerClass: resolve$1('blocker') }, options); - var div = SugarElement.fromTag('div'); - set$2(div, 'role', 'presentation'); - setAll(div, { - position: 'fixed', - left: '0px', - top: '0px', - width: '100%', - height: '100%' - }); - add(div, resolve$1('blocker')); - add(div, settings.layerClass); - var element = constant(div); - var destroy = function () { - remove$5(div); - }; - return { - element: element, - destroy: destroy - }; - }; - - var compare = function (old, nu) { - return SugarPosition(nu.left - old.left, nu.top - old.top); - }; - var extract = function (event) { - return Optional.some(SugarPosition(event.x, event.y)); - }; - var mutate = function (mutation, info) { - mutation.mutate(info.left, info.top); - }; - var sink = function (dragApi, settings) { - var blocker = Blocker(settings); - var mdown = bind(blocker.element(), 'mousedown', dragApi.forceDrop); - var mup = bind(blocker.element(), 'mouseup', dragApi.drop); - var mmove = bind(blocker.element(), 'mousemove', dragApi.move); - var mout = bind(blocker.element(), 'mouseout', dragApi.delayDrop); - var destroy = function () { - blocker.destroy(); - mup.unbind(); - mmove.unbind(); - mout.unbind(); - mdown.unbind(); - }; - var start = function (parent) { - append$1(parent, blocker.element()); - }; - var stop = function () { - remove$5(blocker.element()); - }; - return DragSink({ - element: blocker.element, - start: start, - stop: stop, - destroy: destroy - }); - }; - var MouseDrag = DragMode({ - compare: compare, - extract: extract, - sink: sink, - mutate: mutate - }); - - var transform$1 = function (mutation, settings) { - if (settings === void 0) { - settings = {}; - } - var mode = settings.mode !== undefined ? settings.mode : MouseDrag; - return setup(mutation, mode, settings); - }; - - var closest = function (target) { - return closest$1(target, '[contenteditable]'); - }; - var isEditable$1 = function (element, assumeEditable) { - if (assumeEditable === void 0) { - assumeEditable = false; - } - if (!detect$3().browser.isIE() && inBody(element)) { - return element.dom.isContentEditable; - } else { - return closest(element).fold(constant(assumeEditable), function (editable) { - return getRaw(editable) === 'true'; - }); - } - }; - var getRaw = function (element) { - return element.dom.contentEditable; - }; - - var styles = css('ephox-snooker'); - var resolve = styles.resolve; - - var Mutation = function () { - var events = create$4({ - drag: Event([ - 'xDelta', - 'yDelta' - ]) - }); - var mutate = function (x, y) { - events.trigger.drag(x, y); - }; - return { - mutate: mutate, - events: events.registry - }; - }; - - var BarMutation = function () { - var events = create$4({ - drag: Event([ - 'xDelta', - 'yDelta', - 'target' - ]) - }); - var target = Optional.none(); - var delegate = Mutation(); - delegate.events.drag.bind(function (event) { - target.each(function (t) { - events.trigger.drag(event.xDelta, event.yDelta, t); - }); - }); - var assign = function (t) { - target = Optional.some(t); - }; - var get = function () { - return target; - }; - return { - assign: assign, - get: get, - mutate: delegate.mutate, - events: events.registry - }; - }; - - var col = function (column, x, y, w, h) { - var bar = SugarElement.fromTag('div'); - setAll(bar, { - position: 'absolute', - left: x - w / 2 + 'px', - top: y + 'px', - height: h + 'px', - width: w + 'px' - }); - setAll$1(bar, { - 'data-column': column, - 'role': 'presentation' - }); - return bar; - }; - var row = function (r, x, y, w, h) { - var bar = SugarElement.fromTag('div'); - setAll(bar, { - position: 'absolute', - left: x + 'px', - top: y - h / 2 + 'px', - height: h + 'px', - width: w + 'px' - }); - setAll$1(bar, { - 'data-row': r, - 'role': 'presentation' - }); - return bar; - }; - - var resizeBar = resolve('resizer-bar'); - var resizeRowBar = resolve('resizer-rows'); - var resizeColBar = resolve('resizer-cols'); - var BAR_THICKNESS = 7; - var resizableRows = function (warehouse, isResizable) { - return bind$2(warehouse.all, function (row, i) { - return isResizable(row.element) ? [i] : []; - }); - }; - var resizableColumns = function (warehouse, isResizable) { - var resizableCols = []; - range$1(warehouse.grid.columns, function (index) { - var colElmOpt = Warehouse.getColumnAt(warehouse, index).map(function (col) { - return col.element; - }); - if (colElmOpt.forall(isResizable)) { - resizableCols.push(index); - } - }); - return filter$2(resizableCols, function (colIndex) { - var columnCells = Warehouse.filterItems(warehouse, function (cell) { - return cell.column === colIndex; - }); - return forall(columnCells, function (cell) { - return isResizable(cell.element); - }); - }); - }; - var destroy = function (wire) { - var previous = descendants(wire.parent(), '.' + resizeBar); - each$2(previous, remove$5); - }; - var drawBar = function (wire, positions, create) { - var origin = wire.origin(); - each$2(positions, function (cpOption) { - cpOption.each(function (cp) { - var bar = create(origin, cp); - add(bar, resizeBar); - append$1(wire.parent(), bar); - }); - }); - }; - var refreshCol = function (wire, colPositions, position, tableHeight) { - drawBar(wire, colPositions, function (origin, cp) { - var colBar = col(cp.col, cp.x - origin.left, position.top - origin.top, BAR_THICKNESS, tableHeight); - add(colBar, resizeColBar); - return colBar; - }); - }; - var refreshRow = function (wire, rowPositions, position, tableWidth) { - drawBar(wire, rowPositions, function (origin, cp) { - var rowBar = row(cp.row, position.left - origin.left, cp.y - origin.top, tableWidth, BAR_THICKNESS); - add(rowBar, resizeRowBar); - return rowBar; - }); - }; - var refreshGrid = function (warhouse, wire, table, rows, cols) { - var position = absolute(table); - var isResizable = wire.isResizable; - var rowPositions = rows.length > 0 ? height.positions(rows, table) : []; - var resizableRowBars = rowPositions.length > 0 ? resizableRows(warhouse, isResizable) : []; - var resizableRowPositions = filter$2(rowPositions, function (_pos, i) { - return exists(resizableRowBars, function (barIndex) { - return i === barIndex; - }); - }); - refreshRow(wire, resizableRowPositions, position, getOuter$2(table)); - var colPositions = cols.length > 0 ? width.positions(cols, table) : []; - var resizableColBars = colPositions.length > 0 ? resizableColumns(warhouse, isResizable) : []; - var resizableColPositions = filter$2(colPositions, function (_pos, i) { - return exists(resizableColBars, function (barIndex) { - return i === barIndex; - }); - }); - refreshCol(wire, resizableColPositions, position, getOuter$1(table)); - }; - var refresh = function (wire, table) { - destroy(wire); - if (wire.isResizable(table)) { - var warehouse = Warehouse.fromTable(table); - var rows$1 = rows(warehouse); - var cols = columns(warehouse); - refreshGrid(warehouse, wire, table, rows$1, cols); - } - }; - var each = function (wire, f) { - var bars = descendants(wire.parent(), '.' + resizeBar); - each$2(bars, f); - }; - var hide = function (wire) { - each(wire, function (bar) { - set$1(bar, 'display', 'none'); - }); - }; - var show = function (wire) { - each(wire, function (bar) { - set$1(bar, 'display', 'block'); - }); - }; - var isRowBar = function (element) { - return has(element, resizeRowBar); - }; - var isColBar = function (element) { - return has(element, resizeColBar); - }; - - var resizeBarDragging = resolve('resizer-bar-dragging'); - var BarManager = function (wire) { - var mutation = BarMutation(); - var resizing = transform$1(mutation, {}); - var hoverTable = Optional.none(); - var getResizer = function (element, type) { - return Optional.from(get$b(element, type)); - }; - mutation.events.drag.bind(function (event) { - getResizer(event.target, 'data-row').each(function (_dataRow) { - var currentRow = getCssValue(event.target, 'top'); - set$1(event.target, 'top', currentRow + event.yDelta + 'px'); - }); - getResizer(event.target, 'data-column').each(function (_dataCol) { - var currentCol = getCssValue(event.target, 'left'); - set$1(event.target, 'left', currentCol + event.xDelta + 'px'); - }); - }); - var getDelta = function (target, dir) { - var newX = getCssValue(target, dir); - var oldX = getAttrValue(target, 'data-initial-' + dir, 0); - return newX - oldX; - }; - resizing.events.stop.bind(function () { - mutation.get().each(function (target) { - hoverTable.each(function (table) { - getResizer(target, 'data-row').each(function (row) { - var delta = getDelta(target, 'top'); - remove$7(target, 'data-initial-top'); - events.trigger.adjustHeight(table, delta, parseInt(row, 10)); - }); - getResizer(target, 'data-column').each(function (column) { - var delta = getDelta(target, 'left'); - remove$7(target, 'data-initial-left'); - events.trigger.adjustWidth(table, delta, parseInt(column, 10)); - }); - refresh(wire, table); - }); - }); - }); - var handler = function (target, dir) { - events.trigger.startAdjust(); - mutation.assign(target); - set$2(target, 'data-initial-' + dir, getCssValue(target, dir)); - add(target, resizeBarDragging); - set$1(target, 'opacity', '0.2'); - resizing.go(wire.parent()); - }; - var mousedown = bind(wire.parent(), 'mousedown', function (event) { - if (isRowBar(event.target)) { - handler(event.target, 'top'); - } - if (isColBar(event.target)) { - handler(event.target, 'left'); - } - }); - var isRoot = function (e) { - return eq$1(e, wire.view()); - }; - var findClosestEditableTable = function (target) { - return closest$1(target, 'table', isRoot).filter(isEditable$1); - }; - var mouseover = bind(wire.view(), 'mouseover', function (event) { - findClosestEditableTable(event.target).fold(function () { - if (inBody(event.target)) { - destroy(wire); - } - }, function (table) { - hoverTable = Optional.some(table); - refresh(wire, table); - }); - }); - var destroy$1 = function () { - mousedown.unbind(); - mouseover.unbind(); - resizing.destroy(); - destroy(wire); - }; - var refresh$1 = function (tbl) { - refresh(wire, tbl); - }; - var events = create$4({ - adjustHeight: Event([ - 'table', - 'delta', - 'row' - ]), - adjustWidth: Event([ - 'table', - 'delta', - 'column' - ]), - startAdjust: Event([]) - }); - return { - destroy: destroy$1, - refresh: refresh$1, - on: resizing.on, - off: resizing.off, - hideBars: curry(hide, wire), - showBars: curry(show, wire), - events: events.registry - }; - }; - - var create$3 = function (wire, resizing, lazySizing) { - var hdirection = height; - var vdirection = width; - var manager = BarManager(wire); - var events = create$4({ - beforeResize: Event([ - 'table', - 'type' - ]), - afterResize: Event([ - 'table', - 'type' - ]), - startDrag: Event([]) - }); - manager.events.adjustHeight.bind(function (event) { - var table = event.table; - events.trigger.beforeResize(table, 'row'); - var delta = hdirection.delta(event.delta, table); - adjustHeight(table, delta, event.row, hdirection); - events.trigger.afterResize(table, 'row'); - }); - manager.events.startAdjust.bind(function (_event) { - events.trigger.startDrag(); - }); - manager.events.adjustWidth.bind(function (event) { - var table = event.table; - events.trigger.beforeResize(table, 'col'); - var delta = vdirection.delta(event.delta, table); - var tableSize = lazySizing(table); - adjustWidth(table, delta, event.column, resizing, tableSize); - events.trigger.afterResize(table, 'col'); - }); - return { - on: manager.on, - off: manager.off, - hideBars: manager.hideBars, - showBars: manager.showBars, - destroy: manager.destroy, - events: events.registry - }; - }; - var TableResize = { create: create$3 }; - - var fireNewRow = function (editor, row) { - return editor.fire('newrow', { node: row }); - }; - var fireNewCell = function (editor, cell) { - return editor.fire('newcell', { node: cell }); - }; - var fireObjectResizeStart = function (editor, target, width, height, origin) { - editor.fire('ObjectResizeStart', { - target: target, - width: width, - height: height, - origin: origin - }); - }; - var fireObjectResized = function (editor, target, width, height, origin) { - editor.fire('ObjectResized', { - target: target, - width: width, - height: height, - origin: origin - }); - }; - var fireTableSelectionChange = function (editor, cells, start, finish, otherCells) { - editor.fire('TableSelectionChange', { - cells: cells, - start: start, - finish: finish, - otherCells: otherCells - }); - }; - var fireTableSelectionClear = function (editor) { - editor.fire('TableSelectionClear'); - }; - var fireTableModified = function (editor, table, data) { - editor.fire('TableModified', __assign(__assign({}, data), { table: table })); - }; - var styleModified = { - structure: false, - style: true - }; - var structureModified = { - structure: true, - style: false - }; - var styleAndStructureModified = { - structure: true, - style: true - }; - - var defaultTableToolbar = 'tableprops tabledelete | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol'; - var defaultStyles = { - 'border-collapse': 'collapse', - 'width': '100%' - }; - var defaultCellBorderWidths = range$1(5, function (i) { - var size = i + 1 + 'px'; - return { - title: size, - value: size - }; - }); - var defaultCellBorderStyles = map$1([ - 'Solid', - 'Dotted', - 'Dashed', - 'Double', - 'Groove', - 'Ridge', - 'Inset', - 'Outset', - 'None', - 'Hidden' - ], function (type) { - return { - title: type, - value: type.toLowerCase() - }; - }); - var determineDefaultStyles = function (editor) { - var _a; - if (isPixelsForced(editor)) { - var dom = editor.dom; - var parentBlock = (_a = dom.getParent(editor.selection.getStart(), dom.isBlock)) !== null && _a !== void 0 ? _a : editor.getBody(); - var contentWidth = getInner(SugarElement.fromDom(parentBlock)); - return __assign(__assign({}, defaultStyles), { width: contentWidth + 'px' }); - } else if (isResponsiveForced(editor)) { - return filter$1(defaultStyles, function (_value, key) { - return key !== 'width'; - }); - } else { - return defaultStyles; - } - }; - var defaultAttributes = { border: '1' }; - var defaultColumnResizingBehaviour = 'preservetable'; - var getTableSizingMode = function (editor) { - return editor.getParam('table_sizing_mode', 'auto'); - }; - var getTableResponseWidth = function (editor) { - return editor.getParam('table_responsive_width'); - }; - var getTableBorderWidths = function (editor) { - return editor.getParam('table_border_widths', defaultCellBorderWidths, 'array'); - }; - var getTableBorderStyles = function (editor) { - return editor.getParam('table_border_styles', defaultCellBorderStyles, 'array'); - }; - var getDefaultAttributes = function (editor) { - return editor.getParam('table_default_attributes', defaultAttributes, 'object'); - }; - var getDefaultStyles = function (editor) { - return editor.getParam('table_default_styles', determineDefaultStyles(editor), 'object'); - }; - var hasTableResizeBars = function (editor) { - return editor.getParam('table_resize_bars', true, 'boolean'); - }; - var hasTabNavigation = function (editor) { - return editor.getParam('table_tab_navigation', true, 'boolean'); - }; - var hasAdvancedCellTab = function (editor) { - return editor.getParam('table_cell_advtab', true, 'boolean'); - }; - var hasAdvancedRowTab = function (editor) { - return editor.getParam('table_row_advtab', true, 'boolean'); - }; - var hasAdvancedTableTab = function (editor) { - return editor.getParam('table_advtab', true, 'boolean'); - }; - var hasAppearanceOptions = function (editor) { - return editor.getParam('table_appearance_options', true, 'boolean'); - }; - var hasTableGrid = function (editor) { - return editor.getParam('table_grid', true, 'boolean'); - }; - var shouldStyleWithCss = function (editor) { - return editor.getParam('table_style_by_css', false, 'boolean'); - }; - var getCellClassList = function (editor) { - return editor.getParam('table_cell_class_list', [], 'array'); - }; - var getRowClassList = function (editor) { - return editor.getParam('table_row_class_list', [], 'array'); - }; - var getTableClassList = function (editor) { - return editor.getParam('table_class_list', [], 'array'); - }; - var isPercentagesForced = function (editor) { - return getTableSizingMode(editor) === 'relative' || getTableResponseWidth(editor) === true; - }; - var isPixelsForced = function (editor) { - return getTableSizingMode(editor) === 'fixed' || getTableResponseWidth(editor) === false; - }; - var isResponsiveForced = function (editor) { - return getTableSizingMode(editor) === 'responsive'; - }; - var getToolbar = function (editor) { - return editor.getParam('table_toolbar', defaultTableToolbar); - }; - var useColumnGroup = function (editor) { - return editor.getParam('table_use_colgroups', false, 'boolean'); - }; - var getTableHeaderType = function (editor) { - var defaultValue = 'section'; - var value = editor.getParam('table_header_type', defaultValue, 'string'); - var validValues = [ - 'section', - 'cells', - 'sectionCells', - 'auto' - ]; - if (!contains$2(validValues, value)) { - return defaultValue; - } else { - return value; - } - }; - var getColumnResizingBehaviour = function (editor) { - var validModes = [ - 'preservetable', - 'resizetable' - ]; - var givenMode = editor.getParam('table_column_resizing', defaultColumnResizingBehaviour, 'string'); - return find$1(validModes, function (mode) { - return mode === givenMode; - }).getOr(defaultColumnResizingBehaviour); - }; - var isPreserveTableColumnResizing = function (editor) { - return getColumnResizingBehaviour(editor) === 'preservetable'; - }; - var isResizeTableColumnResizing = function (editor) { - return getColumnResizingBehaviour(editor) === 'resizetable'; - }; - var getCloneElements = function (editor) { - var cloneElements = editor.getParam('table_clone_elements'); - if (isString(cloneElements)) { - return Optional.some(cloneElements.split(/[ ,]/)); - } else if (Array.isArray(cloneElements)) { - return Optional.some(cloneElements); - } else { - return Optional.none(); - } - }; - var hasObjectResizing = function (editor) { - var objectResizing = editor.getParam('object_resizing', true); - return isString(objectResizing) ? objectResizing === 'table' : objectResizing; - }; - var getTableBackgroundColorMap = function (editor) { - return editor.getParam('table_background_color_map', [], 'array'); - }; - var getTableBorderColorMap = function (editor) { - return editor.getParam('table_border_color_map', [], 'array'); - }; - - var get$4 = function (editor, table) { - if (isPercentagesForced(editor)) { - return TableSize.percentageSize(table); - } else if (isPixelsForced(editor)) { - return TableSize.pixelSize(table); - } else { - return TableSize.getTableSize(table); - } - }; - - var cleanupLegacyAttributes = function (element) { - remove$7(element, 'width'); - }; - var convertToPercentSize = function (table) { - var newWidth = getPercentTableWidth(table); - redistribute(table, Optional.some(newWidth), Optional.none()); - cleanupLegacyAttributes(table); - }; - var convertToPixelSize = function (table) { - var newWidth = getPixelTableWidth(table); - redistribute(table, Optional.some(newWidth), Optional.none()); - cleanupLegacyAttributes(table); - }; - var convertToNoneSize = function (table) { - remove$6(table, 'width'); - var columns = columns$1(table); - var rowElements = columns.length > 0 ? columns : cells$1(table); - each$2(rowElements, function (cell) { - remove$6(cell, 'width'); - cleanupLegacyAttributes(cell); - }); - cleanupLegacyAttributes(table); - }; - - var enforcePercentage = convertToPercentSize; - var enforcePixels = convertToPixelSize; - var enforceNone = convertToNoneSize; - var syncPixels = function (table) { - var warehouse = Warehouse.fromTable(table); - if (!Warehouse.hasColumns(warehouse)) { - each$2(cells$1(table), function (cell) { - var computedWidth = get$a(cell, 'width'); - set$1(cell, 'width', computedWidth); - remove$7(cell, 'width'); - }); - } - }; - - var createContainer = function () { - var container = SugarElement.fromTag('div'); - setAll(container, { - position: 'static', - height: '0', - width: '0', - padding: '0', - margin: '0', - border: '0' - }); - append$1(body$1(), container); - return container; - }; - var get$3 = function (editor, isResizable) { - return editor.inline ? ResizeWire.body(getBody(editor), createContainer(), isResizable) : ResizeWire.only(SugarElement.fromDom(editor.getDoc()), isResizable); - }; - var remove$1 = function (editor, wire) { - if (editor.inline) { - remove$5(wire.parent()); - } - }; - - var barResizerPrefix = 'bar-'; - var isResizable = function (elm) { - return get$b(elm, 'data-mce-resize') !== 'false'; - }; - var getResizeHandler = function (editor) { - var selectionRng = Optional.none(); - var resize = Optional.none(); - var wire = Optional.none(); - var startW; - var startRawW; - var isTable = function (elm) { - return elm.nodeName === 'TABLE'; - }; - var lazyResize = function () { - return resize; - }; - var lazyWire = function () { - return wire.getOr(ResizeWire.only(SugarElement.fromDom(editor.getBody()), isResizable)); - }; - var lazySizing = function (table) { - return get$4(editor, table); - }; - var lazyResizingBehaviour = function () { - return isPreserveTableColumnResizing(editor) ? preserveTable() : resizeTable(); - }; - var getNumColumns = function (table) { - return getGridSize(table).columns; - }; - var afterCornerResize = function (table, origin, width) { - var isRightEdgeResize = endsWith(origin, 'e'); - if (startRawW === '') { - enforcePercentage(table); - } - if (width !== startW && startRawW !== '') { - set$1(table, 'width', startRawW); - var resizing = lazyResizingBehaviour(); - var tableSize = lazySizing(table); - var col = isPreserveTableColumnResizing(editor) || isRightEdgeResize ? getNumColumns(table) - 1 : 0; - adjustWidth(table, width - startW, col, resizing, tableSize); - } else if (isPercentage$1(startRawW)) { - var percentW = parseFloat(startRawW.replace('%', '')); - var targetPercentW = width * percentW / startW; - set$1(table, 'width', targetPercentW + '%'); - } - if (isPixel(startRawW)) { - syncPixels(table); - } - }; - var destroy = function () { - resize.each(function (sz) { - sz.destroy(); - }); - wire.each(function (w) { - remove$1(editor, w); - }); - }; - editor.on('init', function () { - var rawWire = get$3(editor, isResizable); - wire = Optional.some(rawWire); - if (hasObjectResizing(editor) && hasTableResizeBars(editor)) { - var resizing = lazyResizingBehaviour(); - var sz = TableResize.create(rawWire, resizing, lazySizing); - sz.on(); - sz.events.startDrag.bind(function (_event) { - selectionRng = Optional.some(editor.selection.getRng()); - }); - sz.events.beforeResize.bind(function (event) { - var rawTable = event.table.dom; - fireObjectResizeStart(editor, rawTable, getPixelWidth(rawTable), getPixelHeight(rawTable), barResizerPrefix + event.type); - }); - sz.events.afterResize.bind(function (event) { - var table = event.table; - var rawTable = table.dom; - removeDataStyle(table); - selectionRng.each(function (rng) { - editor.selection.setRng(rng); - editor.focus(); - }); - fireObjectResized(editor, rawTable, getPixelWidth(rawTable), getPixelHeight(rawTable), barResizerPrefix + event.type); - editor.undoManager.add(); - }); - resize = Optional.some(sz); - } - }); - editor.on('ObjectResizeStart', function (e) { - var targetElm = e.target; - if (isTable(targetElm)) { - var table = SugarElement.fromDom(targetElm); - each$2(editor.dom.select('.mce-clonedresizable'), function (clone) { - editor.dom.addClass(clone, 'mce-' + getColumnResizingBehaviour(editor) + '-columns'); - }); - if (!isPixelSizing(table) && isPixelsForced(editor)) { - enforcePixels(table); - } else if (!isPercentSizing(table) && isPercentagesForced(editor)) { - enforcePercentage(table); - } - if (isNoneSizing(table) && startsWith(e.origin, barResizerPrefix)) { - enforcePercentage(table); - } - startW = e.width; - startRawW = isResponsiveForced(editor) ? '' : getRawWidth(editor, targetElm).getOr(''); - } - }); - editor.on('ObjectResized', function (e) { - var targetElm = e.target; - if (isTable(targetElm)) { - var table = SugarElement.fromDom(targetElm); - var origin_1 = e.origin; - if (startsWith(origin_1, 'corner-')) { - afterCornerResize(table, origin_1, e.width); - } - removeDataStyle(table); - fireTableModified(editor, table.dom, styleModified); - } - }); - editor.on('SwitchMode', function () { - lazyResize().each(function (resize) { - if (editor.mode.isReadOnly()) { - resize.hideBars(); - } else { - resize.showBars(); - } - }); - }); - return { - lazyResize: lazyResize, - lazyWire: lazyWire, - destroy: destroy - }; - }; - - var point = function (element, offset) { - return { - element: element, - offset: offset - }; - }; - - var scan$1 = function (universe, element, direction) { - if (universe.property().isText(element) && universe.property().getText(element).trim().length === 0 || universe.property().isComment(element)) { - return direction(element).bind(function (elem) { - return scan$1(universe, elem, direction).orThunk(function () { - return Optional.some(elem); - }); - }); - } else { - return Optional.none(); - } - }; - var toEnd = function (universe, element) { - if (universe.property().isText(element)) { - return universe.property().getText(element).length; - } - var children = universe.property().children(element); - return children.length; - }; - var freefallRtl$2 = function (universe, element) { - var candidate = scan$1(universe, element, universe.query().prevSibling).getOr(element); - if (universe.property().isText(candidate)) { - return point(candidate, toEnd(universe, candidate)); - } - var children = universe.property().children(candidate); - return children.length > 0 ? freefallRtl$2(universe, children[children.length - 1]) : point(candidate, toEnd(universe, candidate)); - }; - - var freefallRtl$1 = freefallRtl$2; - - var universe$2 = DomUniverse(); - var freefallRtl = function (element) { - return freefallRtl$1(universe$2, element); - }; - - var halve = function (main, other) { - var colspan = getSpan(main, 'colspan'); - if (colspan === 1) { - var width = getGenericWidth(main); - width.each(function (w) { - var newWidth = w.value / 2; - setGenericWidth(main, newWidth, w.unit); - setGenericWidth(other, newWidth, w.unit); - }); - } - }; - - var isHeaderCell = isTag('th'); - var isHeaderCells = function (cells) { - return forall(cells, function (cell) { - return isHeaderCell(cell.element); - }); - }; - var getRowHeaderType = function (isHeaderRow, isHeaderCells) { - if (isHeaderRow && isHeaderCells) { - return 'sectionCells'; - } else if (isHeaderRow) { - return 'section'; - } else { - return 'cells'; - } - }; - var getRowType$1 = function (row) { - var isHeaderRow = row.section === 'thead'; - var isHeaderCells = is(findCommonCellType(row.cells), 'th'); - if (isHeaderRow || isHeaderCells) { - return { - type: 'header', - subType: getRowHeaderType(isHeaderRow, isHeaderCells) - }; - } else if (row.section === 'tfoot') { - return { type: 'footer' }; - } else { - return { type: 'body' }; - } - }; - var findCommonCellType = function (cells) { - var headerCells = filter$2(cells, function (cell) { - return isHeaderCell(cell.element); - }); - if (headerCells.length === 0) { - return Optional.some('td'); - } else if (headerCells.length === cells.length) { - return Optional.some('th'); - } else { - return Optional.none(); - } - }; - var findCommonRowType = function (rows) { - var rowTypes = map$1(rows, function (row) { - return getRowType$1(row).type; - }); - var hasHeader = contains$2(rowTypes, 'header'); - var hasFooter = contains$2(rowTypes, 'footer'); - if (!hasHeader && !hasFooter) { - return Optional.some('body'); - } else { - var hasBody = contains$2(rowTypes, 'body'); - if (hasHeader && !hasBody && !hasFooter) { - return Optional.some('header'); - } else if (!hasHeader && !hasBody && hasFooter) { - return Optional.some('footer'); - } else { - return Optional.none(); - } - } - }; - var findTableRowHeaderType = function (warehouse) { - return findMap(warehouse.all, function (row) { - var rowType = getRowType$1(row); - return rowType.type === 'header' ? Optional.from(rowType.subType) : Optional.none(); - }); - }; - - var transformCell = function (cell, comparator, substitution) { - return elementnew(substitution(cell.element, comparator), true, cell.isLocked); - }; - var transformRow = function (row, section) { - return row.section !== section ? rowcells(row.element, row.cells, section, row.isNew) : row; - }; - var section = function () { - return { - transformRow: transformRow, - transformCell: function (cell, comparator, substitution) { - var newCell = substitution(cell.element, comparator); - var fixedCell = name(newCell) !== 'td' ? mutate$1(newCell, 'td') : newCell; - return elementnew(fixedCell, cell.isNew, cell.isLocked); - } - }; - }; - var sectionCells = function () { - return { - transformRow: transformRow, - transformCell: transformCell - }; - }; - var cells = function () { - return { - transformRow: function (row, section) { - var newSection = section === 'thead' ? 'tbody' : section; - return transformRow(row, newSection); - }, - transformCell: transformCell - }; - }; - var fallback = function () { - return { - transformRow: identity, - transformCell: transformCell - }; - }; - var getTableSectionType = function (table, fallback) { - var warehouse = Warehouse.fromTable(table); - var type = findTableRowHeaderType(warehouse).getOr(fallback); - switch (type) { - case 'section': - return section(); - case 'sectionCells': - return sectionCells(); - case 'cells': - return cells(); - } - }; - var TableSection = { - getTableSectionType: getTableSectionType, - section: section, - sectionCells: sectionCells, - cells: cells, - fallback: fallback - }; - - var setIfNot = function (element, property, value, ignore) { - if (value === ignore) { - remove$7(element, property); - } else { - set$2(element, property, value); - } - }; - var insert$1 = function (table, selector, element) { - last$2(children$1(table, selector)).fold(function () { - return prepend(table, element); - }, function (child) { - return after$5(child, element); - }); - }; - var generateSection = function (table, sectionName) { - var section = child$1(table, sectionName).getOrThunk(function () { - var newSection = SugarElement.fromTag(sectionName, owner(table).dom); - if (sectionName === 'thead') { - insert$1(table, 'caption,colgroup', newSection); - } else if (sectionName === 'colgroup') { - insert$1(table, 'caption', newSection); - } else { - append$1(table, newSection); - } - return newSection; - }); - empty(section); - return section; - }; - var render$1 = function (table, grid) { - var newRows = []; - var newCells = []; - var syncRows = function (gridSection) { - return map$1(gridSection, function (row) { - if (row.isNew) { - newRows.push(row.element); - } - var tr = row.element; - empty(tr); - each$2(row.cells, function (cell) { - if (cell.isNew) { - newCells.push(cell.element); - } - setIfNot(cell.element, 'colspan', cell.colspan, 1); - setIfNot(cell.element, 'rowspan', cell.rowspan, 1); - append$1(tr, cell.element); - }); - return tr; - }); - }; - var syncColGroup = function (gridSection) { - return bind$2(gridSection, function (colGroup) { - return map$1(colGroup.cells, function (col) { - setIfNot(col.element, 'span', col.colspan, 1); - return col.element; - }); - }); - }; - var renderSection = function (gridSection, sectionName) { - var section = generateSection(table, sectionName); - var sync = sectionName === 'colgroup' ? syncColGroup : syncRows; - var sectionElems = sync(gridSection); - append(section, sectionElems); - }; - var removeSection = function (sectionName) { - child$1(table, sectionName).each(remove$5); - }; - var renderOrRemoveSection = function (gridSection, sectionName) { - if (gridSection.length > 0) { - renderSection(gridSection, sectionName); - } else { - removeSection(sectionName); - } - }; - var headSection = []; - var bodySection = []; - var footSection = []; - var columnGroupsSection = []; - each$2(grid, function (row) { - switch (row.section) { - case 'thead': - headSection.push(row); - break; - case 'tbody': - bodySection.push(row); - break; - case 'tfoot': - footSection.push(row); - break; - case 'colgroup': - columnGroupsSection.push(row); - break; - } - }); - renderOrRemoveSection(columnGroupsSection, 'colgroup'); - renderOrRemoveSection(headSection, 'thead'); - renderOrRemoveSection(bodySection, 'tbody'); - renderOrRemoveSection(footSection, 'tfoot'); - return { - newRows: newRows, - newCells: newCells - }; - }; - var copy = function (grid) { - return map$1(grid, function (row) { - var tr = shallow(row.element); - each$2(row.cells, function (cell) { - var clonedCell = deep(cell.element); - setIfNot(clonedCell, 'colspan', cell.colspan, 1); - setIfNot(clonedCell, 'rowspan', cell.rowspan, 1); - append$1(tr, clonedCell); - }); - return tr; - }); - }; - - var getColumn = function (grid, index) { - return map$1(grid, function (row) { - return getCell(row, index); - }); - }; - var getRow = function (grid, index) { - return grid[index]; - }; - var findDiff = function (xs, comp) { - if (xs.length === 0) { - return 0; - } - var first = xs[0]; - var index = findIndex(xs, function (x) { - return !comp(first.element, x.element); - }); - return index.getOr(xs.length); - }; - var subgrid = function (grid, row, column, comparator) { - var gridRow = getRow(grid, row); - var isColRow = gridRow.section === 'colgroup'; - var colspan = findDiff(gridRow.cells.slice(column), comparator); - var rowspan = isColRow ? 1 : findDiff(getColumn(grid.slice(row), column), comparator); - return { - colspan: colspan, - rowspan: rowspan - }; - }; - - var toDetails = function (grid, comparator) { - var seen = map$1(grid, function (row) { - return map$1(row.cells, never); - }); - var updateSeen = function (rowIndex, columnIndex, rowspan, colspan) { - for (var row = rowIndex; row < rowIndex + rowspan; row++) { - for (var column = columnIndex; column < columnIndex + colspan; column++) { - seen[row][column] = true; - } - } - }; - return map$1(grid, function (row, rowIndex) { - var details = bind$2(row.cells, function (cell, columnIndex) { - if (seen[rowIndex][columnIndex] === false) { - var result = subgrid(grid, rowIndex, columnIndex, comparator); - updateSeen(rowIndex, columnIndex, result.rowspan, result.colspan); - return [detailnew(cell.element, result.rowspan, result.colspan, cell.isNew)]; - } else { - return []; - } - }); - return rowdetailnew(row.element, details, row.section, row.isNew); - }); - }; - var toGrid = function (warehouse, generators, isNew) { - var grid = []; - each$2(warehouse.colgroups, function (colgroup) { - var colgroupCols = []; - for (var columnIndex = 0; columnIndex < warehouse.grid.columns; columnIndex++) { - var element = Warehouse.getColumnAt(warehouse, columnIndex).map(function (column) { - return elementnew(column.element, isNew, false); - }).getOrThunk(function () { - return elementnew(generators.colGap(), true, false); - }); - colgroupCols.push(element); - } - grid.push(rowcells(colgroup.element, colgroupCols, 'colgroup', isNew)); - }); - for (var rowIndex = 0; rowIndex < warehouse.grid.rows; rowIndex++) { - var rowCells = []; - for (var columnIndex = 0; columnIndex < warehouse.grid.columns; columnIndex++) { - var element = Warehouse.getAt(warehouse, rowIndex, columnIndex).map(function (item) { - return elementnew(item.element, isNew, item.isLocked); - }).getOrThunk(function () { - return elementnew(generators.gap(), true, false); - }); - rowCells.push(element); - } - var rowDetail = warehouse.all[rowIndex]; - var row = rowcells(rowDetail.element, rowCells, rowDetail.section, isNew); - grid.push(row); - } - return grid; - }; - - var fromWarehouse = function (warehouse, generators) { - return toGrid(warehouse, generators, false); - }; - var toDetailList = function (grid) { - return toDetails(grid, eq$1); - }; - var findInWarehouse = function (warehouse, element) { - return findMap(warehouse.all, function (r) { - return find$1(r.cells, function (e) { - return eq$1(element, e.element); - }); - }); - }; - var extractCells = function (warehouse, target, predicate) { - var details = map$1(target.selection, function (cell$1) { - return cell(cell$1).bind(function (lc) { - return findInWarehouse(warehouse, lc); - }).filter(predicate); - }); - var cells = cat(details); - return someIf(cells.length > 0, cells); - }; - var run = function (operation, extract, adjustment, postAction, genWrappers) { - return function (wire, table, target, generators, behaviours) { - var warehouse = Warehouse.fromTable(table); - var tableSection = Optional.from(behaviours === null || behaviours === void 0 ? void 0 : behaviours.section).getOrThunk(TableSection.fallback); - var output = extract(warehouse, target).map(function (info) { - var model = fromWarehouse(warehouse, generators); - var result = operation(model, info, eq$1, genWrappers(generators), tableSection); - var lockedColumns = getLockedColumnsFromGrid(result.grid); - var grid = toDetailList(result.grid); - return { - info: info, - grid: grid, - cursor: result.cursor, - lockedColumns: lockedColumns - }; - }); - return output.bind(function (out) { - var newElements = render$1(table, out.grid); - var tableSizing = Optional.from(behaviours === null || behaviours === void 0 ? void 0 : behaviours.sizing).getOrThunk(function () { - return TableSize.getTableSize(table); - }); - var resizing = Optional.from(behaviours === null || behaviours === void 0 ? void 0 : behaviours.resize).getOrThunk(preserveTable); - adjustment(table, out.grid, out.info, { - sizing: tableSizing, - resize: resizing, - section: tableSection - }); - postAction(table); - refresh(wire, table); - remove$7(table, LOCKED_COL_ATTR); - if (out.lockedColumns.length > 0) { - set$2(table, LOCKED_COL_ATTR, out.lockedColumns.join(',')); - } - return Optional.some({ - cursor: out.cursor, - newRows: newElements.newRows, - newCells: newElements.newCells - }); - }); - }; - }; - var onPaste = function (warehouse, target) { - return cell(target.element).bind(function (cell) { - return findInWarehouse(warehouse, cell).map(function (details) { - var value = __assign(__assign({}, details), { - generators: target.generators, - clipboard: target.clipboard - }); - return value; - }); - }); - }; - var onPasteByEditor = function (warehouse, target) { - return extractCells(warehouse, target, always).map(function (cells) { - return { - cells: cells, - generators: target.generators, - clipboard: target.clipboard - }; - }); - }; - var onMergable = function (_warehouse, target) { - return target.mergable; - }; - var onUnmergable = function (_warehouse, target) { - return target.unmergable; - }; - var onCells = function (warehouse, target) { - return extractCells(warehouse, target, always); - }; - var onUnlockedCells = function (warehouse, target) { - return extractCells(warehouse, target, function (detail) { - return !detail.isLocked; - }); - }; - var isUnlockedTableCell = function (warehouse, cell) { - return findInWarehouse(warehouse, cell).exists(function (detail) { - return !detail.isLocked; - }); - }; - var allUnlocked = function (warehouse, cells) { - return forall(cells, function (cell) { - return isUnlockedTableCell(warehouse, cell); - }); - }; - var onUnlockedMergable = function (warehouse, target) { - return onMergable(warehouse, target).filter(function (mergeable) { - return allUnlocked(warehouse, mergeable.cells); - }); - }; - var onUnlockedUnmergable = function (warehouse, target) { - return onUnmergable(warehouse, target).filter(function (cells) { - return allUnlocked(warehouse, cells); - }); - }; - - var merge$2 = function (grid, bounds, comparator, substitution) { - var rows = extractGridDetails(grid).rows; - if (rows.length === 0) { - return grid; - } - for (var i = bounds.startRow; i <= bounds.finishRow; i++) { - for (var j = bounds.startCol; j <= bounds.finishCol; j++) { - var row = rows[i]; - var isLocked = getCell(row, j).isLocked; - mutateCell(row, j, elementnew(substitution(), false, isLocked)); - } - } - return grid; - }; - var unmerge = function (grid, target, comparator, substitution) { - var rows = extractGridDetails(grid).rows; - var first = true; - for (var i = 0; i < rows.length; i++) { - for (var j = 0; j < cellLength(rows[0]); j++) { - var row = rows[i]; - var currentCell = getCell(row, j); - var currentCellElm = currentCell.element; - var isToReplace = comparator(currentCellElm, target); - if (isToReplace === true && first === false) { - mutateCell(row, j, elementnew(substitution(), true, currentCell.isLocked)); - } else if (isToReplace === true) { - first = false; - } - } - } - return grid; - }; - var uniqueCells = function (row, comparator) { - return foldl(row, function (rest, cell) { - return exists(rest, function (currentCell) { - return comparator(currentCell.element, cell.element); - }) ? rest : rest.concat([cell]); - }, []); - }; - var splitCols = function (grid, index, comparator, substitution) { - if (index > 0 && index < grid[0].cells.length) { - each$2(grid, function (row) { - var prevCell = row.cells[index - 1]; - var current = row.cells[index]; - var isToReplace = comparator(current.element, prevCell.element); - if (isToReplace) { - mutateCell(row, index, elementnew(substitution(), true, current.isLocked)); - } - }); - } - return grid; - }; - var splitRows = function (grid, index, comparator, substitution) { - var rows = extractGridDetails(grid).rows; - if (index > 0 && index < rows.length) { - var rowPrevCells = rows[index - 1].cells; - var cells = uniqueCells(rowPrevCells, comparator); - each$2(cells, function (cell) { - var replacement = Optional.none(); - for (var i = index; i < rows.length; i++) { - var _loop_1 = function (j) { - var row = rows[i]; - var current = getCell(row, j); - var isToReplace = comparator(current.element, cell.element); - if (isToReplace) { - if (replacement.isNone()) { - replacement = Optional.some(substitution()); - } - replacement.each(function (sub) { - mutateCell(row, j, elementnew(sub, true, current.isLocked)); - }); - } - }; - for (var j = 0; j < cellLength(rows[0]); j++) { - _loop_1(j); - } - } - }); - } - return grid; - }; - - var value$1 = function (o) { - var or = function (_opt) { - return value$1(o); - }; - var orThunk = function (_f) { - return value$1(o); - }; - var map = function (f) { - return value$1(f(o)); - }; - var mapError = function (_f) { - return value$1(o); - }; - var each = function (f) { - f(o); - }; - var bind = function (f) { - return f(o); - }; - var fold = function (_, onValue) { - return onValue(o); - }; - var exists = function (f) { - return f(o); - }; - var forall = function (f) { - return f(o); - }; - var toOptional = function () { - return Optional.some(o); - }; - return { - isValue: always, - isError: never, - getOr: constant(o), - getOrThunk: constant(o), - getOrDie: constant(o), - or: or, - orThunk: orThunk, - fold: fold, - map: map, - mapError: mapError, - each: each, - bind: bind, - exists: exists, - forall: forall, - toOptional: toOptional - }; - }; - var error = function (message) { - var getOrThunk = function (f) { - return f(); - }; - var getOrDie = function () { - return die(String(message))(); - }; - var or = identity; - var orThunk = function (f) { - return f(); - }; - var map = function (_f) { - return error(message); - }; - var mapError = function (f) { - return error(f(message)); - }; - var bind = function (_f) { - return error(message); - }; - var fold = function (onError, _) { - return onError(message); - }; - return { - isValue: never, - isError: always, - getOr: identity, - getOrThunk: getOrThunk, - getOrDie: getOrDie, - or: or, - orThunk: orThunk, - fold: fold, - map: map, - mapError: mapError, - each: noop, - bind: bind, - exists: never, - forall: always, - toOptional: Optional.none - }; - }; - var fromOption = function (opt, err) { - return opt.fold(function () { - return error(err); - }, value$1); - }; - var Result = { - value: value$1, - error: error, - fromOption: fromOption - }; - - var measure = function (startAddress, gridA, gridB) { - if (startAddress.row >= gridA.length || startAddress.column > cellLength(gridA[0])) { - return Result.error('invalid start address out of table bounds, row: ' + startAddress.row + ', column: ' + startAddress.column); - } - var rowRemainder = gridA.slice(startAddress.row); - var colRemainder = rowRemainder[0].cells.slice(startAddress.column); - var colRequired = cellLength(gridB[0]); - var rowRequired = gridB.length; - return Result.value({ - rowDelta: rowRemainder.length - rowRequired, - colDelta: colRemainder.length - colRequired - }); - }; - var measureWidth = function (gridA, gridB) { - var colLengthA = cellLength(gridA[0]); - var colLengthB = cellLength(gridB[0]); - return { - rowDelta: 0, - colDelta: colLengthA - colLengthB - }; - }; - var measureHeight = function (gridA, gridB) { - var rowLengthA = gridA.length; - var rowLengthB = gridB.length; - return { - rowDelta: rowLengthA - rowLengthB, - colDelta: 0 - }; - }; - var generateElements = function (amount, row, generators, isLocked) { - var generator = row.section === 'colgroup' ? generators.col : generators.cell; - return range$1(amount, function (idx) { - return elementnew(generator(), true, isLocked(idx)); - }); - }; - var rowFill = function (grid, amount, generators, lockedColumns) { - var exampleRow = grid[grid.length - 1]; - return grid.concat(range$1(amount, function () { - var generator = exampleRow.section === 'colgroup' ? generators.colgroup : generators.row; - var row = clone$1(exampleRow, generator, identity); - var elements = generateElements(row.cells.length, row, generators, function (idx) { - return has$1(lockedColumns, idx.toString()); - }); - return setCells(row, elements); - })); - }; - var colFill = function (grid, amount, generators, startIndex) { - return map$1(grid, function (row) { - var newChildren = generateElements(amount, row, generators, never); - return addCells(row, startIndex, newChildren); - }); - }; - var lockedColFill = function (grid, generators, lockedColumns) { - return map$1(grid, function (row) { - return foldl(lockedColumns, function (acc, colNum) { - var newChild = generateElements(1, row, generators, always)[0]; - return addCell(acc, colNum, newChild); - }, row); - }); - }; - var tailor = function (gridA, delta, generators) { - var fillCols = delta.colDelta < 0 ? colFill : identity; - var fillRows = delta.rowDelta < 0 ? rowFill : identity; - var lockedColumns = getLockedColumnsFromGrid(gridA); - var gridWidth = cellLength(gridA[0]); - var isLastColLocked = exists(lockedColumns, function (locked) { - return locked === gridWidth - 1; - }); - var modifiedCols = fillCols(gridA, Math.abs(delta.colDelta), generators, isLastColLocked ? gridWidth - 1 : gridWidth); - var newLockedColumns = getLockedColumnsFromGrid(modifiedCols); - return fillRows(modifiedCols, Math.abs(delta.rowDelta), generators, mapToObject(newLockedColumns, always)); - }; - - var isSpanning = function (grid, row, col, comparator) { - var candidate = getCell(grid[row], col); - var matching = curry(comparator, candidate.element); - var currentRow = grid[row]; - return grid.length > 1 && cellLength(currentRow) > 1 && (col > 0 && matching(getCellElement(currentRow, col - 1)) || col < currentRow.cells.length - 1 && matching(getCellElement(currentRow, col + 1)) || row > 0 && matching(getCellElement(grid[row - 1], col)) || row < grid.length - 1 && matching(getCellElement(grid[row + 1], col))); - }; - var mergeTables = function (startAddress, gridA, gridB, generator, comparator, lockedColumns) { - var startRow = startAddress.row; - var startCol = startAddress.column; - var mergeHeight = gridB.length; - var mergeWidth = cellLength(gridB[0]); - var endRow = startRow + mergeHeight; - var endCol = startCol + mergeWidth + lockedColumns.length; - var lockedColumnObj = mapToObject(lockedColumns, always); - for (var r = startRow; r < endRow; r++) { - var skippedCol = 0; - for (var c = startCol; c < endCol; c++) { - if (lockedColumnObj[c]) { - skippedCol++; - continue; - } - if (isSpanning(gridA, r, c, comparator)) { - unmerge(gridA, getCellElement(gridA[r], c), comparator, generator.cell); - } - var gridBColIndex = c - startCol - skippedCol; - var newCell = getCell(gridB[r - startRow], gridBColIndex); - var newCellElm = newCell.element; - var replacement = generator.replace(newCellElm); - mutateCell(gridA[r], c, elementnew(replacement, true, newCell.isLocked)); - } - } - return gridA; - }; - var getValidStartAddress = function (currentStartAddress, grid, lockedColumns) { - var gridColLength = cellLength(grid[0]); - var adjustedRowAddress = extractGridDetails(grid).cols.length + currentStartAddress.row; - var possibleColAddresses = range$1(gridColLength - currentStartAddress.column, function (num) { - return num + currentStartAddress.column; - }); - var validColAddress = find$1(possibleColAddresses, function (num) { - return forall(lockedColumns, function (col) { - return col !== num; - }); - }).getOr(gridColLength - 1); - return { - row: adjustedRowAddress, - column: validColAddress - }; - }; - var getLockedColumnsWithinBounds = function (startAddress, grid, lockedColumns) { - return filter$2(lockedColumns, function (colNum) { - return colNum >= startAddress.column && colNum <= cellLength(grid[0]) + startAddress.column; - }); - }; - var merge$1 = function (startAddress, gridA, gridB, generator, comparator) { - var lockedColumns = getLockedColumnsFromGrid(gridA); - var validStartAddress = getValidStartAddress(startAddress, gridA, lockedColumns); - var gridBRows = extractGridDetails(gridB).rows; - var lockedColumnsWithinBounds = getLockedColumnsWithinBounds(validStartAddress, gridBRows, lockedColumns); - var result = measure(validStartAddress, gridA, gridBRows); - return result.map(function (diff) { - var delta = __assign(__assign({}, diff), { colDelta: diff.colDelta - lockedColumnsWithinBounds.length }); - var fittedGrid = tailor(gridA, delta, generator); - var newLockedColumns = getLockedColumnsFromGrid(fittedGrid); - var newLockedColumnsWithinBounds = getLockedColumnsWithinBounds(validStartAddress, gridBRows, newLockedColumns); - return mergeTables(validStartAddress, fittedGrid, gridBRows, generator, comparator, newLockedColumnsWithinBounds); - }); - }; - var insertCols = function (index, gridA, gridB, generator, comparator) { - splitCols(gridA, index, comparator, generator.cell); - var delta = measureHeight(gridB, gridA); - var fittedNewGrid = tailor(gridB, delta, generator); - var secondDelta = measureHeight(gridA, fittedNewGrid); - var fittedOldGrid = tailor(gridA, secondDelta, generator); - return map$1(fittedOldGrid, function (gridRow, i) { - return addCells(gridRow, index, fittedNewGrid[i].cells); - }); - }; - var insertRows = function (index, gridA, gridB, generator, comparator) { - splitRows(gridA, index, comparator, generator.cell); - var locked = getLockedColumnsFromGrid(gridA); - var diff = measureWidth(gridA, gridB); - var delta = __assign(__assign({}, diff), { colDelta: diff.colDelta - locked.length }); - var fittedOldGrid = tailor(gridA, delta, generator); - var _a = extractGridDetails(fittedOldGrid), oldCols = _a.cols, oldRows = _a.rows; - var newLocked = getLockedColumnsFromGrid(fittedOldGrid); - var secondDiff = measureWidth(gridB, gridA); - var secondDelta = __assign(__assign({}, secondDiff), { colDelta: secondDiff.colDelta + newLocked.length }); - var fittedGridB = lockedColFill(gridB, generator, newLocked); - var fittedNewGrid = tailor(fittedGridB, secondDelta, generator); - return oldCols.concat(oldRows.slice(0, index)).concat(fittedNewGrid).concat(oldRows.slice(index, oldRows.length)); - }; - - var cloneRow = function (row, cloneCell, comparator, substitution) { - return clone$1(row, function (elem) { - return substitution(elem, comparator); - }, cloneCell); - }; - var insertRowAt = function (grid, index, example, comparator, substitution) { - var _a = extractGridDetails(grid), rows = _a.rows, cols = _a.cols; - var before = rows.slice(0, index); - var after = rows.slice(index); - var newRow = cloneRow(rows[example], function (ex, c) { - var withinSpan = index > 0 && index < rows.length && comparator(getCellElement(rows[index - 1], c), getCellElement(rows[index], c)); - var ret = withinSpan ? getCell(rows[index], c) : elementnew(substitution(ex.element, comparator), true, ex.isLocked); - return ret; - }, comparator, substitution); - return cols.concat(before).concat([newRow]).concat(after); - }; - var getElementFor = function (row, column, section, withinSpan, example, comparator, substitution) { - if (section === 'colgroup' || !withinSpan) { - var cell = getCell(row, example); - return elementnew(substitution(cell.element, comparator), true, false); - } else { - return getCell(row, column); - } - }; - var insertColumnAt = function (grid, index, example, comparator, substitution) { - return map$1(grid, function (row) { - var withinSpan = index > 0 && index < cellLength(row) && comparator(getCellElement(row, index - 1), getCellElement(row, index)); - var sub = getElementFor(row, index, row.section, withinSpan, example, comparator, substitution); - return addCell(row, index, sub); - }); - }; - var deleteColumnsAt = function (grid, columns) { - return bind$2(grid, function (row) { - var existingCells = row.cells; - var cells = foldr(columns, function (acc, column) { - return column >= 0 && column < acc.length ? acc.slice(0, column).concat(acc.slice(column + 1)) : acc; - }, existingCells); - return cells.length > 0 ? [rowcells(row.element, cells, row.section, row.isNew)] : []; - }); - }; - var deleteRowsAt = function (grid, start, finish) { - var _a = extractGridDetails(grid), rows = _a.rows, cols = _a.cols; - return cols.concat(rows.slice(0, start)).concat(rows.slice(finish + 1)); - }; - - var notInStartRow = function (grid, rowIndex, colIndex, comparator) { - return getCellElement(grid[rowIndex], colIndex) !== undefined && (rowIndex > 0 && comparator(getCellElement(grid[rowIndex - 1], colIndex), getCellElement(grid[rowIndex], colIndex))); - }; - var notInStartColumn = function (row, index, comparator) { - return index > 0 && comparator(getCellElement(row, index - 1), getCellElement(row, index)); - }; - var isDuplicatedCell = function (grid, rowIndex, colIndex, comparator) { - return notInStartRow(grid, rowIndex, colIndex, comparator) || notInStartColumn(grid[rowIndex], colIndex, comparator); - }; - var rowReplacerPredicate = function (targetRow, columnHeaders) { - var entireTableIsHeader = forall(columnHeaders, identity) && isHeaderCells(targetRow.cells); - return entireTableIsHeader ? always : function (cell, _rowIndex, colIndex) { - var type = name(cell.element); - return !(type === 'th' && columnHeaders[colIndex]); - }; - }; - var columnReplacePredicate = function (targetColumn, rowHeaders) { - var entireTableIsHeader = forall(rowHeaders, identity) && isHeaderCells(targetColumn); - return entireTableIsHeader ? always : function (cell, rowIndex, _colIndex) { - var type = name(cell.element); - return !(type === 'th' && rowHeaders[rowIndex]); - }; - }; - var determineScope = function (applyScope, element, newScope, isInHeader) { - var hasSpan = function (scope) { - return scope === 'row' ? hasRowspan(element) : hasColspan(element); - }; - var getScope = function (scope) { - return hasSpan(scope) ? scope + 'group' : scope; - }; - if (applyScope) { - return isHeaderCell(element) ? getScope(newScope) : null; - } else if (isInHeader && isHeaderCell(element)) { - var oppositeScope = newScope === 'row' ? 'col' : 'row'; - return getScope(oppositeScope); - } else { - return null; - } - }; - var rowScopeGenerator = function (applyScope, columnHeaders) { - return function (cell, rowIndex, columnIndex) { - return Optional.some(determineScope(applyScope, cell.element, 'col', columnHeaders[columnIndex])); - }; - }; - var columnScopeGenerator = function (applyScope, rowHeaders) { - return function (cell, rowIndex) { - return Optional.some(determineScope(applyScope, cell.element, 'row', rowHeaders[rowIndex])); - }; - }; - var replace = function (cell, comparator, substitute) { - return elementnew(substitute(cell.element, comparator), true, cell.isLocked); - }; - var replaceIn = function (grid, targets, comparator, substitute, replacer, genScope, shouldReplace) { - var isTarget = function (cell) { - return exists(targets, function (target) { - return comparator(cell.element, target.element); - }); - }; - return map$1(grid, function (row, rowIndex) { - return mapCells(row, function (cell, colIndex) { - if (isTarget(cell)) { - var newCell_1 = shouldReplace(cell, rowIndex, colIndex) ? replacer(cell, comparator, substitute) : cell; - genScope(newCell_1, rowIndex, colIndex).each(function (scope) { - setOptions(newCell_1.element, { scope: Optional.from(scope) }); - }); - return newCell_1; - } else { - return cell; - } - }); - }); - }; - var getColumnCells = function (rows, columnIndex, comparator) { - return bind$2(rows, function (row, i) { - return isDuplicatedCell(rows, i, columnIndex, comparator) ? [] : [getCell(row, columnIndex)]; - }); - }; - var getRowCells = function (rows, rowIndex, comparator) { - var targetRow = rows[rowIndex]; - return bind$2(targetRow.cells, function (item, i) { - return isDuplicatedCell(rows, rowIndex, i, comparator) ? [] : [item]; - }); - }; - var replaceColumns = function (grid, indexes, applyScope, comparator, substitution) { - var rows = extractGridDetails(grid).rows; - var targets = bind$2(indexes, function (index) { - return getColumnCells(rows, index, comparator); - }); - var rowHeaders = map$1(grid, function (row) { - return isHeaderCells(row.cells); - }); - var shouldReplaceCell = columnReplacePredicate(targets, rowHeaders); - var scopeGenerator = columnScopeGenerator(applyScope, rowHeaders); - return replaceIn(grid, targets, comparator, substitution, replace, scopeGenerator, shouldReplaceCell); - }; - var replaceRows = function (grid, indexes, section, applyScope, comparator, substitution, tableSection) { - var _a = extractGridDetails(grid), cols = _a.cols, rows = _a.rows; - var targetRow = rows[indexes[0]]; - var targets = bind$2(indexes, function (index) { - return getRowCells(rows, index, comparator); - }); - var columnHeaders = map$1(targetRow.cells, function (_cell, index) { - return isHeaderCells(getColumnCells(rows, index, comparator)); - }); - var newRows = __spreadArray([], rows, true); - each$2(indexes, function (index) { - newRows[index] = tableSection.transformRow(rows[index], section); - }); - var newGrid = cols.concat(newRows); - var shouldReplaceCell = rowReplacerPredicate(targetRow, columnHeaders); - var scopeGenerator = rowScopeGenerator(applyScope, columnHeaders); - return replaceIn(newGrid, targets, comparator, substitution, tableSection.transformCell, scopeGenerator, shouldReplaceCell); - }; - var replaceCells = function (grid, details, comparator, substitution) { - var rows = extractGridDetails(grid).rows; - var targetCells = map$1(details, function (detail) { - return getCell(rows[detail.row], detail.column); - }); - return replaceIn(grid, targetCells, comparator, substitution, replace, Optional.none, always); - }; - - var uniqueColumns = function (details) { - var uniqueCheck = function (rest, detail) { - var columnExists = exists(rest, function (currentDetail) { - return currentDetail.column === detail.column; - }); - return columnExists ? rest : rest.concat([detail]); - }; - return foldl(details, uniqueCheck, []).sort(function (detailA, detailB) { - return detailA.column - detailB.column; - }); - }; - - var isCol = isTag('col'); - var isColgroup = isTag('colgroup'); - var isRow$1 = function (element) { - return name(element) === 'tr' || isColgroup(element); - }; - var elementToData = function (element) { - var colspan = getAttrValue(element, 'colspan', 1); - var rowspan = getAttrValue(element, 'rowspan', 1); - return { - element: element, - colspan: colspan, - rowspan: rowspan - }; - }; - var modification = function (generators, toData) { - if (toData === void 0) { - toData = elementToData; - } - var nuCell = function (data) { - return isCol(data.element) ? generators.col(data) : generators.cell(data); - }; - var nuRow = function (data) { - return isColgroup(data.element) ? generators.colgroup(data) : generators.row(data); - }; - var add = function (element) { - if (isRow$1(element)) { - return nuRow({ element: element }); - } else { - var replacement = nuCell(toData(element)); - recent = Optional.some({ - item: element, - replacement: replacement - }); - return replacement; - } - }; - var recent = Optional.none(); - var getOrInit = function (element, comparator) { - return recent.fold(function () { - return add(element); - }, function (p) { - return comparator(element, p.item) ? p.replacement : add(element); - }); - }; - return { getOrInit: getOrInit }; - }; - var transform = function (tag) { - return function (generators) { - var list = []; - var find = function (element, comparator) { - return find$1(list, function (x) { - return comparator(x.item, element); - }); - }; - var makeNew = function (element) { - var attrs = tag === 'td' ? { scope: null } : {}; - var cell = generators.replace(element, tag, attrs); - list.push({ - item: element, - sub: cell - }); - return cell; - }; - var replaceOrInit = function (element, comparator) { - if (isRow$1(element) || isCol(element)) { - return element; - } else { - return find(element, comparator).fold(function () { - return makeNew(element); - }, function (p) { - return comparator(element, p.item) ? p.sub : makeNew(element); - }); - } - }; - return { replaceOrInit: replaceOrInit }; - }; - }; - var getScopeAttribute = function (cell) { - return getOpt(cell, 'scope').map(function (attribute) { - return attribute.substr(0, 3); - }); - }; - var merging = function (generators) { - var unmerge = function (cell) { - var scope = getScopeAttribute(cell); - scope.each(function (attribute) { - return set$2(cell, 'scope', attribute); - }); - return function () { - var raw = generators.cell({ - element: cell, - colspan: 1, - rowspan: 1 - }); - remove$6(raw, 'width'); - remove$6(cell, 'width'); - scope.each(function (attribute) { - return set$2(raw, 'scope', attribute); - }); - return raw; - }; - }; - var merge = function (cells) { - var getScopeProperty = function () { - var stringAttributes = cat(map$1(cells, getScopeAttribute)); - if (stringAttributes.length === 0) { - return Optional.none(); - } else { - var baseScope_1 = stringAttributes[0]; - var scopes_1 = [ - 'row', - 'col' - ]; - var isMixed = exists(stringAttributes, function (attribute) { - return attribute !== baseScope_1 && contains$2(scopes_1, attribute); - }); - return isMixed ? Optional.none() : Optional.from(baseScope_1); - } - }; - remove$6(cells[0], 'width'); - getScopeProperty().fold(function () { - return remove$7(cells[0], 'scope'); - }, function (attribute) { - return set$2(cells[0], 'scope', attribute + 'group'); - }); - return constant(cells[0]); - }; - return { - unmerge: unmerge, - merge: merge - }; - }; - var Generators = { - modification: modification, - transform: transform, - merging: merging - }; - - var blockList = [ - 'body', - 'p', - 'div', - 'article', - 'aside', - 'figcaption', - 'figure', - 'footer', - 'header', - 'nav', - 'section', - 'ol', - 'ul', - 'table', - 'thead', - 'tfoot', - 'tbody', - 'caption', - 'tr', - 'td', - 'th', - 'h1', - 'h2', - 'h3', - 'h4', - 'h5', - 'h6', - 'blockquote', - 'pre', - 'address' - ]; - var isList$1 = function (universe, item) { - var tagName = universe.property().name(item); - return contains$2([ - 'ol', - 'ul' - ], tagName); - }; - var isBlock$1 = function (universe, item) { - var tagName = universe.property().name(item); - return contains$2(blockList, tagName); - }; - var isEmptyTag$1 = function (universe, item) { - return contains$2([ - 'br', - 'img', - 'hr', - 'input' - ], universe.property().name(item)); - }; - - var universe$1 = DomUniverse(); - var isBlock = function (element) { - return isBlock$1(universe$1, element); - }; - var isList = function (element) { - return isList$1(universe$1, element); - }; - var isEmptyTag = function (element) { - return isEmptyTag$1(universe$1, element); - }; - - var merge = function (cells) { - var isBr = function (el) { - return name(el) === 'br'; - }; - var advancedBr = function (children) { - return forall(children, function (c) { - return isBr(c) || isText(c) && get$9(c).trim().length === 0; - }); - }; - var isListItem = function (el) { - return name(el) === 'li' || ancestor$2(el, isList).isSome(); - }; - var siblingIsBlock = function (el) { - return nextSibling(el).map(function (rightSibling) { - if (isBlock(rightSibling)) { - return true; - } - if (isEmptyTag(rightSibling)) { - return name(rightSibling) === 'img' ? false : true; - } - return false; - }).getOr(false); - }; - var markCell = function (cell) { - return last$1(cell).bind(function (rightEdge) { - var rightSiblingIsBlock = siblingIsBlock(rightEdge); - return parent(rightEdge).map(function (parent) { - return rightSiblingIsBlock === true || isListItem(parent) || isBr(rightEdge) || isBlock(parent) && !eq$1(cell, parent) ? [] : [SugarElement.fromTag('br')]; - }); - }).getOr([]); - }; - var markContent = function () { - var content = bind$2(cells, function (cell) { - var children = children$3(cell); - return advancedBr(children) ? [] : children.concat(markCell(cell)); - }); - return content.length === 0 ? [SugarElement.fromTag('br')] : content; - }; - var contents = markContent(); - empty(cells[0]); - append(cells[0], contents); - }; - - var isEditable = function (elem) { - return isEditable$1(elem, true); - }; - var prune = function (table) { - var cells = cells$1(table); - if (cells.length === 0) { - remove$5(table); - } - }; - var outcome = function (grid, cursor) { - return { - grid: grid, - cursor: cursor - }; - }; - var findEditableCursorPosition = function (rows) { - return findMap(rows, function (row) { - return findMap(row.cells, function (cell) { - var elem = cell.element; - return someIf(isEditable(elem), elem); - }); - }); - }; - var elementFromGrid = function (grid, row, column) { - var _a, _b; - var rows = extractGridDetails(grid).rows; - return Optional.from((_b = (_a = rows[row]) === null || _a === void 0 ? void 0 : _a.cells[column]) === null || _b === void 0 ? void 0 : _b.element).filter(isEditable).orThunk(function () { - return findEditableCursorPosition(rows); - }); - }; - var bundle = function (grid, row, column) { - var cursorElement = elementFromGrid(grid, row, column); - return outcome(grid, cursorElement); - }; - var uniqueRows = function (details) { - var rowCompilation = function (rest, detail) { - var rowExists = exists(rest, function (currentDetail) { - return currentDetail.row === detail.row; - }); - return rowExists ? rest : rest.concat([detail]); - }; - return foldl(details, rowCompilation, []).sort(function (detailA, detailB) { - return detailA.row - detailB.row; - }); - }; - var opInsertRowsBefore = function (grid, details, comparator, genWrappers) { - var targetIndex = details[0].row; - var rows = uniqueRows(details); - var newGrid = foldr(rows, function (acc, row) { - var newG = insertRowAt(acc.grid, targetIndex, row.row + acc.delta, comparator, genWrappers.getOrInit); - return { - grid: newG, - delta: acc.delta + 1 - }; - }, { - grid: grid, - delta: 0 - }).grid; - return bundle(newGrid, targetIndex, details[0].column); - }; - var opInsertRowsAfter = function (grid, details, comparator, genWrappers) { - var rows = uniqueRows(details); - var target = rows[rows.length - 1]; - var targetIndex = target.row + target.rowspan; - var newGrid = foldr(rows, function (newG, row) { - return insertRowAt(newG, targetIndex, row.row, comparator, genWrappers.getOrInit); - }, grid); - return bundle(newGrid, targetIndex, details[0].column); - }; - var opInsertColumnsBefore = function (grid, extractDetail, comparator, genWrappers) { - var details = extractDetail.details; - var columns = uniqueColumns(details); - var targetIndex = columns[0].column; - var newGrid = foldr(columns, function (acc, col) { - var newG = insertColumnAt(acc.grid, targetIndex, col.column + acc.delta, comparator, genWrappers.getOrInit); - return { - grid: newG, - delta: acc.delta + 1 - }; - }, { - grid: grid, - delta: 0 - }).grid; - return bundle(newGrid, details[0].row, targetIndex); - }; - var opInsertColumnsAfter = function (grid, extractDetail, comparator, genWrappers) { - var details = extractDetail.details; - var target = details[details.length - 1]; - var targetIndex = target.column + target.colspan; - var columns = uniqueColumns(details); - var newGrid = foldr(columns, function (newG, col) { - return insertColumnAt(newG, targetIndex, col.column, comparator, genWrappers.getOrInit); - }, grid); - return bundle(newGrid, details[0].row, targetIndex); - }; - var opMakeColumnsHeader = function (initialGrid, details, comparator, genWrappers) { - var columns = uniqueColumns(details); - var columnIndexes = map$1(columns, function (detail) { - return detail.column; - }); - var newGrid = replaceColumns(initialGrid, columnIndexes, true, comparator, genWrappers.replaceOrInit); - return bundle(newGrid, details[0].row, details[0].column); - }; - var opMakeCellsHeader = function (initialGrid, details, comparator, genWrappers) { - var newGrid = replaceCells(initialGrid, details, comparator, genWrappers.replaceOrInit); - return bundle(newGrid, details[0].row, details[0].column); - }; - var opUnmakeColumnsHeader = function (initialGrid, details, comparator, genWrappers) { - var columns = uniqueColumns(details); - var columnIndexes = map$1(columns, function (detail) { - return detail.column; - }); - var newGrid = replaceColumns(initialGrid, columnIndexes, false, comparator, genWrappers.replaceOrInit); - return bundle(newGrid, details[0].row, details[0].column); - }; - var opUnmakeCellsHeader = function (initialGrid, details, comparator, genWrappers) { - var newGrid = replaceCells(initialGrid, details, comparator, genWrappers.replaceOrInit); - return bundle(newGrid, details[0].row, details[0].column); - }; - var makeRowsSection = function (section, applyScope) { - return function (initialGrid, details, comparator, genWrappers, tableSection) { - var rows = uniqueRows(details); - var rowIndexes = map$1(rows, function (detail) { - return detail.row; - }); - var newGrid = replaceRows(initialGrid, rowIndexes, section, applyScope, comparator, genWrappers.replaceOrInit, tableSection); - return bundle(newGrid, details[0].row, details[0].column); - }; - }; - var opMakeRowsHeader = makeRowsSection('thead', true); - var opMakeRowsBody = makeRowsSection('tbody', false); - var opMakeRowsFooter = makeRowsSection('tfoot', false); - var opEraseColumns = function (grid, extractDetail, _comparator, _genWrappers) { - var columns = uniqueColumns(extractDetail.details); - var newGrid = deleteColumnsAt(grid, map$1(columns, function (column) { - return column.column; - })); - var maxColIndex = newGrid.length > 0 ? newGrid[0].cells.length - 1 : 0; - return bundle(newGrid, columns[0].row, Math.min(columns[0].column, maxColIndex)); - }; - var opEraseRows = function (grid, details, _comparator, _genWrappers) { - var rows = uniqueRows(details); - var newGrid = deleteRowsAt(grid, rows[0].row, rows[rows.length - 1].row); - var maxRowIndex = newGrid.length > 0 ? newGrid.length - 1 : 0; - return bundle(newGrid, Math.min(details[0].row, maxRowIndex), details[0].column); - }; - var opMergeCells = function (grid, mergable, comparator, genWrappers) { - var cells = mergable.cells; - merge(cells); - var newGrid = merge$2(grid, mergable.bounds, comparator, genWrappers.merge(cells)); - return outcome(newGrid, Optional.from(cells[0])); - }; - var opUnmergeCells = function (grid, unmergable, comparator, genWrappers) { - var unmerge$1 = function (b, cell) { - return unmerge(b, cell, comparator, genWrappers.unmerge(cell)); - }; - var newGrid = foldr(unmergable, unmerge$1, grid); - return outcome(newGrid, Optional.from(unmergable[0])); - }; - var opPasteCells = function (grid, pasteDetails, comparator, _genWrappers) { - var gridify = function (table, generators) { - var wh = Warehouse.fromTable(table); - return toGrid(wh, generators, true); - }; - var gridB = gridify(pasteDetails.clipboard, pasteDetails.generators); - var startAddress = address(pasteDetails.row, pasteDetails.column); - var mergedGrid = merge$1(startAddress, grid, gridB, pasteDetails.generators, comparator); - return mergedGrid.fold(function () { - return outcome(grid, Optional.some(pasteDetails.element)); - }, function (newGrid) { - return bundle(newGrid, pasteDetails.row, pasteDetails.column); - }); - }; - var gridifyRows = function (rows, generators, context) { - var pasteDetails = fromPastedRows(rows, context.section); - var wh = Warehouse.generate(pasteDetails); - return toGrid(wh, generators, true); - }; - var opPasteColsBefore = function (grid, pasteDetails, comparator, _genWrappers) { - var rows = extractGridDetails(grid).rows; - var index = pasteDetails.cells[0].column; - var context = rows[pasteDetails.cells[0].row]; - var gridB = gridifyRows(pasteDetails.clipboard, pasteDetails.generators, context); - var mergedGrid = insertCols(index, grid, gridB, pasteDetails.generators, comparator); - return bundle(mergedGrid, pasteDetails.cells[0].row, pasteDetails.cells[0].column); - }; - var opPasteColsAfter = function (grid, pasteDetails, comparator, _genWrappers) { - var rows = extractGridDetails(grid).rows; - var index = pasteDetails.cells[pasteDetails.cells.length - 1].column + pasteDetails.cells[pasteDetails.cells.length - 1].colspan; - var context = rows[pasteDetails.cells[0].row]; - var gridB = gridifyRows(pasteDetails.clipboard, pasteDetails.generators, context); - var mergedGrid = insertCols(index, grid, gridB, pasteDetails.generators, comparator); - return bundle(mergedGrid, pasteDetails.cells[0].row, pasteDetails.cells[0].column); - }; - var opPasteRowsBefore = function (grid, pasteDetails, comparator, _genWrappers) { - var rows = extractGridDetails(grid).rows; - var index = pasteDetails.cells[0].row; - var context = rows[index]; - var gridB = gridifyRows(pasteDetails.clipboard, pasteDetails.generators, context); - var mergedGrid = insertRows(index, grid, gridB, pasteDetails.generators, comparator); - return bundle(mergedGrid, pasteDetails.cells[0].row, pasteDetails.cells[0].column); - }; - var opPasteRowsAfter = function (grid, pasteDetails, comparator, _genWrappers) { - var rows = extractGridDetails(grid).rows; - var index = pasteDetails.cells[pasteDetails.cells.length - 1].row + pasteDetails.cells[pasteDetails.cells.length - 1].rowspan; - var context = rows[pasteDetails.cells[0].row]; - var gridB = gridifyRows(pasteDetails.clipboard, pasteDetails.generators, context); - var mergedGrid = insertRows(index, grid, gridB, pasteDetails.generators, comparator); - return bundle(mergedGrid, pasteDetails.cells[0].row, pasteDetails.cells[0].column); - }; - var opGetColumnsType = function (table, target) { - var house = Warehouse.fromTable(table); - var details = onCells(house, target); - return details.bind(function (selectedCells) { - var lastSelectedCell = selectedCells[selectedCells.length - 1]; - var minColRange = selectedCells[0].column; - var maxColRange = lastSelectedCell.column + lastSelectedCell.colspan; - var selectedColumnCells = flatten$1(map$1(house.all, function (row) { - return filter$2(row.cells, function (cell) { - return cell.column >= minColRange && cell.column < maxColRange; - }); - })); - return findCommonCellType(selectedColumnCells); - }).getOr(''); - }; - var opGetCellsType = function (table, target) { - var house = Warehouse.fromTable(table); - var details = onCells(house, target); - return details.bind(findCommonCellType).getOr(''); - }; - var opGetRowsType = function (table, target) { - var house = Warehouse.fromTable(table); - var details = onCells(house, target); - return details.bind(function (selectedCells) { - var lastSelectedCell = selectedCells[selectedCells.length - 1]; - var minRowRange = selectedCells[0].row; - var maxRowRange = lastSelectedCell.row + lastSelectedCell.rowspan; - var selectedRows = house.all.slice(minRowRange, maxRowRange); - return findCommonRowType(selectedRows); - }).getOr(''); - }; - var resize = function (table, list, details, behaviours) { - return adjustWidthTo(table, list, details, behaviours.sizing); - }; - var adjustAndRedistributeWidths = function (table, list, details, behaviours) { - return adjustAndRedistributeWidths$1(table, list, details, behaviours.sizing, behaviours.resize); - }; - var firstColumnIsLocked = function (_warehouse, details) { - return exists(details, function (detail) { - return detail.column === 0 && detail.isLocked; - }); - }; - var lastColumnIsLocked = function (warehouse, details) { - return exists(details, function (detail) { - return detail.column + detail.colspan >= warehouse.grid.columns && detail.isLocked; - }); - }; - var getColumnsWidth = function (warehouse, details) { - var columns$1 = columns(warehouse); - var uniqueCols = uniqueColumns(details); - return foldl(uniqueCols, function (acc, detail) { - var column = columns$1[detail.column]; - var colWidth = column.map(getOuter$2).getOr(0); - return acc + colWidth; - }, 0); - }; - var insertColumnsExtractor = function (before) { - return function (warehouse, target) { - return onCells(warehouse, target).filter(function (details) { - var checkLocked = before ? firstColumnIsLocked : lastColumnIsLocked; - return !checkLocked(warehouse, details); - }).map(function (details) { - return { - details: details, - pixelDelta: getColumnsWidth(warehouse, details) - }; - }); - }; - }; - var eraseColumnsExtractor = function (warehouse, target) { - return onUnlockedCells(warehouse, target).map(function (details) { - return { - details: details, - pixelDelta: -getColumnsWidth(warehouse, details) - }; - }); - }; - var pasteColumnsExtractor = function (before) { - return function (warehouse, target) { - return onPasteByEditor(warehouse, target).filter(function (details) { - var checkLocked = before ? firstColumnIsLocked : lastColumnIsLocked; - return !checkLocked(warehouse, details.cells); - }); - }; - }; - var headerCellGenerator = Generators.transform('th'); - var bodyCellGenerator = Generators.transform('td'); - var insertRowsBefore = run(opInsertRowsBefore, onCells, noop, noop, Generators.modification); - var insertRowsAfter = run(opInsertRowsAfter, onCells, noop, noop, Generators.modification); - var insertColumnsBefore = run(opInsertColumnsBefore, insertColumnsExtractor(true), adjustAndRedistributeWidths, noop, Generators.modification); - var insertColumnsAfter = run(opInsertColumnsAfter, insertColumnsExtractor(false), adjustAndRedistributeWidths, noop, Generators.modification); - var eraseColumns = run(opEraseColumns, eraseColumnsExtractor, adjustAndRedistributeWidths, prune, Generators.modification); - var eraseRows = run(opEraseRows, onCells, noop, prune, Generators.modification); - var makeColumnsHeader = run(opMakeColumnsHeader, onUnlockedCells, noop, noop, headerCellGenerator); - var unmakeColumnsHeader = run(opUnmakeColumnsHeader, onUnlockedCells, noop, noop, bodyCellGenerator); - var makeRowsHeader = run(opMakeRowsHeader, onUnlockedCells, noop, noop, headerCellGenerator); - var makeRowsBody = run(opMakeRowsBody, onUnlockedCells, noop, noop, bodyCellGenerator); - var makeRowsFooter = run(opMakeRowsFooter, onUnlockedCells, noop, noop, bodyCellGenerator); - var makeCellsHeader = run(opMakeCellsHeader, onUnlockedCells, noop, noop, headerCellGenerator); - var unmakeCellsHeader = run(opUnmakeCellsHeader, onUnlockedCells, noop, noop, bodyCellGenerator); - var mergeCells = run(opMergeCells, onUnlockedMergable, resize, noop, Generators.merging); - var unmergeCells = run(opUnmergeCells, onUnlockedUnmergable, resize, noop, Generators.merging); - var pasteCells = run(opPasteCells, onPaste, resize, noop, Generators.modification); - var pasteColsBefore = run(opPasteColsBefore, pasteColumnsExtractor(true), noop, noop, Generators.modification); - var pasteColsAfter = run(opPasteColsAfter, pasteColumnsExtractor(false), noop, noop, Generators.modification); - var pasteRowsBefore = run(opPasteRowsBefore, onPasteByEditor, noop, noop, Generators.modification); - var pasteRowsAfter = run(opPasteRowsAfter, onPasteByEditor, noop, noop, Generators.modification); - var getColumnsType = opGetColumnsType; - var getCellsType = opGetCellsType; - var getRowsType = opGetRowsType; - - var TableActions = function (editor, cellSelection, lazyWire) { - var isTableBody = function (editor) { - return name(getBody(editor)) === 'table'; - }; - var lastRowGuard = function (table) { - return isTableBody(editor) === false || getGridSize(table).rows > 1; - }; - var lastColumnGuard = function (table) { - return isTableBody(editor) === false || getGridSize(table).columns > 1; - }; - var cloneFormats = getCloneElements(editor); - var colMutationOp = isResizeTableColumnResizing(editor) ? noop : halve; - var getTableSectionType = function (table) { - switch (getTableHeaderType(editor)) { - case 'section': - return TableSection.section(); - case 'sectionCells': - return TableSection.sectionCells(); - case 'cells': - return TableSection.cells(); - default: - return TableSection.getTableSectionType(table, 'section'); - } - }; - var setSelectionFromAction = function (table, result) { - return result.cursor.fold(function () { - var cells = cells$1(table); - return head(cells).filter(inBody).map(function (firstCell) { - cellSelection.clear(table); - var rng = editor.dom.createRng(); - rng.selectNode(firstCell.dom); - editor.selection.setRng(rng); - set$2(firstCell, 'data-mce-selected', '1'); - return rng; - }); - }, function (cell) { - var des = freefallRtl(cell); - var rng = editor.dom.createRng(); - rng.setStart(des.element.dom, des.offset); - rng.setEnd(des.element.dom, des.offset); - editor.selection.setRng(rng); - cellSelection.clear(table); - return Optional.some(rng); - }); - }; - var execute = function (operation, guard, mutate, lazyWire, effect) { - return function (table, target, noEvents) { - if (noEvents === void 0) { - noEvents = false; - } - removeDataStyle(table); - var wire = lazyWire(); - var doc = SugarElement.fromDom(editor.getDoc()); - var generators = cellOperations(mutate, doc, cloneFormats); - var behaviours = { - sizing: get$4(editor, table), - resize: isResizeTableColumnResizing(editor) ? resizeTable() : preserveTable(), - section: getTableSectionType(table) - }; - return guard(table) ? operation(wire, table, target, generators, behaviours).bind(function (result) { - each$2(result.newRows, function (row) { - fireNewRow(editor, row.dom); - }); - each$2(result.newCells, function (cell) { - fireNewCell(editor, cell.dom); - }); - var range = setSelectionFromAction(table, result); - if (inBody(table)) { - removeDataStyle(table); - if (!noEvents) { - fireTableModified(editor, table.dom, effect); - } - } - return range.map(function (rng) { - return { - rng: rng, - effect: effect - }; - }); - }) : Optional.none(); - }; - }; - var deleteRow = execute(eraseRows, lastRowGuard, noop, lazyWire, structureModified); - var deleteColumn = execute(eraseColumns, lastColumnGuard, noop, lazyWire, structureModified); - var insertRowsBefore$1 = execute(insertRowsBefore, always, noop, lazyWire, structureModified); - var insertRowsAfter$1 = execute(insertRowsAfter, always, noop, lazyWire, structureModified); - var insertColumnsBefore$1 = execute(insertColumnsBefore, always, colMutationOp, lazyWire, structureModified); - var insertColumnsAfter$1 = execute(insertColumnsAfter, always, colMutationOp, lazyWire, structureModified); - var mergeCells$1 = execute(mergeCells, always, noop, lazyWire, structureModified); - var unmergeCells$1 = execute(unmergeCells, always, noop, lazyWire, structureModified); - var pasteColsBefore$1 = execute(pasteColsBefore, always, noop, lazyWire, structureModified); - var pasteColsAfter$1 = execute(pasteColsAfter, always, noop, lazyWire, structureModified); - var pasteRowsBefore$1 = execute(pasteRowsBefore, always, noop, lazyWire, structureModified); - var pasteRowsAfter$1 = execute(pasteRowsAfter, always, noop, lazyWire, structureModified); - var pasteCells$1 = execute(pasteCells, always, noop, lazyWire, styleAndStructureModified); - var makeCellsHeader$1 = execute(makeCellsHeader, always, noop, lazyWire, structureModified); - var unmakeCellsHeader$1 = execute(unmakeCellsHeader, always, noop, lazyWire, structureModified); - var makeColumnsHeader$1 = execute(makeColumnsHeader, always, noop, lazyWire, structureModified); - var unmakeColumnsHeader$1 = execute(unmakeColumnsHeader, always, noop, lazyWire, structureModified); - var makeRowsHeader$1 = execute(makeRowsHeader, always, noop, lazyWire, structureModified); - var makeRowsBody$1 = execute(makeRowsBody, always, noop, lazyWire, structureModified); - var makeRowsFooter$1 = execute(makeRowsFooter, always, noop, lazyWire, structureModified); - var getTableCellType = getCellsType; - var getTableColType = getColumnsType; - var getTableRowType = getRowsType; - return { - deleteRow: deleteRow, - deleteColumn: deleteColumn, - insertRowsBefore: insertRowsBefore$1, - insertRowsAfter: insertRowsAfter$1, - insertColumnsBefore: insertColumnsBefore$1, - insertColumnsAfter: insertColumnsAfter$1, - mergeCells: mergeCells$1, - unmergeCells: unmergeCells$1, - pasteColsBefore: pasteColsBefore$1, - pasteColsAfter: pasteColsAfter$1, - pasteRowsBefore: pasteRowsBefore$1, - pasteRowsAfter: pasteRowsAfter$1, - pasteCells: pasteCells$1, - makeCellsHeader: makeCellsHeader$1, - unmakeCellsHeader: unmakeCellsHeader$1, - makeColumnsHeader: makeColumnsHeader$1, - unmakeColumnsHeader: unmakeColumnsHeader$1, - makeRowsHeader: makeRowsHeader$1, - makeRowsBody: makeRowsBody$1, - makeRowsFooter: makeRowsFooter$1, - getTableRowType: getTableRowType, - getTableCellType: getTableCellType, - getTableColType: getTableColType - }; - }; - - var DefaultRenderOptions = { - styles: { - 'border-collapse': 'collapse', - 'width': '100%' - }, - attributes: { border: '1' }, - colGroups: false - }; - var tableHeaderCell = function () { - return SugarElement.fromTag('th'); - }; - var tableCell = function () { - return SugarElement.fromTag('td'); - }; - var tableColumn = function () { - return SugarElement.fromTag('col'); - }; - var createRow = function (columns, rowHeaders, columnHeaders, rowIndex) { - var tr = SugarElement.fromTag('tr'); - for (var j = 0; j < columns; j++) { - var td = rowIndex < rowHeaders || j < columnHeaders ? tableHeaderCell() : tableCell(); - if (j < columnHeaders) { - set$2(td, 'scope', 'row'); - } - if (rowIndex < rowHeaders) { - set$2(td, 'scope', 'col'); - } - append$1(td, SugarElement.fromTag('br')); - append$1(tr, td); - } - return tr; - }; - var createGroupRow = function (columns) { - var columnGroup = SugarElement.fromTag('colgroup'); - range$1(columns, function () { - return append$1(columnGroup, tableColumn()); - }); - return columnGroup; - }; - var createRows = function (rows, columns, rowHeaders, columnHeaders) { - return range$1(rows, function (r) { - return createRow(columns, rowHeaders, columnHeaders, r); - }); - }; - var render = function (rows, columns, rowHeaders, columnHeaders, headerType, renderOpts) { - if (renderOpts === void 0) { - renderOpts = DefaultRenderOptions; - } - var table = SugarElement.fromTag('table'); - var rowHeadersGoInThead = headerType !== 'cells'; - setAll(table, renderOpts.styles); - setAll$1(table, renderOpts.attributes); - if (renderOpts.colGroups) { - append$1(table, createGroupRow(columns)); - } - var actualRowHeaders = Math.min(rows, rowHeaders); - if (rowHeadersGoInThead && rowHeaders > 0) { - var thead = SugarElement.fromTag('thead'); - append$1(table, thead); - var theadRowHeaders = headerType === 'sectionCells' ? actualRowHeaders : 0; - var theadRows = createRows(rowHeaders, columns, theadRowHeaders, columnHeaders); - append(thead, theadRows); - } - var tbody = SugarElement.fromTag('tbody'); - append$1(table, tbody); - var numRows = rowHeadersGoInThead ? rows - actualRowHeaders : rows; - var numRowHeaders = rowHeadersGoInThead ? 0 : rowHeaders; - var tbodyRows = createRows(numRows, columns, numRowHeaders, columnHeaders); - append(tbody, tbodyRows); - return table; - }; - - var get$2 = function (element) { - return element.dom.innerHTML; - }; - var getOuter = function (element) { - var container = SugarElement.fromTag('div'); - var clone = SugarElement.fromDom(element.dom.cloneNode(true)); - append$1(container, clone); - return get$2(container); - }; - - var placeCaretInCell = function (editor, cell) { - editor.selection.select(cell.dom, true); - editor.selection.collapse(true); - }; - var selectFirstCellInTable = function (editor, tableElm) { - descendant(tableElm, 'td,th').each(curry(placeCaretInCell, editor)); - }; - var fireEvents = function (editor, table) { - each$2(descendants(table, 'tr'), function (row) { - fireNewRow(editor, row.dom); - each$2(descendants(row, 'th,td'), function (cell) { - fireNewCell(editor, cell.dom); - }); - }); - }; - var isPercentage = function (width) { - return isString(width) && width.indexOf('%') !== -1; - }; - var insert = function (editor, columns, rows, colHeaders, rowHeaders) { - var defaultStyles = getDefaultStyles(editor); - var options = { - styles: defaultStyles, - attributes: getDefaultAttributes(editor), - colGroups: useColumnGroup(editor) - }; - editor.undoManager.ignore(function () { - var table = render(rows, columns, rowHeaders, colHeaders, getTableHeaderType(editor), options); - set$2(table, 'data-mce-id', '__mce'); - var html = getOuter(table); - editor.insertContent(html); - editor.addVisual(); - }); - return descendant(getBody(editor), 'table[data-mce-id="__mce"]').map(function (table) { - if (isPixelsForced(editor)) { - enforcePixels(table); - } else if (isResponsiveForced(editor)) { - enforceNone(table); - } else if (isPercentagesForced(editor) || isPercentage(defaultStyles.width)) { - enforcePercentage(table); - } - removeDataStyle(table); - remove$7(table, 'data-mce-id'); - fireEvents(editor, table); - selectFirstCellInTable(editor, table); - return table.dom; - }).getOr(null); - }; - var insertTableWithDataValidation = function (editor, rows, columns, options, errorMsg) { - if (options === void 0) { - options = {}; - } - var checkInput = function (val) { - return isNumber(val) && val > 0; - }; - if (checkInput(rows) && checkInput(columns)) { - var headerRows = options.headerRows || 0; - var headerColumns = options.headerColumns || 0; - return insert(editor, columns, rows, headerColumns, headerRows); - } else { - console.error(errorMsg); - return null; - } - }; - - var getClipboardElements = function (getClipboard) { - return function () { - return getClipboard().fold(function () { - return []; - }, function (elems) { - return map$1(elems, function (e) { - return e.dom; - }); - }); - }; - }; - var setClipboardElements = function (setClipboard) { - return function (elems) { - var elmsOpt = elems.length > 0 ? Optional.some(fromDom(elems)) : Optional.none(); - setClipboard(elmsOpt); - }; - }; - var insertTable = function (editor) { - return function (columns, rows, options) { - if (options === void 0) { - options = {}; - } - var table = insertTableWithDataValidation(editor, rows, columns, options, 'Invalid values for insertTable - rows and columns values are required to insert a table.'); - editor.undoManager.add(); - return table; - }; - }; - var getApi = function (editor, clipboard, resizeHandler, selectionTargets) { - return { - insertTable: insertTable(editor), - setClipboardRows: setClipboardElements(clipboard.setRows), - getClipboardRows: getClipboardElements(clipboard.getRows), - setClipboardCols: setClipboardElements(clipboard.setColumns), - getClipboardCols: getClipboardElements(clipboard.getColumns), - resizeHandler: resizeHandler, - selectionTargets: selectionTargets - }; - }; - - var constrainSpan = function (element, property, value) { - var currentColspan = getAttrValue(element, property, 1); - if (value === 1 || currentColspan <= 1) { - remove$7(element, property); - } else { - set$2(element, property, Math.min(value, currentColspan)); - } - }; - var generateColGroup = function (house, minColRange, maxColRange) { - if (Warehouse.hasColumns(house)) { - var colsToCopy = filter$2(Warehouse.justColumns(house), function (col) { - return col.column >= minColRange && col.column < maxColRange; - }); - var copiedCols = map$1(colsToCopy, function (c) { - var clonedCol = deep(c.element); - constrainSpan(clonedCol, 'span', maxColRange - minColRange); - return clonedCol; - }); - var fakeColgroup = SugarElement.fromTag('colgroup'); - append(fakeColgroup, copiedCols); - return [fakeColgroup]; - } else { - return []; - } - }; - var generateRows = function (house, minColRange, maxColRange) { - return map$1(house.all, function (row) { - var cellsToCopy = filter$2(row.cells, function (cell) { - return cell.column >= minColRange && cell.column < maxColRange; - }); - var copiedCells = map$1(cellsToCopy, function (cell) { - var clonedCell = deep(cell.element); - constrainSpan(clonedCell, 'colspan', maxColRange - minColRange); - return clonedCell; - }); - var fakeTR = SugarElement.fromTag('tr'); - append(fakeTR, copiedCells); - return fakeTR; - }); - }; - var copyCols = function (table, target) { - var house = Warehouse.fromTable(table); - var details = onUnlockedCells(house, target); - return details.map(function (selectedCells) { - var lastSelectedCell = selectedCells[selectedCells.length - 1]; - var minColRange = selectedCells[0].column; - var maxColRange = lastSelectedCell.column + lastSelectedCell.colspan; - var fakeColGroups = generateColGroup(house, minColRange, maxColRange); - var fakeRows = generateRows(house, minColRange, maxColRange); - return __spreadArray(__spreadArray([], fakeColGroups, true), fakeRows, true); - }); - }; - - var copyRows = function (table, target, generators) { - var warehouse = Warehouse.fromTable(table); - var details = onCells(warehouse, target); - return details.bind(function (selectedCells) { - var grid = toGrid(warehouse, generators, false); - var rows = extractGridDetails(grid).rows; - var slicedGrid = rows.slice(selectedCells[0].row, selectedCells[selectedCells.length - 1].row + selectedCells[selectedCells.length - 1].rowspan); - var filteredGrid = bind$2(slicedGrid, function (row) { - var newCells = filter$2(row.cells, function (cell) { - return !cell.isLocked; - }); - return newCells.length > 0 ? [__assign(__assign({}, row), { cells: newCells })] : []; - }); - var slicedDetails = toDetailList(filteredGrid); - return someIf(slicedDetails.length > 0, slicedDetails); - }).map(function (slicedDetails) { - return copy(slicedDetails); - }); - }; - - var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools'); - - var getTDTHOverallStyle = function (dom, elm, name) { - var cells = dom.select('td,th', elm); - var firstChildStyle; - var checkChildren = function (firstChildStyle, elms) { - for (var i = 0; i < elms.length; i++) { - var currentStyle = dom.getStyle(elms[i], name); - if (typeof firstChildStyle === 'undefined') { - firstChildStyle = currentStyle; - } - if (firstChildStyle !== currentStyle) { - return ''; - } - } - return firstChildStyle; - }; - return checkChildren(firstChildStyle, cells); - }; - var applyAlign = function (editor, elm, name) { - if (name) { - editor.formatter.apply('align' + name, {}, elm); - } - }; - var applyVAlign = function (editor, elm, name) { - if (name) { - editor.formatter.apply('valign' + name, {}, elm); - } - }; - var unApplyAlign = function (editor, elm) { - global$2.each('left center right'.split(' '), function (name) { - editor.formatter.remove('align' + name, {}, elm); - }); - }; - var unApplyVAlign = function (editor, elm) { - global$2.each('top middle bottom'.split(' '), function (name) { - editor.formatter.remove('valign' + name, {}, elm); - }); - }; - - var verticalAlignValues = [ - { - text: 'None', - value: '' - }, - { - text: 'Top', - value: 'top' - }, - { - text: 'Middle', - value: 'middle' - }, - { - text: 'Bottom', - value: 'bottom' - } - ]; - - var hexColour = function (value) { - return { value: value }; - }; - var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; - var longformRegex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i; - var isHexString = function (hex) { - return shorthandRegex.test(hex) || longformRegex.test(hex); - }; - var normalizeHex = function (hex) { - return removeLeading(hex, '#').toUpperCase(); - }; - var fromString$1 = function (hex) { - return isHexString(hex) ? Optional.some({ value: normalizeHex(hex) }) : Optional.none(); - }; - var toHex = function (component) { - var hex = component.toString(16); - return (hex.length === 1 ? '0' + hex : hex).toUpperCase(); - }; - var fromRgba = function (rgbaColour) { - var value = toHex(rgbaColour.red) + toHex(rgbaColour.green) + toHex(rgbaColour.blue); - return hexColour(value); - }; - - var rgbRegex = /^rgb\((\d+),\s*(\d+),\s*(\d+)\)/; - var rgbaRegex = /^rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d?(?:\.\d+)?)\)/; - var rgbaColour = function (red, green, blue, alpha) { - return { - red: red, - green: green, - blue: blue, - alpha: alpha - }; - }; - var fromStringValues = function (red, green, blue, alpha) { - var r = parseInt(red, 10); - var g = parseInt(green, 10); - var b = parseInt(blue, 10); - var a = parseFloat(alpha); - return rgbaColour(r, g, b, a); - }; - var fromString = function (rgbaString) { - if (rgbaString === 'transparent') { - return Optional.some(rgbaColour(0, 0, 0, 0)); - } - var rgbMatch = rgbRegex.exec(rgbaString); - if (rgbMatch !== null) { - return Optional.some(fromStringValues(rgbMatch[1], rgbMatch[2], rgbMatch[3], '1')); - } - var rgbaMatch = rgbaRegex.exec(rgbaString); - if (rgbaMatch !== null) { - return Optional.some(fromStringValues(rgbaMatch[1], rgbaMatch[2], rgbaMatch[3], rgbaMatch[4])); - } - return Optional.none(); - }; - - var anyToHex = function (color) { - return fromString$1(color).orThunk(function () { - return fromString(color).map(fromRgba); - }).getOrThunk(function () { - var canvas = document.createElement('canvas'); - canvas.height = 1; - canvas.width = 1; - var canvasContext = canvas.getContext('2d'); - canvasContext.clearRect(0, 0, canvas.width, canvas.height); - canvasContext.fillStyle = '#FFFFFF'; - canvasContext.fillStyle = color; - canvasContext.fillRect(0, 0, 1, 1); - var rgba = canvasContext.getImageData(0, 0, 1, 1).data; - var r = rgba[0]; - var g = rgba[1]; - var b = rgba[2]; - var a = rgba[3]; - return fromRgba(rgbaColour(r, g, b, a)); - }); - }; - - var Cell = function (initial) { - var value = initial; - var get = function () { - return value; - }; - var set = function (v) { - value = v; - }; - return { - get: get, - set: set - }; - }; - - var singleton = function (doRevoke) { - var subject = Cell(Optional.none()); - var revoke = function () { - return subject.get().each(doRevoke); - }; - var clear = function () { - revoke(); - subject.set(Optional.none()); - }; - var isSet = function () { - return subject.get().isSome(); - }; - var get = function () { - return subject.get(); - }; - var set = function (s) { - revoke(); - subject.set(Optional.some(s)); - }; - return { - clear: clear, - isSet: isSet, - get: get, - set: set - }; - }; - var unbindable = function () { - return singleton(function (s) { - return s.unbind(); - }); - }; - var value = function () { - var subject = singleton(noop); - var on = function (f) { - return subject.get().each(f); - }; - return __assign(__assign({}, subject), { on: on }); - }; - - var onSetupToggle = function (editor, selections, formatName, formatValue) { - return function (api) { - var boundCallback = unbindable(); - var isNone = isEmpty$1(formatValue); - var init = function () { - var selectedCells = getCellsFromSelection(selections); - var checkNode = function (cell) { - return editor.formatter.match(formatName, { value: formatValue }, cell.dom, isNone); - }; - if (isNone) { - api.setActive(!exists(selectedCells, checkNode)); - boundCallback.set(editor.formatter.formatChanged(formatName, function (match) { - return api.setActive(!match); - }, true)); - } else { - api.setActive(forall(selectedCells, checkNode)); - boundCallback.set(editor.formatter.formatChanged(formatName, api.setActive, false, { value: formatValue })); - } - }; - editor.initialized ? init() : editor.on('init', init); - return boundCallback.clear; - }; - }; - var isListGroup = function (item) { - return hasNonNullableKey(item, 'menu'); - }; - var buildListItems = function (items) { - return map$1(items, function (item) { - var text = item.text || item.title; - if (isListGroup(item)) { - return { - text: text, - items: buildListItems(item.menu) - }; - } else { - return { - text: text, - value: item.value - }; - } - }); - }; - var buildMenuItems = function (editor, selections, items, format, onAction) { - return map$1(items, function (item) { - var text = item.text || item.title; - if (isListGroup(item)) { - return { - type: 'nestedmenuitem', - text: text, - getSubmenuItems: function () { - return buildMenuItems(editor, selections, item.menu, format, onAction); - } - }; - } else { - return { - text: text, - type: 'togglemenuitem', - onAction: function () { - return onAction(item.value); - }, - onSetup: onSetupToggle(editor, selections, format, item.value) - }; - } - }); - }; - var applyTableCellStyle = function (editor, style) { - return function (value) { - var _a; - editor.execCommand('mceTableApplyCellStyle', false, (_a = {}, _a[style] = value, _a)); - }; - }; - var filterNoneItem = function (list) { - return bind$2(list, function (item) { - if (isListGroup(item)) { - return [__assign(__assign({}, item), { menu: filterNoneItem(item.menu) })]; - } else { - return isNotEmpty(item.value) ? [item] : []; - } - }); - }; - var generateMenuItemsCallback = function (editor, selections, items, format, onAction) { - return function (callback) { - return callback(buildMenuItems(editor, selections, items, format, onAction)); - }; - }; - var buildColorMenu = function (editor, colorList, style) { - var colorMap = map$1(colorList, function (entry) { - return { - text: entry.title, - value: '#' + anyToHex(entry.value).value, - type: 'choiceitem' - }; - }); - return [{ - type: 'fancymenuitem', - fancytype: 'colorswatch', - initData: { - colors: colorMap.length > 0 ? colorMap : undefined, - allowCustomColors: false - }, - onAction: function (data) { - var _a; - var value = data.value === 'remove' ? '' : data.value; - editor.execCommand('mceTableApplyCellStyle', false, (_a = {}, _a[style] = value, _a)); - } - }]; - }; - var changeRowHeader = function (editor) { - return function () { - var currentType = editor.queryCommandValue('mceTableRowType'); - var newType = currentType === 'header' ? 'body' : 'header'; - editor.execCommand('mceTableRowType', false, { type: newType }); - }; - }; - var changeColumnHeader = function (editor) { - return function () { - var currentType = editor.queryCommandValue('mceTableColType'); - var newType = currentType === 'th' ? 'td' : 'th'; - editor.execCommand('mceTableColType', false, { type: newType }); - }; - }; - - var getClassList$1 = function (editor) { - var classes = buildListItems(getCellClassList(editor)); - if (classes.length > 0) { - return Optional.some({ - name: 'class', - type: 'listbox', - label: 'Class', - items: classes - }); - } - return Optional.none(); - }; - var children = [ - { - name: 'width', - type: 'input', - label: 'Width' - }, - { - name: 'height', - type: 'input', - label: 'Height' - }, - { - name: 'celltype', - type: 'listbox', - label: 'Cell type', - items: [ - { - text: 'Cell', - value: 'td' - }, - { - text: 'Header cell', - value: 'th' - } - ] - }, - { - name: 'scope', - type: 'listbox', - label: 'Scope', - items: [ - { - text: 'None', - value: '' - }, - { - text: 'Row', - value: 'row' - }, - { - text: 'Column', - value: 'col' - }, - { - text: 'Row group', - value: 'rowgroup' - }, - { - text: 'Column group', - value: 'colgroup' - } - ] - }, - { - name: 'halign', - type: 'listbox', - label: 'Horizontal align', - items: [ - { - text: 'None', - value: '' - }, - { - text: 'Left', - value: 'left' - }, - { - text: 'Center', - value: 'center' - }, - { - text: 'Right', - value: 'right' - } - ] - }, - { - name: 'valign', - type: 'listbox', - label: 'Vertical align', - items: verticalAlignValues - } - ]; - var getItems$2 = function (editor) { - return children.concat(getClassList$1(editor).toArray()); - }; - - var getAdvancedTab = function (editor, dialogName) { - var emptyBorderStyle = [{ - text: 'Select...', - value: '' - }]; - var advTabItems = [ - { - name: 'borderstyle', - type: 'listbox', - label: 'Border style', - items: emptyBorderStyle.concat(buildListItems(getTableBorderStyles(editor))) - }, - { - name: 'bordercolor', - type: 'colorinput', - label: 'Border color' - }, - { - name: 'backgroundcolor', - type: 'colorinput', - label: 'Background color' - } - ]; - var borderWidth = { - name: 'borderwidth', - type: 'input', - label: 'Border width' - }; - var items = dialogName === 'cell' ? [borderWidth].concat(advTabItems) : advTabItems; - return { - title: 'Advanced', - name: 'advanced', - items: items - }; - }; - - var modifiers = function (testTruthy) { - return function (editor, node) { - var dom = editor.dom; - var setAttrib = function (attr, value) { - if (!testTruthy || value) { - dom.setAttrib(node, attr, value); - } - }; - var setStyle = function (prop, value) { - if (!testTruthy || value) { - dom.setStyle(node, prop, value); - } - }; - var setFormat = function (formatName, value) { - if (!testTruthy || value) { - if (value === '') { - editor.formatter.remove(formatName, { value: null }, node, true); - } else { - editor.formatter.apply(formatName, { value: value }, node); - } - } - }; - return { - setAttrib: setAttrib, - setStyle: setStyle, - setFormat: setFormat - }; - }; - }; - var DomModifier = { - normal: modifiers(false), - ifTruthy: modifiers(true) - }; - - var rgbToHex = function (dom) { - return function (value) { - return startsWith(value, 'rgb') ? dom.toHex(value) : value; - }; - }; - var extractAdvancedStyles = function (dom, elm) { - var element = SugarElement.fromDom(elm); - return { - borderwidth: getRaw$2(element, 'border-width').getOr(''), - borderstyle: getRaw$2(element, 'border-style').getOr(''), - bordercolor: getRaw$2(element, 'border-color').map(rgbToHex(dom)).getOr(''), - backgroundcolor: getRaw$2(element, 'background-color').map(rgbToHex(dom)).getOr('') - }; - }; - var getSharedValues = function (data) { - var baseData = data[0]; - var comparisonData = data.slice(1); - each$2(comparisonData, function (items) { - each$2(keys(baseData), function (key) { - each$1(items, function (itemValue, itemKey) { - var comparisonValue = baseData[key]; - if (comparisonValue !== '' && key === itemKey) { - if (comparisonValue !== itemValue) { - baseData[key] = ''; - } - } - }); - }); - }); - return baseData; - }; - var getAlignment = function (formats, formatName, editor, elm) { - return find$1(formats, function (name) { - return !isUndefined(editor.formatter.matchNode(elm, formatName + name)); - }).getOr(''); - }; - var getHAlignment = curry(getAlignment, [ - 'left', - 'center', - 'right' - ], 'align'); - var getVAlignment = curry(getAlignment, [ - 'top', - 'middle', - 'bottom' - ], 'valign'); - var extractDataFromSettings = function (editor, hasAdvTableTab) { - var style = getDefaultStyles(editor); - var attrs = getDefaultAttributes(editor); - var extractAdvancedStyleData = function (dom) { - return { - borderstyle: get$c(style, 'border-style').getOr(''), - bordercolor: rgbToHex(dom)(get$c(style, 'border-color').getOr('')), - backgroundcolor: rgbToHex(dom)(get$c(style, 'background-color').getOr('')) - }; - }; - var defaultData = { - height: '', - width: '100%', - cellspacing: '', - cellpadding: '', - caption: false, - class: '', - align: '', - border: '' - }; - var getBorder = function () { - var borderWidth = style['border-width']; - if (shouldStyleWithCss(editor) && borderWidth) { - return { border: borderWidth }; - } - return get$c(attrs, 'border').fold(function () { - return {}; - }, function (border) { - return { border: border }; - }); - }; - var advStyle = hasAdvTableTab ? extractAdvancedStyleData(editor.dom) : {}; - var getCellPaddingCellSpacing = function () { - var spacing = get$c(style, 'border-spacing').or(get$c(attrs, 'cellspacing')).fold(function () { - return {}; - }, function (cellspacing) { - return { cellspacing: cellspacing }; - }); - var padding = get$c(style, 'border-padding').or(get$c(attrs, 'cellpadding')).fold(function () { - return {}; - }, function (cellpadding) { - return { cellpadding: cellpadding }; - }); - return __assign(__assign({}, spacing), padding); - }; - var data = __assign(__assign(__assign(__assign(__assign(__assign({}, defaultData), style), attrs), advStyle), getBorder()), getCellPaddingCellSpacing()); - return data; - }; - var getRowType = function (elm) { - return table(SugarElement.fromDom(elm)).map(function (table) { - var target = { selection: fromDom(elm.cells) }; - return getRowsType(table, target); - }).getOr(''); - }; - var extractDataFromTableElement = function (editor, elm, hasAdvTableTab) { - var getBorder = function (dom, elm) { - var optBorderWidth = getRaw$2(SugarElement.fromDom(elm), 'border-width'); - if (shouldStyleWithCss(editor) && optBorderWidth.isSome()) { - return optBorderWidth.getOr(''); - } - return dom.getAttrib(elm, 'border') || getTDTHOverallStyle(editor.dom, elm, 'border-width') || getTDTHOverallStyle(editor.dom, elm, 'border'); - }; - var dom = editor.dom; - var cellspacing = shouldStyleWithCss(editor) ? dom.getStyle(elm, 'border-spacing') || dom.getAttrib(elm, 'cellspacing') : dom.getAttrib(elm, 'cellspacing') || dom.getStyle(elm, 'border-spacing'); - var cellpadding = shouldStyleWithCss(editor) ? getTDTHOverallStyle(dom, elm, 'padding') || dom.getAttrib(elm, 'cellpadding') : dom.getAttrib(elm, 'cellpadding') || getTDTHOverallStyle(dom, elm, 'padding'); - return __assign({ - width: dom.getStyle(elm, 'width') || dom.getAttrib(elm, 'width'), - height: dom.getStyle(elm, 'height') || dom.getAttrib(elm, 'height'), - cellspacing: cellspacing, - cellpadding: cellpadding, - border: getBorder(dom, elm), - caption: !!dom.select('caption', elm)[0], - class: dom.getAttrib(elm, 'class', ''), - align: getHAlignment(editor, elm) - }, hasAdvTableTab ? extractAdvancedStyles(dom, elm) : {}); - }; - var extractDataFromRowElement = function (editor, elm, hasAdvancedRowTab) { - var dom = editor.dom; - return __assign({ - height: dom.getStyle(elm, 'height') || dom.getAttrib(elm, 'height'), - class: dom.getAttrib(elm, 'class', ''), - type: getRowType(elm), - align: getHAlignment(editor, elm) - }, hasAdvancedRowTab ? extractAdvancedStyles(dom, elm) : {}); - }; - var extractDataFromCellElement = function (editor, cell, hasAdvancedCellTab, column) { - var dom = editor.dom; - var colElm = column.getOr(cell); - var getStyle = function (element, style) { - return dom.getStyle(element, style) || dom.getAttrib(element, style); - }; - return __assign({ - width: getStyle(colElm, 'width'), - height: getStyle(cell, 'height'), - scope: dom.getAttrib(cell, 'scope'), - celltype: getNodeName(cell), - class: dom.getAttrib(cell, 'class', ''), - halign: getHAlignment(editor, cell), - valign: getVAlignment(editor, cell) - }, hasAdvancedCellTab ? extractAdvancedStyles(dom, cell) : {}); - }; - - var getSelectedCells = function (table, cells) { - var warehouse = Warehouse.fromTable(table); - var allCells = Warehouse.justCells(warehouse); - var filtered = filter$2(allCells, function (cellA) { - return exists(cells, function (cellB) { - return eq$1(cellA.element, cellB); - }); - }); - return map$1(filtered, function (cell) { - return { - element: cell.element.dom, - column: Warehouse.getColumnAt(warehouse, cell.column).map(function (col) { - return col.element.dom; - }) - }; - }); - }; - var updateSimpleProps$1 = function (modifier, colModifier, data) { - modifier.setAttrib('scope', data.scope); - modifier.setAttrib('class', data.class); - modifier.setStyle('height', addPxSuffix(data.height)); - colModifier.setStyle('width', addPxSuffix(data.width)); - }; - var updateAdvancedProps$1 = function (modifier, data) { - modifier.setFormat('tablecellbackgroundcolor', data.backgroundcolor); - modifier.setFormat('tablecellbordercolor', data.bordercolor); - modifier.setFormat('tablecellborderstyle', data.borderstyle); - modifier.setFormat('tablecellborderwidth', addPxSuffix(data.borderwidth)); - }; - var applyStyleData$1 = function (editor, cells, data) { - var isSingleCell = cells.length === 1; - each$2(cells, function (item) { - var cellElm = item.element; - var modifier = isSingleCell ? DomModifier.normal(editor, cellElm) : DomModifier.ifTruthy(editor, cellElm); - var colModifier = item.column.map(function (col) { - return isSingleCell ? DomModifier.normal(editor, col) : DomModifier.ifTruthy(editor, col); - }).getOr(modifier); - updateSimpleProps$1(modifier, colModifier, data); - if (hasAdvancedCellTab(editor)) { - updateAdvancedProps$1(modifier, data); - } - if (isSingleCell) { - unApplyAlign(editor, cellElm); - unApplyVAlign(editor, cellElm); - } - if (data.halign) { - applyAlign(editor, cellElm, data.halign); - } - if (data.valign) { - applyVAlign(editor, cellElm, data.valign); - } - }); - }; - var applyStructureData$1 = function (editor, data) { - editor.execCommand('mceTableCellType', false, { - type: data.celltype, - no_events: true - }); - }; - var applyCellData = function (editor, cells, oldData, data) { - var modifiedData = filter$1(data, function (value, key) { - return oldData[key] !== value; - }); - if (size(modifiedData) > 0 && cells.length >= 1) { - table(cells[0]).each(function (table) { - var selectedCells = getSelectedCells(table, cells); - var styleModified = size(filter$1(modifiedData, function (_value, key) { - return key !== 'scope' && key !== 'celltype'; - })) > 0; - var structureModified = has$1(modifiedData, 'celltype'); - if (styleModified || has$1(modifiedData, 'scope')) { - applyStyleData$1(editor, selectedCells, data); - } - if (structureModified) { - applyStructureData$1(editor, data); - } - fireTableModified(editor, table.dom, { - structure: structureModified, - style: styleModified - }); - }); - } - }; - var onSubmitCellForm = function (editor, cells, oldData, api) { - var data = api.getData(); - api.close(); - editor.undoManager.transact(function () { - applyCellData(editor, cells, oldData, data); - editor.focus(); - }); - }; - var getData = function (editor, cells) { - var cellsData = table(cells[0]).map(function (table) { - return map$1(getSelectedCells(table, cells), function (item) { - return extractDataFromCellElement(editor, item.element, hasAdvancedCellTab(editor), item.column); - }); - }); - return getSharedValues(cellsData.getOrDie()); - }; - var open$2 = function (editor, selections) { - var cells = getCellsFromSelection(selections); - if (cells.length === 0) { - return; - } - var data = getData(editor, cells); - var dialogTabPanel = { - type: 'tabpanel', - tabs: [ - { - title: 'General', - name: 'general', - items: getItems$2(editor) - }, - getAdvancedTab(editor, 'cell') - ] - }; - var dialogPanel = { - type: 'panel', - items: [{ - type: 'grid', - columns: 2, - items: getItems$2(editor) - }] - }; - editor.windowManager.open({ - title: 'Cell Properties', - size: 'normal', - body: hasAdvancedCellTab(editor) ? dialogTabPanel : dialogPanel, - buttons: [ - { - type: 'cancel', - name: 'cancel', - text: 'Cancel' - }, - { - type: 'submit', - name: 'save', - text: 'Save', - primary: true - } - ], - initialData: data, - onSubmit: curry(onSubmitCellForm, editor, cells, data) - }); - }; - - var getClassList = function (editor) { - var classes = buildListItems(getRowClassList(editor)); - if (classes.length > 0) { - return Optional.some({ - name: 'class', - type: 'listbox', - label: 'Class', - items: classes - }); - } - return Optional.none(); - }; - var formChildren = [ - { - type: 'listbox', - name: 'type', - label: 'Row type', - items: [ - { - text: 'Header', - value: 'header' - }, - { - text: 'Body', - value: 'body' - }, - { - text: 'Footer', - value: 'footer' - } - ] - }, - { - type: 'listbox', - name: 'align', - label: 'Alignment', - items: [ - { - text: 'None', - value: '' - }, - { - text: 'Left', - value: 'left' - }, - { - text: 'Center', - value: 'center' - }, - { - text: 'Right', - value: 'right' - } - ] - }, - { - label: 'Height', - name: 'height', - type: 'input' - } - ]; - var getItems$1 = function (editor) { - return formChildren.concat(getClassList(editor).toArray()); - }; - - var updateSimpleProps = function (modifier, data) { - modifier.setAttrib('class', data.class); - modifier.setStyle('height', addPxSuffix(data.height)); - }; - var updateAdvancedProps = function (modifier, data) { - modifier.setStyle('background-color', data.backgroundcolor); - modifier.setStyle('border-color', data.bordercolor); - modifier.setStyle('border-style', data.borderstyle); - }; - var applyStyleData = function (editor, rows, data, oldData) { - var isSingleRow = rows.length === 1; - each$2(rows, function (rowElm) { - var modifier = isSingleRow ? DomModifier.normal(editor, rowElm) : DomModifier.ifTruthy(editor, rowElm); - updateSimpleProps(modifier, data); - if (hasAdvancedRowTab(editor)) { - updateAdvancedProps(modifier, data); - } - if (data.align !== oldData.align) { - unApplyAlign(editor, rowElm); - applyAlign(editor, rowElm, data.align); - } - }); - }; - var applyStructureData = function (editor, data) { - editor.execCommand('mceTableRowType', false, { - type: data.type, - no_events: true - }); - }; - var applyRowData = function (editor, rows, oldData, data) { - var modifiedData = filter$1(data, function (value, key) { - return oldData[key] !== value; - }); - if (size(modifiedData) > 0) { - var typeModified_1 = has$1(modifiedData, 'type'); - var styleModified_1 = typeModified_1 ? size(modifiedData) > 1 : true; - if (styleModified_1) { - applyStyleData(editor, rows, data, oldData); - } - if (typeModified_1) { - applyStructureData(editor, data); - } - table(SugarElement.fromDom(rows[0])).each(function (table) { - return fireTableModified(editor, table.dom, { - structure: typeModified_1, - style: styleModified_1 - }); - }); - } - }; - var onSubmitRowForm = function (editor, rows, oldData, api) { - var data = api.getData(); - api.close(); - editor.undoManager.transact(function () { - applyRowData(editor, rows, oldData, data); - editor.focus(); - }); - }; - var open$1 = function (editor) { - var rows = getRowsFromSelection(getSelectionStart(editor), ephemera.selected); - if (rows.length === 0) { - return; - } - var rowsData = map$1(rows, function (rowElm) { - return extractDataFromRowElement(editor, rowElm.dom, hasAdvancedRowTab(editor)); - }); - var data = getSharedValues(rowsData); - var dialogTabPanel = { - type: 'tabpanel', - tabs: [ - { - title: 'General', - name: 'general', - items: getItems$1(editor) - }, - getAdvancedTab(editor, 'row') - ] - }; - var dialogPanel = { - type: 'panel', - items: [{ - type: 'grid', - columns: 2, - items: getItems$1(editor) - }] - }; - editor.windowManager.open({ - title: 'Row Properties', - size: 'normal', - body: hasAdvancedRowTab(editor) ? dialogTabPanel : dialogPanel, - buttons: [ - { - type: 'cancel', - name: 'cancel', - text: 'Cancel' - }, - { - type: 'submit', - name: 'save', - text: 'Save', - primary: true - } - ], - initialData: data, - onSubmit: curry(onSubmitRowForm, editor, map$1(rows, function (r) { - return r.dom; - }), data) - }); - }; - - var getItems = function (editor, classes, insertNewTable) { - var rowColCountItems = !insertNewTable ? [] : [ - { - type: 'input', - name: 'cols', - label: 'Cols', - inputMode: 'numeric' - }, - { - type: 'input', - name: 'rows', - label: 'Rows', - inputMode: 'numeric' - } - ]; - var alwaysItems = [ - { - type: 'input', - name: 'width', - label: 'Width' - }, - { - type: 'input', - name: 'height', - label: 'Height' - } - ]; - var appearanceItems = hasAppearanceOptions(editor) ? [ - { - type: 'input', - name: 'cellspacing', - label: 'Cell spacing', - inputMode: 'numeric' - }, - { - type: 'input', - name: 'cellpadding', - label: 'Cell padding', - inputMode: 'numeric' - }, - { - type: 'input', - name: 'border', - label: 'Border width' - }, - { - type: 'label', - label: 'Caption', - items: [{ - type: 'checkbox', - name: 'caption', - label: 'Show caption' - }] - } - ] : []; - var alignmentItem = [{ - type: 'listbox', - name: 'align', - label: 'Alignment', - items: [ - { - text: 'None', - value: '' - }, - { - text: 'Left', - value: 'left' - }, - { - text: 'Center', - value: 'center' - }, - { - text: 'Right', - value: 'right' - } - ] - }]; - var classListItem = classes.length > 0 ? [{ - type: 'listbox', - name: 'class', - label: 'Class', - items: classes - }] : []; - return rowColCountItems.concat(alwaysItems).concat(appearanceItems).concat(alignmentItem).concat(classListItem); - }; - - var styleTDTH = function (dom, elm, name, value) { - if (elm.tagName === 'TD' || elm.tagName === 'TH') { - if (isString(name)) { - dom.setStyle(elm, name, value); - } else { - dom.setStyle(elm, name); - } - } else { - if (elm.children) { - for (var i = 0; i < elm.children.length; i++) { - styleTDTH(dom, elm.children[i], name, value); - } - } - } - }; - var applyDataToElement = function (editor, tableElm, data) { - var dom = editor.dom; - var attrs = {}; - var styles = {}; - attrs.class = data.class; - styles.height = addPxSuffix(data.height); - if (dom.getAttrib(tableElm, 'width') && !shouldStyleWithCss(editor)) { - attrs.width = removePxSuffix(data.width); - } else { - styles.width = addPxSuffix(data.width); - } - if (shouldStyleWithCss(editor)) { - styles['border-width'] = addPxSuffix(data.border); - styles['border-spacing'] = addPxSuffix(data.cellspacing); - } else { - attrs.border = data.border; - attrs.cellpadding = data.cellpadding; - attrs.cellspacing = data.cellspacing; - } - if (shouldStyleWithCss(editor) && tableElm.children) { - for (var i = 0; i < tableElm.children.length; i++) { - styleTDTH(dom, tableElm.children[i], { - 'border-width': addPxSuffix(data.border), - 'padding': addPxSuffix(data.cellpadding) - }); - if (hasAdvancedTableTab(editor)) { - styleTDTH(dom, tableElm.children[i], { 'border-color': data.bordercolor }); - } - } - } - if (hasAdvancedTableTab(editor)) { - styles['background-color'] = data.backgroundcolor; - styles['border-color'] = data.bordercolor; - styles['border-style'] = data.borderstyle; - } - attrs.style = dom.serializeStyle(__assign(__assign({}, getDefaultStyles(editor)), styles)); - dom.setAttribs(tableElm, __assign(__assign({}, getDefaultAttributes(editor)), attrs)); - }; - var onSubmitTableForm = function (editor, tableElm, oldData, api) { - var dom = editor.dom; - var data = api.getData(); - var modifiedData = filter$1(data, function (value, key) { - return oldData[key] !== value; - }); - api.close(); - if (data.class === '') { - delete data.class; - } - editor.undoManager.transact(function () { - if (!tableElm) { - var cols = parseInt(data.cols, 10) || 1; - var rows = parseInt(data.rows, 10) || 1; - tableElm = insert(editor, cols, rows, 0, 0); - } - if (size(modifiedData) > 0) { - applyDataToElement(editor, tableElm, data); - var captionElm = dom.select('caption', tableElm)[0]; - if (captionElm && !data.caption || !captionElm && data.caption) { - editor.execCommand('mceTableToggleCaption'); - } - if (data.align === '') { - unApplyAlign(editor, tableElm); - } else { - applyAlign(editor, tableElm, data.align); - } - } - editor.focus(); - editor.addVisual(); - if (size(modifiedData) > 0) { - var captionModified = has$1(modifiedData, 'caption'); - var styleModified = captionModified ? size(modifiedData) > 1 : true; - fireTableModified(editor, tableElm, { - structure: captionModified, - style: styleModified - }); - } - }); - }; - var open = function (editor, insertNewTable) { - var dom = editor.dom; - var tableElm; - var data = extractDataFromSettings(editor, hasAdvancedTableTab(editor)); - if (insertNewTable === false) { - tableElm = dom.getParent(editor.selection.getStart(), 'table', editor.getBody()); - if (tableElm) { - data = extractDataFromTableElement(editor, tableElm, hasAdvancedTableTab(editor)); - } else { - if (hasAdvancedTableTab(editor)) { - data.borderstyle = ''; - data.bordercolor = ''; - data.backgroundcolor = ''; - } - } - } else { - data.cols = '1'; - data.rows = '1'; - if (hasAdvancedTableTab(editor)) { - data.borderstyle = ''; - data.bordercolor = ''; - data.backgroundcolor = ''; - } - } - var classes = buildListItems(getTableClassList(editor)); - if (classes.length > 0) { - if (data.class) { - data.class = data.class.replace(/\s*mce\-item\-table\s*/g, ''); - } - } - var generalPanel = { - type: 'grid', - columns: 2, - items: getItems(editor, classes, insertNewTable) - }; - var nonAdvancedForm = function () { - return { - type: 'panel', - items: [generalPanel] - }; - }; - var advancedForm = function () { - return { - type: 'tabpanel', - tabs: [ - { - title: 'General', - name: 'general', - items: [generalPanel] - }, - getAdvancedTab(editor, 'table') - ] - }; - }; - var dialogBody = hasAdvancedTableTab(editor) ? advancedForm() : nonAdvancedForm(); - editor.windowManager.open({ - title: 'Table Properties', - size: 'normal', - body: dialogBody, - onSubmit: curry(onSubmitTableForm, editor, tableElm, data), - buttons: [ - { - type: 'cancel', - name: 'cancel', - text: 'Cancel' - }, - { - type: 'submit', - name: 'save', - text: 'Save', - primary: true - } - ], - initialData: data - }); - }; - - var getSelectionStartCellOrCaption = function (editor) { - return getSelectionCellOrCaption(getSelectionStart(editor), getIsRoot(editor)); - }; - var getSelectionStartCell = function (editor) { - return getSelectionCell(getSelectionStart(editor), getIsRoot(editor)); - }; - var registerCommands = function (editor, actions, cellSelection, selections, clipboard) { - var isRoot = getIsRoot(editor); - var eraseTable = function () { - return getSelectionStartCellOrCaption(editor).each(function (cellOrCaption) { - table(cellOrCaption, isRoot).filter(not(isRoot)).each(function (table) { - var cursor = SugarElement.fromText(''); - after$5(table, cursor); - remove$5(table); - if (editor.dom.isEmpty(editor.getBody())) { - editor.setContent(''); - editor.selection.setCursorLocation(); - } else { - var rng = editor.dom.createRng(); - rng.setStart(cursor.dom, 0); - rng.setEnd(cursor.dom, 0); - editor.selection.setRng(rng); - editor.nodeChanged(); - } - }); - }); - }; - var setSizingMode = function (sizing) { - return getSelectionStartCellOrCaption(editor).each(function (cellOrCaption) { - var isForcedSizing = isResponsiveForced(editor) || isPixelsForced(editor) || isPercentagesForced(editor); - if (!isForcedSizing) { - table(cellOrCaption, isRoot).each(function (table) { - if (sizing === 'relative' && !isPercentSizing(table)) { - enforcePercentage(table); - } else if (sizing === 'fixed' && !isPixelSizing(table)) { - enforcePixels(table); - } else if (sizing === 'responsive' && !isNoneSizing(table)) { - enforceNone(table); - } - removeDataStyle(table); - fireTableModified(editor, table.dom, structureModified); - }); - } - }); - }; - var getTableFromCell = function (cell) { - return table(cell, isRoot); - }; - var performActionOnSelection = function (action) { - return getSelectionStartCell(editor).bind(function (cell) { - return getTableFromCell(cell).map(function (table) { - return action(table, cell); - }); - }); - }; - var toggleTableClass = function (_ui, clazz) { - performActionOnSelection(function (table) { - editor.formatter.toggle('tableclass', { value: clazz }, table.dom); - fireTableModified(editor, table.dom, styleModified); - }); - }; - var toggleTableCellClass = function (_ui, clazz) { - performActionOnSelection(function (table) { - var selectedCells = getCellsFromSelection(selections); - var allHaveClass = forall(selectedCells, function (cell) { - return editor.formatter.match('tablecellclass', { value: clazz }, cell.dom); - }); - var formatterAction = allHaveClass ? editor.formatter.remove : editor.formatter.apply; - each$2(selectedCells, function (cell) { - return formatterAction('tablecellclass', { value: clazz }, cell.dom); - }); - fireTableModified(editor, table.dom, styleModified); - }); - }; - var toggleCaption = function () { - getSelectionStartCellOrCaption(editor).each(function (cellOrCaption) { - table(cellOrCaption, isRoot).each(function (table) { - child$1(table, 'caption').fold(function () { - var caption = SugarElement.fromTag('caption'); - append$1(caption, SugarElement.fromText('Caption')); - appendAt(table, caption, 0); - editor.selection.setCursorLocation(caption.dom, 0); - }, function (caption) { - if (isTag('caption')(cellOrCaption)) { - one('td', table).each(function (td) { - return editor.selection.setCursorLocation(td.dom, 0); - }); - } - remove$5(caption); - }); - fireTableModified(editor, table.dom, structureModified); - }); - }); - }; - var postExecute = function (_data) { - editor.focus(); - }; - var actOnSelection = function (execute, noEvents) { - if (noEvents === void 0) { - noEvents = false; - } - return performActionOnSelection(function (table, startCell) { - var targets = forMenu(selections, table, startCell); - execute(table, targets, noEvents).each(postExecute); - }); - }; - var copyRowSelection = function () { - return performActionOnSelection(function (table, startCell) { - var targets = forMenu(selections, table, startCell); - var generators = cellOperations(noop, SugarElement.fromDom(editor.getDoc()), Optional.none()); - return copyRows(table, targets, generators); - }); - }; - var copyColSelection = function () { - return performActionOnSelection(function (table, startCell) { - var targets = forMenu(selections, table, startCell); - return copyCols(table, targets); - }); - }; - var pasteOnSelection = function (execute, getRows) { - return getRows().each(function (rows) { - var clonedRows = map$1(rows, function (row) { - return deep(row); - }); - performActionOnSelection(function (table, startCell) { - var generators = paste$1(SugarElement.fromDom(editor.getDoc())); - var targets = pasteRows(selections, startCell, clonedRows, generators); - execute(table, targets).each(postExecute); - }); - }); - }; - var actOnType = function (getAction) { - return function (_ui, args) { - return get$c(args, 'type').each(function (type) { - actOnSelection(getAction(type), args.no_events); - }); - }; - }; - each$1({ - mceTableSplitCells: function () { - return actOnSelection(actions.unmergeCells); - }, - mceTableMergeCells: function () { - return actOnSelection(actions.mergeCells); - }, - mceTableInsertRowBefore: function () { - return actOnSelection(actions.insertRowsBefore); - }, - mceTableInsertRowAfter: function () { - return actOnSelection(actions.insertRowsAfter); - }, - mceTableInsertColBefore: function () { - return actOnSelection(actions.insertColumnsBefore); - }, - mceTableInsertColAfter: function () { - return actOnSelection(actions.insertColumnsAfter); - }, - mceTableDeleteCol: function () { - return actOnSelection(actions.deleteColumn); - }, - mceTableDeleteRow: function () { - return actOnSelection(actions.deleteRow); - }, - mceTableCutCol: function () { - return copyColSelection().each(function (selection) { - clipboard.setColumns(selection); - actOnSelection(actions.deleteColumn); - }); - }, - mceTableCutRow: function () { - return copyRowSelection().each(function (selection) { - clipboard.setRows(selection); - actOnSelection(actions.deleteRow); - }); - }, - mceTableCopyCol: function () { - return copyColSelection().each(function (selection) { - return clipboard.setColumns(selection); - }); - }, - mceTableCopyRow: function () { - return copyRowSelection().each(function (selection) { - return clipboard.setRows(selection); - }); - }, - mceTablePasteColBefore: function () { - return pasteOnSelection(actions.pasteColsBefore, clipboard.getColumns); - }, - mceTablePasteColAfter: function () { - return pasteOnSelection(actions.pasteColsAfter, clipboard.getColumns); - }, - mceTablePasteRowBefore: function () { - return pasteOnSelection(actions.pasteRowsBefore, clipboard.getRows); - }, - mceTablePasteRowAfter: function () { - return pasteOnSelection(actions.pasteRowsAfter, clipboard.getRows); - }, - mceTableDelete: eraseTable, - mceTableCellToggleClass: toggleTableCellClass, - mceTableToggleClass: toggleTableClass, - mceTableToggleCaption: toggleCaption, - mceTableSizingMode: function (_ui, sizing) { - return setSizingMode(sizing); - }, - mceTableCellType: actOnType(function (type) { - return type === 'th' ? actions.makeCellsHeader : actions.unmakeCellsHeader; - }), - mceTableColType: actOnType(function (type) { - return type === 'th' ? actions.makeColumnsHeader : actions.unmakeColumnsHeader; - }), - mceTableRowType: actOnType(function (type) { - switch (type) { - case 'header': - return actions.makeRowsHeader; - case 'footer': - return actions.makeRowsFooter; - default: - return actions.makeRowsBody; - } - }) - }, function (func, name) { - return editor.addCommand(name, func); - }); - each$1({ - mceTableProps: curry(open, editor, false), - mceTableRowProps: curry(open$1, editor), - mceTableCellProps: curry(open$2, editor, selections) - }, function (func, name) { - return editor.addCommand(name, function () { - return func(); - }); - }); - editor.addCommand('mceInsertTable', function (_ui, args) { - if (isObject(args) && keys(args).length > 0) { - insertTableWithDataValidation(editor, args.rows, args.columns, args.options, 'Invalid values for mceInsertTable - rows and columns values are required to insert a table.'); - } else { - open(editor, true); - } - }); - editor.addCommand('mceTableApplyCellStyle', function (_ui, args) { - var getFormatName = function (style) { - return 'tablecell' + style.toLowerCase().replace('-', ''); - }; - if (!isObject(args)) { - return; - } - var cells = getCellsFromSelection(selections); - if (cells.length === 0) { - return; - } - var validArgs = filter$1(args, function (value, style) { - return editor.formatter.has(getFormatName(style)) && isString(value); - }); - if (isEmpty(validArgs)) { - return; - } - each$1(validArgs, function (value, style) { - each$2(cells, function (cell) { - DomModifier.normal(editor, cell.dom).setFormat(getFormatName(style), value); - }); - }); - getTableFromCell(cells[0]).each(function (table) { - return fireTableModified(editor, table.dom, styleModified); - }); - }); - }; - - var registerQueryCommands = function (editor, actions, selections) { - var isRoot = getIsRoot(editor); - var lookupOnSelection = function (action) { - return getSelectionCell(getSelectionStart(editor)).bind(function (cell) { - return table(cell, isRoot).map(function (table) { - var targets = forMenu(selections, table, cell); - return action(table, targets); - }); - }).getOr(''); - }; - each$1({ - mceTableRowType: function () { - return lookupOnSelection(actions.getTableRowType); - }, - mceTableCellType: function () { - return lookupOnSelection(actions.getTableCellType); - }, - mceTableColType: function () { - return lookupOnSelection(actions.getTableColType); - } - }, function (func, name) { - return editor.addQueryValueHandler(name, func); - }); - }; - - var Clipboard = function () { - var rows = value(); - var cols = value(); - return { - getRows: rows.get, - setRows: function (r) { - r.fold(rows.clear, rows.set); - cols.clear(); - }, - clearRows: rows.clear, - getColumns: cols.get, - setColumns: function (c) { - c.fold(cols.clear, cols.set); - rows.clear(); - }, - clearColumns: cols.clear - }; - }; - - var genericBase = { - remove_similar: true, - inherit: false - }; - var cellBase = __assign({ selector: 'td,th' }, genericBase); - var cellFormats = { - tablecellbackgroundcolor: __assign({ styles: { backgroundColor: '%value' } }, cellBase), - tablecellverticalalign: __assign({ styles: { 'vertical-align': '%value' } }, cellBase), - tablecellbordercolor: __assign({ styles: { borderColor: '%value' } }, cellBase), - tablecellclass: __assign({ classes: ['%value'] }, cellBase), - tableclass: __assign({ - selector: 'table', - classes: ['%value'] - }, genericBase), - tablecellborderstyle: __assign({ styles: { borderStyle: '%value' } }, cellBase), - tablecellborderwidth: __assign({ styles: { borderWidth: '%value' } }, cellBase) - }; - var registerFormats = function (editor) { - editor.formatter.register(cellFormats); - }; - - var adt$5 = Adt.generate([ - { none: ['current'] }, - { first: ['current'] }, - { - middle: [ - 'current', - 'target' - ] - }, - { last: ['current'] } - ]); - var none = function (current) { - if (current === void 0) { - current = undefined; - } - return adt$5.none(current); - }; - var CellLocation = __assign(__assign({}, adt$5), { none: none }); - - var walk = function (all, current, index, direction, isEligible) { - if (isEligible === void 0) { - isEligible = always; - } - var forwards = direction === 1; - if (!forwards && index <= 0) { - return CellLocation.first(all[0]); - } else if (forwards && index >= all.length - 1) { - return CellLocation.last(all[all.length - 1]); - } else { - var newIndex = index + direction; - var elem = all[newIndex]; - return isEligible(elem) ? CellLocation.middle(current, elem) : walk(all, current, newIndex, direction, isEligible); - } - }; - var detect$1 = function (current, isRoot) { - return table(current, isRoot).bind(function (table) { - var all = cells$1(table); - var index = findIndex(all, function (x) { - return eq$1(current, x); - }); - return index.map(function (index) { - return { - index: index, - all: all - }; - }); - }); - }; - var next = function (current, isEligible, isRoot) { - var detection = detect$1(current, isRoot); - return detection.fold(function () { - return CellLocation.none(current); - }, function (info) { - return walk(info.all, current, info.index, 1, isEligible); - }); - }; - var prev = function (current, isEligible, isRoot) { - var detection = detect$1(current, isRoot); - return detection.fold(function () { - return CellLocation.none(); - }, function (info) { - return walk(info.all, current, info.index, -1, isEligible); - }); - }; - - var create$2 = function (start, soffset, finish, foffset) { - return { - start: start, - soffset: soffset, - finish: finish, - foffset: foffset - }; - }; - var SimRange = { create: create$2 }; - - var adt$4 = Adt.generate([ - { before: ['element'] }, - { - on: [ - 'element', - 'offset' - ] - }, - { after: ['element'] } - ]); - var cata$1 = function (subject, onBefore, onOn, onAfter) { - return subject.fold(onBefore, onOn, onAfter); - }; - var getStart$1 = function (situ) { - return situ.fold(identity, identity, identity); - }; - var before$2 = adt$4.before; - var on = adt$4.on; - var after$3 = adt$4.after; - var Situ = { - before: before$2, - on: on, - after: after$3, - cata: cata$1, - getStart: getStart$1 - }; - - var adt$3 = Adt.generate([ - { domRange: ['rng'] }, - { - relative: [ - 'startSitu', - 'finishSitu' - ] - }, - { - exact: [ - 'start', - 'soffset', - 'finish', - 'foffset' - ] - } - ]); - var exactFromRange = function (simRange) { - return adt$3.exact(simRange.start, simRange.soffset, simRange.finish, simRange.foffset); - }; - var getStart = function (selection) { - return selection.match({ - domRange: function (rng) { - return SugarElement.fromDom(rng.startContainer); - }, - relative: function (startSitu, _finishSitu) { - return Situ.getStart(startSitu); - }, - exact: function (start, _soffset, _finish, _foffset) { - return start; - } - }); - }; - var domRange = adt$3.domRange; - var relative = adt$3.relative; - var exact = adt$3.exact; - var getWin = function (selection) { - var start = getStart(selection); - return defaultView(start); - }; - var range = SimRange.create; - var SimSelection = { - domRange: domRange, - relative: relative, - exact: exact, - exactFromRange: exactFromRange, - getWin: getWin, - range: range - }; - - var selectNode = function (win, element) { - var rng = win.document.createRange(); - rng.selectNode(element.dom); - return rng; - }; - var selectNodeContents = function (win, element) { - var rng = win.document.createRange(); - selectNodeContentsUsing(rng, element); - return rng; - }; - var selectNodeContentsUsing = function (rng, element) { - return rng.selectNodeContents(element.dom); - }; - var setStart = function (rng, situ) { - situ.fold(function (e) { - rng.setStartBefore(e.dom); - }, function (e, o) { - rng.setStart(e.dom, o); - }, function (e) { - rng.setStartAfter(e.dom); - }); - }; - var setFinish = function (rng, situ) { - situ.fold(function (e) { - rng.setEndBefore(e.dom); - }, function (e, o) { - rng.setEnd(e.dom, o); - }, function (e) { - rng.setEndAfter(e.dom); - }); - }; - var relativeToNative = function (win, startSitu, finishSitu) { - var range = win.document.createRange(); - setStart(range, startSitu); - setFinish(range, finishSitu); - return range; - }; - var exactToNative = function (win, start, soffset, finish, foffset) { - var rng = win.document.createRange(); - rng.setStart(start.dom, soffset); - rng.setEnd(finish.dom, foffset); - return rng; - }; - var toRect = function (rect) { - return { - left: rect.left, - top: rect.top, - right: rect.right, - bottom: rect.bottom, - width: rect.width, - height: rect.height - }; - }; - var getFirstRect$1 = function (rng) { - var rects = rng.getClientRects(); - var rect = rects.length > 0 ? rects[0] : rng.getBoundingClientRect(); - return rect.width > 0 || rect.height > 0 ? Optional.some(rect).map(toRect) : Optional.none(); - }; - - var adt$2 = Adt.generate([ - { - ltr: [ - 'start', - 'soffset', - 'finish', - 'foffset' - ] - }, - { - rtl: [ - 'start', - 'soffset', - 'finish', - 'foffset' - ] - } - ]); - var fromRange = function (win, type, range) { - return type(SugarElement.fromDom(range.startContainer), range.startOffset, SugarElement.fromDom(range.endContainer), range.endOffset); - }; - var getRanges = function (win, selection) { - return selection.match({ - domRange: function (rng) { - return { - ltr: constant(rng), - rtl: Optional.none - }; - }, - relative: function (startSitu, finishSitu) { - return { - ltr: cached(function () { - return relativeToNative(win, startSitu, finishSitu); - }), - rtl: cached(function () { - return Optional.some(relativeToNative(win, finishSitu, startSitu)); - }) - }; - }, - exact: function (start, soffset, finish, foffset) { - return { - ltr: cached(function () { - return exactToNative(win, start, soffset, finish, foffset); - }), - rtl: cached(function () { - return Optional.some(exactToNative(win, finish, foffset, start, soffset)); - }) - }; - } - }); - }; - var doDiagnose = function (win, ranges) { - var rng = ranges.ltr(); - if (rng.collapsed) { - var reversed = ranges.rtl().filter(function (rev) { - return rev.collapsed === false; - }); - return reversed.map(function (rev) { - return adt$2.rtl(SugarElement.fromDom(rev.endContainer), rev.endOffset, SugarElement.fromDom(rev.startContainer), rev.startOffset); - }).getOrThunk(function () { - return fromRange(win, adt$2.ltr, rng); - }); - } else { - return fromRange(win, adt$2.ltr, rng); - } - }; - var diagnose = function (win, selection) { - var ranges = getRanges(win, selection); - return doDiagnose(win, ranges); - }; - var asLtrRange = function (win, selection) { - var diagnosis = diagnose(win, selection); - return diagnosis.match({ - ltr: function (start, soffset, finish, foffset) { - var rng = win.document.createRange(); - rng.setStart(start.dom, soffset); - rng.setEnd(finish.dom, foffset); - return rng; - }, - rtl: function (start, soffset, finish, foffset) { - var rng = win.document.createRange(); - rng.setStart(finish.dom, foffset); - rng.setEnd(start.dom, soffset); - return rng; - } - }); - }; - adt$2.ltr; - adt$2.rtl; - - var searchForPoint = function (rectForOffset, x, y, maxX, length) { - if (length === 0) { - return 0; - } else if (x === maxX) { - return length - 1; - } - var xDelta = maxX; - for (var i = 1; i < length; i++) { - var rect = rectForOffset(i); - var curDeltaX = Math.abs(x - rect.left); - if (y <= rect.bottom) { - if (y < rect.top || curDeltaX > xDelta) { - return i - 1; - } else { - xDelta = curDeltaX; - } - } - } - return 0; - }; - var inRect = function (rect, x, y) { - return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom; - }; - - var locateOffset = function (doc, textnode, x, y, rect) { - var rangeForOffset = function (o) { - var r = doc.dom.createRange(); - r.setStart(textnode.dom, o); - r.collapse(true); - return r; - }; - var rectForOffset = function (o) { - var r = rangeForOffset(o); - return r.getBoundingClientRect(); - }; - var length = get$9(textnode).length; - var offset = searchForPoint(rectForOffset, x, y, rect.right, length); - return rangeForOffset(offset); - }; - var locate$1 = function (doc, node, x, y) { - var r = doc.dom.createRange(); - r.selectNode(node.dom); - var rects = r.getClientRects(); - var foundRect = findMap(rects, function (rect) { - return inRect(rect, x, y) ? Optional.some(rect) : Optional.none(); - }); - return foundRect.map(function (rect) { - return locateOffset(doc, node, x, y, rect); - }); - }; - - var searchInChildren = function (doc, node, x, y) { - var r = doc.dom.createRange(); - var nodes = children$3(node); - return findMap(nodes, function (n) { - r.selectNode(n.dom); - return inRect(r.getBoundingClientRect(), x, y) ? locateNode(doc, n, x, y) : Optional.none(); - }); - }; - var locateNode = function (doc, node, x, y) { - return isText(node) ? locate$1(doc, node, x, y) : searchInChildren(doc, node, x, y); - }; - var locate = function (doc, node, x, y) { - var r = doc.dom.createRange(); - r.selectNode(node.dom); - var rect = r.getBoundingClientRect(); - var boundedX = Math.max(rect.left, Math.min(rect.right, x)); - var boundedY = Math.max(rect.top, Math.min(rect.bottom, y)); - return locateNode(doc, node, boundedX, boundedY); - }; - - var COLLAPSE_TO_LEFT = true; - var COLLAPSE_TO_RIGHT = false; - var getCollapseDirection = function (rect, x) { - return x - rect.left < rect.right - x ? COLLAPSE_TO_LEFT : COLLAPSE_TO_RIGHT; - }; - var createCollapsedNode = function (doc, target, collapseDirection) { - var r = doc.dom.createRange(); - r.selectNode(target.dom); - r.collapse(collapseDirection); - return r; - }; - var locateInElement = function (doc, node, x) { - var cursorRange = doc.dom.createRange(); - cursorRange.selectNode(node.dom); - var rect = cursorRange.getBoundingClientRect(); - var collapseDirection = getCollapseDirection(rect, x); - var f = collapseDirection === COLLAPSE_TO_LEFT ? first : last$1; - return f(node).map(function (target) { - return createCollapsedNode(doc, target, collapseDirection); - }); - }; - var locateInEmpty = function (doc, node, x) { - var rect = node.dom.getBoundingClientRect(); - var collapseDirection = getCollapseDirection(rect, x); - return Optional.some(createCollapsedNode(doc, node, collapseDirection)); - }; - var search = function (doc, node, x) { - var f = children$3(node).length === 0 ? locateInEmpty : locateInElement; - return f(doc, node, x); - }; - - var caretPositionFromPoint = function (doc, x, y) { - var _a, _b; - return Optional.from((_b = (_a = doc.dom).caretPositionFromPoint) === null || _b === void 0 ? void 0 : _b.call(_a, x, y)).bind(function (pos) { - if (pos.offsetNode === null) { - return Optional.none(); - } - var r = doc.dom.createRange(); - r.setStart(pos.offsetNode, pos.offset); - r.collapse(); - return Optional.some(r); - }); - }; - var caretRangeFromPoint = function (doc, x, y) { - var _a, _b; - return Optional.from((_b = (_a = doc.dom).caretRangeFromPoint) === null || _b === void 0 ? void 0 : _b.call(_a, x, y)); - }; - var searchTextNodes = function (doc, node, x, y) { - var r = doc.dom.createRange(); - r.selectNode(node.dom); - var rect = r.getBoundingClientRect(); - var boundedX = Math.max(rect.left, Math.min(rect.right, x)); - var boundedY = Math.max(rect.top, Math.min(rect.bottom, y)); - return locate(doc, node, boundedX, boundedY); - }; - var searchFromPoint = function (doc, x, y) { - return SugarElement.fromPoint(doc, x, y).bind(function (elem) { - var fallback = function () { - return search(doc, elem, x); - }; - return children$3(elem).length === 0 ? fallback() : searchTextNodes(doc, elem, x, y).orThunk(fallback); - }); - }; - var availableSearch = function () { - if (document.caretPositionFromPoint) { - return caretPositionFromPoint; - } else if (document.caretRangeFromPoint) { - return caretRangeFromPoint; - } else { - return searchFromPoint; - } - }(); - var fromPoint = function (win, x, y) { - var doc = SugarElement.fromDom(win.document); - return availableSearch(doc, x, y).map(function (rng) { - return SimRange.create(SugarElement.fromDom(rng.startContainer), rng.startOffset, SugarElement.fromDom(rng.endContainer), rng.endOffset); - }); - }; - - var beforeSpecial = function (element, offset) { - var name$1 = name(element); - if ('input' === name$1) { - return Situ.after(element); - } else if (!contains$2([ - 'br', - 'img' - ], name$1)) { - return Situ.on(element, offset); - } else { - return offset === 0 ? Situ.before(element) : Situ.after(element); - } - }; - var preprocessRelative = function (startSitu, finishSitu) { - var start = startSitu.fold(Situ.before, beforeSpecial, Situ.after); - var finish = finishSitu.fold(Situ.before, beforeSpecial, Situ.after); - return SimSelection.relative(start, finish); - }; - var preprocessExact = function (start, soffset, finish, foffset) { - var startSitu = beforeSpecial(start, soffset); - var finishSitu = beforeSpecial(finish, foffset); - return SimSelection.relative(startSitu, finishSitu); - }; - var preprocess = function (selection) { - return selection.match({ - domRange: function (rng) { - var start = SugarElement.fromDom(rng.startContainer); - var finish = SugarElement.fromDom(rng.endContainer); - return preprocessExact(start, rng.startOffset, finish, rng.endOffset); - }, - relative: preprocessRelative, - exact: preprocessExact - }); - }; - - var makeRange = function (start, soffset, finish, foffset) { - var doc = owner(start); - var rng = doc.dom.createRange(); - rng.setStart(start.dom, soffset); - rng.setEnd(finish.dom, foffset); - return rng; - }; - var after$2 = function (start, soffset, finish, foffset) { - var r = makeRange(start, soffset, finish, foffset); - var same = eq$1(start, finish) && soffset === foffset; - return r.collapsed && !same; - }; - - var getNativeSelection = function (win) { - return Optional.from(win.getSelection()); - }; - var doSetNativeRange = function (win, rng) { - getNativeSelection(win).each(function (selection) { - selection.removeAllRanges(); - selection.addRange(rng); - }); - }; - var doSetRange = function (win, start, soffset, finish, foffset) { - var rng = exactToNative(win, start, soffset, finish, foffset); - doSetNativeRange(win, rng); - }; - var setLegacyRtlRange = function (win, selection, start, soffset, finish, foffset) { - selection.collapse(start.dom, soffset); - selection.extend(finish.dom, foffset); - }; - var setRangeFromRelative = function (win, relative) { - return diagnose(win, relative).match({ - ltr: function (start, soffset, finish, foffset) { - doSetRange(win, start, soffset, finish, foffset); - }, - rtl: function (start, soffset, finish, foffset) { - getNativeSelection(win).each(function (selection) { - if (selection.setBaseAndExtent) { - selection.setBaseAndExtent(start.dom, soffset, finish.dom, foffset); - } else if (selection.extend) { - try { - setLegacyRtlRange(win, selection, start, soffset, finish, foffset); - } catch (e) { - doSetRange(win, finish, foffset, start, soffset); - } - } else { - doSetRange(win, finish, foffset, start, soffset); - } - }); - } - }); - }; - var setExact = function (win, start, soffset, finish, foffset) { - var relative = preprocessExact(start, soffset, finish, foffset); - setRangeFromRelative(win, relative); - }; - var setRelative = function (win, startSitu, finishSitu) { - var relative = preprocessRelative(startSitu, finishSitu); - setRangeFromRelative(win, relative); - }; - var toNative = function (selection) { - var win = SimSelection.getWin(selection).dom; - var getDomRange = function (start, soffset, finish, foffset) { - return exactToNative(win, start, soffset, finish, foffset); - }; - var filtered = preprocess(selection); - return diagnose(win, filtered).match({ - ltr: getDomRange, - rtl: getDomRange - }); - }; - var readRange = function (selection) { - if (selection.rangeCount > 0) { - var firstRng = selection.getRangeAt(0); - var lastRng = selection.getRangeAt(selection.rangeCount - 1); - return Optional.some(SimRange.create(SugarElement.fromDom(firstRng.startContainer), firstRng.startOffset, SugarElement.fromDom(lastRng.endContainer), lastRng.endOffset)); - } else { - return Optional.none(); - } - }; - var doGetExact = function (selection) { - if (selection.anchorNode === null || selection.focusNode === null) { - return readRange(selection); - } else { - var anchor = SugarElement.fromDom(selection.anchorNode); - var focus_1 = SugarElement.fromDom(selection.focusNode); - return after$2(anchor, selection.anchorOffset, focus_1, selection.focusOffset) ? Optional.some(SimRange.create(anchor, selection.anchorOffset, focus_1, selection.focusOffset)) : readRange(selection); - } - }; - var setToElement = function (win, element, selectNodeContents$1) { - if (selectNodeContents$1 === void 0) { - selectNodeContents$1 = true; - } - var rngGetter = selectNodeContents$1 ? selectNodeContents : selectNode; - var rng = rngGetter(win, element); - doSetNativeRange(win, rng); - }; - var getExact = function (win) { - return getNativeSelection(win).filter(function (sel) { - return sel.rangeCount > 0; - }).bind(doGetExact); - }; - var get$1 = function (win) { - return getExact(win).map(function (range) { - return SimSelection.exact(range.start, range.soffset, range.finish, range.foffset); - }); - }; - var getFirstRect = function (win, selection) { - var rng = asLtrRange(win, selection); - return getFirstRect$1(rng); - }; - var getAtPoint = function (win, x, y) { - return fromPoint(win, x, y); - }; - var clear = function (win) { - getNativeSelection(win).each(function (selection) { - return selection.removeAllRanges(); - }); - }; - - var global$1 = tinymce.util.Tools.resolve('tinymce.util.VK'); - - var forward = function (editor, isRoot, cell) { - return go$1(editor, isRoot, next(cell, isEditable$1)); - }; - var backward = function (editor, isRoot, cell) { - return go$1(editor, isRoot, prev(cell, isEditable$1)); - }; - var getCellFirstCursorPosition = function (editor, cell) { - var selection = SimSelection.exact(cell, 0, cell, 0); - return toNative(selection); - }; - var go$1 = function (editor, isRoot, cell) { - return cell.fold(Optional.none, Optional.none, function (current, next) { - return first(next).map(function (cell) { - return getCellFirstCursorPosition(editor, cell); - }); - }, function (current) { - editor.execCommand('mceTableInsertRowAfter'); - return forward(editor, isRoot, current); - }); - }; - var rootElements = [ - 'table', - 'li', - 'dl' - ]; - var handle$1 = function (event, editor, cellSelection) { - if (event.keyCode === global$1.TAB) { - var body_1 = getBody(editor); - var isRoot_1 = function (element) { - var name$1 = name(element); - return eq$1(element, body_1) || contains$2(rootElements, name$1); - }; - var rng = editor.selection.getRng(); - var container = SugarElement.fromDom(event.shiftKey ? rng.startContainer : rng.endContainer); - cell(container, isRoot_1).each(function (cell) { - event.preventDefault(); - table(cell, isRoot_1).each(cellSelection.clear); - editor.selection.collapse(event.shiftKey); - var navigation = event.shiftKey ? backward : forward; - var rng = navigation(editor, isRoot_1, cell); - rng.each(function (range) { - editor.selection.setRng(range); - }); - }); - } - }; - - var create$1 = function (selection, kill) { - return { - selection: selection, - kill: kill - }; - }; - var Response = { create: create$1 }; - - var create = function (start, soffset, finish, foffset) { - return { - start: Situ.on(start, soffset), - finish: Situ.on(finish, foffset) - }; - }; - var Situs = { create: create }; - - var convertToRange = function (win, selection) { - var rng = asLtrRange(win, selection); - return SimRange.create(SugarElement.fromDom(rng.startContainer), rng.startOffset, SugarElement.fromDom(rng.endContainer), rng.endOffset); - }; - var makeSitus = Situs.create; - - var sync = function (container, isRoot, start, soffset, finish, foffset, selectRange) { - if (!(eq$1(start, finish) && soffset === foffset)) { - return closest$1(start, 'td,th', isRoot).bind(function (s) { - return closest$1(finish, 'td,th', isRoot).bind(function (f) { - return detect(container, isRoot, s, f, selectRange); - }); - }); - } else { - return Optional.none(); - } - }; - var detect = function (container, isRoot, start, finish, selectRange) { - if (!eq$1(start, finish)) { - return identify(start, finish, isRoot).bind(function (cellSel) { - var boxes = cellSel.boxes.getOr([]); - if (boxes.length > 1) { - selectRange(container, boxes, cellSel.start, cellSel.finish); - return Optional.some(Response.create(Optional.some(makeSitus(start, 0, start, getEnd(start))), true)); - } else { - return Optional.none(); - } - }); - } else { - return Optional.none(); - } - }; - var update = function (rows, columns, container, selected, annotations) { - var updateSelection = function (newSels) { - annotations.clearBeforeUpdate(container); - annotations.selectRange(container, newSels.boxes, newSels.start, newSels.finish); - return newSels.boxes; - }; - return shiftSelection(selected, rows, columns, annotations.firstSelectedSelector, annotations.lastSelectedSelector).map(updateSelection); - }; - - var traverse = function (item, mode) { - return { - item: item, - mode: mode - }; - }; - var backtrack = function (universe, item, _direction, transition) { - if (transition === void 0) { - transition = sidestep; - } - return universe.property().parent(item).map(function (p) { - return traverse(p, transition); - }); - }; - var sidestep = function (universe, item, direction, transition) { - if (transition === void 0) { - transition = advance; - } - return direction.sibling(universe, item).map(function (p) { - return traverse(p, transition); - }); - }; - var advance = function (universe, item, direction, transition) { - if (transition === void 0) { - transition = advance; - } - var children = universe.property().children(item); - var result = direction.first(children); - return result.map(function (r) { - return traverse(r, transition); - }); - }; - var successors = [ - { - current: backtrack, - next: sidestep, - fallback: Optional.none() - }, - { - current: sidestep, - next: advance, - fallback: Optional.some(backtrack) - }, - { - current: advance, - next: advance, - fallback: Optional.some(sidestep) - } - ]; - var go = function (universe, item, mode, direction, rules) { - if (rules === void 0) { - rules = successors; - } - var ruleOpt = find$1(rules, function (succ) { - return succ.current === mode; - }); - return ruleOpt.bind(function (rule) { - return rule.current(universe, item, direction, rule.next).orThunk(function () { - return rule.fallback.bind(function (fb) { - return go(universe, item, fb, direction); - }); - }); - }); - }; - - var left$1 = function () { - var sibling = function (universe, item) { - return universe.query().prevSibling(item); - }; - var first = function (children) { - return children.length > 0 ? Optional.some(children[children.length - 1]) : Optional.none(); - }; - return { - sibling: sibling, - first: first - }; - }; - var right$1 = function () { - var sibling = function (universe, item) { - return universe.query().nextSibling(item); - }; - var first = function (children) { - return children.length > 0 ? Optional.some(children[0]) : Optional.none(); - }; - return { - sibling: sibling, - first: first - }; - }; - var Walkers = { - left: left$1, - right: right$1 - }; - - var hone = function (universe, item, predicate, mode, direction, isRoot) { - var next = go(universe, item, mode, direction); - return next.bind(function (n) { - if (isRoot(n.item)) { - return Optional.none(); - } else { - return predicate(n.item) ? Optional.some(n.item) : hone(universe, n.item, predicate, n.mode, direction, isRoot); - } - }); - }; - var left = function (universe, item, predicate, isRoot) { - return hone(universe, item, predicate, sidestep, Walkers.left(), isRoot); - }; - var right = function (universe, item, predicate, isRoot) { - return hone(universe, item, predicate, sidestep, Walkers.right(), isRoot); - }; - - var isLeaf = function (universe) { - return function (element) { - return universe.property().children(element).length === 0; - }; - }; - var before$1 = function (universe, item, isRoot) { - return seekLeft$1(universe, item, isLeaf(universe), isRoot); - }; - var after$1 = function (universe, item, isRoot) { - return seekRight$1(universe, item, isLeaf(universe), isRoot); - }; - var seekLeft$1 = left; - var seekRight$1 = right; - - var universe = DomUniverse(); - var before = function (element, isRoot) { - return before$1(universe, element, isRoot); - }; - var after = function (element, isRoot) { - return after$1(universe, element, isRoot); - }; - var seekLeft = function (element, predicate, isRoot) { - return seekLeft$1(universe, element, predicate, isRoot); - }; - var seekRight = function (element, predicate, isRoot) { - return seekRight$1(universe, element, predicate, isRoot); - }; - - var ancestor = function (scope, predicate, isRoot) { - return ancestor$2(scope, predicate, isRoot).isSome(); - }; - - var adt$1 = Adt.generate([ - { none: ['message'] }, - { success: [] }, - { failedUp: ['cell'] }, - { failedDown: ['cell'] } - ]); - var isOverlapping = function (bridge, before, after) { - var beforeBounds = bridge.getRect(before); - var afterBounds = bridge.getRect(after); - return afterBounds.right > beforeBounds.left && afterBounds.left < beforeBounds.right; - }; - var isRow = function (elem) { - return closest$1(elem, 'tr'); - }; - var verify = function (bridge, before, beforeOffset, after, afterOffset, failure, isRoot) { - return closest$1(after, 'td,th', isRoot).bind(function (afterCell) { - return closest$1(before, 'td,th', isRoot).map(function (beforeCell) { - if (!eq$1(afterCell, beforeCell)) { - return sharedOne(isRow, [ - afterCell, - beforeCell - ]).fold(function () { - return isOverlapping(bridge, beforeCell, afterCell) ? adt$1.success() : failure(beforeCell); - }, function (_sharedRow) { - return failure(beforeCell); - }); - } else { - return eq$1(after, afterCell) && getEnd(afterCell) === afterOffset ? failure(beforeCell) : adt$1.none('in same cell'); - } - }); - }).getOr(adt$1.none('default')); - }; - var cata = function (subject, onNone, onSuccess, onFailedUp, onFailedDown) { - return subject.fold(onNone, onSuccess, onFailedUp, onFailedDown); - }; - var BeforeAfter = __assign(__assign({}, adt$1), { - verify: verify, - cata: cata - }); - - var inParent = function (parent, children, element, index) { - return { - parent: parent, - children: children, - element: element, - index: index - }; - }; - var indexInParent = function (element) { - return parent(element).bind(function (parent) { - var children = children$3(parent); - return indexOf(children, element).map(function (index) { - return inParent(parent, children, element, index); - }); - }); - }; - var indexOf = function (elements, element) { - return findIndex(elements, curry(eq$1, element)); - }; - - var isBr = function (elem) { - return name(elem) === 'br'; - }; - var gatherer = function (cand, gather, isRoot) { - return gather(cand, isRoot).bind(function (target) { - return isText(target) && get$9(target).trim().length === 0 ? gatherer(target, gather, isRoot) : Optional.some(target); - }); - }; - var handleBr = function (isRoot, element, direction) { - return direction.traverse(element).orThunk(function () { - return gatherer(element, direction.gather, isRoot); - }).map(direction.relative); - }; - var findBr = function (element, offset) { - return child$3(element, offset).filter(isBr).orThunk(function () { - return child$3(element, offset - 1).filter(isBr); - }); - }; - var handleParent = function (isRoot, element, offset, direction) { - return findBr(element, offset).bind(function (br) { - return direction.traverse(br).fold(function () { - return gatherer(br, direction.gather, isRoot).map(direction.relative); - }, function (adjacent) { - return indexInParent(adjacent).map(function (info) { - return Situ.on(info.parent, info.index); - }); - }); - }); - }; - var tryBr = function (isRoot, element, offset, direction) { - var target = isBr(element) ? handleBr(isRoot, element, direction) : handleParent(isRoot, element, offset, direction); - return target.map(function (tgt) { - return { - start: tgt, - finish: tgt - }; - }); - }; - var process = function (analysis) { - return BeforeAfter.cata(analysis, function (_message) { - return Optional.none(); - }, function () { - return Optional.none(); - }, function (cell) { - return Optional.some(point(cell, 0)); - }, function (cell) { - return Optional.some(point(cell, getEnd(cell))); - }); - }; - - var moveDown = function (caret, amount) { - return { - left: caret.left, - top: caret.top + amount, - right: caret.right, - bottom: caret.bottom + amount - }; - }; - var moveUp = function (caret, amount) { - return { - left: caret.left, - top: caret.top - amount, - right: caret.right, - bottom: caret.bottom - amount - }; - }; - var translate = function (caret, xDelta, yDelta) { - return { - left: caret.left + xDelta, - top: caret.top + yDelta, - right: caret.right + xDelta, - bottom: caret.bottom + yDelta - }; - }; - var getTop = function (caret) { - return caret.top; - }; - var getBottom = function (caret) { - return caret.bottom; - }; - - var getPartialBox = function (bridge, element, offset) { - if (offset >= 0 && offset < getEnd(element)) { - return bridge.getRangedRect(element, offset, element, offset + 1); - } else if (offset > 0) { - return bridge.getRangedRect(element, offset - 1, element, offset); - } - return Optional.none(); - }; - var toCaret = function (rect) { - return { - left: rect.left, - top: rect.top, - right: rect.right, - bottom: rect.bottom - }; - }; - var getElemBox = function (bridge, element) { - return Optional.some(bridge.getRect(element)); - }; - var getBoxAt = function (bridge, element, offset) { - if (isElement(element)) { - return getElemBox(bridge, element).map(toCaret); - } else if (isText(element)) { - return getPartialBox(bridge, element, offset).map(toCaret); - } else { - return Optional.none(); - } - }; - var getEntireBox = function (bridge, element) { - if (isElement(element)) { - return getElemBox(bridge, element).map(toCaret); - } else if (isText(element)) { - return bridge.getRangedRect(element, 0, element, getEnd(element)).map(toCaret); - } else { - return Optional.none(); - } - }; - - var JUMP_SIZE = 5; - var NUM_RETRIES = 100; - var adt = Adt.generate([ - { none: [] }, - { retry: ['caret'] } - ]); - var isOutside = function (caret, box) { - return caret.left < box.left || Math.abs(box.right - caret.left) < 1 || caret.left > box.right; - }; - var inOutsideBlock = function (bridge, element, caret) { - return closest$2(element, isBlock).fold(never, function (cell) { - return getEntireBox(bridge, cell).exists(function (box) { - return isOutside(caret, box); - }); - }); - }; - var adjustDown = function (bridge, element, guessBox, original, caret) { - var lowerCaret = moveDown(caret, JUMP_SIZE); - if (Math.abs(guessBox.bottom - original.bottom) < 1) { - return adt.retry(lowerCaret); - } else if (guessBox.top > caret.bottom) { - return adt.retry(lowerCaret); - } else if (guessBox.top === caret.bottom) { - return adt.retry(moveDown(caret, 1)); - } else { - return inOutsideBlock(bridge, element, caret) ? adt.retry(translate(lowerCaret, JUMP_SIZE, 0)) : adt.none(); - } - }; - var adjustUp = function (bridge, element, guessBox, original, caret) { - var higherCaret = moveUp(caret, JUMP_SIZE); - if (Math.abs(guessBox.top - original.top) < 1) { - return adt.retry(higherCaret); - } else if (guessBox.bottom < caret.top) { - return adt.retry(higherCaret); - } else if (guessBox.bottom === caret.top) { - return adt.retry(moveUp(caret, 1)); - } else { - return inOutsideBlock(bridge, element, caret) ? adt.retry(translate(higherCaret, JUMP_SIZE, 0)) : adt.none(); - } - }; - var upMovement = { - point: getTop, - adjuster: adjustUp, - move: moveUp, - gather: before - }; - var downMovement = { - point: getBottom, - adjuster: adjustDown, - move: moveDown, - gather: after - }; - var isAtTable = function (bridge, x, y) { - return bridge.elementFromPoint(x, y).filter(function (elm) { - return name(elm) === 'table'; - }).isSome(); - }; - var adjustForTable = function (bridge, movement, original, caret, numRetries) { - return adjustTil(bridge, movement, original, movement.move(caret, JUMP_SIZE), numRetries); - }; - var adjustTil = function (bridge, movement, original, caret, numRetries) { - if (numRetries === 0) { - return Optional.some(caret); - } - if (isAtTable(bridge, caret.left, movement.point(caret))) { - return adjustForTable(bridge, movement, original, caret, numRetries - 1); - } - return bridge.situsFromPoint(caret.left, movement.point(caret)).bind(function (guess) { - return guess.start.fold(Optional.none, function (element) { - return getEntireBox(bridge, element).bind(function (guessBox) { - return movement.adjuster(bridge, element, guessBox, original, caret).fold(Optional.none, function (newCaret) { - return adjustTil(bridge, movement, original, newCaret, numRetries - 1); - }); - }).orThunk(function () { - return Optional.some(caret); - }); - }, Optional.none); - }); - }; - var ieTryDown = function (bridge, caret) { - return bridge.situsFromPoint(caret.left, caret.bottom + JUMP_SIZE); - }; - var ieTryUp = function (bridge, caret) { - return bridge.situsFromPoint(caret.left, caret.top - JUMP_SIZE); - }; - var checkScroll = function (movement, adjusted, bridge) { - if (movement.point(adjusted) > bridge.getInnerHeight()) { - return Optional.some(movement.point(adjusted) - bridge.getInnerHeight()); - } else if (movement.point(adjusted) < 0) { - return Optional.some(-movement.point(adjusted)); - } else { - return Optional.none(); - } - }; - var retry = function (movement, bridge, caret) { - var moved = movement.move(caret, JUMP_SIZE); - var adjusted = adjustTil(bridge, movement, caret, moved, NUM_RETRIES).getOr(moved); - return checkScroll(movement, adjusted, bridge).fold(function () { - return bridge.situsFromPoint(adjusted.left, movement.point(adjusted)); - }, function (delta) { - bridge.scrollBy(0, delta); - return bridge.situsFromPoint(adjusted.left, movement.point(adjusted) - delta); - }); - }; - var Retries = { - tryUp: curry(retry, upMovement), - tryDown: curry(retry, downMovement), - ieTryUp: ieTryUp, - ieTryDown: ieTryDown, - getJumpSize: constant(JUMP_SIZE) - }; - - var MAX_RETRIES = 20; - var findSpot = function (bridge, isRoot, direction) { - return bridge.getSelection().bind(function (sel) { - return tryBr(isRoot, sel.finish, sel.foffset, direction).fold(function () { - return Optional.some(point(sel.finish, sel.foffset)); - }, function (brNeighbour) { - var range = bridge.fromSitus(brNeighbour); - var analysis = BeforeAfter.verify(bridge, sel.finish, sel.foffset, range.finish, range.foffset, direction.failure, isRoot); - return process(analysis); - }); - }); - }; - var scan = function (bridge, isRoot, element, offset, direction, numRetries) { - if (numRetries === 0) { - return Optional.none(); - } - return tryCursor(bridge, isRoot, element, offset, direction).bind(function (situs) { - var range = bridge.fromSitus(situs); - var analysis = BeforeAfter.verify(bridge, element, offset, range.finish, range.foffset, direction.failure, isRoot); - return BeforeAfter.cata(analysis, function () { - return Optional.none(); - }, function () { - return Optional.some(situs); - }, function (cell) { - if (eq$1(element, cell) && offset === 0) { - return tryAgain(bridge, element, offset, moveUp, direction); - } else { - return scan(bridge, isRoot, cell, 0, direction, numRetries - 1); - } - }, function (cell) { - if (eq$1(element, cell) && offset === getEnd(cell)) { - return tryAgain(bridge, element, offset, moveDown, direction); - } else { - return scan(bridge, isRoot, cell, getEnd(cell), direction, numRetries - 1); - } - }); - }); - }; - var tryAgain = function (bridge, element, offset, move, direction) { - return getBoxAt(bridge, element, offset).bind(function (box) { - return tryAt(bridge, direction, move(box, Retries.getJumpSize())); - }); - }; - var tryAt = function (bridge, direction, box) { - var browser = detect$3().browser; - if (browser.isChrome() || browser.isSafari() || browser.isFirefox() || browser.isEdge()) { - return direction.otherRetry(bridge, box); - } else if (browser.isIE()) { - return direction.ieRetry(bridge, box); - } else { - return Optional.none(); - } - }; - var tryCursor = function (bridge, isRoot, element, offset, direction) { - return getBoxAt(bridge, element, offset).bind(function (box) { - return tryAt(bridge, direction, box); - }); - }; - var handle = function (bridge, isRoot, direction) { - return findSpot(bridge, isRoot, direction).bind(function (spot) { - return scan(bridge, isRoot, spot.element, spot.offset, direction, MAX_RETRIES).map(bridge.fromSitus); - }); - }; - - var inSameTable = function (elem, table) { - return ancestor(elem, function (e) { - return parent(e).exists(function (p) { - return eq$1(p, table); - }); - }); - }; - var simulate = function (bridge, isRoot, direction, initial, anchor) { - return closest$1(initial, 'td,th', isRoot).bind(function (start) { - return closest$1(start, 'table', isRoot).bind(function (table) { - if (!inSameTable(anchor, table)) { - return Optional.none(); - } - return handle(bridge, isRoot, direction).bind(function (range) { - return closest$1(range.finish, 'td,th', isRoot).map(function (finish) { - return { - start: start, - finish: finish, - range: range - }; - }); - }); - }); - }); - }; - var navigate = function (bridge, isRoot, direction, initial, anchor, precheck) { - if (detect$3().browser.isIE()) { - return Optional.none(); - } else { - return precheck(initial, isRoot).orThunk(function () { - return simulate(bridge, isRoot, direction, initial, anchor).map(function (info) { - var range = info.range; - return Response.create(Optional.some(makeSitus(range.start, range.soffset, range.finish, range.foffset)), true); - }); - }); - } - }; - var firstUpCheck = function (initial, isRoot) { - return closest$1(initial, 'tr', isRoot).bind(function (startRow) { - return closest$1(startRow, 'table', isRoot).bind(function (table) { - var rows = descendants(table, 'tr'); - if (eq$1(startRow, rows[0])) { - return seekLeft(table, function (element) { - return last$1(element).isSome(); - }, isRoot).map(function (last) { - var lastOffset = getEnd(last); - return Response.create(Optional.some(makeSitus(last, lastOffset, last, lastOffset)), true); - }); - } else { - return Optional.none(); - } - }); - }); - }; - var lastDownCheck = function (initial, isRoot) { - return closest$1(initial, 'tr', isRoot).bind(function (startRow) { - return closest$1(startRow, 'table', isRoot).bind(function (table) { - var rows = descendants(table, 'tr'); - if (eq$1(startRow, rows[rows.length - 1])) { - return seekRight(table, function (element) { - return first(element).isSome(); - }, isRoot).map(function (first) { - return Response.create(Optional.some(makeSitus(first, 0, first, 0)), true); - }); - } else { - return Optional.none(); - } - }); - }); - }; - var select = function (bridge, container, isRoot, direction, initial, anchor, selectRange) { - return simulate(bridge, isRoot, direction, initial, anchor).bind(function (info) { - return detect(container, isRoot, info.start, info.finish, selectRange); - }); - }; - - var findCell = function (target, isRoot) { - return closest$1(target, 'td,th', isRoot); - }; - var MouseSelection = function (bridge, container, isRoot, annotations) { - var cursor = value(); - var clearstate = cursor.clear; - var applySelection = function (event) { - cursor.on(function (start) { - annotations.clearBeforeUpdate(container); - findCell(event.target, isRoot).each(function (finish) { - identify(start, finish, isRoot).each(function (cellSel) { - var boxes = cellSel.boxes.getOr([]); - if (boxes.length === 1) { - var singleCell = boxes[0]; - var isNonEditableCell = getRaw(singleCell) === 'false'; - var isCellClosestContentEditable = is(closest(event.target), singleCell, eq$1); - if (isNonEditableCell && isCellClosestContentEditable) { - annotations.selectRange(container, boxes, singleCell, singleCell); - bridge.selectContents(singleCell); - } - } else if (boxes.length > 1) { - annotations.selectRange(container, boxes, cellSel.start, cellSel.finish); - bridge.selectContents(finish); - } - }); - }); - }); - }; - var mousedown = function (event) { - annotations.clear(container); - findCell(event.target, isRoot).each(cursor.set); - }; - var mouseover = function (event) { - applySelection(event); - }; - var mouseup = function (event) { - applySelection(event); - clearstate(); - }; - return { - clearstate: clearstate, - mousedown: mousedown, - mouseover: mouseover, - mouseup: mouseup - }; - }; - - var down = { - traverse: nextSibling, - gather: after, - relative: Situ.before, - otherRetry: Retries.tryDown, - ieRetry: Retries.ieTryDown, - failure: BeforeAfter.failedDown - }; - var up = { - traverse: prevSibling, - gather: before, - relative: Situ.before, - otherRetry: Retries.tryUp, - ieRetry: Retries.ieTryUp, - failure: BeforeAfter.failedUp - }; - - var isKey = function (key) { - return function (keycode) { - return keycode === key; - }; - }; - var isUp = isKey(38); - var isDown = isKey(40); - var isNavigation = function (keycode) { - return keycode >= 37 && keycode <= 40; - }; - var ltr = { - isBackward: isKey(37), - isForward: isKey(39) - }; - var rtl = { - isBackward: isKey(39), - isForward: isKey(37) - }; - - var get = function (_DOC) { - var doc = _DOC !== undefined ? _DOC.dom : document; - var x = doc.body.scrollLeft || doc.documentElement.scrollLeft; - var y = doc.body.scrollTop || doc.documentElement.scrollTop; - return SugarPosition(x, y); - }; - var by = function (x, y, _DOC) { - var doc = _DOC !== undefined ? _DOC.dom : document; - var win = doc.defaultView; - if (win) { - win.scrollBy(x, y); - } - }; - - var WindowBridge = function (win) { - var elementFromPoint = function (x, y) { - return SugarElement.fromPoint(SugarElement.fromDom(win.document), x, y); - }; - var getRect = function (element) { - return element.dom.getBoundingClientRect(); - }; - var getRangedRect = function (start, soffset, finish, foffset) { - var sel = SimSelection.exact(start, soffset, finish, foffset); - return getFirstRect(win, sel); - }; - var getSelection = function () { - return get$1(win).map(function (exactAdt) { - return convertToRange(win, exactAdt); - }); - }; - var fromSitus = function (situs) { - var relative = SimSelection.relative(situs.start, situs.finish); - return convertToRange(win, relative); - }; - var situsFromPoint = function (x, y) { - return getAtPoint(win, x, y).map(function (exact) { - return Situs.create(exact.start, exact.soffset, exact.finish, exact.foffset); - }); - }; - var clearSelection = function () { - clear(win); - }; - var collapseSelection = function (toStart) { - if (toStart === void 0) { - toStart = false; - } - get$1(win).each(function (sel) { - return sel.fold(function (rng) { - return rng.collapse(toStart); - }, function (startSitu, finishSitu) { - var situ = toStart ? startSitu : finishSitu; - setRelative(win, situ, situ); - }, function (start, soffset, finish, foffset) { - var node = toStart ? start : finish; - var offset = toStart ? soffset : foffset; - setExact(win, node, offset, node, offset); - }); - }); - }; - var selectNode = function (element) { - setToElement(win, element, false); - }; - var selectContents = function (element) { - setToElement(win, element); - }; - var setSelection = function (sel) { - setExact(win, sel.start, sel.soffset, sel.finish, sel.foffset); - }; - var setRelativeSelection = function (start, finish) { - setRelative(win, start, finish); - }; - var getInnerHeight = function () { - return win.innerHeight; - }; - var getScrollY = function () { - var pos = get(SugarElement.fromDom(win.document)); - return pos.top; - }; - var scrollBy = function (x, y) { - by(x, y, SugarElement.fromDom(win.document)); - }; - return { - elementFromPoint: elementFromPoint, - getRect: getRect, - getRangedRect: getRangedRect, - getSelection: getSelection, - fromSitus: fromSitus, - situsFromPoint: situsFromPoint, - clearSelection: clearSelection, - collapseSelection: collapseSelection, - setSelection: setSelection, - setRelativeSelection: setRelativeSelection, - selectNode: selectNode, - selectContents: selectContents, - getInnerHeight: getInnerHeight, - getScrollY: getScrollY, - scrollBy: scrollBy - }; - }; - - var rc = function (rows, cols) { - return { - rows: rows, - cols: cols - }; - }; - var mouse = function (win, container, isRoot, annotations) { - var bridge = WindowBridge(win); - var handlers = MouseSelection(bridge, container, isRoot, annotations); - return { - clearstate: handlers.clearstate, - mousedown: handlers.mousedown, - mouseover: handlers.mouseover, - mouseup: handlers.mouseup - }; - }; - var keyboard = function (win, container, isRoot, annotations) { - var bridge = WindowBridge(win); - var clearToNavigate = function () { - annotations.clear(container); - return Optional.none(); - }; - var keydown = function (event, start, soffset, finish, foffset, direction) { - var realEvent = event.raw; - var keycode = realEvent.which; - var shiftKey = realEvent.shiftKey === true; - var handler = retrieve$1(container, annotations.selectedSelector).fold(function () { - if (isNavigation(keycode) && !shiftKey) { - annotations.clearBeforeUpdate(container); - } - if (isDown(keycode) && shiftKey) { - return curry(select, bridge, container, isRoot, down, finish, start, annotations.selectRange); - } else if (isUp(keycode) && shiftKey) { - return curry(select, bridge, container, isRoot, up, finish, start, annotations.selectRange); - } else if (isDown(keycode)) { - return curry(navigate, bridge, isRoot, down, finish, start, lastDownCheck); - } else if (isUp(keycode)) { - return curry(navigate, bridge, isRoot, up, finish, start, firstUpCheck); - } else { - return Optional.none; - } - }, function (selected) { - var update$1 = function (attempts) { - return function () { - var navigation = findMap(attempts, function (delta) { - return update(delta.rows, delta.cols, container, selected, annotations); - }); - return navigation.fold(function () { - return getEdges(container, annotations.firstSelectedSelector, annotations.lastSelectedSelector).map(function (edges) { - var relative = isDown(keycode) || direction.isForward(keycode) ? Situ.after : Situ.before; - bridge.setRelativeSelection(Situ.on(edges.first, 0), relative(edges.table)); - annotations.clear(container); - return Response.create(Optional.none(), true); - }); - }, function (_) { - return Optional.some(Response.create(Optional.none(), true)); - }); - }; - }; - if (isDown(keycode) && shiftKey) { - return update$1([rc(+1, 0)]); - } else if (isUp(keycode) && shiftKey) { - return update$1([rc(-1, 0)]); - } else if (direction.isBackward(keycode) && shiftKey) { - return update$1([ - rc(0, -1), - rc(-1, 0) - ]); - } else if (direction.isForward(keycode) && shiftKey) { - return update$1([ - rc(0, +1), - rc(+1, 0) - ]); - } else if (isNavigation(keycode) && !shiftKey) { - return clearToNavigate; - } else { - return Optional.none; - } - }); - return handler(); - }; - var keyup = function (event, start, soffset, finish, foffset) { - return retrieve$1(container, annotations.selectedSelector).fold(function () { - var realEvent = event.raw; - var keycode = realEvent.which; - var shiftKey = realEvent.shiftKey === true; - if (!shiftKey) { - return Optional.none(); - } - if (isNavigation(keycode)) { - return sync(container, isRoot, start, soffset, finish, foffset, annotations.selectRange); - } else { - return Optional.none(); - } - }, Optional.none); - }; - return { - keydown: keydown, - keyup: keyup - }; - }; - var external = function (win, container, isRoot, annotations) { - var bridge = WindowBridge(win); - return function (start, finish) { - annotations.clearBeforeUpdate(container); - identify(start, finish, isRoot).each(function (cellSel) { - var boxes = cellSel.boxes.getOr([]); - annotations.selectRange(container, boxes, cellSel.start, cellSel.finish); - bridge.selectContents(finish); - bridge.collapseSelection(); - }); - }; - }; - - var remove = function (element, classes) { - each$2(classes, function (x) { - remove$2(element, x); - }); - }; - - var addClass = function (clazz) { - return function (element) { - add(element, clazz); - }; - }; - var removeClasses = function (classes) { - return function (element) { - remove(element, classes); - }; - }; - - var byClass = function (ephemera) { - var addSelectionClass = addClass(ephemera.selected); - var removeSelectionClasses = removeClasses([ - ephemera.selected, - ephemera.lastSelected, - ephemera.firstSelected - ]); - var clear = function (container) { - var sels = descendants(container, ephemera.selectedSelector); - each$2(sels, removeSelectionClasses); - }; - var selectRange = function (container, cells, start, finish) { - clear(container); - each$2(cells, addSelectionClass); - add(start, ephemera.firstSelected); - add(finish, ephemera.lastSelected); - }; - return { - clearBeforeUpdate: clear, - clear: clear, - selectRange: selectRange, - selectedSelector: ephemera.selectedSelector, - firstSelectedSelector: ephemera.firstSelectedSelector, - lastSelectedSelector: ephemera.lastSelectedSelector - }; - }; - var byAttr = function (ephemera, onSelection, onClear) { - var removeSelectionAttributes = function (element) { - remove$7(element, ephemera.selected); - remove$7(element, ephemera.firstSelected); - remove$7(element, ephemera.lastSelected); - }; - var addSelectionAttribute = function (element) { - set$2(element, ephemera.selected, '1'); - }; - var clear = function (container) { - clearBeforeUpdate(container); - onClear(); - }; - var clearBeforeUpdate = function (container) { - var sels = descendants(container, ephemera.selectedSelector + ',' + ephemera.firstSelectedSelector + ',' + ephemera.lastSelectedSelector); - each$2(sels, removeSelectionAttributes); - }; - var selectRange = function (container, cells, start, finish) { - clear(container); - each$2(cells, addSelectionAttribute); - set$2(start, ephemera.firstSelected, '1'); - set$2(finish, ephemera.lastSelected, '1'); - onSelection(cells, start, finish); - }; - return { - clearBeforeUpdate: clearBeforeUpdate, - clear: clear, - selectRange: selectRange, - selectedSelector: ephemera.selectedSelector, - firstSelectedSelector: ephemera.firstSelectedSelector, - lastSelectedSelector: ephemera.lastSelectedSelector - }; - }; - var SelectionAnnotation = { - byClass: byClass, - byAttr: byAttr - }; - - var getUpOrLeftCells = function (grid, selectedCells) { - var upGrid = grid.slice(0, selectedCells[selectedCells.length - 1].row + 1); - var upDetails = toDetailList(upGrid); - return bind$2(upDetails, function (detail) { - var slicedCells = detail.cells.slice(0, selectedCells[selectedCells.length - 1].column + 1); - return map$1(slicedCells, function (cell) { - return cell.element; - }); - }); - }; - var getDownOrRightCells = function (grid, selectedCells) { - var downGrid = grid.slice(selectedCells[0].row + selectedCells[0].rowspan - 1, grid.length); - var downDetails = toDetailList(downGrid); - return bind$2(downDetails, function (detail) { - var slicedCells = detail.cells.slice(selectedCells[0].column + selectedCells[0].colspan - 1, detail.cells.length); - return map$1(slicedCells, function (cell) { - return cell.element; - }); - }); - }; - var getOtherCells = function (table, target, generators) { - var warehouse = Warehouse.fromTable(table); - var details = onCells(warehouse, target); - return details.map(function (selectedCells) { - var grid = toGrid(warehouse, generators, false); - var upOrLeftCells = getUpOrLeftCells(grid, selectedCells); - var downOrRightCells = getDownOrRightCells(grid, selectedCells); - return { - upOrLeftCells: upOrLeftCells, - downOrRightCells: downOrRightCells - }; - }); - }; - - var global = tinymce.util.Tools.resolve('tinymce.Env'); - - var hasInternalTarget = function (e) { - return has(SugarElement.fromDom(e.target), 'ephox-snooker-resizer-bar') === false; - }; - function CellSelection (editor, lazyResize, selectionTargets) { - var onSelection = function (cells, start, finish) { - selectionTargets.targets().each(function (targets) { - var tableOpt = table(start); - tableOpt.each(function (table) { - var cloneFormats = getCloneElements(editor); - var generators = cellOperations(noop, SugarElement.fromDom(editor.getDoc()), cloneFormats); - var otherCells = getOtherCells(table, targets, generators); - fireTableSelectionChange(editor, cells, start, finish, otherCells); - }); - }); - }; - var onClear = function () { - return fireTableSelectionClear(editor); - }; - var annotations = SelectionAnnotation.byAttr(ephemera, onSelection, onClear); - editor.on('init', function (_e) { - var win = editor.getWin(); - var body = getBody(editor); - var isRoot = getIsRoot(editor); - var syncSelection = function () { - var sel = editor.selection; - var start = SugarElement.fromDom(sel.getStart()); - var end = SugarElement.fromDom(sel.getEnd()); - var shared = sharedOne(table, [ - start, - end - ]); - shared.fold(function () { - return annotations.clear(body); - }, noop); - }; - var mouseHandlers = mouse(win, body, isRoot, annotations); - var keyHandlers = keyboard(win, body, isRoot, annotations); - var external$1 = external(win, body, isRoot, annotations); - var hasShiftKey = function (event) { - return event.raw.shiftKey === true; - }; - editor.on('TableSelectorChange', function (e) { - return external$1(e.start, e.finish); - }); - var handleResponse = function (event, response) { - if (!hasShiftKey(event)) { - return; - } - if (response.kill) { - event.kill(); - } - response.selection.each(function (ns) { - var relative = SimSelection.relative(ns.start, ns.finish); - var rng = asLtrRange(win, relative); - editor.selection.setRng(rng); - }); - }; - var keyup = function (event) { - var wrappedEvent = fromRawEvent(event); - if (wrappedEvent.raw.shiftKey && isNavigation(wrappedEvent.raw.which)) { - var rng = editor.selection.getRng(); - var start = SugarElement.fromDom(rng.startContainer); - var end = SugarElement.fromDom(rng.endContainer); - keyHandlers.keyup(wrappedEvent, start, rng.startOffset, end, rng.endOffset).each(function (response) { - handleResponse(wrappedEvent, response); - }); - } - }; - var keydown = function (event) { - var wrappedEvent = fromRawEvent(event); - lazyResize().each(function (resize) { - return resize.hideBars(); - }); - var rng = editor.selection.getRng(); - var start = SugarElement.fromDom(rng.startContainer); - var end = SugarElement.fromDom(rng.endContainer); - var direction = onDirection(ltr, rtl)(SugarElement.fromDom(editor.selection.getStart())); - keyHandlers.keydown(wrappedEvent, start, rng.startOffset, end, rng.endOffset, direction).each(function (response) { - handleResponse(wrappedEvent, response); - }); - lazyResize().each(function (resize) { - return resize.showBars(); - }); - }; - var isLeftMouse = function (raw) { - return raw.button === 0; - }; - var isLeftButtonPressed = function (raw) { - if (raw.buttons === undefined) { - return true; - } - if (global.browser.isEdge() && raw.buttons === 0) { - return true; - } - return (raw.buttons & 1) !== 0; - }; - var dragStart = function (_e) { - mouseHandlers.clearstate(); - }; - var mouseDown = function (e) { - if (isLeftMouse(e) && hasInternalTarget(e)) { - mouseHandlers.mousedown(fromRawEvent(e)); - } - }; - var mouseOver = function (e) { - if (isLeftButtonPressed(e) && hasInternalTarget(e)) { - mouseHandlers.mouseover(fromRawEvent(e)); - } - }; - var mouseUp = function (e) { - if (isLeftMouse(e) && hasInternalTarget(e)) { - mouseHandlers.mouseup(fromRawEvent(e)); - } - }; - var getDoubleTap = function () { - var lastTarget = Cell(SugarElement.fromDom(body)); - var lastTimeStamp = Cell(0); - var touchEnd = function (t) { - var target = SugarElement.fromDom(t.target); - if (name(target) === 'td' || name(target) === 'th') { - var lT = lastTarget.get(); - var lTS = lastTimeStamp.get(); - if (eq$1(lT, target) && t.timeStamp - lTS < 300) { - t.preventDefault(); - external$1(target, target); - } - } - lastTarget.set(target); - lastTimeStamp.set(t.timeStamp); - }; - return { touchEnd: touchEnd }; - }; - var doubleTap = getDoubleTap(); - editor.on('dragstart', dragStart); - editor.on('mousedown', mouseDown); - editor.on('mouseover', mouseOver); - editor.on('mouseup', mouseUp); - editor.on('touchend', doubleTap.touchEnd); - editor.on('keyup', keyup); - editor.on('keydown', keydown); - editor.on('NodeChange', syncSelection); - }); - return { clear: annotations.clear }; - } - - var child = function (scope, selector) { - return child$1(scope, selector).isSome(); - }; - - var getSelectionTargets = function (editor, selections) { - var targets = Cell(Optional.none()); - var changeHandlers = Cell([]); - var selectionDetails = Optional.none(); - var isCaption = isTag('caption'); - var isDisabledForSelection = function (key) { - return selectionDetails.forall(function (details) { - return !details[key]; - }); - }; - var getStart = function () { - return getSelectionCellOrCaption(getSelectionStart(editor), getIsRoot(editor)); - }; - var getEnd = function () { - return getSelectionCellOrCaption(getSelectionEnd(editor), getIsRoot(editor)); - }; - var findTargets = function () { - return getStart().bind(function (startCellOrCaption) { - return flatten(lift2(table(startCellOrCaption), getEnd().bind(table), function (startTable, endTable) { - if (eq$1(startTable, endTable)) { - if (isCaption(startCellOrCaption)) { - return Optional.some(noMenu(startCellOrCaption)); - } else { - return Optional.some(forMenu(selections, startTable, startCellOrCaption)); - } - } - return Optional.none(); - })); - }); - }; - var getExtractedDetails = function (targets) { - var tableOpt = table(targets.element); - return tableOpt.map(function (table) { - var warehouse = Warehouse.fromTable(table); - var selectedCells = onCells(warehouse, targets).getOr([]); - var locked = foldl(selectedCells, function (acc, cell) { - if (cell.isLocked) { - acc.onAny = true; - if (cell.column === 0) { - acc.onFirst = true; - } else if (cell.column + cell.colspan >= warehouse.grid.columns) { - acc.onLast = true; - } - } - return acc; - }, { - onAny: false, - onFirst: false, - onLast: false - }); - return { - mergeable: onUnlockedMergable(warehouse, targets).isSome(), - unmergeable: onUnlockedUnmergable(warehouse, targets).isSome(), - locked: locked - }; - }); - }; - var resetTargets = function () { - targets.set(cached(findTargets)()); - selectionDetails = targets.get().bind(getExtractedDetails); - each$2(changeHandlers.get(), function (handler) { - return handler(); - }); - }; - var setupHandler = function (handler) { - handler(); - changeHandlers.set(changeHandlers.get().concat([handler])); - return function () { - changeHandlers.set(filter$2(changeHandlers.get(), function (h) { - return h !== handler; - })); - }; - }; - var onSetup = function (api, isDisabled) { - return setupHandler(function () { - return targets.get().fold(function () { - api.setDisabled(true); - }, function (targets) { - api.setDisabled(isDisabled(targets)); - }); - }); - }; - var onSetupWithToggle = function (api, isDisabled, isActive) { - return setupHandler(function () { - return targets.get().fold(function () { - api.setDisabled(true); - api.setActive(false); - }, function (targets) { - api.setDisabled(isDisabled(targets)); - api.setActive(isActive(targets)); - }); - }); - }; - var isDisabledFromLocked = function (lockedDisable) { - return selectionDetails.exists(function (details) { - return details.locked[lockedDisable]; - }); - }; - var onSetupTable = function (api) { - return onSetup(api, function (_) { - return false; - }); - }; - var onSetupCellOrRow = function (api) { - return onSetup(api, function (targets) { - return isCaption(targets.element); - }); - }; - var onSetupColumn = function (lockedDisable) { - return function (api) { - return onSetup(api, function (targets) { - return isCaption(targets.element) || isDisabledFromLocked(lockedDisable); - }); - }; - }; - var onSetupPasteable = function (getClipboardData) { - return function (api) { - return onSetup(api, function (targets) { - return isCaption(targets.element) || getClipboardData().isNone(); - }); - }; - }; - var onSetupPasteableColumn = function (getClipboardData, lockedDisable) { - return function (api) { - return onSetup(api, function (targets) { - return isCaption(targets.element) || getClipboardData().isNone() || isDisabledFromLocked(lockedDisable); - }); - }; - }; - var onSetupMergeable = function (api) { - return onSetup(api, function (_targets) { - return isDisabledForSelection('mergeable'); - }); - }; - var onSetupUnmergeable = function (api) { - return onSetup(api, function (_targets) { - return isDisabledForSelection('unmergeable'); - }); - }; - var onSetupTableWithCaption = function (api) { - return onSetupWithToggle(api, never, function (targets) { - var tableOpt = table(targets.element, getIsRoot(editor)); - return tableOpt.exists(function (table) { - return child(table, 'caption'); - }); - }); - }; - var onSetupTableHeaders = function (command, headerType) { - return function (api) { - return onSetupWithToggle(api, function (targets) { - return isCaption(targets.element); - }, function () { - return editor.queryCommandValue(command) === headerType; - }); - }; - }; - var onSetupTableRowHeaders = onSetupTableHeaders('mceTableRowType', 'header'); - var onSetupTableColumnHeaders = onSetupTableHeaders('mceTableColType', 'th'); - editor.on('NodeChange ExecCommand TableSelectorChange', resetTargets); - return { - onSetupTable: onSetupTable, - onSetupCellOrRow: onSetupCellOrRow, - onSetupColumn: onSetupColumn, - onSetupPasteable: onSetupPasteable, - onSetupPasteableColumn: onSetupPasteableColumn, - onSetupMergeable: onSetupMergeable, - onSetupUnmergeable: onSetupUnmergeable, - resetTargets: resetTargets, - onSetupTableWithCaption: onSetupTableWithCaption, - onSetupTableRowHeaders: onSetupTableRowHeaders, - onSetupTableColumnHeaders: onSetupTableColumnHeaders, - targets: targets.get - }; - }; - - var addButtons = function (editor, selections, selectionTargets, clipboard) { - editor.ui.registry.addMenuButton('table', { - tooltip: 'Table', - icon: 'table', - fetch: function (callback) { - return callback('inserttable | cell row column | advtablesort | tableprops deletetable'); - } - }); - var cmd = function (command) { - return function () { - return editor.execCommand(command); - }; - }; - editor.ui.registry.addButton('tableprops', { - tooltip: 'Table properties', - onAction: cmd('mceTableProps'), - icon: 'table', - onSetup: selectionTargets.onSetupTable - }); - editor.ui.registry.addButton('tabledelete', { - tooltip: 'Delete table', - onAction: cmd('mceTableDelete'), - icon: 'table-delete-table', - onSetup: selectionTargets.onSetupTable - }); - editor.ui.registry.addButton('tablecellprops', { - tooltip: 'Cell properties', - onAction: cmd('mceTableCellProps'), - icon: 'table-cell-properties', - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addButton('tablemergecells', { - tooltip: 'Merge cells', - onAction: cmd('mceTableMergeCells'), - icon: 'table-merge-cells', - onSetup: selectionTargets.onSetupMergeable - }); - editor.ui.registry.addButton('tablesplitcells', { - tooltip: 'Split cell', - onAction: cmd('mceTableSplitCells'), - icon: 'table-split-cells', - onSetup: selectionTargets.onSetupUnmergeable - }); - editor.ui.registry.addButton('tableinsertrowbefore', { - tooltip: 'Insert row before', - onAction: cmd('mceTableInsertRowBefore'), - icon: 'table-insert-row-above', - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addButton('tableinsertrowafter', { - tooltip: 'Insert row after', - onAction: cmd('mceTableInsertRowAfter'), - icon: 'table-insert-row-after', - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addButton('tabledeleterow', { - tooltip: 'Delete row', - onAction: cmd('mceTableDeleteRow'), - icon: 'table-delete-row', - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addButton('tablerowprops', { - tooltip: 'Row properties', - onAction: cmd('mceTableRowProps'), - icon: 'table-row-properties', - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addButton('tableinsertcolbefore', { - tooltip: 'Insert column before', - onAction: cmd('mceTableInsertColBefore'), - icon: 'table-insert-column-before', - onSetup: selectionTargets.onSetupColumn('onFirst') - }); - editor.ui.registry.addButton('tableinsertcolafter', { - tooltip: 'Insert column after', - onAction: cmd('mceTableInsertColAfter'), - icon: 'table-insert-column-after', - onSetup: selectionTargets.onSetupColumn('onLast') - }); - editor.ui.registry.addButton('tabledeletecol', { - tooltip: 'Delete column', - onAction: cmd('mceTableDeleteCol'), - icon: 'table-delete-column', - onSetup: selectionTargets.onSetupColumn('onAny') - }); - editor.ui.registry.addButton('tablecutrow', { - tooltip: 'Cut row', - icon: 'cut-row', - onAction: cmd('mceTableCutRow'), - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addButton('tablecopyrow', { - tooltip: 'Copy row', - icon: 'duplicate-row', - onAction: cmd('mceTableCopyRow'), - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addButton('tablepasterowbefore', { - tooltip: 'Paste row before', - icon: 'paste-row-before', - onAction: cmd('mceTablePasteRowBefore'), - onSetup: selectionTargets.onSetupPasteable(clipboard.getRows) - }); - editor.ui.registry.addButton('tablepasterowafter', { - tooltip: 'Paste row after', - icon: 'paste-row-after', - onAction: cmd('mceTablePasteRowAfter'), - onSetup: selectionTargets.onSetupPasteable(clipboard.getRows) - }); - editor.ui.registry.addButton('tablecutcol', { - tooltip: 'Cut column', - icon: 'cut-column', - onAction: cmd('mceTableCutCol'), - onSetup: selectionTargets.onSetupColumn('onAny') - }); - editor.ui.registry.addButton('tablecopycol', { - tooltip: 'Copy column', - icon: 'duplicate-column', - onAction: cmd('mceTableCopyCol'), - onSetup: selectionTargets.onSetupColumn('onAny') - }); - editor.ui.registry.addButton('tablepastecolbefore', { - tooltip: 'Paste column before', - icon: 'paste-column-before', - onAction: cmd('mceTablePasteColBefore'), - onSetup: selectionTargets.onSetupPasteableColumn(clipboard.getColumns, 'onFirst') - }); - editor.ui.registry.addButton('tablepastecolafter', { - tooltip: 'Paste column after', - icon: 'paste-column-after', - onAction: cmd('mceTablePasteColAfter'), - onSetup: selectionTargets.onSetupPasteableColumn(clipboard.getColumns, 'onLast') - }); - editor.ui.registry.addButton('tableinsertdialog', { - tooltip: 'Insert table', - onAction: cmd('mceInsertTable'), - icon: 'table' - }); - var tableClassList = filterNoneItem(getTableClassList(editor)); - if (tableClassList.length !== 0) { - editor.ui.registry.addMenuButton('tableclass', { - icon: 'table-classes', - tooltip: 'Table styles', - fetch: generateMenuItemsCallback(editor, selections, tableClassList, 'tableclass', function (value) { - return editor.execCommand('mceTableToggleClass', false, value); - }), - onSetup: selectionTargets.onSetupTable - }); - } - var tableCellClassList = filterNoneItem(getCellClassList(editor)); - if (tableCellClassList.length !== 0) { - editor.ui.registry.addMenuButton('tablecellclass', { - icon: 'table-cell-classes', - tooltip: 'Cell styles', - fetch: generateMenuItemsCallback(editor, selections, tableCellClassList, 'tablecellclass', function (value) { - return editor.execCommand('mceTableCellToggleClass', false, value); - }), - onSetup: selectionTargets.onSetupCellOrRow - }); - } - editor.ui.registry.addMenuButton('tablecellvalign', { - icon: 'vertical-align', - tooltip: 'Vertical align', - fetch: generateMenuItemsCallback(editor, selections, verticalAlignValues, 'tablecellverticalalign', applyTableCellStyle(editor, 'vertical-align')), - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addMenuButton('tablecellborderwidth', { - icon: 'border-width', - tooltip: 'Border width', - fetch: generateMenuItemsCallback(editor, selections, getTableBorderWidths(editor), 'tablecellborderwidth', applyTableCellStyle(editor, 'border-width')), - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addMenuButton('tablecellborderstyle', { - icon: 'border-style', - tooltip: 'Border style', - fetch: generateMenuItemsCallback(editor, selections, getTableBorderStyles(editor), 'tablecellborderstyle', applyTableCellStyle(editor, 'border-style')), - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addToggleButton('tablecaption', { - tooltip: 'Table caption', - onAction: cmd('mceTableToggleCaption'), - icon: 'table-caption', - onSetup: selectionTargets.onSetupTableWithCaption - }); - editor.ui.registry.addMenuButton('tablecellbackgroundcolor', { - icon: 'cell-background-color', - tooltip: 'Background color', - fetch: function (callback) { - return callback(buildColorMenu(editor, getTableBackgroundColorMap(editor), 'background-color')); - }, - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addMenuButton('tablecellbordercolor', { - icon: 'cell-border-color', - tooltip: 'Border color', - fetch: function (callback) { - return callback(buildColorMenu(editor, getTableBorderColorMap(editor), 'border-color')); - }, - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addToggleButton('tablerowheader', { - tooltip: 'Row header', - icon: 'table-top-header', - onAction: changeRowHeader(editor), - onSetup: selectionTargets.onSetupTableRowHeaders - }); - editor.ui.registry.addToggleButton('tablecolheader', { - tooltip: 'Column header', - icon: 'table-left-header', - onAction: changeColumnHeader(editor), - onSetup: selectionTargets.onSetupTableColumnHeaders - }); - }; - var addToolbars = function (editor) { - var isTable = function (table) { - return editor.dom.is(table, 'table') && editor.getBody().contains(table); - }; - var toolbar = getToolbar(editor); - if (toolbar.length > 0) { - editor.ui.registry.addContextToolbar('table', { - predicate: isTable, - items: toolbar, - scope: 'node', - position: 'node' - }); - } - }; - - var addMenuItems = function (editor, selections, selectionTargets, clipboard) { - var cmd = function (command) { - return function () { - return editor.execCommand(command); - }; - }; - var insertTableAction = function (data) { - editor.execCommand('mceInsertTable', false, { - rows: data.numRows, - columns: data.numColumns - }); - }; - var tableProperties = { - text: 'Table properties', - onSetup: selectionTargets.onSetupTable, - onAction: cmd('mceTableProps') - }; - var deleteTable = { - text: 'Delete table', - icon: 'table-delete-table', - onSetup: selectionTargets.onSetupTable, - onAction: cmd('mceTableDelete') - }; - editor.ui.registry.addMenuItem('tableinsertrowbefore', { - text: 'Insert row before', - icon: 'table-insert-row-above', - onAction: cmd('mceTableInsertRowBefore'), - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addMenuItem('tableinsertrowafter', { - text: 'Insert row after', - icon: 'table-insert-row-after', - onAction: cmd('mceTableInsertRowAfter'), - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addMenuItem('tabledeleterow', { - text: 'Delete row', - icon: 'table-delete-row', - onAction: cmd('mceTableDeleteRow'), - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addMenuItem('tablerowprops', { - text: 'Row properties', - icon: 'table-row-properties', - onAction: cmd('mceTableRowProps'), - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addMenuItem('tablecutrow', { - text: 'Cut row', - icon: 'cut-row', - onAction: cmd('mceTableCutRow'), - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addMenuItem('tablecopyrow', { - text: 'Copy row', - icon: 'duplicate-row', - onAction: cmd('mceTableCopyRow'), - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addMenuItem('tablepasterowbefore', { - text: 'Paste row before', - icon: 'paste-row-before', - onAction: cmd('mceTablePasteRowBefore'), - onSetup: selectionTargets.onSetupPasteable(clipboard.getRows) - }); - editor.ui.registry.addMenuItem('tablepasterowafter', { - text: 'Paste row after', - icon: 'paste-row-after', - onAction: cmd('mceTablePasteRowAfter'), - onSetup: selectionTargets.onSetupPasteable(clipboard.getRows) - }); - var row = { - type: 'nestedmenuitem', - text: 'Row', - getSubmenuItems: constant('tableinsertrowbefore tableinsertrowafter tabledeleterow tablerowprops | tablecutrow tablecopyrow tablepasterowbefore tablepasterowafter') - }; - editor.ui.registry.addMenuItem('tableinsertcolumnbefore', { - text: 'Insert column before', - icon: 'table-insert-column-before', - onAction: cmd('mceTableInsertColBefore'), - onSetup: selectionTargets.onSetupColumn('onFirst') - }); - editor.ui.registry.addMenuItem('tableinsertcolumnafter', { - text: 'Insert column after', - icon: 'table-insert-column-after', - onAction: cmd('mceTableInsertColAfter'), - onSetup: selectionTargets.onSetupColumn('onLast') - }); - editor.ui.registry.addMenuItem('tabledeletecolumn', { - text: 'Delete column', - icon: 'table-delete-column', - onAction: cmd('mceTableDeleteCol'), - onSetup: selectionTargets.onSetupColumn('onAny') - }); - editor.ui.registry.addMenuItem('tablecutcolumn', { - text: 'Cut column', - icon: 'cut-column', - onAction: cmd('mceTableCutCol'), - onSetup: selectionTargets.onSetupColumn('onAny') - }); - editor.ui.registry.addMenuItem('tablecopycolumn', { - text: 'Copy column', - icon: 'duplicate-column', - onAction: cmd('mceTableCopyCol'), - onSetup: selectionTargets.onSetupColumn('onAny') - }); - editor.ui.registry.addMenuItem('tablepastecolumnbefore', { - text: 'Paste column before', - icon: 'paste-column-before', - onAction: cmd('mceTablePasteColBefore'), - onSetup: selectionTargets.onSetupPasteableColumn(clipboard.getColumns, 'onFirst') - }); - editor.ui.registry.addMenuItem('tablepastecolumnafter', { - text: 'Paste column after', - icon: 'paste-column-after', - onAction: cmd('mceTablePasteColAfter'), - onSetup: selectionTargets.onSetupPasteableColumn(clipboard.getColumns, 'onLast') - }); - var column = { - type: 'nestedmenuitem', - text: 'Column', - getSubmenuItems: constant('tableinsertcolumnbefore tableinsertcolumnafter tabledeletecolumn | tablecutcolumn tablecopycolumn tablepastecolumnbefore tablepastecolumnafter') - }; - editor.ui.registry.addMenuItem('tablecellprops', { - text: 'Cell properties', - icon: 'table-cell-properties', - onAction: cmd('mceTableCellProps'), - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addMenuItem('tablemergecells', { - text: 'Merge cells', - icon: 'table-merge-cells', - onAction: cmd('mceTableMergeCells'), - onSetup: selectionTargets.onSetupMergeable - }); - editor.ui.registry.addMenuItem('tablesplitcells', { - text: 'Split cell', - icon: 'table-split-cells', - onAction: cmd('mceTableSplitCells'), - onSetup: selectionTargets.onSetupUnmergeable - }); - var cell = { - type: 'nestedmenuitem', - text: 'Cell', - getSubmenuItems: constant('tablecellprops tablemergecells tablesplitcells') - }; - if (hasTableGrid(editor) === false) { - editor.ui.registry.addMenuItem('inserttable', { - text: 'Table', - icon: 'table', - onAction: cmd('mceInsertTable') - }); - } else { - editor.ui.registry.addNestedMenuItem('inserttable', { - text: 'Table', - icon: 'table', - getSubmenuItems: function () { - return [{ - type: 'fancymenuitem', - fancytype: 'inserttable', - onAction: insertTableAction - }]; - } - }); - } - editor.ui.registry.addMenuItem('inserttabledialog', { - text: 'Insert table', - icon: 'table', - onAction: cmd('mceInsertTable') - }); - editor.ui.registry.addMenuItem('tableprops', tableProperties); - editor.ui.registry.addMenuItem('deletetable', deleteTable); - editor.ui.registry.addNestedMenuItem('row', row); - editor.ui.registry.addNestedMenuItem('column', column); - editor.ui.registry.addNestedMenuItem('cell', cell); - editor.ui.registry.addContextMenu('table', { - update: function () { - selectionTargets.resetTargets(); - return selectionTargets.targets().fold(constant(''), function (targets) { - if (name(targets.element) === 'caption') { - return 'tableprops deletetable'; - } else { - return 'cell row column | advtablesort | tableprops deletetable'; - } - }); - } - }); - var tableClassList = filterNoneItem(getTableClassList(editor)); - if (tableClassList.length !== 0) { - editor.ui.registry.addNestedMenuItem('tableclass', { - icon: 'table-classes', - text: 'Table styles', - getSubmenuItems: function () { - return buildMenuItems(editor, selections, tableClassList, 'tableclass', function (value) { - return editor.execCommand('mceTableToggleClass', false, value); - }); - }, - onSetup: selectionTargets.onSetupTable - }); - } - var tableCellClassList = filterNoneItem(getCellClassList(editor)); - if (tableCellClassList.length !== 0) { - editor.ui.registry.addNestedMenuItem('tablecellclass', { - icon: 'table-cell-classes', - text: 'Cell styles', - getSubmenuItems: function () { - return buildMenuItems(editor, selections, tableCellClassList, 'tablecellclass', function (value) { - return editor.execCommand('mceTableCellToggleClass', false, value); - }); - }, - onSetup: selectionTargets.onSetupCellOrRow - }); - } - editor.ui.registry.addNestedMenuItem('tablecellvalign', { - icon: 'vertical-align', - text: 'Vertical align', - getSubmenuItems: function () { - return buildMenuItems(editor, selections, verticalAlignValues, 'tablecellverticalalign', applyTableCellStyle(editor, 'vertical-align')); - }, - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addNestedMenuItem('tablecellborderwidth', { - icon: 'border-width', - text: 'Border width', - getSubmenuItems: function () { - return buildMenuItems(editor, selections, getTableBorderWidths(editor), 'tablecellborderwidth', applyTableCellStyle(editor, 'border-width')); - }, - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addNestedMenuItem('tablecellborderstyle', { - icon: 'border-style', - text: 'Border style', - getSubmenuItems: function () { - return buildMenuItems(editor, selections, getTableBorderStyles(editor), 'tablecellborderstyle', applyTableCellStyle(editor, 'border-style')); - }, - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addToggleMenuItem('tablecaption', { - icon: 'table-caption', - text: 'Table caption', - onAction: cmd('mceTableToggleCaption'), - onSetup: selectionTargets.onSetupTableWithCaption - }); - editor.ui.registry.addNestedMenuItem('tablecellbackgroundcolor', { - icon: 'cell-background-color', - text: 'Background color', - getSubmenuItems: function () { - return buildColorMenu(editor, getTableBackgroundColorMap(editor), 'background-color'); - }, - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addNestedMenuItem('tablecellbordercolor', { - icon: 'cell-border-color', - text: 'Border color', - getSubmenuItems: function () { - return buildColorMenu(editor, getTableBorderColorMap(editor), 'border-color'); - }, - onSetup: selectionTargets.onSetupCellOrRow - }); - editor.ui.registry.addToggleMenuItem('tablerowheader', { - text: 'Row header', - icon: 'table-top-header', - onAction: changeRowHeader(editor), - onSetup: selectionTargets.onSetupTableRowHeaders - }); - editor.ui.registry.addToggleMenuItem('tablecolheader', { - text: 'Column header', - icon: 'table-left-header', - onAction: changeColumnHeader(editor), - onSetup: selectionTargets.onSetupTableColumnHeaders - }); - }; - - var Plugin = function (editor) { - var selections = Selections(function () { - return getBody(editor); - }, function () { - return getSelectionCell(getSelectionStart(editor), getIsRoot(editor)); - }, ephemera.selectedSelector); - var selectionTargets = getSelectionTargets(editor, selections); - var resizeHandler = getResizeHandler(editor); - var cellSelection = CellSelection(editor, resizeHandler.lazyResize, selectionTargets); - var actions = TableActions(editor, cellSelection, resizeHandler.lazyWire); - var clipboard = Clipboard(); - registerCommands(editor, actions, cellSelection, selections, clipboard); - registerQueryCommands(editor, actions, selections); - registerEvents(editor, selections, actions); - addMenuItems(editor, selections, selectionTargets, clipboard); - addButtons(editor, selections, selectionTargets, clipboard); - addToolbars(editor); - editor.on('PreInit', function () { - editor.serializer.addTempAttr(ephemera.firstSelected); - editor.serializer.addTempAttr(ephemera.lastSelected); - registerFormats(editor); - }); - if (hasTabNavigation(editor)) { - editor.on('keydown', function (e) { - handle$1(e, editor, cellSelection); - }); - } - editor.on('remove', function () { - resizeHandler.destroy(); - }); - return getApi(editor, clipboard, resizeHandler, selectionTargets); - }; - function Plugin$1 () { - global$3.add('table', Plugin); - } - - Plugin$1(); - -}()); - -/** - * Copyright (c) Tiny Technologies, Inc. All rights reserved. - * Licensed under the LGPL or a commercial license. - * For LGPL see License.txt in the project root for license information. - * For commercial licenses see https://www.tiny.cloud/ - * - * Version: 5.10.5 (2022-05-25) - */ -(function () { - 'use strict'; - - var global$4 = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - var typeOf = function (x) { - var t = typeof x; - if (x === null) { - return 'null'; - } else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) { - return 'array'; - } else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) { - return 'string'; - } else { - return t; - } - }; - var isType = function (type) { - return function (value) { - return typeOf(value) === type; - }; - }; - var isSimpleType = function (type) { - return function (value) { - return typeof value === type; - }; - }; - var isString = isType('string'); - var isFunction = isSimpleType('function'); - - var noop = function () { - }; - var constant = function (value) { - return function () { - return value; - }; - }; - var identity = function (x) { - return x; - }; - function curry(fn) { - var initialArgs = []; - for (var _i = 1; _i < arguments.length; _i++) { - initialArgs[_i - 1] = arguments[_i]; - } - return function () { - var restArgs = []; - for (var _i = 0; _i < arguments.length; _i++) { - restArgs[_i] = arguments[_i]; - } - var all = initialArgs.concat(restArgs); - return fn.apply(null, all); - }; - } - var never = constant(false); - var always = constant(true); - - var global$3 = tinymce.util.Tools.resolve('tinymce.util.Tools'); - - var global$2 = tinymce.util.Tools.resolve('tinymce.util.XHR'); - - var getCreationDateClasses = function (editor) { - return editor.getParam('template_cdate_classes', 'cdate'); - }; - var getModificationDateClasses = function (editor) { - return editor.getParam('template_mdate_classes', 'mdate'); - }; - var getSelectedContentClasses = function (editor) { - return editor.getParam('template_selected_content_classes', 'selcontent'); - }; - var getPreviewReplaceValues = function (editor) { - return editor.getParam('template_preview_replace_values'); - }; - var getContentStyle = function (editor) { - return editor.getParam('content_style', '', 'string'); - }; - var shouldUseContentCssCors = function (editor) { - return editor.getParam('content_css_cors', false, 'boolean'); - }; - var getTemplateReplaceValues = function (editor) { - return editor.getParam('template_replace_values'); - }; - var getTemplates = function (editor) { - return editor.getParam('templates'); - }; - var getCdateFormat = function (editor) { - return editor.getParam('template_cdate_format', editor.translate('%Y-%m-%d')); - }; - var getMdateFormat = function (editor) { - return editor.getParam('template_mdate_format', editor.translate('%Y-%m-%d')); - }; - var getBodyClassFromHash = function (editor) { - var bodyClass = editor.getParam('body_class', '', 'hash'); - return bodyClass[editor.id] || ''; - }; - var getBodyClass = function (editor) { - var bodyClass = editor.getParam('body_class', '', 'string'); - if (bodyClass.indexOf('=') === -1) { - return bodyClass; - } else { - return getBodyClassFromHash(editor); - } - }; - - var addZeros = function (value, len) { - value = '' + value; - if (value.length < len) { - for (var i = 0; i < len - value.length; i++) { - value = '0' + value; - } - } - return value; - }; - var getDateTime = function (editor, fmt, date) { - if (date === void 0) { - date = new Date(); - } - var daysShort = 'Sun Mon Tue Wed Thu Fri Sat Sun'.split(' '); - var daysLong = 'Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday'.split(' '); - var monthsShort = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' '); - var monthsLong = 'January February March April May June July August September October November December'.split(' '); - fmt = fmt.replace('%D', '%m/%d/%Y'); - fmt = fmt.replace('%r', '%I:%M:%S %p'); - fmt = fmt.replace('%Y', '' + date.getFullYear()); - fmt = fmt.replace('%y', '' + date.getYear()); - fmt = fmt.replace('%m', addZeros(date.getMonth() + 1, 2)); - fmt = fmt.replace('%d', addZeros(date.getDate(), 2)); - fmt = fmt.replace('%H', '' + addZeros(date.getHours(), 2)); - fmt = fmt.replace('%M', '' + addZeros(date.getMinutes(), 2)); - fmt = fmt.replace('%S', '' + addZeros(date.getSeconds(), 2)); - fmt = fmt.replace('%I', '' + ((date.getHours() + 11) % 12 + 1)); - fmt = fmt.replace('%p', '' + (date.getHours() < 12 ? 'AM' : 'PM')); - fmt = fmt.replace('%B', '' + editor.translate(monthsLong[date.getMonth()])); - fmt = fmt.replace('%b', '' + editor.translate(monthsShort[date.getMonth()])); - fmt = fmt.replace('%A', '' + editor.translate(daysLong[date.getDay()])); - fmt = fmt.replace('%a', '' + editor.translate(daysShort[date.getDay()])); - fmt = fmt.replace('%%', '%'); - return fmt; - }; - - var createTemplateList = function (editor, callback) { - return function () { - var templateList = getTemplates(editor); - if (isFunction(templateList)) { - templateList(callback); - } else if (isString(templateList)) { - global$2.send({ - url: templateList, - success: function (text) { - callback(JSON.parse(text)); - } - }); - } else { - callback(templateList); - } - }; - }; - var replaceTemplateValues = function (html, templateValues) { - global$3.each(templateValues, function (v, k) { - if (isFunction(v)) { - v = v(k); - } - html = html.replace(new RegExp('\\{\\$' + k + '\\}', 'g'), v); - }); - return html; - }; - var replaceVals = function (editor, scope) { - var dom = editor.dom, vl = getTemplateReplaceValues(editor); - global$3.each(dom.select('*', scope), function (e) { - global$3.each(vl, function (v, k) { - if (dom.hasClass(e, k)) { - if (isFunction(v)) { - v(e); - } - } - }); - }); - }; - var hasClass = function (n, c) { - return new RegExp('\\b' + c + '\\b', 'g').test(n.className); - }; - var insertTemplate = function (editor, _ui, html) { - var dom = editor.dom; - var sel = editor.selection.getContent(); - html = replaceTemplateValues(html, getTemplateReplaceValues(editor)); - var el = dom.create('div', null, html); - var n = dom.select('.mceTmpl', el); - if (n && n.length > 0) { - el = dom.create('div', null); - el.appendChild(n[0].cloneNode(true)); - } - global$3.each(dom.select('*', el), function (n) { - if (hasClass(n, getCreationDateClasses(editor).replace(/\s+/g, '|'))) { - n.innerHTML = getDateTime(editor, getCdateFormat(editor)); - } - if (hasClass(n, getModificationDateClasses(editor).replace(/\s+/g, '|'))) { - n.innerHTML = getDateTime(editor, getMdateFormat(editor)); - } - if (hasClass(n, getSelectedContentClasses(editor).replace(/\s+/g, '|'))) { - n.innerHTML = sel; - } - }); - replaceVals(editor, el); - editor.execCommand('mceInsertContent', false, el.innerHTML); - editor.addVisual(); - }; - - var none = function () { - return NONE; - }; - var NONE = function () { - var call = function (thunk) { - return thunk(); - }; - var id = identity; - var me = { - fold: function (n, _s) { - return n(); - }, - isSome: never, - isNone: always, - getOr: id, - getOrThunk: call, - getOrDie: function (msg) { - throw new Error(msg || 'error: getOrDie called on none.'); - }, - getOrNull: constant(null), - getOrUndefined: constant(undefined), - or: id, - orThunk: call, - map: none, - each: noop, - bind: none, - exists: never, - forall: always, - filter: function () { - return none(); - }, - toArray: function () { - return []; - }, - toString: constant('none()') - }; - return me; - }(); - var some = function (a) { - var constant_a = constant(a); - var self = function () { - return me; - }; - var bind = function (f) { - return f(a); - }; - var me = { - fold: function (n, s) { - return s(a); - }, - isSome: always, - isNone: never, - getOr: constant_a, - getOrThunk: constant_a, - getOrDie: constant_a, - getOrNull: constant_a, - getOrUndefined: constant_a, - or: self, - orThunk: self, - map: function (f) { - return some(f(a)); - }, - each: function (f) { - f(a); - }, - bind: bind, - exists: bind, - forall: bind, - filter: function (f) { - return f(a) ? me : NONE; - }, - toArray: function () { - return [a]; - }, - toString: function () { - return 'some(' + a + ')'; - } - }; - return me; - }; - var from = function (value) { - return value === null || value === undefined ? NONE : some(value); - }; - var Optional = { - some: some, - none: none, - from: from - }; - - var map = function (xs, f) { - var len = xs.length; - var r = new Array(len); - for (var i = 0; i < len; i++) { - var x = xs[i]; - r[i] = f(x, i); - } - return r; - }; - var findUntil = function (xs, pred, until) { - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - if (pred(x, i)) { - return Optional.some(x); - } else if (until(x, i)) { - break; - } - } - return Optional.none(); - }; - var find = function (xs, pred) { - return findUntil(xs, pred, never); - }; - - var global$1 = tinymce.util.Tools.resolve('tinymce.Env'); - - var global = tinymce.util.Tools.resolve('tinymce.util.Promise'); - - var hasOwnProperty = Object.hasOwnProperty; - var get = function (obj, key) { - return has(obj, key) ? Optional.from(obj[key]) : Optional.none(); - }; - var has = function (obj, key) { - return hasOwnProperty.call(obj, key); - }; - - var entitiesAttr = { - '"': '"', - '<': '<', - '>': '>', - '&': '&', - '\'': ''' - }; - var htmlEscape = function (html) { - return html.replace(/["'<>&]/g, function (match) { - return get(entitiesAttr, match).getOr(match); - }); - }; - - var getPreviewContent = function (editor, html) { - if (html.indexOf('') === -1) { - var contentCssEntries_1 = ''; - var contentStyle = getContentStyle(editor); - var cors_1 = shouldUseContentCssCors(editor) ? ' crossorigin="anonymous"' : ''; - global$3.each(editor.contentCSS, function (url) { - contentCssEntries_1 += ''; - }); - if (contentStyle) { - contentCssEntries_1 += ''; - } - var bodyClass = getBodyClass(editor); - var encode = editor.dom.encode; - var isMetaKeyPressed = global$1.mac ? 'e.metaKey' : 'e.ctrlKey && !e.altKey'; - var preventClicksOnLinksScript = ' '; - var directionality = editor.getBody().dir; - var dirAttr = directionality ? ' dir="' + encode(directionality) + '"' : ''; - html = '' + '' + '' + '' + contentCssEntries_1 + preventClicksOnLinksScript + '' + '' + html + '' + ''; - } - return replaceTemplateValues(html, getPreviewReplaceValues(editor)); - }; - var open = function (editor, templateList) { - var createTemplates = function () { - if (!templateList || templateList.length === 0) { - var message = editor.translate('No templates defined.'); - editor.notificationManager.open({ - text: message, - type: 'info' - }); - return Optional.none(); - } - return Optional.from(global$3.map(templateList, function (template, index) { - var isUrlTemplate = function (t) { - return t.url !== undefined; - }; - return { - selected: index === 0, - text: template.title, - value: { - url: isUrlTemplate(template) ? Optional.from(template.url) : Optional.none(), - content: !isUrlTemplate(template) ? Optional.from(template.content) : Optional.none(), - description: template.description - } - }; - })); - }; - var createSelectBoxItems = function (templates) { - return map(templates, function (t) { - return { - text: t.text, - value: t.text - }; - }); - }; - var findTemplate = function (templates, templateTitle) { - return find(templates, function (t) { - return t.text === templateTitle; - }); - }; - var loadFailedAlert = function (api) { - editor.windowManager.alert('Could not load the specified template.', function () { - return api.focus('template'); - }); - }; - var getTemplateContent = function (t) { - return new global(function (resolve, reject) { - t.value.url.fold(function () { - return resolve(t.value.content.getOr('')); - }, function (url) { - return global$2.send({ - url: url, - success: function (html) { - resolve(html); - }, - error: function (e) { - reject(e); - } - }); - }); - }); - }; - var onChange = function (templates, updateDialog) { - return function (api, change) { - if (change.name === 'template') { - var newTemplateTitle = api.getData().template; - findTemplate(templates, newTemplateTitle).each(function (t) { - api.block('Loading...'); - getTemplateContent(t).then(function (previewHtml) { - updateDialog(api, t, previewHtml); - }).catch(function () { - updateDialog(api, t, ''); - api.disable('save'); - loadFailedAlert(api); - }); - }); - } - }; - }; - var onSubmit = function (templates) { - return function (api) { - var data = api.getData(); - findTemplate(templates, data.template).each(function (t) { - getTemplateContent(t).then(function (previewHtml) { - editor.execCommand('mceInsertTemplate', false, previewHtml); - api.close(); - }).catch(function () { - api.disable('save'); - loadFailedAlert(api); - }); - }); - }; - }; - var openDialog = function (templates) { - var selectBoxItems = createSelectBoxItems(templates); - var buildDialogSpec = function (bodyItems, initialData) { - return { - title: 'Insert Template', - size: 'large', - body: { - type: 'panel', - items: bodyItems - }, - initialData: initialData, - buttons: [ - { - type: 'cancel', - name: 'cancel', - text: 'Cancel' - }, - { - type: 'submit', - name: 'save', - text: 'Save', - primary: true - } - ], - onSubmit: onSubmit(templates), - onChange: onChange(templates, updateDialog) - }; - }; - var updateDialog = function (dialogApi, template, previewHtml) { - var content = getPreviewContent(editor, previewHtml); - var bodyItems = [ - { - type: 'selectbox', - name: 'template', - label: 'Templates', - items: selectBoxItems - }, - { - type: 'htmlpanel', - html: '

' + htmlEscape(template.value.description) + '

' - }, - { - label: 'Preview', - type: 'iframe', - name: 'preview', - sandboxed: false - } - ]; - var initialData = { - template: template.text, - preview: content - }; - dialogApi.unblock(); - dialogApi.redial(buildDialogSpec(bodyItems, initialData)); - dialogApi.focus('template'); - }; - var dialogApi = editor.windowManager.open(buildDialogSpec([], { - template: '', - preview: '' - })); - dialogApi.block('Loading...'); - getTemplateContent(templates[0]).then(function (previewHtml) { - updateDialog(dialogApi, templates[0], previewHtml); - }).catch(function () { - updateDialog(dialogApi, templates[0], ''); - dialogApi.disable('save'); - loadFailedAlert(dialogApi); - }); - }; - var optTemplates = createTemplates(); - optTemplates.each(openDialog); - }; - - var showDialog = function (editor) { - return function (templates) { - open(editor, templates); - }; - }; - var register$1 = function (editor) { - editor.addCommand('mceInsertTemplate', curry(insertTemplate, editor)); - editor.addCommand('mceTemplate', createTemplateList(editor, showDialog(editor))); - }; - - var setup = function (editor) { - editor.on('PreProcess', function (o) { - var dom = editor.dom, dateFormat = getMdateFormat(editor); - global$3.each(dom.select('div', o.node), function (e) { - if (dom.hasClass(e, 'mceTmpl')) { - global$3.each(dom.select('*', e), function (e) { - if (dom.hasClass(e, getModificationDateClasses(editor).replace(/\s+/g, '|'))) { - e.innerHTML = getDateTime(editor, dateFormat); - } - }); - replaceVals(editor, e); - } - }); - }); - }; - - var register = function (editor) { - var onAction = function () { - return editor.execCommand('mceTemplate'); - }; - editor.ui.registry.addButton('template', { - icon: 'template', - tooltip: 'Insert template', - onAction: onAction - }); - editor.ui.registry.addMenuItem('template', { - icon: 'template', - text: 'Insert template...', - onAction: onAction - }); - }; - - function Plugin () { - global$4.add('template', function (editor) { - register(editor); - register$1(editor); - setup(editor); - }); - } - - Plugin(); - -}()); - -/** - * Copyright (c) Tiny Technologies, Inc. All rights reserved. - * Licensed under the LGPL or a commercial license. - * For LGPL see License.txt in the project root for license information. - * For commercial licenses see https://www.tiny.cloud/ - * - * Version: 5.10.5 (2022-05-25) - */ -(function () { - 'use strict'; - - var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - function Plugin () { - global.add('textcolor', function () { - }); - } - - Plugin(); - -}()); - -/** - * Copyright (c) Tiny Technologies, Inc. All rights reserved. - * Licensed under the LGPL or a commercial license. - * For LGPL see License.txt in the project root for license information. - * For commercial licenses see https://www.tiny.cloud/ - * - * Version: 5.10.5 (2022-05-25) - */ -(function () { - 'use strict'; - - var Cell = function (initial) { - var value = initial; - var get = function () { - return value; - }; - var set = function (v) { - value = v; - }; - return { - get: get, - set: set - }; - }; - - var global$5 = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - var __assign = function () { - __assign = Object.assign || function __assign(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) - if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); - }; - function __spreadArray(to, from, pack) { - if (pack || arguments.length === 2) - for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) - ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); - } - - var typeOf = function (x) { - var t = typeof x; - if (x === null) { - return 'null'; - } else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) { - return 'array'; - } else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) { - return 'string'; - } else { - return t; - } - }; - var isType = function (type) { - return function (value) { - return typeOf(value) === type; - }; - }; - var isString = isType('string'); - var isObject = isType('object'); - var isArray = isType('array'); - - var noop = function () { - }; - var constant = function (value) { - return function () { - return value; - }; - }; - var identity = function (x) { - return x; - }; - var die = function (msg) { - return function () { - throw new Error(msg); - }; - }; - var never = constant(false); - var always = constant(true); - - var none = function () { - return NONE; - }; - var NONE = function () { - var call = function (thunk) { - return thunk(); - }; - var id = identity; - var me = { - fold: function (n, _s) { - return n(); - }, - isSome: never, - isNone: always, - getOr: id, - getOrThunk: call, - getOrDie: function (msg) { - throw new Error(msg || 'error: getOrDie called on none.'); - }, - getOrNull: constant(null), - getOrUndefined: constant(undefined), - or: id, - orThunk: call, - map: none, - each: noop, - bind: none, - exists: never, - forall: always, - filter: function () { - return none(); - }, - toArray: function () { - return []; - }, - toString: constant('none()') - }; - return me; - }(); - var some = function (a) { - var constant_a = constant(a); - var self = function () { - return me; - }; - var bind = function (f) { - return f(a); - }; - var me = { - fold: function (n, s) { - return s(a); - }, - isSome: always, - isNone: never, - getOr: constant_a, - getOrThunk: constant_a, - getOrDie: constant_a, - getOrNull: constant_a, - getOrUndefined: constant_a, - or: self, - orThunk: self, - map: function (f) { - return some(f(a)); - }, - each: function (f) { - f(a); - }, - bind: bind, - exists: bind, - forall: bind, - filter: function (f) { - return f(a) ? me : NONE; - }, - toArray: function () { - return [a]; - }, - toString: function () { - return 'some(' + a + ')'; - } - }; - return me; - }; - var from = function (value) { - return value === null || value === undefined ? NONE : some(value); - }; - var Optional = { - some: some, - none: none, - from: from - }; - - var nativeSlice = Array.prototype.slice; - var nativeIndexOf = Array.prototype.indexOf; - var rawIndexOf = function (ts, t) { - return nativeIndexOf.call(ts, t); - }; - var contains = function (xs, x) { - return rawIndexOf(xs, x) > -1; - }; - var map = function (xs, f) { - var len = xs.length; - var r = new Array(len); - for (var i = 0; i < len; i++) { - var x = xs[i]; - r[i] = f(x, i); - } - return r; - }; - var each = function (xs, f) { - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - f(x, i); - } - }; - var eachr = function (xs, f) { - for (var i = xs.length - 1; i >= 0; i--) { - var x = xs[i]; - f(x, i); - } - }; - var filter = function (xs, pred) { - var r = []; - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - if (pred(x, i)) { - r.push(x); - } - } - return r; - }; - var foldr = function (xs, f, acc) { - eachr(xs, function (x, i) { - acc = f(acc, x, i); - }); - return acc; - }; - var foldl = function (xs, f, acc) { - each(xs, function (x, i) { - acc = f(acc, x, i); - }); - return acc; - }; - var findUntil = function (xs, pred, until) { - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - if (pred(x, i)) { - return Optional.some(x); - } else if (until(x, i)) { - break; - } - } - return Optional.none(); - }; - var find = function (xs, pred) { - return findUntil(xs, pred, never); - }; - var forall = function (xs, pred) { - for (var i = 0, len = xs.length; i < len; ++i) { - var x = xs[i]; - if (pred(x, i) !== true) { - return false; - } - } - return true; - }; - var sort = function (xs, comparator) { - var copy = nativeSlice.call(xs, 0); - copy.sort(comparator); - return copy; - }; - var get$1 = function (xs, i) { - return i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none(); - }; - var head = function (xs) { - return get$1(xs, 0); - }; - - var keys = Object.keys; - var hasOwnProperty = Object.hasOwnProperty; - var has = function (obj, key) { - return hasOwnProperty.call(obj, key); - }; - - var generate$1 = function (cases) { - if (!isArray(cases)) { - throw new Error('cases must be an array'); - } - if (cases.length === 0) { - throw new Error('there must be at least one case'); - } - var constructors = []; - var adt = {}; - each(cases, function (acase, count) { - var keys$1 = keys(acase); - if (keys$1.length !== 1) { - throw new Error('one and only one name per case'); - } - var key = keys$1[0]; - var value = acase[key]; - if (adt[key] !== undefined) { - throw new Error('duplicate key detected:' + key); - } else if (key === 'cata') { - throw new Error('cannot have a case named cata (sorry)'); - } else if (!isArray(value)) { - throw new Error('case arguments must be an array'); - } - constructors.push(key); - adt[key] = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var argLength = args.length; - if (argLength !== value.length) { - throw new Error('Wrong number of arguments to case ' + key + '. Expected ' + value.length + ' (' + value + '), got ' + argLength); - } - var match = function (branches) { - var branchKeys = keys(branches); - if (constructors.length !== branchKeys.length) { - throw new Error('Wrong number of arguments to match. Expected: ' + constructors.join(',') + '\nActual: ' + branchKeys.join(',')); - } - var allReqd = forall(constructors, function (reqKey) { - return contains(branchKeys, reqKey); - }); - if (!allReqd) { - throw new Error('Not all branches were specified when using match. Specified: ' + branchKeys.join(', ') + '\nRequired: ' + constructors.join(', ')); - } - return branches[key].apply(null, args); - }; - return { - fold: function () { - var foldArgs = []; - for (var _i = 0; _i < arguments.length; _i++) { - foldArgs[_i] = arguments[_i]; - } - if (foldArgs.length !== cases.length) { - throw new Error('Wrong number of arguments to fold. Expected ' + cases.length + ', got ' + foldArgs.length); - } - var target = foldArgs[count]; - return target.apply(null, args); - }, - match: match, - log: function (label) { - console.log(label, { - constructors: constructors, - constructor: key, - params: args - }); - } - }; - }; - }); - return adt; - }; - var Adt = { generate: generate$1 }; - - Adt.generate([ - { - bothErrors: [ - 'error1', - 'error2' - ] - }, - { - firstError: [ - 'error1', - 'value2' - ] - }, - { - secondError: [ - 'value1', - 'error2' - ] - }, - { - bothValues: [ - 'value1', - 'value2' - ] - } - ]); - var partition = function (results) { - var errors = []; - var values = []; - each(results, function (result) { - result.fold(function (err) { - errors.push(err); - }, function (value) { - values.push(value); - }); - }); - return { - errors: errors, - values: values - }; - }; - - var value = function (o) { - var or = function (_opt) { - return value(o); - }; - var orThunk = function (_f) { - return value(o); - }; - var map = function (f) { - return value(f(o)); - }; - var mapError = function (_f) { - return value(o); - }; - var each = function (f) { - f(o); - }; - var bind = function (f) { - return f(o); - }; - var fold = function (_, onValue) { - return onValue(o); - }; - var exists = function (f) { - return f(o); - }; - var forall = function (f) { - return f(o); - }; - var toOptional = function () { - return Optional.some(o); - }; - return { - isValue: always, - isError: never, - getOr: constant(o), - getOrThunk: constant(o), - getOrDie: constant(o), - or: or, - orThunk: orThunk, - fold: fold, - map: map, - mapError: mapError, - each: each, - bind: bind, - exists: exists, - forall: forall, - toOptional: toOptional - }; - }; - var error$1 = function (message) { - var getOrThunk = function (f) { - return f(); - }; - var getOrDie = function () { - return die(String(message))(); - }; - var or = identity; - var orThunk = function (f) { - return f(); - }; - var map = function (_f) { - return error$1(message); - }; - var mapError = function (f) { - return error$1(f(message)); - }; - var bind = function (_f) { - return error$1(message); - }; - var fold = function (onError, _) { - return onError(message); - }; - return { - isValue: never, - isError: always, - getOr: identity, - getOrThunk: getOrThunk, - getOrDie: getOrDie, - or: or, - orThunk: orThunk, - fold: fold, - map: map, - mapError: mapError, - each: noop, - bind: bind, - exists: never, - forall: always, - toOptional: Optional.none - }; - }; - var fromOption = function (opt, err) { - return opt.fold(function () { - return error$1(err); - }, value); - }; - var Result = { - value: value, - error: error$1, - fromOption: fromOption - }; - - var isInlinePattern = function (pattern) { - return pattern.type === 'inline-command' || pattern.type === 'inline-format'; - }; - var isBlockPattern = function (pattern) { - return pattern.type === 'block-command' || pattern.type === 'block-format'; - }; - var sortPatterns = function (patterns) { - return sort(patterns, function (a, b) { - if (a.start.length === b.start.length) { - return 0; - } - return a.start.length > b.start.length ? -1 : 1; - }); - }; - var normalizePattern = function (pattern) { - var err = function (message) { - return Result.error({ - message: message, - pattern: pattern - }); - }; - var formatOrCmd = function (name, onFormat, onCommand) { - if (pattern.format !== undefined) { - var formats = void 0; - if (isArray(pattern.format)) { - if (!forall(pattern.format, isString)) { - return err(name + ' pattern has non-string items in the `format` array'); - } - formats = pattern.format; - } else if (isString(pattern.format)) { - formats = [pattern.format]; - } else { - return err(name + ' pattern has non-string `format` parameter'); - } - return Result.value(onFormat(formats)); - } else if (pattern.cmd !== undefined) { - if (!isString(pattern.cmd)) { - return err(name + ' pattern has non-string `cmd` parameter'); - } - return Result.value(onCommand(pattern.cmd, pattern.value)); - } else { - return err(name + ' pattern is missing both `format` and `cmd` parameters'); - } - }; - if (!isObject(pattern)) { - return err('Raw pattern is not an object'); - } - if (!isString(pattern.start)) { - return err('Raw pattern is missing `start` parameter'); - } - if (pattern.end !== undefined) { - if (!isString(pattern.end)) { - return err('Inline pattern has non-string `end` parameter'); - } - if (pattern.start.length === 0 && pattern.end.length === 0) { - return err('Inline pattern has empty `start` and `end` parameters'); - } - var start_1 = pattern.start; - var end_1 = pattern.end; - if (end_1.length === 0) { - end_1 = start_1; - start_1 = ''; - } - return formatOrCmd('Inline', function (format) { - return { - type: 'inline-format', - start: start_1, - end: end_1, - format: format - }; - }, function (cmd, value) { - return { - type: 'inline-command', - start: start_1, - end: end_1, - cmd: cmd, - value: value - }; - }); - } else if (pattern.replacement !== undefined) { - if (!isString(pattern.replacement)) { - return err('Replacement pattern has non-string `replacement` parameter'); - } - if (pattern.start.length === 0) { - return err('Replacement pattern has empty `start` parameter'); - } - return Result.value({ - type: 'inline-command', - start: '', - end: pattern.start, - cmd: 'mceInsertContent', - value: pattern.replacement - }); - } else { - if (pattern.start.length === 0) { - return err('Block pattern has empty `start` parameter'); - } - return formatOrCmd('Block', function (formats) { - return { - type: 'block-format', - start: pattern.start, - format: formats[0] - }; - }, function (command, commandValue) { - return { - type: 'block-command', - start: pattern.start, - cmd: command, - value: commandValue - }; - }); - } - }; - var denormalizePattern = function (pattern) { - if (pattern.type === 'block-command') { - return { - start: pattern.start, - cmd: pattern.cmd, - value: pattern.value - }; - } else if (pattern.type === 'block-format') { - return { - start: pattern.start, - format: pattern.format - }; - } else if (pattern.type === 'inline-command') { - if (pattern.cmd === 'mceInsertContent' && pattern.start === '') { - return { - start: pattern.end, - replacement: pattern.value - }; - } else { - return { - start: pattern.start, - end: pattern.end, - cmd: pattern.cmd, - value: pattern.value - }; - } - } else if (pattern.type === 'inline-format') { - return { - start: pattern.start, - end: pattern.end, - format: pattern.format.length === 1 ? pattern.format[0] : pattern.format - }; - } - }; - var createPatternSet = function (patterns) { - return { - inlinePatterns: filter(patterns, isInlinePattern), - blockPatterns: sortPatterns(filter(patterns, isBlockPattern)) - }; - }; - - var get = function (patternsState) { - var setPatterns = function (newPatterns) { - var normalized = partition(map(newPatterns, normalizePattern)); - if (normalized.errors.length > 0) { - var firstError = normalized.errors[0]; - throw new Error(firstError.message + ':\n' + JSON.stringify(firstError.pattern, null, 2)); - } - patternsState.set(createPatternSet(normalized.values)); - }; - var getPatterns = function () { - return __spreadArray(__spreadArray([], map(patternsState.get().inlinePatterns, denormalizePattern), true), map(patternsState.get().blockPatterns, denormalizePattern), true); - }; - return { - setPatterns: setPatterns, - getPatterns: getPatterns - }; - }; - - var Global = typeof window !== 'undefined' ? window : Function('return this;')(); - - var error = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var console = Global.console; - if (console) { - if (console.error) { - console.error.apply(console, args); - } else { - console.log.apply(console, args); - } - } - }; - var defaultPatterns = [ - { - start: '*', - end: '*', - format: 'italic' - }, - { - start: '**', - end: '**', - format: 'bold' - }, - { - start: '#', - format: 'h1' - }, - { - start: '##', - format: 'h2' - }, - { - start: '###', - format: 'h3' - }, - { - start: '####', - format: 'h4' - }, - { - start: '#####', - format: 'h5' - }, - { - start: '######', - format: 'h6' - }, - { - start: '1. ', - cmd: 'InsertOrderedList' - }, - { - start: '* ', - cmd: 'InsertUnorderedList' - }, - { - start: '- ', - cmd: 'InsertUnorderedList' - } - ]; - var getPatternSet = function (editor) { - var patterns = editor.getParam('textpattern_patterns', defaultPatterns, 'array'); - if (!isArray(patterns)) { - error('The setting textpattern_patterns should be an array'); - return { - inlinePatterns: [], - blockPatterns: [] - }; - } - var normalized = partition(map(patterns, normalizePattern)); - each(normalized.errors, function (err) { - return error(err.message, err.pattern); - }); - return createPatternSet(normalized.values); - }; - var getForcedRootBlock = function (editor) { - var block = editor.getParam('forced_root_block', 'p'); - if (block === false) { - return ''; - } else if (block === true) { - return 'p'; - } else { - return block; - } - }; - - var global$4 = tinymce.util.Tools.resolve('tinymce.util.Delay'); - - var global$3 = tinymce.util.Tools.resolve('tinymce.util.VK'); - - var zeroWidth = '\uFEFF'; - var nbsp = '\xA0'; - - var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools'); - - var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); - - var global = tinymce.util.Tools.resolve('tinymce.dom.TextSeeker'); - - var point = function (container, offset) { - return { - container: container, - offset: offset - }; - }; - - var isText = function (node) { - return node.nodeType === Node.TEXT_NODE; - }; - var cleanEmptyNodes = function (dom, node, isRoot) { - if (node && dom.isEmpty(node) && !isRoot(node)) { - var parent_1 = node.parentNode; - dom.remove(node); - cleanEmptyNodes(dom, parent_1, isRoot); - } - }; - var deleteRng = function (dom, rng, isRoot, clean) { - if (clean === void 0) { - clean = true; - } - var startParent = rng.startContainer.parentNode; - var endParent = rng.endContainer.parentNode; - rng.deleteContents(); - if (clean && !isRoot(rng.startContainer)) { - if (isText(rng.startContainer) && rng.startContainer.data.length === 0) { - dom.remove(rng.startContainer); - } - if (isText(rng.endContainer) && rng.endContainer.data.length === 0) { - dom.remove(rng.endContainer); - } - cleanEmptyNodes(dom, startParent, isRoot); - if (startParent !== endParent) { - cleanEmptyNodes(dom, endParent, isRoot); - } - } - }; - var isBlockFormatName = function (name, formatter) { - var formatSet = formatter.get(name); - return isArray(formatSet) && head(formatSet).exists(function (format) { - return has(format, 'block'); - }); - }; - var isReplacementPattern = function (pattern) { - return pattern.start.length === 0; - }; - var getParentBlock = function (editor, rng) { - var parentBlockOpt = Optional.from(editor.dom.getParent(rng.startContainer, editor.dom.isBlock)); - if (getForcedRootBlock(editor) === '') { - return parentBlockOpt.orThunk(function () { - return Optional.some(editor.getBody()); - }); - } else { - return parentBlockOpt; - } - }; - - var DOM = global$1.DOM; - var alwaysNext = function (startNode) { - return function (node) { - return startNode === node ? -1 : 0; - }; - }; - var isBoundary = function (dom) { - return function (node) { - return dom.isBlock(node) || contains([ - 'BR', - 'IMG', - 'HR', - 'INPUT' - ], node.nodeName) || dom.getContentEditable(node) === 'false'; - }; - }; - var textBefore = function (node, offset, rootNode) { - if (isText(node) && offset >= 0) { - return Optional.some(point(node, offset)); - } else { - var textSeeker = global(DOM); - return Optional.from(textSeeker.backwards(node, offset, alwaysNext(node), rootNode)).map(function (prev) { - return point(prev.container, prev.container.data.length); - }); - } - }; - var textAfter = function (node, offset, rootNode) { - if (isText(node) && offset >= node.length) { - return Optional.some(point(node, offset)); - } else { - var textSeeker = global(DOM); - return Optional.from(textSeeker.forwards(node, offset, alwaysNext(node), rootNode)).map(function (prev) { - return point(prev.container, 0); - }); - } - }; - var scanLeft = function (node, offset, rootNode) { - if (!isText(node)) { - return Optional.none(); - } - var text = node.textContent; - if (offset >= 0 && offset <= text.length) { - return Optional.some(point(node, offset)); - } else { - var textSeeker = global(DOM); - return Optional.from(textSeeker.backwards(node, offset, alwaysNext(node), rootNode)).bind(function (prev) { - var prevText = prev.container.data; - return scanLeft(prev.container, offset + prevText.length, rootNode); - }); - } - }; - var scanRight = function (node, offset, rootNode) { - if (!isText(node)) { - return Optional.none(); - } - var text = node.textContent; - if (offset <= text.length) { - return Optional.some(point(node, offset)); - } else { - var textSeeker = global(DOM); - return Optional.from(textSeeker.forwards(node, offset, alwaysNext(node), rootNode)).bind(function (next) { - return scanRight(next.container, offset - text.length, rootNode); - }); - } - }; - var repeatLeft = function (dom, node, offset, process, rootNode) { - var search = global(dom, isBoundary(dom)); - return Optional.from(search.backwards(node, offset, process, rootNode)); - }; - - var generatePath = function (root, node, offset) { - if (isText(node) && (offset < 0 || offset > node.data.length)) { - return []; - } - var p = [offset]; - var current = node; - while (current !== root && current.parentNode) { - var parent_1 = current.parentNode; - for (var i = 0; i < parent_1.childNodes.length; i++) { - if (parent_1.childNodes[i] === current) { - p.push(i); - break; - } - } - current = parent_1; - } - return current === root ? p.reverse() : []; - }; - var generatePathRange = function (root, startNode, startOffset, endNode, endOffset) { - var start = generatePath(root, startNode, startOffset); - var end = generatePath(root, endNode, endOffset); - return { - start: start, - end: end - }; - }; - var resolvePath = function (root, path) { - var nodePath = path.slice(); - var offset = nodePath.pop(); - var resolvedNode = foldl(nodePath, function (optNode, index) { - return optNode.bind(function (node) { - return Optional.from(node.childNodes[index]); - }); - }, Optional.some(root)); - return resolvedNode.bind(function (node) { - if (isText(node) && (offset < 0 || offset > node.data.length)) { - return Optional.none(); - } else { - return Optional.some({ - node: node, - offset: offset - }); - } - }); - }; - var resolvePathRange = function (root, range) { - return resolvePath(root, range.start).bind(function (_a) { - var startNode = _a.node, startOffset = _a.offset; - return resolvePath(root, range.end).map(function (_a) { - var endNode = _a.node, endOffset = _a.offset; - var rng = document.createRange(); - rng.setStart(startNode, startOffset); - rng.setEnd(endNode, endOffset); - return rng; - }); - }); - }; - var generatePathRangeFromRange = function (root, range) { - return generatePathRange(root, range.startContainer, range.startOffset, range.endContainer, range.endOffset); - }; - - var stripPattern = function (dom, block, pattern) { - var firstTextNode = textAfter(block, 0, block); - firstTextNode.each(function (spot) { - var node = spot.container; - scanRight(node, pattern.start.length, block).each(function (end) { - var rng = dom.createRng(); - rng.setStart(node, 0); - rng.setEnd(end.container, end.offset); - deleteRng(dom, rng, function (e) { - return e === block; - }); - }); - }); - }; - var applyPattern$1 = function (editor, match) { - var dom = editor.dom; - var pattern = match.pattern; - var rng = resolvePathRange(dom.getRoot(), match.range).getOrDie('Unable to resolve path range'); - getParentBlock(editor, rng).each(function (block) { - if (pattern.type === 'block-format') { - if (isBlockFormatName(pattern.format, editor.formatter)) { - editor.undoManager.transact(function () { - stripPattern(editor.dom, block, pattern); - editor.formatter.apply(pattern.format); - }); - } - } else if (pattern.type === 'block-command') { - editor.undoManager.transact(function () { - stripPattern(editor.dom, block, pattern); - editor.execCommand(pattern.cmd, false, pattern.value); - }); - } - }); - return true; - }; - var findPattern$1 = function (patterns, text) { - var nuText = text.replace(nbsp, ' '); - return find(patterns, function (pattern) { - return text.indexOf(pattern.start) === 0 || nuText.indexOf(pattern.start) === 0; - }); - }; - var findPatterns$1 = function (editor, patterns) { - var dom = editor.dom; - var rng = editor.selection.getRng(); - return getParentBlock(editor, rng).filter(function (block) { - var forcedRootBlock = getForcedRootBlock(editor); - var matchesForcedRootBlock = forcedRootBlock === '' && dom.is(block, 'body') || dom.is(block, forcedRootBlock); - return block !== null && matchesForcedRootBlock; - }).bind(function (block) { - var blockText = block.textContent; - var matchedPattern = findPattern$1(patterns, blockText); - return matchedPattern.map(function (pattern) { - if (global$2.trim(blockText).length === pattern.start.length) { - return []; - } - return [{ - pattern: pattern, - range: generatePathRange(dom.getRoot(), block, 0, block, 0) - }]; - }); - }).getOr([]); - }; - var applyMatches$1 = function (editor, matches) { - if (matches.length === 0) { - return; - } - var bookmark = editor.selection.getBookmark(); - each(matches, function (match) { - return applyPattern$1(editor, match); - }); - editor.selection.moveToBookmark(bookmark); - }; - - var unique = 0; - var generate = function (prefix) { - var date = new Date(); - var time = date.getTime(); - var random = Math.floor(Math.random() * 1000000000); - unique++; - return prefix + '_' + random + unique + String(time); - }; - - var checkRange = function (str, substr, start) { - return substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr; - }; - var endsWith = function (str, suffix) { - return checkRange(str, suffix, str.length - suffix.length); - }; - - var newMarker = function (dom, id) { - return dom.create('span', { - 'data-mce-type': 'bookmark', - id: id - }); - }; - var rangeFromMarker = function (dom, marker) { - var rng = dom.createRng(); - rng.setStartAfter(marker.start); - rng.setEndBefore(marker.end); - return rng; - }; - var createMarker = function (dom, markerPrefix, pathRange) { - var rng = resolvePathRange(dom.getRoot(), pathRange).getOrDie('Unable to resolve path range'); - var startNode = rng.startContainer; - var endNode = rng.endContainer; - var textEnd = rng.endOffset === 0 ? endNode : endNode.splitText(rng.endOffset); - var textStart = rng.startOffset === 0 ? startNode : startNode.splitText(rng.startOffset); - return { - prefix: markerPrefix, - end: textEnd.parentNode.insertBefore(newMarker(dom, markerPrefix + '-end'), textEnd), - start: textStart.parentNode.insertBefore(newMarker(dom, markerPrefix + '-start'), textStart) - }; - }; - var removeMarker = function (dom, marker, isRoot) { - cleanEmptyNodes(dom, dom.get(marker.prefix + '-end'), isRoot); - cleanEmptyNodes(dom, dom.get(marker.prefix + '-start'), isRoot); - }; - - var matchesPattern = function (dom, block, patternContent) { - return function (element, offset) { - var text = element.data; - var searchText = text.substring(0, offset); - var startEndIndex = searchText.lastIndexOf(patternContent.charAt(patternContent.length - 1)); - var startIndex = searchText.lastIndexOf(patternContent); - if (startIndex !== -1) { - return startIndex + patternContent.length; - } else if (startEndIndex !== -1) { - return startEndIndex + 1; - } else { - return -1; - } - }; - }; - var findPatternStartFromSpot = function (dom, pattern, block, spot) { - var startPattern = pattern.start; - var startSpot = repeatLeft(dom, spot.container, spot.offset, matchesPattern(dom, block, startPattern), block); - return startSpot.bind(function (spot) { - if (spot.offset >= startPattern.length) { - var rng = dom.createRng(); - rng.setStart(spot.container, spot.offset - startPattern.length); - rng.setEnd(spot.container, spot.offset); - return Optional.some(rng); - } else { - var offset = spot.offset - startPattern.length; - return scanLeft(spot.container, offset, block).map(function (nextSpot) { - var rng = dom.createRng(); - rng.setStart(nextSpot.container, nextSpot.offset); - rng.setEnd(spot.container, spot.offset); - return rng; - }).filter(function (rng) { - return rng.toString() === startPattern; - }).orThunk(function () { - return findPatternStartFromSpot(dom, pattern, block, point(spot.container, 0)); - }); - } - }); - }; - var findPatternStart = function (dom, pattern, node, offset, block, requireGap) { - if (requireGap === void 0) { - requireGap = false; - } - if (pattern.start.length === 0 && !requireGap) { - var rng = dom.createRng(); - rng.setStart(node, offset); - rng.setEnd(node, offset); - return Optional.some(rng); - } - return textBefore(node, offset, block).bind(function (spot) { - var start = findPatternStartFromSpot(dom, pattern, block, spot); - return start.bind(function (startRange) { - if (requireGap) { - if (startRange.endContainer === spot.container && startRange.endOffset === spot.offset) { - return Optional.none(); - } else if (spot.offset === 0 && startRange.endContainer.textContent.length === startRange.endOffset) { - return Optional.none(); - } - } - return Optional.some(startRange); - }); - }); - }; - var findPattern = function (editor, block, details) { - var dom = editor.dom; - var root = dom.getRoot(); - var pattern = details.pattern; - var endNode = details.position.container; - var endOffset = details.position.offset; - return scanLeft(endNode, endOffset - details.pattern.end.length, block).bind(function (spot) { - var endPathRng = generatePathRange(root, spot.container, spot.offset, endNode, endOffset); - if (isReplacementPattern(pattern)) { - return Optional.some({ - matches: [{ - pattern: pattern, - startRng: endPathRng, - endRng: endPathRng - }], - position: spot - }); - } else { - var resultsOpt = findPatternsRec(editor, details.remainingPatterns, spot.container, spot.offset, block); - var results_1 = resultsOpt.getOr({ - matches: [], - position: spot - }); - var pos = results_1.position; - var start = findPatternStart(dom, pattern, pos.container, pos.offset, block, resultsOpt.isNone()); - return start.map(function (startRng) { - var startPathRng = generatePathRangeFromRange(root, startRng); - return { - matches: results_1.matches.concat([{ - pattern: pattern, - startRng: startPathRng, - endRng: endPathRng - }]), - position: point(startRng.startContainer, startRng.startOffset) - }; - }); - } - }); - }; - var findPatternsRec = function (editor, patterns, node, offset, block) { - var dom = editor.dom; - return textBefore(node, offset, dom.getRoot()).bind(function (endSpot) { - var rng = dom.createRng(); - rng.setStart(block, 0); - rng.setEnd(node, offset); - var text = rng.toString(); - for (var i = 0; i < patterns.length; i++) { - var pattern = patterns[i]; - if (!endsWith(text, pattern.end)) { - continue; - } - var patternsWithoutCurrent = patterns.slice(); - patternsWithoutCurrent.splice(i, 1); - var result = findPattern(editor, block, { - pattern: pattern, - remainingPatterns: patternsWithoutCurrent, - position: endSpot - }); - if (result.isSome()) { - return result; - } - } - return Optional.none(); - }); - }; - var applyPattern = function (editor, pattern, patternRange) { - editor.selection.setRng(patternRange); - if (pattern.type === 'inline-format') { - each(pattern.format, function (format) { - editor.formatter.apply(format); - }); - } else { - editor.execCommand(pattern.cmd, false, pattern.value); - } - }; - var applyReplacementPattern = function (editor, pattern, marker, isRoot) { - var markerRange = rangeFromMarker(editor.dom, marker); - deleteRng(editor.dom, markerRange, isRoot); - applyPattern(editor, pattern, markerRange); - }; - var applyPatternWithContent = function (editor, pattern, startMarker, endMarker, isRoot) { - var dom = editor.dom; - var markerEndRange = rangeFromMarker(dom, endMarker); - var markerStartRange = rangeFromMarker(dom, startMarker); - deleteRng(dom, markerStartRange, isRoot); - deleteRng(dom, markerEndRange, isRoot); - var patternMarker = { - prefix: startMarker.prefix, - start: startMarker.end, - end: endMarker.start - }; - var patternRange = rangeFromMarker(dom, patternMarker); - applyPattern(editor, pattern, patternRange); - }; - var addMarkers = function (dom, matches) { - var markerPrefix = generate('mce_textpattern'); - var matchesWithEnds = foldr(matches, function (acc, match) { - var endMarker = createMarker(dom, markerPrefix + ('_end' + acc.length), match.endRng); - return acc.concat([__assign(__assign({}, match), { endMarker: endMarker })]); - }, []); - return foldr(matchesWithEnds, function (acc, match) { - var idx = matchesWithEnds.length - acc.length - 1; - var startMarker = isReplacementPattern(match.pattern) ? match.endMarker : createMarker(dom, markerPrefix + ('_start' + idx), match.startRng); - return acc.concat([__assign(__assign({}, match), { startMarker: startMarker })]); - }, []); - }; - var findPatterns = function (editor, patterns, space) { - var rng = editor.selection.getRng(); - if (rng.collapsed === false) { - return []; - } - return getParentBlock(editor, rng).bind(function (block) { - var offset = rng.startOffset - (space ? 1 : 0); - return findPatternsRec(editor, patterns, rng.startContainer, offset, block); - }).fold(function () { - return []; - }, function (result) { - return result.matches; - }); - }; - var applyMatches = function (editor, matches) { - if (matches.length === 0) { - return; - } - var dom = editor.dom; - var bookmark = editor.selection.getBookmark(); - var matchesWithMarkers = addMarkers(dom, matches); - each(matchesWithMarkers, function (match) { - var block = dom.getParent(match.startMarker.start, dom.isBlock); - var isRoot = function (node) { - return node === block; - }; - if (isReplacementPattern(match.pattern)) { - applyReplacementPattern(editor, match.pattern, match.endMarker, isRoot); - } else { - applyPatternWithContent(editor, match.pattern, match.startMarker, match.endMarker, isRoot); - } - removeMarker(dom, match.endMarker, isRoot); - removeMarker(dom, match.startMarker, isRoot); - }); - editor.selection.moveToBookmark(bookmark); - }; - - var handleEnter = function (editor, patternSet) { - if (!editor.selection.isCollapsed()) { - return false; - } - var inlineMatches = findPatterns(editor, patternSet.inlinePatterns, false); - var blockMatches = findPatterns$1(editor, patternSet.blockPatterns); - if (blockMatches.length > 0 || inlineMatches.length > 0) { - editor.undoManager.add(); - editor.undoManager.extra(function () { - editor.execCommand('mceInsertNewLine'); - }, function () { - editor.insertContent(zeroWidth); - applyMatches(editor, inlineMatches); - applyMatches$1(editor, blockMatches); - var range = editor.selection.getRng(); - var spot = textBefore(range.startContainer, range.startOffset, editor.dom.getRoot()); - editor.execCommand('mceInsertNewLine'); - spot.each(function (s) { - var node = s.container; - if (node.data.charAt(s.offset - 1) === zeroWidth) { - node.deleteData(s.offset - 1, 1); - cleanEmptyNodes(editor.dom, node.parentNode, function (e) { - return e === editor.dom.getRoot(); - }); - } - }); - }); - return true; - } - return false; - }; - var handleInlineKey = function (editor, patternSet) { - var inlineMatches = findPatterns(editor, patternSet.inlinePatterns, true); - if (inlineMatches.length > 0) { - editor.undoManager.transact(function () { - applyMatches(editor, inlineMatches); - }); - } - }; - var checkKeyEvent = function (codes, event, predicate) { - for (var i = 0; i < codes.length; i++) { - if (predicate(codes[i], event)) { - return true; - } - } - return false; - }; - var checkKeyCode = function (codes, event) { - return checkKeyEvent(codes, event, function (code, event) { - return code === event.keyCode && global$3.modifierPressed(event) === false; - }); - }; - var checkCharCode = function (chars, event) { - return checkKeyEvent(chars, event, function (chr, event) { - return chr.charCodeAt(0) === event.charCode; - }); - }; - - var setup = function (editor, patternsState) { - var charCodes = [ - ',', - '.', - ';', - ':', - '!', - '?' - ]; - var keyCodes = [32]; - editor.on('keydown', function (e) { - if (e.keyCode === 13 && !global$3.modifierPressed(e)) { - if (handleEnter(editor, patternsState.get())) { - e.preventDefault(); - } - } - }, true); - editor.on('keyup', function (e) { - if (checkKeyCode(keyCodes, e)) { - handleInlineKey(editor, patternsState.get()); - } - }); - editor.on('keypress', function (e) { - if (checkCharCode(charCodes, e)) { - global$4.setEditorTimeout(editor, function () { - handleInlineKey(editor, patternsState.get()); - }); - } - }); - }; - - function Plugin () { - global$5.add('textpattern', function (editor) { - var patternsState = Cell(getPatternSet(editor)); - setup(editor, patternsState); - return get(patternsState); - }); - } - - Plugin(); - -}()); - -/** - * Copyright (c) Tiny Technologies, Inc. All rights reserved. - * Licensed under the LGPL or a commercial license. - * For LGPL see License.txt in the project root for license information. - * For commercial licenses see https://www.tiny.cloud/ - * - * Version: 5.10.5 (2022-05-25) - */ -(function () { - 'use strict'; - - var global$3 = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - var global$2 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); - - var global$1 = tinymce.util.Tools.resolve('tinymce.util.I18n'); - - var global = tinymce.util.Tools.resolve('tinymce.util.Tools'); - - var getTocClass = function (editor) { - return editor.getParam('toc_class', 'mce-toc'); - }; - var getTocHeader = function (editor) { - var tagName = editor.getParam('toc_header', 'h2'); - return /^h[1-6]$/.test(tagName) ? tagName : 'h2'; - }; - var getTocDepth = function (editor) { - var depth = parseInt(editor.getParam('toc_depth', '3'), 10); - return depth >= 1 && depth <= 9 ? depth : 3; - }; - - var create = function (prefix) { - var counter = 0; - return function () { - var guid = new Date().getTime().toString(32); - return prefix + guid + (counter++).toString(32); - }; - }; - - var tocId = create('mcetoc_'); - var generateSelector = function (depth) { - var i; - var selector = []; - for (i = 1; i <= depth; i++) { - selector.push('h' + i); - } - return selector.join(','); - }; - var hasHeaders = function (editor) { - return readHeaders(editor).length > 0; - }; - var readHeaders = function (editor) { - var tocClass = getTocClass(editor); - var headerTag = getTocHeader(editor); - var selector = generateSelector(getTocDepth(editor)); - var headers = editor.$(selector); - if (headers.length && /^h[1-9]$/i.test(headerTag)) { - headers = headers.filter(function (i, el) { - return !editor.dom.hasClass(el.parentNode, tocClass); - }); - } - return global.map(headers, function (h) { - var id = h.id; - return { - id: id ? id : tocId(), - level: parseInt(h.nodeName.replace(/^H/i, ''), 10), - title: editor.$.text(h), - element: h - }; - }); - }; - var getMinLevel = function (headers) { - var minLevel = 9; - for (var i = 0; i < headers.length; i++) { - if (headers[i].level < minLevel) { - minLevel = headers[i].level; - } - if (minLevel === 1) { - return minLevel; - } - } - return minLevel; - }; - var generateTitle = function (tag, title) { - var openTag = '<' + tag + ' contenteditable="true">'; - var closeTag = ''; - return openTag + global$2.DOM.encode(title) + closeTag; - }; - var generateTocHtml = function (editor) { - var html = generateTocContentHtml(editor); - return '
' + html + '
'; - }; - var generateTocContentHtml = function (editor) { - var html = ''; - var headers = readHeaders(editor); - var prevLevel = getMinLevel(headers) - 1; - if (!headers.length) { - return ''; - } - html += generateTitle(getTocHeader(editor), global$1.translate('Table of Contents')); - for (var i = 0; i < headers.length; i++) { - var h = headers[i]; - h.element.id = h.id; - var nextLevel = headers[i + 1] && headers[i + 1].level; - if (prevLevel === h.level) { - html += '
  • '; - } else { - for (var ii = prevLevel; ii < h.level; ii++) { - html += '
    • '; - } - } - html += '' + h.title + ''; - if (nextLevel === h.level || !nextLevel) { - html += '
    • '; - if (!nextLevel) { - html += '
    '; - } - } else { - for (var ii = h.level; ii > nextLevel; ii--) { - if (ii === nextLevel + 1) { - html += '
  • '; - } else { - html += '
  • '; - } - } - } - prevLevel = h.level; - } - return html; - }; - var isEmptyOrOffscreen = function (editor, nodes) { - return !nodes.length || editor.dom.getParents(nodes[0], '.mce-offscreen-selection').length > 0; - }; - var insertToc = function (editor) { - var tocClass = getTocClass(editor); - var $tocElm = editor.$('.' + tocClass); - if (isEmptyOrOffscreen(editor, $tocElm)) { - editor.insertContent(generateTocHtml(editor)); - } else { - updateToc(editor); - } - }; - var updateToc = function (editor) { - var tocClass = getTocClass(editor); - var $tocElm = editor.$('.' + tocClass); - if ($tocElm.length) { - editor.undoManager.transact(function () { - $tocElm.html(generateTocContentHtml(editor)); - }); - } - }; - - var register$1 = function (editor) { - editor.addCommand('mceInsertToc', function () { - insertToc(editor); - }); - editor.addCommand('mceUpdateToc', function () { - updateToc(editor); - }); - }; - - var setup = function (editor) { - var $ = editor.$, tocClass = getTocClass(editor); - editor.on('PreProcess', function (e) { - var $tocElm = $('.' + tocClass, e.node); - if ($tocElm.length) { - $tocElm.removeAttr('contentEditable'); - $tocElm.find('[contenteditable]').removeAttr('contentEditable'); - } - }); - editor.on('SetContent', function () { - var $tocElm = $('.' + tocClass); - if ($tocElm.length) { - $tocElm.attr('contentEditable', false); - $tocElm.children(':first-child').attr('contentEditable', true); - } - }); - }; - - var toggleState = function (editor) { - return function (api) { - var toggleDisabledState = function () { - return api.setDisabled(editor.mode.isReadOnly() || !hasHeaders(editor)); - }; - toggleDisabledState(); - editor.on('LoadContent SetContent change', toggleDisabledState); - return function () { - return editor.on('LoadContent SetContent change', toggleDisabledState); - }; - }; - }; - var isToc = function (editor) { - return function (elm) { - return elm && editor.dom.is(elm, '.' + getTocClass(editor)) && editor.getBody().contains(elm); - }; - }; - var register = function (editor) { - var insertTocAction = function () { - return editor.execCommand('mceInsertToc'); - }; - editor.ui.registry.addButton('toc', { - icon: 'toc', - tooltip: 'Table of contents', - onAction: insertTocAction, - onSetup: toggleState(editor) - }); - editor.ui.registry.addButton('tocupdate', { - icon: 'reload', - tooltip: 'Update', - onAction: function () { - return editor.execCommand('mceUpdateToc'); - } - }); - editor.ui.registry.addMenuItem('toc', { - icon: 'toc', - text: 'Table of contents', - onAction: insertTocAction, - onSetup: toggleState(editor) - }); - editor.ui.registry.addContextToolbar('toc', { - items: 'tocupdate', - predicate: isToc(editor), - scope: 'node', - position: 'node' - }); - }; - - function Plugin () { - global$3.add('toc', function (editor) { - register$1(editor); - register(editor); - setup(editor); - }); - } - - Plugin(); - -}()); - -/** - * Copyright (c) Tiny Technologies, Inc. All rights reserved. - * Licensed under the LGPL or a commercial license. - * For LGPL see License.txt in the project root for license information. - * For commercial licenses see https://www.tiny.cloud/ - * - * Version: 5.10.5 (2022-05-25) - */ -(function () { - 'use strict'; - - var Cell = function (initial) { - var value = initial; - var get = function () { - return value; - }; - var set = function (v) { - value = v; - }; - return { - get: get, - set: set - }; - }; - - var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - var get$2 = function (toggleState) { - var isEnabled = function () { - return toggleState.get(); - }; - return { isEnabled: isEnabled }; - }; - - var fireVisualChars = function (editor, state) { - return editor.fire('VisualChars', { state: state }); - }; - - var typeOf = function (x) { - var t = typeof x; - if (x === null) { - return 'null'; - } else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) { - return 'array'; - } else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) { - return 'string'; - } else { - return t; - } - }; - var isType$1 = function (type) { - return function (value) { - return typeOf(value) === type; - }; - }; - var isSimpleType = function (type) { - return function (value) { - return typeof value === type; - }; - }; - var isString = isType$1('string'); - var isBoolean = isSimpleType('boolean'); - var isNumber = isSimpleType('number'); - - var noop = function () { - }; - var constant = function (value) { - return function () { - return value; - }; - }; - var identity = function (x) { - return x; - }; - var never = constant(false); - var always = constant(true); - - var none = function () { - return NONE; - }; - var NONE = function () { - var call = function (thunk) { - return thunk(); - }; - var id = identity; - var me = { - fold: function (n, _s) { - return n(); - }, - isSome: never, - isNone: always, - getOr: id, - getOrThunk: call, - getOrDie: function (msg) { - throw new Error(msg || 'error: getOrDie called on none.'); - }, - getOrNull: constant(null), - getOrUndefined: constant(undefined), - or: id, - orThunk: call, - map: none, - each: noop, - bind: none, - exists: never, - forall: always, - filter: function () { - return none(); - }, - toArray: function () { - return []; - }, - toString: constant('none()') - }; - return me; - }(); - var some = function (a) { - var constant_a = constant(a); - var self = function () { - return me; - }; - var bind = function (f) { - return f(a); - }; - var me = { - fold: function (n, s) { - return s(a); - }, - isSome: always, - isNone: never, - getOr: constant_a, - getOrThunk: constant_a, - getOrDie: constant_a, - getOrNull: constant_a, - getOrUndefined: constant_a, - or: self, - orThunk: self, - map: function (f) { - return some(f(a)); - }, - each: function (f) { - f(a); - }, - bind: bind, - exists: bind, - forall: bind, - filter: function (f) { - return f(a) ? me : NONE; - }, - toArray: function () { - return [a]; - }, - toString: function () { - return 'some(' + a + ')'; - } - }; - return me; - }; - var from = function (value) { - return value === null || value === undefined ? NONE : some(value); - }; - var Optional = { - some: some, - none: none, - from: from - }; - - var map = function (xs, f) { - var len = xs.length; - var r = new Array(len); - for (var i = 0; i < len; i++) { - var x = xs[i]; - r[i] = f(x, i); - } - return r; - }; - var each$1 = function (xs, f) { - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - f(x, i); - } - }; - var filter = function (xs, pred) { - var r = []; - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - if (pred(x, i)) { - r.push(x); - } - } - return r; - }; - - var keys = Object.keys; - var each = function (obj, f) { - var props = keys(obj); - for (var k = 0, len = props.length; k < len; k++) { - var i = props[k]; - var x = obj[i]; - f(x, i); - } - }; - - typeof window !== 'undefined' ? window : Function('return this;')(); - - var TEXT = 3; - - var type = function (element) { - return element.dom.nodeType; - }; - var value = function (element) { - return element.dom.nodeValue; - }; - var isType = function (t) { - return function (element) { - return type(element) === t; - }; - }; - var isText = isType(TEXT); - - var rawSet = function (dom, key, value) { - if (isString(value) || isBoolean(value) || isNumber(value)) { - dom.setAttribute(key, value + ''); - } else { - console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom); - throw new Error('Attribute value was not simple'); - } - }; - var set = function (element, key, value) { - rawSet(element.dom, key, value); - }; - var get$1 = function (element, key) { - var v = element.dom.getAttribute(key); - return v === null ? undefined : v; - }; - var remove$3 = function (element, key) { - element.dom.removeAttribute(key); - }; - - var read = function (element, attr) { - var value = get$1(element, attr); - return value === undefined || value === '' ? [] : value.split(' '); - }; - var add$2 = function (element, attr, id) { - var old = read(element, attr); - var nu = old.concat([id]); - set(element, attr, nu.join(' ')); - return true; - }; - var remove$2 = function (element, attr, id) { - var nu = filter(read(element, attr), function (v) { - return v !== id; - }); - if (nu.length > 0) { - set(element, attr, nu.join(' ')); - } else { - remove$3(element, attr); - } - return false; - }; - - var supports = function (element) { - return element.dom.classList !== undefined; - }; - var get = function (element) { - return read(element, 'class'); - }; - var add$1 = function (element, clazz) { - return add$2(element, 'class', clazz); - }; - var remove$1 = function (element, clazz) { - return remove$2(element, 'class', clazz); - }; - - var add = function (element, clazz) { - if (supports(element)) { - element.dom.classList.add(clazz); - } else { - add$1(element, clazz); - } - }; - var cleanClass = function (element) { - var classList = supports(element) ? element.dom.classList : get(element); - if (classList.length === 0) { - remove$3(element, 'class'); - } - }; - var remove = function (element, clazz) { - if (supports(element)) { - var classList = element.dom.classList; - classList.remove(clazz); - } else { - remove$1(element, clazz); - } - cleanClass(element); - }; - - var fromHtml = function (html, scope) { - var doc = scope || document; - var div = doc.createElement('div'); - div.innerHTML = html; - if (!div.hasChildNodes() || div.childNodes.length > 1) { - console.error('HTML does not have a single root node', html); - throw new Error('HTML must have a single root node'); - } - return fromDom(div.childNodes[0]); - }; - var fromTag = function (tag, scope) { - var doc = scope || document; - var node = doc.createElement(tag); - return fromDom(node); - }; - var fromText = function (text, scope) { - var doc = scope || document; - var node = doc.createTextNode(text); - return fromDom(node); - }; - var fromDom = function (node) { - if (node === null || node === undefined) { - throw new Error('Node cannot be null or undefined'); - } - return { dom: node }; - }; - var fromPoint = function (docElm, x, y) { - return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom); - }; - var SugarElement = { - fromHtml: fromHtml, - fromTag: fromTag, - fromText: fromText, - fromDom: fromDom, - fromPoint: fromPoint - }; - - var charMap = { - '\xA0': 'nbsp', - '\xAD': 'shy' - }; - var charMapToRegExp = function (charMap, global) { - var regExp = ''; - each(charMap, function (_value, key) { - regExp += key; - }); - return new RegExp('[' + regExp + ']', global ? 'g' : ''); - }; - var charMapToSelector = function (charMap) { - var selector = ''; - each(charMap, function (value) { - if (selector) { - selector += ','; - } - selector += 'span.mce-' + value; - }); - return selector; - }; - var regExp = charMapToRegExp(charMap); - var regExpGlobal = charMapToRegExp(charMap, true); - var selector = charMapToSelector(charMap); - var nbspClass = 'mce-nbsp'; - - var wrapCharWithSpan = function (value) { - return '' + value + ''; - }; - - var isMatch = function (n) { - var value$1 = value(n); - return isText(n) && value$1 !== undefined && regExp.test(value$1); - }; - var filterDescendants = function (scope, predicate) { - var result = []; - var dom = scope.dom; - var children = map(dom.childNodes, SugarElement.fromDom); - each$1(children, function (x) { - if (predicate(x)) { - result = result.concat([x]); - } - result = result.concat(filterDescendants(x, predicate)); - }); - return result; - }; - var findParentElm = function (elm, rootElm) { - while (elm.parentNode) { - if (elm.parentNode === rootElm) { - return elm; - } - elm = elm.parentNode; - } - }; - var replaceWithSpans = function (text) { - return text.replace(regExpGlobal, wrapCharWithSpan); - }; - - var isWrappedNbsp = function (node) { - return node.nodeName.toLowerCase() === 'span' && node.classList.contains('mce-nbsp-wrap'); - }; - var show = function (editor, rootElm) { - var nodeList = filterDescendants(SugarElement.fromDom(rootElm), isMatch); - each$1(nodeList, function (n) { - var parent = n.dom.parentNode; - if (isWrappedNbsp(parent)) { - add(SugarElement.fromDom(parent), nbspClass); - } else { - var withSpans = replaceWithSpans(editor.dom.encode(value(n))); - var div = editor.dom.create('div', null, withSpans); - var node = void 0; - while (node = div.lastChild) { - editor.dom.insertAfter(node, n.dom); - } - editor.dom.remove(n.dom); - } - }); - }; - var hide = function (editor, rootElm) { - var nodeList = editor.dom.select(selector, rootElm); - each$1(nodeList, function (node) { - if (isWrappedNbsp(node)) { - remove(SugarElement.fromDom(node), nbspClass); - } else { - editor.dom.remove(node, true); - } - }); - }; - var toggle = function (editor) { - var body = editor.getBody(); - var bookmark = editor.selection.getBookmark(); - var parentNode = findParentElm(editor.selection.getNode(), body); - parentNode = parentNode !== undefined ? parentNode : body; - hide(editor, parentNode); - show(editor, parentNode); - editor.selection.moveToBookmark(bookmark); - }; - - var applyVisualChars = function (editor, toggleState) { - fireVisualChars(editor, toggleState.get()); - var body = editor.getBody(); - if (toggleState.get() === true) { - show(editor, body); - } else { - hide(editor, body); - } - }; - var toggleVisualChars = function (editor, toggleState) { - toggleState.set(!toggleState.get()); - var bookmark = editor.selection.getBookmark(); - applyVisualChars(editor, toggleState); - editor.selection.moveToBookmark(bookmark); - }; - - var register$1 = function (editor, toggleState) { - editor.addCommand('mceVisualChars', function () { - toggleVisualChars(editor, toggleState); - }); - }; - - var isEnabledByDefault = function (editor) { - return editor.getParam('visualchars_default_state', false); - }; - var hasForcedRootBlock = function (editor) { - return editor.getParam('forced_root_block') !== false; - }; - - var setup$1 = function (editor, toggleState) { - editor.on('init', function () { - applyVisualChars(editor, toggleState); - }); - }; - - var global = tinymce.util.Tools.resolve('tinymce.util.Delay'); - - var setup = function (editor, toggleState) { - var debouncedToggle = global.debounce(function () { - toggle(editor); - }, 300); - if (hasForcedRootBlock(editor)) { - editor.on('keydown', function (e) { - if (toggleState.get() === true) { - e.keyCode === 13 ? toggle(editor) : debouncedToggle(); - } - }); - } - editor.on('remove', debouncedToggle.stop); - }; - - var toggleActiveState = function (editor, enabledStated) { - return function (api) { - api.setActive(enabledStated.get()); - var editorEventCallback = function (e) { - return api.setActive(e.state); - }; - editor.on('VisualChars', editorEventCallback); - return function () { - return editor.off('VisualChars', editorEventCallback); - }; - }; - }; - var register = function (editor, toggleState) { - var onAction = function () { - return editor.execCommand('mceVisualChars'); - }; - editor.ui.registry.addToggleButton('visualchars', { - tooltip: 'Show invisible characters', - icon: 'visualchars', - onAction: onAction, - onSetup: toggleActiveState(editor, toggleState) - }); - editor.ui.registry.addToggleMenuItem('visualchars', { - text: 'Show invisible characters', - icon: 'visualchars', - onAction: onAction, - onSetup: toggleActiveState(editor, toggleState) - }); - }; - - function Plugin () { - global$1.add('visualchars', function (editor) { - var toggleState = Cell(isEnabledByDefault(editor)); - register$1(editor, toggleState); - register(editor, toggleState); - setup(editor, toggleState); - setup$1(editor, toggleState); - return get$2(toggleState); - }); - } - - Plugin(); - -}()); - -/** - * Copyright (c) Tiny Technologies, Inc. All rights reserved. - * Licensed under the LGPL or a commercial license. - * For LGPL see License.txt in the project root for license information. - * For commercial licenses see https://www.tiny.cloud/ - * - * Version: 5.10.5 (2022-05-25) - */ -(function () { - 'use strict'; - - var Cell = function (initial) { - var value = initial; - var get = function () { - return value; - }; - var set = function (v) { - value = v; - }; - return { - get: get, - set: set - }; - }; - - var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - var fireVisualBlocks = function (editor, state) { - editor.fire('VisualBlocks', { state: state }); - }; - - var toggleVisualBlocks = function (editor, pluginUrl, enabledState) { - var dom = editor.dom; - dom.toggleClass(editor.getBody(), 'mce-visualblocks'); - enabledState.set(!enabledState.get()); - fireVisualBlocks(editor, enabledState.get()); - }; - - var register$1 = function (editor, pluginUrl, enabledState) { - editor.addCommand('mceVisualBlocks', function () { - toggleVisualBlocks(editor, pluginUrl, enabledState); - }); - }; - - var isEnabledByDefault = function (editor) { - return editor.getParam('visualblocks_default_state', false, 'boolean'); - }; - - var setup = function (editor, pluginUrl, enabledState) { - editor.on('PreviewFormats AfterPreviewFormats', function (e) { - if (enabledState.get()) { - editor.dom.toggleClass(editor.getBody(), 'mce-visualblocks', e.type === 'afterpreviewformats'); - } - }); - editor.on('init', function () { - if (isEnabledByDefault(editor)) { - toggleVisualBlocks(editor, pluginUrl, enabledState); - } - }); - }; - - var toggleActiveState = function (editor, enabledState) { - return function (api) { - api.setActive(enabledState.get()); - var editorEventCallback = function (e) { - return api.setActive(e.state); - }; - editor.on('VisualBlocks', editorEventCallback); - return function () { - return editor.off('VisualBlocks', editorEventCallback); - }; - }; - }; - var register = function (editor, enabledState) { - var onAction = function () { - return editor.execCommand('mceVisualBlocks'); - }; - editor.ui.registry.addToggleButton('visualblocks', { - icon: 'visualblocks', - tooltip: 'Show blocks', - onAction: onAction, - onSetup: toggleActiveState(editor, enabledState) - }); - editor.ui.registry.addToggleMenuItem('visualblocks', { - text: 'Show blocks', - icon: 'visualblocks', - onAction: onAction, - onSetup: toggleActiveState(editor, enabledState) - }); - }; - - function Plugin () { - global.add('visualblocks', function (editor, pluginUrl) { - var enabledState = Cell(false); - register$1(editor, pluginUrl, enabledState); - register(editor, enabledState); - setup(editor, pluginUrl, enabledState); - }); - } - - Plugin(); - -}()); - -/** - * Copyright (c) Tiny Technologies, Inc. All rights reserved. - * Licensed under the LGPL or a commercial license. - * For LGPL see License.txt in the project root for license information. - * For commercial licenses see https://www.tiny.cloud/ - * - * Version: 5.10.5 (2022-05-25) - */ -(function () { - 'use strict'; - - var global$2 = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - var identity = function (x) { - return x; - }; - - var __assign = function () { - __assign = Object.assign || function __assign(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) - if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); - }; - - var zeroWidth = '\uFEFF'; - var removeZwsp$1 = function (s) { - return s.replace(/\uFEFF/g, ''); - }; - - var map = function (xs, f) { - var len = xs.length; - var r = new Array(len); - for (var i = 0; i < len; i++) { - var x = xs[i]; - r[i] = f(x, i); - } - return r; - }; - - var punctuationStr = '[!-#%-*,-\\/:;?@\\[-\\]_{}\xA1\xAB\xB7\xBB\xBF;\xB7\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1361-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u3008\u3009\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30\u2E31\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uff3f\uFF5B\uFF5D\uFF5F-\uFF65]'; - var regExps = { - aletter: '[A-Za-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05F3\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u10a0-\u10c5\u10d0-\u10fa\u10fc\u1100-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1a00-\u1a16\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bc0-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u24B6-\u24E9\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2d00-\u2d25\u2d30-\u2d65\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005\u303b\u303c\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790\ua791\ua7a0-\ua7a9\ua7fa-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uffa0-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]', - midnumlet: '[-\'\\.\u2018\u2019\u2024\uFE52\uFF07\uFF0E]', - midletter: '[:\xB7\xB7\u05F4\u2027\uFE13\uFE55\uFF1A]', - midnum: '[\xB1+*/,;;\u0589\u060C\u060D\u066C\u07F8\u2044\uFE10\uFE14\uFE50\uFE54\uFF0C\uFF1B]', - numeric: '[0-9\u0660-\u0669\u066B\u06f0-\u06f9\u07c0-\u07c9\u0966-\u096f\u09e6-\u09ef\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be6-\u0bef\u0c66-\u0c6f\u0ce6-\u0cef\u0d66-\u0d6f\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29\u1040-\u1049\u1090-\u1099\u17e0-\u17e9\u1810-\u1819\u1946-\u194f\u19d0-\u19d9\u1a80-\u1a89\u1a90-\u1a99\u1b50-\u1b59\u1bb0-\u1bb9\u1c40-\u1c49\u1c50-\u1c59\ua620-\ua629\ua8d0-\ua8d9\ua900-\ua909\ua9d0-\ua9d9\uaa50-\uaa59\uabf0-\uabf9]', - cr: '\\r', - lf: '\\n', - newline: '[\x0B\f\x85\u2028\u2029]', - extend: '[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065f\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0c01-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d02\u0d03\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f\u109a-\u109d\u135d-\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b6-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u192b\u1930-\u193b\u19b0-\u19c0\u19c8\u19c9\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f\u1b00-\u1b04\u1b34-\u1b44\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1baa\u1be6-\u1bf3\u1c24-\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf2\u1dc0-\u1de6\u1dfc-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\uA672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa7b\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe3-\uabea\uabec\uabed\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]', - format: '[\xAD\u0600-\u0603\u06DD\u070F\u17b4\u17b5\u200E\u200F\u202A-\u202E\u2060-\u2064\u206A-\u206F\uFEFF\uFFF9-\uFFFB]', - katakana: '[\u3031-\u3035\u309B\u309C\u30A0-\u30fa\u30fc-\u30ff\u31f0-\u31ff\u32D0-\u32FE\u3300-\u3357\uff66-\uff9d]', - extendnumlet: '[=_\u203f\u2040\u2054\ufe33\ufe34\ufe4d-\ufe4f\uff3f\u2200-\u22FF<>]', - punctuation: punctuationStr - }; - var characterIndices = { - ALETTER: 0, - MIDNUMLET: 1, - MIDLETTER: 2, - MIDNUM: 3, - NUMERIC: 4, - CR: 5, - LF: 6, - NEWLINE: 7, - EXTEND: 8, - FORMAT: 9, - KATAKANA: 10, - EXTENDNUMLET: 11, - AT: 12, - OTHER: 13 - }; - var SETS$1 = [ - new RegExp(regExps.aletter), - new RegExp(regExps.midnumlet), - new RegExp(regExps.midletter), - new RegExp(regExps.midnum), - new RegExp(regExps.numeric), - new RegExp(regExps.cr), - new RegExp(regExps.lf), - new RegExp(regExps.newline), - new RegExp(regExps.extend), - new RegExp(regExps.format), - new RegExp(regExps.katakana), - new RegExp(regExps.extendnumlet), - new RegExp('@') - ]; - var EMPTY_STRING$1 = ''; - var PUNCTUATION$1 = new RegExp('^' + regExps.punctuation + '$'); - var WHITESPACE$1 = /^\s+$/; - - var SETS = SETS$1; - var OTHER = characterIndices.OTHER; - var getType = function (char) { - var type = OTHER; - var setsLength = SETS.length; - for (var j = 0; j < setsLength; ++j) { - var set = SETS[j]; - if (set && set.test(char)) { - type = j; - break; - } - } - return type; - }; - var memoize = function (func) { - var cache = {}; - return function (char) { - if (cache[char]) { - return cache[char]; - } else { - var result = func(char); - cache[char] = result; - return result; - } - }; - }; - var classify = function (characters) { - var memoized = memoize(getType); - return map(characters, memoized); - }; - - var isWordBoundary = function (map, index) { - var type = map[index]; - var nextType = map[index + 1]; - if (index < 0 || index > map.length - 1 && index !== 0) { - return false; - } - if (type === characterIndices.ALETTER && nextType === characterIndices.ALETTER) { - return false; - } - var nextNextType = map[index + 2]; - if (type === characterIndices.ALETTER && (nextType === characterIndices.MIDLETTER || nextType === characterIndices.MIDNUMLET || nextType === characterIndices.AT) && nextNextType === characterIndices.ALETTER) { - return false; - } - var prevType = map[index - 1]; - if ((type === characterIndices.MIDLETTER || type === characterIndices.MIDNUMLET || nextType === characterIndices.AT) && nextType === characterIndices.ALETTER && prevType === characterIndices.ALETTER) { - return false; - } - if ((type === characterIndices.NUMERIC || type === characterIndices.ALETTER) && (nextType === characterIndices.NUMERIC || nextType === characterIndices.ALETTER)) { - return false; - } - if ((type === characterIndices.MIDNUM || type === characterIndices.MIDNUMLET) && nextType === characterIndices.NUMERIC && prevType === characterIndices.NUMERIC) { - return false; - } - if (type === characterIndices.NUMERIC && (nextType === characterIndices.MIDNUM || nextType === characterIndices.MIDNUMLET) && nextNextType === characterIndices.NUMERIC) { - return false; - } - if (type === characterIndices.EXTEND || type === characterIndices.FORMAT || prevType === characterIndices.EXTEND || prevType === characterIndices.FORMAT || nextType === characterIndices.EXTEND || nextType === characterIndices.FORMAT) { - return false; - } - if (type === characterIndices.CR && nextType === characterIndices.LF) { - return false; - } - if (type === characterIndices.NEWLINE || type === characterIndices.CR || type === characterIndices.LF) { - return true; - } - if (nextType === characterIndices.NEWLINE || nextType === characterIndices.CR || nextType === characterIndices.LF) { - return true; - } - if (type === characterIndices.KATAKANA && nextType === characterIndices.KATAKANA) { - return false; - } - if (nextType === characterIndices.EXTENDNUMLET && (type === characterIndices.ALETTER || type === characterIndices.NUMERIC || type === characterIndices.KATAKANA || type === characterIndices.EXTENDNUMLET)) { - return false; - } - if (type === characterIndices.EXTENDNUMLET && (nextType === characterIndices.ALETTER || nextType === characterIndices.NUMERIC || nextType === characterIndices.KATAKANA)) { - return false; - } - if (type === characterIndices.AT) { - return false; - } - return true; - }; - - var EMPTY_STRING = EMPTY_STRING$1; - var WHITESPACE = WHITESPACE$1; - var PUNCTUATION = PUNCTUATION$1; - var isProtocol = function (str) { - return str === 'http' || str === 'https'; - }; - var findWordEnd = function (characters, startIndex) { - var i; - for (i = startIndex; i < characters.length; i++) { - if (WHITESPACE.test(characters[i])) { - break; - } - } - return i; - }; - var findUrlEnd = function (characters, startIndex) { - var endIndex = findWordEnd(characters, startIndex + 1); - var peakedWord = characters.slice(startIndex + 1, endIndex).join(EMPTY_STRING); - return peakedWord.substr(0, 3) === '://' ? endIndex : startIndex; - }; - var findWords = function (chars, sChars, characterMap, options) { - var words = []; - var word = []; - for (var i = 0; i < characterMap.length; ++i) { - word.push(chars[i]); - if (isWordBoundary(characterMap, i)) { - var ch = sChars[i]; - if ((options.includeWhitespace || !WHITESPACE.test(ch)) && (options.includePunctuation || !PUNCTUATION.test(ch))) { - var startOfWord = i - word.length + 1; - var endOfWord = i + 1; - var str = sChars.slice(startOfWord, endOfWord).join(EMPTY_STRING); - if (isProtocol(str)) { - var endOfUrl = findUrlEnd(sChars, i); - var url = chars.slice(endOfWord, endOfUrl); - Array.prototype.push.apply(word, url); - i = endOfUrl; - } - words.push(word); - } - word = []; - } - } - return words; - }; - var getDefaultOptions = function () { - return { - includeWhitespace: false, - includePunctuation: false - }; - }; - var getWords$1 = function (chars, extract, options) { - options = __assign(__assign({}, getDefaultOptions()), options); - var filteredChars = []; - var extractedChars = []; - for (var i = 0; i < chars.length; i++) { - var ch = extract(chars[i]); - if (ch !== zeroWidth) { - filteredChars.push(chars[i]); - extractedChars.push(ch); - } - } - var characterMap = classify(extractedChars); - return findWords(filteredChars, extractedChars, characterMap, options); - }; - - var getWords = getWords$1; - - var global$1 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker'); - - var getText = function (node, schema) { - var blockElements = schema.getBlockElements(); - var shortEndedElements = schema.getShortEndedElements(); - var isNewline = function (node) { - return blockElements[node.nodeName] || shortEndedElements[node.nodeName]; - }; - var textBlocks = []; - var txt = ''; - var treeWalker = new global$1(node, node); - while (node = treeWalker.next()) { - if (node.nodeType === 3) { - txt += removeZwsp$1(node.data); - } else if (isNewline(node) && txt.length) { - textBlocks.push(txt); - txt = ''; - } - } - if (txt.length) { - textBlocks.push(txt); - } - return textBlocks; - }; - - var removeZwsp = function (text) { - return text.replace(/\u200B/g, ''); - }; - var strLen = function (str) { - return str.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, '_').length; - }; - var countWords = function (node, schema) { - var text = removeZwsp(getText(node, schema).join('\n')); - return getWords(text.split(''), identity).length; - }; - var countCharacters = function (node, schema) { - var text = getText(node, schema).join(''); - return strLen(text); - }; - var countCharactersWithoutSpaces = function (node, schema) { - var text = getText(node, schema).join('').replace(/\s/g, ''); - return strLen(text); - }; - - var createBodyCounter = function (editor, count) { - return function () { - return count(editor.getBody(), editor.schema); - }; - }; - var createSelectionCounter = function (editor, count) { - return function () { - return count(editor.selection.getRng().cloneContents(), editor.schema); - }; - }; - var createBodyWordCounter = function (editor) { - return createBodyCounter(editor, countWords); - }; - var get = function (editor) { - return { - body: { - getWordCount: createBodyWordCounter(editor), - getCharacterCount: createBodyCounter(editor, countCharacters), - getCharacterCountWithoutSpaces: createBodyCounter(editor, countCharactersWithoutSpaces) - }, - selection: { - getWordCount: createSelectionCounter(editor, countWords), - getCharacterCount: createSelectionCounter(editor, countCharacters), - getCharacterCountWithoutSpaces: createSelectionCounter(editor, countCharactersWithoutSpaces) - }, - getCount: createBodyWordCounter(editor) - }; - }; - - var open = function (editor, api) { - editor.windowManager.open({ - title: 'Word Count', - body: { - type: 'panel', - items: [{ - type: 'table', - header: [ - 'Count', - 'Document', - 'Selection' - ], - cells: [ - [ - 'Words', - String(api.body.getWordCount()), - String(api.selection.getWordCount()) - ], - [ - 'Characters (no spaces)', - String(api.body.getCharacterCountWithoutSpaces()), - String(api.selection.getCharacterCountWithoutSpaces()) - ], - [ - 'Characters', - String(api.body.getCharacterCount()), - String(api.selection.getCharacterCount()) - ] - ] - }] - }, - buttons: [{ - type: 'cancel', - name: 'close', - text: 'Close', - primary: true - }] - }); - }; - - var register$1 = function (editor, api) { - editor.addCommand('mceWordCount', function () { - return open(editor, api); - }); - }; - - var global = tinymce.util.Tools.resolve('tinymce.util.Delay'); - - var fireWordCountUpdate = function (editor, api) { - editor.fire('wordCountUpdate', { - wordCount: { - words: api.body.getWordCount(), - characters: api.body.getCharacterCount(), - charactersWithoutSpaces: api.body.getCharacterCountWithoutSpaces() - } - }); - }; - - var updateCount = function (editor, api) { - fireWordCountUpdate(editor, api); - }; - var setup = function (editor, api, delay) { - var debouncedUpdate = global.debounce(function () { - return updateCount(editor, api); - }, delay); - editor.on('init', function () { - updateCount(editor, api); - global.setEditorTimeout(editor, function () { - editor.on('SetContent BeforeAddUndo Undo Redo ViewUpdate keyup', debouncedUpdate); - }, 0); - }); - }; - - var register = function (editor) { - var onAction = function () { - return editor.execCommand('mceWordCount'); - }; - editor.ui.registry.addButton('wordcount', { - tooltip: 'Word count', - icon: 'character-count', - onAction: onAction - }); - editor.ui.registry.addMenuItem('wordcount', { - text: 'Word count', - icon: 'character-count', - onAction: onAction - }); - }; - - function Plugin (delay) { - if (delay === void 0) { - delay = 300; - } - global$2.add('wordcount', function (editor) { - var api = get(editor); - register$1(editor, api); - register(editor); - setup(editor, api, delay); - return api; - }); - } - - Plugin(); - -}()); diff --git a/Moonlight/wwwroot/assets/plugins/custom/typedjs/typedjs.bundle.js b/Moonlight/wwwroot/assets/plugins/custom/typedjs/typedjs.bundle.js deleted file mode 100644 index 0992dc56..00000000 --- a/Moonlight/wwwroot/assets/plugins/custom/typedjs/typedjs.bundle.js +++ /dev/null @@ -1,1052 +0,0 @@ -/*! - * - * typed.js - A JavaScript Typing Animation Library - * Author: Matt Boldt - * Version: v2.0.12 - * Url: https://github.com/mattboldt/typed.js - * License(s): MIT - * - */ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(); - else if(typeof define === 'function' && define.amd) - define([], factory); - else if(typeof exports === 'object') - exports["Typed"] = factory(); - else - root["Typed"] = factory(); -})(this, function() { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) -/******/ return installedModules[moduleId].exports; -/******/ -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ exports: {}, -/******/ id: moduleId, -/******/ loaded: false -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.loaded = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(0); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ (function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, '__esModule', { - value: true - }); - - var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - - var _initializerJs = __webpack_require__(1); - - var _htmlParserJs = __webpack_require__(3); - - /** - * Welcome to Typed.js! - * @param {string} elementId HTML element ID _OR_ HTML element - * @param {object} options options object - * @returns {object} a new Typed object - */ - - var Typed = (function () { - function Typed(elementId, options) { - _classCallCheck(this, Typed); - - // Initialize it up - _initializerJs.initializer.load(this, options, elementId); - // All systems go! - this.begin(); - } - - /** - * Toggle start() and stop() of the Typed instance - * @public - */ - - _createClass(Typed, [{ - key: 'toggle', - value: function toggle() { - this.pause.status ? this.start() : this.stop(); - } - - /** - * Stop typing / backspacing and enable cursor blinking - * @public - */ - }, { - key: 'stop', - value: function stop() { - if (this.typingComplete) return; - if (this.pause.status) return; - this.toggleBlinking(true); - this.pause.status = true; - this.options.onStop(this.arrayPos, this); - } - - /** - * Start typing / backspacing after being stopped - * @public - */ - }, { - key: 'start', - value: function start() { - if (this.typingComplete) return; - if (!this.pause.status) return; - this.pause.status = false; - if (this.pause.typewrite) { - this.typewrite(this.pause.curString, this.pause.curStrPos); - } else { - this.backspace(this.pause.curString, this.pause.curStrPos); - } - this.options.onStart(this.arrayPos, this); - } - - /** - * Destroy this instance of Typed - * @public - */ - }, { - key: 'destroy', - value: function destroy() { - this.reset(false); - this.options.onDestroy(this); - } - - /** - * Reset Typed and optionally restarts - * @param {boolean} restart - * @public - */ - }, { - key: 'reset', - value: function reset() { - var restart = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0]; - - clearInterval(this.timeout); - this.replaceText(''); - if (this.cursor && this.cursor.parentNode) { - this.cursor.parentNode.removeChild(this.cursor); - this.cursor = null; - } - this.strPos = 0; - this.arrayPos = 0; - this.curLoop = 0; - if (restart) { - this.insertCursor(); - this.options.onReset(this); - this.begin(); - } - } - - /** - * Begins the typing animation - * @private - */ - }, { - key: 'begin', - value: function begin() { - var _this = this; - - this.options.onBegin(this); - this.typingComplete = false; - this.shuffleStringsIfNeeded(this); - this.insertCursor(); - if (this.bindInputFocusEvents) this.bindFocusEvents(); - this.timeout = setTimeout(function () { - // Check if there is some text in the element, if yes start by backspacing the default message - if (!_this.currentElContent || _this.currentElContent.length === 0) { - _this.typewrite(_this.strings[_this.sequence[_this.arrayPos]], _this.strPos); - } else { - // Start typing - _this.backspace(_this.currentElContent, _this.currentElContent.length); - } - }, this.startDelay); - } - - /** - * Called for each character typed - * @param {string} curString the current string in the strings array - * @param {number} curStrPos the current position in the curString - * @private - */ - }, { - key: 'typewrite', - value: function typewrite(curString, curStrPos) { - var _this2 = this; - - if (this.fadeOut && this.el.classList.contains(this.fadeOutClass)) { - this.el.classList.remove(this.fadeOutClass); - if (this.cursor) this.cursor.classList.remove(this.fadeOutClass); - } - - var humanize = this.humanizer(this.typeSpeed); - var numChars = 1; - - if (this.pause.status === true) { - this.setPauseStatus(curString, curStrPos, true); - return; - } - - // contain typing function in a timeout humanize'd delay - this.timeout = setTimeout(function () { - // skip over any HTML chars - curStrPos = _htmlParserJs.htmlParser.typeHtmlChars(curString, curStrPos, _this2); - - var pauseTime = 0; - var substr = curString.substr(curStrPos); - // check for an escape character before a pause value - // format: \^\d+ .. eg: ^1000 .. should be able to print the ^ too using ^^ - // single ^ are removed from string - if (substr.charAt(0) === '^') { - if (/^\^\d+/.test(substr)) { - var skip = 1; // skip at least 1 - substr = /\d+/.exec(substr)[0]; - skip += substr.length; - pauseTime = parseInt(substr); - _this2.temporaryPause = true; - _this2.options.onTypingPaused(_this2.arrayPos, _this2); - // strip out the escape character and pause value so they're not printed - curString = curString.substring(0, curStrPos) + curString.substring(curStrPos + skip); - _this2.toggleBlinking(true); - } - } - - // check for skip characters formatted as - // "this is a `string to print NOW` ..." - if (substr.charAt(0) === '`') { - while (curString.substr(curStrPos + numChars).charAt(0) !== '`') { - numChars++; - if (curStrPos + numChars > curString.length) break; - } - // strip out the escape characters and append all the string in between - var stringBeforeSkip = curString.substring(0, curStrPos); - var stringSkipped = curString.substring(stringBeforeSkip.length + 1, curStrPos + numChars); - var stringAfterSkip = curString.substring(curStrPos + numChars + 1); - curString = stringBeforeSkip + stringSkipped + stringAfterSkip; - numChars--; - } - - // timeout for any pause after a character - _this2.timeout = setTimeout(function () { - // Accounts for blinking while paused - _this2.toggleBlinking(false); - - // We're done with this sentence! - if (curStrPos >= curString.length) { - _this2.doneTyping(curString, curStrPos); - } else { - _this2.keepTyping(curString, curStrPos, numChars); - } - // end of character pause - if (_this2.temporaryPause) { - _this2.temporaryPause = false; - _this2.options.onTypingResumed(_this2.arrayPos, _this2); - } - }, pauseTime); - - // humanized value for typing - }, humanize); - } - - /** - * Continue to the next string & begin typing - * @param {string} curString the current string in the strings array - * @param {number} curStrPos the current position in the curString - * @private - */ - }, { - key: 'keepTyping', - value: function keepTyping(curString, curStrPos, numChars) { - // call before functions if applicable - if (curStrPos === 0) { - this.toggleBlinking(false); - this.options.preStringTyped(this.arrayPos, this); - } - // start typing each new char into existing string - // curString: arg, this.el.html: original text inside element - curStrPos += numChars; - var nextString = curString.substr(0, curStrPos); - this.replaceText(nextString); - // loop the function - this.typewrite(curString, curStrPos); - } - - /** - * We're done typing the current string - * @param {string} curString the current string in the strings array - * @param {number} curStrPos the current position in the curString - * @private - */ - }, { - key: 'doneTyping', - value: function doneTyping(curString, curStrPos) { - var _this3 = this; - - // fires callback function - this.options.onStringTyped(this.arrayPos, this); - this.toggleBlinking(true); - // is this the final string - if (this.arrayPos === this.strings.length - 1) { - // callback that occurs on the last typed string - this.complete(); - // quit if we wont loop back - if (this.loop === false || this.curLoop === this.loopCount) { - return; - } - } - this.timeout = setTimeout(function () { - _this3.backspace(curString, curStrPos); - }, this.backDelay); - } - - /** - * Backspaces 1 character at a time - * @param {string} curString the current string in the strings array - * @param {number} curStrPos the current position in the curString - * @private - */ - }, { - key: 'backspace', - value: function backspace(curString, curStrPos) { - var _this4 = this; - - if (this.pause.status === true) { - this.setPauseStatus(curString, curStrPos, false); - return; - } - if (this.fadeOut) return this.initFadeOut(); - - this.toggleBlinking(false); - var humanize = this.humanizer(this.backSpeed); - - this.timeout = setTimeout(function () { - curStrPos = _htmlParserJs.htmlParser.backSpaceHtmlChars(curString, curStrPos, _this4); - // replace text with base text + typed characters - var curStringAtPosition = curString.substr(0, curStrPos); - _this4.replaceText(curStringAtPosition); - - // if smartBack is enabled - if (_this4.smartBackspace) { - // the remaining part of the current string is equal of the same part of the new string - var nextString = _this4.strings[_this4.arrayPos + 1]; - if (nextString && curStringAtPosition === nextString.substr(0, curStrPos)) { - _this4.stopNum = curStrPos; - } else { - _this4.stopNum = 0; - } - } - - // if the number (id of character in current string) is - // less than the stop number, keep going - if (curStrPos > _this4.stopNum) { - // subtract characters one by one - curStrPos--; - // loop the function - _this4.backspace(curString, curStrPos); - } else if (curStrPos <= _this4.stopNum) { - // if the stop number has been reached, increase - // array position to next string - _this4.arrayPos++; - // When looping, begin at the beginning after backspace complete - if (_this4.arrayPos === _this4.strings.length) { - _this4.arrayPos = 0; - _this4.options.onLastStringBackspaced(); - _this4.shuffleStringsIfNeeded(); - _this4.begin(); - } else { - _this4.typewrite(_this4.strings[_this4.sequence[_this4.arrayPos]], curStrPos); - } - } - // humanized value for typing - }, humanize); - } - - /** - * Full animation is complete - * @private - */ - }, { - key: 'complete', - value: function complete() { - this.options.onComplete(this); - if (this.loop) { - this.curLoop++; - } else { - this.typingComplete = true; - } - } - - /** - * Has the typing been stopped - * @param {string} curString the current string in the strings array - * @param {number} curStrPos the current position in the curString - * @param {boolean} isTyping - * @private - */ - }, { - key: 'setPauseStatus', - value: function setPauseStatus(curString, curStrPos, isTyping) { - this.pause.typewrite = isTyping; - this.pause.curString = curString; - this.pause.curStrPos = curStrPos; - } - - /** - * Toggle the blinking cursor - * @param {boolean} isBlinking - * @private - */ - }, { - key: 'toggleBlinking', - value: function toggleBlinking(isBlinking) { - if (!this.cursor) return; - // if in paused state, don't toggle blinking a 2nd time - if (this.pause.status) return; - if (this.cursorBlinking === isBlinking) return; - this.cursorBlinking = isBlinking; - if (isBlinking) { - this.cursor.classList.add('typed-cursor--blink'); - } else { - this.cursor.classList.remove('typed-cursor--blink'); - } - } - - /** - * Speed in MS to type - * @param {number} speed - * @private - */ - }, { - key: 'humanizer', - value: function humanizer(speed) { - return Math.round(Math.random() * speed / 2) + speed; - } - - /** - * Shuffle the sequence of the strings array - * @private - */ - }, { - key: 'shuffleStringsIfNeeded', - value: function shuffleStringsIfNeeded() { - if (!this.shuffle) return; - this.sequence = this.sequence.sort(function () { - return Math.random() - 0.5; - }); - } - - /** - * Adds a CSS class to fade out current string - * @private - */ - }, { - key: 'initFadeOut', - value: function initFadeOut() { - var _this5 = this; - - this.el.className += ' ' + this.fadeOutClass; - if (this.cursor) this.cursor.className += ' ' + this.fadeOutClass; - return setTimeout(function () { - _this5.arrayPos++; - _this5.replaceText(''); - - // Resets current string if end of loop reached - if (_this5.strings.length > _this5.arrayPos) { - _this5.typewrite(_this5.strings[_this5.sequence[_this5.arrayPos]], 0); - } else { - _this5.typewrite(_this5.strings[0], 0); - _this5.arrayPos = 0; - } - }, this.fadeOutDelay); - } - - /** - * Replaces current text in the HTML element - * depending on element type - * @param {string} str - * @private - */ - }, { - key: 'replaceText', - value: function replaceText(str) { - if (this.attr) { - this.el.setAttribute(this.attr, str); - } else { - if (this.isInput) { - this.el.value = str; - } else if (this.contentType === 'html') { - this.el.innerHTML = str; - } else { - this.el.textContent = str; - } - } - } - - /** - * If using input elements, bind focus in order to - * start and stop the animation - * @private - */ - }, { - key: 'bindFocusEvents', - value: function bindFocusEvents() { - var _this6 = this; - - if (!this.isInput) return; - this.el.addEventListener('focus', function (e) { - _this6.stop(); - }); - this.el.addEventListener('blur', function (e) { - if (_this6.el.value && _this6.el.value.length !== 0) { - return; - } - _this6.start(); - }); - } - - /** - * On init, insert the cursor element - * @private - */ - }, { - key: 'insertCursor', - value: function insertCursor() { - if (!this.showCursor) return; - if (this.cursor) return; - this.cursor = document.createElement('span'); - this.cursor.className = 'typed-cursor'; - this.cursor.setAttribute('aria-hidden', true); - this.cursor.innerHTML = this.cursorChar; - this.el.parentNode && this.el.parentNode.insertBefore(this.cursor, this.el.nextSibling); - } - }]); - - return Typed; - })(); - - exports['default'] = Typed; - module.exports = exports['default']; - -/***/ }), -/* 1 */ -/***/ (function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, '__esModule', { - value: true - }); - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - - var _defaultsJs = __webpack_require__(2); - - var _defaultsJs2 = _interopRequireDefault(_defaultsJs); - - /** - * Initialize the Typed object - */ - - var Initializer = (function () { - function Initializer() { - _classCallCheck(this, Initializer); - } - - _createClass(Initializer, [{ - key: 'load', - - /** - * Load up defaults & options on the Typed instance - * @param {Typed} self instance of Typed - * @param {object} options options object - * @param {string} elementId HTML element ID _OR_ instance of HTML element - * @private - */ - - value: function load(self, options, elementId) { - // chosen element to manipulate text - if (typeof elementId === 'string') { - self.el = document.querySelector(elementId); - } else { - self.el = elementId; - } - - self.options = _extends({}, _defaultsJs2['default'], options); - - // attribute to type into - self.isInput = self.el.tagName.toLowerCase() === 'input'; - self.attr = self.options.attr; - self.bindInputFocusEvents = self.options.bindInputFocusEvents; - - // show cursor - self.showCursor = self.isInput ? false : self.options.showCursor; - - // custom cursor - self.cursorChar = self.options.cursorChar; - - // Is the cursor blinking - self.cursorBlinking = true; - - // text content of element - self.elContent = self.attr ? self.el.getAttribute(self.attr) : self.el.textContent; - - // html or plain text - self.contentType = self.options.contentType; - - // typing speed - self.typeSpeed = self.options.typeSpeed; - - // add a delay before typing starts - self.startDelay = self.options.startDelay; - - // backspacing speed - self.backSpeed = self.options.backSpeed; - - // only backspace what doesn't match the previous string - self.smartBackspace = self.options.smartBackspace; - - // amount of time to wait before backspacing - self.backDelay = self.options.backDelay; - - // Fade out instead of backspace - self.fadeOut = self.options.fadeOut; - self.fadeOutClass = self.options.fadeOutClass; - self.fadeOutDelay = self.options.fadeOutDelay; - - // variable to check whether typing is currently paused - self.isPaused = false; - - // input strings of text - self.strings = self.options.strings.map(function (s) { - return s.trim(); - }); - - // div containing strings - if (typeof self.options.stringsElement === 'string') { - self.stringsElement = document.querySelector(self.options.stringsElement); - } else { - self.stringsElement = self.options.stringsElement; - } - - if (self.stringsElement) { - self.strings = []; - self.stringsElement.style.display = 'none'; - var strings = Array.prototype.slice.apply(self.stringsElement.children); - var stringsLength = strings.length; - - if (stringsLength) { - for (var i = 0; i < stringsLength; i += 1) { - var stringEl = strings[i]; - self.strings.push(stringEl.innerHTML.trim()); - } - } - } - - // character number position of current string - self.strPos = 0; - - // current array position - self.arrayPos = 0; - - // index of string to stop backspacing on - self.stopNum = 0; - - // Looping logic - self.loop = self.options.loop; - self.loopCount = self.options.loopCount; - self.curLoop = 0; - - // shuffle the strings - self.shuffle = self.options.shuffle; - // the order of strings - self.sequence = []; - - self.pause = { - status: false, - typewrite: true, - curString: '', - curStrPos: 0 - }; - - // When the typing is complete (when not looped) - self.typingComplete = false; - - // Set the order in which the strings are typed - for (var i in self.strings) { - self.sequence[i] = i; - } - - // If there is some text in the element - self.currentElContent = this.getCurrentElContent(self); - - self.autoInsertCss = self.options.autoInsertCss; - - this.appendAnimationCss(self); - } - }, { - key: 'getCurrentElContent', - value: function getCurrentElContent(self) { - var elContent = ''; - if (self.attr) { - elContent = self.el.getAttribute(self.attr); - } else if (self.isInput) { - elContent = self.el.value; - } else if (self.contentType === 'html') { - elContent = self.el.innerHTML; - } else { - elContent = self.el.textContent; - } - return elContent; - } - }, { - key: 'appendAnimationCss', - value: function appendAnimationCss(self) { - var cssDataName = 'data-typed-js-css'; - if (!self.autoInsertCss) { - return; - } - if (!self.showCursor && !self.fadeOut) { - return; - } - if (document.querySelector('[' + cssDataName + ']')) { - return; - } - - var css = document.createElement('style'); - css.type = 'text/css'; - css.setAttribute(cssDataName, true); - - var innerCss = ''; - if (self.showCursor) { - innerCss += '\n .typed-cursor{\n opacity: 1;\n }\n .typed-cursor.typed-cursor--blink{\n animation: typedjsBlink 0.7s infinite;\n -webkit-animation: typedjsBlink 0.7s infinite;\n animation: typedjsBlink 0.7s infinite;\n }\n @keyframes typedjsBlink{\n 50% { opacity: 0.0; }\n }\n @-webkit-keyframes typedjsBlink{\n 0% { opacity: 1; }\n 50% { opacity: 0.0; }\n 100% { opacity: 1; }\n }\n '; - } - if (self.fadeOut) { - innerCss += '\n .typed-fade-out{\n opacity: 0;\n transition: opacity .25s;\n }\n .typed-cursor.typed-cursor--blink.typed-fade-out{\n -webkit-animation: 0;\n animation: 0;\n }\n '; - } - if (css.length === 0) { - return; - } - css.innerHTML = innerCss; - document.body.appendChild(css); - } - }]); - - return Initializer; - })(); - - exports['default'] = Initializer; - var initializer = new Initializer(); - exports.initializer = initializer; - -/***/ }), -/* 2 */ -/***/ (function(module, exports) { - - /** - * Defaults & options - * @returns {object} Typed defaults & options - * @public - */ - - 'use strict'; - - Object.defineProperty(exports, '__esModule', { - value: true - }); - var defaults = { - /** - * @property {array} strings strings to be typed - * @property {string} stringsElement ID of element containing string children - */ - strings: ['These are the default values...', 'You know what you should do?', 'Use your own!', 'Have a great day!'], - stringsElement: null, - - /** - * @property {number} typeSpeed type speed in milliseconds - */ - typeSpeed: 0, - - /** - * @property {number} startDelay time before typing starts in milliseconds - */ - startDelay: 0, - - /** - * @property {number} backSpeed backspacing speed in milliseconds - */ - backSpeed: 0, - - /** - * @property {boolean} smartBackspace only backspace what doesn't match the previous string - */ - smartBackspace: true, - - /** - * @property {boolean} shuffle shuffle the strings - */ - shuffle: false, - - /** - * @property {number} backDelay time before backspacing in milliseconds - */ - backDelay: 700, - - /** - * @property {boolean} fadeOut Fade out instead of backspace - * @property {string} fadeOutClass css class for fade animation - * @property {boolean} fadeOutDelay Fade out delay in milliseconds - */ - fadeOut: false, - fadeOutClass: 'typed-fade-out', - fadeOutDelay: 500, - - /** - * @property {boolean} loop loop strings - * @property {number} loopCount amount of loops - */ - loop: false, - loopCount: Infinity, - - /** - * @property {boolean} showCursor show cursor - * @property {string} cursorChar character for cursor - * @property {boolean} autoInsertCss insert CSS for cursor and fadeOut into HTML - */ - showCursor: true, - cursorChar: '|', - autoInsertCss: true, - - /** - * @property {string} attr attribute for typing - * Ex: input placeholder, value, or just HTML text - */ - attr: null, - - /** - * @property {boolean} bindInputFocusEvents bind to focus and blur if el is text input - */ - bindInputFocusEvents: false, - - /** - * @property {string} contentType 'html' or 'null' for plaintext - */ - contentType: 'html', - - /** - * Before it begins typing - * @param {Typed} self - */ - onBegin: function onBegin(self) {}, - - /** - * All typing is complete - * @param {Typed} self - */ - onComplete: function onComplete(self) {}, - - /** - * Before each string is typed - * @param {number} arrayPos - * @param {Typed} self - */ - preStringTyped: function preStringTyped(arrayPos, self) {}, - - /** - * After each string is typed - * @param {number} arrayPos - * @param {Typed} self - */ - onStringTyped: function onStringTyped(arrayPos, self) {}, - - /** - * During looping, after last string is typed - * @param {Typed} self - */ - onLastStringBackspaced: function onLastStringBackspaced(self) {}, - - /** - * Typing has been stopped - * @param {number} arrayPos - * @param {Typed} self - */ - onTypingPaused: function onTypingPaused(arrayPos, self) {}, - - /** - * Typing has been started after being stopped - * @param {number} arrayPos - * @param {Typed} self - */ - onTypingResumed: function onTypingResumed(arrayPos, self) {}, - - /** - * After reset - * @param {Typed} self - */ - onReset: function onReset(self) {}, - - /** - * After stop - * @param {number} arrayPos - * @param {Typed} self - */ - onStop: function onStop(arrayPos, self) {}, - - /** - * After start - * @param {number} arrayPos - * @param {Typed} self - */ - onStart: function onStart(arrayPos, self) {}, - - /** - * After destroy - * @param {Typed} self - */ - onDestroy: function onDestroy(self) {} - }; - - exports['default'] = defaults; - module.exports = exports['default']; - -/***/ }), -/* 3 */ -/***/ (function(module, exports) { - - /** - * TODO: These methods can probably be combined somehow - * Parse HTML tags & HTML Characters - */ - - 'use strict'; - - Object.defineProperty(exports, '__esModule', { - value: true - }); - - var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - - var HTMLParser = (function () { - function HTMLParser() { - _classCallCheck(this, HTMLParser); - } - - _createClass(HTMLParser, [{ - key: 'typeHtmlChars', - - /** - * Type HTML tags & HTML Characters - * @param {string} curString Current string - * @param {number} curStrPos Position in current string - * @param {Typed} self instance of Typed - * @returns {number} a new string position - * @private - */ - - value: function typeHtmlChars(curString, curStrPos, self) { - if (self.contentType !== 'html') return curStrPos; - var curChar = curString.substr(curStrPos).charAt(0); - if (curChar === '<' || curChar === '&') { - var endTag = ''; - if (curChar === '<') { - endTag = '>'; - } else { - endTag = ';'; - } - while (curString.substr(curStrPos + 1).charAt(0) !== endTag) { - curStrPos++; - if (curStrPos + 1 > curString.length) { - break; - } - } - curStrPos++; - } - return curStrPos; - } - - /** - * Backspace HTML tags and HTML Characters - * @param {string} curString Current string - * @param {number} curStrPos Position in current string - * @param {Typed} self instance of Typed - * @returns {number} a new string position - * @private - */ - }, { - key: 'backSpaceHtmlChars', - value: function backSpaceHtmlChars(curString, curStrPos, self) { - if (self.contentType !== 'html') return curStrPos; - var curChar = curString.substr(curStrPos).charAt(0); - if (curChar === '>' || curChar === ';') { - var endTag = ''; - if (curChar === '>') { - endTag = '<'; - } else { - endTag = '&'; - } - while (curString.substr(curStrPos - 1).charAt(0) !== endTag) { - curStrPos--; - if (curStrPos < 0) { - break; - } - } - curStrPos--; - } - return curStrPos; - } - }]); - - return HTMLParser; - })(); - - exports['default'] = HTMLParser; - var htmlParser = new HTMLParser(); - exports.htmlParser = htmlParser; - -/***/ }) -/******/ ]) -}); -; \ No newline at end of file diff --git a/Moonlight/wwwroot/assets/plugins/custom/vis-timeline/vis-timeline.bundle.css b/Moonlight/wwwroot/assets/plugins/custom/vis-timeline/vis-timeline.bundle.css deleted file mode 100644 index fab63d28..00000000 --- a/Moonlight/wwwroot/assets/plugins/custom/vis-timeline/vis-timeline.bundle.css +++ /dev/null @@ -1,1240 +0,0 @@ -@charset "UTF-8"; -/* override some bootstrap styles screwing up the timelines css */ -.vis [class*=span] { - min-height: 0; - width: auto; -} - -.vis-timeline { - /* - -webkit-transition: height .4s ease-in-out; - transition: height .4s ease-in-out; - */ -} - -.vis-panel { - /* - -webkit-transition: height .4s ease-in-out, top .4s ease-in-out; - transition: height .4s ease-in-out, top .4s ease-in-out; - */ -} - -.vis-axis { - /* - -webkit-transition: top .4s ease-in-out; - transition: top .4s ease-in-out; - */ -} - -/* TODO: get animation working nicely - -.vis-item { - -webkit-transition: top .4s ease-in-out; - transition: top .4s ease-in-out; -} - -.vis-item.line { - -webkit-transition: height .4s ease-in-out, top .4s ease-in-out; - transition: height .4s ease-in-out, top .4s ease-in-out; -} -/**/ -.vis-panel { - position: absolute; - padding: 0; - margin: 0; - box-sizing: border-box; -} - -.vis-panel.vis-center, -.vis-panel.vis-left, -.vis-panel.vis-right, -.vis-panel.vis-top, -.vis-panel.vis-bottom { - border: 1px #bfbfbf; -} - -.vis-panel.vis-center, -.vis-panel.vis-left, -.vis-panel.vis-right { - border-top-style: solid; - border-bottom-style: solid; - overflow: hidden; -} - -.vis-left.vis-panel.vis-vertical-scroll, .vis-right.vis-panel.vis-vertical-scroll { - height: 100%; - overflow-x: hidden; - overflow-y: scroll; -} - -.vis-left.vis-panel.vis-vertical-scroll { - direction: rtl; -} - -.vis-left.vis-panel.vis-vertical-scroll .vis-content { - direction: ltr; -} - -.vis-right.vis-panel.vis-vertical-scroll { - direction: ltr; -} - -.vis-right.vis-panel.vis-vertical-scroll .vis-content { - direction: rtl; -} - -.vis-panel.vis-center, -.vis-panel.vis-top, -.vis-panel.vis-bottom { - border-left-style: solid; - border-right-style: solid; -} - -.vis-background { - overflow: hidden; -} - -.vis-panel > .vis-content { - position: relative; -} - -.vis-panel .vis-shadow { - position: absolute; - width: 100%; - height: 1px; - box-shadow: 0 0 10px rgba(0, 0, 0, 0.8); - /* TODO: find a nice way to ensure vis-shadows are drawn on top of items - z-index: 1; - */ -} - -.vis-panel .vis-shadow.vis-top { - top: -1px; - left: 0; -} - -.vis-panel .vis-shadow.vis-bottom { - bottom: -1px; - left: 0; -} - -.vis-graph-group0 { - fill: #4f81bd; - fill-opacity: 0; - stroke-width: 2px; - stroke: #4f81bd; -} - -.vis-graph-group1 { - fill: #f79646; - fill-opacity: 0; - stroke-width: 2px; - stroke: #f79646; -} - -.vis-graph-group2 { - fill: #8c51cf; - fill-opacity: 0; - stroke-width: 2px; - stroke: #8c51cf; -} - -.vis-graph-group3 { - fill: #75c841; - fill-opacity: 0; - stroke-width: 2px; - stroke: #75c841; -} - -.vis-graph-group4 { - fill: #ff0100; - fill-opacity: 0; - stroke-width: 2px; - stroke: #ff0100; -} - -.vis-graph-group5 { - fill: #37d8e6; - fill-opacity: 0; - stroke-width: 2px; - stroke: #37d8e6; -} - -.vis-graph-group6 { - fill: #042662; - fill-opacity: 0; - stroke-width: 2px; - stroke: #042662; -} - -.vis-graph-group7 { - fill: #00ff26; - fill-opacity: 0; - stroke-width: 2px; - stroke: #00ff26; -} - -.vis-graph-group8 { - fill: #ff00ff; - fill-opacity: 0; - stroke-width: 2px; - stroke: #ff00ff; -} - -.vis-graph-group9 { - fill: #8f3938; - fill-opacity: 0; - stroke-width: 2px; - stroke: #8f3938; -} - -.vis-timeline .vis-fill { - fill-opacity: 0.1; - stroke: none; -} - -.vis-timeline .vis-bar { - fill-opacity: 0.5; - stroke-width: 1px; -} - -.vis-timeline .vis-point { - stroke-width: 2px; - fill-opacity: 1; -} - -.vis-timeline .vis-legend-background { - stroke-width: 1px; - fill-opacity: 0.9; - fill: #ffffff; - stroke: #c2c2c2; -} - -.vis-timeline .vis-outline { - stroke-width: 1px; - fill-opacity: 1; - fill: #ffffff; - stroke: #e5e5e5; -} - -.vis-timeline .vis-icon-fill { - fill-opacity: 0.3; - stroke: none; -} - -.vis-current-time { - background-color: #FF7F6E; - width: 2px; - z-index: 1; - pointer-events: none; -} - -.vis-rolling-mode-btn { - height: 40px; - width: 40px; - position: absolute; - top: 7px; - right: 20px; - border-radius: 50%; - font-size: 28px; - cursor: pointer; - opacity: 0.8; - color: white; - font-weight: bold; - text-align: center; - background: #3876c2; -} - -.vis-rolling-mode-btn:before { - content: "⛶"; -} - -.vis-rolling-mode-btn:hover { - opacity: 1; -} - -.vis-timeline { - position: relative; - border: 1px solid #bfbfbf; - overflow: hidden; - padding: 0; - margin: 0; - box-sizing: border-box; -} - -.vis-loading-screen { - width: 100%; - height: 100%; - position: absolute; - top: 0; - left: 0; -} - -.vis-custom-time { - background-color: #6E94FF; - width: 2px; - cursor: move; - z-index: 1; -} - -.vis-custom-time > .vis-custom-time-marker { - background-color: inherit; - color: white; - font-size: 12px; - white-space: nowrap; - padding: 3px 5px; - top: 0px; - cursor: initial; - z-index: inherit; -} - -.vis-panel.vis-background.vis-horizontal .vis-grid.vis-horizontal { - position: absolute; - width: 100%; - height: 0; - border-bottom: 1px solid; -} - -.vis-panel.vis-background.vis-horizontal .vis-grid.vis-minor { - border-color: #e5e5e5; -} - -.vis-panel.vis-background.vis-horizontal .vis-grid.vis-major { - border-color: #bfbfbf; -} - -.vis-data-axis .vis-y-axis.vis-major { - width: 100%; - position: absolute; - color: #4d4d4d; - white-space: nowrap; -} - -.vis-data-axis .vis-y-axis.vis-major.vis-measure { - padding: 0; - margin: 0; - border: 0; - visibility: hidden; - width: auto; -} - -.vis-data-axis .vis-y-axis.vis-minor { - position: absolute; - width: 100%; - color: #bebebe; - white-space: nowrap; -} - -.vis-data-axis .vis-y-axis.vis-minor.vis-measure { - padding: 0; - margin: 0; - border: 0; - visibility: hidden; - width: auto; -} - -.vis-data-axis .vis-y-axis.vis-title { - position: absolute; - color: #4d4d4d; - white-space: nowrap; - bottom: 20px; - text-align: center; -} - -.vis-data-axis .vis-y-axis.vis-title.vis-measure { - padding: 0; - margin: 0; - visibility: hidden; - width: auto; -} - -.vis-data-axis .vis-y-axis.vis-title.vis-left { - bottom: 0; - -webkit-transform-origin: left top; - -moz-transform-origin: left top; - -ms-transform-origin: left top; - -o-transform-origin: left top; - transform-origin: left bottom; - -webkit-transform: rotate(-90deg); - -moz-transform: rotate(-90deg); - -ms-transform: rotate(-90deg); - -o-transform: rotate(-90deg); - transform: rotate(-90deg); -} - -.vis-data-axis .vis-y-axis.vis-title.vis-right { - bottom: 0; - -webkit-transform-origin: right bottom; - -moz-transform-origin: right bottom; - -ms-transform-origin: right bottom; - -o-transform-origin: right bottom; - transform-origin: right bottom; - -webkit-transform: rotate(90deg); - -moz-transform: rotate(90deg); - -ms-transform: rotate(90deg); - -o-transform: rotate(90deg); - transform: rotate(90deg); -} - -.vis-legend { - background-color: rgba(247, 252, 255, 0.65); - padding: 5px; - border: 1px solid #b3b3b3; - box-shadow: 2px 2px 10px rgba(154, 154, 154, 0.55); -} - -.vis-legend-text { - /*font-size: 10px;*/ - white-space: nowrap; - display: inline-block; -} - -.vis-itemset { - position: relative; - padding: 0; - margin: 0; - box-sizing: border-box; -} - -.vis-itemset .vis-background, -.vis-itemset .vis-foreground { - position: absolute; - width: 100%; - height: 100%; - overflow: visible; -} - -.vis-axis { - position: absolute; - width: 100%; - height: 0; - left: 0; - z-index: 1; -} - -.vis-foreground .vis-group { - position: relative; - box-sizing: border-box; - border-bottom: 1px solid #bfbfbf; -} - -.vis-foreground .vis-group:last-child { - border-bottom: none; -} - -.vis-nesting-group { - cursor: pointer; -} - -.vis-label.vis-nested-group.vis-group-level-unknown-but-gte1 { - background: #f5f5f5; -} - -.vis-label.vis-nested-group.vis-group-level-0 { - background-color: #ffffff; -} - -.vis-ltr .vis-label.vis-nested-group.vis-group-level-0 .vis-inner { - padding-left: 0; -} - -.vis-rtl .vis-label.vis-nested-group.vis-group-level-0 .vis-inner { - padding-right: 0; -} - -.vis-label.vis-nested-group.vis-group-level-1 { - background-color: rgba(0, 0, 0, 0.05); -} - -.vis-ltr .vis-label.vis-nested-group.vis-group-level-1 .vis-inner { - padding-left: 15px; -} - -.vis-rtl .vis-label.vis-nested-group.vis-group-level-1 .vis-inner { - padding-right: 15px; -} - -.vis-label.vis-nested-group.vis-group-level-2 { - background-color: rgba(0, 0, 0, 0.1); -} - -.vis-ltr .vis-label.vis-nested-group.vis-group-level-2 .vis-inner { - padding-left: 30px; -} - -.vis-rtl .vis-label.vis-nested-group.vis-group-level-2 .vis-inner { - padding-right: 30px; -} - -.vis-label.vis-nested-group.vis-group-level-3 { - background-color: rgba(0, 0, 0, 0.15); -} - -.vis-ltr .vis-label.vis-nested-group.vis-group-level-3 .vis-inner { - padding-left: 45px; -} - -.vis-rtl .vis-label.vis-nested-group.vis-group-level-3 .vis-inner { - padding-right: 45px; -} - -.vis-label.vis-nested-group.vis-group-level-4 { - background-color: rgba(0, 0, 0, 0.2); -} - -.vis-ltr .vis-label.vis-nested-group.vis-group-level-4 .vis-inner { - padding-left: 60px; -} - -.vis-rtl .vis-label.vis-nested-group.vis-group-level-4 .vis-inner { - padding-right: 60px; -} - -.vis-label.vis-nested-group.vis-group-level-5 { - background-color: rgba(0, 0, 0, 0.25); -} - -.vis-ltr .vis-label.vis-nested-group.vis-group-level-5 .vis-inner { - padding-left: 75px; -} - -.vis-rtl .vis-label.vis-nested-group.vis-group-level-5 .vis-inner { - padding-right: 75px; -} - -.vis-label.vis-nested-group.vis-group-level-6 { - background-color: rgba(0, 0, 0, 0.3); -} - -.vis-ltr .vis-label.vis-nested-group.vis-group-level-6 .vis-inner { - padding-left: 90px; -} - -.vis-rtl .vis-label.vis-nested-group.vis-group-level-6 .vis-inner { - padding-right: 90px; -} - -.vis-label.vis-nested-group.vis-group-level-7 { - background-color: rgba(0, 0, 0, 0.35); -} - -.vis-ltr .vis-label.vis-nested-group.vis-group-level-7 .vis-inner { - padding-left: 105px; -} - -.vis-rtl .vis-label.vis-nested-group.vis-group-level-7 .vis-inner { - padding-right: 105px; -} - -.vis-label.vis-nested-group.vis-group-level-8 { - background-color: rgba(0, 0, 0, 0.4); -} - -.vis-ltr .vis-label.vis-nested-group.vis-group-level-8 .vis-inner { - padding-left: 120px; -} - -.vis-rtl .vis-label.vis-nested-group.vis-group-level-8 .vis-inner { - padding-right: 120px; -} - -.vis-label.vis-nested-group.vis-group-level-9 { - background-color: rgba(0, 0, 0, 0.45); -} - -.vis-ltr .vis-label.vis-nested-group.vis-group-level-9 .vis-inner { - padding-left: 135px; -} - -.vis-rtl .vis-label.vis-nested-group.vis-group-level-9 .vis-inner { - padding-right: 135px; -} - -/* default takes over beginning with level-10 (thats why we add .vis-nested-group - to the selectors above, to have higher specifity than these rules for the defaults) */ -.vis-label.vis-nested-group { - background-color: rgba(0, 0, 0, 0.5); -} - -.vis-ltr .vis-label.vis-nested-group .vis-inner { - padding-left: 150px; -} - -.vis-rtl .vis-label.vis-nested-group .vis-inner { - padding-right: 150px; -} - -.vis-group-level-unknown-but-gte1 { - border: 1px solid red; -} - -/* expanded/collapsed indicators */ -.vis-label.vis-nesting-group:before, -.vis-label.vis-nesting-group:before { - display: inline-block; - width: 15px; -} - -.vis-label.vis-nesting-group.expanded:before { - content: "▼"; -} - -.vis-label.vis-nesting-group.collapsed:before { - content: "▶"; -} - -.vis-rtl .vis-label.vis-nesting-group.collapsed:before { - content: "◀"; -} - -/* compensate missing expanded/collapsed indicator, but only at levels > 0 */ -.vis-ltr .vis-label:not(.vis-nesting-group):not(.vis-group-level-0) { - padding-left: 15px; -} - -.vis-rtl .vis-label:not(.vis-nesting-group):not(.vis-group-level-0) { - padding-right: 15px; -} - -.vis-overlay { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - z-index: 10; -} - -.vis-labelset { - position: relative; - overflow: hidden; - box-sizing: border-box; -} - -.vis-labelset .vis-label { - position: relative; - left: 0; - top: 0; - width: 100%; - color: #4d4d4d; - box-sizing: border-box; -} - -.vis-labelset .vis-label { - border-bottom: 1px solid #bfbfbf; -} - -.vis-labelset .vis-label.draggable { - cursor: pointer; -} - -.vis-group-is-dragging { - background: rgba(0, 0, 0, 0.1); -} - -.vis-labelset .vis-label:last-child { - border-bottom: none; -} - -.vis-labelset .vis-label .vis-inner { - display: inline-block; - padding: 5px; -} - -.vis-labelset .vis-label .vis-inner.vis-hidden { - padding: 0; -} - -.vis-time-axis { - position: relative; - overflow: hidden; -} - -.vis-time-axis.vis-foreground { - top: 0; - left: 0; - width: 100%; -} - -.vis-time-axis.vis-background { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; -} - -.vis-time-axis .vis-text { - position: absolute; - color: #4d4d4d; - padding: 3px; - overflow: hidden; - box-sizing: border-box; - white-space: nowrap; -} - -.vis-time-axis .vis-text.vis-measure { - position: absolute; - padding-left: 0; - padding-right: 0; - margin-left: 0; - margin-right: 0; - visibility: hidden; -} - -.vis-time-axis .vis-grid.vis-vertical { - position: absolute; - border-left: 1px solid; -} - -.vis-time-axis .vis-grid.vis-vertical-rtl { - position: absolute; - border-right: 1px solid; -} - -.vis-time-axis .vis-grid.vis-minor { - border-color: #e5e5e5; -} - -.vis-time-axis .vis-grid.vis-major { - border-color: #bfbfbf; -} - -.vis-item { - position: absolute; - color: #1A1A1A; - border-color: #97B0F8; - border-width: 1px; - background-color: #D5DDF6; - display: inline-block; - z-index: 1; - /*overflow: hidden;*/ -} - -.vis-item.vis-selected { - border-color: #FFC200; - background-color: #FFF785; - /* z-index must be higher than the z-index of custom time bar and current time bar */ - z-index: 2; -} - -.vis-editable.vis-selected { - cursor: move; -} - -.vis-item.vis-point.vis-selected { - background-color: #FFF785; -} - -.vis-item.vis-box { - text-align: center; - border-style: solid; - border-radius: 2px; -} - -.vis-item.vis-point { - background: none; -} - -.vis-item.vis-dot { - position: absolute; - padding: 0; - border-width: 4px; - border-style: solid; - border-radius: 4px; -} - -.vis-item.vis-range { - border-style: solid; - border-radius: 2px; - box-sizing: border-box; -} - -.vis-item.vis-background { - border: none; - background-color: rgba(213, 221, 246, 0.4); - box-sizing: border-box; - padding: 0; - margin: 0; -} - -.vis-item .vis-item-overflow { - position: relative; - width: 100%; - height: 100%; - padding: 0; - margin: 0; - overflow: hidden; -} - -.vis-item-visible-frame { - white-space: nowrap; -} - -.vis-item.vis-range .vis-item-content { - position: relative; - display: inline-block; -} - -.vis-item.vis-background .vis-item-content { - position: absolute; - display: inline-block; -} - -.vis-item.vis-line { - padding: 0; - position: absolute; - width: 0; - border-left-width: 1px; - border-left-style: solid; -} - -.vis-item .vis-item-content { - white-space: nowrap; - box-sizing: border-box; - padding: 5px; -} - -.vis-item .vis-onUpdateTime-tooltip { - position: absolute; - background: #4f81bd; - color: white; - width: 200px; - text-align: center; - white-space: nowrap; - padding: 5px; - border-radius: 1px; - transition: 0.4s; - -o-transition: 0.4s; - -moz-transition: 0.4s; - -webkit-transition: 0.4s; -} - -.vis-item .vis-delete, .vis-item .vis-delete-rtl { - position: absolute; - top: 0px; - width: 24px; - height: 24px; - box-sizing: border-box; - padding: 0px 5px; - cursor: pointer; - -webkit-transition: background 0.2s linear; - -moz-transition: background 0.2s linear; - -ms-transition: background 0.2s linear; - -o-transition: background 0.2s linear; - transition: background 0.2s linear; -} - -.vis-item .vis-delete { - right: -24px; -} - -.vis-item .vis-delete-rtl { - left: -24px; -} - -.vis-item .vis-delete:after, .vis-item .vis-delete-rtl:after { - content: "×"; /* MULTIPLICATION SIGN */ - color: red; - font-family: arial, sans-serif; - font-size: 22px; - font-weight: bold; - -webkit-transition: color 0.2s linear; - -moz-transition: color 0.2s linear; - -ms-transition: color 0.2s linear; - -o-transition: color 0.2s linear; - transition: color 0.2s linear; -} - -.vis-item .vis-delete:hover, .vis-item .vis-delete-rtl:hover { - background: red; -} - -.vis-item .vis-delete:hover:after, .vis-item .vis-delete-rtl:hover:after { - color: white; -} - -.vis-item .vis-drag-center { - position: absolute; - width: 100%; - height: 100%; - top: 0; - left: 0px; - cursor: move; -} - -.vis-item.vis-range .vis-drag-left { - position: absolute; - width: 24px; - max-width: 20%; - min-width: 2px; - height: 100%; - top: 0; - left: -4px; - cursor: w-resize; -} - -.vis-item.vis-range .vis-drag-right { - position: absolute; - width: 24px; - max-width: 20%; - min-width: 2px; - height: 100%; - top: 0; - right: -4px; - cursor: e-resize; -} - -.vis-range.vis-item.vis-readonly .vis-drag-left, -.vis-range.vis-item.vis-readonly .vis-drag-right { - cursor: auto; -} - -.vis-item.vis-cluster { - vertical-align: center; - text-align: center; - border-style: solid; - border-radius: 2px; -} - -.vis-item.vis-cluster-line { - padding: 0; - position: absolute; - width: 0; - border-left-width: 1px; - border-left-style: solid; -} - -.vis-item.vis-cluster-dot { - position: absolute; - padding: 0; - border-width: 4px; - border-style: solid; - border-radius: 4px; -} - -div.vis-configuration { - position: relative; - display: block; - float: left; - font-size: 12px; -} - -div.vis-configuration-wrapper { - display: block; - width: 700px; -} - -div.vis-configuration-wrapper::after { - clear: both; - content: ""; - display: block; -} - -div.vis-configuration.vis-config-option-container { - display: block; - width: 495px; - background-color: #ffffff; - border: 2px solid #f7f8fa; - border-radius: 4px; - margin-top: 20px; - left: 10px; - padding-left: 5px; -} - -div.vis-configuration.vis-config-button { - display: block; - width: 495px; - height: 25px; - vertical-align: middle; - line-height: 25px; - background-color: #f7f8fa; - border: 2px solid #ceced0; - border-radius: 4px; - margin-top: 20px; - left: 10px; - padding-left: 5px; - cursor: pointer; - margin-bottom: 30px; -} - -div.vis-configuration.vis-config-button.hover { - background-color: #4588e6; - border: 2px solid #214373; - color: #ffffff; -} - -div.vis-configuration.vis-config-item { - display: block; - float: left; - width: 495px; - height: 25px; - vertical-align: middle; - line-height: 25px; -} - -div.vis-configuration.vis-config-item.vis-config-s2 { - left: 10px; - background-color: #f7f8fa; - padding-left: 5px; - border-radius: 3px; -} - -div.vis-configuration.vis-config-item.vis-config-s3 { - left: 20px; - background-color: #e4e9f0; - padding-left: 5px; - border-radius: 3px; -} - -div.vis-configuration.vis-config-item.vis-config-s4 { - left: 30px; - background-color: #cfd8e6; - padding-left: 5px; - border-radius: 3px; -} - -div.vis-configuration.vis-config-header { - font-size: 18px; - font-weight: bold; -} - -div.vis-configuration.vis-config-label { - width: 120px; - height: 25px; - line-height: 25px; -} - -div.vis-configuration.vis-config-label.vis-config-s3 { - width: 110px; -} - -div.vis-configuration.vis-config-label.vis-config-s4 { - width: 100px; -} - -div.vis-configuration.vis-config-colorBlock { - top: 1px; - width: 30px; - height: 19px; - border: 1px solid #444444; - border-radius: 2px; - padding: 0px; - margin: 0px; - cursor: pointer; -} - -input.vis-configuration.vis-config-checkbox { - left: -5px; -} - -input.vis-configuration.vis-config-rangeinput { - position: relative; - top: -5px; - width: 60px; - /*height:13px;*/ - padding: 1px; - margin: 0; - pointer-events: none; -} - -input.vis-configuration.vis-config-range { - /*removes default webkit styles*/ - -webkit-appearance: none; - /*fix for FF unable to apply focus style bug */ - border: 0px solid white; - background-color: rgba(0, 0, 0, 0); - /*required for proper track sizing in FF*/ - width: 300px; - height: 20px; -} - -input.vis-configuration.vis-config-range::-webkit-slider-runnable-track { - width: 300px; - height: 5px; - background: #dedede; /* Old browsers */ - background: -moz-linear-gradient(top, #dedede 0%, #c8c8c8 99%); /* FF3.6+ */ - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #dedede), color-stop(99%, #c8c8c8)); /* Chrome,Safari4+ */ - background: -webkit-linear-gradient(top, #dedede 0%, #c8c8c8 99%); /* Chrome10+,Safari5.1+ */ - background: -o-linear-gradient(top, #dedede 0%, #c8c8c8 99%); /* Opera 11.10+ */ - background: -ms-linear-gradient(top, #dedede 0%, #c8c8c8 99%); /* IE10+ */ - background: linear-gradient(to bottom, #dedede 0%, #c8c8c8 99%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr="#dedede", endColorstr="#c8c8c8",GradientType=0 ); /* IE6-9 */ - border: 1px solid #999999; - box-shadow: #aaaaaa 0px 0px 3px 0px; - border-radius: 3px; -} - -input.vis-configuration.vis-config-range::-webkit-slider-thumb { - -webkit-appearance: none; - border: 1px solid #14334b; - height: 17px; - width: 17px; - border-radius: 50%; - background: #3876c2; /* Old browsers */ - background: -moz-linear-gradient(top, #3876c2 0%, #385380 100%); /* FF3.6+ */ - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #3876c2), color-stop(100%, #385380)); /* Chrome,Safari4+ */ - background: -webkit-linear-gradient(top, #3876c2 0%, #385380 100%); /* Chrome10+,Safari5.1+ */ - background: -o-linear-gradient(top, #3876c2 0%, #385380 100%); /* Opera 11.10+ */ - background: -ms-linear-gradient(top, #3876c2 0%, #385380 100%); /* IE10+ */ - background: linear-gradient(to bottom, #3876c2 0%, #385380 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr="#3876c2", endColorstr="#385380",GradientType=0 ); /* IE6-9 */ - box-shadow: #111927 0px 0px 1px 0px; - margin-top: -7px; -} - -input.vis-configuration.vis-config-range:focus { - outline: none; -} - -input.vis-configuration.vis-config-range:focus::-webkit-slider-runnable-track { - background: #9d9d9d; /* Old browsers */ - background: -moz-linear-gradient(top, #9d9d9d 0%, #c8c8c8 99%); /* FF3.6+ */ - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #9d9d9d), color-stop(99%, #c8c8c8)); /* Chrome,Safari4+ */ - background: -webkit-linear-gradient(top, #9d9d9d 0%, #c8c8c8 99%); /* Chrome10+,Safari5.1+ */ - background: -o-linear-gradient(top, #9d9d9d 0%, #c8c8c8 99%); /* Opera 11.10+ */ - background: -ms-linear-gradient(top, #9d9d9d 0%, #c8c8c8 99%); /* IE10+ */ - background: linear-gradient(to bottom, #9d9d9d 0%, #c8c8c8 99%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr="#9d9d9d", endColorstr="#c8c8c8",GradientType=0 ); /* IE6-9 */ -} - -input.vis-configuration.vis-config-range::-moz-range-track { - width: 300px; - height: 10px; - background: #dedede; /* Old browsers */ - background: -moz-linear-gradient(top, #dedede 0%, #c8c8c8 99%); /* FF3.6+ */ - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #dedede), color-stop(99%, #c8c8c8)); /* Chrome,Safari4+ */ - background: -webkit-linear-gradient(top, #dedede 0%, #c8c8c8 99%); /* Chrome10+,Safari5.1+ */ - background: -o-linear-gradient(top, #dedede 0%, #c8c8c8 99%); /* Opera 11.10+ */ - background: -ms-linear-gradient(top, #dedede 0%, #c8c8c8 99%); /* IE10+ */ - background: linear-gradient(to bottom, #dedede 0%, #c8c8c8 99%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr="#dedede", endColorstr="#c8c8c8",GradientType=0 ); /* IE6-9 */ - border: 1px solid #999999; - box-shadow: #aaaaaa 0px 0px 3px 0px; - border-radius: 3px; -} - -input.vis-configuration.vis-config-range::-moz-range-thumb { - border: none; - height: 16px; - width: 16px; - border-radius: 50%; - background: #385380; -} - -/*hide the outline behind the border*/ -input.vis-configuration.vis-config-range:-moz-focusring { - outline: 1px solid white; - outline-offset: -1px; -} - -input.vis-configuration.vis-config-range::-ms-track { - width: 300px; - height: 5px; - /*remove bg colour from the track, we'll use ms-fill-lower and ms-fill-upper instead */ - background: transparent; - /*leave room for the larger thumb to overflow with a transparent border */ - border-color: transparent; - border-width: 6px 0; - /*remove default tick marks*/ - color: transparent; -} - -input.vis-configuration.vis-config-range::-ms-fill-lower { - background: #777; - border-radius: 10px; -} - -input.vis-configuration.vis-config-range::-ms-fill-upper { - background: #ddd; - border-radius: 10px; -} - -input.vis-configuration.vis-config-range::-ms-thumb { - border: none; - height: 16px; - width: 16px; - border-radius: 50%; - background: #385380; -} - -input.vis-configuration.vis-config-range:focus::-ms-fill-lower { - background: #888; -} - -input.vis-configuration.vis-config-range:focus::-ms-fill-upper { - background: #ccc; -} - -.vis-configuration-popup { - position: absolute; - background: rgba(57, 76, 89, 0.85); - border: 2px solid #f2faff; - line-height: 30px; - height: 30px; - width: 150px; - text-align: center; - color: #ffffff; - font-size: 14px; - border-radius: 4px; - -webkit-transition: opacity 0.3s ease-in-out; - -moz-transition: opacity 0.3s ease-in-out; - transition: opacity 0.3s ease-in-out; -} - -.vis-configuration-popup:after, .vis-configuration-popup:before { - left: 100%; - top: 50%; - border: solid transparent; - content: " "; - height: 0; - width: 0; - position: absolute; - pointer-events: none; -} - -.vis-configuration-popup:after { - border-color: rgba(136, 183, 213, 0); - border-left-color: rgba(57, 76, 89, 0.85); - border-width: 8px; - margin-top: -8px; -} - -.vis-configuration-popup:before { - border-color: rgba(194, 225, 245, 0); - border-left-color: #f2faff; - border-width: 12px; - margin-top: -12px; -} - -.vis .overlay { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - /* Must be displayed above for example selected Timeline items */ - z-index: 10; -} - -.vis-active { - box-shadow: 0 0 10px #86d5f8; -} - -div.vis-tooltip { - position: absolute; - visibility: hidden; - padding: 5px; - white-space: nowrap; - font-family: verdana; - font-size: 14px; - color: #000000; - background-color: #f5f4ed; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; - border: 1px solid #808074; - box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.2); - pointer-events: none; - z-index: 5; -} \ No newline at end of file diff --git a/Moonlight/wwwroot/assets/plugins/custom/vis-timeline/vis-timeline.bundle.js b/Moonlight/wwwroot/assets/plugins/custom/vis-timeline/vis-timeline.bundle.js deleted file mode 100644 index 2c6b7fe6..00000000 --- a/Moonlight/wwwroot/assets/plugins/custom/vis-timeline/vis-timeline.bundle.js +++ /dev/null @@ -1,64 +0,0 @@ -/** - * vis-timeline and vis-graph2d - * https://visjs.github.io/vis-timeline/ - * - * Create a fully customizable, interactive timeline with items and ranges. - * - * @version 7.5.1 - * @date 2022-03-01T18:26:09.239Z - * - * @copyright (c) 2011-2017 Almende B.V, http://almende.com - * @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs - * - * @license - * vis.js is dual licensed under both - * - * 1. The Apache 2.0 License - * http://www.apache.org/licenses/LICENSE-2.0 - * - * and - * - * 2. The MIT License - * http://opensource.org/licenses/MIT - * - * vis.js may be distributed under either license. - */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).vis=t.vis||{})}(this,(function(t){var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var o={exports:{}};!function(t,e){t.exports=function(){var e,i;function o(){return e.apply(null,arguments)}function r(t){e=t}function s(t){return t instanceof Array||"[object Array]"===Object.prototype.toString.call(t)}function a(t){return null!=t&&"[object Object]"===Object.prototype.toString.call(t)}function l(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function h(t){if(Object.getOwnPropertyNames)return 0===Object.getOwnPropertyNames(t).length;var e;for(e in t)if(l(t,e))return!1;return!0}function u(t){return void 0===t}function d(t){return"number"==typeof t||"[object Number]"===Object.prototype.toString.call(t)}function c(t){return t instanceof Date||"[object Date]"===Object.prototype.toString.call(t)}function p(t,e){var i,n=[];for(i=0;i>>0;for(e=0;e0)for(i=0;i<_.length;i++)u(o=e[n=_[i]])||(t[n]=o);return t}function x(t){k(this,t),this._d=new Date(null!=t._d?t._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),!1===w&&(w=!0,o.updateOffset(this),w=!1)}function D(t){return t instanceof x||null!=t&&null!=t._isAMomentObject}function S(t){!1===o.suppressDeprecationWarnings&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+t)}function C(t,e){var i=!0;return f((function(){if(null!=o.deprecationHandler&&o.deprecationHandler(null,t),i){var n,r,s,a=[];for(r=0;r=0?i?"+":"":"-")+Math.pow(10,Math.max(0,o)).toString().substr(1)+n}var R=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,Y=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,j={},H={};function z(t,e,i,n){var o=n;"string"==typeof n&&(o=function(){return this[n]()}),t&&(H[t]=o),e&&(H[e[0]]=function(){return F(o.apply(this,arguments),e[1],e[2])}),i&&(H[i]=function(){return this.localeData().ordinal(o.apply(this,arguments),t)})}function G(t){return t.match(/\[[\s\S]/)?t.replace(/^\[|\]$/g,""):t.replace(/\\/g,"")}function B(t){var e,i,n=t.match(R);for(e=0,i=n.length;e=0&&Y.test(t);)t=t.replace(Y,n),Y.lastIndex=0,i-=1;return t}var U={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};function X(t){var e=this._longDateFormat[t],i=this._longDateFormat[t.toUpperCase()];return e||!i?e:(this._longDateFormat[t]=i.match(R).map((function(t){return"MMMM"===t||"MM"===t||"DD"===t||"dddd"===t?t.slice(1):t})).join(""),this._longDateFormat[t])}var q="Invalid date";function Z(){return this._invalidDate}var $="%d",K=/\d{1,2}/;function J(t){return this._ordinal.replace("%d",t)}var Q={future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function tt(t,e,i,n){var o=this._relativeTime[i];return E(o)?o(t,e,i,n):o.replace(/%d/i,t)}function et(t,e){var i=this._relativeTime[t>0?"future":"past"];return E(i)?i(e):i.replace(/%s/i,e)}var it={};function nt(t,e){var i=t.toLowerCase();it[i]=it[i+"s"]=it[e]=t}function ot(t){return"string"==typeof t?it[t]||it[t.toLowerCase()]:void 0}function rt(t){var e,i,n={};for(i in t)l(t,i)&&(e=ot(i))&&(n[e]=t[i]);return n}var st={};function at(t,e){st[t]=e}function lt(t){var e,i=[];for(e in t)l(t,e)&&i.push({unit:e,priority:st[e]});return i.sort((function(t,e){return t.priority-e.priority})),i}function ht(t){return t%4==0&&t%100!=0||t%400==0}function ut(t){return t<0?Math.ceil(t)||0:Math.floor(t)}function dt(t){var e=+t,i=0;return 0!==e&&isFinite(e)&&(i=ut(e)),i}function ct(t,e){return function(i){return null!=i?(ft(this,t,i),o.updateOffset(this,e),this):pt(this,t)}}function pt(t,e){return t.isValid()?t._d["get"+(t._isUTC?"UTC":"")+e]():NaN}function ft(t,e,i){t.isValid()&&!isNaN(i)&&("FullYear"===e&&ht(t.year())&&1===t.month()&&29===t.date()?(i=dt(i),t._d["set"+(t._isUTC?"UTC":"")+e](i,t.month(),te(i,t.month()))):t._d["set"+(t._isUTC?"UTC":"")+e](i))}function mt(t){return E(this[t=ot(t)])?this[t]():this}function vt(t,e){if("object"==typeof t){var i,n=lt(t=rt(t));for(i=0;i68?1900:2e3)};var ge=ct("FullYear",!0);function ye(){return ht(this.year())}function be(t,e,i,n,o,r,s){var a;return t<100&&t>=0?(a=new Date(t+400,e,i,n,o,r,s),isFinite(a.getFullYear())&&a.setFullYear(t)):a=new Date(t,e,i,n,o,r,s),a}function _e(t){var e,i;return t<100&&t>=0?((i=Array.prototype.slice.call(arguments))[0]=t+400,e=new Date(Date.UTC.apply(null,i)),isFinite(e.getUTCFullYear())&&e.setUTCFullYear(t)):e=new Date(Date.UTC.apply(null,arguments)),e}function we(t,e,i){var n=7+e-i;return-(7+_e(t,0,n).getUTCDay()-e)%7+n-1}function ke(t,e,i,n,o){var r,s,a=1+7*(e-1)+(7+i-n)%7+we(t,n,o);return a<=0?s=ve(r=t-1)+a:a>ve(t)?(r=t+1,s=a-ve(t)):(r=t,s=a),{year:r,dayOfYear:s}}function xe(t,e,i){var n,o,r=we(t.year(),e,i),s=Math.floor((t.dayOfYear()-r-1)/7)+1;return s<1?n=s+De(o=t.year()-1,e,i):s>De(t.year(),e,i)?(n=s-De(t.year(),e,i),o=t.year()+1):(o=t.year(),n=s),{week:n,year:o}}function De(t,e,i){var n=we(t,e,i),o=we(t+1,e,i);return(ve(t)-n+o)/7}function Se(t){return xe(t,this._week.dow,this._week.doy).week}z("w",["ww",2],"wo","week"),z("W",["WW",2],"Wo","isoWeek"),nt("week","w"),nt("isoWeek","W"),at("week",5),at("isoWeek",5),Nt("w",xt),Nt("ww",xt,bt),Nt("W",xt),Nt("WW",xt,bt),zt(["w","ww","W","WW"],(function(t,e,i,n){e[n.substr(0,1)]=dt(t)}));var Ce={dow:0,doy:6};function Te(){return this._week.dow}function Me(){return this._week.doy}function Oe(t){var e=this.localeData().week(this);return null==t?e:this.add(7*(t-e),"d")}function Ee(t){var e=xe(this,1,4).week;return null==t?e:this.add(7*(t-e),"d")}function Pe(t,e){return"string"!=typeof t?t:isNaN(t)?"number"==typeof(t=e.weekdaysParse(t))?t:null:parseInt(t,10)}function Ae(t,e){return"string"==typeof t?e.weekdaysParse(t)%7||7:isNaN(t)?null:t}function Ie(t,e){return t.slice(e,7).concat(t.slice(0,e))}z("d",0,"do","day"),z("dd",0,0,(function(t){return this.localeData().weekdaysMin(this,t)})),z("ddd",0,0,(function(t){return this.localeData().weekdaysShort(this,t)})),z("dddd",0,0,(function(t){return this.localeData().weekdays(this,t)})),z("e",0,0,"weekday"),z("E",0,0,"isoWeekday"),nt("day","d"),nt("weekday","e"),nt("isoWeekday","E"),at("day",11),at("weekday",11),at("isoWeekday",11),Nt("d",xt),Nt("e",xt),Nt("E",xt),Nt("dd",(function(t,e){return e.weekdaysMinRegex(t)})),Nt("ddd",(function(t,e){return e.weekdaysShortRegex(t)})),Nt("dddd",(function(t,e){return e.weekdaysRegex(t)})),zt(["dd","ddd","dddd"],(function(t,e,i,n){var o=i._locale.weekdaysParse(t,n,i._strict);null!=o?e.d=o:g(i).invalidWeekday=t})),zt(["d","e","E"],(function(t,e,i,n){e[n]=dt(t)}));var Le="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),Ne="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),Fe="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),Re=Lt,Ye=Lt,je=Lt;function He(t,e){var i=s(this._weekdays)?this._weekdays:this._weekdays[t&&!0!==t&&this._weekdays.isFormat.test(e)?"format":"standalone"];return!0===t?Ie(i,this._week.dow):t?i[t.day()]:i}function ze(t){return!0===t?Ie(this._weekdaysShort,this._week.dow):t?this._weekdaysShort[t.day()]:this._weekdaysShort}function Ge(t){return!0===t?Ie(this._weekdaysMin,this._week.dow):t?this._weekdaysMin[t.day()]:this._weekdaysMin}function Be(t,e,i){var n,o,r,s=t.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],n=0;n<7;++n)r=m([2e3,1]).day(n),this._minWeekdaysParse[n]=this.weekdaysMin(r,"").toLocaleLowerCase(),this._shortWeekdaysParse[n]=this.weekdaysShort(r,"").toLocaleLowerCase(),this._weekdaysParse[n]=this.weekdays(r,"").toLocaleLowerCase();return i?"dddd"===e?-1!==(o=Bt.call(this._weekdaysParse,s))?o:null:"ddd"===e?-1!==(o=Bt.call(this._shortWeekdaysParse,s))?o:null:-1!==(o=Bt.call(this._minWeekdaysParse,s))?o:null:"dddd"===e?-1!==(o=Bt.call(this._weekdaysParse,s))||-1!==(o=Bt.call(this._shortWeekdaysParse,s))||-1!==(o=Bt.call(this._minWeekdaysParse,s))?o:null:"ddd"===e?-1!==(o=Bt.call(this._shortWeekdaysParse,s))||-1!==(o=Bt.call(this._weekdaysParse,s))||-1!==(o=Bt.call(this._minWeekdaysParse,s))?o:null:-1!==(o=Bt.call(this._minWeekdaysParse,s))||-1!==(o=Bt.call(this._weekdaysParse,s))||-1!==(o=Bt.call(this._shortWeekdaysParse,s))?o:null}function We(t,e,i){var n,o,r;if(this._weekdaysParseExact)return Be.call(this,t,e,i);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),n=0;n<7;n++){if(o=m([2e3,1]).day(n),i&&!this._fullWeekdaysParse[n]&&(this._fullWeekdaysParse[n]=new RegExp("^"+this.weekdays(o,"").replace(".","\\.?")+"$","i"),this._shortWeekdaysParse[n]=new RegExp("^"+this.weekdaysShort(o,"").replace(".","\\.?")+"$","i"),this._minWeekdaysParse[n]=new RegExp("^"+this.weekdaysMin(o,"").replace(".","\\.?")+"$","i")),this._weekdaysParse[n]||(r="^"+this.weekdays(o,"")+"|^"+this.weekdaysShort(o,"")+"|^"+this.weekdaysMin(o,""),this._weekdaysParse[n]=new RegExp(r.replace(".",""),"i")),i&&"dddd"===e&&this._fullWeekdaysParse[n].test(t))return n;if(i&&"ddd"===e&&this._shortWeekdaysParse[n].test(t))return n;if(i&&"dd"===e&&this._minWeekdaysParse[n].test(t))return n;if(!i&&this._weekdaysParse[n].test(t))return n}}function Ve(t){if(!this.isValid())return null!=t?this:NaN;var e=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=t?(t=Pe(t,this.localeData()),this.add(t-e,"d")):e}function Ue(t){if(!this.isValid())return null!=t?this:NaN;var e=(this.day()+7-this.localeData()._week.dow)%7;return null==t?e:this.add(t-e,"d")}function Xe(t){if(!this.isValid())return null!=t?this:NaN;if(null!=t){var e=Ae(t,this.localeData());return this.day(this.day()%7?e:e-7)}return this.day()||7}function qe(t){return this._weekdaysParseExact?(l(this,"_weekdaysRegex")||Ke.call(this),t?this._weekdaysStrictRegex:this._weekdaysRegex):(l(this,"_weekdaysRegex")||(this._weekdaysRegex=Re),this._weekdaysStrictRegex&&t?this._weekdaysStrictRegex:this._weekdaysRegex)}function Ze(t){return this._weekdaysParseExact?(l(this,"_weekdaysRegex")||Ke.call(this),t?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(l(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=Ye),this._weekdaysShortStrictRegex&&t?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function $e(t){return this._weekdaysParseExact?(l(this,"_weekdaysRegex")||Ke.call(this),t?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(l(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=je),this._weekdaysMinStrictRegex&&t?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function Ke(){function t(t,e){return e.length-t.length}var e,i,n,o,r,s=[],a=[],l=[],h=[];for(e=0;e<7;e++)i=m([2e3,1]).day(e),n=Yt(this.weekdaysMin(i,"")),o=Yt(this.weekdaysShort(i,"")),r=Yt(this.weekdays(i,"")),s.push(n),a.push(o),l.push(r),h.push(n),h.push(o),h.push(r);s.sort(t),a.sort(t),l.sort(t),h.sort(t),this._weekdaysRegex=new RegExp("^("+h.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+l.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+a.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+s.join("|")+")","i")}function Je(){return this.hours()%12||12}function Qe(){return this.hours()||24}function ti(t,e){z(t,0,0,(function(){return this.localeData().meridiem(this.hours(),this.minutes(),e)}))}function ei(t,e){return e._meridiemParse}function ii(t){return"p"===(t+"").toLowerCase().charAt(0)}z("H",["HH",2],0,"hour"),z("h",["hh",2],0,Je),z("k",["kk",2],0,Qe),z("hmm",0,0,(function(){return""+Je.apply(this)+F(this.minutes(),2)})),z("hmmss",0,0,(function(){return""+Je.apply(this)+F(this.minutes(),2)+F(this.seconds(),2)})),z("Hmm",0,0,(function(){return""+this.hours()+F(this.minutes(),2)})),z("Hmmss",0,0,(function(){return""+this.hours()+F(this.minutes(),2)+F(this.seconds(),2)})),ti("a",!0),ti("A",!1),nt("hour","h"),at("hour",13),Nt("a",ei),Nt("A",ei),Nt("H",xt),Nt("h",xt),Nt("k",xt),Nt("HH",xt,bt),Nt("hh",xt,bt),Nt("kk",xt,bt),Nt("hmm",Dt),Nt("hmmss",St),Nt("Hmm",Dt),Nt("Hmmss",St),Ht(["H","HH"],Xt),Ht(["k","kk"],(function(t,e,i){var n=dt(t);e[Xt]=24===n?0:n})),Ht(["a","A"],(function(t,e,i){i._isPm=i._locale.isPM(t),i._meridiem=t})),Ht(["h","hh"],(function(t,e,i){e[Xt]=dt(t),g(i).bigHour=!0})),Ht("hmm",(function(t,e,i){var n=t.length-2;e[Xt]=dt(t.substr(0,n)),e[qt]=dt(t.substr(n)),g(i).bigHour=!0})),Ht("hmmss",(function(t,e,i){var n=t.length-4,o=t.length-2;e[Xt]=dt(t.substr(0,n)),e[qt]=dt(t.substr(n,2)),e[Zt]=dt(t.substr(o)),g(i).bigHour=!0})),Ht("Hmm",(function(t,e,i){var n=t.length-2;e[Xt]=dt(t.substr(0,n)),e[qt]=dt(t.substr(n))})),Ht("Hmmss",(function(t,e,i){var n=t.length-4,o=t.length-2;e[Xt]=dt(t.substr(0,n)),e[qt]=dt(t.substr(n,2)),e[Zt]=dt(t.substr(o))}));var ni=/[ap]\.?m?\.?/i,oi=ct("Hours",!0);function ri(t,e,i){return t>11?i?"pm":"PM":i?"am":"AM"}var si,ai={calendar:L,longDateFormat:U,invalidDate:q,ordinal:$,dayOfMonthOrdinalParse:K,relativeTime:Q,months:ee,monthsShort:ie,week:Ce,weekdays:Le,weekdaysMin:Fe,weekdaysShort:Ne,meridiemParse:ni},li={},hi={};function ui(t,e){var i,n=Math.min(t.length,e.length);for(i=0;i0;){if(n=pi(o.slice(0,e).join("-")))return n;if(i&&i.length>=e&&ui(o,i)>=e-1)break;e--}r++}return si}function pi(e){var i=null;if(void 0===li[e]&&t&&t.exports)try{i=si._abbr,n("./locale/"+e),fi(i)}catch(t){li[e]=null}return li[e]}function fi(t,e){var i;return t&&((i=u(e)?gi(t):mi(t,e))?si=i:"undefined"!=typeof console&&console.warn&&console.warn("Locale "+t+" not found. Did you forget to load it?")),si._abbr}function mi(t,e){if(null!==e){var i,n=ai;if(e.abbr=t,null!=li[t])O("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),n=li[t]._config;else if(null!=e.parentLocale)if(null!=li[e.parentLocale])n=li[e.parentLocale]._config;else{if(null==(i=pi(e.parentLocale)))return hi[e.parentLocale]||(hi[e.parentLocale]=[]),hi[e.parentLocale].push({name:t,config:e}),null;n=i._config}return li[t]=new I(A(n,e)),hi[t]&&hi[t].forEach((function(t){mi(t.name,t.config)})),fi(t),li[t]}return delete li[t],null}function vi(t,e){if(null!=e){var i,n,o=ai;null!=li[t]&&null!=li[t].parentLocale?li[t].set(A(li[t]._config,e)):(null!=(n=pi(t))&&(o=n._config),e=A(o,e),null==n&&(e.abbr=t),(i=new I(e)).parentLocale=li[t],li[t]=i),fi(t)}else null!=li[t]&&(null!=li[t].parentLocale?(li[t]=li[t].parentLocale,t===fi()&&fi(t)):null!=li[t]&&delete li[t]);return li[t]}function gi(t){var e;if(t&&t._locale&&t._locale._abbr&&(t=t._locale._abbr),!t)return si;if(!s(t)){if(e=pi(t))return e;t=[t]}return ci(t)}function yi(){return T(li)}function bi(t){var e,i=t._a;return i&&-2===g(t).overflow&&(e=i[Vt]<0||i[Vt]>11?Vt:i[Ut]<1||i[Ut]>te(i[Wt],i[Vt])?Ut:i[Xt]<0||i[Xt]>24||24===i[Xt]&&(0!==i[qt]||0!==i[Zt]||0!==i[$t])?Xt:i[qt]<0||i[qt]>59?qt:i[Zt]<0||i[Zt]>59?Zt:i[$t]<0||i[$t]>999?$t:-1,g(t)._overflowDayOfYear&&(eUt)&&(e=Ut),g(t)._overflowWeeks&&-1===e&&(e=Kt),g(t)._overflowWeekday&&-1===e&&(e=Jt),g(t).overflow=e),t}var _i=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,wi=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,ki=/Z|[+-]\d\d(?::?\d\d)?/,xi=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/],["YYYYMM",/\d{6}/,!1],["YYYY",/\d{4}/,!1]],Di=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],Si=/^\/?Date\((-?\d+)/i,Ci=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,Ti={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Mi(t){var e,i,n,o,r,s,a=t._i,l=_i.exec(a)||wi.exec(a);if(l){for(g(t).iso=!0,e=0,i=xi.length;eve(r)||0===t._dayOfYear)&&(g(t)._overflowDayOfYear=!0),i=_e(r,0,t._dayOfYear),t._a[Vt]=i.getUTCMonth(),t._a[Ut]=i.getUTCDate()),e=0;e<3&&null==t._a[e];++e)t._a[e]=s[e]=n[e];for(;e<7;e++)t._a[e]=s[e]=null==t._a[e]?2===e?1:0:t._a[e];24===t._a[Xt]&&0===t._a[qt]&&0===t._a[Zt]&&0===t._a[$t]&&(t._nextDay=!0,t._a[Xt]=0),t._d=(t._useUTC?_e:be).apply(null,s),o=t._useUTC?t._d.getUTCDay():t._d.getDay(),null!=t._tzm&&t._d.setUTCMinutes(t._d.getUTCMinutes()-t._tzm),t._nextDay&&(t._a[Xt]=24),t._w&&void 0!==t._w.d&&t._w.d!==o&&(g(t).weekdayMismatch=!0)}}function ji(t){var e,i,n,o,r,s,a,l,h;null!=(e=t._w).GG||null!=e.W||null!=e.E?(r=1,s=4,i=Fi(e.GG,t._a[Wt],xe(qi(),1,4).year),n=Fi(e.W,1),((o=Fi(e.E,1))<1||o>7)&&(l=!0)):(r=t._locale._week.dow,s=t._locale._week.doy,h=xe(qi(),r,s),i=Fi(e.gg,t._a[Wt],h.year),n=Fi(e.w,h.week),null!=e.d?((o=e.d)<0||o>6)&&(l=!0):null!=e.e?(o=e.e+r,(e.e<0||e.e>6)&&(l=!0)):o=r),n<1||n>De(i,r,s)?g(t)._overflowWeeks=!0:null!=l?g(t)._overflowWeekday=!0:(a=ke(i,n,o,r,s),t._a[Wt]=a.year,t._dayOfYear=a.dayOfYear)}function Hi(t){if(t._f!==o.ISO_8601)if(t._f!==o.RFC_2822){t._a=[],g(t).empty=!0;var e,i,n,r,s,a,l=""+t._i,h=l.length,u=0;for(n=V(t._f,t._locale).match(R)||[],e=0;e0&&g(t).unusedInput.push(s),l=l.slice(l.indexOf(i)+i.length),u+=i.length),H[r]?(i?g(t).empty=!1:g(t).unusedTokens.push(r),Gt(r,i,t)):t._strict&&!i&&g(t).unusedTokens.push(r);g(t).charsLeftOver=h-u,l.length>0&&g(t).unusedInput.push(l),t._a[Xt]<=12&&!0===g(t).bigHour&&t._a[Xt]>0&&(g(t).bigHour=void 0),g(t).parsedDateParts=t._a.slice(0),g(t).meridiem=t._meridiem,t._a[Xt]=zi(t._locale,t._a[Xt],t._meridiem),null!==(a=g(t).era)&&(t._a[Wt]=t._locale.erasConvertYear(a,t._a[Wt])),Yi(t),bi(t)}else Li(t);else Mi(t)}function zi(t,e,i){var n;return null==i?e:null!=t.meridiemHour?t.meridiemHour(e,i):null!=t.isPM?((n=t.isPM(i))&&e<12&&(e+=12),n||12!==e||(e=0),e):e}function Gi(t){var e,i,n,o,r,s,a=!1;if(0===t._f.length)return g(t).invalidFormat=!0,void(t._d=new Date(NaN));for(o=0;othis?this:t:b()}));function Ki(t,e){var i,n;if(1===e.length&&s(e[0])&&(e=e[0]),!e.length)return qi();for(i=e[0],n=1;nthis.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function kn(){if(!u(this._isDSTShifted))return this._isDSTShifted;var t,e={};return k(e,this),(e=Vi(e))._a?(t=e._isUTC?m(e._a):qi(e._a),this._isDSTShifted=this.isValid()&&hn(e._a,t.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function xn(){return!!this.isValid()&&!this._isUTC}function Dn(){return!!this.isValid()&&this._isUTC}function Sn(){return!!this.isValid()&&this._isUTC&&0===this._offset}o.updateOffset=function(){};var Cn=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,Tn=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function Mn(t,e){var i,n,o,r=t,s=null;return an(t)?r={ms:t._milliseconds,d:t._days,M:t._months}:d(t)||!isNaN(+t)?(r={},e?r[e]=+t:r.milliseconds=+t):(s=Cn.exec(t))?(i="-"===s[1]?-1:1,r={y:0,d:dt(s[Ut])*i,h:dt(s[Xt])*i,m:dt(s[qt])*i,s:dt(s[Zt])*i,ms:dt(ln(1e3*s[$t]))*i}):(s=Tn.exec(t))?(i="-"===s[1]?-1:1,r={y:On(s[2],i),M:On(s[3],i),w:On(s[4],i),d:On(s[5],i),h:On(s[6],i),m:On(s[7],i),s:On(s[8],i)}):null==r?r={}:"object"==typeof r&&("from"in r||"to"in r)&&(o=Pn(qi(r.from),qi(r.to)),(r={}).ms=o.milliseconds,r.M=o.months),n=new sn(r),an(t)&&l(t,"_locale")&&(n._locale=t._locale),an(t)&&l(t,"_isValid")&&(n._isValid=t._isValid),n}function On(t,e){var i=t&&parseFloat(t.replace(",","."));return(isNaN(i)?0:i)*e}function En(t,e){var i={};return i.months=e.month()-t.month()+12*(e.year()-t.year()),t.clone().add(i.months,"M").isAfter(e)&&--i.months,i.milliseconds=+e-+t.clone().add(i.months,"M"),i}function Pn(t,e){var i;return t.isValid()&&e.isValid()?(e=pn(e,t),t.isBefore(e)?i=En(t,e):((i=En(e,t)).milliseconds=-i.milliseconds,i.months=-i.months),i):{milliseconds:0,months:0}}function An(t,e){return function(i,n){var o;return null===n||isNaN(+n)||(O(e,"moment()."+e+"(period, number) is deprecated. Please use moment()."+e+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),o=i,i=n,n=o),In(this,Mn(i,n),t),this}}function In(t,e,i,n){var r=e._milliseconds,s=ln(e._days),a=ln(e._months);t.isValid()&&(n=null==n||n,a&&ue(t,pt(t,"Month")+a*i),s&&ft(t,"Date",pt(t,"Date")+s*i),r&&t._d.setTime(t._d.valueOf()+r*i),n&&o.updateOffset(t,s||a))}Mn.fn=sn.prototype,Mn.invalid=rn;var Ln=An(1,"add"),Nn=An(-1,"subtract");function Fn(t){return"string"==typeof t||t instanceof String}function Rn(t){return D(t)||c(t)||Fn(t)||d(t)||jn(t)||Yn(t)||null==t}function Yn(t){var e,i,n=a(t)&&!h(t),o=!1,r=["years","year","y","months","month","M","days","day","d","dates","date","D","hours","hour","h","minutes","minute","m","seconds","second","s","milliseconds","millisecond","ms"];for(e=0;ei.valueOf():i.valueOf()9999?W(i,e?"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYYYY-MM-DD[T]HH:mm:ss.SSSZ"):E(Date.prototype.toISOString)?e?this.toDate().toISOString():new Date(this.valueOf()+60*this.utcOffset()*1e3).toISOString().replace("Z",W(i,"Z")):W(i,e?"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYY-MM-DD[T]HH:mm:ss.SSSZ")}function to(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var t,e,i,n,o="moment",r="";return this.isLocal()||(o=0===this.utcOffset()?"moment.utc":"moment.parseZone",r="Z"),t="["+o+'("]',e=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",i="-MM-DD[T]HH:mm:ss.SSS",n=r+'[")]',this.format(t+e+i+n)}function eo(t){t||(t=this.isUtc()?o.defaultFormatUtc:o.defaultFormat);var e=W(this,t);return this.localeData().postformat(e)}function io(t,e){return this.isValid()&&(D(t)&&t.isValid()||qi(t).isValid())?Mn({to:this,from:t}).locale(this.locale()).humanize(!e):this.localeData().invalidDate()}function no(t){return this.from(qi(),t)}function oo(t,e){return this.isValid()&&(D(t)&&t.isValid()||qi(t).isValid())?Mn({from:this,to:t}).locale(this.locale()).humanize(!e):this.localeData().invalidDate()}function ro(t){return this.to(qi(),t)}function so(t){var e;return void 0===t?this._locale._abbr:(null!=(e=gi(t))&&(this._locale=e),this)}o.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",o.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";var ao=C("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",(function(t){return void 0===t?this.localeData():this.locale(t)}));function lo(){return this._locale}var ho=1e3,uo=60*ho,co=60*uo,po=3506328*co;function fo(t,e){return(t%e+e)%e}function mo(t,e,i){return t<100&&t>=0?new Date(t+400,e,i)-po:new Date(t,e,i).valueOf()}function vo(t,e,i){return t<100&&t>=0?Date.UTC(t+400,e,i)-po:Date.UTC(t,e,i)}function go(t){var e,i;if(void 0===(t=ot(t))||"millisecond"===t||!this.isValid())return this;switch(i=this._isUTC?vo:mo,t){case"year":e=i(this.year(),0,1);break;case"quarter":e=i(this.year(),this.month()-this.month()%3,1);break;case"month":e=i(this.year(),this.month(),1);break;case"week":e=i(this.year(),this.month(),this.date()-this.weekday());break;case"isoWeek":e=i(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case"day":case"date":e=i(this.year(),this.month(),this.date());break;case"hour":e=this._d.valueOf(),e-=fo(e+(this._isUTC?0:this.utcOffset()*uo),co);break;case"minute":e=this._d.valueOf(),e-=fo(e,uo);break;case"second":e=this._d.valueOf(),e-=fo(e,ho)}return this._d.setTime(e),o.updateOffset(this,!0),this}function yo(t){var e,i;if(void 0===(t=ot(t))||"millisecond"===t||!this.isValid())return this;switch(i=this._isUTC?vo:mo,t){case"year":e=i(this.year()+1,0,1)-1;break;case"quarter":e=i(this.year(),this.month()-this.month()%3+3,1)-1;break;case"month":e=i(this.year(),this.month()+1,1)-1;break;case"week":e=i(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case"isoWeek":e=i(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case"day":case"date":e=i(this.year(),this.month(),this.date()+1)-1;break;case"hour":e=this._d.valueOf(),e+=co-fo(e+(this._isUTC?0:this.utcOffset()*uo),co)-1;break;case"minute":e=this._d.valueOf(),e+=uo-fo(e,uo)-1;break;case"second":e=this._d.valueOf(),e+=ho-fo(e,ho)-1}return this._d.setTime(e),o.updateOffset(this,!0),this}function bo(){return this._d.valueOf()-6e4*(this._offset||0)}function _o(){return Math.floor(this.valueOf()/1e3)}function wo(){return new Date(this.valueOf())}function ko(){var t=this;return[t.year(),t.month(),t.date(),t.hour(),t.minute(),t.second(),t.millisecond()]}function xo(){var t=this;return{years:t.year(),months:t.month(),date:t.date(),hours:t.hours(),minutes:t.minutes(),seconds:t.seconds(),milliseconds:t.milliseconds()}}function Do(){return this.isValid()?this.toISOString():null}function So(){return y(this)}function Co(){return f({},g(this))}function To(){return g(this).overflow}function Mo(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}function Oo(t,e){var i,n,r,s=this._eras||gi("en")._eras;for(i=0,n=s.length;i=0)return l[n]}function Po(t,e){var i=t.since<=t.until?1:-1;return void 0===e?o(t.since).year():o(t.since).year()+(e-t.offset)*i}function Ao(){var t,e,i,n=this.localeData().eras();for(t=0,e=n.length;t(r=De(t,n,o))&&(e=r),Jo.call(this,t,e,i,n,o))}function Jo(t,e,i,n,o){var r=ke(t,e,i,n,o),s=_e(r.year,0,r.dayOfYear);return this.year(s.getUTCFullYear()),this.month(s.getUTCMonth()),this.date(s.getUTCDate()),this}function Qo(t){return null==t?Math.ceil((this.month()+1)/3):this.month(3*(t-1)+this.month()%3)}z("N",0,0,"eraAbbr"),z("NN",0,0,"eraAbbr"),z("NNN",0,0,"eraAbbr"),z("NNNN",0,0,"eraName"),z("NNNNN",0,0,"eraNarrow"),z("y",["y",1],"yo","eraYear"),z("y",["yy",2],0,"eraYear"),z("y",["yyy",3],0,"eraYear"),z("y",["yyyy",4],0,"eraYear"),Nt("N",jo),Nt("NN",jo),Nt("NNN",jo),Nt("NNNN",Ho),Nt("NNNNN",zo),Ht(["N","NN","NNN","NNNN","NNNNN"],(function(t,e,i,n){var o=i._locale.erasParse(t,n,i._strict);o?g(i).era=o:g(i).invalidEra=t})),Nt("y",Ot),Nt("yy",Ot),Nt("yyy",Ot),Nt("yyyy",Ot),Nt("yo",Go),Ht(["y","yy","yyy","yyyy"],Wt),Ht(["yo"],(function(t,e,i,n){var o;i._locale._eraYearOrdinalRegex&&(o=t.match(i._locale._eraYearOrdinalRegex)),i._locale.eraYearOrdinalParse?e[Wt]=i._locale.eraYearOrdinalParse(t,o):e[Wt]=parseInt(t,10)})),z(0,["gg",2],0,(function(){return this.weekYear()%100})),z(0,["GG",2],0,(function(){return this.isoWeekYear()%100})),Wo("gggg","weekYear"),Wo("ggggg","weekYear"),Wo("GGGG","isoWeekYear"),Wo("GGGGG","isoWeekYear"),nt("weekYear","gg"),nt("isoWeekYear","GG"),at("weekYear",1),at("isoWeekYear",1),Nt("G",Et),Nt("g",Et),Nt("GG",xt,bt),Nt("gg",xt,bt),Nt("GGGG",Tt,wt),Nt("gggg",Tt,wt),Nt("GGGGG",Mt,kt),Nt("ggggg",Mt,kt),zt(["gggg","ggggg","GGGG","GGGGG"],(function(t,e,i,n){e[n.substr(0,2)]=dt(t)})),zt(["gg","GG"],(function(t,e,i,n){e[n]=o.parseTwoDigitYear(t)})),z("Q",0,"Qo","quarter"),nt("quarter","Q"),at("quarter",7),Nt("Q",yt),Ht("Q",(function(t,e){e[Vt]=3*(dt(t)-1)})),z("D",["DD",2],"Do","date"),nt("date","D"),at("date",9),Nt("D",xt),Nt("DD",xt,bt),Nt("Do",(function(t,e){return t?e._dayOfMonthOrdinalParse||e._ordinalParse:e._dayOfMonthOrdinalParseLenient})),Ht(["D","DD"],Ut),Ht("Do",(function(t,e){e[Ut]=dt(t.match(xt)[0])}));var tr=ct("Date",!0);function er(t){var e=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==t?e:this.add(t-e,"d")}z("DDD",["DDDD",3],"DDDo","dayOfYear"),nt("dayOfYear","DDD"),at("dayOfYear",4),Nt("DDD",Ct),Nt("DDDD",_t),Ht(["DDD","DDDD"],(function(t,e,i){i._dayOfYear=dt(t)})),z("m",["mm",2],0,"minute"),nt("minute","m"),at("minute",14),Nt("m",xt),Nt("mm",xt,bt),Ht(["m","mm"],qt);var ir=ct("Minutes",!1);z("s",["ss",2],0,"second"),nt("second","s"),at("second",15),Nt("s",xt),Nt("ss",xt,bt),Ht(["s","ss"],Zt);var nr,or,rr=ct("Seconds",!1);for(z("S",0,0,(function(){return~~(this.millisecond()/100)})),z(0,["SS",2],0,(function(){return~~(this.millisecond()/10)})),z(0,["SSS",3],0,"millisecond"),z(0,["SSSS",4],0,(function(){return 10*this.millisecond()})),z(0,["SSSSS",5],0,(function(){return 100*this.millisecond()})),z(0,["SSSSSS",6],0,(function(){return 1e3*this.millisecond()})),z(0,["SSSSSSS",7],0,(function(){return 1e4*this.millisecond()})),z(0,["SSSSSSSS",8],0,(function(){return 1e5*this.millisecond()})),z(0,["SSSSSSSSS",9],0,(function(){return 1e6*this.millisecond()})),nt("millisecond","ms"),at("millisecond",16),Nt("S",Ct,yt),Nt("SS",Ct,bt),Nt("SSS",Ct,_t),nr="SSSS";nr.length<=9;nr+="S")Nt(nr,Ot);function sr(t,e){e[$t]=dt(1e3*("0."+t))}for(nr="S";nr.length<=9;nr+="S")Ht(nr,sr);function ar(){return this._isUTC?"UTC":""}function lr(){return this._isUTC?"Coordinated Universal Time":""}or=ct("Milliseconds",!1),z("z",0,0,"zoneAbbr"),z("zz",0,0,"zoneName");var hr=x.prototype;function ur(t){return qi(1e3*t)}function dr(){return qi.apply(null,arguments).parseZone()}function cr(t){return t}hr.add=Ln,hr.calendar=Gn,hr.clone=Bn,hr.diff=$n,hr.endOf=yo,hr.format=eo,hr.from=io,hr.fromNow=no,hr.to=oo,hr.toNow=ro,hr.get=mt,hr.invalidAt=To,hr.isAfter=Wn,hr.isBefore=Vn,hr.isBetween=Un,hr.isSame=Xn,hr.isSameOrAfter=qn,hr.isSameOrBefore=Zn,hr.isValid=So,hr.lang=ao,hr.locale=so,hr.localeData=lo,hr.max=$i,hr.min=Zi,hr.parsingFlags=Co,hr.set=vt,hr.startOf=go,hr.subtract=Nn,hr.toArray=ko,hr.toObject=xo,hr.toDate=wo,hr.toISOString=Qn,hr.inspect=to,"undefined"!=typeof Symbol&&null!=Symbol.for&&(hr[Symbol.for("nodejs.util.inspect.custom")]=function(){return"Moment<"+this.format()+">"}),hr.toJSON=Do,hr.toString=Jn,hr.unix=_o,hr.valueOf=bo,hr.creationData=Mo,hr.eraName=Ao,hr.eraNarrow=Io,hr.eraAbbr=Lo,hr.eraYear=No,hr.year=ge,hr.isLeapYear=ye,hr.weekYear=Vo,hr.isoWeekYear=Uo,hr.quarter=hr.quarters=Qo,hr.month=de,hr.daysInMonth=ce,hr.week=hr.weeks=Oe,hr.isoWeek=hr.isoWeeks=Ee,hr.weeksInYear=Zo,hr.weeksInWeekYear=$o,hr.isoWeeksInYear=Xo,hr.isoWeeksInISOWeekYear=qo,hr.date=tr,hr.day=hr.days=Ve,hr.weekday=Ue,hr.isoWeekday=Xe,hr.dayOfYear=er,hr.hour=hr.hours=oi,hr.minute=hr.minutes=ir,hr.second=hr.seconds=rr,hr.millisecond=hr.milliseconds=or,hr.utcOffset=mn,hr.utc=gn,hr.local=yn,hr.parseZone=bn,hr.hasAlignedHourOffset=_n,hr.isDST=wn,hr.isLocal=xn,hr.isUtcOffset=Dn,hr.isUtc=Sn,hr.isUTC=Sn,hr.zoneAbbr=ar,hr.zoneName=lr,hr.dates=C("dates accessor is deprecated. Use date instead.",tr),hr.months=C("months accessor is deprecated. Use month instead",de),hr.years=C("years accessor is deprecated. Use year instead",ge),hr.zone=C("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",vn),hr.isDSTShifted=C("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",kn);var pr=I.prototype;function fr(t,e,i,n){var o=gi(),r=m().set(n,e);return o[i](r,t)}function mr(t,e,i){if(d(t)&&(e=t,t=void 0),t=t||"",null!=e)return fr(t,e,i,"month");var n,o=[];for(n=0;n<12;n++)o[n]=fr(t,n,i,"month");return o}function vr(t,e,i,n){"boolean"==typeof t?(d(e)&&(i=e,e=void 0),e=e||""):(i=e=t,t=!1,d(e)&&(i=e,e=void 0),e=e||"");var o,r=gi(),s=t?r._week.dow:0,a=[];if(null!=i)return fr(e,(i+s)%7,n,"day");for(o=0;o<7;o++)a[o]=fr(e,(o+s)%7,n,"day");return a}function gr(t,e){return mr(t,e,"months")}function yr(t,e){return mr(t,e,"monthsShort")}function br(t,e,i){return vr(t,e,i,"weekdays")}function _r(t,e,i){return vr(t,e,i,"weekdaysShort")}function wr(t,e,i){return vr(t,e,i,"weekdaysMin")}pr.calendar=N,pr.longDateFormat=X,pr.invalidDate=Z,pr.ordinal=J,pr.preparse=cr,pr.postformat=cr,pr.relativeTime=tt,pr.pastFuture=et,pr.set=P,pr.eras=Oo,pr.erasParse=Eo,pr.erasConvertYear=Po,pr.erasAbbrRegex=Ro,pr.erasNameRegex=Fo,pr.erasNarrowRegex=Yo,pr.months=se,pr.monthsShort=ae,pr.monthsParse=he,pr.monthsRegex=fe,pr.monthsShortRegex=pe,pr.week=Se,pr.firstDayOfYear=Me,pr.firstDayOfWeek=Te,pr.weekdays=He,pr.weekdaysMin=Ge,pr.weekdaysShort=ze,pr.weekdaysParse=We,pr.weekdaysRegex=qe,pr.weekdaysShortRegex=Ze,pr.weekdaysMinRegex=$e,pr.isPM=ii,pr.meridiem=ri,fi("en",{eras:[{since:"0001-01-01",until:1/0,offset:1,name:"Anno Domini",narrow:"AD",abbr:"AD"},{since:"0000-12-31",until:-1/0,offset:1,name:"Before Christ",narrow:"BC",abbr:"BC"}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(t){var e=t%10;return t+(1===dt(t%100/10)?"th":1===e?"st":2===e?"nd":3===e?"rd":"th")}}),o.lang=C("moment.lang is deprecated. Use moment.locale instead.",fi),o.langData=C("moment.langData is deprecated. Use moment.localeData instead.",gi);var kr=Math.abs;function xr(){var t=this._data;return this._milliseconds=kr(this._milliseconds),this._days=kr(this._days),this._months=kr(this._months),t.milliseconds=kr(t.milliseconds),t.seconds=kr(t.seconds),t.minutes=kr(t.minutes),t.hours=kr(t.hours),t.months=kr(t.months),t.years=kr(t.years),this}function Dr(t,e,i,n){var o=Mn(e,i);return t._milliseconds+=n*o._milliseconds,t._days+=n*o._days,t._months+=n*o._months,t._bubble()}function Sr(t,e){return Dr(this,t,e,1)}function Cr(t,e){return Dr(this,t,e,-1)}function Tr(t){return t<0?Math.floor(t):Math.ceil(t)}function Mr(){var t,e,i,n,o,r=this._milliseconds,s=this._days,a=this._months,l=this._data;return r>=0&&s>=0&&a>=0||r<=0&&s<=0&&a<=0||(r+=864e5*Tr(Er(a)+s),s=0,a=0),l.milliseconds=r%1e3,t=ut(r/1e3),l.seconds=t%60,e=ut(t/60),l.minutes=e%60,i=ut(e/60),l.hours=i%24,s+=ut(i/24),a+=o=ut(Or(s)),s-=Tr(Er(o)),n=ut(a/12),a%=12,l.days=s,l.months=a,l.years=n,this}function Or(t){return 4800*t/146097}function Er(t){return 146097*t/4800}function Pr(t){if(!this.isValid())return NaN;var e,i,n=this._milliseconds;if("month"===(t=ot(t))||"quarter"===t||"year"===t)switch(e=this._days+n/864e5,i=this._months+Or(e),t){case"month":return i;case"quarter":return i/3;case"year":return i/12}else switch(e=this._days+Math.round(Er(this._months)),t){case"week":return e/7+n/6048e5;case"day":return e+n/864e5;case"hour":return 24*e+n/36e5;case"minute":return 1440*e+n/6e4;case"second":return 86400*e+n/1e3;case"millisecond":return Math.floor(864e5*e)+n;default:throw new Error("Unknown unit "+t)}}function Ar(){return this.isValid()?this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*dt(this._months/12):NaN}function Ir(t){return function(){return this.as(t)}}var Lr=Ir("ms"),Nr=Ir("s"),Fr=Ir("m"),Rr=Ir("h"),Yr=Ir("d"),jr=Ir("w"),Hr=Ir("M"),zr=Ir("Q"),Gr=Ir("y");function Br(){return Mn(this)}function Wr(t){return t=ot(t),this.isValid()?this[t+"s"]():NaN}function Vr(t){return function(){return this.isValid()?this._data[t]:NaN}}var Ur=Vr("milliseconds"),Xr=Vr("seconds"),qr=Vr("minutes"),Zr=Vr("hours"),$r=Vr("days"),Kr=Vr("months"),Jr=Vr("years");function Qr(){return ut(this.days()/7)}var ts=Math.round,es={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function is(t,e,i,n,o){return o.relativeTime(e||1,!!i,t,n)}function ns(t,e,i,n){var o=Mn(t).abs(),r=ts(o.as("s")),s=ts(o.as("m")),a=ts(o.as("h")),l=ts(o.as("d")),h=ts(o.as("M")),u=ts(o.as("w")),d=ts(o.as("y")),c=r<=i.ss&&["s",r]||r0,c[4]=n,is.apply(null,c)}function os(t){return void 0===t?ts:"function"==typeof t&&(ts=t,!0)}function rs(t,e){return void 0!==es[t]&&(void 0===e?es[t]:(es[t]=e,"s"===t&&(es.ss=e-1),!0))}function ss(t,e){if(!this.isValid())return this.localeData().invalidDate();var i,n,o=!1,r=es;return"object"==typeof t&&(e=t,t=!1),"boolean"==typeof t&&(o=t),"object"==typeof e&&(r=Object.assign({},es,e),null!=e.s&&null==e.ss&&(r.ss=e.s-1)),n=ns(this,!o,r,i=this.localeData()),o&&(n=i.pastFuture(+this,n)),i.postformat(n)}var as=Math.abs;function ls(t){return(t>0)-(t<0)||+t}function hs(){if(!this.isValid())return this.localeData().invalidDate();var t,e,i,n,o,r,s,a,l=as(this._milliseconds)/1e3,h=as(this._days),u=as(this._months),d=this.asSeconds();return d?(t=ut(l/60),e=ut(t/60),l%=60,t%=60,i=ut(u/12),u%=12,n=l?l.toFixed(3).replace(/\.?0+$/,""):"",o=d<0?"-":"",r=ls(this._months)!==ls(d)?"-":"",s=ls(this._days)!==ls(d)?"-":"",a=ls(this._milliseconds)!==ls(d)?"-":"",o+"P"+(i?r+i+"Y":"")+(u?r+u+"M":"")+(h?s+h+"D":"")+(e||t||l?"T":"")+(e?a+e+"H":"")+(t?a+t+"M":"")+(l?a+n+"S":"")):"P0D"}var us=sn.prototype;return us.isValid=on,us.abs=xr,us.add=Sr,us.subtract=Cr,us.as=Pr,us.asMilliseconds=Lr,us.asSeconds=Nr,us.asMinutes=Fr,us.asHours=Rr,us.asDays=Yr,us.asWeeks=jr,us.asMonths=Hr,us.asQuarters=zr,us.asYears=Gr,us.valueOf=Ar,us._bubble=Mr,us.clone=Br,us.get=Wr,us.milliseconds=Ur,us.seconds=Xr,us.minutes=qr,us.hours=Zr,us.days=$r,us.weeks=Qr,us.months=Kr,us.years=Jr,us.humanize=ss,us.toISOString=hs,us.toString=hs,us.toJSON=hs,us.locale=so,us.localeData=lo,us.toIsoString=C("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",hs),us.lang=ao,z("X",0,0,"unix"),z("x",0,0,"valueOf"),Nt("x",Et),Nt("X",It),Ht("X",(function(t,e,i){i._d=new Date(1e3*parseFloat(t))})),Ht("x",(function(t,e,i){i._d=new Date(dt(t))})),//! moment.js -o.version="2.29.1",r(qi),o.fn=hr,o.min=Ji,o.max=Qi,o.now=tn,o.utc=m,o.unix=ur,o.months=gr,o.isDate=c,o.locale=fi,o.invalid=b,o.duration=Mn,o.isMoment=D,o.weekdays=br,o.parseZone=dr,o.localeData=gi,o.isDuration=an,o.monthsShort=yr,o.weekdaysMin=wr,o.defineLocale=mi,o.updateLocale=vi,o.locales=yi,o.weekdaysShort=_r,o.normalizeUnits=ot,o.relativeTimeRounding=os,o.relativeTimeThreshold=rs,o.calendarFormat=zn,o.prototype=hr,o.HTML5_FMT={DATETIME_LOCAL:"YYYY-MM-DDTHH:mm",DATETIME_LOCAL_SECONDS:"YYYY-MM-DDTHH:mm:ss",DATETIME_LOCAL_MS:"YYYY-MM-DDTHH:mm:ss.SSS",DATE:"YYYY-MM-DD",TIME:"HH:mm",TIME_SECONDS:"HH:mm:ss",TIME_MS:"HH:mm:ss.SSS",WEEK:"GGGG-[W]WW",MONTH:"YYYY-MM"},o}()}(o);var r=o.exports;!function(t){function e(t,e,i,n){var o={m:["eine Minute","einer Minute"],h:["eine Stunde","einer Stunde"],d:["ein Tag","einem Tag"],dd:[t+" Tage",t+" Tagen"],w:["eine Woche","einer Woche"],M:["ein Monat","einem Monat"],MM:[t+" Monate",t+" Monaten"],y:["ein Jahr","einem Jahr"],yy:[t+" Jahre",t+" Jahren"]};return e?o[i][0]:o[i][1]}t.defineLocale("de",{months:"Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),monthsShort:"Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.".split("_"),monthsParseExact:!0,weekdays:"Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag".split("_"),weekdaysShort:"So._Mo._Di._Mi._Do._Fr._Sa.".split("_"),weekdaysMin:"So_Mo_Di_Mi_Do_Fr_Sa".split("_"),weekdaysParseExact:!0,longDateFormat:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY HH:mm",LLLL:"dddd, D. MMMM YYYY HH:mm"},calendar:{sameDay:"[heute um] LT [Uhr]",sameElse:"L",nextDay:"[morgen um] LT [Uhr]",nextWeek:"dddd [um] LT [Uhr]",lastDay:"[gestern um] LT [Uhr]",lastWeek:"[letzten] dddd [um] LT [Uhr]"},relativeTime:{future:"in %s",past:"vor %s",s:"ein paar Sekunden",ss:"%d Sekunden",m:e,mm:"%d Minuten",h:e,hh:"%d Stunden",d:e,dd:e,w:e,ww:"%d Wochen",M:e,MM:e,y:e,yy:e},dayOfMonthOrdinalParse:/\d{1,2}\./,ordinal:"%d.",week:{dow:1,doy:4}})}(o.exports),function(t){var e="ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.".split("_"),i="ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),n=[/^ene/i,/^feb/i,/^mar/i,/^abr/i,/^may/i,/^jun/i,/^jul/i,/^ago/i,/^sep/i,/^oct/i,/^nov/i,/^dic/i],o=/^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre|ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i;t.defineLocale("es",{months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),monthsShort:function(t,n){return t?/-MMM-/.test(n)?i[t.month()]:e[t.month()]:e},monthsRegex:o,monthsShortRegex:o,monthsStrictRegex:/^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i,monthsShortStrictRegex:/^(ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i,monthsParse:n,longMonthsParse:n,shortMonthsParse:n,weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),weekdaysParseExact:!0,longDateFormat:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY H:mm",LLLL:"dddd, D [de] MMMM [de] YYYY H:mm"},calendar:{sameDay:function(){return"[hoy a la"+(1!==this.hours()?"s":"")+"] LT"},nextDay:function(){return"[mañana a la"+(1!==this.hours()?"s":"")+"] LT"},nextWeek:function(){return"dddd [a la"+(1!==this.hours()?"s":"")+"] LT"},lastDay:function(){return"[ayer a la"+(1!==this.hours()?"s":"")+"] LT"},lastWeek:function(){return"[el] dddd [pasado a la"+(1!==this.hours()?"s":"")+"] LT"},sameElse:"L"},relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",ss:"%d segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",w:"una semana",ww:"%d semanas",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},dayOfMonthOrdinalParse:/\d{1,2}º/,ordinal:"%dº",week:{dow:1,doy:4},invalidDate:"Fecha inválida"})}(o.exports),function(t){var e=/(janv\.?|févr\.?|mars|avr\.?|mai|juin|juil\.?|août|sept\.?|oct\.?|nov\.?|déc\.?|janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre)/i,i=[/^janv/i,/^févr/i,/^mars/i,/^avr/i,/^mai/i,/^juin/i,/^juil/i,/^août/i,/^sept/i,/^oct/i,/^nov/i,/^déc/i];t.defineLocale("fr",{months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),monthsRegex:e,monthsShortRegex:e,monthsStrictRegex:/^(janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre)/i,monthsShortStrictRegex:/(janv\.?|févr\.?|mars|avr\.?|mai|juin|juil\.?|août|sept\.?|oct\.?|nov\.?|déc\.?)/i,monthsParse:i,longMonthsParse:i,shortMonthsParse:i,weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),weekdaysMin:"di_lu_ma_me_je_ve_sa".split("_"),weekdaysParseExact:!0,longDateFormat:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},calendar:{sameDay:"[Aujourd’hui à] LT",nextDay:"[Demain à] LT",nextWeek:"dddd [à] LT",lastDay:"[Hier à] LT",lastWeek:"dddd [dernier à] LT",sameElse:"L"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",ss:"%d secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",w:"une semaine",ww:"%d semaines",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"},dayOfMonthOrdinalParse:/\d{1,2}(er|)/,ordinal:function(t,e){switch(e){case"D":return t+(1===t?"er":"");default:case"M":case"Q":case"DDD":case"d":return t+(1===t?"er":"e");case"w":case"W":return t+(1===t?"re":"e")}},week:{dow:1,doy:4}})}(o.exports),function(t){t.defineLocale("it",{months:"gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre".split("_"),monthsShort:"gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic".split("_"),weekdays:"domenica_lunedì_martedì_mercoledì_giovedì_venerdì_sabato".split("_"),weekdaysShort:"dom_lun_mar_mer_gio_ven_sab".split("_"),weekdaysMin:"do_lu_ma_me_gi_ve_sa".split("_"),longDateFormat:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},calendar:{sameDay:function(){return"[Oggi a"+(this.hours()>1?"lle ":0===this.hours()?" ":"ll'")+"]LT"},nextDay:function(){return"[Domani a"+(this.hours()>1?"lle ":0===this.hours()?" ":"ll'")+"]LT"},nextWeek:function(){return"dddd [a"+(this.hours()>1?"lle ":0===this.hours()?" ":"ll'")+"]LT"},lastDay:function(){return"[Ieri a"+(this.hours()>1?"lle ":0===this.hours()?" ":"ll'")+"]LT"},lastWeek:function(){switch(this.day()){case 0:return"[La scorsa] dddd [a"+(this.hours()>1?"lle ":0===this.hours()?" ":"ll'")+"]LT";default:return"[Lo scorso] dddd [a"+(this.hours()>1?"lle ":0===this.hours()?" ":"ll'")+"]LT"}},sameElse:"L"},relativeTime:{future:"tra %s",past:"%s fa",s:"alcuni secondi",ss:"%d secondi",m:"un minuto",mm:"%d minuti",h:"un'ora",hh:"%d ore",d:"un giorno",dd:"%d giorni",w:"una settimana",ww:"%d settimane",M:"un mese",MM:"%d mesi",y:"un anno",yy:"%d anni"},dayOfMonthOrdinalParse:/\d{1,2}º/,ordinal:"%dº",week:{dow:1,doy:4}})}(o.exports),function(t){t.defineLocale("ja",{eras:[{since:"2019-05-01",offset:1,name:"令和",narrow:"㋿",abbr:"R"},{since:"1989-01-08",until:"2019-04-30",offset:1,name:"平成",narrow:"㍻",abbr:"H"},{since:"1926-12-25",until:"1989-01-07",offset:1,name:"昭和",narrow:"㍼",abbr:"S"},{since:"1912-07-30",until:"1926-12-24",offset:1,name:"大正",narrow:"㍽",abbr:"T"},{since:"1873-01-01",until:"1912-07-29",offset:6,name:"明治",narrow:"㍾",abbr:"M"},{since:"0001-01-01",until:"1873-12-31",offset:1,name:"西暦",narrow:"AD",abbr:"AD"},{since:"0000-12-31",until:-1/0,offset:1,name:"紀元前",narrow:"BC",abbr:"BC"}],eraYearOrdinalRegex:/(元|\d+)年/,eraYearOrdinalParse:function(t,e){return"元"===e[1]?1:parseInt(e[1]||t,10)},months:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),weekdays:"日曜日_月曜日_火曜日_水曜日_木曜日_金曜日_土曜日".split("_"),weekdaysShort:"日_月_火_水_木_金_土".split("_"),weekdaysMin:"日_月_火_水_木_金_土".split("_"),longDateFormat:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日 HH:mm",LLLL:"YYYY年M月D日 dddd HH:mm",l:"YYYY/MM/DD",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日(ddd) HH:mm"},meridiemParse:/午前|午後/i,isPM:function(t){return"午後"===t},meridiem:function(t,e,i){return t<12?"午前":"午後"},calendar:{sameDay:"[今日] LT",nextDay:"[明日] LT",nextWeek:function(t){return t.week()!==this.week()?"[来週]dddd LT":"dddd LT"},lastDay:"[昨日] LT",lastWeek:function(t){return this.week()!==t.week()?"[先週]dddd LT":"dddd LT"},sameElse:"L"},dayOfMonthOrdinalParse:/\d{1,2}日/,ordinal:function(t,e){switch(e){case"y":return 1===t?"元年":t+"年";case"d":case"D":case"DDD":return t+"日";default:return t}},relativeTime:{future:"%s後",past:"%s前",s:"数秒",ss:"%d秒",m:"1分",mm:"%d分",h:"1時間",hh:"%d時間",d:"1日",dd:"%d日",M:"1ヶ月",MM:"%dヶ月",y:"1年",yy:"%d年"}})}(o.exports),function(t){var e="jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.".split("_"),i="jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec".split("_"),n=[/^jan/i,/^feb/i,/^maart|mrt.?$/i,/^apr/i,/^mei$/i,/^jun[i.]?$/i,/^jul[i.]?$/i,/^aug/i,/^sep/i,/^okt/i,/^nov/i,/^dec/i],o=/^(januari|februari|maart|april|mei|ju[nl]i|augustus|september|oktober|november|december|jan\.?|feb\.?|mrt\.?|apr\.?|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i;t.defineLocale("nl",{months:"januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december".split("_"),monthsShort:function(t,n){return t?/-MMM-/.test(n)?i[t.month()]:e[t.month()]:e},monthsRegex:o,monthsShortRegex:o,monthsStrictRegex:/^(januari|februari|maart|april|mei|ju[nl]i|augustus|september|oktober|november|december)/i,monthsShortStrictRegex:/^(jan\.?|feb\.?|mrt\.?|apr\.?|mei|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i,monthsParse:n,longMonthsParse:n,shortMonthsParse:n,weekdays:"zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag".split("_"),weekdaysShort:"zo._ma._di._wo._do._vr._za.".split("_"),weekdaysMin:"zo_ma_di_wo_do_vr_za".split("_"),weekdaysParseExact:!0,longDateFormat:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD-MM-YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},calendar:{sameDay:"[vandaag om] LT",nextDay:"[morgen om] LT",nextWeek:"dddd [om] LT",lastDay:"[gisteren om] LT",lastWeek:"[afgelopen] dddd [om] LT",sameElse:"L"},relativeTime:{future:"over %s",past:"%s geleden",s:"een paar seconden",ss:"%d seconden",m:"één minuut",mm:"%d minuten",h:"één uur",hh:"%d uur",d:"één dag",dd:"%d dagen",w:"één week",ww:"%d weken",M:"één maand",MM:"%d maanden",y:"één jaar",yy:"%d jaar"},dayOfMonthOrdinalParse:/\d{1,2}(ste|de)/,ordinal:function(t){return t+(1===t||8===t||t>=20?"ste":"de")},week:{dow:1,doy:4}})}(o.exports),function(t){var e="styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień".split("_"),i="stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia".split("_"),n=[/^sty/i,/^lut/i,/^mar/i,/^kwi/i,/^maj/i,/^cze/i,/^lip/i,/^sie/i,/^wrz/i,/^paź/i,/^lis/i,/^gru/i];function o(t){return t%10<5&&t%10>1&&~~(t/10)%10!=1}function r(t,e,i){var n=t+" ";switch(i){case"ss":return n+(o(t)?"sekundy":"sekund");case"m":return e?"minuta":"minutę";case"mm":return n+(o(t)?"minuty":"minut");case"h":return e?"godzina":"godzinę";case"hh":return n+(o(t)?"godziny":"godzin");case"ww":return n+(o(t)?"tygodnie":"tygodni");case"MM":return n+(o(t)?"miesiące":"miesięcy");case"yy":return n+(o(t)?"lata":"lat")}}t.defineLocale("pl",{months:function(t,n){return t?/D MMMM/.test(n)?i[t.month()]:e[t.month()]:e},monthsShort:"sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru".split("_"),monthsParse:n,longMonthsParse:n,shortMonthsParse:n,weekdays:"niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota".split("_"),weekdaysShort:"ndz_pon_wt_śr_czw_pt_sob".split("_"),weekdaysMin:"Nd_Pn_Wt_Śr_Cz_Pt_So".split("_"),longDateFormat:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},calendar:{sameDay:"[Dziś o] LT",nextDay:"[Jutro o] LT",nextWeek:function(){switch(this.day()){case 0:return"[W niedzielę o] LT";case 2:return"[We wtorek o] LT";case 3:return"[W środę o] LT";case 6:return"[W sobotę o] LT";default:return"[W] dddd [o] LT"}},lastDay:"[Wczoraj o] LT",lastWeek:function(){switch(this.day()){case 0:return"[W zeszłą niedzielę o] LT";case 3:return"[W zeszłą środę o] LT";case 6:return"[W zeszłą sobotę o] LT";default:return"[W zeszły] dddd [o] LT"}},sameElse:"L"},relativeTime:{future:"za %s",past:"%s temu",s:"kilka sekund",ss:r,m:r,mm:r,h:r,hh:r,d:"1 dzień",dd:"%d dni",w:"tydzień",ww:r,M:"miesiąc",MM:r,y:"rok",yy:r},dayOfMonthOrdinalParse:/\d{1,2}\./,ordinal:"%d.",week:{dow:1,doy:4}})}(o.exports),function(t){function e(t,e,i){var n,o;return"m"===i?e?"минута":"минуту":t+" "+(n=+t,o={ss:e?"секунда_секунды_секунд":"секунду_секунды_секунд",mm:e?"минута_минуты_минут":"минуту_минуты_минут",hh:"час_часа_часов",dd:"день_дня_дней",ww:"неделя_недели_недель",MM:"месяц_месяца_месяцев",yy:"год_года_лет"}[i].split("_"),n%10==1&&n%100!=11?o[0]:n%10>=2&&n%10<=4&&(n%100<10||n%100>=20)?o[1]:o[2])}var i=[/^янв/i,/^фев/i,/^мар/i,/^апр/i,/^ма[йя]/i,/^июн/i,/^июл/i,/^авг/i,/^сен/i,/^окт/i,/^ноя/i,/^дек/i];t.defineLocale("ru",{months:{format:"января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря".split("_"),standalone:"январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь".split("_")},monthsShort:{format:"янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.".split("_"),standalone:"янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.".split("_")},weekdays:{standalone:"воскресенье_понедельник_вторник_среда_четверг_пятница_суббота".split("_"),format:"воскресенье_понедельник_вторник_среду_четверг_пятницу_субботу".split("_"),isFormat:/\[ ?[Вв] ?(?:прошлую|следующую|эту)? ?] ?dddd/},weekdaysShort:"вс_пн_вт_ср_чт_пт_сб".split("_"),weekdaysMin:"вс_пн_вт_ср_чт_пт_сб".split("_"),monthsParse:i,longMonthsParse:i,shortMonthsParse:i,monthsRegex:/^(январ[ья]|янв\.?|феврал[ья]|февр?\.?|марта?|мар\.?|апрел[ья]|апр\.?|ма[йя]|июн[ья]|июн\.?|июл[ья]|июл\.?|августа?|авг\.?|сентябр[ья]|сент?\.?|октябр[ья]|окт\.?|ноябр[ья]|нояб?\.?|декабр[ья]|дек\.?)/i,monthsShortRegex:/^(январ[ья]|янв\.?|феврал[ья]|февр?\.?|марта?|мар\.?|апрел[ья]|апр\.?|ма[йя]|июн[ья]|июн\.?|июл[ья]|июл\.?|августа?|авг\.?|сентябр[ья]|сент?\.?|октябр[ья]|окт\.?|ноябр[ья]|нояб?\.?|декабр[ья]|дек\.?)/i,monthsStrictRegex:/^(январ[яь]|феврал[яь]|марта?|апрел[яь]|ма[яй]|июн[яь]|июл[яь]|августа?|сентябр[яь]|октябр[яь]|ноябр[яь]|декабр[яь])/i,monthsShortStrictRegex:/^(янв\.|февр?\.|мар[т.]|апр\.|ма[яй]|июн[ья.]|июл[ья.]|авг\.|сент?\.|окт\.|нояб?\.|дек\.)/i,longDateFormat:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY г.",LLL:"D MMMM YYYY г., H:mm",LLLL:"dddd, D MMMM YYYY г., H:mm"},calendar:{sameDay:"[Сегодня, в] LT",nextDay:"[Завтра, в] LT",lastDay:"[Вчера, в] LT",nextWeek:function(t){if(t.week()===this.week())return 2===this.day()?"[Во] dddd, [в] LT":"[В] dddd, [в] LT";switch(this.day()){case 0:return"[В следующее] dddd, [в] LT";case 1:case 2:case 4:return"[В следующий] dddd, [в] LT";case 3:case 5:case 6:return"[В следующую] dddd, [в] LT"}},lastWeek:function(t){if(t.week()===this.week())return 2===this.day()?"[Во] dddd, [в] LT":"[В] dddd, [в] LT";switch(this.day()){case 0:return"[В прошлое] dddd, [в] LT";case 1:case 2:case 4:return"[В прошлый] dddd, [в] LT";case 3:case 5:case 6:return"[В прошлую] dddd, [в] LT"}},sameElse:"L"},relativeTime:{future:"через %s",past:"%s назад",s:"несколько секунд",ss:e,m:e,mm:e,h:"час",hh:e,d:"день",dd:e,w:"неделя",ww:e,M:"месяц",MM:e,y:"год",yy:e},meridiemParse:/ночи|утра|дня|вечера/i,isPM:function(t){return/^(дня|вечера)$/.test(t)},meridiem:function(t,e,i){return t<4?"ночи":t<12?"утра":t<17?"дня":"вечера"},dayOfMonthOrdinalParse:/\d{1,2}-(й|го|я)/,ordinal:function(t,e){switch(e){case"M":case"d":case"DDD":return t+"-й";case"D":return t+"-го";case"w":case"W":return t+"-я";default:return t}},week:{dow:1,doy:4}})}(o.exports),function(t){function e(t,e,i){var n,o;return"m"===i?e?"хвилина":"хвилину":"h"===i?e?"година":"годину":t+" "+(n=+t,o={ss:e?"секунда_секунди_секунд":"секунду_секунди_секунд",mm:e?"хвилина_хвилини_хвилин":"хвилину_хвилини_хвилин",hh:e?"година_години_годин":"годину_години_годин",dd:"день_дні_днів",MM:"місяць_місяці_місяців",yy:"рік_роки_років"}[i].split("_"),n%10==1&&n%100!=11?o[0]:n%10>=2&&n%10<=4&&(n%100<10||n%100>=20)?o[1]:o[2])}function i(t){return function(){return t+"о"+(11===this.hours()?"б":"")+"] LT"}}t.defineLocale("uk",{months:{format:"січня_лютого_березня_квітня_травня_червня_липня_серпня_вересня_жовтня_листопада_грудня".split("_"),standalone:"січень_лютий_березень_квітень_травень_червень_липень_серпень_вересень_жовтень_листопад_грудень".split("_")},monthsShort:"січ_лют_бер_квіт_трав_черв_лип_серп_вер_жовт_лист_груд".split("_"),weekdays:function(t,e){var i={nominative:"неділя_понеділок_вівторок_середа_четвер_п’ятниця_субота".split("_"),accusative:"неділю_понеділок_вівторок_середу_четвер_п’ятницю_суботу".split("_"),genitive:"неділі_понеділка_вівторка_середи_четверга_п’ятниці_суботи".split("_")};return!0===t?i.nominative.slice(1,7).concat(i.nominative.slice(0,1)):t?i[/(\[[ВвУу]\]) ?dddd/.test(e)?"accusative":/\[?(?:минулої|наступної)? ?\] ?dddd/.test(e)?"genitive":"nominative"][t.day()]:i.nominative},weekdaysShort:"нд_пн_вт_ср_чт_пт_сб".split("_"),weekdaysMin:"нд_пн_вт_ср_чт_пт_сб".split("_"),longDateFormat:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY р.",LLL:"D MMMM YYYY р., HH:mm",LLLL:"dddd, D MMMM YYYY р., HH:mm"},calendar:{sameDay:i("[Сьогодні "),nextDay:i("[Завтра "),lastDay:i("[Вчора "),nextWeek:i("[У] dddd ["),lastWeek:function(){switch(this.day()){case 0:case 3:case 5:case 6:return i("[Минулої] dddd [").call(this);case 1:case 2:case 4:return i("[Минулого] dddd [").call(this)}},sameElse:"L"},relativeTime:{future:"за %s",past:"%s тому",s:"декілька секунд",ss:e,m:e,mm:e,h:"годину",hh:e,d:"день",dd:e,M:"місяць",MM:e,y:"рік",yy:e},meridiemParse:/ночі|ранку|дня|вечора/,isPM:function(t){return/^(дня|вечора)$/.test(t)},meridiem:function(t,e,i){return t<4?"ночі":t<12?"ранку":t<17?"дня":"вечора"},dayOfMonthOrdinalParse:/\d{1,2}-(й|го)/,ordinal:function(t,e){switch(e){case"M":case"d":case"DDD":case"w":case"W":return t+"-й";case"D":return t+"-го";default:return t}},week:{dow:1,doy:7}})}(o.exports);var s=Function.prototype,a=s.bind,l=s.call,h=a&&a.bind(l),u=a?function(t){return t&&h(l,t)}:function(t){return t&&function(){return l.apply(t,arguments)}},d=Math.ceil,c=Math.floor,p=function(t){var e=+t;return e!=e||0===e?0:(e>0?c:d)(e)},f=function(t){return t&&t.Math==Math&&t},m=f("object"==typeof globalThis&&globalThis)||f("object"==typeof window&&window)||f("object"==typeof self&&self)||f("object"==typeof e&&e)||function(){return this}()||Function("return this")(),v={exports:{}},g=m,y=Object.defineProperty,b=function(t,e){try{y(g,t,{value:e,configurable:!0,writable:!0})}catch(i){g[t]=e}return e},_="__core-js_shared__",w=m[_]||b(_,{}),k=w;(v.exports=function(t,e){return k[t]||(k[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.19.1",mode:"pure",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"});var x,D,S=m.TypeError,C=function(t){if(null==t)throw S("Can't call method on "+t);return t},T=C,M=m.Object,O=function(t){return M(T(t))},E=O,P=u({}.hasOwnProperty),A=Object.hasOwn||function(t,e){return P(E(t),e)},I=u,L=0,N=Math.random(),F=I(1..toString),R=function(t){return"Symbol("+(void 0===t?"":t)+")_"+F(++L+N,36)},Y={},j=function(t){return"function"==typeof t},H=Y,z=m,G=j,B=function(t){return G(t)?t:void 0},W=function(t,e){return arguments.length<2?B(H[t])||B(z[t]):H[t]&&H[t][e]||z[t]&&z[t][e]},V=W("navigator","userAgent")||"",U=m,X=V,q=U.process,Z=U.Deno,$=q&&q.versions||Z&&Z.version,K=$&&$.v8;K&&(D=(x=K.split("."))[0]>0&&x[0]<4?1:+(x[0]+x[1])),!D&&X&&(!(x=X.match(/Edge\/(\d+)/))||x[1]>=74)&&(x=X.match(/Chrome\/(\d+)/))&&(D=+x[1]);var J=D,Q=function(t){try{return!!t()}catch(t){return!0}},tt=J,et=Q,it=!!Object.getOwnPropertySymbols&&!et((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&tt&&tt<41})),nt=it&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ot=m,rt=v.exports,st=A,at=R,lt=it,ht=nt,ut=rt("wks"),dt=ot.Symbol,ct=dt&&dt.for,pt=ht?dt:dt&&dt.withoutSetter||at,ft=function(t){if(!st(ut,t)||!lt&&"string"!=typeof ut[t]){var e="Symbol."+t;lt&&st(dt,t)?ut[t]=dt[t]:ut[t]=ht&&ct?ct(e):pt(e)}return ut[t]},mt={};mt[ft("toStringTag")]="z";var vt="[object z]"===String(mt),gt=u,yt=gt({}.toString),bt=gt("".slice),_t=function(t){return bt(yt(t),8,-1)},wt=m,kt=vt,xt=j,Dt=_t,St=ft("toStringTag"),Ct=wt.Object,Tt="Arguments"==Dt(function(){return arguments}()),Mt=kt?Dt:function(t){var e,i,n;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(i=function(t,e){try{return t[e]}catch(t){}}(e=Ct(t),St))?i:Tt?Dt(e):"Object"==(n=Dt(e))&&xt(e.callee)?"Arguments":n},Ot=Mt,Et=m.String,Pt=function(t){if("Symbol"===Ot(t))throw TypeError("Cannot convert a Symbol value to a string");return Et(t)},At=u,It=p,Lt=Pt,Nt=C,Ft=At("".charAt),Rt=At("".charCodeAt),Yt=At("".slice),jt=function(t){return function(e,i){var n,o,r=Lt(Nt(e)),s=It(i),a=r.length;return s<0||s>=a?t?"":void 0:(n=Rt(r,s))<55296||n>56319||s+1===a||(o=Rt(r,s+1))<56320||o>57343?t?Ft(r,s):n:t?Yt(r,s,s+2):o-56320+(n-55296<<10)+65536}},Ht={codeAt:jt(!1),charAt:jt(!0)},zt=j,Gt=w,Bt=u(Function.toString);zt(Gt.inspectSource)||(Gt.inspectSource=function(t){return Bt(t)});var Wt=Gt.inspectSource,Vt=j,Ut=Wt,Xt=m.WeakMap,qt=Vt(Xt)&&/native code/.test(Ut(Xt)),Zt=j,$t=function(t){return"object"==typeof t?null!==t:Zt(t)},Kt=!Q((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),Jt={},Qt=$t,te=m.document,ee=Qt(te)&&Qt(te.createElement),ie=function(t){return ee?te.createElement(t):{}},ne=ie,oe=!Kt&&!Q((function(){return 7!=Object.defineProperty(ne("div"),"a",{get:function(){return 7}}).a})),re=m,se=$t,ae=re.String,le=re.TypeError,he=function(t){if(se(t))return t;throw le(ae(t)+" is not an object")},ue=Function.prototype.call,de=ue.bind?ue.bind(ue):function(){return ue.apply(ue,arguments)},ce=u({}.isPrototypeOf),pe=W,fe=j,me=ce,ve=nt,ge=m.Object,ye=ve?function(t){return"symbol"==typeof t}:function(t){var e=pe("Symbol");return fe(e)&&me(e.prototype,ge(t))},be=m.String,_e=function(t){try{return be(t)}catch(t){return"Object"}},we=j,ke=_e,xe=m.TypeError,De=function(t){if(we(t))return t;throw xe(ke(t)+" is not a function")},Se=De,Ce=function(t,e){var i=t[e];return null==i?void 0:Se(i)},Te=de,Me=j,Oe=$t,Ee=m.TypeError,Pe=de,Ae=$t,Ie=ye,Le=Ce,Ne=function(t,e){var i,n;if("string"===e&&Me(i=t.toString)&&!Oe(n=Te(i,t)))return n;if(Me(i=t.valueOf)&&!Oe(n=Te(i,t)))return n;if("string"!==e&&Me(i=t.toString)&&!Oe(n=Te(i,t)))return n;throw Ee("Can't convert object to primitive value")},Fe=ft,Re=m.TypeError,Ye=Fe("toPrimitive"),je=function(t,e){if(!Ae(t)||Ie(t))return t;var i,n=Le(t,Ye);if(n){if(void 0===e&&(e="default"),i=Pe(n,t,e),!Ae(i)||Ie(i))return i;throw Re("Can't convert object to primitive value")}return void 0===e&&(e="number"),Ne(t,e)},He=ye,ze=function(t){var e=je(t,"string");return He(e)?e:e+""},Ge=Kt,Be=oe,We=he,Ve=ze,Ue=m.TypeError,Xe=Object.defineProperty;Jt.f=Ge?Xe:function(t,e,i){if(We(t),e=Ve(e),We(i),Be)try{return Xe(t,e,i)}catch(t){}if("get"in i||"set"in i)throw Ue("Accessors not supported");return"value"in i&&(t[e]=i.value),t};var qe,Ze,$e,Ke=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},Je=Jt,Qe=Ke,ti=Kt?function(t,e,i){return Je.f(t,e,Qe(1,i))}:function(t,e,i){return t[e]=i,t},ei=v.exports,ii=R,ni=ei("keys"),oi=function(t){return ni[t]||(ni[t]=ii(t))},ri={},si=qt,ai=m,li=u,hi=$t,ui=ti,di=A,ci=w,pi=oi,fi=ri,mi="Object already initialized",vi=ai.TypeError,gi=ai.WeakMap;if(si||ci.state){var yi=ci.state||(ci.state=new gi),bi=li(yi.get),_i=li(yi.has),wi=li(yi.set);qe=function(t,e){if(_i(yi,t))throw new vi(mi);return e.facade=t,wi(yi,t,e),e},Ze=function(t){return bi(yi,t)||{}},$e=function(t){return _i(yi,t)}}else{var ki=pi("state");fi[ki]=!0,qe=function(t,e){if(di(t,ki))throw new vi(mi);return e.facade=t,ui(t,ki,e),e},Ze=function(t){return di(t,ki)?t[ki]:{}},$e=function(t){return di(t,ki)}}var xi={set:qe,get:Ze,has:$e,enforce:function(t){return $e(t)?Ze(t):qe(t,{})},getterFor:function(t){return function(e){var i;if(!hi(e)||(i=Ze(e)).type!==t)throw vi("Incompatible receiver, "+t+" required");return i}}},Di=Function.prototype,Si=Di.apply,Ci=Di.bind,Ti=Di.call,Mi="object"==typeof Reflect&&Reflect.apply||(Ci?Ti.bind(Si):function(){return Ti.apply(Si,arguments)}),Oi={},Ei={},Pi={}.propertyIsEnumerable,Ai=Object.getOwnPropertyDescriptor,Ii=Ai&&!Pi.call({1:2},1);Ei.f=Ii?function(t){var e=Ai(this,t);return!!e&&e.enumerable}:Pi;var Li=u,Ni=Q,Fi=_t,Ri=m.Object,Yi=Li("".split),ji=Ni((function(){return!Ri("z").propertyIsEnumerable(0)}))?function(t){return"String"==Fi(t)?Yi(t,""):Ri(t)}:Ri,Hi=ji,zi=C,Gi=function(t){return Hi(zi(t))},Bi=Kt,Wi=de,Vi=Ei,Ui=Ke,Xi=Gi,qi=ze,Zi=A,$i=oe,Ki=Object.getOwnPropertyDescriptor;Oi.f=Bi?Ki:function(t,e){if(t=Xi(t),e=qi(e),$i)try{return Ki(t,e)}catch(t){}if(Zi(t,e))return Ui(!Wi(Vi.f,t,e),t[e])};var Ji,Qi=Q,tn=j,en=/#|\.prototype\./,nn=function(t,e){var i=rn[on(t)];return i==an||i!=sn&&(tn(e)?Qi(e):!!e)},on=nn.normalize=function(t){return String(t).replace(en,".").toLowerCase()},rn=nn.data={},sn=nn.NATIVE="N",an=nn.POLYFILL="P",ln=nn,hn=De,un=u(u.bind),dn=function(t,e){return hn(t),void 0===e?t:un?un(t,e):function(){return t.apply(e,arguments)}},cn=m,pn=Mi,fn=u,mn=j,vn=Oi.f,gn=ln,yn=Y,bn=dn,_n=ti,wn=A,kn=function(t){var e=function(i,n,o){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(i);case 2:return new t(i,n)}return new t(i,n,o)}return pn(t,this,arguments)};return e.prototype=t.prototype,e},xn=function(t,e){var i,n,o,r,s,a,l,h,u=t.target,d=t.global,c=t.stat,p=t.proto,f=d?cn:c?cn[u]:(cn[u]||{}).prototype,m=d?yn:yn[u]||_n(yn,u,{})[u],v=m.prototype;for(o in e)i=!gn(d?o:u+(c?".":"#")+o,t.forced)&&f&&wn(f,o),s=m[o],i&&(a=t.noTargetGet?(h=vn(f,o))&&h.value:f[o]),r=i&&a?a:e[o],i&&typeof s==typeof r||(l=t.bind&&i?bn(r,cn):t.wrap&&i?kn(r):p&&mn(r)?fn(r):r,(t.sham||r&&r.sham||s&&s.sham)&&_n(l,"sham",!0),_n(m,o,l),p&&(wn(yn,n=u+"Prototype")||_n(yn,n,{}),_n(yn[n],o,r),t.real&&v&&!v[o]&&_n(v,o,r)))},Dn=Kt,Sn=A,Cn=Function.prototype,Tn=Dn&&Object.getOwnPropertyDescriptor,Mn=Sn(Cn,"name"),On={EXISTS:Mn,PROPER:Mn&&"something"===function(){}.name,CONFIGURABLE:Mn&&(!Dn||Dn&&Tn(Cn,"name").configurable)},En=p,Pn=Math.max,An=Math.min,In=function(t,e){var i=En(t);return i<0?Pn(i+e,0):An(i,e)},Ln=p,Nn=Math.min,Fn=function(t){return t>0?Nn(Ln(t),9007199254740991):0},Rn=function(t){return Fn(t.length)},Yn=Gi,jn=In,Hn=Rn,zn=function(t){return function(e,i,n){var o,r=Yn(e),s=Hn(r),a=jn(n,s);if(t&&i!=i){for(;s>a;)if((o=r[a++])!=o)return!0}else for(;s>a;a++)if((t||a in r)&&r[a]===i)return t||a||0;return!t&&-1}},Gn={includes:zn(!0),indexOf:zn(!1)},Bn=A,Wn=Gi,Vn=Gn.indexOf,Un=ri,Xn=u([].push),qn=function(t,e){var i,n=Wn(t),o=0,r=[];for(i in n)!Bn(Un,i)&&Bn(n,i)&&Xn(r,i);for(;e.length>o;)Bn(n,i=e[o++])&&(~Vn(r,i)||Xn(r,i));return r},Zn=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],$n=qn,Kn=Zn,Jn=Object.keys||function(t){return $n(t,Kn)},Qn=Jt,to=he,eo=Gi,io=Jn,no=Kt?Object.defineProperties:function(t,e){to(t);for(var i,n=eo(e),o=io(e),r=o.length,s=0;r>s;)Qn.f(t,i=o[s++],n[i]);return t},oo=W("document","documentElement"),ro=he,so=no,ao=Zn,lo=ri,ho=oo,uo=ie,co=oi("IE_PROTO"),po=function(){},fo=function(t){return"