@akinon/ui-editor 1.0.0
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/dist/cjs/__tests__/index.test.d.ts +2 -0
- package/dist/cjs/__tests__/index.test.d.ts.map +1 -0
- package/dist/cjs/__tests__/index.test.js +38 -0
- package/dist/cjs/__tests__/index.test.tsx +51 -0
- package/dist/cjs/i18n/index.d.ts +3 -0
- package/dist/cjs/i18n/index.d.ts.map +1 -0
- package/dist/cjs/i18n/index.js +11 -0
- package/dist/cjs/i18n/translations/en.d.ts +86 -0
- package/dist/cjs/i18n/translations/en.d.ts.map +1 -0
- package/dist/cjs/i18n/translations/en.js +85 -0
- package/dist/cjs/i18n/translations/tr.d.ts +86 -0
- package/dist/cjs/i18n/translations/tr.d.ts.map +1 -0
- package/dist/cjs/i18n/translations/tr.js +85 -0
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/tiptap/assets/__tests__/icons.test.d.ts +2 -0
- package/dist/cjs/tiptap/assets/__tests__/icons.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/assets/__tests__/icons.test.js +25 -0
- package/dist/cjs/tiptap/assets/__tests__/icons.test.tsx +29 -0
- package/dist/cjs/tiptap/assets/icons.d.ts +3 -0
- package/dist/cjs/tiptap/assets/icons.d.ts.map +1 -0
- package/dist/cjs/tiptap/assets/icons.js +3 -0
- package/dist/cjs/tiptap/components/__tests__/format-bubble-menu.test.d.ts +6 -0
- package/dist/cjs/tiptap/components/__tests__/format-bubble-menu.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/__tests__/format-bubble-menu.test.js +311 -0
- package/dist/cjs/tiptap/components/__tests__/format-bubble-menu.test.tsx +452 -0
- package/dist/cjs/tiptap/components/__tests__/html-code-viewer.test.d.ts +2 -0
- package/dist/cjs/tiptap/components/__tests__/html-code-viewer.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/__tests__/html-code-viewer.test.js +89 -0
- package/dist/cjs/tiptap/components/__tests__/html-code-viewer.test.tsx +126 -0
- package/dist/cjs/tiptap/components/__tests__/image-upload-placeholder.test.d.ts +2 -0
- package/dist/cjs/tiptap/components/__tests__/image-upload-placeholder.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/__tests__/image-upload-placeholder.test.js +206 -0
- package/dist/cjs/tiptap/components/__tests__/image-upload-placeholder.test.tsx +297 -0
- package/dist/cjs/tiptap/components/__tests__/secure-script-component.test.d.ts +2 -0
- package/dist/cjs/tiptap/components/__tests__/secure-script-component.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/__tests__/secure-script-component.test.js +57 -0
- package/dist/cjs/tiptap/components/__tests__/secure-script-component.test.tsx +89 -0
- package/dist/cjs/tiptap/components/__tests__/table-bubble-menu.test.d.ts +6 -0
- package/dist/cjs/tiptap/components/__tests__/table-bubble-menu.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/__tests__/table-bubble-menu.test.js +284 -0
- package/dist/cjs/tiptap/components/__tests__/table-bubble-menu.test.tsx +466 -0
- package/dist/cjs/tiptap/components/__tests__/table-popover.test.d.ts +2 -0
- package/dist/cjs/tiptap/components/__tests__/table-popover.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/__tests__/table-popover.test.js +101 -0
- package/dist/cjs/tiptap/components/__tests__/table-popover.test.tsx +157 -0
- package/dist/cjs/tiptap/components/__tests__/tiptap.test.d.ts +2 -0
- package/dist/cjs/tiptap/components/__tests__/tiptap.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/__tests__/tiptap.test.js +275 -0
- package/dist/cjs/tiptap/components/__tests__/tiptap.test.tsx +378 -0
- package/dist/cjs/tiptap/components/format-bubble-menu.d.ts +8 -0
- package/dist/cjs/tiptap/components/format-bubble-menu.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/format-bubble-menu.js +202 -0
- package/dist/cjs/tiptap/components/html-code-viewer.d.ts +10 -0
- package/dist/cjs/tiptap/components/html-code-viewer.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/html-code-viewer.js +96 -0
- package/dist/cjs/tiptap/components/image-upload-placeholder.d.ts +4 -0
- package/dist/cjs/tiptap/components/image-upload-placeholder.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/image-upload-placeholder.js +94 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/action-toolbar.test.d.ts +2 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/action-toolbar.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/action-toolbar.test.js +78 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/action-toolbar.test.tsx +212 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/alignment-toolbar.test.d.ts +3 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/alignment-toolbar.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/alignment-toolbar.test.js +201 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/alignment-toolbar.test.tsx +411 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/heading-selector.test.d.ts +4 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/heading-selector.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/heading-selector.test.js +242 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/heading-selector.test.tsx +569 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/index.test.d.ts +2 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/index.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/index.test.js +236 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/index.test.tsx +325 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/link-popover.test.d.ts +3 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/link-popover.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/link-popover.test.js +332 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/link-popover.test.tsx +648 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/list-and-block-toolbar.test.d.ts +2 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/list-and-block-toolbar.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/list-and-block-toolbar.test.js +196 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/list-and-block-toolbar.test.tsx +414 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/media-toolbar.test.d.ts +2 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/media-toolbar.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/media-toolbar.test.js +74 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/media-toolbar.test.tsx +206 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/text-formatting-toolbar.test.d.ts +2 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/text-formatting-toolbar.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/text-formatting-toolbar.test.js +265 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/text-formatting-toolbar.test.tsx +575 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/youtube-popover.test.d.ts +3 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/youtube-popover.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/youtube-popover.test.js +277 -0
- package/dist/cjs/tiptap/components/menu-bar/__tests__/youtube-popover.test.tsx +538 -0
- package/dist/cjs/tiptap/components/menu-bar/action-toolbar.d.ts +15 -0
- package/dist/cjs/tiptap/components/menu-bar/action-toolbar.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/menu-bar/action-toolbar.js +40 -0
- package/dist/cjs/tiptap/components/menu-bar/alignment-toolbar.d.ts +12 -0
- package/dist/cjs/tiptap/components/menu-bar/alignment-toolbar.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/menu-bar/alignment-toolbar.js +39 -0
- package/dist/cjs/tiptap/components/menu-bar/heading-selector.d.ts +16 -0
- package/dist/cjs/tiptap/components/menu-bar/heading-selector.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/menu-bar/heading-selector.js +70 -0
- package/dist/cjs/tiptap/components/menu-bar/index.d.ts +18 -0
- package/dist/cjs/tiptap/components/menu-bar/index.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/menu-bar/index.js +131 -0
- package/dist/cjs/tiptap/components/menu-bar/link-popover.d.ts +12 -0
- package/dist/cjs/tiptap/components/menu-bar/link-popover.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/menu-bar/link-popover.js +108 -0
- package/dist/cjs/tiptap/components/menu-bar/list-and-block-toolbar.d.ts +18 -0
- package/dist/cjs/tiptap/components/menu-bar/list-and-block-toolbar.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/menu-bar/list-and-block-toolbar.js +69 -0
- package/dist/cjs/tiptap/components/menu-bar/media-toolbar.d.ts +13 -0
- package/dist/cjs/tiptap/components/menu-bar/media-toolbar.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/menu-bar/media-toolbar.js +15 -0
- package/dist/cjs/tiptap/components/menu-bar/text-formatting-toolbar.d.ts +18 -0
- package/dist/cjs/tiptap/components/menu-bar/text-formatting-toolbar.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/menu-bar/text-formatting-toolbar.js +87 -0
- package/dist/cjs/tiptap/components/menu-bar/youtube-popover.d.ts +12 -0
- package/dist/cjs/tiptap/components/menu-bar/youtube-popover.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/menu-bar/youtube-popover.js +70 -0
- package/dist/cjs/tiptap/components/secure-script-component.d.ts +3 -0
- package/dist/cjs/tiptap/components/secure-script-component.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/secure-script-component.js +61 -0
- package/dist/cjs/tiptap/components/table-bubble-menu.d.ts +9 -0
- package/dist/cjs/tiptap/components/table-bubble-menu.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/table-bubble-menu.js +274 -0
- package/dist/cjs/tiptap/components/table-popover.d.ts +10 -0
- package/dist/cjs/tiptap/components/table-popover.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/table-popover.js +86 -0
- package/dist/cjs/tiptap/components/tiptap.d.ts +4 -0
- package/dist/cjs/tiptap/components/tiptap.d.ts.map +1 -0
- package/dist/cjs/tiptap/components/tiptap.js +311 -0
- package/dist/cjs/tiptap/constants/__tests__/table-defaults.test.d.ts +2 -0
- package/dist/cjs/tiptap/constants/__tests__/table-defaults.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/constants/__tests__/table-defaults.test.js +56 -0
- package/dist/cjs/tiptap/constants/__tests__/table-defaults.test.ts +69 -0
- package/dist/cjs/tiptap/constants/editor-config.d.ts +89 -0
- package/dist/cjs/tiptap/constants/editor-config.d.ts.map +1 -0
- package/dist/cjs/tiptap/constants/editor-config.js +103 -0
- package/dist/cjs/tiptap/constants/html-elements.d.ts +95 -0
- package/dist/cjs/tiptap/constants/html-elements.d.ts.map +1 -0
- package/dist/cjs/tiptap/constants/html-elements.js +158 -0
- package/dist/cjs/tiptap/constants/index.d.ts +4 -0
- package/dist/cjs/tiptap/constants/index.d.ts.map +1 -0
- package/dist/cjs/tiptap/constants/index.js +3 -0
- package/dist/cjs/tiptap/constants/table-defaults.d.ts +14 -0
- package/dist/cjs/tiptap/constants/table-defaults.d.ts.map +1 -0
- package/dist/cjs/tiptap/constants/table-defaults.js +18 -0
- package/dist/cjs/tiptap/extensions/__tests__/comment-extension.test.d.ts +2 -0
- package/dist/cjs/tiptap/extensions/__tests__/comment-extension.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/__tests__/comment-extension.test.js +75 -0
- package/dist/cjs/tiptap/extensions/__tests__/comment-extension.test.ts +84 -0
- package/dist/cjs/tiptap/extensions/__tests__/custom-table-cell-extension.test.d.ts +2 -0
- package/dist/cjs/tiptap/extensions/__tests__/custom-table-cell-extension.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/__tests__/custom-table-cell-extension.test.js +116 -0
- package/dist/cjs/tiptap/extensions/__tests__/custom-table-cell-extension.test.ts +147 -0
- package/dist/cjs/tiptap/extensions/__tests__/custom-table-cell-extension.test.tsx +90 -0
- package/dist/cjs/tiptap/extensions/__tests__/custom-table-header-extension.test.d.ts +2 -0
- package/dist/cjs/tiptap/extensions/__tests__/custom-table-header-extension.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/__tests__/custom-table-header-extension.test.js +183 -0
- package/dist/cjs/tiptap/extensions/__tests__/custom-table-header-extension.test.ts +213 -0
- package/dist/cjs/tiptap/extensions/__tests__/html-block-extension.test.d.ts +2 -0
- package/dist/cjs/tiptap/extensions/__tests__/html-block-extension.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/__tests__/html-block-extension.test.js +103 -0
- package/dist/cjs/tiptap/extensions/__tests__/html-block-extension.test.ts +117 -0
- package/dist/cjs/tiptap/extensions/__tests__/html-inline-extension.test.d.ts +2 -0
- package/dist/cjs/tiptap/extensions/__tests__/html-inline-extension.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/__tests__/html-inline-extension.test.js +105 -0
- package/dist/cjs/tiptap/extensions/__tests__/html-inline-extension.test.ts +119 -0
- package/dist/cjs/tiptap/extensions/__tests__/iframe-extension.test.d.ts +2 -0
- package/dist/cjs/tiptap/extensions/__tests__/iframe-extension.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/__tests__/iframe-extension.test.js +262 -0
- package/dist/cjs/tiptap/extensions/__tests__/iframe-extension.test.ts +297 -0
- package/dist/cjs/tiptap/extensions/__tests__/image-upload-extension.test.d.ts +2 -0
- package/dist/cjs/tiptap/extensions/__tests__/image-upload-extension.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/__tests__/image-upload-extension.test.js +52 -0
- package/dist/cjs/tiptap/extensions/__tests__/image-upload-extension.test.tsx +65 -0
- package/dist/cjs/tiptap/extensions/__tests__/index.test.d.ts +2 -0
- package/dist/cjs/tiptap/extensions/__tests__/index.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/__tests__/index.test.js +24 -0
- package/dist/cjs/tiptap/extensions/__tests__/index.test.ts +26 -0
- package/dist/cjs/tiptap/extensions/__tests__/reset-marks-extension.test.d.ts +2 -0
- package/dist/cjs/tiptap/extensions/__tests__/reset-marks-extension.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/__tests__/reset-marks-extension.test.js +53 -0
- package/dist/cjs/tiptap/extensions/__tests__/reset-marks-extension.test.ts +74 -0
- package/dist/cjs/tiptap/extensions/__tests__/secure-script-extension.test.d.ts +2 -0
- package/dist/cjs/tiptap/extensions/__tests__/secure-script-extension.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/__tests__/secure-script-extension.test.js +27 -0
- package/dist/cjs/tiptap/extensions/__tests__/secure-script-extension.test.tsx +32 -0
- package/dist/cjs/tiptap/extensions/comment-extension.d.ts +13 -0
- package/dist/cjs/tiptap/extensions/comment-extension.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/comment-extension.js +47 -0
- package/dist/cjs/tiptap/extensions/custom-table-cell-extension.d.ts +10 -0
- package/dist/cjs/tiptap/extensions/custom-table-cell-extension.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/custom-table-cell-extension.js +64 -0
- package/dist/cjs/tiptap/extensions/custom-table-header-extension.d.ts +10 -0
- package/dist/cjs/tiptap/extensions/custom-table-header-extension.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/custom-table-header-extension.js +63 -0
- package/dist/cjs/tiptap/extensions/html-block-extension.d.ts +6 -0
- package/dist/cjs/tiptap/extensions/html-block-extension.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/html-block-extension.js +90 -0
- package/dist/cjs/tiptap/extensions/html-inline-extension.d.ts +6 -0
- package/dist/cjs/tiptap/extensions/html-inline-extension.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/html-inline-extension.js +87 -0
- package/dist/cjs/tiptap/extensions/iframe-extension.d.ts +18 -0
- package/dist/cjs/tiptap/extensions/iframe-extension.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/iframe-extension.js +170 -0
- package/dist/cjs/tiptap/extensions/image-upload-extension.d.ts +3 -0
- package/dist/cjs/tiptap/extensions/image-upload-extension.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/image-upload-extension.js +29 -0
- package/dist/cjs/tiptap/extensions/index.d.ts +10 -0
- package/dist/cjs/tiptap/extensions/index.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/index.js +9 -0
- package/dist/cjs/tiptap/extensions/reset-marks-extension.d.ts +3 -0
- package/dist/cjs/tiptap/extensions/reset-marks-extension.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/reset-marks-extension.js +17 -0
- package/dist/cjs/tiptap/extensions/secure-script-extension.d.ts +3 -0
- package/dist/cjs/tiptap/extensions/secure-script-extension.d.ts.map +1 -0
- package/dist/cjs/tiptap/extensions/secure-script-extension.js +55 -0
- package/dist/cjs/tiptap/types/index.d.ts +232 -0
- package/dist/cjs/tiptap/types/index.d.ts.map +1 -0
- package/dist/cjs/tiptap/types/index.js +1 -0
- package/dist/cjs/tiptap/utils/__tests__/format-html.test.d.ts +2 -0
- package/dist/cjs/tiptap/utils/__tests__/format-html.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/utils/__tests__/format-html.test.js +68 -0
- package/dist/cjs/tiptap/utils/__tests__/format-html.test.ts +91 -0
- package/dist/cjs/tiptap/utils/__tests__/highlight-html.test.d.ts +2 -0
- package/dist/cjs/tiptap/utils/__tests__/highlight-html.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/utils/__tests__/highlight-html.test.js +71 -0
- package/dist/cjs/tiptap/utils/__tests__/highlight-html.test.ts +100 -0
- package/dist/cjs/tiptap/utils/__tests__/index.test.d.ts +2 -0
- package/dist/cjs/tiptap/utils/__tests__/index.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/utils/__tests__/index.test.js +13 -0
- package/dist/cjs/tiptap/utils/__tests__/index.test.ts +15 -0
- package/dist/cjs/tiptap/utils/__tests__/normalize-html.test.d.ts +2 -0
- package/dist/cjs/tiptap/utils/__tests__/normalize-html.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/utils/__tests__/normalize-html.test.js +53 -0
- package/dist/cjs/tiptap/utils/__tests__/normalize-html.test.ts +77 -0
- package/dist/cjs/tiptap/utils/__tests__/tiptap-extensions.test.d.ts +2 -0
- package/dist/cjs/tiptap/utils/__tests__/tiptap-extensions.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/utils/__tests__/tiptap-extensions.test.js +209 -0
- package/dist/cjs/tiptap/utils/__tests__/tiptap-extensions.test.ts +299 -0
- package/dist/cjs/tiptap/utils/format-html.d.ts +6 -0
- package/dist/cjs/tiptap/utils/format-html.d.ts.map +1 -0
- package/dist/cjs/tiptap/utils/format-html.js +108 -0
- package/dist/cjs/tiptap/utils/highlight-html.d.ts +6 -0
- package/dist/cjs/tiptap/utils/highlight-html.d.ts.map +1 -0
- package/dist/cjs/tiptap/utils/highlight-html.js +82 -0
- package/dist/cjs/tiptap/utils/index.d.ts +5 -0
- package/dist/cjs/tiptap/utils/index.d.ts.map +1 -0
- package/dist/cjs/tiptap/utils/index.js +4 -0
- package/dist/cjs/tiptap/utils/normalize-html.d.ts +7 -0
- package/dist/cjs/tiptap/utils/normalize-html.d.ts.map +1 -0
- package/dist/cjs/tiptap/utils/normalize-html.js +109 -0
- package/dist/cjs/tiptap/utils/tiptap-extensions.d.ts +21 -0
- package/dist/cjs/tiptap/utils/tiptap-extensions.d.ts.map +1 -0
- package/dist/cjs/tiptap/utils/tiptap-extensions.js +198 -0
- package/dist/esm/__tests__/index.test.d.ts +2 -0
- package/dist/esm/__tests__/index.test.d.ts.map +1 -0
- package/dist/esm/__tests__/index.test.js +38 -0
- package/dist/esm/__tests__/index.test.tsx +51 -0
- package/dist/esm/i18n/index.d.ts +3 -0
- package/dist/esm/i18n/index.d.ts.map +1 -0
- package/dist/esm/i18n/index.js +11 -0
- package/dist/esm/i18n/translations/en.d.ts +86 -0
- package/dist/esm/i18n/translations/en.d.ts.map +1 -0
- package/dist/esm/i18n/translations/en.js +85 -0
- package/dist/esm/i18n/translations/tr.d.ts +86 -0
- package/dist/esm/i18n/translations/tr.d.ts.map +1 -0
- package/dist/esm/i18n/translations/tr.js +85 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/tiptap/assets/__tests__/icons.test.d.ts +2 -0
- package/dist/esm/tiptap/assets/__tests__/icons.test.d.ts.map +1 -0
- package/dist/esm/tiptap/assets/__tests__/icons.test.js +25 -0
- package/dist/esm/tiptap/assets/__tests__/icons.test.tsx +29 -0
- package/dist/esm/tiptap/assets/icons.d.ts +3 -0
- package/dist/esm/tiptap/assets/icons.d.ts.map +1 -0
- package/dist/esm/tiptap/assets/icons.js +3 -0
- package/dist/esm/tiptap/components/__tests__/format-bubble-menu.test.d.ts +6 -0
- package/dist/esm/tiptap/components/__tests__/format-bubble-menu.test.d.ts.map +1 -0
- package/dist/esm/tiptap/components/__tests__/format-bubble-menu.test.js +311 -0
- package/dist/esm/tiptap/components/__tests__/format-bubble-menu.test.tsx +452 -0
- package/dist/esm/tiptap/components/__tests__/html-code-viewer.test.d.ts +2 -0
- package/dist/esm/tiptap/components/__tests__/html-code-viewer.test.d.ts.map +1 -0
- package/dist/esm/tiptap/components/__tests__/html-code-viewer.test.js +89 -0
- package/dist/esm/tiptap/components/__tests__/html-code-viewer.test.tsx +126 -0
- package/dist/esm/tiptap/components/__tests__/image-upload-placeholder.test.d.ts +2 -0
- package/dist/esm/tiptap/components/__tests__/image-upload-placeholder.test.d.ts.map +1 -0
- package/dist/esm/tiptap/components/__tests__/image-upload-placeholder.test.js +206 -0
- package/dist/esm/tiptap/components/__tests__/image-upload-placeholder.test.tsx +297 -0
- package/dist/esm/tiptap/components/__tests__/secure-script-component.test.d.ts +2 -0
- package/dist/esm/tiptap/components/__tests__/secure-script-component.test.d.ts.map +1 -0
- package/dist/esm/tiptap/components/__tests__/secure-script-component.test.js +57 -0
- package/dist/esm/tiptap/components/__tests__/secure-script-component.test.tsx +89 -0
- package/dist/esm/tiptap/components/__tests__/table-bubble-menu.test.d.ts +6 -0
- package/dist/esm/tiptap/components/__tests__/table-bubble-menu.test.d.ts.map +1 -0
- package/dist/esm/tiptap/components/__tests__/table-bubble-menu.test.js +284 -0
- package/dist/esm/tiptap/components/__tests__/table-bubble-menu.test.tsx +466 -0
- package/dist/esm/tiptap/components/__tests__/table-popover.test.d.ts +2 -0
- package/dist/esm/tiptap/components/__tests__/table-popover.test.d.ts.map +1 -0
- package/dist/esm/tiptap/components/__tests__/table-popover.test.js +101 -0
- package/dist/esm/tiptap/components/__tests__/table-popover.test.tsx +157 -0
- package/dist/esm/tiptap/components/__tests__/tiptap.test.d.ts +2 -0
- package/dist/esm/tiptap/components/__tests__/tiptap.test.d.ts.map +1 -0
- package/dist/esm/tiptap/components/__tests__/tiptap.test.js +275 -0
- package/dist/esm/tiptap/components/__tests__/tiptap.test.tsx +378 -0
- package/dist/esm/tiptap/components/format-bubble-menu.d.ts +8 -0
- package/dist/esm/tiptap/components/format-bubble-menu.d.ts.map +1 -0
- package/dist/esm/tiptap/components/format-bubble-menu.js +202 -0
- package/dist/esm/tiptap/components/html-code-viewer.d.ts +10 -0
- package/dist/esm/tiptap/components/html-code-viewer.d.ts.map +1 -0
- package/dist/esm/tiptap/components/html-code-viewer.js +96 -0
- package/dist/esm/tiptap/components/image-upload-placeholder.d.ts +4 -0
- package/dist/esm/tiptap/components/image-upload-placeholder.d.ts.map +1 -0
- package/dist/esm/tiptap/components/image-upload-placeholder.js +94 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/action-toolbar.test.d.ts +2 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/action-toolbar.test.d.ts.map +1 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/action-toolbar.test.js +78 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/action-toolbar.test.tsx +212 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/alignment-toolbar.test.d.ts +3 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/alignment-toolbar.test.d.ts.map +1 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/alignment-toolbar.test.js +201 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/alignment-toolbar.test.tsx +411 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/heading-selector.test.d.ts +4 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/heading-selector.test.d.ts.map +1 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/heading-selector.test.js +242 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/heading-selector.test.tsx +569 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/index.test.d.ts +2 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/index.test.d.ts.map +1 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/index.test.js +236 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/index.test.tsx +325 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/link-popover.test.d.ts +3 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/link-popover.test.d.ts.map +1 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/link-popover.test.js +332 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/link-popover.test.tsx +648 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/list-and-block-toolbar.test.d.ts +2 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/list-and-block-toolbar.test.d.ts.map +1 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/list-and-block-toolbar.test.js +196 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/list-and-block-toolbar.test.tsx +414 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/media-toolbar.test.d.ts +2 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/media-toolbar.test.d.ts.map +1 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/media-toolbar.test.js +74 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/media-toolbar.test.tsx +206 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/text-formatting-toolbar.test.d.ts +2 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/text-formatting-toolbar.test.d.ts.map +1 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/text-formatting-toolbar.test.js +265 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/text-formatting-toolbar.test.tsx +575 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/youtube-popover.test.d.ts +3 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/youtube-popover.test.d.ts.map +1 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/youtube-popover.test.js +277 -0
- package/dist/esm/tiptap/components/menu-bar/__tests__/youtube-popover.test.tsx +538 -0
- package/dist/esm/tiptap/components/menu-bar/action-toolbar.d.ts +15 -0
- package/dist/esm/tiptap/components/menu-bar/action-toolbar.d.ts.map +1 -0
- package/dist/esm/tiptap/components/menu-bar/action-toolbar.js +40 -0
- package/dist/esm/tiptap/components/menu-bar/alignment-toolbar.d.ts +12 -0
- package/dist/esm/tiptap/components/menu-bar/alignment-toolbar.d.ts.map +1 -0
- package/dist/esm/tiptap/components/menu-bar/alignment-toolbar.js +39 -0
- package/dist/esm/tiptap/components/menu-bar/heading-selector.d.ts +16 -0
- package/dist/esm/tiptap/components/menu-bar/heading-selector.d.ts.map +1 -0
- package/dist/esm/tiptap/components/menu-bar/heading-selector.js +70 -0
- package/dist/esm/tiptap/components/menu-bar/index.d.ts +18 -0
- package/dist/esm/tiptap/components/menu-bar/index.d.ts.map +1 -0
- package/dist/esm/tiptap/components/menu-bar/index.js +131 -0
- package/dist/esm/tiptap/components/menu-bar/link-popover.d.ts +12 -0
- package/dist/esm/tiptap/components/menu-bar/link-popover.d.ts.map +1 -0
- package/dist/esm/tiptap/components/menu-bar/link-popover.js +108 -0
- package/dist/esm/tiptap/components/menu-bar/list-and-block-toolbar.d.ts +18 -0
- package/dist/esm/tiptap/components/menu-bar/list-and-block-toolbar.d.ts.map +1 -0
- package/dist/esm/tiptap/components/menu-bar/list-and-block-toolbar.js +69 -0
- package/dist/esm/tiptap/components/menu-bar/media-toolbar.d.ts +13 -0
- package/dist/esm/tiptap/components/menu-bar/media-toolbar.d.ts.map +1 -0
- package/dist/esm/tiptap/components/menu-bar/media-toolbar.js +15 -0
- package/dist/esm/tiptap/components/menu-bar/text-formatting-toolbar.d.ts +18 -0
- package/dist/esm/tiptap/components/menu-bar/text-formatting-toolbar.d.ts.map +1 -0
- package/dist/esm/tiptap/components/menu-bar/text-formatting-toolbar.js +87 -0
- package/dist/esm/tiptap/components/menu-bar/youtube-popover.d.ts +12 -0
- package/dist/esm/tiptap/components/menu-bar/youtube-popover.d.ts.map +1 -0
- package/dist/esm/tiptap/components/menu-bar/youtube-popover.js +70 -0
- package/dist/esm/tiptap/components/secure-script-component.d.ts +3 -0
- package/dist/esm/tiptap/components/secure-script-component.d.ts.map +1 -0
- package/dist/esm/tiptap/components/secure-script-component.js +61 -0
- package/dist/esm/tiptap/components/table-bubble-menu.d.ts +9 -0
- package/dist/esm/tiptap/components/table-bubble-menu.d.ts.map +1 -0
- package/dist/esm/tiptap/components/table-bubble-menu.js +274 -0
- package/dist/esm/tiptap/components/table-popover.d.ts +10 -0
- package/dist/esm/tiptap/components/table-popover.d.ts.map +1 -0
- package/dist/esm/tiptap/components/table-popover.js +86 -0
- package/dist/esm/tiptap/components/tiptap.d.ts +4 -0
- package/dist/esm/tiptap/components/tiptap.d.ts.map +1 -0
- package/dist/esm/tiptap/components/tiptap.js +311 -0
- package/dist/esm/tiptap/constants/__tests__/table-defaults.test.d.ts +2 -0
- package/dist/esm/tiptap/constants/__tests__/table-defaults.test.d.ts.map +1 -0
- package/dist/esm/tiptap/constants/__tests__/table-defaults.test.js +56 -0
- package/dist/esm/tiptap/constants/__tests__/table-defaults.test.ts +69 -0
- package/dist/esm/tiptap/constants/editor-config.d.ts +89 -0
- package/dist/esm/tiptap/constants/editor-config.d.ts.map +1 -0
- package/dist/esm/tiptap/constants/editor-config.js +103 -0
- package/dist/esm/tiptap/constants/html-elements.d.ts +95 -0
- package/dist/esm/tiptap/constants/html-elements.d.ts.map +1 -0
- package/dist/esm/tiptap/constants/html-elements.js +158 -0
- package/dist/esm/tiptap/constants/index.d.ts +4 -0
- package/dist/esm/tiptap/constants/index.d.ts.map +1 -0
- package/dist/esm/tiptap/constants/index.js +3 -0
- package/dist/esm/tiptap/constants/table-defaults.d.ts +14 -0
- package/dist/esm/tiptap/constants/table-defaults.d.ts.map +1 -0
- package/dist/esm/tiptap/constants/table-defaults.js +18 -0
- package/dist/esm/tiptap/extensions/__tests__/comment-extension.test.d.ts +2 -0
- package/dist/esm/tiptap/extensions/__tests__/comment-extension.test.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/__tests__/comment-extension.test.js +75 -0
- package/dist/esm/tiptap/extensions/__tests__/comment-extension.test.ts +84 -0
- package/dist/esm/tiptap/extensions/__tests__/custom-table-cell-extension.test.d.ts +2 -0
- package/dist/esm/tiptap/extensions/__tests__/custom-table-cell-extension.test.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/__tests__/custom-table-cell-extension.test.js +116 -0
- package/dist/esm/tiptap/extensions/__tests__/custom-table-cell-extension.test.ts +147 -0
- package/dist/esm/tiptap/extensions/__tests__/custom-table-cell-extension.test.tsx +90 -0
- package/dist/esm/tiptap/extensions/__tests__/custom-table-header-extension.test.d.ts +2 -0
- package/dist/esm/tiptap/extensions/__tests__/custom-table-header-extension.test.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/__tests__/custom-table-header-extension.test.js +183 -0
- package/dist/esm/tiptap/extensions/__tests__/custom-table-header-extension.test.ts +213 -0
- package/dist/esm/tiptap/extensions/__tests__/html-block-extension.test.d.ts +2 -0
- package/dist/esm/tiptap/extensions/__tests__/html-block-extension.test.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/__tests__/html-block-extension.test.js +103 -0
- package/dist/esm/tiptap/extensions/__tests__/html-block-extension.test.ts +117 -0
- package/dist/esm/tiptap/extensions/__tests__/html-inline-extension.test.d.ts +2 -0
- package/dist/esm/tiptap/extensions/__tests__/html-inline-extension.test.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/__tests__/html-inline-extension.test.js +105 -0
- package/dist/esm/tiptap/extensions/__tests__/html-inline-extension.test.ts +119 -0
- package/dist/esm/tiptap/extensions/__tests__/iframe-extension.test.d.ts +2 -0
- package/dist/esm/tiptap/extensions/__tests__/iframe-extension.test.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/__tests__/iframe-extension.test.js +262 -0
- package/dist/esm/tiptap/extensions/__tests__/iframe-extension.test.ts +297 -0
- package/dist/esm/tiptap/extensions/__tests__/image-upload-extension.test.d.ts +2 -0
- package/dist/esm/tiptap/extensions/__tests__/image-upload-extension.test.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/__tests__/image-upload-extension.test.js +52 -0
- package/dist/esm/tiptap/extensions/__tests__/image-upload-extension.test.tsx +65 -0
- package/dist/esm/tiptap/extensions/__tests__/index.test.d.ts +2 -0
- package/dist/esm/tiptap/extensions/__tests__/index.test.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/__tests__/index.test.js +24 -0
- package/dist/esm/tiptap/extensions/__tests__/index.test.ts +26 -0
- package/dist/esm/tiptap/extensions/__tests__/reset-marks-extension.test.d.ts +2 -0
- package/dist/esm/tiptap/extensions/__tests__/reset-marks-extension.test.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/__tests__/reset-marks-extension.test.js +53 -0
- package/dist/esm/tiptap/extensions/__tests__/reset-marks-extension.test.ts +74 -0
- package/dist/esm/tiptap/extensions/__tests__/secure-script-extension.test.d.ts +2 -0
- package/dist/esm/tiptap/extensions/__tests__/secure-script-extension.test.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/__tests__/secure-script-extension.test.js +27 -0
- package/dist/esm/tiptap/extensions/__tests__/secure-script-extension.test.tsx +32 -0
- package/dist/esm/tiptap/extensions/comment-extension.d.ts +13 -0
- package/dist/esm/tiptap/extensions/comment-extension.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/comment-extension.js +47 -0
- package/dist/esm/tiptap/extensions/custom-table-cell-extension.d.ts +10 -0
- package/dist/esm/tiptap/extensions/custom-table-cell-extension.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/custom-table-cell-extension.js +64 -0
- package/dist/esm/tiptap/extensions/custom-table-header-extension.d.ts +10 -0
- package/dist/esm/tiptap/extensions/custom-table-header-extension.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/custom-table-header-extension.js +63 -0
- package/dist/esm/tiptap/extensions/html-block-extension.d.ts +6 -0
- package/dist/esm/tiptap/extensions/html-block-extension.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/html-block-extension.js +90 -0
- package/dist/esm/tiptap/extensions/html-inline-extension.d.ts +6 -0
- package/dist/esm/tiptap/extensions/html-inline-extension.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/html-inline-extension.js +87 -0
- package/dist/esm/tiptap/extensions/iframe-extension.d.ts +18 -0
- package/dist/esm/tiptap/extensions/iframe-extension.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/iframe-extension.js +170 -0
- package/dist/esm/tiptap/extensions/image-upload-extension.d.ts +3 -0
- package/dist/esm/tiptap/extensions/image-upload-extension.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/image-upload-extension.js +29 -0
- package/dist/esm/tiptap/extensions/index.d.ts +10 -0
- package/dist/esm/tiptap/extensions/index.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/index.js +9 -0
- package/dist/esm/tiptap/extensions/reset-marks-extension.d.ts +3 -0
- package/dist/esm/tiptap/extensions/reset-marks-extension.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/reset-marks-extension.js +17 -0
- package/dist/esm/tiptap/extensions/secure-script-extension.d.ts +3 -0
- package/dist/esm/tiptap/extensions/secure-script-extension.d.ts.map +1 -0
- package/dist/esm/tiptap/extensions/secure-script-extension.js +55 -0
- package/dist/esm/tiptap/types/index.d.ts +232 -0
- package/dist/esm/tiptap/types/index.d.ts.map +1 -0
- package/dist/esm/tiptap/types/index.js +1 -0
- package/dist/esm/tiptap/utils/__tests__/format-html.test.d.ts +2 -0
- package/dist/esm/tiptap/utils/__tests__/format-html.test.d.ts.map +1 -0
- package/dist/esm/tiptap/utils/__tests__/format-html.test.js +68 -0
- package/dist/esm/tiptap/utils/__tests__/format-html.test.ts +91 -0
- package/dist/esm/tiptap/utils/__tests__/highlight-html.test.d.ts +2 -0
- package/dist/esm/tiptap/utils/__tests__/highlight-html.test.d.ts.map +1 -0
- package/dist/esm/tiptap/utils/__tests__/highlight-html.test.js +71 -0
- package/dist/esm/tiptap/utils/__tests__/highlight-html.test.ts +100 -0
- package/dist/esm/tiptap/utils/__tests__/index.test.d.ts +2 -0
- package/dist/esm/tiptap/utils/__tests__/index.test.d.ts.map +1 -0
- package/dist/esm/tiptap/utils/__tests__/index.test.js +13 -0
- package/dist/esm/tiptap/utils/__tests__/index.test.ts +15 -0
- package/dist/esm/tiptap/utils/__tests__/normalize-html.test.d.ts +2 -0
- package/dist/esm/tiptap/utils/__tests__/normalize-html.test.d.ts.map +1 -0
- package/dist/esm/tiptap/utils/__tests__/normalize-html.test.js +53 -0
- package/dist/esm/tiptap/utils/__tests__/normalize-html.test.ts +77 -0
- package/dist/esm/tiptap/utils/__tests__/tiptap-extensions.test.d.ts +2 -0
- package/dist/esm/tiptap/utils/__tests__/tiptap-extensions.test.d.ts.map +1 -0
- package/dist/esm/tiptap/utils/__tests__/tiptap-extensions.test.js +209 -0
- package/dist/esm/tiptap/utils/__tests__/tiptap-extensions.test.ts +299 -0
- package/dist/esm/tiptap/utils/format-html.d.ts +6 -0
- package/dist/esm/tiptap/utils/format-html.d.ts.map +1 -0
- package/dist/esm/tiptap/utils/format-html.js +108 -0
- package/dist/esm/tiptap/utils/highlight-html.d.ts +6 -0
- package/dist/esm/tiptap/utils/highlight-html.d.ts.map +1 -0
- package/dist/esm/tiptap/utils/highlight-html.js +82 -0
- package/dist/esm/tiptap/utils/index.d.ts +5 -0
- package/dist/esm/tiptap/utils/index.d.ts.map +1 -0
- package/dist/esm/tiptap/utils/index.js +4 -0
- package/dist/esm/tiptap/utils/normalize-html.d.ts +7 -0
- package/dist/esm/tiptap/utils/normalize-html.d.ts.map +1 -0
- package/dist/esm/tiptap/utils/normalize-html.js +109 -0
- package/dist/esm/tiptap/utils/tiptap-extensions.d.ts +21 -0
- package/dist/esm/tiptap/utils/tiptap-extensions.d.ts.map +1 -0
- package/dist/esm/tiptap/utils/tiptap-extensions.js +198 -0
- package/package.json +99 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import FileHandler from '@tiptap/extension-file-handler';
|
|
2
|
+
import HorizontalRule from '@tiptap/extension-horizontal-rule';
|
|
3
|
+
import Paragraph from '@tiptap/extension-paragraph';
|
|
4
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import { getExtensions, handleImageFile, validateAutoLink, validateLink } from '../tiptap-extensions';
|
|
6
|
+
vi.mock('@tiptap/extension-document', () => ({ default: { extend: vi.fn() } }));
|
|
7
|
+
vi.mock('@tiptap/extension-paragraph', () => ({
|
|
8
|
+
default: { extend: vi.fn() }
|
|
9
|
+
}));
|
|
10
|
+
vi.mock('@tiptap/extension-horizontal-rule', () => ({
|
|
11
|
+
default: {
|
|
12
|
+
extend: vi.fn(config => (Object.assign(Object.assign({}, config), { name: 'horizontalRule' })))
|
|
13
|
+
}
|
|
14
|
+
}));
|
|
15
|
+
vi.mock('../../constants/editor-config', async (importOriginal) => {
|
|
16
|
+
const actual = await importOriginal();
|
|
17
|
+
return Object.assign(Object.assign({}, actual), { LINK_CONFIG: Object.assign(Object.assign({}, actual.LINK_CONFIG), { PHISHING_DOMAINS: ['phishing.com'], NO_AUTOLINK_DOMAINS: ['no-auto.com'] }) });
|
|
18
|
+
});
|
|
19
|
+
vi.mock('@tiptap/extension-file-handler', () => ({
|
|
20
|
+
default: {
|
|
21
|
+
configure: vi.fn((options) => ({
|
|
22
|
+
name: 'fileHandler',
|
|
23
|
+
options
|
|
24
|
+
}))
|
|
25
|
+
}
|
|
26
|
+
}));
|
|
27
|
+
describe('tiptap-extensions', () => {
|
|
28
|
+
describe('getExtensions', () => {
|
|
29
|
+
it('should return an array of extensions', () => {
|
|
30
|
+
const extensions = getExtensions();
|
|
31
|
+
expect(Array.isArray(extensions)).toBe(true);
|
|
32
|
+
expect(extensions.length).toBeGreaterThan(0);
|
|
33
|
+
});
|
|
34
|
+
it('should configure Paragraph with addAttributes', () => {
|
|
35
|
+
expect(Paragraph.extend).toHaveBeenCalled();
|
|
36
|
+
// @ts-expect-error Mock implementation
|
|
37
|
+
const config = Paragraph.extend.mock.calls[0][0];
|
|
38
|
+
const attrs = config.addAttributes();
|
|
39
|
+
expect(attrs).toHaveProperty('style');
|
|
40
|
+
expect(attrs).toHaveProperty('class');
|
|
41
|
+
expect(attrs).toHaveProperty('id');
|
|
42
|
+
});
|
|
43
|
+
it('should configure HorizontalRule with addNodeView', () => {
|
|
44
|
+
expect(HorizontalRule.extend).toHaveBeenCalled();
|
|
45
|
+
// @ts-expect-error Mock implementation
|
|
46
|
+
const config = HorizontalRule.extend.mock.calls[0][0];
|
|
47
|
+
const parseRules = config.parseHTML();
|
|
48
|
+
expect(parseRules).toHaveLength(1);
|
|
49
|
+
expect(parseRules[0].tag).toBe('hr');
|
|
50
|
+
const nodeView = config.addNodeView();
|
|
51
|
+
const result = nodeView();
|
|
52
|
+
expect(result.dom).toBeInstanceOf(HTMLElement);
|
|
53
|
+
expect(result.dom.tagName).toBe('HR');
|
|
54
|
+
});
|
|
55
|
+
it('should configure FileHandler with correct options', () => {
|
|
56
|
+
getExtensions();
|
|
57
|
+
expect(FileHandler.configure).toHaveBeenCalled();
|
|
58
|
+
// @ts-expect-error Mock implementation
|
|
59
|
+
const options = FileHandler.configure.mock.calls[0][0];
|
|
60
|
+
const editor = {};
|
|
61
|
+
const result = options.onPaste(editor, [], '<div>content</div>');
|
|
62
|
+
expect(result).toBe(false);
|
|
63
|
+
const result2 = options.onPaste(editor, [], '');
|
|
64
|
+
expect(result2).toBeUndefined();
|
|
65
|
+
const files = [new File([''], 'test.png')];
|
|
66
|
+
vi.stubGlobal('FileReader', class MockReader {
|
|
67
|
+
readAsDataURL() { }
|
|
68
|
+
onload() { }
|
|
69
|
+
});
|
|
70
|
+
options.onDrop(editor, files, 10);
|
|
71
|
+
vi.stubGlobal('FileReader', undefined);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
describe('validateLink', () => {
|
|
75
|
+
const ctx = {
|
|
76
|
+
defaultProtocol: 'https',
|
|
77
|
+
protocols: ['http', 'https', 'mailto'],
|
|
78
|
+
defaultValidate: () => true
|
|
79
|
+
};
|
|
80
|
+
it('should allow valid https urls', () => {
|
|
81
|
+
expect(validateLink('https://example.com', ctx)).toBe(true);
|
|
82
|
+
});
|
|
83
|
+
it('should allow valid http urls', () => {
|
|
84
|
+
expect(validateLink('http://example.com', ctx)).toBe(true);
|
|
85
|
+
});
|
|
86
|
+
it('should add default protocol if missing', () => {
|
|
87
|
+
expect(validateLink('example.com', ctx)).toBe(true);
|
|
88
|
+
});
|
|
89
|
+
it('should disallow javascript protocol', () => {
|
|
90
|
+
expect(validateLink('javascript:alert(1)', ctx)).toBe(false);
|
|
91
|
+
});
|
|
92
|
+
it('should disallow vbscript protocol', () => {
|
|
93
|
+
expect(validateLink('vbscript:msgbox', ctx)).toBe(false);
|
|
94
|
+
});
|
|
95
|
+
it('should disallow protocols not in the allowed list', () => {
|
|
96
|
+
expect(validateLink('ftp://example.com', ctx)).toBe(false);
|
|
97
|
+
});
|
|
98
|
+
it('should return true for empty url', () => {
|
|
99
|
+
expect(validateLink('', ctx)).toBe(true);
|
|
100
|
+
});
|
|
101
|
+
it('should return false for invalid urls', () => {
|
|
102
|
+
// @ts-expect-error Testing invalid input
|
|
103
|
+
expect(validateLink(null, ctx)).toBe(true);
|
|
104
|
+
expect(validateLink('http://', ctx)).toBe(false);
|
|
105
|
+
});
|
|
106
|
+
it('should handle phishing domains', () => {
|
|
107
|
+
expect(validateLink('https://phishing.com', ctx)).toBe(false);
|
|
108
|
+
});
|
|
109
|
+
it('should handle custom validation failure', () => {
|
|
110
|
+
const customCtx = Object.assign(Object.assign({}, ctx), { defaultValidate: () => false });
|
|
111
|
+
expect(validateLink('https://example.com', customCtx)).toBe(false);
|
|
112
|
+
});
|
|
113
|
+
it('should handle object protocols', () => {
|
|
114
|
+
const customCtx = Object.assign(Object.assign({}, ctx), { protocols: [{ scheme: 'custom' }] });
|
|
115
|
+
expect(validateLink('custom://test', customCtx)).toBe(true);
|
|
116
|
+
});
|
|
117
|
+
it('should return false on exception', () => {
|
|
118
|
+
const originalURL = global.URL;
|
|
119
|
+
global.URL = vi.fn(() => {
|
|
120
|
+
throw new Error('Mock error');
|
|
121
|
+
});
|
|
122
|
+
expect(validateLink('something', ctx)).toBe(false);
|
|
123
|
+
global.URL = originalURL;
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
describe('validateAutoLink', () => {
|
|
127
|
+
it('should return true for normal domains', () => {
|
|
128
|
+
expect(validateAutoLink('example.com')).toBe(true);
|
|
129
|
+
});
|
|
130
|
+
it('should handle full urls', () => {
|
|
131
|
+
expect(validateAutoLink('https://example.com')).toBe(true);
|
|
132
|
+
});
|
|
133
|
+
it('should return false for disallowed domains', () => {
|
|
134
|
+
expect(validateAutoLink('no-auto.com')).toBe(false);
|
|
135
|
+
});
|
|
136
|
+
it('should handle invalid urls gracefully', () => {
|
|
137
|
+
const originalURL = global.URL;
|
|
138
|
+
global.URL = vi.fn(() => {
|
|
139
|
+
throw new Error('Mock error');
|
|
140
|
+
});
|
|
141
|
+
expect(validateAutoLink('bad')).toBe(false);
|
|
142
|
+
global.URL = originalURL;
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
describe('handleImageFile', () => {
|
|
146
|
+
it('should read file and insert image content', () => {
|
|
147
|
+
const editor = {
|
|
148
|
+
chain: () => ({
|
|
149
|
+
insertContentAt: vi.fn(),
|
|
150
|
+
focus: () => ({ run: vi.fn() })
|
|
151
|
+
}),
|
|
152
|
+
state: {
|
|
153
|
+
selection: { anchor: 10 }
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const chainSpy = vi.spyOn(editor, 'chain');
|
|
157
|
+
const insertSpy = vi.fn();
|
|
158
|
+
const runSpy = vi.fn();
|
|
159
|
+
chainSpy.mockReturnValue({
|
|
160
|
+
insertContentAt: insertSpy,
|
|
161
|
+
focus: () => ({ run: runSpy })
|
|
162
|
+
});
|
|
163
|
+
const file = new File(['content'], 'test.png', { type: 'image/png' });
|
|
164
|
+
const mockFileReader = {
|
|
165
|
+
readAsDataURL: vi.fn(),
|
|
166
|
+
onload: vi.fn(),
|
|
167
|
+
result: 'data:image/png;base64,fake'
|
|
168
|
+
};
|
|
169
|
+
vi.stubGlobal('FileReader', vi.fn(() => mockFileReader));
|
|
170
|
+
handleImageFile(editor, file);
|
|
171
|
+
expect(mockFileReader.readAsDataURL).toHaveBeenCalledWith(file);
|
|
172
|
+
mockFileReader.onload();
|
|
173
|
+
expect(chainSpy).toHaveBeenCalled();
|
|
174
|
+
expect(insertSpy).toHaveBeenCalledWith(10, {
|
|
175
|
+
type: 'image',
|
|
176
|
+
attrs: { src: 'data:image/png;base64,fake' }
|
|
177
|
+
});
|
|
178
|
+
expect(runSpy).toHaveBeenCalled();
|
|
179
|
+
vi.stubGlobal('FileReader', undefined);
|
|
180
|
+
});
|
|
181
|
+
it('should handle insertion at specific position', () => {
|
|
182
|
+
const editor = {
|
|
183
|
+
chain: () => ({
|
|
184
|
+
insertContentAt: vi.fn(),
|
|
185
|
+
focus: () => ({ run: vi.fn() })
|
|
186
|
+
}),
|
|
187
|
+
state: { selection: { anchor: 0 } }
|
|
188
|
+
};
|
|
189
|
+
const chainSpy = vi.spyOn(editor, 'chain');
|
|
190
|
+
const insertSpy = vi.fn();
|
|
191
|
+
const runSpy = vi.fn();
|
|
192
|
+
chainSpy.mockReturnValue({
|
|
193
|
+
insertContentAt: insertSpy,
|
|
194
|
+
focus: () => ({ run: runSpy })
|
|
195
|
+
});
|
|
196
|
+
const file = new File([''], 'test.png');
|
|
197
|
+
const mockFileReader = {
|
|
198
|
+
readAsDataURL: vi.fn(),
|
|
199
|
+
onload: vi.fn(),
|
|
200
|
+
result: 'data:...'
|
|
201
|
+
};
|
|
202
|
+
vi.stubGlobal('FileReader', vi.fn(() => mockFileReader));
|
|
203
|
+
handleImageFile(editor, file, 55);
|
|
204
|
+
mockFileReader.onload();
|
|
205
|
+
expect(insertSpy).toHaveBeenCalledWith(55, expect.anything());
|
|
206
|
+
vi.stubGlobal('FileReader', undefined);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
});
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { ChainedCommands, Editor } from '@tiptap/core';
|
|
2
|
+
import FileHandler from '@tiptap/extension-file-handler';
|
|
3
|
+
import HorizontalRule from '@tiptap/extension-horizontal-rule';
|
|
4
|
+
import Paragraph from '@tiptap/extension-paragraph';
|
|
5
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
getExtensions,
|
|
9
|
+
handleImageFile,
|
|
10
|
+
validateAutoLink,
|
|
11
|
+
validateLink
|
|
12
|
+
} from '../tiptap-extensions';
|
|
13
|
+
|
|
14
|
+
vi.mock('@tiptap/extension-document', () => ({ default: { extend: vi.fn() } }));
|
|
15
|
+
|
|
16
|
+
vi.mock('@tiptap/extension-paragraph', () => ({
|
|
17
|
+
default: { extend: vi.fn() }
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
vi.mock('@tiptap/extension-horizontal-rule', () => ({
|
|
21
|
+
default: {
|
|
22
|
+
extend: vi.fn(config => ({ ...config, name: 'horizontalRule' }))
|
|
23
|
+
}
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
vi.mock('../../constants/editor-config', async importOriginal => {
|
|
27
|
+
const actual =
|
|
28
|
+
await importOriginal<typeof import('../../constants/editor-config')>();
|
|
29
|
+
return {
|
|
30
|
+
...actual,
|
|
31
|
+
LINK_CONFIG: {
|
|
32
|
+
...actual.LINK_CONFIG,
|
|
33
|
+
PHISHING_DOMAINS: ['phishing.com'],
|
|
34
|
+
NO_AUTOLINK_DOMAINS: ['no-auto.com']
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
vi.mock('@tiptap/extension-file-handler', () => ({
|
|
40
|
+
default: {
|
|
41
|
+
configure: vi.fn((options: Record<string, unknown>) => ({
|
|
42
|
+
name: 'fileHandler',
|
|
43
|
+
options
|
|
44
|
+
}))
|
|
45
|
+
}
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
describe('tiptap-extensions', () => {
|
|
49
|
+
describe('getExtensions', () => {
|
|
50
|
+
it('should return an array of extensions', () => {
|
|
51
|
+
const extensions = getExtensions();
|
|
52
|
+
|
|
53
|
+
expect(Array.isArray(extensions)).toBe(true);
|
|
54
|
+
expect(extensions.length).toBeGreaterThan(0);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should configure Paragraph with addAttributes', () => {
|
|
58
|
+
expect(Paragraph.extend).toHaveBeenCalled();
|
|
59
|
+
// @ts-expect-error Mock implementation
|
|
60
|
+
const config = Paragraph.extend.mock.calls[0][0];
|
|
61
|
+
|
|
62
|
+
const attrs = config.addAttributes();
|
|
63
|
+
|
|
64
|
+
expect(attrs).toHaveProperty('style');
|
|
65
|
+
expect(attrs).toHaveProperty('class');
|
|
66
|
+
expect(attrs).toHaveProperty('id');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('should configure HorizontalRule with addNodeView', () => {
|
|
70
|
+
expect(HorizontalRule.extend).toHaveBeenCalled();
|
|
71
|
+
// @ts-expect-error Mock implementation
|
|
72
|
+
const config = HorizontalRule.extend.mock.calls[0][0];
|
|
73
|
+
|
|
74
|
+
const parseRules = config.parseHTML();
|
|
75
|
+
|
|
76
|
+
expect(parseRules).toHaveLength(1);
|
|
77
|
+
expect(parseRules[0].tag).toBe('hr');
|
|
78
|
+
|
|
79
|
+
const nodeView = config.addNodeView();
|
|
80
|
+
const result = nodeView();
|
|
81
|
+
|
|
82
|
+
expect(result.dom).toBeInstanceOf(HTMLElement);
|
|
83
|
+
expect(result.dom.tagName).toBe('HR');
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should configure FileHandler with correct options', () => {
|
|
87
|
+
getExtensions();
|
|
88
|
+
expect(FileHandler.configure).toHaveBeenCalled();
|
|
89
|
+
// @ts-expect-error Mock implementation
|
|
90
|
+
const options = FileHandler.configure.mock.calls[0][0];
|
|
91
|
+
const editor = {} as unknown as Editor;
|
|
92
|
+
const result = options.onPaste(editor, [], '<div>content</div>');
|
|
93
|
+
|
|
94
|
+
expect(result).toBe(false);
|
|
95
|
+
|
|
96
|
+
const result2 = options.onPaste(editor, [], '');
|
|
97
|
+
|
|
98
|
+
expect(result2).toBeUndefined();
|
|
99
|
+
|
|
100
|
+
const files = [new File([''], 'test.png')];
|
|
101
|
+
|
|
102
|
+
vi.stubGlobal(
|
|
103
|
+
'FileReader',
|
|
104
|
+
class MockReader {
|
|
105
|
+
readAsDataURL() {}
|
|
106
|
+
onload() {}
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
options.onDrop(editor, files, 10);
|
|
111
|
+
|
|
112
|
+
vi.stubGlobal('FileReader', undefined);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe('validateLink', () => {
|
|
117
|
+
const ctx = {
|
|
118
|
+
defaultProtocol: 'https',
|
|
119
|
+
protocols: ['http', 'https', 'mailto'],
|
|
120
|
+
defaultValidate: () => true
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
it('should allow valid https urls', () => {
|
|
124
|
+
expect(validateLink('https://example.com', ctx)).toBe(true);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('should allow valid http urls', () => {
|
|
128
|
+
expect(validateLink('http://example.com', ctx)).toBe(true);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('should add default protocol if missing', () => {
|
|
132
|
+
expect(validateLink('example.com', ctx)).toBe(true);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('should disallow javascript protocol', () => {
|
|
136
|
+
expect(validateLink('javascript:alert(1)', ctx)).toBe(false);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('should disallow vbscript protocol', () => {
|
|
140
|
+
expect(validateLink('vbscript:msgbox', ctx)).toBe(false);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('should disallow protocols not in the allowed list', () => {
|
|
144
|
+
expect(validateLink('ftp://example.com', ctx)).toBe(false);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('should return true for empty url', () => {
|
|
148
|
+
expect(validateLink('', ctx)).toBe(true);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('should return false for invalid urls', () => {
|
|
152
|
+
// @ts-expect-error Testing invalid input
|
|
153
|
+
expect(validateLink(null, ctx)).toBe(true);
|
|
154
|
+
expect(validateLink('http://', ctx)).toBe(false);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('should handle phishing domains', () => {
|
|
158
|
+
expect(validateLink('https://phishing.com', ctx)).toBe(false);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('should handle custom validation failure', () => {
|
|
162
|
+
const customCtx = { ...ctx, defaultValidate: () => false };
|
|
163
|
+
|
|
164
|
+
expect(validateLink('https://example.com', customCtx)).toBe(false);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('should handle object protocols', () => {
|
|
168
|
+
const customCtx = {
|
|
169
|
+
...ctx,
|
|
170
|
+
protocols: [{ scheme: 'custom' }]
|
|
171
|
+
};
|
|
172
|
+
expect(validateLink('custom://test', customCtx)).toBe(true);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('should return false on exception', () => {
|
|
176
|
+
const originalURL = global.URL;
|
|
177
|
+
|
|
178
|
+
global.URL = vi.fn(() => {
|
|
179
|
+
throw new Error('Mock error');
|
|
180
|
+
}) as unknown as typeof URL;
|
|
181
|
+
|
|
182
|
+
expect(validateLink('something', ctx)).toBe(false);
|
|
183
|
+
global.URL = originalURL;
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
describe('validateAutoLink', () => {
|
|
188
|
+
it('should return true for normal domains', () => {
|
|
189
|
+
expect(validateAutoLink('example.com')).toBe(true);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('should handle full urls', () => {
|
|
193
|
+
expect(validateAutoLink('https://example.com')).toBe(true);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it('should return false for disallowed domains', () => {
|
|
197
|
+
expect(validateAutoLink('no-auto.com')).toBe(false);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it('should handle invalid urls gracefully', () => {
|
|
201
|
+
const originalURL = global.URL;
|
|
202
|
+
|
|
203
|
+
global.URL = vi.fn(() => {
|
|
204
|
+
throw new Error('Mock error');
|
|
205
|
+
}) as unknown as typeof URL;
|
|
206
|
+
|
|
207
|
+
expect(validateAutoLink('bad')).toBe(false);
|
|
208
|
+
global.URL = originalURL;
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
describe('handleImageFile', () => {
|
|
213
|
+
it('should read file and insert image content', () => {
|
|
214
|
+
const editor = {
|
|
215
|
+
chain: () => ({
|
|
216
|
+
insertContentAt: vi.fn(),
|
|
217
|
+
focus: () => ({ run: vi.fn() })
|
|
218
|
+
}),
|
|
219
|
+
state: {
|
|
220
|
+
selection: { anchor: 10 }
|
|
221
|
+
}
|
|
222
|
+
} as unknown as Editor;
|
|
223
|
+
|
|
224
|
+
const chainSpy = vi.spyOn(editor, 'chain');
|
|
225
|
+
|
|
226
|
+
const insertSpy = vi.fn();
|
|
227
|
+
const runSpy = vi.fn();
|
|
228
|
+
|
|
229
|
+
chainSpy.mockReturnValue({
|
|
230
|
+
insertContentAt: insertSpy,
|
|
231
|
+
focus: () => ({ run: runSpy })
|
|
232
|
+
} as unknown as ChainedCommands);
|
|
233
|
+
|
|
234
|
+
const file = new File(['content'], 'test.png', { type: 'image/png' });
|
|
235
|
+
|
|
236
|
+
const mockFileReader = {
|
|
237
|
+
readAsDataURL: vi.fn(),
|
|
238
|
+
onload: vi.fn(),
|
|
239
|
+
result: 'data:image/png;base64,fake'
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
vi.stubGlobal(
|
|
243
|
+
'FileReader',
|
|
244
|
+
vi.fn(() => mockFileReader as unknown as FileReader)
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
handleImageFile(editor, file);
|
|
248
|
+
|
|
249
|
+
expect(mockFileReader.readAsDataURL).toHaveBeenCalledWith(file);
|
|
250
|
+
|
|
251
|
+
mockFileReader.onload();
|
|
252
|
+
|
|
253
|
+
expect(chainSpy).toHaveBeenCalled();
|
|
254
|
+
expect(insertSpy).toHaveBeenCalledWith(10, {
|
|
255
|
+
type: 'image',
|
|
256
|
+
attrs: { src: 'data:image/png;base64,fake' }
|
|
257
|
+
});
|
|
258
|
+
expect(runSpy).toHaveBeenCalled();
|
|
259
|
+
|
|
260
|
+
vi.stubGlobal('FileReader', undefined);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it('should handle insertion at specific position', () => {
|
|
264
|
+
const editor = {
|
|
265
|
+
chain: () => ({
|
|
266
|
+
insertContentAt: vi.fn(),
|
|
267
|
+
focus: () => ({ run: vi.fn() })
|
|
268
|
+
}),
|
|
269
|
+
state: { selection: { anchor: 0 } }
|
|
270
|
+
} as unknown as Editor;
|
|
271
|
+
|
|
272
|
+
const chainSpy = vi.spyOn(editor, 'chain');
|
|
273
|
+
const insertSpy = vi.fn();
|
|
274
|
+
const runSpy = vi.fn();
|
|
275
|
+
|
|
276
|
+
chainSpy.mockReturnValue({
|
|
277
|
+
insertContentAt: insertSpy,
|
|
278
|
+
focus: () => ({ run: runSpy })
|
|
279
|
+
} as unknown as ChainedCommands);
|
|
280
|
+
|
|
281
|
+
const file = new File([''], 'test.png');
|
|
282
|
+
const mockFileReader = {
|
|
283
|
+
readAsDataURL: vi.fn(),
|
|
284
|
+
onload: vi.fn(),
|
|
285
|
+
result: 'data:...'
|
|
286
|
+
};
|
|
287
|
+
vi.stubGlobal(
|
|
288
|
+
'FileReader',
|
|
289
|
+
vi.fn(() => mockFileReader as unknown as FileReader)
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
handleImageFile(editor, file, 55);
|
|
293
|
+
mockFileReader.onload();
|
|
294
|
+
|
|
295
|
+
expect(insertSpy).toHaveBeenCalledWith(55, expect.anything());
|
|
296
|
+
vi.stubGlobal('FileReader', undefined);
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-html.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/utils/format-html.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,KAAG,MAQzC,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { BLOCK_ELEMENTS, HTML_ELEMENTS, VOID_ELEMENTS } from '../constants';
|
|
2
|
+
const TAB = ' ';
|
|
3
|
+
const NEWLINE = '\n';
|
|
4
|
+
/**
|
|
5
|
+
* Formats HTML string with proper indentation and cleaner structure.
|
|
6
|
+
* Uses browser DOM parsing to ensure valid HTML structure before formatting.
|
|
7
|
+
*/
|
|
8
|
+
export const formatHtml = (html) => {
|
|
9
|
+
const div = document.createElement(HTML_ELEMENTS.DIV);
|
|
10
|
+
div.innerHTML = html.trim();
|
|
11
|
+
const formatted = formatNode(div, 0).trim();
|
|
12
|
+
// Normalize multiple newlines to single newline
|
|
13
|
+
return formatted.replace(/\n\n+/g, NEWLINE);
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Removes common leading whitespace from a multi-line string.
|
|
17
|
+
*/
|
|
18
|
+
const dedent = (str) => {
|
|
19
|
+
const lines = str.split(NEWLINE);
|
|
20
|
+
const nonEmptyLines = lines.filter(line => line.trim());
|
|
21
|
+
const minIndent = nonEmptyLines.reduce((min, line) => {
|
|
22
|
+
const indent = line.match(/^\s*/)[0].length;
|
|
23
|
+
return Math.min(min, indent);
|
|
24
|
+
}, Infinity);
|
|
25
|
+
return lines
|
|
26
|
+
.map(line => (line.length >= minIndent ? line.slice(minIndent) : line))
|
|
27
|
+
.join(NEWLINE)
|
|
28
|
+
.trim();
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Recursive function to traverse and format DOM nodes.
|
|
32
|
+
*/
|
|
33
|
+
const formatNode = (node, level) => {
|
|
34
|
+
const indentStr = TAB.repeat(level);
|
|
35
|
+
let result = '';
|
|
36
|
+
Array.from(node.childNodes).forEach(child => {
|
|
37
|
+
if (child.nodeType === Node.TEXT_NODE) {
|
|
38
|
+
result += formatTextNode(child);
|
|
39
|
+
}
|
|
40
|
+
else if (child.nodeType === Node.ELEMENT_NODE) {
|
|
41
|
+
result += formatElementNode(child, level, indentStr);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
const formatTextNode = (node) => {
|
|
47
|
+
return node.textContent;
|
|
48
|
+
};
|
|
49
|
+
const formatElementNode = (element, level, indentStr) => {
|
|
50
|
+
const tagName = element.tagName.toLowerCase();
|
|
51
|
+
const isSpan = tagName === HTML_ELEMENTS.SPAN;
|
|
52
|
+
const isComment = element.getAttribute('data-type') === 'comment';
|
|
53
|
+
if (isSpan && isComment) {
|
|
54
|
+
const content = element.getAttribute('data-content') || '';
|
|
55
|
+
return `<!--${content}-->`;
|
|
56
|
+
}
|
|
57
|
+
const isBlock = BLOCK_ELEMENTS.includes(tagName);
|
|
58
|
+
const isVoid = VOID_ELEMENTS.includes(tagName);
|
|
59
|
+
let output = '';
|
|
60
|
+
// Handle block element spacing
|
|
61
|
+
if (isBlock) {
|
|
62
|
+
output += NEWLINE;
|
|
63
|
+
output += indentStr;
|
|
64
|
+
}
|
|
65
|
+
// Construct opening tag with attributes
|
|
66
|
+
const attrs = Array.from(element.attributes)
|
|
67
|
+
.map(attr => ` ${attr.name}="${attr.value}"`)
|
|
68
|
+
.join('');
|
|
69
|
+
const openingTag = `<${tagName}${attrs}${isVoid ? ' />' : '>'}`;
|
|
70
|
+
output += openingTag;
|
|
71
|
+
// Handle content
|
|
72
|
+
if (tagName === HTML_ELEMENTS.PRE) {
|
|
73
|
+
output += element.innerHTML;
|
|
74
|
+
output += `</${tagName}>`;
|
|
75
|
+
}
|
|
76
|
+
else if (!isVoid) {
|
|
77
|
+
output += getElementChildren(element, tagName, level, isBlock, indentStr);
|
|
78
|
+
output += `</${tagName}>`;
|
|
79
|
+
}
|
|
80
|
+
// Close block element with newline
|
|
81
|
+
if (isBlock) {
|
|
82
|
+
output += NEWLINE;
|
|
83
|
+
}
|
|
84
|
+
return output;
|
|
85
|
+
};
|
|
86
|
+
const getElementChildren = (element, tagName, level, isBlock, indentStr) => {
|
|
87
|
+
const isScriptOrStyle = tagName === HTML_ELEMENTS.SCRIPT || tagName === HTML_ELEMENTS.STYLE;
|
|
88
|
+
const content = isScriptOrStyle
|
|
89
|
+
? formatScriptOrStyleContent(element.textContent || '', indentStr)
|
|
90
|
+
: formatNode(element, isBlock ? level + 1 : level);
|
|
91
|
+
if (!content)
|
|
92
|
+
return '';
|
|
93
|
+
const hasBlockChildren = content.includes(NEWLINE) || isScriptOrStyle;
|
|
94
|
+
if (isBlock && hasBlockChildren) {
|
|
95
|
+
return `${NEWLINE}${content}${NEWLINE}${indentStr}`;
|
|
96
|
+
}
|
|
97
|
+
return content;
|
|
98
|
+
};
|
|
99
|
+
const formatScriptOrStyleContent = (content, baseIndent) => {
|
|
100
|
+
if (!content.trim())
|
|
101
|
+
return '';
|
|
102
|
+
const dedented = dedent(content);
|
|
103
|
+
// Indent each line relative to the parent script/style tag
|
|
104
|
+
return dedented
|
|
105
|
+
.split(NEWLINE)
|
|
106
|
+
.map(line => (line ? `${baseIndent}${TAB}${line}` : ''))
|
|
107
|
+
.join(NEWLINE);
|
|
108
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlight-html.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/utils/highlight-html.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA2BH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,MAG5C,CAAC"}
|