create-nextjs-cms 0.5.55 → 0.5.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/templates/default/CHANGELOG.md +140 -140
- package/templates/default/_gitignore +1 -0
- package/templates/default/app/(auth)/auth/login/LoginPage.tsx +14 -11
- package/templates/default/app/(rootLayout)/admins/page.tsx +7 -2
- package/templates/default/app/(rootLayout)/advanced/page.tsx +8 -2
- package/templates/default/app/(rootLayout)/browse/[section]/[page]/page.tsx +17 -3
- package/templates/default/app/(rootLayout)/categorized/[section]/page.tsx +9 -1
- package/templates/default/app/(rootLayout)/dashboard-new/page.tsx +7 -0
- package/templates/default/app/(rootLayout)/edit/[section]/[itemId]/page.tsx +11 -1
- package/templates/default/app/(rootLayout)/layout.tsx +8 -1
- package/templates/default/app/(rootLayout)/new/[section]/page.tsx +9 -1
- package/templates/default/app/(rootLayout)/section/[section]/page.tsx +10 -1
- package/templates/default/app/(rootLayout)/settings/page.tsx +7 -1
- package/templates/default/app/api/trpc/[trpc]/route.ts +1 -1
- package/templates/default/app/api/video/route.ts +1 -1
- package/templates/default/app/layout.tsx +5 -3
- package/templates/default/app/providers.tsx +10 -9
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/LICENSE +191 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/README.md +118 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/install/build.js +38 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/install/check.js +14 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/channel.js +177 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/colour.js +195 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/composite.js +212 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/constructor.js +499 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/index.d.ts +1971 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/index.js +16 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/input.js +809 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/is.js +143 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/libvips.js +207 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/operation.js +1016 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/output.js +1666 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/resize.js +595 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/sharp.js +121 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/utility.js +291 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/package.json +202 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/binding.gyp +298 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/common.cc +1130 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/common.h +402 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/metadata.cc +346 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/metadata.h +90 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/operations.cc +499 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/operations.h +137 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/pipeline.cc +1814 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/pipeline.h +408 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/sharp.cc +43 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/stats.cc +186 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/stats.h +62 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/utilities.cc +288 -0
- package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/utilities.h +22 -0
- package/templates/default/components/BrowsePage.tsx +4 -4
- package/templates/default/components/DashboardNewPage.tsx +252 -0
- package/templates/default/components/Layout.tsx +2 -2
- package/templates/default/components/LogPage.tsx +2 -3
- package/templates/default/components/NavbarAlt.tsx +5 -5
- package/templates/default/components/SettingsPage.tsx +1 -1
- package/templates/default/components/Sidebar.tsx +7 -7
- package/templates/default/components/form/Form.tsx +5 -5
- package/templates/default/components/form/helpers/util.ts +5 -5
- package/templates/default/dynamic-schemas/schema.ts +381 -381
- package/templates/default/next-env.d.ts +1 -1
- package/templates/default/next.config.ts +24 -0
- package/templates/default/package.json +23 -17
- package/templates/default/{middleware.ts → proxy.ts} +3 -4
- package/templates/default/test/prize.section.ts +58 -0
- package/templates/default/tsconfig.json +6 -3
- package/templates/default/app/api/placeholder/route.ts +0 -7
- package/templates/default/components/form/helpers/_section-hot-reload.js +0 -11
- package/templates/default/public/tinymce/CHANGELOG.md +0 -3940
- package/templates/default/public/tinymce/README.md +0 -77
- package/templates/default/public/tinymce/bower.json +0 -27
- package/templates/default/public/tinymce/composer.json +0 -52
- package/templates/default/public/tinymce/icons/default/icons.js +0 -239
- package/templates/default/public/tinymce/icons/default/icons.min.js +0 -1
- package/templates/default/public/tinymce/icons/default/index.js +0 -7
- package/templates/default/public/tinymce/license.md +0 -9
- package/templates/default/public/tinymce/models/dom/index.js +0 -7
- package/templates/default/public/tinymce/models/dom/model.js +0 -8980
- package/templates/default/public/tinymce/models/dom/model.min.js +0 -1
- package/templates/default/public/tinymce/notices.txt +0 -21
- package/templates/default/public/tinymce/package.json +0 -32
- package/templates/default/public/tinymce/plugins/accordion/index.js +0 -7
- package/templates/default/public/tinymce/plugins/accordion/plugin.js +0 -1373
- package/templates/default/public/tinymce/plugins/accordion/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/advlist/index.js +0 -7
- package/templates/default/public/tinymce/plugins/advlist/plugin.js +0 -473
- package/templates/default/public/tinymce/plugins/advlist/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/anchor/index.js +0 -7
- package/templates/default/public/tinymce/plugins/anchor/plugin.js +0 -237
- package/templates/default/public/tinymce/plugins/anchor/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/autolink/index.js +0 -7
- package/templates/default/public/tinymce/plugins/autolink/plugin.js +0 -315
- package/templates/default/public/tinymce/plugins/autolink/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/autoresize/index.js +0 -7
- package/templates/default/public/tinymce/plugins/autoresize/plugin.js +0 -221
- package/templates/default/public/tinymce/plugins/autoresize/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/autosave/index.js +0 -7
- package/templates/default/public/tinymce/plugins/autosave/plugin.js +0 -249
- package/templates/default/public/tinymce/plugins/autosave/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/charmap/index.js +0 -7
- package/templates/default/public/tinymce/plugins/charmap/plugin.js +0 -997
- package/templates/default/public/tinymce/plugins/charmap/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/code/index.js +0 -7
- package/templates/default/public/tinymce/plugins/code/plugin.js +0 -98
- package/templates/default/public/tinymce/plugins/code/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/codesample/index.js +0 -7
- package/templates/default/public/tinymce/plugins/codesample/plugin.js +0 -3655
- package/templates/default/public/tinymce/plugins/codesample/plugin.min.js +0 -9
- package/templates/default/public/tinymce/plugins/directionality/index.js +0 -7
- package/templates/default/public/tinymce/plugins/directionality/plugin.js +0 -634
- package/templates/default/public/tinymce/plugins/directionality/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/emoticons/index.js +0 -7
- package/templates/default/public/tinymce/plugins/emoticons/js/emojiimages.js +0 -1
- package/templates/default/public/tinymce/plugins/emoticons/js/emojiimages.min.js +0 -1
- package/templates/default/public/tinymce/plugins/emoticons/js/emojis.js +0 -1
- package/templates/default/public/tinymce/plugins/emoticons/js/emojis.min.js +0 -1
- package/templates/default/public/tinymce/plugins/emoticons/plugin.js +0 -809
- package/templates/default/public/tinymce/plugins/emoticons/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/fullscreen/index.js +0 -7
- package/templates/default/public/tinymce/plugins/fullscreen/plugin.js +0 -1607
- package/templates/default/public/tinymce/plugins/fullscreen/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/help/index.js +0 -7
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ar.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/bg-BG.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/bg_BG.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ca.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/cs.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/da.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/de.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/el.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/en.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/es.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/eu.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/fa.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/fi.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/fr-FR.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/fr_FR.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/he-IL.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/he_IL.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/hi.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/hr.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/hu-HU.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/hu_HU.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/id.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/it.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ja.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/kk.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ko-KR.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ko_KR.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ms.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/nb-NO.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/nb_NO.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/nl.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/pl.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/pt-BR.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/pt-PT.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/pt_BR.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/pt_PT.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ro.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ru.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/sk.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/sl-SI.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/sl_SI.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/sv-SE.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/sv_SE.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/th-TH.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/th_TH.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/tr.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/uk.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/vi.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/zh-CN.js +0 -87
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/zh-TW.js +0 -93
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/zh_CN.js +0 -87
- package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/zh_TW.js +0 -93
- package/templates/default/public/tinymce/plugins/help/plugin.js +0 -826
- package/templates/default/public/tinymce/plugins/help/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/image/index.js +0 -7
- package/templates/default/public/tinymce/plugins/image/plugin.js +0 -1691
- package/templates/default/public/tinymce/plugins/image/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/importcss/index.js +0 -7
- package/templates/default/public/tinymce/plugins/importcss/plugin.js +0 -401
- package/templates/default/public/tinymce/plugins/importcss/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/insertdatetime/index.js +0 -7
- package/templates/default/public/tinymce/plugins/insertdatetime/plugin.js +0 -187
- package/templates/default/public/tinymce/plugins/insertdatetime/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/link/index.js +0 -7
- package/templates/default/public/tinymce/plugins/link/plugin.js +0 -1709
- package/templates/default/public/tinymce/plugins/link/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/lists/index.js +0 -7
- package/templates/default/public/tinymce/plugins/lists/plugin.js +0 -602
- package/templates/default/public/tinymce/plugins/lists/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/media/index.js +0 -7
- package/templates/default/public/tinymce/plugins/media/plugin.js +0 -1442
- package/templates/default/public/tinymce/plugins/media/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/nonbreaking/index.js +0 -7
- package/templates/default/public/tinymce/plugins/nonbreaking/plugin.js +0 -128
- package/templates/default/public/tinymce/plugins/nonbreaking/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/pagebreak/index.js +0 -7
- package/templates/default/public/tinymce/plugins/pagebreak/plugin.js +0 -123
- package/templates/default/public/tinymce/plugins/pagebreak/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/preview/index.js +0 -7
- package/templates/default/public/tinymce/plugins/preview/plugin.js +0 -843
- package/templates/default/public/tinymce/plugins/preview/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/quickbars/index.js +0 -7
- package/templates/default/public/tinymce/plugins/quickbars/plugin.js +0 -654
- package/templates/default/public/tinymce/plugins/quickbars/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/save/index.js +0 -7
- package/templates/default/public/tinymce/plugins/save/plugin.js +0 -136
- package/templates/default/public/tinymce/plugins/save/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/searchreplace/index.js +0 -7
- package/templates/default/public/tinymce/plugins/searchreplace/plugin.js +0 -1367
- package/templates/default/public/tinymce/plugins/searchreplace/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/table/index.js +0 -7
- package/templates/default/public/tinymce/plugins/table/plugin.js +0 -4008
- package/templates/default/public/tinymce/plugins/table/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/visualblocks/index.js +0 -7
- package/templates/default/public/tinymce/plugins/visualblocks/plugin.js +0 -106
- package/templates/default/public/tinymce/plugins/visualblocks/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/visualchars/index.js +0 -7
- package/templates/default/public/tinymce/plugins/visualchars/plugin.js +0 -808
- package/templates/default/public/tinymce/plugins/visualchars/plugin.min.js +0 -1
- package/templates/default/public/tinymce/plugins/wordcount/index.js +0 -7
- package/templates/default/public/tinymce/plugins/wordcount/plugin.js +0 -480
- package/templates/default/public/tinymce/plugins/wordcount/plugin.min.js +0 -1
- package/templates/default/public/tinymce/skins/content/dark/content.css +0 -75
- package/templates/default/public/tinymce/skins/content/dark/content.js +0 -10
- package/templates/default/public/tinymce/skins/content/dark/content.min.css +0 -10
- package/templates/default/public/tinymce/skins/content/dark/content.min.ts +0 -3
- package/templates/default/public/tinymce/skins/content/dark/content.ts +0 -3
- package/templates/default/public/tinymce/skins/content/default/content.css +0 -70
- package/templates/default/public/tinymce/skins/content/default/content.js +0 -10
- package/templates/default/public/tinymce/skins/content/default/content.min.css +0 -10
- package/templates/default/public/tinymce/skins/content/default/content.min.ts +0 -3
- package/templates/default/public/tinymce/skins/content/default/content.ts +0 -3
- package/templates/default/public/tinymce/skins/content/document/content.css +0 -75
- package/templates/default/public/tinymce/skins/content/document/content.js +0 -10
- package/templates/default/public/tinymce/skins/content/document/content.min.css +0 -10
- package/templates/default/public/tinymce/skins/content/document/content.min.ts +0 -3
- package/templates/default/public/tinymce/skins/content/document/content.ts +0 -3
- package/templates/default/public/tinymce/skins/content/tinymce-5/content.css +0 -70
- package/templates/default/public/tinymce/skins/content/tinymce-5/content.js +0 -10
- package/templates/default/public/tinymce/skins/content/tinymce-5/content.min.css +0 -10
- package/templates/default/public/tinymce/skins/content/tinymce-5/content.min.ts +0 -3
- package/templates/default/public/tinymce/skins/content/tinymce-5/content.ts +0 -3
- package/templates/default/public/tinymce/skins/content/tinymce-5-dark/content.css +0 -75
- package/templates/default/public/tinymce/skins/content/tinymce-5-dark/content.js +0 -10
- package/templates/default/public/tinymce/skins/content/tinymce-5-dark/content.min.css +0 -10
- package/templates/default/public/tinymce/skins/content/tinymce-5-dark/content.min.ts +0 -3
- package/templates/default/public/tinymce/skins/content/tinymce-5-dark/content.ts +0 -3
- package/templates/default/public/tinymce/skins/content/writer/content.css +0 -71
- package/templates/default/public/tinymce/skins/content/writer/content.js +0 -10
- package/templates/default/public/tinymce/skins/content/writer/content.min.css +0 -10
- package/templates/default/public/tinymce/skins/content/writer/content.min.ts +0 -3
- package/templates/default/public/tinymce/skins/content/writer/content.ts +0 -3
- package/templates/default/public/tinymce/skins/ui/oxide/content.css +0 -1037
- package/templates/default/public/tinymce/skins/ui/oxide/content.inline.css +0 -1031
- package/templates/default/public/tinymce/skins/ui/oxide/content.inline.js +0 -10
- package/templates/default/public/tinymce/skins/ui/oxide/content.inline.min.css +0 -10
- package/templates/default/public/tinymce/skins/ui/oxide/content.inline.min.ts +0 -116
- package/templates/default/public/tinymce/skins/ui/oxide/content.inline.ts +0 -116
- package/templates/default/public/tinymce/skins/ui/oxide/content.js +0 -10
- package/templates/default/public/tinymce/skins/ui/oxide/content.min.css +0 -10
- package/templates/default/public/tinymce/skins/ui/oxide/content.min.ts +0 -116
- package/templates/default/public/tinymce/skins/ui/oxide/content.ts +0 -116
- package/templates/default/public/tinymce/skins/ui/oxide/skin.css +0 -5615
- package/templates/default/public/tinymce/skins/ui/oxide/skin.js +0 -1
- package/templates/default/public/tinymce/skins/ui/oxide/skin.min.css +0 -1
- package/templates/default/public/tinymce/skins/ui/oxide/skin.min.ts +0 -507
- package/templates/default/public/tinymce/skins/ui/oxide/skin.shadowdom.css +0 -30
- package/templates/default/public/tinymce/skins/ui/oxide/skin.shadowdom.js +0 -1
- package/templates/default/public/tinymce/skins/ui/oxide/skin.shadowdom.min.css +0 -1
- package/templates/default/public/tinymce/skins/ui/oxide/skin.shadowdom.min.ts +0 -9
- package/templates/default/public/tinymce/skins/ui/oxide/skin.shadowdom.ts +0 -9
- package/templates/default/public/tinymce/skins/ui/oxide/skin.ts +0 -507
- package/templates/default/public/tinymce/skins/ui/oxide-dark/content.css +0 -1025
- package/templates/default/public/tinymce/skins/ui/oxide-dark/content.inline.css +0 -1031
- package/templates/default/public/tinymce/skins/ui/oxide-dark/content.inline.js +0 -10
- package/templates/default/public/tinymce/skins/ui/oxide-dark/content.inline.min.css +0 -10
- package/templates/default/public/tinymce/skins/ui/oxide-dark/content.inline.min.ts +0 -116
- package/templates/default/public/tinymce/skins/ui/oxide-dark/content.inline.ts +0 -116
- package/templates/default/public/tinymce/skins/ui/oxide-dark/content.js +0 -10
- package/templates/default/public/tinymce/skins/ui/oxide-dark/content.min.css +0 -10
- package/templates/default/public/tinymce/skins/ui/oxide-dark/content.min.ts +0 -116
- package/templates/default/public/tinymce/skins/ui/oxide-dark/content.ts +0 -116
- package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.css +0 -5618
- package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.js +0 -1
- package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.min.css +0 -1
- package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.min.ts +0 -507
- package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.css +0 -30
- package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.js +0 -1
- package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.css +0 -1
- package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.ts +0 -9
- package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.ts +0 -9
- package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.ts +0 -507
- package/templates/default/public/tinymce/skins/ui/tinymce-5/content.css +0 -1037
- package/templates/default/public/tinymce/skins/ui/tinymce-5/content.inline.css +0 -1031
- package/templates/default/public/tinymce/skins/ui/tinymce-5/content.inline.js +0 -10
- package/templates/default/public/tinymce/skins/ui/tinymce-5/content.inline.min.css +0 -10
- package/templates/default/public/tinymce/skins/ui/tinymce-5/content.inline.min.ts +0 -116
- package/templates/default/public/tinymce/skins/ui/tinymce-5/content.inline.ts +0 -116
- package/templates/default/public/tinymce/skins/ui/tinymce-5/content.js +0 -10
- package/templates/default/public/tinymce/skins/ui/tinymce-5/content.min.css +0 -10
- package/templates/default/public/tinymce/skins/ui/tinymce-5/content.min.ts +0 -116
- package/templates/default/public/tinymce/skins/ui/tinymce-5/content.ts +0 -116
- package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.css +0 -5734
- package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.js +0 -1
- package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.min.css +0 -1
- package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.min.ts +0 -508
- package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.shadowdom.css +0 -30
- package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.shadowdom.js +0 -1
- package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.shadowdom.min.css +0 -1
- package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.shadowdom.min.ts +0 -9
- package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.shadowdom.ts +0 -9
- package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.ts +0 -508
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.css +0 -1025
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.inline.css +0 -1031
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.inline.js +0 -10
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.inline.min.css +0 -10
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.inline.min.ts +0 -116
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.inline.ts +0 -116
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.js +0 -10
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.min.css +0 -10
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.min.ts +0 -116
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.ts +0 -116
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.css +0 -5734
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.js +0 -1
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.min.css +0 -1
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.min.ts +0 -508
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.css +0 -30
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.js +0 -1
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.min.css +0 -1
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.min.ts +0 -9
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.ts +0 -9
- package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.ts +0 -508
- package/templates/default/public/tinymce/themes/silver/index.js +0 -7
- package/templates/default/public/tinymce/themes/silver/theme.js +0 -34748
- package/templates/default/public/tinymce/themes/silver/theme.min.js +0 -1
- package/templates/default/public/tinymce/tinymce.d.ts +0 -3413
- package/templates/default/public/tinymce/tinymce.js +0 -41518
- package/templates/default/public/tinymce/tinymce.min.js +0 -10
|
@@ -1,1373 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TinyMCE version 8.3.1 (2025-12-17)
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
(function () {
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
var global$4 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
9
|
-
|
|
10
|
-
/* eslint-disable @typescript-eslint/no-wrapper-object-types */
|
|
11
|
-
const hasProto = (v, constructor, predicate) => {
|
|
12
|
-
if (predicate(v, constructor.prototype)) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
// String-based fallback time
|
|
17
|
-
return v.constructor?.name === constructor.name;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
const typeOf = (x) => {
|
|
21
|
-
const t = typeof x;
|
|
22
|
-
if (x === null) {
|
|
23
|
-
return 'null';
|
|
24
|
-
}
|
|
25
|
-
else if (t === 'object' && Array.isArray(x)) {
|
|
26
|
-
return 'array';
|
|
27
|
-
}
|
|
28
|
-
else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
|
|
29
|
-
return 'string';
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
return t;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const isType$1 = (type) => (value) => typeOf(value) === type;
|
|
36
|
-
const isSimpleType = (type) => (value) => typeof value === type;
|
|
37
|
-
const isString = isType$1('string');
|
|
38
|
-
const isBoolean = isSimpleType('boolean');
|
|
39
|
-
const isNullable = (a) => a === null || a === undefined;
|
|
40
|
-
const isNonNullable = (a) => !isNullable(a);
|
|
41
|
-
const isFunction = isSimpleType('function');
|
|
42
|
-
const isNumber = isSimpleType('number');
|
|
43
|
-
|
|
44
|
-
/** Compose two unary functions. Similar to compose, but avoids using Function.prototype.apply. */
|
|
45
|
-
const compose1 = (fbc, fab) => (a) => fbc(fab(a));
|
|
46
|
-
const constant = (value) => {
|
|
47
|
-
return () => {
|
|
48
|
-
return value;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
const tripleEquals = (a, b) => {
|
|
52
|
-
return a === b;
|
|
53
|
-
};
|
|
54
|
-
const never = constant(false);
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* The `Optional` type represents a value (of any type) that potentially does
|
|
58
|
-
* not exist. Any `Optional<T>` can either be a `Some<T>` (in which case the
|
|
59
|
-
* value does exist) or a `None` (in which case the value does not exist). This
|
|
60
|
-
* module defines a whole lot of FP-inspired utility functions for dealing with
|
|
61
|
-
* `Optional` objects.
|
|
62
|
-
*
|
|
63
|
-
* Comparison with null or undefined:
|
|
64
|
-
* - We don't get fancy null coalescing operators with `Optional`
|
|
65
|
-
* - We do get fancy helper functions with `Optional`
|
|
66
|
-
* - `Optional` support nesting, and allow for the type to still be nullable (or
|
|
67
|
-
* another `Optional`)
|
|
68
|
-
* - There is no option to turn off strict-optional-checks like there is for
|
|
69
|
-
* strict-null-checks
|
|
70
|
-
*/
|
|
71
|
-
class Optional {
|
|
72
|
-
tag;
|
|
73
|
-
value;
|
|
74
|
-
// Sneaky optimisation: every instance of Optional.none is identical, so just
|
|
75
|
-
// reuse the same object
|
|
76
|
-
static singletonNone = new Optional(false);
|
|
77
|
-
// The internal representation has a `tag` and a `value`, but both are
|
|
78
|
-
// private: able to be console.logged, but not able to be accessed by code
|
|
79
|
-
constructor(tag, value) {
|
|
80
|
-
this.tag = tag;
|
|
81
|
-
this.value = value;
|
|
82
|
-
}
|
|
83
|
-
// --- Identities ---
|
|
84
|
-
/**
|
|
85
|
-
* Creates a new `Optional<T>` that **does** contain a value.
|
|
86
|
-
*/
|
|
87
|
-
static some(value) {
|
|
88
|
-
return new Optional(true, value);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Create a new `Optional<T>` that **does not** contain a value. `T` can be
|
|
92
|
-
* any type because we don't actually have a `T`.
|
|
93
|
-
*/
|
|
94
|
-
static none() {
|
|
95
|
-
return Optional.singletonNone;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Perform a transform on an `Optional` type. Regardless of whether this
|
|
99
|
-
* `Optional` contains a value or not, `fold` will return a value of type `U`.
|
|
100
|
-
* If this `Optional` does not contain a value, the `U` will be created by
|
|
101
|
-
* calling `onNone`. If this `Optional` does contain a value, the `U` will be
|
|
102
|
-
* created by calling `onSome`.
|
|
103
|
-
*
|
|
104
|
-
* For the FP enthusiasts in the room, this function:
|
|
105
|
-
* 1. Could be used to implement all of the functions below
|
|
106
|
-
* 2. Forms a catamorphism
|
|
107
|
-
*/
|
|
108
|
-
fold(onNone, onSome) {
|
|
109
|
-
if (this.tag) {
|
|
110
|
-
return onSome(this.value);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
return onNone();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Determine if this `Optional` object contains a value.
|
|
118
|
-
*/
|
|
119
|
-
isSome() {
|
|
120
|
-
return this.tag;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Determine if this `Optional` object **does not** contain a value.
|
|
124
|
-
*/
|
|
125
|
-
isNone() {
|
|
126
|
-
return !this.tag;
|
|
127
|
-
}
|
|
128
|
-
// --- Functor (name stolen from Haskell / maths) ---
|
|
129
|
-
/**
|
|
130
|
-
* Perform a transform on an `Optional` object, **if** there is a value. If
|
|
131
|
-
* you provide a function to turn a T into a U, this is the function you use
|
|
132
|
-
* to turn an `Optional<T>` into an `Optional<U>`. If this **does** contain
|
|
133
|
-
* a value then the output will also contain a value (that value being the
|
|
134
|
-
* output of `mapper(this.value)`), and if this **does not** contain a value
|
|
135
|
-
* then neither will the output.
|
|
136
|
-
*/
|
|
137
|
-
map(mapper) {
|
|
138
|
-
if (this.tag) {
|
|
139
|
-
return Optional.some(mapper(this.value));
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
return Optional.none();
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
// --- Monad (name stolen from Haskell / maths) ---
|
|
146
|
-
/**
|
|
147
|
-
* Perform a transform on an `Optional` object, **if** there is a value.
|
|
148
|
-
* Unlike `map`, here the transform itself also returns an `Optional`.
|
|
149
|
-
*/
|
|
150
|
-
bind(binder) {
|
|
151
|
-
if (this.tag) {
|
|
152
|
-
return binder(this.value);
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
return Optional.none();
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
// --- Traversable (name stolen from Haskell / maths) ---
|
|
159
|
-
/**
|
|
160
|
-
* For a given predicate, this function finds out if there **exists** a value
|
|
161
|
-
* inside this `Optional` object that meets the predicate. In practice, this
|
|
162
|
-
* means that for `Optional`s that do not contain a value it returns false (as
|
|
163
|
-
* no predicate-meeting value exists).
|
|
164
|
-
*/
|
|
165
|
-
exists(predicate) {
|
|
166
|
-
return this.tag && predicate(this.value);
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* For a given predicate, this function finds out if **all** the values inside
|
|
170
|
-
* this `Optional` object meet the predicate. In practice, this means that
|
|
171
|
-
* for `Optional`s that do not contain a value it returns true (as all 0
|
|
172
|
-
* objects do meet the predicate).
|
|
173
|
-
*/
|
|
174
|
-
forall(predicate) {
|
|
175
|
-
return !this.tag || predicate(this.value);
|
|
176
|
-
}
|
|
177
|
-
filter(predicate) {
|
|
178
|
-
if (!this.tag || predicate(this.value)) {
|
|
179
|
-
return this;
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
return Optional.none();
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
// --- Getters ---
|
|
186
|
-
/**
|
|
187
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
188
|
-
* `replacement` value if the provided `Optional` object does not contain a
|
|
189
|
-
* value.
|
|
190
|
-
*/
|
|
191
|
-
getOr(replacement) {
|
|
192
|
-
return this.tag ? this.value : replacement;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
196
|
-
* `replacement` value if the provided `Optional` object does not contain a
|
|
197
|
-
* value. Unlike `getOr`, in this method the `replacement` object is also
|
|
198
|
-
* `Optional` - meaning that this method will always return an `Optional`.
|
|
199
|
-
*/
|
|
200
|
-
or(replacement) {
|
|
201
|
-
return this.tag ? this : replacement;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
205
|
-
* `replacement` value if the provided `Optional` object does not contain a
|
|
206
|
-
* value. Unlike `getOr`, in this method the `replacement` value is
|
|
207
|
-
* "thunked" - that is to say that you don't pass a value to `getOrThunk`, you
|
|
208
|
-
* pass a function which (if called) will **return** the `value` you want to
|
|
209
|
-
* use.
|
|
210
|
-
*/
|
|
211
|
-
getOrThunk(thunk) {
|
|
212
|
-
return this.tag ? this.value : thunk();
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
216
|
-
* `replacement` value if the provided Optional object does not contain a
|
|
217
|
-
* value.
|
|
218
|
-
*
|
|
219
|
-
* Unlike `or`, in this method the `replacement` value is "thunked" - that is
|
|
220
|
-
* to say that you don't pass a value to `orThunk`, you pass a function which
|
|
221
|
-
* (if called) will **return** the `value` you want to use.
|
|
222
|
-
*
|
|
223
|
-
* Unlike `getOrThunk`, in this method the `replacement` value is also
|
|
224
|
-
* `Optional`, meaning that this method will always return an `Optional`.
|
|
225
|
-
*/
|
|
226
|
-
orThunk(thunk) {
|
|
227
|
-
return this.tag ? this : thunk();
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Get the value out of the inside of the `Optional` object, throwing an
|
|
231
|
-
* exception if the provided `Optional` object does not contain a value.
|
|
232
|
-
*
|
|
233
|
-
* WARNING:
|
|
234
|
-
* You should only be using this function if you know that the `Optional`
|
|
235
|
-
* object **is not** empty (otherwise you're throwing exceptions in production
|
|
236
|
-
* code, which is bad).
|
|
237
|
-
*
|
|
238
|
-
* In tests this is more acceptable.
|
|
239
|
-
*
|
|
240
|
-
* Prefer other methods to this, such as `.each`.
|
|
241
|
-
*/
|
|
242
|
-
getOrDie(message) {
|
|
243
|
-
if (!this.tag) {
|
|
244
|
-
throw new Error(message ?? 'Called getOrDie on None');
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
return this.value;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
// --- Interop with null and undefined ---
|
|
251
|
-
/**
|
|
252
|
-
* Creates an `Optional` value from a nullable (or undefined-able) input.
|
|
253
|
-
* Null, or undefined, is converted to `None`, and anything else is converted
|
|
254
|
-
* to `Some`.
|
|
255
|
-
*/
|
|
256
|
-
static from(value) {
|
|
257
|
-
return isNonNullable(value) ? Optional.some(value) : Optional.none();
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Converts an `Optional` to a nullable type, by getting the value if it
|
|
261
|
-
* exists, or returning `null` if it does not.
|
|
262
|
-
*/
|
|
263
|
-
getOrNull() {
|
|
264
|
-
return this.tag ? this.value : null;
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Converts an `Optional` to an undefined-able type, by getting the value if
|
|
268
|
-
* it exists, or returning `undefined` if it does not.
|
|
269
|
-
*/
|
|
270
|
-
getOrUndefined() {
|
|
271
|
-
return this.value;
|
|
272
|
-
}
|
|
273
|
-
// --- Utilities ---
|
|
274
|
-
/**
|
|
275
|
-
* If the `Optional` contains a value, perform an action on that value.
|
|
276
|
-
* Unlike the rest of the methods on this type, `.each` has side-effects. If
|
|
277
|
-
* you want to transform an `Optional<T>` **into** something, then this is not
|
|
278
|
-
* the method for you. If you want to use an `Optional<T>` to **do**
|
|
279
|
-
* something, then this is the method for you - provided you're okay with not
|
|
280
|
-
* doing anything in the case where the `Optional` doesn't have a value inside
|
|
281
|
-
* it. If you're not sure whether your use-case fits into transforming
|
|
282
|
-
* **into** something or **doing** something, check whether it has a return
|
|
283
|
-
* value. If it does, you should be performing a transform.
|
|
284
|
-
*/
|
|
285
|
-
each(worker) {
|
|
286
|
-
if (this.tag) {
|
|
287
|
-
worker(this.value);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Turn the `Optional` object into an array that contains all of the values
|
|
292
|
-
* stored inside the `Optional`. In practice, this means the output will have
|
|
293
|
-
* either 0 or 1 elements.
|
|
294
|
-
*/
|
|
295
|
-
toArray() {
|
|
296
|
-
return this.tag ? [this.value] : [];
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Turn the `Optional` object into a string for debugging or printing. Not
|
|
300
|
-
* recommended for production code, but good for debugging. Also note that
|
|
301
|
-
* these days an `Optional` object can be logged to the console directly, and
|
|
302
|
-
* its inner value (if it exists) will be visible.
|
|
303
|
-
*/
|
|
304
|
-
toString() {
|
|
305
|
-
return this.tag ? `some(${this.value})` : 'none()';
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
const nativeIndexOf = Array.prototype.indexOf;
|
|
310
|
-
const rawIndexOf = (ts, t) => nativeIndexOf.call(ts, t);
|
|
311
|
-
const contains = (xs, x) => rawIndexOf(xs, x) > -1;
|
|
312
|
-
const map = (xs, f) => {
|
|
313
|
-
// pre-allocating array size when it's guaranteed to be known
|
|
314
|
-
// http://jsperf.com/push-allocated-vs-dynamic/22
|
|
315
|
-
const len = xs.length;
|
|
316
|
-
const r = new Array(len);
|
|
317
|
-
for (let i = 0; i < len; i++) {
|
|
318
|
-
const x = xs[i];
|
|
319
|
-
r[i] = f(x, i);
|
|
320
|
-
}
|
|
321
|
-
return r;
|
|
322
|
-
};
|
|
323
|
-
// Unwound implementing other functions in terms of each.
|
|
324
|
-
// The code size is roughly the same, and it should allow for better optimisation.
|
|
325
|
-
// const each = function<T, U>(xs: T[], f: (x: T, i?: number, xs?: T[]) => void): void {
|
|
326
|
-
const each$1 = (xs, f) => {
|
|
327
|
-
for (let i = 0, len = xs.length; i < len; i++) {
|
|
328
|
-
const x = xs[i];
|
|
329
|
-
f(x, i);
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
const filter = (xs, pred) => {
|
|
333
|
-
const r = [];
|
|
334
|
-
for (let i = 0, len = xs.length; i < len; i++) {
|
|
335
|
-
const x = xs[i];
|
|
336
|
-
if (pred(x, i)) {
|
|
337
|
-
r.push(x);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
return r;
|
|
341
|
-
};
|
|
342
|
-
const foldl = (xs, f, acc) => {
|
|
343
|
-
each$1(xs, (x, i) => {
|
|
344
|
-
acc = f(acc, x, i);
|
|
345
|
-
});
|
|
346
|
-
return acc;
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
// There are many variations of Object iteration that are faster than the 'for-in' style:
|
|
350
|
-
// http://jsperf.com/object-keys-iteration/107
|
|
351
|
-
//
|
|
352
|
-
// Use the native keys if it is available (IE9+), otherwise fall back to manually filtering
|
|
353
|
-
const keys = Object.keys;
|
|
354
|
-
const each = (obj, f) => {
|
|
355
|
-
const props = keys(obj);
|
|
356
|
-
for (let k = 0, len = props.length; k < len; k++) {
|
|
357
|
-
const i = props[k];
|
|
358
|
-
const x = obj[i];
|
|
359
|
-
f(x, i);
|
|
360
|
-
}
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Adds two numbers, and wrap to a range.
|
|
365
|
-
* If the result overflows to the right, snap to the left.
|
|
366
|
-
* If the result overflows to the left, snap to the right.
|
|
367
|
-
*/
|
|
368
|
-
// the division is meant to get a number between 0 and 1 for more information check this discussion: https://stackoverflow.com/questions/58285941/how-to-replace-math-random-with-crypto-getrandomvalues-and-keep-same-result
|
|
369
|
-
const random = () => window.crypto.getRandomValues(new Uint32Array(1))[0] / 4294967295;
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Generate a unique identifier.
|
|
373
|
-
*
|
|
374
|
-
* The unique portion of the identifier only contains an underscore
|
|
375
|
-
* and digits, so that it may safely be used within HTML attributes.
|
|
376
|
-
*
|
|
377
|
-
* The chance of generating a non-unique identifier has been minimized
|
|
378
|
-
* by combining the current time, a random number and a one-up counter.
|
|
379
|
-
*
|
|
380
|
-
* generate :: String -> String
|
|
381
|
-
*/
|
|
382
|
-
let unique = 0;
|
|
383
|
-
const generate = (prefix) => {
|
|
384
|
-
const date = new Date();
|
|
385
|
-
const time = date.getTime();
|
|
386
|
-
const random$1 = Math.floor(random() * 1000000000);
|
|
387
|
-
unique++;
|
|
388
|
-
return prefix + '_' + random$1 + unique + String(time);
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* **Is** the value stored inside this Optional object equal to `rhs`?
|
|
393
|
-
*/
|
|
394
|
-
const is$2 = (lhs, rhs, comparator = tripleEquals) => lhs.exists((left) => comparator(left, rhs));
|
|
395
|
-
|
|
396
|
-
const blank = (r) => (s) => s.replace(r, '');
|
|
397
|
-
/** removes all leading and trailing spaces */
|
|
398
|
-
const trim = blank(/^\s+|\s+$/g);
|
|
399
|
-
|
|
400
|
-
const point = (element, offset) => ({
|
|
401
|
-
element,
|
|
402
|
-
offset
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
const fromHtml = (html, scope) => {
|
|
406
|
-
const doc = scope || document;
|
|
407
|
-
const div = doc.createElement('div');
|
|
408
|
-
div.innerHTML = html;
|
|
409
|
-
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
|
410
|
-
const message = 'HTML does not have a single root node';
|
|
411
|
-
// eslint-disable-next-line no-console
|
|
412
|
-
console.error(message, html);
|
|
413
|
-
throw new Error(message);
|
|
414
|
-
}
|
|
415
|
-
return fromDom(div.childNodes[0]);
|
|
416
|
-
};
|
|
417
|
-
const fromTag = (tag, scope) => {
|
|
418
|
-
const doc = scope || document;
|
|
419
|
-
const node = doc.createElement(tag);
|
|
420
|
-
return fromDom(node);
|
|
421
|
-
};
|
|
422
|
-
const fromText = (text, scope) => {
|
|
423
|
-
const doc = scope || document;
|
|
424
|
-
const node = doc.createTextNode(text);
|
|
425
|
-
return fromDom(node);
|
|
426
|
-
};
|
|
427
|
-
const fromDom = (node) => {
|
|
428
|
-
// TODO: Consider removing this check, but left atm for safety
|
|
429
|
-
if (node === null || node === undefined) {
|
|
430
|
-
throw new Error('Node cannot be null or undefined');
|
|
431
|
-
}
|
|
432
|
-
return {
|
|
433
|
-
dom: node
|
|
434
|
-
};
|
|
435
|
-
};
|
|
436
|
-
const fromPoint = (docElm, x, y) => Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
|
|
437
|
-
// tslint:disable-next-line:variable-name
|
|
438
|
-
const SugarElement = {
|
|
439
|
-
fromHtml,
|
|
440
|
-
fromTag,
|
|
441
|
-
fromText,
|
|
442
|
-
fromDom,
|
|
443
|
-
fromPoint
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
const COMMENT = 8;
|
|
447
|
-
const DOCUMENT = 9;
|
|
448
|
-
const DOCUMENT_FRAGMENT = 11;
|
|
449
|
-
const ELEMENT = 1;
|
|
450
|
-
const TEXT = 3;
|
|
451
|
-
|
|
452
|
-
const is$1 = (element, selector) => {
|
|
453
|
-
const dom = element.dom;
|
|
454
|
-
if (dom.nodeType !== ELEMENT) {
|
|
455
|
-
return false;
|
|
456
|
-
}
|
|
457
|
-
else {
|
|
458
|
-
const elem = dom;
|
|
459
|
-
if (elem.matches !== undefined) {
|
|
460
|
-
return elem.matches(selector);
|
|
461
|
-
}
|
|
462
|
-
else if (elem.msMatchesSelector !== undefined) {
|
|
463
|
-
return elem.msMatchesSelector(selector);
|
|
464
|
-
}
|
|
465
|
-
else if (elem.webkitMatchesSelector !== undefined) {
|
|
466
|
-
return elem.webkitMatchesSelector(selector);
|
|
467
|
-
}
|
|
468
|
-
else if (elem.mozMatchesSelector !== undefined) {
|
|
469
|
-
// cast to any as mozMatchesSelector doesn't exist in TS DOM lib
|
|
470
|
-
return elem.mozMatchesSelector(selector);
|
|
471
|
-
}
|
|
472
|
-
else {
|
|
473
|
-
throw new Error('Browser lacks native selectors');
|
|
474
|
-
} // unfortunately we can't throw this on startup :(
|
|
475
|
-
}
|
|
476
|
-
};
|
|
477
|
-
const bypassSelector = (dom) =>
|
|
478
|
-
// Only elements, documents and shadow roots support querySelector
|
|
479
|
-
// shadow root element type is DOCUMENT_FRAGMENT
|
|
480
|
-
dom.nodeType !== ELEMENT && dom.nodeType !== DOCUMENT && dom.nodeType !== DOCUMENT_FRAGMENT ||
|
|
481
|
-
// IE fix for complex queries on empty nodes: http://jsfiddle.net/spyder/fv9ptr5L/
|
|
482
|
-
dom.childElementCount === 0;
|
|
483
|
-
const all = (selector, scope) => {
|
|
484
|
-
const base = scope === undefined ? document : scope.dom;
|
|
485
|
-
return bypassSelector(base) ? [] : map(base.querySelectorAll(selector), SugarElement.fromDom);
|
|
486
|
-
};
|
|
487
|
-
const one = (selector, scope) => {
|
|
488
|
-
const base = scope === undefined ? document : scope.dom;
|
|
489
|
-
return bypassSelector(base) ? Optional.none() : Optional.from(base.querySelector(selector)).map(SugarElement.fromDom);
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
const eq = (e1, e2) => e1.dom === e2.dom;
|
|
493
|
-
const is = is$1;
|
|
494
|
-
|
|
495
|
-
const name = (element) => {
|
|
496
|
-
const r = element.dom.nodeName;
|
|
497
|
-
return r.toLowerCase();
|
|
498
|
-
};
|
|
499
|
-
const type = (element) => element.dom.nodeType;
|
|
500
|
-
const isType = (t) => (element) => type(element) === t;
|
|
501
|
-
const isComment = (element) => type(element) === COMMENT || name(element) === '#comment';
|
|
502
|
-
const isElement = isType(ELEMENT);
|
|
503
|
-
const isText = isType(TEXT);
|
|
504
|
-
const isDocument = isType(DOCUMENT);
|
|
505
|
-
const isDocumentFragment = isType(DOCUMENT_FRAGMENT);
|
|
506
|
-
|
|
507
|
-
/**
|
|
508
|
-
* The document associated with the current element
|
|
509
|
-
* NOTE: this will throw if the owner is null.
|
|
510
|
-
*/
|
|
511
|
-
const owner = (element) => SugarElement.fromDom(element.dom.ownerDocument);
|
|
512
|
-
/**
|
|
513
|
-
* If the element is a document, return it. Otherwise, return its ownerDocument.
|
|
514
|
-
* @param dos
|
|
515
|
-
*/
|
|
516
|
-
const documentOrOwner = (dos) => isDocument(dos) ? dos : owner(dos);
|
|
517
|
-
const parent = (element) => Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
|
|
518
|
-
const parents = (element, isRoot) => {
|
|
519
|
-
const stop = isFunction(isRoot) ? isRoot : never;
|
|
520
|
-
// This is used a *lot* so it needs to be performant, not recursive
|
|
521
|
-
let dom = element.dom;
|
|
522
|
-
const ret = [];
|
|
523
|
-
while (dom.parentNode !== null && dom.parentNode !== undefined) {
|
|
524
|
-
const rawParent = dom.parentNode;
|
|
525
|
-
const p = SugarElement.fromDom(rawParent);
|
|
526
|
-
ret.push(p);
|
|
527
|
-
if (stop(p) === true) {
|
|
528
|
-
break;
|
|
529
|
-
}
|
|
530
|
-
else {
|
|
531
|
-
dom = rawParent;
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
return ret;
|
|
535
|
-
};
|
|
536
|
-
const prevSibling = (element) => Optional.from(element.dom.previousSibling).map(SugarElement.fromDom);
|
|
537
|
-
const nextSibling = (element) => Optional.from(element.dom.nextSibling).map(SugarElement.fromDom);
|
|
538
|
-
const children = (element) => map(element.dom.childNodes, SugarElement.fromDom);
|
|
539
|
-
const child = (element, index) => {
|
|
540
|
-
const cs = element.dom.childNodes;
|
|
541
|
-
return Optional.from(cs[index]).map(SugarElement.fromDom);
|
|
542
|
-
};
|
|
543
|
-
const firstChild = (element) => child(element, 0);
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* Is the element a ShadowRoot?
|
|
547
|
-
*
|
|
548
|
-
* Note: this is insufficient to test if any element is a shadow root, but it is sufficient to differentiate between
|
|
549
|
-
* a Document and a ShadowRoot.
|
|
550
|
-
*/
|
|
551
|
-
const isShadowRoot = (dos) => isDocumentFragment(dos) && isNonNullable(dos.dom.host);
|
|
552
|
-
const getRootNode = (e) => SugarElement.fromDom(e.dom.getRootNode());
|
|
553
|
-
/** If this element is in a ShadowRoot, return it. */
|
|
554
|
-
const getShadowRoot = (e) => {
|
|
555
|
-
const r = getRootNode(e);
|
|
556
|
-
return isShadowRoot(r) ? Optional.some(r) : Optional.none();
|
|
557
|
-
};
|
|
558
|
-
/** Return the host of a ShadowRoot.
|
|
559
|
-
*
|
|
560
|
-
* This function will throw if Shadow DOM is unsupported in the browser, or if the host is null.
|
|
561
|
-
* If you actually have a ShadowRoot, this shouldn't happen.
|
|
562
|
-
*/
|
|
563
|
-
const getShadowHost = (e) => SugarElement.fromDom(e.dom.host);
|
|
564
|
-
|
|
565
|
-
const before = (marker, element) => {
|
|
566
|
-
const parent$1 = parent(marker);
|
|
567
|
-
parent$1.each((v) => {
|
|
568
|
-
v.dom.insertBefore(element.dom, marker.dom);
|
|
569
|
-
});
|
|
570
|
-
};
|
|
571
|
-
const after$1 = (marker, element) => {
|
|
572
|
-
const sibling = nextSibling(marker);
|
|
573
|
-
sibling.fold(() => {
|
|
574
|
-
const parent$1 = parent(marker);
|
|
575
|
-
parent$1.each((v) => {
|
|
576
|
-
append$1(v, element);
|
|
577
|
-
});
|
|
578
|
-
}, (v) => {
|
|
579
|
-
before(v, element);
|
|
580
|
-
});
|
|
581
|
-
};
|
|
582
|
-
const prepend = (parent, element) => {
|
|
583
|
-
const firstChild$1 = firstChild(parent);
|
|
584
|
-
firstChild$1.fold(() => {
|
|
585
|
-
append$1(parent, element);
|
|
586
|
-
}, (v) => {
|
|
587
|
-
parent.dom.insertBefore(element.dom, v.dom);
|
|
588
|
-
});
|
|
589
|
-
};
|
|
590
|
-
const append$1 = (parent, element) => {
|
|
591
|
-
parent.dom.appendChild(element.dom);
|
|
592
|
-
};
|
|
593
|
-
const wrap = (element, wrapper) => {
|
|
594
|
-
before(element, wrapper);
|
|
595
|
-
append$1(wrapper, element);
|
|
596
|
-
};
|
|
597
|
-
|
|
598
|
-
const after = (marker, elements) => {
|
|
599
|
-
each$1(elements, (x, i) => {
|
|
600
|
-
const e = i === 0 ? marker : elements[i - 1];
|
|
601
|
-
after$1(e, x);
|
|
602
|
-
});
|
|
603
|
-
};
|
|
604
|
-
const append = (parent, elements) => {
|
|
605
|
-
each$1(elements, (x) => {
|
|
606
|
-
append$1(parent, x);
|
|
607
|
-
});
|
|
608
|
-
};
|
|
609
|
-
|
|
610
|
-
const rawSet = (dom, key, value) => {
|
|
611
|
-
/*
|
|
612
|
-
* JQuery coerced everything to a string, and silently did nothing on text node/null/undefined.
|
|
613
|
-
*
|
|
614
|
-
* We fail on those invalid cases, only allowing numbers and booleans.
|
|
615
|
-
*/
|
|
616
|
-
if (isString(value) || isBoolean(value) || isNumber(value)) {
|
|
617
|
-
dom.setAttribute(key, value + '');
|
|
618
|
-
}
|
|
619
|
-
else {
|
|
620
|
-
// eslint-disable-next-line no-console
|
|
621
|
-
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
|
|
622
|
-
throw new Error('Attribute value was not simple');
|
|
623
|
-
}
|
|
624
|
-
};
|
|
625
|
-
const set$2 = (element, key, value) => {
|
|
626
|
-
rawSet(element.dom, key, value);
|
|
627
|
-
};
|
|
628
|
-
const setAll = (element, attrs) => {
|
|
629
|
-
const dom = element.dom;
|
|
630
|
-
each(attrs, (v, k) => {
|
|
631
|
-
rawSet(dom, k, v);
|
|
632
|
-
});
|
|
633
|
-
};
|
|
634
|
-
const get$2 = (element, key) => {
|
|
635
|
-
const v = element.dom.getAttribute(key);
|
|
636
|
-
// undefined is the more appropriate value for JS, and this matches JQuery
|
|
637
|
-
return v === null ? undefined : v;
|
|
638
|
-
};
|
|
639
|
-
const getOpt = (element, key) => Optional.from(get$2(element, key));
|
|
640
|
-
const remove$2 = (element, key) => {
|
|
641
|
-
element.dom.removeAttribute(key);
|
|
642
|
-
};
|
|
643
|
-
const clone = (element) => foldl(element.dom.attributes, (acc, attr) => {
|
|
644
|
-
acc[attr.name] = attr.value;
|
|
645
|
-
return acc;
|
|
646
|
-
}, {});
|
|
647
|
-
|
|
648
|
-
const remove$1 = (element) => {
|
|
649
|
-
const dom = element.dom;
|
|
650
|
-
if (dom.parentNode !== null) {
|
|
651
|
-
dom.parentNode.removeChild(dom);
|
|
652
|
-
}
|
|
653
|
-
};
|
|
654
|
-
const unwrap = (wrapper) => {
|
|
655
|
-
const children$1 = children(wrapper);
|
|
656
|
-
if (children$1.length > 0) {
|
|
657
|
-
after(wrapper, children$1);
|
|
658
|
-
}
|
|
659
|
-
remove$1(wrapper);
|
|
660
|
-
};
|
|
661
|
-
|
|
662
|
-
// some elements, such as mathml, don't have style attributes
|
|
663
|
-
// others, such as angular elements, have style attributes that aren't a CSSStyleDeclaration
|
|
664
|
-
const isSupported = (dom) => dom.style !== undefined && isFunction(dom.style.getPropertyValue);
|
|
665
|
-
|
|
666
|
-
// Node.contains() is very, very, very good performance
|
|
667
|
-
// http://jsperf.com/closest-vs-contains/5
|
|
668
|
-
const inBody = (element) => {
|
|
669
|
-
// Technically this is only required on IE, where contains() returns false for text nodes.
|
|
670
|
-
// But it's cheap enough to run everywhere and Sugar doesn't have platform detection (yet).
|
|
671
|
-
const dom = isText(element) ? element.dom.parentNode : element.dom;
|
|
672
|
-
// use ownerDocument.body to ensure this works inside iframes.
|
|
673
|
-
// Normally contains is bad because an element "contains" itself, but here we want that.
|
|
674
|
-
if (dom === undefined || dom === null || dom.ownerDocument === null) {
|
|
675
|
-
return false;
|
|
676
|
-
}
|
|
677
|
-
const doc = dom.ownerDocument;
|
|
678
|
-
return getShadowRoot(SugarElement.fromDom(dom)).fold(() => doc.body.contains(dom), compose1(inBody, getShadowHost));
|
|
679
|
-
};
|
|
680
|
-
|
|
681
|
-
const internalSet = (dom, property, value) => {
|
|
682
|
-
// This is going to hurt. Apologies.
|
|
683
|
-
// JQuery coerces numbers to pixels for certain property names, and other times lets numbers through.
|
|
684
|
-
// we're going to be explicit; strings only.
|
|
685
|
-
if (!isString(value)) {
|
|
686
|
-
// eslint-disable-next-line no-console
|
|
687
|
-
console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);
|
|
688
|
-
throw new Error('CSS value must be a string: ' + value);
|
|
689
|
-
}
|
|
690
|
-
// removed: support for dom().style[property] where prop is camel case instead of normal property name
|
|
691
|
-
if (isSupported(dom)) {
|
|
692
|
-
dom.style.setProperty(property, value);
|
|
693
|
-
}
|
|
694
|
-
};
|
|
695
|
-
const internalRemove = (dom, property) => {
|
|
696
|
-
/*
|
|
697
|
-
* IE9 and above - MDN doesn't have details, but here's a couple of random internet claims
|
|
698
|
-
*
|
|
699
|
-
* http://help.dottoro.com/ljopsjck.php
|
|
700
|
-
* http://stackoverflow.com/a/7901886/7546
|
|
701
|
-
*/
|
|
702
|
-
if (isSupported(dom)) {
|
|
703
|
-
dom.style.removeProperty(property);
|
|
704
|
-
}
|
|
705
|
-
};
|
|
706
|
-
const set$1 = (element, property, value) => {
|
|
707
|
-
const dom = element.dom;
|
|
708
|
-
internalSet(dom, property, value);
|
|
709
|
-
};
|
|
710
|
-
/*
|
|
711
|
-
* NOTE: For certain properties, this returns the "used value" which is subtly different to the "computed value" (despite calling getComputedStyle).
|
|
712
|
-
* Blame CSS 2.0.
|
|
713
|
-
*
|
|
714
|
-
* https://developer.mozilla.org/en-US/docs/Web/CSS/used_value
|
|
715
|
-
*/
|
|
716
|
-
const get$1 = (element, property) => {
|
|
717
|
-
const dom = element.dom;
|
|
718
|
-
/*
|
|
719
|
-
* IE9 and above per
|
|
720
|
-
* https://developer.mozilla.org/en/docs/Web/API/window.getComputedStyle
|
|
721
|
-
*
|
|
722
|
-
* Not in numerosity, because it doesn't memoize and looking this up dynamically in performance critical code would be horrendous.
|
|
723
|
-
*
|
|
724
|
-
* JQuery has some magic here for IE popups, but we don't really need that.
|
|
725
|
-
* It also uses element.ownerDocument.defaultView to handle iframes but that hasn't been required since FF 3.6.
|
|
726
|
-
*/
|
|
727
|
-
const styles = window.getComputedStyle(dom);
|
|
728
|
-
const r = styles.getPropertyValue(property);
|
|
729
|
-
// jquery-ism: If r is an empty string, check that the element is not in a document. If it isn't, return the raw value.
|
|
730
|
-
// Turns out we do this a lot.
|
|
731
|
-
return (r === '' && !inBody(element)) ? getUnsafeProperty(dom, property) : r;
|
|
732
|
-
};
|
|
733
|
-
// removed: support for dom().style[property] where prop is camel case instead of normal property name
|
|
734
|
-
// empty string is what the browsers (IE11 and Chrome) return when the propertyValue doesn't exists.
|
|
735
|
-
const getUnsafeProperty = (dom, property) => isSupported(dom) ? dom.style.getPropertyValue(property) : '';
|
|
736
|
-
/*
|
|
737
|
-
* Gets the raw value from the style attribute. Useful for retrieving "used values" from the DOM:
|
|
738
|
-
* https://developer.mozilla.org/en-US/docs/Web/CSS/used_value
|
|
739
|
-
*
|
|
740
|
-
* Returns NONE if the property isn't set, or the value is an empty string.
|
|
741
|
-
*/
|
|
742
|
-
const getRaw = (element, property) => {
|
|
743
|
-
const dom = element.dom;
|
|
744
|
-
const raw = getUnsafeProperty(dom, property);
|
|
745
|
-
return Optional.from(raw).filter((r) => r.length > 0);
|
|
746
|
-
};
|
|
747
|
-
const remove = (element, property) => {
|
|
748
|
-
const dom = element.dom;
|
|
749
|
-
internalRemove(dom, property);
|
|
750
|
-
if (is$2(getOpt(element, 'style').map(trim), '')) {
|
|
751
|
-
// No more styles left, remove the style attribute as well
|
|
752
|
-
remove$2(element, 'style');
|
|
753
|
-
}
|
|
754
|
-
};
|
|
755
|
-
|
|
756
|
-
const NodeValue = (is, name) => {
|
|
757
|
-
const get = (element) => {
|
|
758
|
-
if (!is(element)) {
|
|
759
|
-
throw new Error('Can only get ' + name + ' value of a ' + name + ' node');
|
|
760
|
-
}
|
|
761
|
-
return getOption(element).getOr('');
|
|
762
|
-
};
|
|
763
|
-
const getOption = (element) => is(element) ? Optional.from(element.dom.nodeValue) : Optional.none();
|
|
764
|
-
const set = (element, value) => {
|
|
765
|
-
if (!is(element)) {
|
|
766
|
-
throw new Error('Can only set raw ' + name + ' value of a ' + name + ' node');
|
|
767
|
-
}
|
|
768
|
-
element.dom.nodeValue = value;
|
|
769
|
-
};
|
|
770
|
-
return {
|
|
771
|
-
get,
|
|
772
|
-
getOption,
|
|
773
|
-
set
|
|
774
|
-
};
|
|
775
|
-
};
|
|
776
|
-
|
|
777
|
-
const api = NodeValue(isText, 'text');
|
|
778
|
-
const get = (element) => api.get(element);
|
|
779
|
-
const set = (element, value) => api.set(element, value);
|
|
780
|
-
|
|
781
|
-
var ClosestOrAncestor = (is, ancestor, scope, a, isRoot) => {
|
|
782
|
-
if (is(scope, a)) {
|
|
783
|
-
return Optional.some(scope);
|
|
784
|
-
}
|
|
785
|
-
else if (isFunction(isRoot) && isRoot(scope)) {
|
|
786
|
-
return Optional.none();
|
|
787
|
-
}
|
|
788
|
-
else {
|
|
789
|
-
return ancestor(scope, a, isRoot);
|
|
790
|
-
}
|
|
791
|
-
};
|
|
792
|
-
|
|
793
|
-
const ancestor$1 = (scope, predicate, isRoot) => {
|
|
794
|
-
let element = scope.dom;
|
|
795
|
-
const stop = isFunction(isRoot) ? isRoot : never;
|
|
796
|
-
while (element.parentNode) {
|
|
797
|
-
element = element.parentNode;
|
|
798
|
-
const el = SugarElement.fromDom(element);
|
|
799
|
-
if (predicate(el)) {
|
|
800
|
-
return Optional.some(el);
|
|
801
|
-
}
|
|
802
|
-
else if (stop(el)) {
|
|
803
|
-
break;
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
return Optional.none();
|
|
807
|
-
};
|
|
808
|
-
|
|
809
|
-
const ancestor = (scope, selector, isRoot) => ancestor$1(scope, (e) => is$1(e, selector), isRoot);
|
|
810
|
-
const descendant = (scope, selector) => one(selector, scope);
|
|
811
|
-
// Returns Some(closest ancestor element (sugared)) matching 'selector' up to isRoot, or None() otherwise
|
|
812
|
-
const closest = (scope, selector, isRoot) => {
|
|
813
|
-
const is = (element, selector) => is$1(element, selector);
|
|
814
|
-
return ClosestOrAncestor(is, ancestor, scope, selector, isRoot);
|
|
815
|
-
};
|
|
816
|
-
|
|
817
|
-
const descendants$1 = (scope, predicate) => {
|
|
818
|
-
let result = [];
|
|
819
|
-
// Recurse.toArray() might help here
|
|
820
|
-
each$1(children(scope), (x) => {
|
|
821
|
-
if (predicate(x)) {
|
|
822
|
-
result = result.concat([x]);
|
|
823
|
-
}
|
|
824
|
-
result = result.concat(descendants$1(x, predicate));
|
|
825
|
-
});
|
|
826
|
-
return result;
|
|
827
|
-
};
|
|
828
|
-
|
|
829
|
-
const descendants = (scope, selector) => all(selector, scope);
|
|
830
|
-
|
|
831
|
-
var TagBoundaries = [
|
|
832
|
-
'body',
|
|
833
|
-
'p',
|
|
834
|
-
'div',
|
|
835
|
-
'article',
|
|
836
|
-
'aside',
|
|
837
|
-
'figcaption',
|
|
838
|
-
'figure',
|
|
839
|
-
'footer',
|
|
840
|
-
'header',
|
|
841
|
-
'nav',
|
|
842
|
-
'section',
|
|
843
|
-
'ol',
|
|
844
|
-
'ul',
|
|
845
|
-
'li',
|
|
846
|
-
'table',
|
|
847
|
-
'thead',
|
|
848
|
-
'tbody',
|
|
849
|
-
'tfoot',
|
|
850
|
-
'caption',
|
|
851
|
-
'tr',
|
|
852
|
-
'td',
|
|
853
|
-
'th',
|
|
854
|
-
'h1',
|
|
855
|
-
'h2',
|
|
856
|
-
'h3',
|
|
857
|
-
'h4',
|
|
858
|
-
'h5',
|
|
859
|
-
'h6',
|
|
860
|
-
'blockquote',
|
|
861
|
-
'pre',
|
|
862
|
-
'address'
|
|
863
|
-
];
|
|
864
|
-
|
|
865
|
-
var DomUniverse = () => {
|
|
866
|
-
const clone$1 = (element) => {
|
|
867
|
-
return SugarElement.fromDom(element.dom.cloneNode(false));
|
|
868
|
-
};
|
|
869
|
-
const document = (element) => documentOrOwner(element).dom;
|
|
870
|
-
const isBoundary = (element) => {
|
|
871
|
-
if (!isElement(element)) {
|
|
872
|
-
return false;
|
|
873
|
-
}
|
|
874
|
-
if (name(element) === 'body') {
|
|
875
|
-
return true;
|
|
876
|
-
}
|
|
877
|
-
return contains(TagBoundaries, name(element));
|
|
878
|
-
};
|
|
879
|
-
const isEmptyTag = (element) => {
|
|
880
|
-
if (!isElement(element)) {
|
|
881
|
-
return false;
|
|
882
|
-
}
|
|
883
|
-
return contains(['br', 'img', 'hr', 'input'], name(element));
|
|
884
|
-
};
|
|
885
|
-
const isNonEditable = (element) => isElement(element) && get$2(element, 'contenteditable') === 'false';
|
|
886
|
-
const comparePosition = (element, other) => {
|
|
887
|
-
return element.dom.compareDocumentPosition(other.dom);
|
|
888
|
-
};
|
|
889
|
-
const copyAttributesTo = (source, destination) => {
|
|
890
|
-
const as = clone(source);
|
|
891
|
-
setAll(destination, as);
|
|
892
|
-
};
|
|
893
|
-
const isSpecial = (element) => {
|
|
894
|
-
const tag = name(element);
|
|
895
|
-
return contains([
|
|
896
|
-
'script', 'noscript', 'iframe', 'noframes', 'noembed', 'title', 'style', 'textarea', 'xmp'
|
|
897
|
-
], tag);
|
|
898
|
-
};
|
|
899
|
-
const getLanguage = (element) => isElement(element) ? getOpt(element, 'lang') : Optional.none();
|
|
900
|
-
return {
|
|
901
|
-
up: constant({
|
|
902
|
-
selector: ancestor,
|
|
903
|
-
closest: closest,
|
|
904
|
-
predicate: ancestor$1,
|
|
905
|
-
all: parents
|
|
906
|
-
}),
|
|
907
|
-
down: constant({
|
|
908
|
-
selector: descendants,
|
|
909
|
-
predicate: descendants$1
|
|
910
|
-
}),
|
|
911
|
-
styles: constant({
|
|
912
|
-
get: get$1,
|
|
913
|
-
getRaw: getRaw,
|
|
914
|
-
set: set$1,
|
|
915
|
-
remove: remove
|
|
916
|
-
}),
|
|
917
|
-
attrs: constant({
|
|
918
|
-
get: get$2,
|
|
919
|
-
set: set$2,
|
|
920
|
-
remove: remove$2,
|
|
921
|
-
copyTo: copyAttributesTo
|
|
922
|
-
}),
|
|
923
|
-
insert: constant({
|
|
924
|
-
before: before,
|
|
925
|
-
after: after$1,
|
|
926
|
-
afterAll: after,
|
|
927
|
-
append: append$1,
|
|
928
|
-
appendAll: append,
|
|
929
|
-
prepend: prepend,
|
|
930
|
-
wrap: wrap
|
|
931
|
-
}),
|
|
932
|
-
remove: constant({
|
|
933
|
-
unwrap: unwrap,
|
|
934
|
-
remove: remove$1
|
|
935
|
-
}),
|
|
936
|
-
create: constant({
|
|
937
|
-
nu: SugarElement.fromTag,
|
|
938
|
-
clone: clone$1,
|
|
939
|
-
text: SugarElement.fromText
|
|
940
|
-
}),
|
|
941
|
-
query: constant({
|
|
942
|
-
comparePosition,
|
|
943
|
-
prevSibling: prevSibling,
|
|
944
|
-
nextSibling: nextSibling
|
|
945
|
-
}),
|
|
946
|
-
property: constant({
|
|
947
|
-
children: children,
|
|
948
|
-
name: name,
|
|
949
|
-
parent: parent,
|
|
950
|
-
document,
|
|
951
|
-
isText: isText,
|
|
952
|
-
isComment: isComment,
|
|
953
|
-
isElement: isElement,
|
|
954
|
-
isSpecial,
|
|
955
|
-
getLanguage,
|
|
956
|
-
getText: get,
|
|
957
|
-
setText: set,
|
|
958
|
-
isBoundary,
|
|
959
|
-
isEmptyTag,
|
|
960
|
-
isNonEditable
|
|
961
|
-
}),
|
|
962
|
-
eq: eq,
|
|
963
|
-
is: is
|
|
964
|
-
};
|
|
965
|
-
};
|
|
966
|
-
|
|
967
|
-
const scan = (universe, element, direction) => {
|
|
968
|
-
// if a comment or zero-length text, scan the siblings
|
|
969
|
-
if ((universe.property().isText(element) && universe.property().getText(element).trim().length === 0)
|
|
970
|
-
|| universe.property().isComment(element)) {
|
|
971
|
-
return direction(element).bind((elem) => {
|
|
972
|
-
return scan(universe, elem, direction).orThunk(() => {
|
|
973
|
-
return Optional.some(elem);
|
|
974
|
-
});
|
|
975
|
-
});
|
|
976
|
-
}
|
|
977
|
-
else {
|
|
978
|
-
return Optional.none();
|
|
979
|
-
}
|
|
980
|
-
};
|
|
981
|
-
const toEnd = (universe, element) => {
|
|
982
|
-
if (universe.property().isText(element)) {
|
|
983
|
-
return universe.property().getText(element).length;
|
|
984
|
-
}
|
|
985
|
-
const children = universe.property().children(element);
|
|
986
|
-
return children.length;
|
|
987
|
-
};
|
|
988
|
-
const freefallRtl$2 = (universe, element) => {
|
|
989
|
-
const candidate = scan(universe, element, universe.query().prevSibling).getOr(element);
|
|
990
|
-
if (universe.property().isText(candidate)) {
|
|
991
|
-
return point(candidate, toEnd(universe, candidate));
|
|
992
|
-
}
|
|
993
|
-
const children = universe.property().children(candidate);
|
|
994
|
-
return children.length > 0 ? freefallRtl$2(universe, children[children.length - 1]) : point(candidate, toEnd(universe, candidate));
|
|
995
|
-
};
|
|
996
|
-
|
|
997
|
-
const freefallRtl$1 = freefallRtl$2;
|
|
998
|
-
|
|
999
|
-
const universe = DomUniverse();
|
|
1000
|
-
const freefallRtl = (element) => {
|
|
1001
|
-
return freefallRtl$1(universe, element);
|
|
1002
|
-
};
|
|
1003
|
-
|
|
1004
|
-
const fireToggleAccordionEvent = (editor, element, state) => editor.dispatch('ToggledAccordion', { element, state });
|
|
1005
|
-
const fireToggleAllAccordionsEvent = (editor, elements, state) => editor.dispatch('ToggledAllAccordions', { elements, state });
|
|
1006
|
-
|
|
1007
|
-
const option = (name) => (editor) => editor.options.get(name);
|
|
1008
|
-
const isDisabled = option('disabled');
|
|
1009
|
-
|
|
1010
|
-
const accordionTag = 'details';
|
|
1011
|
-
const accordionDetailsClass = 'mce-accordion';
|
|
1012
|
-
const accordionSummaryClass = 'mce-accordion-summary';
|
|
1013
|
-
const accordionBodyWrapperClass = 'mce-accordion-body';
|
|
1014
|
-
const accordionBodyWrapperTag = 'div';
|
|
1015
|
-
const accordionReadonlyCompensationAttribute = 'data-mce-accordion-open';
|
|
1016
|
-
|
|
1017
|
-
var global$3 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
1018
|
-
|
|
1019
|
-
const isSummary = (node) => node?.nodeName === 'SUMMARY';
|
|
1020
|
-
const isDetails = (node) => node?.nodeName === 'DETAILS';
|
|
1021
|
-
const isOpen = (details) => details.hasAttribute('open');
|
|
1022
|
-
const isInSummary = (editor) => {
|
|
1023
|
-
const node = editor.selection.getNode();
|
|
1024
|
-
return isSummary(node) || Boolean(editor.dom.getParent(node, isSummary));
|
|
1025
|
-
};
|
|
1026
|
-
const isAtDetailsStart = (editor) => {
|
|
1027
|
-
const rng = editor.selection.getRng();
|
|
1028
|
-
return isDetails(rng.startContainer)
|
|
1029
|
-
&& rng.collapsed
|
|
1030
|
-
&& rng.startOffset === 0;
|
|
1031
|
-
};
|
|
1032
|
-
const isInsertAllowed = (editor) => !isInSummary(editor) && editor.dom.isEditable(editor.selection.getNode()) && !editor.mode.isReadOnly();
|
|
1033
|
-
const getSelectedDetails = (editor) => Optional.from(editor.dom.getParent(editor.selection.getNode(), isDetails));
|
|
1034
|
-
const isDetailsSelected = (editor) => getSelectedDetails(editor).isSome();
|
|
1035
|
-
const insertBogus = (element) => {
|
|
1036
|
-
element.innerHTML = '<br data-mce-bogus="1" />';
|
|
1037
|
-
return element;
|
|
1038
|
-
};
|
|
1039
|
-
const createParagraph = (editor) => insertBogus(editor.dom.create('p'));
|
|
1040
|
-
const createSummary = (editor) => insertBogus(editor.dom.create('summary'));
|
|
1041
|
-
const insertAndSelectParagraphAfter = (editor, target) => {
|
|
1042
|
-
const paragraph = createParagraph(editor);
|
|
1043
|
-
target.insertAdjacentElement('afterend', paragraph);
|
|
1044
|
-
editor.selection.setCursorLocation(paragraph, 0);
|
|
1045
|
-
};
|
|
1046
|
-
const normalizeContent = (editor, accordion) => {
|
|
1047
|
-
if (isSummary(accordion?.lastChild)) {
|
|
1048
|
-
const paragraph = createParagraph(editor);
|
|
1049
|
-
accordion.appendChild(paragraph);
|
|
1050
|
-
editor.selection.setCursorLocation(paragraph, 0);
|
|
1051
|
-
}
|
|
1052
|
-
};
|
|
1053
|
-
const normalizeSummary = (editor, accordion) => {
|
|
1054
|
-
if (!isSummary(accordion?.firstChild)) {
|
|
1055
|
-
const summary = createSummary(editor);
|
|
1056
|
-
accordion.prepend(summary);
|
|
1057
|
-
editor.selection.setCursorLocation(summary, 0);
|
|
1058
|
-
}
|
|
1059
|
-
};
|
|
1060
|
-
const normalizeAccordion = (editor) => (accordion) => {
|
|
1061
|
-
normalizeContent(editor, accordion);
|
|
1062
|
-
normalizeSummary(editor, accordion);
|
|
1063
|
-
};
|
|
1064
|
-
const normalizeDetails = (editor) => {
|
|
1065
|
-
global$3.each(global$3.grep(editor.dom.select('details', editor.getBody())), normalizeAccordion(editor));
|
|
1066
|
-
};
|
|
1067
|
-
|
|
1068
|
-
const insertAccordion = (editor) => {
|
|
1069
|
-
if (!isInsertAllowed(editor)) {
|
|
1070
|
-
return;
|
|
1071
|
-
}
|
|
1072
|
-
const editorBody = SugarElement.fromDom(editor.getBody());
|
|
1073
|
-
const uid = generate('acc');
|
|
1074
|
-
const summaryText = editor.dom.encode(editor.selection.getRng().toString() || editor.translate('Accordion summary...'));
|
|
1075
|
-
const bodyText = editor.dom.encode(editor.translate('Accordion body...'));
|
|
1076
|
-
const accordionSummaryHtml = `<summary class="${accordionSummaryClass}">${summaryText}</summary>`;
|
|
1077
|
-
const accordionBodyHtml = `<${accordionBodyWrapperTag} class="${accordionBodyWrapperClass}"><p>${bodyText}</p></${accordionBodyWrapperTag}>`;
|
|
1078
|
-
editor.undoManager.transact(() => {
|
|
1079
|
-
editor.insertContent([
|
|
1080
|
-
`<details data-mce-id="${uid}" class="${accordionDetailsClass}" open="open">`,
|
|
1081
|
-
accordionSummaryHtml,
|
|
1082
|
-
accordionBodyHtml,
|
|
1083
|
-
`</details>`
|
|
1084
|
-
].join(''));
|
|
1085
|
-
descendant(editorBody, `[data-mce-id="${uid}"]`).each((detailsElm) => {
|
|
1086
|
-
remove$2(detailsElm, 'data-mce-id');
|
|
1087
|
-
descendant(detailsElm, `summary`).each((summaryElm) => {
|
|
1088
|
-
// Set the cursor location to be at the end of the summary text
|
|
1089
|
-
const rng = editor.dom.createRng();
|
|
1090
|
-
const des = freefallRtl(summaryElm);
|
|
1091
|
-
rng.setStart(des.element.dom, des.offset);
|
|
1092
|
-
rng.setEnd(des.element.dom, des.offset);
|
|
1093
|
-
editor.selection.setRng(rng);
|
|
1094
|
-
});
|
|
1095
|
-
});
|
|
1096
|
-
});
|
|
1097
|
-
};
|
|
1098
|
-
const toggleDetailsElement = (isReadonly, details, state) => {
|
|
1099
|
-
const shouldOpen = state ?? !isOpen(details);
|
|
1100
|
-
if (!isReadonly) {
|
|
1101
|
-
details.setAttribute(accordionReadonlyCompensationAttribute, shouldOpen ? 'open' : 'closed');
|
|
1102
|
-
}
|
|
1103
|
-
if (shouldOpen) {
|
|
1104
|
-
details.setAttribute('open', 'open');
|
|
1105
|
-
}
|
|
1106
|
-
else {
|
|
1107
|
-
details.removeAttribute('open');
|
|
1108
|
-
}
|
|
1109
|
-
return shouldOpen;
|
|
1110
|
-
};
|
|
1111
|
-
const toggleAccordion = (editor, state) => {
|
|
1112
|
-
if (isDisabled(editor)) {
|
|
1113
|
-
return;
|
|
1114
|
-
}
|
|
1115
|
-
getSelectedDetails(editor).each((details) => {
|
|
1116
|
-
fireToggleAccordionEvent(editor, details, toggleDetailsElement(editor.readonly, details, state));
|
|
1117
|
-
});
|
|
1118
|
-
};
|
|
1119
|
-
const removeAccordion = (editor) => {
|
|
1120
|
-
if (!editor.mode.isReadOnly()) {
|
|
1121
|
-
getSelectedDetails(editor)
|
|
1122
|
-
.each((details) => {
|
|
1123
|
-
const { nextSibling } = details;
|
|
1124
|
-
if (nextSibling) {
|
|
1125
|
-
editor.selection.select(nextSibling, true);
|
|
1126
|
-
editor.selection.collapse(true);
|
|
1127
|
-
}
|
|
1128
|
-
else {
|
|
1129
|
-
insertAndSelectParagraphAfter(editor, details);
|
|
1130
|
-
}
|
|
1131
|
-
details.remove();
|
|
1132
|
-
});
|
|
1133
|
-
}
|
|
1134
|
-
};
|
|
1135
|
-
const toggleAllAccordions = (editor, state) => {
|
|
1136
|
-
const accordions = Array.from(editor.getBody().querySelectorAll('details'));
|
|
1137
|
-
if (accordions.length === 0) {
|
|
1138
|
-
return;
|
|
1139
|
-
}
|
|
1140
|
-
each$1(accordions, (accordion) => toggleDetailsElement(editor.readonly, accordion, state ?? !isOpen(accordion)));
|
|
1141
|
-
fireToggleAllAccordionsEvent(editor, accordions, state);
|
|
1142
|
-
};
|
|
1143
|
-
|
|
1144
|
-
const register$1 = (editor) => {
|
|
1145
|
-
editor.addCommand('InsertAccordion', () => insertAccordion(editor));
|
|
1146
|
-
editor.addCommand('ToggleAccordion', (_ui, value) => toggleAccordion(editor, value));
|
|
1147
|
-
editor.addCommand('ToggleAllAccordions', (_ui, value) => toggleAllAccordions(editor, value));
|
|
1148
|
-
editor.addCommand('RemoveAccordion', () => removeAccordion(editor));
|
|
1149
|
-
};
|
|
1150
|
-
|
|
1151
|
-
var global$2 = tinymce.util.Tools.resolve('tinymce.html.Node');
|
|
1152
|
-
|
|
1153
|
-
const normalizeOpenAttribute = (node) => {
|
|
1154
|
-
if (hasAttribute(node, 'open')) {
|
|
1155
|
-
setAttribute(node, 'open', 'open');
|
|
1156
|
-
}
|
|
1157
|
-
};
|
|
1158
|
-
const hasAttribute = (node, attribute) => node.attr(attribute) !== undefined;
|
|
1159
|
-
const setAttribute = (node, attribute, value) => {
|
|
1160
|
-
node.attr(attribute, value);
|
|
1161
|
-
};
|
|
1162
|
-
|
|
1163
|
-
const getClassList = (node) => node.attr('class')?.split(' ') ?? [];
|
|
1164
|
-
const addClasses = (node, classes) => {
|
|
1165
|
-
const classListSet = new Set([...getClassList(node), ...classes]);
|
|
1166
|
-
const newClassList = Array.from(classListSet);
|
|
1167
|
-
if (newClassList.length > 0) {
|
|
1168
|
-
node.attr('class', newClassList.join(' '));
|
|
1169
|
-
}
|
|
1170
|
-
};
|
|
1171
|
-
const removeClasses = (node, classes) => {
|
|
1172
|
-
const newClassList = filter(getClassList(node), (clazz) => !classes.has(clazz));
|
|
1173
|
-
node.attr('class', newClassList.length > 0 ? newClassList.join(' ') : null);
|
|
1174
|
-
};
|
|
1175
|
-
const isAccordionDetailsNode = (node) => node.name === accordionTag && contains(getClassList(node), accordionDetailsClass);
|
|
1176
|
-
const isAccordionBodyWrapperNode = (node) => node.name === accordionBodyWrapperTag && contains(getClassList(node), accordionBodyWrapperClass);
|
|
1177
|
-
const getAccordionChildren = (accordionNode) => {
|
|
1178
|
-
const children = accordionNode.children();
|
|
1179
|
-
let summaryNode;
|
|
1180
|
-
let wrapperNode;
|
|
1181
|
-
const otherNodes = [];
|
|
1182
|
-
for (let i = 0; i < children.length; i++) {
|
|
1183
|
-
const child = children[i];
|
|
1184
|
-
// Only want to get the first summary element
|
|
1185
|
-
if (child.name === 'summary' && isNullable(summaryNode)) {
|
|
1186
|
-
summaryNode = child;
|
|
1187
|
-
}
|
|
1188
|
-
else if (isAccordionBodyWrapperNode(child) && isNullable(wrapperNode)) {
|
|
1189
|
-
wrapperNode = child;
|
|
1190
|
-
}
|
|
1191
|
-
else {
|
|
1192
|
-
otherNodes.push(child);
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
return {
|
|
1196
|
-
summaryNode,
|
|
1197
|
-
wrapperNode,
|
|
1198
|
-
otherNodes
|
|
1199
|
-
};
|
|
1200
|
-
};
|
|
1201
|
-
const padInputNode = (node) => {
|
|
1202
|
-
// Add br to node to ensure the cursor can be placed inside the node
|
|
1203
|
-
// Mark as bogus so that it is converted to an nbsp on serialization
|
|
1204
|
-
const br = new global$2('br', 1);
|
|
1205
|
-
br.attr('data-mce-bogus', '1');
|
|
1206
|
-
node.empty();
|
|
1207
|
-
node.append(br);
|
|
1208
|
-
};
|
|
1209
|
-
const setup$2 = (editor) => {
|
|
1210
|
-
editor.on('PreInit', () => {
|
|
1211
|
-
const { serializer, parser } = editor;
|
|
1212
|
-
// Purpose:
|
|
1213
|
-
// - add mce-accordion-summary class to summary node
|
|
1214
|
-
// - wrap details body in div and add mce-accordion-body class (TINY-9959 assists with Chrome selection issue)
|
|
1215
|
-
// - Normalize accordion 'open' attribute value to open="open"
|
|
1216
|
-
parser.addNodeFilter(accordionTag, (nodes) => {
|
|
1217
|
-
// Using a traditional for loop here as we may have to iterate over many nodes and it is the most performant way of doing so
|
|
1218
|
-
for (let i = 0; i < nodes.length; i++) {
|
|
1219
|
-
const node = nodes[i];
|
|
1220
|
-
normalizeOpenAttribute(node);
|
|
1221
|
-
if (isAccordionDetailsNode(node)) {
|
|
1222
|
-
const accordionNode = node;
|
|
1223
|
-
accordionNode.attr(accordionReadonlyCompensationAttribute, accordionNode.attr('open') === 'open' ? 'open' : 'closed');
|
|
1224
|
-
const { summaryNode, wrapperNode, otherNodes } = getAccordionChildren(accordionNode);
|
|
1225
|
-
const hasSummaryNode = isNonNullable(summaryNode);
|
|
1226
|
-
const newSummaryNode = hasSummaryNode ? summaryNode : new global$2('summary', 1);
|
|
1227
|
-
// If there is nothing in the summary, pad it with a br
|
|
1228
|
-
// so the cursor can be put inside the accordion summary
|
|
1229
|
-
if (isNullable(newSummaryNode.firstChild)) {
|
|
1230
|
-
padInputNode(newSummaryNode);
|
|
1231
|
-
}
|
|
1232
|
-
addClasses(newSummaryNode, [accordionSummaryClass]);
|
|
1233
|
-
if (!hasSummaryNode) {
|
|
1234
|
-
if (isNonNullable(accordionNode.firstChild)) {
|
|
1235
|
-
accordionNode.insert(newSummaryNode, accordionNode.firstChild, true);
|
|
1236
|
-
}
|
|
1237
|
-
else {
|
|
1238
|
-
accordionNode.append(newSummaryNode);
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
const hasWrapperNode = isNonNullable(wrapperNode);
|
|
1242
|
-
const newWrapperNode = hasWrapperNode ? wrapperNode : new global$2(accordionBodyWrapperTag, 1);
|
|
1243
|
-
newWrapperNode.attr('data-mce-bogus', '1');
|
|
1244
|
-
addClasses(newWrapperNode, [accordionBodyWrapperClass]);
|
|
1245
|
-
if (otherNodes.length > 0) {
|
|
1246
|
-
for (let j = 0; j < otherNodes.length; j++) {
|
|
1247
|
-
const otherNode = otherNodes[j];
|
|
1248
|
-
newWrapperNode.append(otherNode);
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
// If there is nothing in the wrapper, append a placeholder p tag
|
|
1252
|
-
// so the cursor can be put inside the accordion body
|
|
1253
|
-
if (isNullable(newWrapperNode.firstChild)) {
|
|
1254
|
-
const pNode = new global$2('p', 1);
|
|
1255
|
-
padInputNode(pNode);
|
|
1256
|
-
newWrapperNode.append(pNode);
|
|
1257
|
-
}
|
|
1258
|
-
if (!hasWrapperNode) {
|
|
1259
|
-
accordionNode.append(newWrapperNode);
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
});
|
|
1264
|
-
// Purpose:
|
|
1265
|
-
// - remove div wrapping details content as it is only required during editor (see TINY-9959 for details)
|
|
1266
|
-
// - remove mce-accordion-summary class on the summary node
|
|
1267
|
-
serializer.addNodeFilter(accordionTag, (nodes) => {
|
|
1268
|
-
const summaryClassRemoveSet = new Set([accordionSummaryClass]);
|
|
1269
|
-
// Using a traditional for loop here as we may have to iterate over many nodes and it is the most performant way of doing so
|
|
1270
|
-
for (let i = 0; i < nodes.length; i++) {
|
|
1271
|
-
const node = nodes[i];
|
|
1272
|
-
if (isAccordionDetailsNode(node)) {
|
|
1273
|
-
const accordionNode = node;
|
|
1274
|
-
accordionNode.attr('open', accordionNode.attr(accordionReadonlyCompensationAttribute) === 'open' ? 'open' : null);
|
|
1275
|
-
accordionNode.attr(accordionReadonlyCompensationAttribute, null);
|
|
1276
|
-
const { summaryNode, wrapperNode } = getAccordionChildren(accordionNode);
|
|
1277
|
-
if (isNonNullable(summaryNode)) {
|
|
1278
|
-
removeClasses(summaryNode, summaryClassRemoveSet);
|
|
1279
|
-
}
|
|
1280
|
-
if (isNonNullable(wrapperNode)) {
|
|
1281
|
-
wrapperNode.unwrap();
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
});
|
|
1286
|
-
});
|
|
1287
|
-
};
|
|
1288
|
-
|
|
1289
|
-
var global$1 = tinymce.util.Tools.resolve('tinymce.util.VK');
|
|
1290
|
-
|
|
1291
|
-
const setupEnterKeyInSummary = (editor) => {
|
|
1292
|
-
editor.on('keydown', (event) => {
|
|
1293
|
-
if (!event.shiftKey && event.keyCode === global$1.ENTER
|
|
1294
|
-
&& isInSummary(editor) || isAtDetailsStart(editor)) {
|
|
1295
|
-
event.preventDefault();
|
|
1296
|
-
editor.execCommand('ToggleAccordion');
|
|
1297
|
-
}
|
|
1298
|
-
});
|
|
1299
|
-
};
|
|
1300
|
-
const setup$1 = (editor) => {
|
|
1301
|
-
setupEnterKeyInSummary(editor);
|
|
1302
|
-
editor.on('ExecCommand', (e) => {
|
|
1303
|
-
const cmd = e.command.toLowerCase();
|
|
1304
|
-
if ((cmd === 'delete' || cmd === 'forwarddelete') && isDetailsSelected(editor)) {
|
|
1305
|
-
normalizeDetails(editor);
|
|
1306
|
-
}
|
|
1307
|
-
});
|
|
1308
|
-
};
|
|
1309
|
-
|
|
1310
|
-
var global = tinymce.util.Tools.resolve('tinymce.Env');
|
|
1311
|
-
|
|
1312
|
-
const setup = (editor) => {
|
|
1313
|
-
// TINY-10177: On Safari, clicking on the expand arrow of the `details` element sets the selection before the `summary`,
|
|
1314
|
-
// so we override the selection to the beginning of `summary` content
|
|
1315
|
-
if (global.browser.isSafari()) {
|
|
1316
|
-
editor.on('click', (e) => {
|
|
1317
|
-
if (isSummary(e.target)) {
|
|
1318
|
-
const summary = e.target;
|
|
1319
|
-
const rng = editor.selection.getRng();
|
|
1320
|
-
if (rng.collapsed && rng.startContainer === summary.parentNode && rng.startOffset === 0) {
|
|
1321
|
-
editor.selection.setCursorLocation(summary, 0);
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
});
|
|
1325
|
-
}
|
|
1326
|
-
};
|
|
1327
|
-
|
|
1328
|
-
const onSetup = (editor) => (buttonApi) => {
|
|
1329
|
-
const onNodeChange = () => buttonApi.setEnabled(isInsertAllowed(editor));
|
|
1330
|
-
editor.on('NodeChange', onNodeChange);
|
|
1331
|
-
return () => editor.off('NodeChange', onNodeChange);
|
|
1332
|
-
};
|
|
1333
|
-
const register = (editor) => {
|
|
1334
|
-
const onAction = () => editor.execCommand('InsertAccordion');
|
|
1335
|
-
editor.ui.registry.addButton('accordion', { icon: 'accordion', tooltip: 'Insert accordion', onSetup: onSetup(editor), onAction });
|
|
1336
|
-
editor.ui.registry.addMenuItem('accordion', { icon: 'accordion', text: 'Accordion', onSetup: onSetup(editor), onAction });
|
|
1337
|
-
editor.ui.registry.addToggleButton('accordiontoggle', {
|
|
1338
|
-
icon: 'accordion-toggle',
|
|
1339
|
-
tooltip: 'Toggle accordion',
|
|
1340
|
-
onAction: () => editor.execCommand('ToggleAccordion'),
|
|
1341
|
-
context: 'any',
|
|
1342
|
-
});
|
|
1343
|
-
editor.ui.registry.addToggleButton('accordionremove', {
|
|
1344
|
-
icon: 'remove',
|
|
1345
|
-
tooltip: 'Delete accordion',
|
|
1346
|
-
onAction: () => editor.execCommand('RemoveAccordion')
|
|
1347
|
-
});
|
|
1348
|
-
editor.ui.registry.addContextToolbar('accordion', {
|
|
1349
|
-
predicate: (accordion) => editor.dom.is(accordion, 'details') && editor.getBody().contains(accordion) && editor.dom.isEditable(accordion.parentNode),
|
|
1350
|
-
items: 'accordiontoggle accordionremove',
|
|
1351
|
-
scope: 'node',
|
|
1352
|
-
position: 'node'
|
|
1353
|
-
});
|
|
1354
|
-
};
|
|
1355
|
-
|
|
1356
|
-
var Plugin = () => {
|
|
1357
|
-
global$4.add('accordion', (editor) => {
|
|
1358
|
-
register(editor);
|
|
1359
|
-
register$1(editor);
|
|
1360
|
-
setup$1(editor);
|
|
1361
|
-
setup$2(editor);
|
|
1362
|
-
setup(editor);
|
|
1363
|
-
});
|
|
1364
|
-
};
|
|
1365
|
-
|
|
1366
|
-
Plugin();
|
|
1367
|
-
/** *****
|
|
1368
|
-
* DO NOT EXPORT ANYTHING
|
|
1369
|
-
*
|
|
1370
|
-
* IF YOU DO ROLLUP WILL LEAVE A GLOBAL ON THE PAGE
|
|
1371
|
-
*******/
|
|
1372
|
-
|
|
1373
|
-
})();
|