create-nextjs-cms 0.5.56 → 0.5.60
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/(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 +1 -1
- package/templates/default/app/providers.tsx +4 -4
- 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/LogPage.tsx +2 -3
- package/templates/default/components/SettingsPage.tsx +1 -1
- package/templates/default/components/form/Form.tsx +5 -5
- package/templates/default/components/form/helpers/_section-hot-reload.js +1 -1
- 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/tsconfig.json +6 -3
- package/templates/default/app/api/placeholder/route.ts +0 -7
- 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,1709 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TinyMCE version 8.3.1 (2025-12-17)
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
(function () {
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
var global$5 = 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 = (type) => (value) => typeOf(value) === type;
|
|
36
|
-
const isSimpleType = (type) => (value) => typeof value === type;
|
|
37
|
-
const eq = (t) => (a) => t === a;
|
|
38
|
-
const isString = isType('string');
|
|
39
|
-
const isObject = isType('object');
|
|
40
|
-
const isArray = isType('array');
|
|
41
|
-
const isNull = eq(null);
|
|
42
|
-
const isBoolean = isSimpleType('boolean');
|
|
43
|
-
const isNullable = (a) => a === null || a === undefined;
|
|
44
|
-
const isNonNullable = (a) => !isNullable(a);
|
|
45
|
-
const isFunction = isSimpleType('function');
|
|
46
|
-
const isArrayOf = (value, pred) => {
|
|
47
|
-
if (isArray(value)) {
|
|
48
|
-
for (let i = 0, len = value.length; i < len; ++i) {
|
|
49
|
-
if (!(pred(value[i]))) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
return false;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const noop = () => { };
|
|
59
|
-
const constant = (value) => {
|
|
60
|
-
return () => {
|
|
61
|
-
return value;
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
const identity = (x) => {
|
|
65
|
-
return x;
|
|
66
|
-
};
|
|
67
|
-
const tripleEquals = (a, b) => {
|
|
68
|
-
return a === b;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* The `Optional` type represents a value (of any type) that potentially does
|
|
73
|
-
* not exist. Any `Optional<T>` can either be a `Some<T>` (in which case the
|
|
74
|
-
* value does exist) or a `None` (in which case the value does not exist). This
|
|
75
|
-
* module defines a whole lot of FP-inspired utility functions for dealing with
|
|
76
|
-
* `Optional` objects.
|
|
77
|
-
*
|
|
78
|
-
* Comparison with null or undefined:
|
|
79
|
-
* - We don't get fancy null coalescing operators with `Optional`
|
|
80
|
-
* - We do get fancy helper functions with `Optional`
|
|
81
|
-
* - `Optional` support nesting, and allow for the type to still be nullable (or
|
|
82
|
-
* another `Optional`)
|
|
83
|
-
* - There is no option to turn off strict-optional-checks like there is for
|
|
84
|
-
* strict-null-checks
|
|
85
|
-
*/
|
|
86
|
-
class Optional {
|
|
87
|
-
tag;
|
|
88
|
-
value;
|
|
89
|
-
// Sneaky optimisation: every instance of Optional.none is identical, so just
|
|
90
|
-
// reuse the same object
|
|
91
|
-
static singletonNone = new Optional(false);
|
|
92
|
-
// The internal representation has a `tag` and a `value`, but both are
|
|
93
|
-
// private: able to be console.logged, but not able to be accessed by code
|
|
94
|
-
constructor(tag, value) {
|
|
95
|
-
this.tag = tag;
|
|
96
|
-
this.value = value;
|
|
97
|
-
}
|
|
98
|
-
// --- Identities ---
|
|
99
|
-
/**
|
|
100
|
-
* Creates a new `Optional<T>` that **does** contain a value.
|
|
101
|
-
*/
|
|
102
|
-
static some(value) {
|
|
103
|
-
return new Optional(true, value);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Create a new `Optional<T>` that **does not** contain a value. `T` can be
|
|
107
|
-
* any type because we don't actually have a `T`.
|
|
108
|
-
*/
|
|
109
|
-
static none() {
|
|
110
|
-
return Optional.singletonNone;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Perform a transform on an `Optional` type. Regardless of whether this
|
|
114
|
-
* `Optional` contains a value or not, `fold` will return a value of type `U`.
|
|
115
|
-
* If this `Optional` does not contain a value, the `U` will be created by
|
|
116
|
-
* calling `onNone`. If this `Optional` does contain a value, the `U` will be
|
|
117
|
-
* created by calling `onSome`.
|
|
118
|
-
*
|
|
119
|
-
* For the FP enthusiasts in the room, this function:
|
|
120
|
-
* 1. Could be used to implement all of the functions below
|
|
121
|
-
* 2. Forms a catamorphism
|
|
122
|
-
*/
|
|
123
|
-
fold(onNone, onSome) {
|
|
124
|
-
if (this.tag) {
|
|
125
|
-
return onSome(this.value);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
return onNone();
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Determine if this `Optional` object contains a value.
|
|
133
|
-
*/
|
|
134
|
-
isSome() {
|
|
135
|
-
return this.tag;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Determine if this `Optional` object **does not** contain a value.
|
|
139
|
-
*/
|
|
140
|
-
isNone() {
|
|
141
|
-
return !this.tag;
|
|
142
|
-
}
|
|
143
|
-
// --- Functor (name stolen from Haskell / maths) ---
|
|
144
|
-
/**
|
|
145
|
-
* Perform a transform on an `Optional` object, **if** there is a value. If
|
|
146
|
-
* you provide a function to turn a T into a U, this is the function you use
|
|
147
|
-
* to turn an `Optional<T>` into an `Optional<U>`. If this **does** contain
|
|
148
|
-
* a value then the output will also contain a value (that value being the
|
|
149
|
-
* output of `mapper(this.value)`), and if this **does not** contain a value
|
|
150
|
-
* then neither will the output.
|
|
151
|
-
*/
|
|
152
|
-
map(mapper) {
|
|
153
|
-
if (this.tag) {
|
|
154
|
-
return Optional.some(mapper(this.value));
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
return Optional.none();
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
// --- Monad (name stolen from Haskell / maths) ---
|
|
161
|
-
/**
|
|
162
|
-
* Perform a transform on an `Optional` object, **if** there is a value.
|
|
163
|
-
* Unlike `map`, here the transform itself also returns an `Optional`.
|
|
164
|
-
*/
|
|
165
|
-
bind(binder) {
|
|
166
|
-
if (this.tag) {
|
|
167
|
-
return binder(this.value);
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
return Optional.none();
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
// --- Traversable (name stolen from Haskell / maths) ---
|
|
174
|
-
/**
|
|
175
|
-
* For a given predicate, this function finds out if there **exists** a value
|
|
176
|
-
* inside this `Optional` object that meets the predicate. In practice, this
|
|
177
|
-
* means that for `Optional`s that do not contain a value it returns false (as
|
|
178
|
-
* no predicate-meeting value exists).
|
|
179
|
-
*/
|
|
180
|
-
exists(predicate) {
|
|
181
|
-
return this.tag && predicate(this.value);
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* For a given predicate, this function finds out if **all** the values inside
|
|
185
|
-
* this `Optional` object meet the predicate. In practice, this means that
|
|
186
|
-
* for `Optional`s that do not contain a value it returns true (as all 0
|
|
187
|
-
* objects do meet the predicate).
|
|
188
|
-
*/
|
|
189
|
-
forall(predicate) {
|
|
190
|
-
return !this.tag || predicate(this.value);
|
|
191
|
-
}
|
|
192
|
-
filter(predicate) {
|
|
193
|
-
if (!this.tag || predicate(this.value)) {
|
|
194
|
-
return this;
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
return Optional.none();
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
// --- Getters ---
|
|
201
|
-
/**
|
|
202
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
203
|
-
* `replacement` value if the provided `Optional` object does not contain a
|
|
204
|
-
* value.
|
|
205
|
-
*/
|
|
206
|
-
getOr(replacement) {
|
|
207
|
-
return this.tag ? this.value : replacement;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
211
|
-
* `replacement` value if the provided `Optional` object does not contain a
|
|
212
|
-
* value. Unlike `getOr`, in this method the `replacement` object is also
|
|
213
|
-
* `Optional` - meaning that this method will always return an `Optional`.
|
|
214
|
-
*/
|
|
215
|
-
or(replacement) {
|
|
216
|
-
return this.tag ? this : replacement;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
220
|
-
* `replacement` value if the provided `Optional` object does not contain a
|
|
221
|
-
* value. Unlike `getOr`, in this method the `replacement` value is
|
|
222
|
-
* "thunked" - that is to say that you don't pass a value to `getOrThunk`, you
|
|
223
|
-
* pass a function which (if called) will **return** the `value` you want to
|
|
224
|
-
* use.
|
|
225
|
-
*/
|
|
226
|
-
getOrThunk(thunk) {
|
|
227
|
-
return this.tag ? this.value : thunk();
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
231
|
-
* `replacement` value if the provided Optional object does not contain a
|
|
232
|
-
* value.
|
|
233
|
-
*
|
|
234
|
-
* Unlike `or`, in this method the `replacement` value is "thunked" - that is
|
|
235
|
-
* to say that you don't pass a value to `orThunk`, you pass a function which
|
|
236
|
-
* (if called) will **return** the `value` you want to use.
|
|
237
|
-
*
|
|
238
|
-
* Unlike `getOrThunk`, in this method the `replacement` value is also
|
|
239
|
-
* `Optional`, meaning that this method will always return an `Optional`.
|
|
240
|
-
*/
|
|
241
|
-
orThunk(thunk) {
|
|
242
|
-
return this.tag ? this : thunk();
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Get the value out of the inside of the `Optional` object, throwing an
|
|
246
|
-
* exception if the provided `Optional` object does not contain a value.
|
|
247
|
-
*
|
|
248
|
-
* WARNING:
|
|
249
|
-
* You should only be using this function if you know that the `Optional`
|
|
250
|
-
* object **is not** empty (otherwise you're throwing exceptions in production
|
|
251
|
-
* code, which is bad).
|
|
252
|
-
*
|
|
253
|
-
* In tests this is more acceptable.
|
|
254
|
-
*
|
|
255
|
-
* Prefer other methods to this, such as `.each`.
|
|
256
|
-
*/
|
|
257
|
-
getOrDie(message) {
|
|
258
|
-
if (!this.tag) {
|
|
259
|
-
throw new Error(message ?? 'Called getOrDie on None');
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
262
|
-
return this.value;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
// --- Interop with null and undefined ---
|
|
266
|
-
/**
|
|
267
|
-
* Creates an `Optional` value from a nullable (or undefined-able) input.
|
|
268
|
-
* Null, or undefined, is converted to `None`, and anything else is converted
|
|
269
|
-
* to `Some`.
|
|
270
|
-
*/
|
|
271
|
-
static from(value) {
|
|
272
|
-
return isNonNullable(value) ? Optional.some(value) : Optional.none();
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Converts an `Optional` to a nullable type, by getting the value if it
|
|
276
|
-
* exists, or returning `null` if it does not.
|
|
277
|
-
*/
|
|
278
|
-
getOrNull() {
|
|
279
|
-
return this.tag ? this.value : null;
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Converts an `Optional` to an undefined-able type, by getting the value if
|
|
283
|
-
* it exists, or returning `undefined` if it does not.
|
|
284
|
-
*/
|
|
285
|
-
getOrUndefined() {
|
|
286
|
-
return this.value;
|
|
287
|
-
}
|
|
288
|
-
// --- Utilities ---
|
|
289
|
-
/**
|
|
290
|
-
* If the `Optional` contains a value, perform an action on that value.
|
|
291
|
-
* Unlike the rest of the methods on this type, `.each` has side-effects. If
|
|
292
|
-
* you want to transform an `Optional<T>` **into** something, then this is not
|
|
293
|
-
* the method for you. If you want to use an `Optional<T>` to **do**
|
|
294
|
-
* something, then this is the method for you - provided you're okay with not
|
|
295
|
-
* doing anything in the case where the `Optional` doesn't have a value inside
|
|
296
|
-
* it. If you're not sure whether your use-case fits into transforming
|
|
297
|
-
* **into** something or **doing** something, check whether it has a return
|
|
298
|
-
* value. If it does, you should be performing a transform.
|
|
299
|
-
*/
|
|
300
|
-
each(worker) {
|
|
301
|
-
if (this.tag) {
|
|
302
|
-
worker(this.value);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Turn the `Optional` object into an array that contains all of the values
|
|
307
|
-
* stored inside the `Optional`. In practice, this means the output will have
|
|
308
|
-
* either 0 or 1 elements.
|
|
309
|
-
*/
|
|
310
|
-
toArray() {
|
|
311
|
-
return this.tag ? [this.value] : [];
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Turn the `Optional` object into a string for debugging or printing. Not
|
|
315
|
-
* recommended for production code, but good for debugging. Also note that
|
|
316
|
-
* these days an `Optional` object can be logged to the console directly, and
|
|
317
|
-
* its inner value (if it exists) will be visible.
|
|
318
|
-
*/
|
|
319
|
-
toString() {
|
|
320
|
-
return this.tag ? `some(${this.value})` : 'none()';
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
const nativeSlice = Array.prototype.slice;
|
|
325
|
-
const nativeIndexOf = Array.prototype.indexOf;
|
|
326
|
-
const nativePush = Array.prototype.push;
|
|
327
|
-
const rawIndexOf = (ts, t) => nativeIndexOf.call(ts, t);
|
|
328
|
-
const contains = (xs, x) => rawIndexOf(xs, x) > -1;
|
|
329
|
-
const map = (xs, f) => {
|
|
330
|
-
// pre-allocating array size when it's guaranteed to be known
|
|
331
|
-
// http://jsperf.com/push-allocated-vs-dynamic/22
|
|
332
|
-
const len = xs.length;
|
|
333
|
-
const r = new Array(len);
|
|
334
|
-
for (let i = 0; i < len; i++) {
|
|
335
|
-
const x = xs[i];
|
|
336
|
-
r[i] = f(x, i);
|
|
337
|
-
}
|
|
338
|
-
return r;
|
|
339
|
-
};
|
|
340
|
-
// Unwound implementing other functions in terms of each.
|
|
341
|
-
// The code size is roughly the same, and it should allow for better optimisation.
|
|
342
|
-
// const each = function<T, U>(xs: T[], f: (x: T, i?: number, xs?: T[]) => void): void {
|
|
343
|
-
const each$1 = (xs, f) => {
|
|
344
|
-
for (let i = 0, len = xs.length; i < len; i++) {
|
|
345
|
-
const x = xs[i];
|
|
346
|
-
f(x, i);
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
const foldl = (xs, f, acc) => {
|
|
350
|
-
each$1(xs, (x, i) => {
|
|
351
|
-
acc = f(acc, x, i);
|
|
352
|
-
});
|
|
353
|
-
return acc;
|
|
354
|
-
};
|
|
355
|
-
const flatten = (xs) => {
|
|
356
|
-
// Note, this is possible because push supports multiple arguments:
|
|
357
|
-
// http://jsperf.com/concat-push/6
|
|
358
|
-
// Note that in the past, concat() would silently work (very slowly) for array-like objects.
|
|
359
|
-
// With this change it will throw an error.
|
|
360
|
-
const r = [];
|
|
361
|
-
for (let i = 0, len = xs.length; i < len; ++i) {
|
|
362
|
-
// Ensure that each value is an array itself
|
|
363
|
-
if (!isArray(xs[i])) {
|
|
364
|
-
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
|
|
365
|
-
}
|
|
366
|
-
nativePush.apply(r, xs[i]);
|
|
367
|
-
}
|
|
368
|
-
return r;
|
|
369
|
-
};
|
|
370
|
-
const bind = (xs, f) => flatten(map(xs, f));
|
|
371
|
-
const get = (xs, i) => i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
|
|
372
|
-
const head = (xs) => get(xs, 0);
|
|
373
|
-
isFunction(Array.from) ? Array.from : (x) => nativeSlice.call(x);
|
|
374
|
-
const findMap = (arr, f) => {
|
|
375
|
-
for (let i = 0; i < arr.length; i++) {
|
|
376
|
-
const r = f(arr[i], i);
|
|
377
|
-
if (r.isSome()) {
|
|
378
|
-
return r;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
return Optional.none();
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
// There are many variations of Object iteration that are faster than the 'for-in' style:
|
|
385
|
-
// http://jsperf.com/object-keys-iteration/107
|
|
386
|
-
//
|
|
387
|
-
// Use the native keys if it is available (IE9+), otherwise fall back to manually filtering
|
|
388
|
-
const keys = Object.keys;
|
|
389
|
-
const hasOwnProperty = Object.hasOwnProperty;
|
|
390
|
-
const each = (obj, f) => {
|
|
391
|
-
const props = keys(obj);
|
|
392
|
-
for (let k = 0, len = props.length; k < len; k++) {
|
|
393
|
-
const i = props[k];
|
|
394
|
-
const x = obj[i];
|
|
395
|
-
f(x, i);
|
|
396
|
-
}
|
|
397
|
-
};
|
|
398
|
-
const objAcc = (r) => (x, i) => {
|
|
399
|
-
r[i] = x;
|
|
400
|
-
};
|
|
401
|
-
const internalFilter = (obj, pred, onTrue, onFalse) => {
|
|
402
|
-
each(obj, (x, i) => {
|
|
403
|
-
(pred(x, i) ? onTrue : onFalse)(x, i);
|
|
404
|
-
});
|
|
405
|
-
};
|
|
406
|
-
const filter = (obj, pred) => {
|
|
407
|
-
const t = {};
|
|
408
|
-
internalFilter(obj, pred, objAcc(t), noop);
|
|
409
|
-
return t;
|
|
410
|
-
};
|
|
411
|
-
const has = (obj, key) => hasOwnProperty.call(obj, key);
|
|
412
|
-
const hasNonNullableKey = (obj, key) => has(obj, key) && obj[key] !== undefined && obj[key] !== null;
|
|
413
|
-
|
|
414
|
-
const Cell = (initial) => {
|
|
415
|
-
let value = initial;
|
|
416
|
-
const get = () => {
|
|
417
|
-
return value;
|
|
418
|
-
};
|
|
419
|
-
const set = (v) => {
|
|
420
|
-
value = v;
|
|
421
|
-
};
|
|
422
|
-
return {
|
|
423
|
-
get,
|
|
424
|
-
set
|
|
425
|
-
};
|
|
426
|
-
};
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* **Is** the value stored inside this Optional object equal to `rhs`?
|
|
430
|
-
*/
|
|
431
|
-
const is = (lhs, rhs, comparator = tripleEquals) => lhs.exists((left) => comparator(left, rhs));
|
|
432
|
-
const cat = (arr) => {
|
|
433
|
-
const r = [];
|
|
434
|
-
const push = (x) => {
|
|
435
|
-
r.push(x);
|
|
436
|
-
};
|
|
437
|
-
for (let i = 0; i < arr.length; i++) {
|
|
438
|
-
arr[i].each(push);
|
|
439
|
-
}
|
|
440
|
-
return r;
|
|
441
|
-
};
|
|
442
|
-
// This can help with type inference, by specifying the type param on the none case, so the caller doesn't have to.
|
|
443
|
-
const someIf = (b, a) => b ? Optional.some(a) : Optional.none();
|
|
444
|
-
|
|
445
|
-
const singleton = (doRevoke) => {
|
|
446
|
-
const subject = Cell(Optional.none());
|
|
447
|
-
const revoke = () => subject.get().each(doRevoke);
|
|
448
|
-
const clear = () => {
|
|
449
|
-
revoke();
|
|
450
|
-
subject.set(Optional.none());
|
|
451
|
-
};
|
|
452
|
-
const isSet = () => subject.get().isSome();
|
|
453
|
-
const get = () => subject.get();
|
|
454
|
-
const set = (s) => {
|
|
455
|
-
revoke();
|
|
456
|
-
subject.set(Optional.some(s));
|
|
457
|
-
};
|
|
458
|
-
return {
|
|
459
|
-
clear,
|
|
460
|
-
isSet,
|
|
461
|
-
get,
|
|
462
|
-
set
|
|
463
|
-
};
|
|
464
|
-
};
|
|
465
|
-
const value = () => {
|
|
466
|
-
const subject = singleton(noop);
|
|
467
|
-
const on = (f) => subject.get().each(f);
|
|
468
|
-
return {
|
|
469
|
-
...subject,
|
|
470
|
-
on
|
|
471
|
-
};
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
const removeFromStart = (str, numChars) => {
|
|
475
|
-
return str.substring(numChars);
|
|
476
|
-
};
|
|
477
|
-
|
|
478
|
-
const checkRange = (str, substr, start) => substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
|
|
479
|
-
const removeLeading = (str, prefix) => {
|
|
480
|
-
return startsWith(str, prefix) ? removeFromStart(str, prefix.length) : str;
|
|
481
|
-
};
|
|
482
|
-
/** Does 'str' start with 'prefix'?
|
|
483
|
-
* Note: all strings start with the empty string.
|
|
484
|
-
* More formally, for all strings x, startsWith(x, "").
|
|
485
|
-
* This is so that for all strings x and y, startsWith(y + x, y)
|
|
486
|
-
*/
|
|
487
|
-
const startsWith = (str, prefix) => {
|
|
488
|
-
return checkRange(str, prefix, 0);
|
|
489
|
-
};
|
|
490
|
-
|
|
491
|
-
const option = (name) => (editor) => editor.options.get(name);
|
|
492
|
-
const register$1 = (editor) => {
|
|
493
|
-
const registerOption = editor.options.register;
|
|
494
|
-
registerOption('link_assume_external_targets', {
|
|
495
|
-
processor: (value) => {
|
|
496
|
-
const valid = isString(value) || isBoolean(value);
|
|
497
|
-
if (valid) {
|
|
498
|
-
if (value === true) {
|
|
499
|
-
return { value: 1 /* AssumeExternalTargets.WARN */, valid };
|
|
500
|
-
}
|
|
501
|
-
else if (value === "http" /* AssumeExternalTargets.ALWAYS_HTTP */ || value === "https" /* AssumeExternalTargets.ALWAYS_HTTPS */) {
|
|
502
|
-
return { value, valid };
|
|
503
|
-
}
|
|
504
|
-
else {
|
|
505
|
-
return { value: 0 /* AssumeExternalTargets.OFF */, valid };
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
else {
|
|
509
|
-
return { valid: false, message: 'Must be a string or a boolean.' };
|
|
510
|
-
}
|
|
511
|
-
},
|
|
512
|
-
default: false
|
|
513
|
-
});
|
|
514
|
-
registerOption('link_context_toolbar', {
|
|
515
|
-
processor: 'boolean',
|
|
516
|
-
default: false
|
|
517
|
-
});
|
|
518
|
-
registerOption('link_list', {
|
|
519
|
-
processor: (value) => isString(value) || isFunction(value) || isArrayOf(value, isObject)
|
|
520
|
-
});
|
|
521
|
-
registerOption('link_default_target', {
|
|
522
|
-
processor: 'string'
|
|
523
|
-
});
|
|
524
|
-
registerOption('link_default_protocol', {
|
|
525
|
-
processor: 'string',
|
|
526
|
-
default: 'https'
|
|
527
|
-
});
|
|
528
|
-
registerOption('link_target_list', {
|
|
529
|
-
processor: (value) => isBoolean(value) || isArrayOf(value, isObject),
|
|
530
|
-
default: true
|
|
531
|
-
});
|
|
532
|
-
registerOption('link_rel_list', {
|
|
533
|
-
processor: 'object[]',
|
|
534
|
-
default: []
|
|
535
|
-
});
|
|
536
|
-
registerOption('link_class_list', {
|
|
537
|
-
processor: 'object[]',
|
|
538
|
-
default: []
|
|
539
|
-
});
|
|
540
|
-
registerOption('link_title', {
|
|
541
|
-
processor: 'boolean',
|
|
542
|
-
default: true
|
|
543
|
-
});
|
|
544
|
-
registerOption('allow_unsafe_link_target', {
|
|
545
|
-
processor: 'boolean',
|
|
546
|
-
default: false
|
|
547
|
-
});
|
|
548
|
-
registerOption('link_quicklink', {
|
|
549
|
-
processor: 'boolean',
|
|
550
|
-
default: false
|
|
551
|
-
});
|
|
552
|
-
registerOption('link_attributes_postprocess', {
|
|
553
|
-
processor: 'function',
|
|
554
|
-
});
|
|
555
|
-
registerOption('files_upload_handler', {
|
|
556
|
-
processor: 'function'
|
|
557
|
-
});
|
|
558
|
-
registerOption('link_uploadtab', {
|
|
559
|
-
processor: 'boolean',
|
|
560
|
-
default: true
|
|
561
|
-
});
|
|
562
|
-
};
|
|
563
|
-
const assumeExternalTargets = option('link_assume_external_targets');
|
|
564
|
-
const hasContextToolbar = option('link_context_toolbar');
|
|
565
|
-
const getLinkList = option('link_list');
|
|
566
|
-
const getDefaultLinkTarget = option('link_default_target');
|
|
567
|
-
const getDefaultLinkProtocol = option('link_default_protocol');
|
|
568
|
-
const getTargetList = option('link_target_list');
|
|
569
|
-
const getRelList = option('link_rel_list');
|
|
570
|
-
const getLinkClassList = option('link_class_list');
|
|
571
|
-
const shouldShowLinkTitle = option('link_title');
|
|
572
|
-
const allowUnsafeLinkTarget = option('allow_unsafe_link_target');
|
|
573
|
-
const useQuickLink = option('link_quicklink');
|
|
574
|
-
const attributesPostProcess = option('link_attributes_postprocess');
|
|
575
|
-
const getFilesUploadHandler = option('files_upload_handler');
|
|
576
|
-
const hasLinkUploadtab = option('link_uploadtab');
|
|
577
|
-
const getDocumentsFileTypes = option('documents_file_types');
|
|
578
|
-
const hasFilesUploadHandler = (editor) => isNonNullable(editor.options.get('files_upload_handler'));
|
|
579
|
-
const hasDocumentsFileTypes = (editor) => isNonNullable(editor.options.get('documents_file_types'));
|
|
580
|
-
|
|
581
|
-
var global$4 = tinymce.util.Tools.resolve('tinymce.util.URI');
|
|
582
|
-
|
|
583
|
-
var global$3 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker');
|
|
584
|
-
|
|
585
|
-
var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
586
|
-
|
|
587
|
-
const isAnchor = (elm) => isNonNullable(elm) && elm.nodeName.toLowerCase() === 'a';
|
|
588
|
-
const isLink = (elm) => isAnchor(elm) && !!getHref(elm);
|
|
589
|
-
const collectNodesInRange = (rng, predicate) => {
|
|
590
|
-
if (rng.collapsed) {
|
|
591
|
-
return [];
|
|
592
|
-
}
|
|
593
|
-
else {
|
|
594
|
-
const contents = rng.cloneContents();
|
|
595
|
-
const firstChild = contents.firstChild;
|
|
596
|
-
const walker = new global$3(firstChild, contents);
|
|
597
|
-
const elements = [];
|
|
598
|
-
let current = firstChild;
|
|
599
|
-
do {
|
|
600
|
-
if (predicate(current)) {
|
|
601
|
-
elements.push(current);
|
|
602
|
-
}
|
|
603
|
-
} while ((current = walker.next()));
|
|
604
|
-
return elements;
|
|
605
|
-
}
|
|
606
|
-
};
|
|
607
|
-
const hasProtocol = (url) => /^\w+:/i.test(url);
|
|
608
|
-
const getHref = (elm) => {
|
|
609
|
-
// Returns the real href value not the resolved a.href value
|
|
610
|
-
return elm.getAttribute('data-mce-href') ?? elm.getAttribute('href') ?? '';
|
|
611
|
-
};
|
|
612
|
-
const applyRelTargetRules = (rel, isUnsafe) => {
|
|
613
|
-
const rules = ['noopener'];
|
|
614
|
-
const rels = rel ? rel.split(/\s+/) : [];
|
|
615
|
-
const toString = (rels) => global$2.trim(rels.sort().join(' '));
|
|
616
|
-
const addTargetRules = (rels) => {
|
|
617
|
-
rels = removeTargetRules(rels);
|
|
618
|
-
return rels.length > 0 ? rels.concat(rules) : rules;
|
|
619
|
-
};
|
|
620
|
-
const removeTargetRules = (rels) => rels.filter((val) => global$2.inArray(rules, val) === -1);
|
|
621
|
-
const newRels = isUnsafe ? addTargetRules(rels) : removeTargetRules(rels);
|
|
622
|
-
return newRels.length > 0 ? toString(newRels) : '';
|
|
623
|
-
};
|
|
624
|
-
const trimCaretContainers = (text) => text.replace(/\uFEFF/g, '');
|
|
625
|
-
const getAnchorElement = (editor, selectedElm) => {
|
|
626
|
-
selectedElm = selectedElm || getLinksInSelection(editor.selection.getRng())[0] || editor.selection.getNode();
|
|
627
|
-
if (isImageFigure(selectedElm)) {
|
|
628
|
-
// for an image contained in a figure we look for a link inside the selected element
|
|
629
|
-
return Optional.from(editor.dom.select('a[href]', selectedElm)[0]);
|
|
630
|
-
}
|
|
631
|
-
else {
|
|
632
|
-
return Optional.from(editor.dom.getParent(selectedElm, 'a[href]'));
|
|
633
|
-
}
|
|
634
|
-
};
|
|
635
|
-
const isInAnchor = (editor, selectedElm) => getAnchorElement(editor, selectedElm).isSome();
|
|
636
|
-
const getAnchorText = (selection, anchorElm) => {
|
|
637
|
-
const text = anchorElm.fold(() => selection.getContent({ format: 'text' }), (anchorElm) => anchorElm.innerText || anchorElm.textContent || '');
|
|
638
|
-
return trimCaretContainers(text);
|
|
639
|
-
};
|
|
640
|
-
const getLinksInSelection = (rng) => collectNodesInRange(rng, isLink);
|
|
641
|
-
const getLinks$1 = (elements) => global$2.grep(elements, isLink);
|
|
642
|
-
const hasLinks = (elements) => getLinks$1(elements).length > 0;
|
|
643
|
-
const hasLinksInSelection = (rng) => getLinksInSelection(rng).length > 0;
|
|
644
|
-
const isOnlyTextSelected = (editor) => {
|
|
645
|
-
// Allow anchor and inline text elements to be in the selection but nothing else
|
|
646
|
-
const inlineTextElements = editor.schema.getTextInlineElements();
|
|
647
|
-
const isElement = (elm) => elm.nodeType === 1 && !isAnchor(elm) && !has(inlineTextElements, elm.nodeName.toLowerCase());
|
|
648
|
-
// If selection is inside a block anchor then always treat it as non text only
|
|
649
|
-
const isInBlockAnchor = getAnchorElement(editor).exists((anchor) => anchor.hasAttribute('data-mce-block'));
|
|
650
|
-
if (isInBlockAnchor) {
|
|
651
|
-
return false;
|
|
652
|
-
}
|
|
653
|
-
const rng = editor.selection.getRng();
|
|
654
|
-
if (!rng.collapsed) {
|
|
655
|
-
// Collect all non inline text elements in the range and make sure no elements were found
|
|
656
|
-
const elements = collectNodesInRange(rng, isElement);
|
|
657
|
-
return elements.length === 0;
|
|
658
|
-
}
|
|
659
|
-
else {
|
|
660
|
-
return true;
|
|
661
|
-
}
|
|
662
|
-
};
|
|
663
|
-
const isImageFigure = (elm) => isNonNullable(elm) && elm.nodeName === 'FIGURE' && /\bimage\b/i.test(elm.className);
|
|
664
|
-
const blobToDataUri = (blob) => new Promise((resolve, reject) => {
|
|
665
|
-
const reader = new FileReader();
|
|
666
|
-
reader.onload = () => {
|
|
667
|
-
resolve(reader.result);
|
|
668
|
-
};
|
|
669
|
-
reader.onerror = () => {
|
|
670
|
-
reject(new Error(reader.error?.message ?? 'Failed to convert blob to a data url'));
|
|
671
|
-
};
|
|
672
|
-
reader.readAsDataURL(blob);
|
|
673
|
-
});
|
|
674
|
-
|
|
675
|
-
const getLinkAttrs = (data) => {
|
|
676
|
-
const attrs = ['title', 'rel', 'class', 'target'];
|
|
677
|
-
return foldl(attrs, (acc, key) => {
|
|
678
|
-
data[key].each((value) => {
|
|
679
|
-
// If dealing with an empty string, then treat that as being null so the attribute is removed
|
|
680
|
-
acc[key] = value.length > 0 ? value : null;
|
|
681
|
-
});
|
|
682
|
-
return acc;
|
|
683
|
-
}, {
|
|
684
|
-
href: data.href
|
|
685
|
-
});
|
|
686
|
-
};
|
|
687
|
-
const handleExternalTargets = (href, assumeExternalTargets) => {
|
|
688
|
-
if ((assumeExternalTargets === "http" /* AssumeExternalTargets.ALWAYS_HTTP */
|
|
689
|
-
|| assumeExternalTargets === "https" /* AssumeExternalTargets.ALWAYS_HTTPS */)
|
|
690
|
-
&& !hasProtocol(href)) {
|
|
691
|
-
return assumeExternalTargets + '://' + href;
|
|
692
|
-
}
|
|
693
|
-
return href;
|
|
694
|
-
};
|
|
695
|
-
const applyLinkOverrides = (editor, linkAttrs) => {
|
|
696
|
-
const newLinkAttrs = { ...linkAttrs };
|
|
697
|
-
if (getRelList(editor).length === 0 && !allowUnsafeLinkTarget(editor)) {
|
|
698
|
-
const newRel = applyRelTargetRules(newLinkAttrs.rel, newLinkAttrs.target === '_blank');
|
|
699
|
-
newLinkAttrs.rel = newRel ? newRel : null;
|
|
700
|
-
}
|
|
701
|
-
if (Optional.from(newLinkAttrs.target).isNone() && getTargetList(editor) === false) {
|
|
702
|
-
newLinkAttrs.target = getDefaultLinkTarget(editor);
|
|
703
|
-
}
|
|
704
|
-
newLinkAttrs.href = handleExternalTargets(newLinkAttrs.href, assumeExternalTargets(editor));
|
|
705
|
-
return newLinkAttrs;
|
|
706
|
-
};
|
|
707
|
-
const updateLink = (editor, anchorElm, text, linkAttrs) => {
|
|
708
|
-
// If we have text, then update the anchor elements text content
|
|
709
|
-
text.each((text) => {
|
|
710
|
-
if (has(anchorElm, 'innerText')) {
|
|
711
|
-
anchorElm.innerText = text;
|
|
712
|
-
}
|
|
713
|
-
else {
|
|
714
|
-
anchorElm.textContent = text;
|
|
715
|
-
}
|
|
716
|
-
});
|
|
717
|
-
editor.dom.setAttribs(anchorElm, linkAttrs);
|
|
718
|
-
// Move the cursor behind the updated link, so the user can go on typing.
|
|
719
|
-
const rng = editor.dom.createRng();
|
|
720
|
-
rng.setStartAfter(anchorElm);
|
|
721
|
-
rng.setEndAfter(anchorElm);
|
|
722
|
-
editor.selection.setRng(rng);
|
|
723
|
-
};
|
|
724
|
-
const createLink = (editor, selectedElm, text, linkAttrs) => {
|
|
725
|
-
const dom = editor.dom;
|
|
726
|
-
if (isImageFigure(selectedElm)) {
|
|
727
|
-
linkImageFigure(dom, selectedElm, linkAttrs);
|
|
728
|
-
}
|
|
729
|
-
else {
|
|
730
|
-
text.fold(() => {
|
|
731
|
-
editor.execCommand('mceInsertLink', false, linkAttrs);
|
|
732
|
-
// Now the newly inserted link is selected. Move the cursor behind the new link, so the user can go on typing.
|
|
733
|
-
const end = editor.selection.getEnd();
|
|
734
|
-
const rng = dom.createRng();
|
|
735
|
-
rng.setStartAfter(end);
|
|
736
|
-
rng.setEndAfter(end);
|
|
737
|
-
editor.selection.setRng(rng);
|
|
738
|
-
}, (text) => {
|
|
739
|
-
editor.insertContent(dom.createHTML('a', linkAttrs, dom.encode(text)));
|
|
740
|
-
});
|
|
741
|
-
}
|
|
742
|
-
};
|
|
743
|
-
const linkDomMutation = (editor, attachState, data) => {
|
|
744
|
-
const selectedElm = editor.selection.getNode();
|
|
745
|
-
const anchorElm = getAnchorElement(editor, selectedElm);
|
|
746
|
-
const linkAttrs = applyLinkOverrides(editor, getLinkAttrs(data));
|
|
747
|
-
const attributesPostProcess$1 = attributesPostProcess(editor);
|
|
748
|
-
if (isNonNullable(attributesPostProcess$1)) {
|
|
749
|
-
attributesPostProcess$1(linkAttrs);
|
|
750
|
-
}
|
|
751
|
-
editor.undoManager.transact(() => {
|
|
752
|
-
if (data.href === attachState.href) {
|
|
753
|
-
attachState.attach();
|
|
754
|
-
}
|
|
755
|
-
anchorElm.fold(() => {
|
|
756
|
-
createLink(editor, selectedElm, data.text, linkAttrs);
|
|
757
|
-
}, (elm) => {
|
|
758
|
-
editor.focus();
|
|
759
|
-
updateLink(editor, elm, data.text, linkAttrs);
|
|
760
|
-
});
|
|
761
|
-
});
|
|
762
|
-
};
|
|
763
|
-
const unlinkSelection = (editor) => {
|
|
764
|
-
const dom = editor.dom, selection = editor.selection;
|
|
765
|
-
const bookmark = selection.getBookmark();
|
|
766
|
-
const rng = selection.getRng().cloneRange();
|
|
767
|
-
// Extend the selection out to the entire anchor element
|
|
768
|
-
const startAnchorElm = dom.getParent(rng.startContainer, 'a[href]', editor.getBody());
|
|
769
|
-
const endAnchorElm = dom.getParent(rng.endContainer, 'a[href]', editor.getBody());
|
|
770
|
-
if (startAnchorElm) {
|
|
771
|
-
rng.setStartBefore(startAnchorElm);
|
|
772
|
-
}
|
|
773
|
-
if (endAnchorElm) {
|
|
774
|
-
rng.setEndAfter(endAnchorElm);
|
|
775
|
-
}
|
|
776
|
-
selection.setRng(rng);
|
|
777
|
-
// Remove the link
|
|
778
|
-
editor.execCommand('unlink');
|
|
779
|
-
selection.moveToBookmark(bookmark);
|
|
780
|
-
};
|
|
781
|
-
const unlinkDomMutation = (editor) => {
|
|
782
|
-
editor.undoManager.transact(() => {
|
|
783
|
-
const node = editor.selection.getNode();
|
|
784
|
-
if (isImageFigure(node)) {
|
|
785
|
-
unlinkImageFigure(editor, node);
|
|
786
|
-
}
|
|
787
|
-
else {
|
|
788
|
-
unlinkSelection(editor);
|
|
789
|
-
}
|
|
790
|
-
editor.focus();
|
|
791
|
-
});
|
|
792
|
-
};
|
|
793
|
-
/*
|
|
794
|
-
* RTC uses unwrapped options.
|
|
795
|
-
*
|
|
796
|
-
* To best simulate this, we unwrap to null and filter out empty values.
|
|
797
|
-
*/
|
|
798
|
-
const unwrapOptions = (data) => {
|
|
799
|
-
const { class: cls, href, rel, target, text, title } = data;
|
|
800
|
-
return filter({
|
|
801
|
-
class: cls.getOrNull(),
|
|
802
|
-
href,
|
|
803
|
-
rel: rel.getOrNull(),
|
|
804
|
-
target: target.getOrNull(),
|
|
805
|
-
text: text.getOrNull(),
|
|
806
|
-
title: title.getOrNull()
|
|
807
|
-
}, (v, _k) => isNull(v) === false);
|
|
808
|
-
};
|
|
809
|
-
const sanitizeData = (editor, data) => {
|
|
810
|
-
const getOption = editor.options.get;
|
|
811
|
-
const uriOptions = {
|
|
812
|
-
allow_html_data_urls: getOption('allow_html_data_urls'),
|
|
813
|
-
allow_script_urls: getOption('allow_script_urls'),
|
|
814
|
-
allow_svg_data_urls: getOption('allow_svg_data_urls')
|
|
815
|
-
};
|
|
816
|
-
// Sanitize the URL
|
|
817
|
-
const href = data.href;
|
|
818
|
-
return {
|
|
819
|
-
...data,
|
|
820
|
-
href: global$4.isDomSafe(href, 'a', uriOptions) ? href : ''
|
|
821
|
-
};
|
|
822
|
-
};
|
|
823
|
-
const link = (editor, attachState, data) => {
|
|
824
|
-
const sanitizedData = sanitizeData(editor, data);
|
|
825
|
-
editor.hasPlugin('rtc', true) ? editor.execCommand('createlink', false, unwrapOptions(sanitizedData)) : linkDomMutation(editor, attachState, sanitizedData);
|
|
826
|
-
};
|
|
827
|
-
const unlink = (editor) => {
|
|
828
|
-
editor.hasPlugin('rtc', true) ? editor.execCommand('unlink') : unlinkDomMutation(editor);
|
|
829
|
-
};
|
|
830
|
-
const unlinkImageFigure = (editor, fig) => {
|
|
831
|
-
const img = editor.dom.select('img', fig)[0];
|
|
832
|
-
if (img) {
|
|
833
|
-
const a = editor.dom.getParents(img, 'a[href]', fig)[0];
|
|
834
|
-
if (a) {
|
|
835
|
-
a.parentNode?.insertBefore(img, a);
|
|
836
|
-
editor.dom.remove(a);
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
};
|
|
840
|
-
const linkImageFigure = (dom, fig, attrs) => {
|
|
841
|
-
const img = dom.select('img', fig)[0];
|
|
842
|
-
if (img) {
|
|
843
|
-
const a = dom.create('a', attrs);
|
|
844
|
-
img.parentNode?.insertBefore(a, img);
|
|
845
|
-
a.appendChild(img);
|
|
846
|
-
}
|
|
847
|
-
};
|
|
848
|
-
|
|
849
|
-
const getValue = (item) => isString(item.value) ? item.value : '';
|
|
850
|
-
const getText = (item) => {
|
|
851
|
-
if (isString(item.text)) {
|
|
852
|
-
return item.text;
|
|
853
|
-
}
|
|
854
|
-
else if (isString(item.title)) {
|
|
855
|
-
return item.title;
|
|
856
|
-
}
|
|
857
|
-
else {
|
|
858
|
-
return '';
|
|
859
|
-
}
|
|
860
|
-
};
|
|
861
|
-
const sanitizeList = (list, extractValue) => {
|
|
862
|
-
const out = [];
|
|
863
|
-
global$2.each(list, (item) => {
|
|
864
|
-
const text = getText(item);
|
|
865
|
-
if (item.menu !== undefined) {
|
|
866
|
-
const items = sanitizeList(item.menu, extractValue);
|
|
867
|
-
out.push({ text, items }); // list group
|
|
868
|
-
}
|
|
869
|
-
else {
|
|
870
|
-
const value = extractValue(item);
|
|
871
|
-
out.push({ text, value }); // list value
|
|
872
|
-
}
|
|
873
|
-
});
|
|
874
|
-
return out;
|
|
875
|
-
};
|
|
876
|
-
const sanitizeWith = (extracter = getValue) => (list) => Optional.from(list).map((list) => sanitizeList(list, extracter));
|
|
877
|
-
const sanitize = (list) => sanitizeWith(getValue)(list);
|
|
878
|
-
// NOTE: May need to care about flattening.
|
|
879
|
-
const createUi = (name, label) => (items) => ({
|
|
880
|
-
name,
|
|
881
|
-
type: 'listbox',
|
|
882
|
-
label,
|
|
883
|
-
items
|
|
884
|
-
});
|
|
885
|
-
const ListOptions = {
|
|
886
|
-
sanitize,
|
|
887
|
-
sanitizeWith,
|
|
888
|
-
createUi,
|
|
889
|
-
getValue
|
|
890
|
-
};
|
|
891
|
-
|
|
892
|
-
const isListGroup = (item) => hasNonNullableKey(item, 'items');
|
|
893
|
-
const findTextByValue = (value, catalog) => findMap(catalog, (item) => {
|
|
894
|
-
if (isListGroup(item)) {
|
|
895
|
-
return findTextByValue(value, item.items);
|
|
896
|
-
}
|
|
897
|
-
else {
|
|
898
|
-
return someIf(item.value === value, item);
|
|
899
|
-
}
|
|
900
|
-
});
|
|
901
|
-
const getDelta = (persistentText, fieldName, catalog, data) => {
|
|
902
|
-
const value = data[fieldName];
|
|
903
|
-
const hasPersistentText = persistentText.length > 0;
|
|
904
|
-
return value !== undefined ? findTextByValue(value, catalog).map((i) => ({
|
|
905
|
-
url: {
|
|
906
|
-
value: i.value,
|
|
907
|
-
meta: {
|
|
908
|
-
text: hasPersistentText ? persistentText : i.text,
|
|
909
|
-
attach: noop
|
|
910
|
-
}
|
|
911
|
-
},
|
|
912
|
-
text: hasPersistentText ? persistentText : i.text
|
|
913
|
-
})) : Optional.none();
|
|
914
|
-
};
|
|
915
|
-
const findCatalog = (catalogs, fieldName) => {
|
|
916
|
-
if (fieldName === 'link') {
|
|
917
|
-
return catalogs.link;
|
|
918
|
-
}
|
|
919
|
-
else if (fieldName === 'anchor') {
|
|
920
|
-
return catalogs.anchor;
|
|
921
|
-
}
|
|
922
|
-
else {
|
|
923
|
-
return Optional.none();
|
|
924
|
-
}
|
|
925
|
-
};
|
|
926
|
-
const init = (initialData, linkCatalog) => {
|
|
927
|
-
const persistentData = {
|
|
928
|
-
text: initialData.text,
|
|
929
|
-
title: initialData.title
|
|
930
|
-
};
|
|
931
|
-
const getTitleFromUrlChange = (url) => someIf(persistentData.title.length <= 0, Optional.from(url.meta?.title).getOr(''));
|
|
932
|
-
const getTextFromUrlChange = (url) => someIf(persistentData.text.length <= 0, Optional.from(url.meta?.text).getOr(url.value));
|
|
933
|
-
const onUrlChange = (data) => {
|
|
934
|
-
const text = getTextFromUrlChange(data.url);
|
|
935
|
-
const title = getTitleFromUrlChange(data.url);
|
|
936
|
-
// We are going to change the text/title because it has not been manually entered by the user.
|
|
937
|
-
if (text.isSome() || title.isSome()) {
|
|
938
|
-
return Optional.some({
|
|
939
|
-
...text.map((text) => ({ text })).getOr({}),
|
|
940
|
-
...title.map((title) => ({ title })).getOr({})
|
|
941
|
-
});
|
|
942
|
-
}
|
|
943
|
-
else {
|
|
944
|
-
return Optional.none();
|
|
945
|
-
}
|
|
946
|
-
};
|
|
947
|
-
const onCatalogChange = (data, change) => {
|
|
948
|
-
const catalog = findCatalog(linkCatalog, change).getOr([]);
|
|
949
|
-
return getDelta(persistentData.text, change, catalog, data);
|
|
950
|
-
};
|
|
951
|
-
const onChange = (getData, change) => {
|
|
952
|
-
const name = change.name;
|
|
953
|
-
if (name === 'url') {
|
|
954
|
-
return onUrlChange(getData());
|
|
955
|
-
}
|
|
956
|
-
else if (contains(['anchor', 'link'], name)) {
|
|
957
|
-
return onCatalogChange(getData(), name);
|
|
958
|
-
}
|
|
959
|
-
else if (name === 'text' || name === 'title') {
|
|
960
|
-
// Update the persistent text/title state, as a user has input custom text
|
|
961
|
-
persistentData[name] = getData()[name];
|
|
962
|
-
return Optional.none();
|
|
963
|
-
}
|
|
964
|
-
else {
|
|
965
|
-
return Optional.none();
|
|
966
|
-
}
|
|
967
|
-
};
|
|
968
|
-
return {
|
|
969
|
-
onChange
|
|
970
|
-
};
|
|
971
|
-
};
|
|
972
|
-
const DialogChanges = {
|
|
973
|
-
init,
|
|
974
|
-
getDelta
|
|
975
|
-
};
|
|
976
|
-
|
|
977
|
-
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
|
978
|
-
|
|
979
|
-
// Delay confirm since onSubmit will move focus
|
|
980
|
-
const delayedConfirm = (editor, message, callback) => {
|
|
981
|
-
const rng = editor.selection.getRng();
|
|
982
|
-
global$1.setEditorTimeout(editor, () => {
|
|
983
|
-
editor.windowManager.confirm(message, (state) => {
|
|
984
|
-
editor.selection.setRng(rng);
|
|
985
|
-
callback(state);
|
|
986
|
-
});
|
|
987
|
-
});
|
|
988
|
-
};
|
|
989
|
-
const tryEmailTransform = (data) => {
|
|
990
|
-
const url = data.href;
|
|
991
|
-
const suggestMailTo = url.indexOf('@') > 0 && url.indexOf('/') === -1 && url.indexOf('mailto:') === -1;
|
|
992
|
-
return suggestMailTo ? Optional.some({
|
|
993
|
-
message: 'The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?',
|
|
994
|
-
preprocess: (oldData) => ({ ...oldData, href: 'mailto:' + url })
|
|
995
|
-
}) : Optional.none();
|
|
996
|
-
};
|
|
997
|
-
const tryProtocolTransform = (assumeExternalTargets, defaultLinkProtocol) => (data) => {
|
|
998
|
-
const url = data.href;
|
|
999
|
-
const suggestProtocol = (assumeExternalTargets === 1 /* AssumeExternalTargets.WARN */ && !hasProtocol(url) ||
|
|
1000
|
-
assumeExternalTargets === 0 /* AssumeExternalTargets.OFF */ && /^\s*www(\.|\d\.)/i.test(url));
|
|
1001
|
-
return suggestProtocol ? Optional.some({
|
|
1002
|
-
message: `The URL you entered seems to be an external link. Do you want to add the required ${defaultLinkProtocol}:// prefix?`,
|
|
1003
|
-
preprocess: (oldData) => ({ ...oldData, href: defaultLinkProtocol + '://' + url })
|
|
1004
|
-
}) : Optional.none();
|
|
1005
|
-
};
|
|
1006
|
-
const preprocess = (editor, data) => findMap([tryEmailTransform, tryProtocolTransform(assumeExternalTargets(editor), getDefaultLinkProtocol(editor))], (f) => f(data)).fold(() => Promise.resolve(data), (transform) => new Promise((callback) => {
|
|
1007
|
-
delayedConfirm(editor, transform.message, (state) => {
|
|
1008
|
-
callback(state ? transform.preprocess(data) : data);
|
|
1009
|
-
});
|
|
1010
|
-
}));
|
|
1011
|
-
const DialogConfirms = {
|
|
1012
|
-
preprocess
|
|
1013
|
-
};
|
|
1014
|
-
|
|
1015
|
-
// NOTE: you currently need anchors in the content for this field to appear
|
|
1016
|
-
const getAnchors = (editor) => {
|
|
1017
|
-
const anchorNodes = editor.dom.select('a:not([href])');
|
|
1018
|
-
const anchors = bind(anchorNodes, (anchor) => {
|
|
1019
|
-
const id = anchor.name || anchor.id;
|
|
1020
|
-
return id ? [{ text: id, value: '#' + id }] : [];
|
|
1021
|
-
});
|
|
1022
|
-
return anchors.length > 0 ? Optional.some([{ text: 'None', value: '' }].concat(anchors)) : Optional.none();
|
|
1023
|
-
};
|
|
1024
|
-
const AnchorListOptions = {
|
|
1025
|
-
getAnchors
|
|
1026
|
-
};
|
|
1027
|
-
|
|
1028
|
-
// Looks like tinymce currently renders menus, but doesn't
|
|
1029
|
-
// let you choose from one.
|
|
1030
|
-
const getClasses = (editor) => {
|
|
1031
|
-
const list = getLinkClassList(editor);
|
|
1032
|
-
if (list.length > 0) {
|
|
1033
|
-
return ListOptions.sanitize(list);
|
|
1034
|
-
}
|
|
1035
|
-
return Optional.none();
|
|
1036
|
-
};
|
|
1037
|
-
const ClassListOptions = {
|
|
1038
|
-
getClasses
|
|
1039
|
-
};
|
|
1040
|
-
|
|
1041
|
-
const parseJson = (text) => {
|
|
1042
|
-
// Do some proper modelling.
|
|
1043
|
-
try {
|
|
1044
|
-
return Optional.some(JSON.parse(text));
|
|
1045
|
-
}
|
|
1046
|
-
catch {
|
|
1047
|
-
return Optional.none();
|
|
1048
|
-
}
|
|
1049
|
-
};
|
|
1050
|
-
const getLinks = (editor) => {
|
|
1051
|
-
const extractor = (item) => editor.convertURL(item.value || item.url || '', 'href');
|
|
1052
|
-
const linkList = getLinkList(editor);
|
|
1053
|
-
return new Promise((resolve) => {
|
|
1054
|
-
// TODO - better handling of failure
|
|
1055
|
-
if (isString(linkList)) {
|
|
1056
|
-
fetch(linkList)
|
|
1057
|
-
.then((res) => res.ok ? res.text().then(parseJson) : Promise.reject())
|
|
1058
|
-
.then(resolve, () => resolve(Optional.none()));
|
|
1059
|
-
}
|
|
1060
|
-
else if (isFunction(linkList)) {
|
|
1061
|
-
linkList((output) => resolve(Optional.some(output)));
|
|
1062
|
-
}
|
|
1063
|
-
else {
|
|
1064
|
-
resolve(Optional.from(linkList));
|
|
1065
|
-
}
|
|
1066
|
-
}).then((optItems) => optItems.bind(ListOptions.sanitizeWith(extractor)).map((items) => {
|
|
1067
|
-
if (items.length > 0) {
|
|
1068
|
-
const noneItem = [{ text: 'None', value: '' }];
|
|
1069
|
-
return noneItem.concat(items);
|
|
1070
|
-
}
|
|
1071
|
-
else {
|
|
1072
|
-
return items;
|
|
1073
|
-
}
|
|
1074
|
-
}));
|
|
1075
|
-
};
|
|
1076
|
-
const LinkListOptions = {
|
|
1077
|
-
getLinks
|
|
1078
|
-
};
|
|
1079
|
-
|
|
1080
|
-
const getRels = (editor, initialTarget) => {
|
|
1081
|
-
const list = getRelList(editor);
|
|
1082
|
-
if (list.length > 0) {
|
|
1083
|
-
const isTargetBlank = is(initialTarget, '_blank');
|
|
1084
|
-
const enforceSafe = allowUnsafeLinkTarget(editor) === false;
|
|
1085
|
-
const safeRelExtractor = (item) => applyRelTargetRules(ListOptions.getValue(item), isTargetBlank);
|
|
1086
|
-
const sanitizer = enforceSafe ? ListOptions.sanitizeWith(safeRelExtractor) : ListOptions.sanitize;
|
|
1087
|
-
return sanitizer(list);
|
|
1088
|
-
}
|
|
1089
|
-
return Optional.none();
|
|
1090
|
-
};
|
|
1091
|
-
const RelOptions = {
|
|
1092
|
-
getRels
|
|
1093
|
-
};
|
|
1094
|
-
|
|
1095
|
-
// In current tinymce, targets can be nested menus.
|
|
1096
|
-
// Do we really want to support that?
|
|
1097
|
-
const fallbacks = [
|
|
1098
|
-
{ text: 'Current window', value: '' },
|
|
1099
|
-
{ text: 'New window', value: '_blank' }
|
|
1100
|
-
];
|
|
1101
|
-
const getTargets = (editor) => {
|
|
1102
|
-
const list = getTargetList(editor);
|
|
1103
|
-
if (isArray(list)) {
|
|
1104
|
-
return ListOptions.sanitize(list).orThunk(() => Optional.some(fallbacks));
|
|
1105
|
-
}
|
|
1106
|
-
else if (list === false) {
|
|
1107
|
-
return Optional.none();
|
|
1108
|
-
}
|
|
1109
|
-
return Optional.some(fallbacks);
|
|
1110
|
-
};
|
|
1111
|
-
const TargetOptions = {
|
|
1112
|
-
getTargets
|
|
1113
|
-
};
|
|
1114
|
-
|
|
1115
|
-
const nonEmptyAttr = (dom, elem, name) => {
|
|
1116
|
-
const val = dom.getAttrib(elem, name);
|
|
1117
|
-
return val !== null && val.length > 0 ? Optional.some(val) : Optional.none();
|
|
1118
|
-
};
|
|
1119
|
-
const extractFromAnchor = (editor, anchor) => {
|
|
1120
|
-
const dom = editor.dom;
|
|
1121
|
-
const onlyText = isOnlyTextSelected(editor);
|
|
1122
|
-
const text = onlyText ? Optional.some(getAnchorText(editor.selection, anchor)) : Optional.none();
|
|
1123
|
-
const url = anchor.bind((anchorElm) => Optional.from(dom.getAttrib(anchorElm, 'href')));
|
|
1124
|
-
const target = anchor.bind((anchorElm) => Optional.from(dom.getAttrib(anchorElm, 'target')));
|
|
1125
|
-
const rel = anchor.bind((anchorElm) => nonEmptyAttr(dom, anchorElm, 'rel'));
|
|
1126
|
-
const linkClass = anchor.bind((anchorElm) => nonEmptyAttr(dom, anchorElm, 'class'));
|
|
1127
|
-
const title = anchor.bind((anchorElm) => nonEmptyAttr(dom, anchorElm, 'title'));
|
|
1128
|
-
return {
|
|
1129
|
-
url,
|
|
1130
|
-
text,
|
|
1131
|
-
title,
|
|
1132
|
-
target,
|
|
1133
|
-
rel,
|
|
1134
|
-
linkClass
|
|
1135
|
-
};
|
|
1136
|
-
};
|
|
1137
|
-
const collect = (editor, linkNode) => LinkListOptions.getLinks(editor).then((links) => {
|
|
1138
|
-
const hasUploadPanel = hasFilesUploadHandler(editor) && hasDocumentsFileTypes(editor) && hasLinkUploadtab(editor);
|
|
1139
|
-
const anchor = extractFromAnchor(editor, linkNode);
|
|
1140
|
-
return {
|
|
1141
|
-
anchor,
|
|
1142
|
-
catalogs: {
|
|
1143
|
-
targets: TargetOptions.getTargets(editor),
|
|
1144
|
-
// This should be initial target. Is anchor.target that?
|
|
1145
|
-
rels: RelOptions.getRels(editor, anchor.target),
|
|
1146
|
-
classes: ClassListOptions.getClasses(editor),
|
|
1147
|
-
anchor: AnchorListOptions.getAnchors(editor),
|
|
1148
|
-
link: links
|
|
1149
|
-
},
|
|
1150
|
-
hasUploadPanel,
|
|
1151
|
-
optNode: linkNode,
|
|
1152
|
-
flags: {
|
|
1153
|
-
titleEnabled: shouldShowLinkTitle(editor)
|
|
1154
|
-
}
|
|
1155
|
-
};
|
|
1156
|
-
});
|
|
1157
|
-
const DialogInfo = {
|
|
1158
|
-
collect
|
|
1159
|
-
};
|
|
1160
|
-
|
|
1161
|
-
const makeTab = (fileTypes) => {
|
|
1162
|
-
const items = [
|
|
1163
|
-
{
|
|
1164
|
-
type: 'dropzone',
|
|
1165
|
-
name: 'fileinput',
|
|
1166
|
-
buttonLabel: 'Browse for a file',
|
|
1167
|
-
dropAreaLabel: 'Drop a file here',
|
|
1168
|
-
allowedFileTypes: fileTypes.map((e) => e.mimeType).join(','),
|
|
1169
|
-
allowedFileExtensions: flatten(fileTypes.map((e) => e.extensions)),
|
|
1170
|
-
}
|
|
1171
|
-
];
|
|
1172
|
-
return {
|
|
1173
|
-
title: 'Upload',
|
|
1174
|
-
name: 'upload',
|
|
1175
|
-
items
|
|
1176
|
-
};
|
|
1177
|
-
};
|
|
1178
|
-
const UploadTab = {
|
|
1179
|
-
makeTab
|
|
1180
|
-
};
|
|
1181
|
-
|
|
1182
|
-
const handleSubmit = (editor, info) => (api) => {
|
|
1183
|
-
const data = api.getData();
|
|
1184
|
-
if (!data.url.value) {
|
|
1185
|
-
unlink(editor);
|
|
1186
|
-
// Temporary fix. TODO: TINY-2811
|
|
1187
|
-
api.close();
|
|
1188
|
-
return;
|
|
1189
|
-
}
|
|
1190
|
-
// Check if a key is defined, meaning it was a field in the dialog. If it is,
|
|
1191
|
-
// then check if it's changed and return none if nothing has changed.
|
|
1192
|
-
const getChangedValue = (key) => Optional.from(data[key]).filter((value) => !is(info.anchor[key], value));
|
|
1193
|
-
const changedData = {
|
|
1194
|
-
href: data.url.value,
|
|
1195
|
-
text: getChangedValue('text'),
|
|
1196
|
-
target: getChangedValue('target'),
|
|
1197
|
-
rel: getChangedValue('rel'),
|
|
1198
|
-
class: getChangedValue('linkClass'),
|
|
1199
|
-
title: getChangedValue('title')
|
|
1200
|
-
};
|
|
1201
|
-
const attachState = {
|
|
1202
|
-
href: data.url.value,
|
|
1203
|
-
attach: data.url.meta !== undefined && data.url.meta.attach ? data.url.meta.attach : noop
|
|
1204
|
-
};
|
|
1205
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
1206
|
-
DialogConfirms.preprocess(editor, changedData).then((pData) => {
|
|
1207
|
-
link(editor, attachState, pData);
|
|
1208
|
-
});
|
|
1209
|
-
api.close();
|
|
1210
|
-
};
|
|
1211
|
-
const uploadFile = (editor) => (blobInfo, progress) => {
|
|
1212
|
-
const fileUploadHandler = getFilesUploadHandler(editor);
|
|
1213
|
-
return fileUploadHandler(blobInfo, progress);
|
|
1214
|
-
};
|
|
1215
|
-
const dataUrlToBase64 = (dataUrl) => Optional.from(dataUrl.split(',')[1]).getOr('');
|
|
1216
|
-
const changeFileInput = (helpers, api) => {
|
|
1217
|
-
const data = api.getData();
|
|
1218
|
-
api.block('Uploading file');
|
|
1219
|
-
head(data.fileinput)
|
|
1220
|
-
.fold(() => {
|
|
1221
|
-
api.unblock();
|
|
1222
|
-
}, (file) => {
|
|
1223
|
-
const blobUri = URL.createObjectURL(file);
|
|
1224
|
-
const updateUrlAndSwitchTab = ({ url, fileName }) => {
|
|
1225
|
-
api.setData({ text: fileName, title: fileName, url: { value: url, meta: {} } });
|
|
1226
|
-
api.showTab('general');
|
|
1227
|
-
api.focus('url');
|
|
1228
|
-
};
|
|
1229
|
-
const finalize = () => {
|
|
1230
|
-
api.unblock();
|
|
1231
|
-
URL.revokeObjectURL(blobUri);
|
|
1232
|
-
};
|
|
1233
|
-
blobToDataUri(file).then((dataUrl) => {
|
|
1234
|
-
const existingBlobInfo = helpers.getExistingBlobInfo(dataUrlToBase64(dataUrl), file.type);
|
|
1235
|
-
const blobInfo = existingBlobInfo && existingBlobInfo.filename() === file.name ? existingBlobInfo : helpers.createBlobCache(file, blobUri, dataUrl);
|
|
1236
|
-
helpers.addToBlobCache(blobInfo);
|
|
1237
|
-
return helpers.uploadFile(blobInfo, identity);
|
|
1238
|
-
}).then((result) => {
|
|
1239
|
-
updateUrlAndSwitchTab(result);
|
|
1240
|
-
finalize();
|
|
1241
|
-
}).catch((err) => {
|
|
1242
|
-
finalize();
|
|
1243
|
-
helpers.alertErr(err, () => {
|
|
1244
|
-
api.focus('fileinput');
|
|
1245
|
-
});
|
|
1246
|
-
});
|
|
1247
|
-
});
|
|
1248
|
-
};
|
|
1249
|
-
const createBlobCache = (editor) => (file, blobUri, dataUrl) => editor.editorUpload.blobCache.create({
|
|
1250
|
-
blob: file,
|
|
1251
|
-
blobUri,
|
|
1252
|
-
name: file.name?.replace(/\.[^\.]+$/, ''),
|
|
1253
|
-
filename: file.name,
|
|
1254
|
-
base64: dataUrl.split(',')[1]
|
|
1255
|
-
});
|
|
1256
|
-
const addToBlobCache = (editor) => (blobInfo) => {
|
|
1257
|
-
editor.editorUpload.blobCache.add(blobInfo);
|
|
1258
|
-
};
|
|
1259
|
-
const getExistingBlobInfo = (editor) => (base64, type) => {
|
|
1260
|
-
return editor.editorUpload.blobCache.getByData(base64, type);
|
|
1261
|
-
};
|
|
1262
|
-
const alertErr = (editor) => (message, callback) => {
|
|
1263
|
-
editor.windowManager.alert(message, callback);
|
|
1264
|
-
};
|
|
1265
|
-
const collectData = (editor) => {
|
|
1266
|
-
const anchorNode = getAnchorElement(editor);
|
|
1267
|
-
return DialogInfo.collect(editor, anchorNode);
|
|
1268
|
-
};
|
|
1269
|
-
const getInitialData = (info, defaultTarget) => {
|
|
1270
|
-
const anchor = info.anchor;
|
|
1271
|
-
const url = anchor.url.getOr('');
|
|
1272
|
-
return {
|
|
1273
|
-
url: {
|
|
1274
|
-
value: url,
|
|
1275
|
-
meta: {
|
|
1276
|
-
original: {
|
|
1277
|
-
value: url
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
},
|
|
1281
|
-
text: anchor.text.getOr(''),
|
|
1282
|
-
title: anchor.title.getOr(''),
|
|
1283
|
-
anchor: url,
|
|
1284
|
-
link: url,
|
|
1285
|
-
rel: anchor.rel.getOr(''),
|
|
1286
|
-
target: anchor.target.or(defaultTarget).getOr(''),
|
|
1287
|
-
linkClass: anchor.linkClass.getOr(''),
|
|
1288
|
-
fileinput: []
|
|
1289
|
-
};
|
|
1290
|
-
};
|
|
1291
|
-
const makeDialogBody = (urlInput, displayText, titleText, catalogs, hasUploadPanel, fileTypes) => {
|
|
1292
|
-
const generalPanelItems = flatten([
|
|
1293
|
-
urlInput,
|
|
1294
|
-
displayText,
|
|
1295
|
-
titleText,
|
|
1296
|
-
cat([
|
|
1297
|
-
catalogs.anchor.map(ListOptions.createUi('anchor', 'Anchors')),
|
|
1298
|
-
catalogs.rels.map(ListOptions.createUi('rel', 'Rel')),
|
|
1299
|
-
catalogs.targets.map(ListOptions.createUi('target', 'Open link in...')),
|
|
1300
|
-
catalogs.link.map(ListOptions.createUi('link', 'Link list')),
|
|
1301
|
-
catalogs.classes.map(ListOptions.createUi('linkClass', 'Class'))
|
|
1302
|
-
])
|
|
1303
|
-
]);
|
|
1304
|
-
if (hasUploadPanel) {
|
|
1305
|
-
const tabPanel = {
|
|
1306
|
-
type: 'tabpanel',
|
|
1307
|
-
tabs: flatten([
|
|
1308
|
-
[{
|
|
1309
|
-
title: 'General',
|
|
1310
|
-
name: 'general',
|
|
1311
|
-
items: generalPanelItems
|
|
1312
|
-
}],
|
|
1313
|
-
[UploadTab.makeTab(fileTypes)]
|
|
1314
|
-
])
|
|
1315
|
-
};
|
|
1316
|
-
return tabPanel;
|
|
1317
|
-
}
|
|
1318
|
-
else {
|
|
1319
|
-
return {
|
|
1320
|
-
type: 'panel',
|
|
1321
|
-
items: generalPanelItems
|
|
1322
|
-
};
|
|
1323
|
-
}
|
|
1324
|
-
};
|
|
1325
|
-
const makeDialog = (settings, onSubmit, editor) => {
|
|
1326
|
-
const urlInput = [
|
|
1327
|
-
{
|
|
1328
|
-
name: 'url',
|
|
1329
|
-
type: 'urlinput',
|
|
1330
|
-
filetype: 'file',
|
|
1331
|
-
label: 'URL',
|
|
1332
|
-
picker_text: 'Browse links'
|
|
1333
|
-
}
|
|
1334
|
-
];
|
|
1335
|
-
const displayText = settings.anchor.text.map(() => ({
|
|
1336
|
-
name: 'text',
|
|
1337
|
-
type: 'input',
|
|
1338
|
-
label: 'Text to display'
|
|
1339
|
-
})).toArray();
|
|
1340
|
-
const titleText = settings.flags.titleEnabled ? [
|
|
1341
|
-
{
|
|
1342
|
-
name: 'title',
|
|
1343
|
-
type: 'input',
|
|
1344
|
-
label: 'Title'
|
|
1345
|
-
}
|
|
1346
|
-
] : [];
|
|
1347
|
-
const defaultTarget = Optional.from(getDefaultLinkTarget(editor));
|
|
1348
|
-
const initialData = getInitialData(settings, defaultTarget);
|
|
1349
|
-
const catalogs = settings.catalogs;
|
|
1350
|
-
const dialogDelta = DialogChanges.init(initialData, catalogs);
|
|
1351
|
-
const body = makeDialogBody(urlInput, displayText, titleText, catalogs, settings.hasUploadPanel, getDocumentsFileTypes(editor));
|
|
1352
|
-
const helpers = {
|
|
1353
|
-
addToBlobCache: addToBlobCache(editor),
|
|
1354
|
-
createBlobCache: createBlobCache(editor),
|
|
1355
|
-
alertErr: alertErr(editor),
|
|
1356
|
-
uploadFile: uploadFile(editor),
|
|
1357
|
-
getExistingBlobInfo: getExistingBlobInfo(editor)
|
|
1358
|
-
};
|
|
1359
|
-
return {
|
|
1360
|
-
title: 'Insert/Edit Link',
|
|
1361
|
-
size: 'normal',
|
|
1362
|
-
body,
|
|
1363
|
-
buttons: [
|
|
1364
|
-
{
|
|
1365
|
-
type: 'cancel',
|
|
1366
|
-
name: 'cancel',
|
|
1367
|
-
text: 'Cancel'
|
|
1368
|
-
},
|
|
1369
|
-
{
|
|
1370
|
-
type: 'submit',
|
|
1371
|
-
name: 'save',
|
|
1372
|
-
text: 'Save',
|
|
1373
|
-
primary: true
|
|
1374
|
-
}
|
|
1375
|
-
],
|
|
1376
|
-
initialData,
|
|
1377
|
-
onChange: (api, { name }) => {
|
|
1378
|
-
if (name === 'fileinput') {
|
|
1379
|
-
changeFileInput(helpers, api);
|
|
1380
|
-
}
|
|
1381
|
-
else {
|
|
1382
|
-
dialogDelta.onChange(api.getData, { name }).each((newData) => {
|
|
1383
|
-
api.setData(newData);
|
|
1384
|
-
});
|
|
1385
|
-
}
|
|
1386
|
-
},
|
|
1387
|
-
onSubmit
|
|
1388
|
-
};
|
|
1389
|
-
};
|
|
1390
|
-
const open = (editor) => {
|
|
1391
|
-
const data = collectData(editor);
|
|
1392
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
1393
|
-
data.then((info) => {
|
|
1394
|
-
const onSubmit = handleSubmit(editor, info);
|
|
1395
|
-
return makeDialog(info, onSubmit, editor);
|
|
1396
|
-
}).then((spec) => {
|
|
1397
|
-
editor.windowManager.open(spec);
|
|
1398
|
-
});
|
|
1399
|
-
};
|
|
1400
|
-
|
|
1401
|
-
const register = (editor) => {
|
|
1402
|
-
editor.addCommand('mceLink', (_ui, value) => {
|
|
1403
|
-
if (value?.dialog === true || !useQuickLink(editor)) {
|
|
1404
|
-
open(editor);
|
|
1405
|
-
}
|
|
1406
|
-
else {
|
|
1407
|
-
editor.dispatch('contexttoolbar-show', {
|
|
1408
|
-
toolbarKey: 'quicklink'
|
|
1409
|
-
});
|
|
1410
|
-
}
|
|
1411
|
-
});
|
|
1412
|
-
};
|
|
1413
|
-
|
|
1414
|
-
const setup$2 = (editor) => {
|
|
1415
|
-
editor.addShortcut('Meta+K', '', () => {
|
|
1416
|
-
editor.execCommand('mceLink');
|
|
1417
|
-
});
|
|
1418
|
-
};
|
|
1419
|
-
|
|
1420
|
-
var global = tinymce.util.Tools.resolve('tinymce.util.VK');
|
|
1421
|
-
|
|
1422
|
-
const appendClickRemove = (link, evt) => {
|
|
1423
|
-
document.body.appendChild(link);
|
|
1424
|
-
link.dispatchEvent(evt);
|
|
1425
|
-
document.body.removeChild(link);
|
|
1426
|
-
};
|
|
1427
|
-
const openLink = (url) => {
|
|
1428
|
-
const link = document.createElement('a');
|
|
1429
|
-
link.target = '_blank';
|
|
1430
|
-
link.href = url;
|
|
1431
|
-
link.rel = 'noreferrer noopener';
|
|
1432
|
-
const evt = new MouseEvent('click', {
|
|
1433
|
-
bubbles: true,
|
|
1434
|
-
cancelable: true,
|
|
1435
|
-
view: window
|
|
1436
|
-
});
|
|
1437
|
-
document.dispatchEvent(evt);
|
|
1438
|
-
appendClickRemove(link, evt);
|
|
1439
|
-
};
|
|
1440
|
-
const hasOnlyAltModifier = (e) => {
|
|
1441
|
-
return e.altKey === true && e.shiftKey === false && e.ctrlKey === false && e.metaKey === false;
|
|
1442
|
-
};
|
|
1443
|
-
const gotoLink = (editor, a) => {
|
|
1444
|
-
if (a) {
|
|
1445
|
-
const href = getHref(a);
|
|
1446
|
-
if (/^#/.test(href)) {
|
|
1447
|
-
const targetEl = editor.dom.select(`${href},[name="${removeLeading(href, '#')}"]`);
|
|
1448
|
-
if (targetEl.length) {
|
|
1449
|
-
editor.selection.scrollIntoView(targetEl[0], true);
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
else {
|
|
1453
|
-
openLink(a.href);
|
|
1454
|
-
}
|
|
1455
|
-
}
|
|
1456
|
-
};
|
|
1457
|
-
const isSelectionOnImageWithEmbeddedLink = (editor) => {
|
|
1458
|
-
const rng = editor.selection.getRng();
|
|
1459
|
-
const node = rng.startContainer;
|
|
1460
|
-
// Handle a case where an image embedded with a link is selected
|
|
1461
|
-
return isLink(node) && rng.startContainer === rng.endContainer && editor.dom.select('img', node).length === 1;
|
|
1462
|
-
};
|
|
1463
|
-
const getLinkFromElement = (editor, element) => {
|
|
1464
|
-
const links = getLinks$1(editor.dom.getParents(element));
|
|
1465
|
-
return someIf(links.length === 1, links[0]);
|
|
1466
|
-
};
|
|
1467
|
-
const getLinkInSelection = (editor) => {
|
|
1468
|
-
const links = getLinksInSelection(editor.selection.getRng());
|
|
1469
|
-
return someIf(links.length > 0, links[0]).or(getLinkFromElement(editor, editor.selection.getNode()));
|
|
1470
|
-
};
|
|
1471
|
-
const getLinkFromSelection = (editor) => editor.selection.isCollapsed() || isSelectionOnImageWithEmbeddedLink(editor)
|
|
1472
|
-
? getLinkFromElement(editor, editor.selection.getStart())
|
|
1473
|
-
: getLinkInSelection(editor);
|
|
1474
|
-
const setup$1 = (editor) => {
|
|
1475
|
-
const selectedLink = value();
|
|
1476
|
-
const getSelectedLink = () => selectedLink.get().or(getLinkFromSelection(editor));
|
|
1477
|
-
const gotoSelectedLink = () => getSelectedLink().each((link) => gotoLink(editor, link));
|
|
1478
|
-
editor.on('contextmenu', (e) => {
|
|
1479
|
-
getLinkFromElement(editor, e.target).each(selectedLink.set);
|
|
1480
|
-
});
|
|
1481
|
-
editor.on('SelectionChange', () => {
|
|
1482
|
-
if (!selectedLink.isSet()) {
|
|
1483
|
-
getLinkFromSelection(editor).each(selectedLink.set);
|
|
1484
|
-
}
|
|
1485
|
-
});
|
|
1486
|
-
editor.on('click', (e) => {
|
|
1487
|
-
selectedLink.clear();
|
|
1488
|
-
const links = getLinks$1(editor.dom.getParents(e.target));
|
|
1489
|
-
if (links.length === 1 && global.metaKeyPressed(e)) {
|
|
1490
|
-
e.preventDefault();
|
|
1491
|
-
gotoLink(editor, links[0]);
|
|
1492
|
-
}
|
|
1493
|
-
});
|
|
1494
|
-
editor.on('keydown', (e) => {
|
|
1495
|
-
selectedLink.clear();
|
|
1496
|
-
if (!e.isDefaultPrevented() && e.keyCode === 13 && hasOnlyAltModifier(e)) {
|
|
1497
|
-
getSelectedLink().each((link) => {
|
|
1498
|
-
e.preventDefault();
|
|
1499
|
-
gotoLink(editor, link);
|
|
1500
|
-
});
|
|
1501
|
-
}
|
|
1502
|
-
});
|
|
1503
|
-
return {
|
|
1504
|
-
gotoSelectedLink
|
|
1505
|
-
};
|
|
1506
|
-
};
|
|
1507
|
-
|
|
1508
|
-
const openDialog = (editor) => () => {
|
|
1509
|
-
editor.execCommand('mceLink', false, { dialog: true });
|
|
1510
|
-
};
|
|
1511
|
-
const toggleState = (editor, toggler) => {
|
|
1512
|
-
editor.on('NodeChange', toggler);
|
|
1513
|
-
return () => editor.off('NodeChange', toggler);
|
|
1514
|
-
};
|
|
1515
|
-
const toggleLinkState = (editor) => (api) => {
|
|
1516
|
-
const updateState = () => {
|
|
1517
|
-
api.setActive(!editor.mode.isReadOnly() && isInAnchor(editor, editor.selection.getNode()));
|
|
1518
|
-
api.setEnabled(editor.selection.isEditable());
|
|
1519
|
-
};
|
|
1520
|
-
updateState();
|
|
1521
|
-
return toggleState(editor, updateState);
|
|
1522
|
-
};
|
|
1523
|
-
const toggleLinkMenuState = (editor) => (api) => {
|
|
1524
|
-
const updateState = () => {
|
|
1525
|
-
api.setEnabled(editor.selection.isEditable());
|
|
1526
|
-
};
|
|
1527
|
-
updateState();
|
|
1528
|
-
return toggleState(editor, updateState);
|
|
1529
|
-
};
|
|
1530
|
-
const toggleRequiresLinkState = (editor) => (api) => {
|
|
1531
|
-
const hasLinks$1 = (parents) => hasLinks(parents) || hasLinksInSelection(editor.selection.getRng());
|
|
1532
|
-
const parents = editor.dom.getParents(editor.selection.getStart());
|
|
1533
|
-
const updateEnabled = (parents) => {
|
|
1534
|
-
api.setEnabled(hasLinks$1(parents) && editor.selection.isEditable());
|
|
1535
|
-
};
|
|
1536
|
-
updateEnabled(parents);
|
|
1537
|
-
return toggleState(editor, (e) => updateEnabled(e.parents));
|
|
1538
|
-
};
|
|
1539
|
-
const setupButtons = (editor, openLink) => {
|
|
1540
|
-
editor.ui.registry.addToggleButton('link', {
|
|
1541
|
-
icon: 'link',
|
|
1542
|
-
tooltip: 'Insert/edit link',
|
|
1543
|
-
shortcut: 'Meta+K',
|
|
1544
|
-
onAction: openDialog(editor),
|
|
1545
|
-
onSetup: toggleLinkState(editor)
|
|
1546
|
-
});
|
|
1547
|
-
editor.ui.registry.addButton('openlink', {
|
|
1548
|
-
icon: 'new-tab',
|
|
1549
|
-
tooltip: 'Open link',
|
|
1550
|
-
onAction: openLink.gotoSelectedLink,
|
|
1551
|
-
onSetup: toggleRequiresLinkState(editor)
|
|
1552
|
-
});
|
|
1553
|
-
editor.ui.registry.addButton('unlink', {
|
|
1554
|
-
icon: 'unlink',
|
|
1555
|
-
tooltip: 'Remove link',
|
|
1556
|
-
onAction: () => unlink(editor),
|
|
1557
|
-
onSetup: toggleRequiresLinkState(editor)
|
|
1558
|
-
});
|
|
1559
|
-
};
|
|
1560
|
-
const setupMenuItems = (editor, openLink) => {
|
|
1561
|
-
editor.ui.registry.addMenuItem('openlink', {
|
|
1562
|
-
text: 'Open link',
|
|
1563
|
-
icon: 'new-tab',
|
|
1564
|
-
onAction: openLink.gotoSelectedLink,
|
|
1565
|
-
onSetup: toggleRequiresLinkState(editor)
|
|
1566
|
-
});
|
|
1567
|
-
editor.ui.registry.addMenuItem('link', {
|
|
1568
|
-
icon: 'link',
|
|
1569
|
-
text: 'Link...',
|
|
1570
|
-
shortcut: 'Meta+K',
|
|
1571
|
-
onAction: openDialog(editor),
|
|
1572
|
-
onSetup: toggleLinkMenuState(editor)
|
|
1573
|
-
});
|
|
1574
|
-
editor.ui.registry.addMenuItem('unlink', {
|
|
1575
|
-
icon: 'unlink',
|
|
1576
|
-
text: 'Remove link',
|
|
1577
|
-
onAction: () => unlink(editor),
|
|
1578
|
-
onSetup: toggleRequiresLinkState(editor)
|
|
1579
|
-
});
|
|
1580
|
-
};
|
|
1581
|
-
const setupContextMenu = (editor) => {
|
|
1582
|
-
const inLink = 'link unlink openlink';
|
|
1583
|
-
const noLink = 'link';
|
|
1584
|
-
editor.ui.registry.addContextMenu('link', {
|
|
1585
|
-
update: (element) => {
|
|
1586
|
-
const isEditable = editor.dom.isEditable(element);
|
|
1587
|
-
if (!isEditable) {
|
|
1588
|
-
return '';
|
|
1589
|
-
}
|
|
1590
|
-
return hasLinks(editor.dom.getParents(element, 'a')) ? inLink : noLink;
|
|
1591
|
-
}
|
|
1592
|
-
});
|
|
1593
|
-
};
|
|
1594
|
-
const setupContextToolbars = (editor, openLink) => {
|
|
1595
|
-
const collapseSelectionToEnd = (editor) => {
|
|
1596
|
-
editor.selection.collapse(false);
|
|
1597
|
-
};
|
|
1598
|
-
const onSetupLink = (buttonApi) => {
|
|
1599
|
-
const node = editor.selection.getNode();
|
|
1600
|
-
buttonApi.setEnabled(isInAnchor(editor, node) && editor.selection.isEditable());
|
|
1601
|
-
return noop;
|
|
1602
|
-
};
|
|
1603
|
-
/**
|
|
1604
|
-
* if we're editing a link, don't change the text.
|
|
1605
|
-
* if anything other than text is selected, don't change the text.
|
|
1606
|
-
* TINY-9593: If there is a text selection return `Optional.none`
|
|
1607
|
-
* because `mceInsertLink` command will handle the selection.
|
|
1608
|
-
*/
|
|
1609
|
-
const getLinkText = (value) => {
|
|
1610
|
-
const anchor = getAnchorElement(editor);
|
|
1611
|
-
const onlyText = isOnlyTextSelected(editor);
|
|
1612
|
-
if (anchor.isNone() && onlyText) {
|
|
1613
|
-
const text = getAnchorText(editor.selection, anchor);
|
|
1614
|
-
return someIf(text.length === 0, value);
|
|
1615
|
-
}
|
|
1616
|
-
else {
|
|
1617
|
-
return Optional.none();
|
|
1618
|
-
}
|
|
1619
|
-
};
|
|
1620
|
-
editor.ui.registry.addContextForm('quicklink', {
|
|
1621
|
-
launch: {
|
|
1622
|
-
type: 'contextformtogglebutton',
|
|
1623
|
-
icon: 'link',
|
|
1624
|
-
tooltip: 'Link',
|
|
1625
|
-
onSetup: toggleLinkState(editor)
|
|
1626
|
-
},
|
|
1627
|
-
label: 'Link',
|
|
1628
|
-
predicate: (node) => hasContextToolbar(editor) && isInAnchor(editor, node),
|
|
1629
|
-
initValue: () => {
|
|
1630
|
-
const elm = getAnchorElement(editor);
|
|
1631
|
-
return elm.fold(constant(''), getHref);
|
|
1632
|
-
},
|
|
1633
|
-
commands: [
|
|
1634
|
-
{
|
|
1635
|
-
type: 'contextformtogglebutton',
|
|
1636
|
-
icon: 'link',
|
|
1637
|
-
tooltip: 'Link',
|
|
1638
|
-
primary: true,
|
|
1639
|
-
onSetup: (buttonApi) => {
|
|
1640
|
-
const node = editor.selection.getNode();
|
|
1641
|
-
// TODO: Make a test for this later.
|
|
1642
|
-
buttonApi.setActive(isInAnchor(editor, node));
|
|
1643
|
-
return toggleLinkState(editor)(buttonApi);
|
|
1644
|
-
},
|
|
1645
|
-
onAction: (formApi) => {
|
|
1646
|
-
const value = formApi.getValue();
|
|
1647
|
-
const text = getLinkText(value);
|
|
1648
|
-
const attachState = { href: value, attach: noop };
|
|
1649
|
-
link(editor, attachState, {
|
|
1650
|
-
href: value,
|
|
1651
|
-
text,
|
|
1652
|
-
title: Optional.none(),
|
|
1653
|
-
rel: Optional.none(),
|
|
1654
|
-
target: Optional.from(getDefaultLinkTarget(editor)),
|
|
1655
|
-
class: Optional.none()
|
|
1656
|
-
});
|
|
1657
|
-
collapseSelectionToEnd(editor);
|
|
1658
|
-
formApi.hide();
|
|
1659
|
-
}
|
|
1660
|
-
},
|
|
1661
|
-
{
|
|
1662
|
-
type: 'contextformbutton',
|
|
1663
|
-
icon: 'unlink',
|
|
1664
|
-
tooltip: 'Remove link',
|
|
1665
|
-
onSetup: onSetupLink,
|
|
1666
|
-
// TODO: The original inlite action was quite complex. Are we missing something with this?
|
|
1667
|
-
onAction: (formApi) => {
|
|
1668
|
-
unlink(editor);
|
|
1669
|
-
formApi.hide();
|
|
1670
|
-
}
|
|
1671
|
-
},
|
|
1672
|
-
{
|
|
1673
|
-
type: 'contextformbutton',
|
|
1674
|
-
icon: 'new-tab',
|
|
1675
|
-
tooltip: 'Open link',
|
|
1676
|
-
onSetup: onSetupLink,
|
|
1677
|
-
onAction: (formApi) => {
|
|
1678
|
-
openLink.gotoSelectedLink();
|
|
1679
|
-
formApi.hide();
|
|
1680
|
-
}
|
|
1681
|
-
}
|
|
1682
|
-
]
|
|
1683
|
-
});
|
|
1684
|
-
};
|
|
1685
|
-
const setup = (editor) => {
|
|
1686
|
-
const openLink = setup$1(editor);
|
|
1687
|
-
setupButtons(editor, openLink);
|
|
1688
|
-
setupMenuItems(editor, openLink);
|
|
1689
|
-
setupContextMenu(editor);
|
|
1690
|
-
setupContextToolbars(editor, openLink);
|
|
1691
|
-
};
|
|
1692
|
-
|
|
1693
|
-
var Plugin = () => {
|
|
1694
|
-
global$5.add('link', (editor) => {
|
|
1695
|
-
register$1(editor);
|
|
1696
|
-
register(editor);
|
|
1697
|
-
setup(editor);
|
|
1698
|
-
setup$2(editor);
|
|
1699
|
-
});
|
|
1700
|
-
};
|
|
1701
|
-
|
|
1702
|
-
Plugin();
|
|
1703
|
-
/** *****
|
|
1704
|
-
* DO NOT EXPORT ANYTHING
|
|
1705
|
-
*
|
|
1706
|
-
* IF YOU DO ROLLUP WILL LEAVE A GLOBAL ON THE PAGE
|
|
1707
|
-
*******/
|
|
1708
|
-
|
|
1709
|
-
})();
|