@atlaskit/editor-common 74.0.1 → 74.1.1
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/CHANGELOG.md +26 -0
- package/dist/cjs/event-dispatcher/index.js +6 -3
- package/dist/cjs/insert/index.js +274 -0
- package/dist/cjs/monitoring/error.js +106 -0
- package/dist/cjs/monitoring/index.js +12 -0
- package/dist/cjs/node-width/index.js +5 -0
- package/dist/cjs/paste/index.js +12 -0
- package/dist/cjs/paste/md-plugins/ignore-list-heading-md-plugin.js +47 -0
- package/dist/cjs/paste/md-plugins/linkify-md-plugin.js +135 -0
- package/dist/cjs/paste/md-plugins/newline-md-plugin.js +67 -0
- package/dist/cjs/paste/md-plugins/paragraph-md-plugin.js +73 -0
- package/dist/cjs/paste/md.js +31 -0
- package/dist/cjs/preset/plugin-injection-api.js +4 -2
- package/dist/cjs/resizer.js +13 -0
- package/dist/cjs/styles/index.js +8 -1
- package/dist/cjs/styles/shared/blockquote.js +1 -2
- package/dist/cjs/styles/shared/code-block.js +5 -5
- package/dist/cjs/styles/shared/extension.js +4 -0
- package/dist/cjs/styles/shared/layout.js +4 -0
- package/dist/cjs/styles/shared/panel.js +4 -1
- package/dist/cjs/styles/shared/resizer.js +31 -0
- package/dist/cjs/styles/shared/smart-card.js +5 -0
- package/dist/cjs/styles/shared/table.js +2 -3
- package/dist/cjs/types/performance-tracking.js +5 -0
- package/dist/cjs/ui/DropList/index.js +6 -4
- package/dist/cjs/ui/ErrorBoundary/index.js +7 -0
- package/dist/cjs/ui/Expand/index.js +11 -8
- package/dist/cjs/ui/FloatingToolbar/Button.js +93 -0
- package/dist/cjs/ui/FloatingToolbar/styles.js +79 -0
- package/dist/cjs/ui/MediaSingle/grid.js +52 -1
- package/dist/cjs/ui/MediaSingle/index.js +2 -4
- package/dist/cjs/ui/Messages/index.js +2 -3
- package/dist/cjs/ui/Resizer/index.js +97 -0
- package/dist/cjs/ui/Resizer/types.js +5 -0
- package/dist/cjs/ui/Resizer/utils.js +8 -0
- package/dist/cjs/ui/index.js +14 -1
- package/dist/cjs/ui-color/ColorPalette/styles.js +1 -2
- package/dist/cjs/utils/editor-core-utils.js +9 -1
- package/dist/cjs/utils/hyperlink.js +200 -0
- package/dist/cjs/utils/index.js +96 -8
- package/dist/cjs/utils/list.js +19 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/event-dispatcher/index.js +4 -2
- package/dist/es2019/insert/index.js +264 -0
- package/dist/es2019/monitoring/error.js +68 -0
- package/dist/es2019/monitoring/index.js +1 -0
- package/dist/es2019/node-width/index.js +4 -0
- package/dist/es2019/paste/index.js +1 -0
- package/dist/es2019/paste/md-plugins/ignore-list-heading-md-plugin.js +43 -0
- package/dist/es2019/paste/md-plugins/linkify-md-plugin.js +128 -0
- package/dist/es2019/paste/md-plugins/newline-md-plugin.js +58 -0
- package/dist/es2019/paste/md-plugins/paragraph-md-plugin.js +64 -0
- package/dist/es2019/paste/md.js +22 -0
- package/dist/es2019/preset/plugin-injection-api.js +4 -2
- package/dist/es2019/resizer.js +1 -0
- package/dist/es2019/styles/index.js +2 -1
- package/dist/es2019/styles/shared/blockquote.js +2 -3
- package/dist/es2019/styles/shared/code-block.js +8 -7
- package/dist/es2019/styles/shared/extension.js +4 -0
- package/dist/es2019/styles/shared/layout.js +4 -0
- package/dist/es2019/styles/shared/panel.js +7 -4
- package/dist/es2019/styles/shared/resizer.js +72 -0
- package/dist/es2019/styles/shared/smart-card.js +4 -0
- package/dist/es2019/styles/shared/table.js +2 -3
- package/dist/es2019/types/performance-tracking.js +1 -0
- package/dist/es2019/ui/DropList/index.js +7 -3
- package/dist/es2019/ui/ErrorBoundary/index.js +7 -0
- package/dist/es2019/ui/Expand/index.js +14 -9
- package/dist/es2019/ui/FloatingToolbar/Button.js +85 -0
- package/dist/es2019/ui/FloatingToolbar/styles.js +64 -0
- package/dist/es2019/ui/MediaSingle/grid.js +50 -0
- package/dist/es2019/ui/MediaSingle/index.js +1 -2
- package/dist/es2019/ui/Messages/index.js +2 -3
- package/dist/es2019/ui/Resizer/index.js +92 -0
- package/dist/es2019/ui/Resizer/types.js +1 -0
- package/dist/es2019/ui/Resizer/utils.js +1 -0
- package/dist/es2019/ui/index.js +4 -3
- package/dist/es2019/ui-color/ColorPalette/styles.js +1 -2
- package/dist/es2019/utils/editor-core-utils.js +7 -0
- package/dist/es2019/utils/hyperlink.js +165 -0
- package/dist/es2019/utils/index.js +6 -3
- package/dist/es2019/utils/list.js +13 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/event-dispatcher/index.js +4 -2
- package/dist/esm/insert/index.js +262 -0
- package/dist/esm/monitoring/error.js +91 -0
- package/dist/esm/monitoring/index.js +1 -0
- package/dist/esm/node-width/index.js +4 -0
- package/dist/esm/paste/index.js +1 -0
- package/dist/esm/paste/md-plugins/ignore-list-heading-md-plugin.js +41 -0
- package/dist/esm/paste/md-plugins/linkify-md-plugin.js +128 -0
- package/dist/esm/paste/md-plugins/newline-md-plugin.js +60 -0
- package/dist/esm/paste/md-plugins/paragraph-md-plugin.js +66 -0
- package/dist/esm/paste/md.js +22 -0
- package/dist/esm/preset/plugin-injection-api.js +4 -2
- package/dist/esm/resizer.js +1 -0
- package/dist/esm/styles/index.js +2 -1
- package/dist/esm/styles/shared/blockquote.js +1 -2
- package/dist/esm/styles/shared/code-block.js +6 -6
- package/dist/esm/styles/shared/extension.js +4 -0
- package/dist/esm/styles/shared/layout.js +4 -0
- package/dist/esm/styles/shared/panel.js +4 -1
- package/dist/esm/styles/shared/resizer.js +18 -0
- package/dist/esm/styles/shared/smart-card.js +4 -0
- package/dist/esm/styles/shared/table.js +2 -3
- package/dist/esm/types/performance-tracking.js +1 -0
- package/dist/esm/ui/DropList/index.js +6 -3
- package/dist/esm/ui/ErrorBoundary/index.js +7 -0
- package/dist/esm/ui/Expand/index.js +11 -8
- package/dist/esm/ui/FloatingToolbar/Button.js +85 -0
- package/dist/esm/ui/FloatingToolbar/styles.js +68 -0
- package/dist/esm/ui/MediaSingle/grid.js +48 -0
- package/dist/esm/ui/MediaSingle/index.js +1 -2
- package/dist/esm/ui/Messages/index.js +2 -3
- package/dist/esm/ui/Resizer/index.js +90 -0
- package/dist/esm/ui/Resizer/types.js +1 -0
- package/dist/esm/ui/Resizer/utils.js +1 -0
- package/dist/esm/ui/index.js +4 -3
- package/dist/esm/ui-color/ColorPalette/styles.js +1 -2
- package/dist/esm/utils/editor-core-utils.js +7 -0
- package/dist/esm/utils/hyperlink.js +184 -0
- package/dist/esm/utils/index.js +6 -3
- package/dist/esm/utils/list.js +13 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/api.d.ts +1 -1
- package/dist/types/event-dispatcher/index.d.ts +3 -1
- package/dist/types/insert/index.d.ts +25 -0
- package/dist/types/monitoring/error.d.ts +4 -0
- package/dist/types/monitoring/index.d.ts +1 -0
- package/dist/types/paste/index.d.ts +1 -0
- package/dist/types/paste/md-plugins/ignore-list-heading-md-plugin.d.ts +2 -0
- package/dist/types/paste/md-plugins/linkify-md-plugin.d.ts +2 -0
- package/dist/types/paste/md-plugins/newline-md-plugin.d.ts +2 -0
- package/dist/types/paste/md-plugins/paragraph-md-plugin.d.ts +2 -0
- package/dist/types/paste/md.d.ts +2 -0
- package/dist/types/resizer.d.ts +1 -0
- package/dist/types/styles/index.d.ts +1 -0
- package/dist/types/styles/shared/resizer.d.ts +6 -0
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types/types/next-editor-plugin.d.ts +1 -1
- package/dist/types/types/performance-tracking.d.ts +343 -0
- package/dist/types/ui/DropList/index.d.ts +1 -1
- package/dist/types/ui/FloatingToolbar/Button.d.ts +30 -0
- package/dist/types/ui/FloatingToolbar/styles.d.ts +20 -0
- package/dist/types/ui/MediaSingle/grid.d.ts +14 -0
- package/dist/types/ui/MediaSingle/index.d.ts +0 -1
- package/dist/types/ui/Resizer/index.d.ts +22 -0
- package/dist/types/ui/Resizer/types.d.ts +18 -0
- package/dist/types/ui/Resizer/utils.d.ts +1 -0
- package/dist/types/ui/index.d.ts +3 -2
- package/dist/types/utils/editor-core-utils.d.ts +4 -0
- package/dist/types/utils/hyperlink.d.ts +27 -0
- package/dist/types/utils/index.d.ts +4 -3
- package/dist/types/utils/list.d.ts +4 -0
- package/dist/types-ts4.5/__tests_external__/cases/fundamentals/collection.d.ts +3 -0
- package/dist/types-ts4.5/__tests_external__/cases/fundamentals/test-cases/editor-is-present.d.ts +3 -0
- package/dist/types-ts4.5/__tests_external__/cases/fundamentals/test-cases/editor-typing.d.ts +3 -0
- package/dist/types-ts4.5/__tests_external__/cases/smart-links/index.d.ts +4 -0
- package/dist/types-ts4.5/__tests_external__/cases/smart-links/test-cases/block/delete.d.ts +3 -0
- package/dist/types-ts4.5/__tests_external__/cases/smart-links/test-cases/block/edit.d.ts +4 -0
- package/dist/types-ts4.5/__tests_external__/cases/smart-links/test-cases/block/index.d.ts +3 -0
- package/dist/types-ts4.5/__tests_external__/cases/smart-links/test-cases/block/insert.d.ts +3 -0
- package/dist/types-ts4.5/__tests_external__/cases/smart-links/test-cases/embed/delete.d.ts +3 -0
- package/dist/types-ts4.5/__tests_external__/cases/smart-links/test-cases/embed/edit.d.ts +4 -0
- package/dist/types-ts4.5/__tests_external__/cases/smart-links/test-cases/embed/index.d.ts +3 -0
- package/dist/types-ts4.5/__tests_external__/cases/smart-links/test-cases/embed/insert.d.ts +3 -0
- package/dist/types-ts4.5/__tests_external__/cases/smart-links/test-cases/inline/delete.d.ts +3 -0
- package/dist/types-ts4.5/__tests_external__/cases/smart-links/test-cases/inline/edit.d.ts +4 -0
- package/dist/types-ts4.5/__tests_external__/cases/smart-links/test-cases/inline/index.d.ts +3 -0
- package/dist/types-ts4.5/__tests_external__/cases/smart-links/test-cases/inline/insert.d.ts +3 -0
- package/dist/types-ts4.5/__tests_external__/cases/smart-links/test-cases/inline/unlink.d.ts +3 -0
- package/dist/types-ts4.5/__tests_external__/cases/smart-links/test-cases/types.d.ts +4 -0
- package/dist/types-ts4.5/__tests_external__/cases/smart-links/test-cases/url/index.d.ts +3 -0
- package/dist/types-ts4.5/__tests_external__/cases/smart-links/test-cases/url/insert.d.ts +3 -0
- package/dist/types-ts4.5/__tests_external__/cases/types.d.ts +7 -0
- package/dist/types-ts4.5/__tests_external__/index.d.ts +3 -0
- package/dist/types-ts4.5/__tests_external__/page-objects/Editor.d.ts +9 -0
- package/dist/types-ts4.5/__tests_external__/page-objects/EditorSmartLink.d.ts +40 -0
- package/dist/types-ts4.5/__tests_external__/page-objects/Renderer.d.ts +6 -0
- package/dist/types-ts4.5/analytics/analytics-queue.d.ts +10 -0
- package/dist/types-ts4.5/analytics/api.d.ts +5 -0
- package/dist/types-ts4.5/analytics/fire-analytics-event.d.ts +2 -0
- package/dist/types-ts4.5/analytics/index.d.ts +5 -0
- package/dist/types-ts4.5/analytics/types/avatar.d.ts +5 -0
- package/dist/types-ts4.5/analytics/types/block.d.ts +3 -0
- package/dist/types-ts4.5/analytics/types/config-panel-events.d.ts +17 -0
- package/dist/types-ts4.5/analytics/types/cut-copy-events.d.ts +12 -0
- package/dist/types-ts4.5/analytics/types/date-events.d.ts +17 -0
- package/dist/types-ts4.5/analytics/types/dispatch-analytics-event.d.ts +2 -0
- package/dist/types-ts4.5/analytics/types/element-browser-events.d.ts +11 -0
- package/dist/types-ts4.5/analytics/types/enums.d.ts +357 -0
- package/dist/types-ts4.5/analytics/types/events.d.ts +130 -0
- package/dist/types-ts4.5/analytics/types/experimental-events.d.ts +16 -0
- package/dist/types-ts4.5/analytics/types/extension-events.d.ts +37 -0
- package/dist/types-ts4.5/analytics/types/find-replace-events.d.ts +23 -0
- package/dist/types-ts4.5/analytics/types/format-events.d.ts +49 -0
- package/dist/types-ts4.5/analytics/types/general-events.d.ts +187 -0
- package/dist/types-ts4.5/analytics/types/index.d.ts +36 -0
- package/dist/types-ts4.5/analytics/types/inline-comment-events.d.ts +17 -0
- package/dist/types-ts4.5/analytics/types/insert-events.d.ts +128 -0
- package/dist/types-ts4.5/analytics/types/link-tool-bar-events.d.ts +76 -0
- package/dist/types-ts4.5/analytics/types/list-events.d.ts +66 -0
- package/dist/types-ts4.5/analytics/types/media-events.d.ts +18 -0
- package/dist/types-ts4.5/analytics/types/node-events.d.ts +56 -0
- package/dist/types-ts4.5/analytics/types/paste-events.d.ts +39 -0
- package/dist/types-ts4.5/analytics/types/performance-report.d.ts +24 -0
- package/dist/types-ts4.5/analytics/types/referentiality-events.d.ts +52 -0
- package/dist/types-ts4.5/analytics/types/selection-events.d.ts +18 -0
- package/dist/types-ts4.5/analytics/types/smart-links.d.ts +14 -0
- package/dist/types-ts4.5/analytics/types/substitute-events.d.ts +26 -0
- package/dist/types-ts4.5/analytics/types/table-events.d.ts +102 -0
- package/dist/types-ts4.5/analytics/types/toolbar-button.d.ts +22 -0
- package/dist/types-ts4.5/analytics/types/type-ahead.d.ts +27 -0
- package/dist/types-ts4.5/analytics/types/utils.d.ts +46 -0
- package/dist/types-ts4.5/analytics/utils.d.ts +3 -0
- package/dist/types-ts4.5/card/cardOptions.d.ts +12 -0
- package/dist/types-ts4.5/card/index.d.ts +2 -0
- package/dist/types-ts4.5/card/utils.d.ts +18 -0
- package/dist/types-ts4.5/collab/types.d.ts +101 -0
- package/dist/types-ts4.5/collab.d.ts +1 -0
- package/dist/types-ts4.5/core-utils/index.d.ts +1 -0
- package/dist/types-ts4.5/core-utils/inside.d.ts +2 -0
- package/dist/types-ts4.5/emoji.d.ts +3 -0
- package/dist/types-ts4.5/event-dispatcher/index.d.ts +21 -0
- package/dist/types-ts4.5/extensions/combine-extension-providers.d.ts +7 -0
- package/dist/types-ts4.5/extensions/default-extension-provider.d.ts +17 -0
- package/dist/types-ts4.5/extensions/extension-fields-helpers.d.ts +10 -0
- package/dist/types-ts4.5/extensions/extension-handlers.d.ts +13 -0
- package/dist/types-ts4.5/extensions/index.d.ts +8 -0
- package/dist/types-ts4.5/extensions/manifest-helpers.d.ts +9 -0
- package/dist/types-ts4.5/extensions/module-helpers.d.ts +11 -0
- package/dist/types-ts4.5/extensions/types/extension-handler.d.ts +40 -0
- package/dist/types-ts4.5/extensions/types/extension-manifest-common.d.ts +8 -0
- package/dist/types-ts4.5/extensions/types/extension-manifest-toolbar-item.d.ts +45 -0
- package/dist/types-ts4.5/extensions/types/extension-manifest.d.ts +101 -0
- package/dist/types-ts4.5/extensions/types/extension-parameters.d.ts +5 -0
- package/dist/types-ts4.5/extensions/types/extension-provider.d.ts +8 -0
- package/dist/types-ts4.5/extensions/types/field-definitions.d.ts +171 -0
- package/dist/types-ts4.5/extensions/types/index.d.ts +8 -0
- package/dist/types-ts4.5/extensions/types/utils.d.ts +18 -0
- package/dist/types-ts4.5/extensions.d.ts +2 -0
- package/dist/types-ts4.5/hooks/index.d.ts +3 -0
- package/dist/types-ts4.5/hooks/useConstructor.d.ts +9 -0
- package/dist/types-ts4.5/hooks/usePreviousState.d.ts +11 -0
- package/dist/types-ts4.5/hooks/useSharedPluginState.d.ts +39 -0
- package/dist/types-ts4.5/i18n/cs.d.ts +133 -0
- package/dist/types-ts4.5/i18n/da.d.ts +133 -0
- package/dist/types-ts4.5/i18n/de.d.ts +133 -0
- package/dist/types-ts4.5/i18n/en.d.ts +133 -0
- package/dist/types-ts4.5/i18n/en_GB.d.ts +133 -0
- package/dist/types-ts4.5/i18n/en_ZZ.d.ts +115 -0
- package/dist/types-ts4.5/i18n/es.d.ts +133 -0
- package/dist/types-ts4.5/i18n/et.d.ts +8 -0
- package/dist/types-ts4.5/i18n/fi.d.ts +133 -0
- package/dist/types-ts4.5/i18n/fr.d.ts +133 -0
- package/dist/types-ts4.5/i18n/hu.d.ts +133 -0
- package/dist/types-ts4.5/i18n/index.d.ts +32 -0
- package/dist/types-ts4.5/i18n/it.d.ts +133 -0
- package/dist/types-ts4.5/i18n/ja.d.ts +133 -0
- package/dist/types-ts4.5/i18n/ko.d.ts +133 -0
- package/dist/types-ts4.5/i18n/languages.d.ts +35 -0
- package/dist/types-ts4.5/i18n/nb.d.ts +133 -0
- package/dist/types-ts4.5/i18n/nl.d.ts +133 -0
- package/dist/types-ts4.5/i18n/pl.d.ts +133 -0
- package/dist/types-ts4.5/i18n/pt_BR.d.ts +133 -0
- package/dist/types-ts4.5/i18n/pt_PT.d.ts +8 -0
- package/dist/types-ts4.5/i18n/ru.d.ts +133 -0
- package/dist/types-ts4.5/i18n/sk.d.ts +8 -0
- package/dist/types-ts4.5/i18n/sv.d.ts +133 -0
- package/dist/types-ts4.5/i18n/th.d.ts +133 -0
- package/dist/types-ts4.5/i18n/tr.d.ts +133 -0
- package/dist/types-ts4.5/i18n/uk.d.ts +133 -0
- package/dist/types-ts4.5/i18n/vi.d.ts +133 -0
- package/dist/types-ts4.5/i18n/zh.d.ts +133 -0
- package/dist/types-ts4.5/i18n/zh_TW.d.ts +133 -0
- package/dist/types-ts4.5/icons/index.d.ts +10 -0
- package/dist/types-ts4.5/icons/shared/BorderIcon.d.ts +3 -0
- package/dist/types-ts4.5/icons/shared/PanelErrorIcon.d.ts +3 -0
- package/dist/types-ts4.5/icons/shared/PanelInfoIcon.d.ts +3 -0
- package/dist/types-ts4.5/icons/shared/PanelNoteIcon.d.ts +3 -0
- package/dist/types-ts4.5/icons/shared/PanelSuccessIcon.d.ts +3 -0
- package/dist/types-ts4.5/icons/shared/PanelWarningIcon.d.ts +3 -0
- package/dist/types-ts4.5/icons/shared/table.d.ts +2 -0
- package/dist/types-ts4.5/in-product.d.ts +1 -0
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/insert/index.d.ts +25 -0
- package/dist/types-ts4.5/keymaps/consts.d.ts +12 -0
- package/dist/types-ts4.5/keymaps/index.d.ts +91 -0
- package/dist/types-ts4.5/mention.d.ts +2 -0
- package/dist/types-ts4.5/messages/codeBidiWarning.d.ts +11 -0
- package/dist/types-ts4.5/messages/codeBlockButton.d.ts +22 -0
- package/dist/types-ts4.5/messages/index.d.ts +128 -0
- package/dist/types-ts4.5/messages/insert-block.d.ts +172 -0
- package/dist/types-ts4.5/messages/link.d.ts +7 -0
- package/dist/types-ts4.5/messages/unsupportedContent.d.ts +17 -0
- package/dist/types-ts4.5/monitoring/error.d.ts +4 -0
- package/dist/types-ts4.5/monitoring/index.d.ts +1 -0
- package/dist/types-ts4.5/node-width/index.d.ts +7 -0
- package/dist/types-ts4.5/normalize-feature-flags.d.ts +27 -0
- package/dist/types-ts4.5/panel.d.ts +1 -0
- package/dist/types-ts4.5/paste/index.d.ts +1 -0
- package/dist/types-ts4.5/paste/md-plugins/ignore-list-heading-md-plugin.d.ts +2 -0
- package/dist/types-ts4.5/paste/md-plugins/linkify-md-plugin.d.ts +2 -0
- package/dist/types-ts4.5/paste/md-plugins/newline-md-plugin.d.ts +2 -0
- package/dist/types-ts4.5/paste/md-plugins/paragraph-md-plugin.d.ts +2 -0
- package/dist/types-ts4.5/paste/md.d.ts +2 -0
- package/dist/types-ts4.5/preset/builder.d.ts +36 -0
- package/dist/types-ts4.5/preset/index.d.ts +2 -0
- package/dist/types-ts4.5/preset/plugin-injection-api.d.ts +50 -0
- package/dist/types-ts4.5/provider-factory/autoformatting-provider.d.ts +9 -0
- package/dist/types-ts4.5/provider-factory/card-provider.d.ts +7 -0
- package/dist/types-ts4.5/provider-factory/context-identifier-provider.d.ts +6 -0
- package/dist/types-ts4.5/provider-factory/context.d.ts +6 -0
- package/dist/types-ts4.5/provider-factory/image-upload-provider.d.ts +6 -0
- package/dist/types-ts4.5/provider-factory/macro-provider.d.ts +25 -0
- package/dist/types-ts4.5/provider-factory/media-provider.d.ts +15 -0
- package/dist/types-ts4.5/provider-factory/profile-card-provider.d.ts +6 -0
- package/dist/types-ts4.5/provider-factory/provider-factory.d.ts +17 -0
- package/dist/types-ts4.5/provider-factory/quick-insert-provider.d.ts +24 -0
- package/dist/types-ts4.5/provider-factory/search-provider.d.ts +12 -0
- package/dist/types-ts4.5/provider-factory/types.d.ts +37 -0
- package/dist/types-ts4.5/provider-factory/with-providers.d.ts +18 -0
- package/dist/types-ts4.5/provider-factory.d.ts +13 -0
- package/dist/types-ts4.5/provider-helpers/combine-providers.d.ts +9 -0
- package/dist/types-ts4.5/provider-helpers/index.d.ts +1 -0
- package/dist/types-ts4.5/provider-helpers/promise-helpers.d.ts +32 -0
- package/dist/types-ts4.5/react-node-view/index.d.ts +52 -0
- package/dist/types-ts4.5/react-node-view/types.d.ts +12 -0
- package/dist/types-ts4.5/resizer.d.ts +1 -0
- package/dist/types-ts4.5/safe-plugin/index.d.ts +6 -0
- package/dist/types-ts4.5/selection/gap-cursor/selection.d.ts +40 -0
- package/dist/types-ts4.5/selection/gap-cursor/utils/index.d.ts +2 -0
- package/dist/types-ts4.5/selection/gap-cursor/utils/is-ignored.d.ts +2 -0
- package/dist/types-ts4.5/selection/gap-cursor/utils/is-valid-target-node.d.ts +2 -0
- package/dist/types-ts4.5/selection/index.d.ts +5 -0
- package/dist/types-ts4.5/selection/types.d.ts +26 -0
- package/dist/types-ts4.5/selection/utils.d.ts +4 -0
- package/dist/types-ts4.5/styles/index.d.ts +25 -0
- package/dist/types-ts4.5/styles/shared/annotation.d.ts +12 -0
- package/dist/types-ts4.5/styles/shared/block-marks.d.ts +1 -0
- package/dist/types-ts4.5/styles/shared/blockquote.d.ts +1 -0
- package/dist/types-ts4.5/styles/shared/code-block.d.ts +12 -0
- package/dist/types-ts4.5/styles/shared/code-mark.d.ts +2 -0
- package/dist/types-ts4.5/styles/shared/column-layout.d.ts +2 -0
- package/dist/types-ts4.5/styles/shared/date.d.ts +5 -0
- package/dist/types-ts4.5/styles/shared/dropdown-menu.d.ts +4 -0
- package/dist/types-ts4.5/styles/shared/emoji.d.ts +7 -0
- package/dist/types-ts4.5/styles/shared/extension.d.ts +2 -0
- package/dist/types-ts4.5/styles/shared/headings.d.ts +2 -0
- package/dist/types-ts4.5/styles/shared/indentation.d.ts +1 -0
- package/dist/types-ts4.5/styles/shared/layout.d.ts +2 -0
- package/dist/types-ts4.5/styles/shared/link.d.ts +2 -0
- package/dist/types-ts4.5/styles/shared/lists.d.ts +4 -0
- package/dist/types-ts4.5/styles/shared/media-single.d.ts +3 -0
- package/dist/types-ts4.5/styles/shared/mention.d.ts +3 -0
- package/dist/types-ts4.5/styles/shared/panel.d.ts +85 -0
- package/dist/types-ts4.5/styles/shared/paragraph.d.ts +1 -0
- package/dist/types-ts4.5/styles/shared/resizer.d.ts +6 -0
- package/dist/types-ts4.5/styles/shared/rule.d.ts +2 -0
- package/dist/types-ts4.5/styles/shared/shadow.d.ts +15 -0
- package/dist/types-ts4.5/styles/shared/smart-card.d.ts +7 -0
- package/dist/types-ts4.5/styles/shared/status.d.ts +4 -0
- package/dist/types-ts4.5/styles/shared/table.d.ts +31 -0
- package/dist/types-ts4.5/styles/shared/tableCell.d.ts +1 -0
- package/dist/types-ts4.5/styles/shared/task-decision.d.ts +4 -0
- package/dist/types-ts4.5/styles/shared/text-color.d.ts +1 -0
- package/dist/types-ts4.5/styles/shared/whitespace.d.ts +2 -0
- package/dist/types-ts4.5/transforms/expand.d.ts +5 -0
- package/dist/types-ts4.5/transforms/extension.d.ts +6 -0
- package/dist/types-ts4.5/transforms/index.d.ts +3 -0
- package/dist/types-ts4.5/transforms/layout.d.ts +15 -0
- package/dist/types-ts4.5/type-ahead/index.d.ts +12 -0
- package/dist/types-ts4.5/types/annotation/emitter.d.ts +33 -0
- package/dist/types-ts4.5/types/annotation/index.d.ts +84 -0
- package/dist/types-ts4.5/types/collab.d.ts +8 -0
- package/dist/types-ts4.5/types/command.d.ts +5 -0
- package/dist/types-ts4.5/types/context-panel.d.ts +3 -0
- package/dist/types-ts4.5/types/copy-button.d.ts +24 -0
- package/dist/types-ts4.5/types/editor-actions.d.ts +21 -0
- package/dist/types-ts4.5/types/editor-appearance.d.ts +1 -0
- package/dist/types-ts4.5/types/editor-container-width.d.ts +20 -0
- package/dist/types-ts4.5/types/editor-plugin.d.ts +83 -0
- package/dist/types-ts4.5/types/editor-react-context.d.ts +6 -0
- package/dist/types-ts4.5/types/empty-state-handler.d.ts +7 -0
- package/dist/types-ts4.5/types/feature-flags.d.ts +432 -0
- package/dist/types-ts4.5/types/floating-toolbar.d.ts +256 -0
- package/dist/types-ts4.5/types/index.d.ts +36 -0
- package/dist/types-ts4.5/types/next-editor-plugin.d.ts +113 -0
- package/dist/types-ts4.5/types/performance-tracking.d.ts +343 -0
- package/dist/types-ts4.5/types/plugin-factory.d.ts +27 -0
- package/dist/types-ts4.5/types/prosemirror-config.d.ts +14 -0
- package/dist/types-ts4.5/types/quick-insert.d.ts +26 -0
- package/dist/types-ts4.5/types/supported-browsers.d.ts +15 -0
- package/dist/types-ts4.5/types/toolbar.d.ts +30 -0
- package/dist/types-ts4.5/types/type-ahead.d.ts +72 -0
- package/dist/types-ts4.5/types/ui-components.d.ts +22 -0
- package/dist/types-ts4.5/ufo/experience-store.d.ts +33 -0
- package/dist/types-ts4.5/ufo/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/BaseTheme/index.d.ts +15 -0
- package/dist/types-ts4.5/ui/Caption/index.d.ts +19 -0
- package/dist/types-ts4.5/ui/Caption/messages.d.ts +7 -0
- package/dist/types-ts4.5/ui/DropList/index.d.ts +20 -0
- package/dist/types-ts4.5/ui/Emoji/index.d.ts +22 -0
- package/dist/types-ts4.5/ui/ErrorBoundary/index.d.ts +24 -0
- package/dist/types-ts4.5/ui/EventHandlers/index.d.ts +36 -0
- package/dist/types-ts4.5/ui/Expand/index.d.ts +43 -0
- package/dist/types-ts4.5/ui/FloatingToolbar/Button.d.ts +30 -0
- package/dist/types-ts4.5/ui/FloatingToolbar/styles.d.ts +20 -0
- package/dist/types-ts4.5/ui/IntlErrorBoundary/index.d.ts +15 -0
- package/dist/types-ts4.5/ui/IntlProviderIfMissingWrapper/index.d.ts +6 -0
- package/dist/types-ts4.5/ui/Layer/index.d.ts +47 -0
- package/dist/types-ts4.5/ui/Layer/internal/helpers.d.ts +5 -0
- package/dist/types-ts4.5/ui/MediaSingle/grid.d.ts +24 -0
- package/dist/types-ts4.5/ui/MediaSingle/index.d.ts +23 -0
- package/dist/types-ts4.5/ui/MediaSingle/link.d.ts +1 -0
- package/dist/types-ts4.5/ui/MediaSingle/styled.d.ts +43 -0
- package/dist/types-ts4.5/ui/Mention/index.d.ts +21 -0
- package/dist/types-ts4.5/ui/Mention/mention-with-profilecard.d.ts +15 -0
- package/dist/types-ts4.5/ui/Mention/mention-with-providers.d.ts +22 -0
- package/dist/types-ts4.5/ui/Mention/types.d.ts +2 -0
- package/dist/types-ts4.5/ui/Messages/index.d.ts +11 -0
- package/dist/types-ts4.5/ui/OverflowShadow/index.d.ts +103 -0
- package/dist/types-ts4.5/ui/OverflowShadow/shadowObserver.d.ts +27 -0
- package/dist/types-ts4.5/ui/Popup/index.d.ts +83 -0
- package/dist/types-ts4.5/ui/Popup/utils.d.ts +42 -0
- package/dist/types-ts4.5/ui/PortalProvider/PortalProviderThemesProvider.d.ts +6 -0
- package/dist/types-ts4.5/ui/PortalProvider/index.d.ts +51 -0
- package/dist/types-ts4.5/ui/Resizer/index.d.ts +22 -0
- package/dist/types-ts4.5/ui/Resizer/types.d.ts +18 -0
- package/dist/types-ts4.5/ui/Resizer/utils.d.ts +1 -0
- package/dist/types-ts4.5/ui/UnsupportedBlock/index.d.ts +14 -0
- package/dist/types-ts4.5/ui/UnsupportedInline/index.d.ts +14 -0
- package/dist/types-ts4.5/ui/WidthProvider/index.d.ts +29 -0
- package/dist/types-ts4.5/ui/WithCreateAnalyticsEvent/index.d.ts +6 -0
- package/dist/types-ts4.5/ui/clear-next-sibling-margin-top.d.ts +2 -0
- package/dist/types-ts4.5/ui/index.d.ts +28 -0
- package/dist/types-ts4.5/ui/unsupported-content-helper.d.ts +3 -0
- package/dist/types-ts4.5/ui/with-outer-listeners.d.ts +8 -0
- package/dist/types-ts4.5/ui-color/ColorPalette/Color/index.d.ts +20 -0
- package/dist/types-ts4.5/ui-color/ColorPalette/Color/styles.d.ts +4 -0
- package/dist/types-ts4.5/ui-color/ColorPalette/Palettes/borderColorPalette.d.ts +3 -0
- package/dist/types-ts4.5/ui-color/ColorPalette/Palettes/cellBackgroundColorPalette.d.ts +3 -0
- package/dist/types-ts4.5/ui-color/ColorPalette/Palettes/common.d.ts +2 -0
- package/dist/types-ts4.5/ui-color/ColorPalette/Palettes/getColorMessage.d.ts +2 -0
- package/dist/types-ts4.5/ui-color/ColorPalette/Palettes/index.d.ts +3 -0
- package/dist/types-ts4.5/ui-color/ColorPalette/Palettes/paletteMessages.d.ts +123 -0
- package/dist/types-ts4.5/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.d.ts +1444 -0
- package/dist/types-ts4.5/ui-color/ColorPalette/Palettes/panelBackgroundPalette.d.ts +4 -0
- package/dist/types-ts4.5/ui-color/ColorPalette/Palettes/statusColorPalette.d.ts +4 -0
- package/dist/types-ts4.5/ui-color/ColorPalette/Palettes/textColorPalette.d.ts +2 -0
- package/dist/types-ts4.5/ui-color/ColorPalette/Palettes/type.d.ts +12 -0
- package/dist/types-ts4.5/ui-color/ColorPalette/index.d.ts +50 -0
- package/dist/types-ts4.5/ui-color/ColorPalette/styles.d.ts +1 -0
- package/dist/types-ts4.5/ui-color/ColorPalette/utils.d.ts +11 -0
- package/dist/types-ts4.5/ui-color/index.d.ts +12 -0
- package/dist/types-ts4.5/ui-menu/ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider/index.d.ts +7 -0
- package/dist/types-ts4.5/ui-menu/ArrowKeyNavigationProvider/MenuArrowKeyNavigationProvider/index.d.ts +7 -0
- package/dist/types-ts4.5/ui-menu/ArrowKeyNavigationProvider/index.d.ts +3 -0
- package/dist/types-ts4.5/ui-menu/ArrowKeyNavigationProvider/types.d.ts +36 -0
- package/dist/types-ts4.5/ui-menu/Dropdown/index.d.ts +40 -0
- package/dist/types-ts4.5/ui-menu/DropdownMenu/index.d.ts +22 -0
- package/dist/types-ts4.5/ui-menu/DropdownMenu/types.d.ts +52 -0
- package/dist/types-ts4.5/ui-menu/ToolbarButton/index.d.ts +57 -0
- package/dist/types-ts4.5/ui-menu/ToolbarButton/styles.d.ts +4 -0
- package/dist/types-ts4.5/ui-menu/index.d.ts +8 -0
- package/dist/types-ts4.5/ui-react/ReactEditorViewContext.d.ts +8 -0
- package/dist/types-ts4.5/ui-react/index.d.ts +2 -0
- package/dist/types-ts4.5/ui-react/with-react-editor-view-outer-listeners.d.ts +11 -0
- package/dist/types-ts4.5/utils/analytics.d.ts +29 -0
- package/dist/types-ts4.5/utils/annotation/index.d.ts +8 -0
- package/dist/types-ts4.5/utils/breakout.d.ts +43 -0
- package/dist/types-ts4.5/utils/browser-extensions.d.ts +43 -0
- package/dist/types-ts4.5/utils/browser.d.ts +4 -0
- package/dist/types-ts4.5/utils/collab.d.ts +2 -0
- package/dist/types-ts4.5/utils/compare-props.d.ts +32 -0
- package/dist/types-ts4.5/utils/compareNodes.d.ts +47 -0
- package/dist/types-ts4.5/utils/compose.d.ts +30 -0
- package/dist/types-ts4.5/utils/date.d.ts +18 -0
- package/dist/types-ts4.5/utils/dom.d.ts +40 -0
- package/dist/types-ts4.5/utils/editor-core-utils.d.ts +28 -0
- package/dist/types-ts4.5/utils/error-reporter.d.ts +13 -0
- package/dist/types-ts4.5/utils/extension-handler.d.ts +2 -0
- package/dist/types-ts4.5/utils/get-performance-options.d.ts +18 -0
- package/dist/types-ts4.5/utils/getModeFromTheme.d.ts +1 -0
- package/dist/types-ts4.5/utils/hyperlink.d.ts +27 -0
- package/dist/types-ts4.5/utils/imageLoader.d.ts +14 -0
- package/dist/types-ts4.5/utils/index.d.ts +51 -0
- package/dist/types-ts4.5/utils/is-text-input.d.ts +2 -0
- package/dist/types-ts4.5/utils/list.d.ts +14 -0
- package/dist/types-ts4.5/utils/macro.d.ts +10 -0
- package/dist/types-ts4.5/utils/nodes.d.ts +49 -0
- package/dist/types-ts4.5/utils/outdated-browsers.d.ts +1 -0
- package/dist/types-ts4.5/utils/performance/hooks/use-component-render-tracking/index.d.ts +19 -0
- package/dist/types-ts4.5/utils/performance/is-performance-api-available.d.ts +3 -0
- package/dist/types-ts4.5/utils/performance/measure-render.d.ts +53 -0
- package/dist/types-ts4.5/utils/performance/measure-tti.d.ts +14 -0
- package/dist/types-ts4.5/utils/performance/measure.d.ts +3 -0
- package/dist/types-ts4.5/utils/performance/navigation.d.ts +1 -0
- package/dist/types-ts4.5/utils/plugin-state-factory.d.ts +16 -0
- package/dist/types-ts4.5/utils/profiler/render-count.d.ts +50 -0
- package/dist/types-ts4.5/utils/referentiality.d.ts +18 -0
- package/dist/types-ts4.5/utils/should-force-tracking.d.ts +1 -0
- package/dist/types-ts4.5/utils/slice.d.ts +11 -0
- package/dist/types-ts4.5/utils/table.d.ts +4 -0
- package/dist/types-ts4.5/utils/track-unsupported-content.d.ts +20 -0
- package/dist/types-ts4.5/utils/traversor.d.ts +9 -0
- package/dist/types-ts4.5/utils/types.d.ts +2 -0
- package/dist/types-ts4.5/utils/unsupportedContent/get-unsupported-content-level-data.d.ts +57 -0
- package/dist/types-ts4.5/utils/validate-using-spec.d.ts +19 -0
- package/dist/types-ts4.5/utils/validator.d.ts +42 -0
- package/dist/types-ts4.5/utils/whitespace.d.ts +2 -0
- package/dist/types-ts4.5/validator.d.ts +2 -0
- package/dist/types-ts4.5/with-plugin-state/index.d.ts +88 -0
- package/dist/types-ts4.5/with-plugin-state/types.d.ts +10 -0
- package/insert/package.json +15 -0
- package/monitoring/package.json +15 -0
- package/package.json +30 -12
- package/paste/package.json +15 -0
- package/report.api.md +1 -1
- package/resizer/package.json +15 -0
- package/dist/cjs/utils/sendLogs.js +0 -17
- package/dist/es2019/utils/sendLogs.js +0 -8
- package/dist/esm/utils/sendLogs.js +0 -10
- package/dist/types/utils/sendLogs.d.ts +0 -1
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { Fragment, Node, Slice } from 'prosemirror-model';
|
|
2
|
+
import { NodeSelection, Selection, TextSelection } from 'prosemirror-state';
|
|
3
|
+
import { ReplaceAroundStep, ReplaceStep } from 'prosemirror-transform';
|
|
4
|
+
import { canInsert, findParentNodeOfType, hasParentNodeOfType, isNodeSelection, safeInsert as pmSafeInsert } from 'prosemirror-utils';
|
|
5
|
+
import { GapCursorSelection, Side } from '../selection';
|
|
6
|
+
import { isEmptyParagraph, isListItemNode } from '../utils';
|
|
7
|
+
export let LookDirection = /*#__PURE__*/function (LookDirection) {
|
|
8
|
+
LookDirection["Before"] = "before";
|
|
9
|
+
LookDirection["After"] = "after";
|
|
10
|
+
return LookDirection;
|
|
11
|
+
}({});
|
|
12
|
+
export const normaliseNestedLayout = ({
|
|
13
|
+
selection,
|
|
14
|
+
doc
|
|
15
|
+
}, node) => {
|
|
16
|
+
if (selection.$from.depth > 1) {
|
|
17
|
+
if (node.attrs.layout && node.attrs.layout !== 'default') {
|
|
18
|
+
return node.type.createChecked({
|
|
19
|
+
...node.attrs,
|
|
20
|
+
layout: 'default'
|
|
21
|
+
}, node.content, node.marks);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// If its a breakout layout, we can remove the mark
|
|
25
|
+
// Since default isn't a valid breakout mode.
|
|
26
|
+
const breakoutMark = doc.type.schema.marks.breakout;
|
|
27
|
+
if (breakoutMark && breakoutMark.isInSet(node.marks)) {
|
|
28
|
+
const newMarks = breakoutMark.removeFromSet(node.marks);
|
|
29
|
+
return node.type.createChecked(node.attrs, node.content, newMarks);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return node;
|
|
33
|
+
};
|
|
34
|
+
const isLastChild = ($pos, doc) => doc.resolve($pos.after()).node().lastChild === $pos.node();
|
|
35
|
+
const isFirstChild = ($pos, doc) => doc.resolve($pos.before()).node().firstChild === $pos.node();
|
|
36
|
+
const nodeIsInsideAList = tr => {
|
|
37
|
+
const {
|
|
38
|
+
nodes
|
|
39
|
+
} = tr.doc.type.schema;
|
|
40
|
+
return hasParentNodeOfType([nodes.orderedList, nodes.bulletList])(tr.selection);
|
|
41
|
+
};
|
|
42
|
+
const selectionIsInsideAPanel = tr => {
|
|
43
|
+
const {
|
|
44
|
+
nodes
|
|
45
|
+
} = tr.doc.type.schema;
|
|
46
|
+
return hasParentNodeOfType(nodes.panel)(tr.selection);
|
|
47
|
+
};
|
|
48
|
+
const selectionIsInNestedList = tr => {
|
|
49
|
+
const {
|
|
50
|
+
nodes
|
|
51
|
+
} = tr.doc.type.schema;
|
|
52
|
+
const parentListNode = findParentNodeOfType([nodes.orderedList, nodes.bulletList])(tr.selection);
|
|
53
|
+
if (!parentListNode) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return isListItemNode(tr.doc.resolve(parentListNode.pos).parent);
|
|
57
|
+
};
|
|
58
|
+
const insertBeforeOrAfter = (tr, lookDirection, $parentPos, $proposedPosition, content) => {
|
|
59
|
+
/**
|
|
60
|
+
* This block caters for the first item in a parent with the cursor being at the very start
|
|
61
|
+
* or the last item with the cursor being at the very end
|
|
62
|
+
*
|
|
63
|
+
* e.g.
|
|
64
|
+
* ul
|
|
65
|
+
* li {<>}Scenario one
|
|
66
|
+
* li
|
|
67
|
+
* li Scenario two{<>}
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
if (isFirstChild($proposedPosition, tr.doc) && lookDirection === LookDirection.Before || isLastChild($proposedPosition, tr.doc) && lookDirection === LookDirection.After) {
|
|
71
|
+
return tr.insert($parentPos[lookDirection](), content);
|
|
72
|
+
}
|
|
73
|
+
return tr.insert($proposedPosition[lookDirection](), content);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// FIXME: A more sustainable and configurable way to choose when to split
|
|
77
|
+
const shouldSplit = (nodeType, schemaNodes) => {
|
|
78
|
+
return [schemaNodes.bulletList, schemaNodes.orderedList, schemaNodes.panel].includes(nodeType);
|
|
79
|
+
};
|
|
80
|
+
export const safeInsert = (content, position) => tr => {
|
|
81
|
+
var _tr$selection$$from$n;
|
|
82
|
+
const {
|
|
83
|
+
nodes
|
|
84
|
+
} = tr.doc.type.schema;
|
|
85
|
+
const whitelist = [nodes.rule, nodes.mediaSingle];
|
|
86
|
+
if (content instanceof Fragment || !whitelist.includes(content.type)) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Check for selection
|
|
91
|
+
if (!tr.selection.empty || isNodeSelection(tr.selection)) {
|
|
92
|
+
// NOT IMPLEMENTED
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const {
|
|
96
|
+
$from
|
|
97
|
+
} = tr.selection;
|
|
98
|
+
const $insertPos = position ? tr.doc.resolve(position) : isNodeSelection(tr.selection) ? tr.doc.resolve($from.pos + 1) : $from;
|
|
99
|
+
let lookDirection;
|
|
100
|
+
const insertPosEnd = $insertPos.end();
|
|
101
|
+
const insertPosStart = $insertPos.start();
|
|
102
|
+
|
|
103
|
+
// When parent node is an empty paragraph,
|
|
104
|
+
// check the empty paragraph is the first or last node of its parent.
|
|
105
|
+
if (isEmptyParagraph($insertPos.parent)) {
|
|
106
|
+
if (isLastChild($insertPos, tr.doc)) {
|
|
107
|
+
lookDirection = LookDirection.After;
|
|
108
|
+
} else if (isFirstChild($insertPos, tr.doc)) {
|
|
109
|
+
lookDirection = LookDirection.Before;
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
if ($insertPos.pos === insertPosEnd) {
|
|
113
|
+
lookDirection = LookDirection.After;
|
|
114
|
+
} else if ($insertPos.pos === insertPosStart) {
|
|
115
|
+
lookDirection = LookDirection.Before;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const grandParentNodeType = (_tr$selection$$from$n = tr.selection.$from.node(-1)) === null || _tr$selection$$from$n === void 0 ? void 0 : _tr$selection$$from$n.type;
|
|
119
|
+
const parentNodeType = tr.selection.$from.parent.type;
|
|
120
|
+
|
|
121
|
+
// if there is no direction, and cannot split for this particular node
|
|
122
|
+
const noDirectionAndShouldNotSplit = !lookDirection && !shouldSplitSelectedNodeOnNodeInsertion({
|
|
123
|
+
parentNodeType,
|
|
124
|
+
grandParentNodeType,
|
|
125
|
+
content
|
|
126
|
+
});
|
|
127
|
+
const ruleNodeInANestedListNode = content.type === nodes.rule && selectionIsInNestedList(tr);
|
|
128
|
+
const nonRuleNodeInListNode = !(content.type === nodes.rule) && nodeIsInsideAList(tr);
|
|
129
|
+
if (ruleNodeInANestedListNode || noDirectionAndShouldNotSplit && nonRuleNodeInListNode || noDirectionAndShouldNotSplit && !nodeIsInsideAList(tr)) {
|
|
130
|
+
// node to be inserted is an invalid child of selection so insert below selected node
|
|
131
|
+
return pmSafeInsert(content, tr.selection.from)(tr);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// if node is a rule and that is a flat list splitting and not at the end of a list
|
|
135
|
+
const {
|
|
136
|
+
from,
|
|
137
|
+
to
|
|
138
|
+
} = tr.selection;
|
|
139
|
+
const ruleTypeInAList = content.type === nodes.rule && nodeIsInsideAList(tr);
|
|
140
|
+
if (ruleTypeInAList && !($insertPos.pos === insertPosEnd)) {
|
|
141
|
+
return tr.replaceRange(from, to, new Slice(Fragment.from(nodes.rule.createChecked()), 0, 0));
|
|
142
|
+
}
|
|
143
|
+
if (!lookDirection) {
|
|
144
|
+
// fallback to consumer for now
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Replace empty paragraph
|
|
149
|
+
if (isEmptyParagraph($insertPos.parent) && canInsert(tr.doc.resolve($insertPos[lookDirection]()), content)) {
|
|
150
|
+
return finaliseInsert(tr.replaceWith($insertPos.before(), $insertPos.after(), content), -1);
|
|
151
|
+
}
|
|
152
|
+
let $proposedPosition = $insertPos;
|
|
153
|
+
while ($proposedPosition.depth > 0) {
|
|
154
|
+
const $parentPos = tr.doc.resolve($proposedPosition[lookDirection]());
|
|
155
|
+
const parentNode = $parentPos.node();
|
|
156
|
+
|
|
157
|
+
// Insert at position (before or after target pos)
|
|
158
|
+
if (canInsert($proposedPosition, content)) {
|
|
159
|
+
return finaliseInsert(tr.insert($proposedPosition.pos, content), content.nodeSize);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// If we can't insert, and we think we should split, we fallback to consumer for now
|
|
163
|
+
if (shouldSplit(parentNode.type, tr.doc.type.schema.nodes)) {
|
|
164
|
+
const nextTr = finaliseInsert(insertBeforeOrAfter(tr, lookDirection, $parentPos, $proposedPosition, content), content.nodeSize);
|
|
165
|
+
|
|
166
|
+
// Move selection to the closest text node, otherwise it defaults to the whatever the lookDirection is set to above
|
|
167
|
+
if ([nodes.orderedList, nodes.bulletList].includes(parentNode.type) && nextTr) {
|
|
168
|
+
return nextTr.setSelection(TextSelection.between(nextTr.selection.$from, nextTr.selection.$from));
|
|
169
|
+
} else {
|
|
170
|
+
return nextTr;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Can not insert into current parent, step up one parent
|
|
175
|
+
$proposedPosition = $parentPos;
|
|
176
|
+
}
|
|
177
|
+
return finaliseInsert(tr.insert($proposedPosition.pos, content), content.nodeSize);
|
|
178
|
+
};
|
|
179
|
+
const finaliseInsert = (tr, nodeLength) => {
|
|
180
|
+
const lastStep = tr.steps[tr.steps.length - 1];
|
|
181
|
+
if (!(lastStep instanceof ReplaceStep || lastStep instanceof ReplaceAroundStep)) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Place gap cursor after the newly inserted node
|
|
186
|
+
const gapCursorPos = lastStep.to + lastStep.slice.openStart + nodeLength;
|
|
187
|
+
return tr.setSelection(new GapCursorSelection(tr.doc.resolve(gapCursorPos), Side.RIGHT)).scrollIntoView();
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Method extracted from typeahed plugin to be shared with the element browser on handling element insertion.
|
|
192
|
+
*/
|
|
193
|
+
export const insertSelectedItem = (maybeNode, opts = {}) => (state, tr, start) => {
|
|
194
|
+
if (!maybeNode) {
|
|
195
|
+
return tr;
|
|
196
|
+
}
|
|
197
|
+
const isInputFragment = maybeNode instanceof Fragment;
|
|
198
|
+
let node;
|
|
199
|
+
try {
|
|
200
|
+
node = maybeNode instanceof Node || isInputFragment ? maybeNode : typeof maybeNode === 'string' ? state.schema.text(maybeNode) : Node.fromJSON(state.schema, maybeNode);
|
|
201
|
+
} catch (e) {
|
|
202
|
+
// eslint-disable-next-line no-console
|
|
203
|
+
console.error(e);
|
|
204
|
+
return tr;
|
|
205
|
+
}
|
|
206
|
+
if (node.isText) {
|
|
207
|
+
tr = tr.replaceWith(start, start, node);
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
*
|
|
211
|
+
* Replacing a type ahead query mark with a block node.
|
|
212
|
+
*
|
|
213
|
+
*/
|
|
214
|
+
} else if (node.isBlock) {
|
|
215
|
+
/**
|
|
216
|
+
*
|
|
217
|
+
* Rule has unique insertion behaviour
|
|
218
|
+
* so using this safeInsert function in order to handle specific cases in flat list vs nested list
|
|
219
|
+
* instead of a generic pmSafeInsert (i.e appending at the end)
|
|
220
|
+
*
|
|
221
|
+
*/
|
|
222
|
+
|
|
223
|
+
const selectionInsideAPanel = selectionIsInsideAPanel(tr);
|
|
224
|
+
if (node.type.name === 'rule' && !selectionInsideAPanel) {
|
|
225
|
+
var _safeInsert;
|
|
226
|
+
tr = (_safeInsert = safeInsert(node, tr.selection.from)(tr)) !== null && _safeInsert !== void 0 ? _safeInsert : tr;
|
|
227
|
+
} else {
|
|
228
|
+
tr = pmSafeInsert(normaliseNestedLayout(state, node), undefined, true)(tr);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
*
|
|
233
|
+
* Replacing a type ahead query mark with an inline node.
|
|
234
|
+
*
|
|
235
|
+
*/
|
|
236
|
+
} else if (node.isInline || isInputFragment) {
|
|
237
|
+
const fragment = isInputFragment ? node : Fragment.fromArray([node, state.schema.text(' ')]);
|
|
238
|
+
tr = tr.replaceWith(start, start, fragment);
|
|
239
|
+
if (opts.selectInlineNode) {
|
|
240
|
+
// Select inserted node
|
|
241
|
+
tr = tr.setSelection(NodeSelection.create(tr.doc, start));
|
|
242
|
+
} else {
|
|
243
|
+
// Placing cursor after node + space.
|
|
244
|
+
tr = tr.setSelection(Selection.near(tr.doc.resolve(start + fragment.size)));
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return tr;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* ED-14584: Util to check if the destination node is a paragraph & the
|
|
252
|
+
* content being inserted is a valid child of the grandparent node.
|
|
253
|
+
* In this case, the destination node should split
|
|
254
|
+
*/
|
|
255
|
+
export const shouldSplitSelectedNodeOnNodeInsertion = ({
|
|
256
|
+
parentNodeType,
|
|
257
|
+
grandParentNodeType,
|
|
258
|
+
content
|
|
259
|
+
}) => {
|
|
260
|
+
if (parentNodeType.name === 'doc' || parentNodeType.name === 'paragraph' && grandParentNodeType.validContent(Fragment.from(content))) {
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
return false;
|
|
264
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
2
|
+
const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
3
|
+
const packageVersion = "74.1.1";
|
|
4
|
+
const sanitiseSentryEvents = (data, _hint) => {
|
|
5
|
+
// Remove URL as it has UGC
|
|
6
|
+
// TODO: Sanitise the URL instead of just removing it
|
|
7
|
+
if (data.request) {
|
|
8
|
+
delete data.request.url;
|
|
9
|
+
}
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
export const logException = async (error, tags) => {
|
|
13
|
+
try {
|
|
14
|
+
var _process$env$CLOUD_EN;
|
|
15
|
+
// We don't want to log exceptions for branch deploys or in development / test scenarios
|
|
16
|
+
if (process.env.NODE_ENV !== 'production' || process.env.CLOUD_ENV === 'branch') {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const {
|
|
20
|
+
BrowserClient,
|
|
21
|
+
defaultIntegrations,
|
|
22
|
+
getCurrentHub
|
|
23
|
+
} = await import( /* webpackChunkName: "@atlaskit-internal_editor-sentrybrowser" */'@sentry/browser');
|
|
24
|
+
const {
|
|
25
|
+
ExtraErrorData
|
|
26
|
+
} = await import( /* webpackChunkName: "@atlaskit-internal_editor-sentryintegrations" */'@sentry/integrations');
|
|
27
|
+
const sentryOptions = {
|
|
28
|
+
dsn: SENTRY_DSN,
|
|
29
|
+
release: `${packageName}@${packageVersion}`,
|
|
30
|
+
environment: (_process$env$CLOUD_EN = process.env.CLOUD_ENV) !== null && _process$env$CLOUD_EN !== void 0 ? _process$env$CLOUD_EN : 'unknown',
|
|
31
|
+
ignoreErrors: [
|
|
32
|
+
// Network issues
|
|
33
|
+
/^network error/i, /^network failure/i, 'TypeError: Failed to fetch',
|
|
34
|
+
// A benign error, see https://stackoverflow.com/a/50387233/2645305
|
|
35
|
+
'ResizeObserver loop limit exceeded', /ResizeObserver loop completed with undelivered notifications/],
|
|
36
|
+
autoSessionTracking: false,
|
|
37
|
+
integrations: _integrations => [
|
|
38
|
+
// Remove the Breadcrumbs integration from the default as it's too likely to log UGC/PII
|
|
39
|
+
// https://docs.sentry.io/platforms/javascript/configuration/integrations/default/
|
|
40
|
+
...defaultIntegrations.filter(({
|
|
41
|
+
name
|
|
42
|
+
}) => name !== 'Breadcrumbs'),
|
|
43
|
+
// Extracts all non-native attributes from the error object and attaches them to the event as the extra data
|
|
44
|
+
// https://docs.sentry.io/platforms/javascript/configuration/integrations/plugin/?original_referrer=https%3A%2F%2Fduckduckgo.com%2F#extraerrordata
|
|
45
|
+
new ExtraErrorData()],
|
|
46
|
+
beforeSend: sanitiseSentryEvents
|
|
47
|
+
};
|
|
48
|
+
// Use a client to avoid picking up the errors from parent applications
|
|
49
|
+
const client = new BrowserClient(sentryOptions);
|
|
50
|
+
const hub = getCurrentHub();
|
|
51
|
+
hub.bindClient(client);
|
|
52
|
+
hub.withScope(scope => {
|
|
53
|
+
scope.setTags({
|
|
54
|
+
// Jira environment variables
|
|
55
|
+
'jira-bundler': window.BUNDLER_VERSION,
|
|
56
|
+
'jira-variant': window.BUILD_VARIANT,
|
|
57
|
+
'jira-release': window.BUILD_KEY,
|
|
58
|
+
// Confluence environment variables
|
|
59
|
+
'confluence-frontend-version': window.__buildInfo.FRONTEND_VERSION,
|
|
60
|
+
...tags
|
|
61
|
+
});
|
|
62
|
+
hub.captureException(error);
|
|
63
|
+
});
|
|
64
|
+
return client.close();
|
|
65
|
+
} catch (_error) {
|
|
66
|
+
// Error reporting failed, we don't want this to generate more errors
|
|
67
|
+
}
|
|
68
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { logException } from './error';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { findParentNodeOfTypeClosestToPos } from 'prosemirror-utils';
|
|
2
2
|
import { akEditorFullWidthLayoutWidth, akLayoutGutterOffset, gridMediumMaxWidth } from '@atlaskit/editor-shared-styles';
|
|
3
|
+
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
|
|
3
4
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
4
5
|
import { BODIED_EXT_PADDING } from '../styles/shared/extension';
|
|
5
6
|
import { LAYOUT_COLUMN_PADDING, LAYOUT_SECTION_MARGIN } from '../styles/shared/layout';
|
|
@@ -49,6 +50,9 @@ export const getParentNodeWidth = (pos, state, containerWidth, isFullWidthModeEn
|
|
|
49
50
|
case schema.nodes.bodiedExtension:
|
|
50
51
|
parentWidth -= BODIED_EXT_PADDING * 2;
|
|
51
52
|
break;
|
|
53
|
+
|
|
54
|
+
// TODO: Migrate away from gridSize
|
|
55
|
+
// Recommendation: Replace gridSize with 8
|
|
52
56
|
case schema.nodes.expand:
|
|
53
57
|
// padding
|
|
54
58
|
parentWidth -= gridSize() * 2;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { md } from './md';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ED-15646
|
|
3
|
+
* Headings in list items are not supported in our schema.
|
|
4
|
+
* As the markdown transformer is used by the paste plugin,
|
|
5
|
+
* certain pastes will strip invalid lines as
|
|
6
|
+
* prosemirror-markdown cannot conform to the schema
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
function handleHeadingOpen(state, token, acc, index) {
|
|
10
|
+
var _state$tokens;
|
|
11
|
+
const isInListItem = ((_state$tokens = state.tokens[index - 1]) === null || _state$tokens === void 0 ? void 0 : _state$tokens.type) === 'list_item_open';
|
|
12
|
+
if (isInListItem) {
|
|
13
|
+
acc.push(new state.Token('paragraph_open', 'p', 1));
|
|
14
|
+
} else {
|
|
15
|
+
acc.push(token);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function handleHeadingClose(state, token, acc, index) {
|
|
19
|
+
var _state$tokens2;
|
|
20
|
+
const isInListItem = ((_state$tokens2 = state.tokens[index + 1]) === null || _state$tokens2 === void 0 ? void 0 : _state$tokens2.type) === 'list_item_close';
|
|
21
|
+
if (isInListItem) {
|
|
22
|
+
acc.push(new state.Token('paragraph_close', 'p', -1));
|
|
23
|
+
} else {
|
|
24
|
+
acc.push(token);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export default function (md) {
|
|
28
|
+
md.core.ruler.after('inline', 'ignore-list-heading-md-plugin', function (state) {
|
|
29
|
+
state.tokens = state.tokens.reduce((acc, token, index) => {
|
|
30
|
+
const {
|
|
31
|
+
type
|
|
32
|
+
} = token;
|
|
33
|
+
if (type === 'heading_open') {
|
|
34
|
+
handleHeadingOpen(state, token, acc, index);
|
|
35
|
+
} else if (type === 'heading_close') {
|
|
36
|
+
handleHeadingClose(state, token, acc, index);
|
|
37
|
+
} else {
|
|
38
|
+
acc.push(token);
|
|
39
|
+
}
|
|
40
|
+
return acc;
|
|
41
|
+
}, []);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// File has been copied to packages/editor/editor-plugin-ai/src/provider/markdown-transformer/md/linkify-md-plugin.ts
|
|
2
|
+
// If changes are made to this file, please make the same update in the linked file.
|
|
3
|
+
|
|
4
|
+
import LinkifyIt from 'linkify-it';
|
|
5
|
+
import { linkifyMatch } from '@atlaskit/adf-schema';
|
|
6
|
+
import { findFilepaths, isLinkInMatches } from '../../utils';
|
|
7
|
+
|
|
8
|
+
// modified version of the original Linkify plugin
|
|
9
|
+
// https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.js
|
|
10
|
+
const arrayReplaceAt = (src, pos, newElements) => {
|
|
11
|
+
return [].concat(src.slice(0, pos), newElements, src.slice(pos + 1));
|
|
12
|
+
};
|
|
13
|
+
const isLinkOpen = str => {
|
|
14
|
+
return /^<a[>\s]/i.test(str);
|
|
15
|
+
};
|
|
16
|
+
const isLinkClose = str => {
|
|
17
|
+
return /^<\/a\s*>/i.test(str);
|
|
18
|
+
};
|
|
19
|
+
const linkify = state => {
|
|
20
|
+
const blockTokens = state.tokens;
|
|
21
|
+
const linkify = new LinkifyIt();
|
|
22
|
+
for (let j = 0, l = blockTokens.length; j < l; j++) {
|
|
23
|
+
if (blockTokens[j].type !== 'inline' || !linkify.pretest(blockTokens[j].content)) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
let tokens = blockTokens[j].children;
|
|
27
|
+
let htmlLinkLevel = 0;
|
|
28
|
+
|
|
29
|
+
// We scan from the end, to keep position when new tags added.
|
|
30
|
+
// Use reversed logic in links start/end match
|
|
31
|
+
for (let i = tokens.length - 1; i >= 0; i--) {
|
|
32
|
+
const currentToken = tokens[i];
|
|
33
|
+
|
|
34
|
+
// Skip content of markdown links
|
|
35
|
+
if (currentToken.type === 'link_close') {
|
|
36
|
+
i--;
|
|
37
|
+
while (tokens[i].level !== currentToken.level && tokens[i].type !== 'link_open') {
|
|
38
|
+
i--;
|
|
39
|
+
}
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Skip content of html tag links
|
|
44
|
+
if (currentToken.type === 'html_inline') {
|
|
45
|
+
if (isLinkOpen(currentToken.content) && htmlLinkLevel > 0) {
|
|
46
|
+
htmlLinkLevel--;
|
|
47
|
+
}
|
|
48
|
+
if (isLinkClose(currentToken.content)) {
|
|
49
|
+
htmlLinkLevel++;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (htmlLinkLevel > 0) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (currentToken.type === 'text' && linkify.test(currentToken.content)) {
|
|
56
|
+
const text = currentToken.content;
|
|
57
|
+
let links = linkifyMatch(text);
|
|
58
|
+
if (!links.length) {
|
|
59
|
+
links = linkify.match(text) || [];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Now split string to nodes
|
|
63
|
+
const nodes = [];
|
|
64
|
+
let level = currentToken.level;
|
|
65
|
+
let lastPos = 0;
|
|
66
|
+
const filepaths = findFilepaths(text);
|
|
67
|
+
for (let ln = 0; ln < links.length; ln++) {
|
|
68
|
+
if (isLinkInMatches(links[ln].index, filepaths)) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const {
|
|
72
|
+
url
|
|
73
|
+
} = links[ln];
|
|
74
|
+
const fullUrl = state.md.normalizeLink(url);
|
|
75
|
+
if (!state.md.validateLink(fullUrl)) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
let urlText = links[ln].text;
|
|
79
|
+
|
|
80
|
+
// Linkifier might send raw hostnames like "example.com", where url
|
|
81
|
+
// starts with domain name. So we prepend http:// in those cases,
|
|
82
|
+
// and remove it afterwards.
|
|
83
|
+
//
|
|
84
|
+
if (!links[ln].schema) {
|
|
85
|
+
urlText = state.md.normalizeLinkText('http://' + urlText).replace(/^http:\/\//, '');
|
|
86
|
+
} else if (links[ln].schema === 'mailto:' && !/^mailto:/i.test(urlText)) {
|
|
87
|
+
urlText = state.md.normalizeLinkText('mailto:' + urlText).replace(/^mailto:/, '');
|
|
88
|
+
} else {
|
|
89
|
+
urlText = state.md.normalizeLinkText(urlText);
|
|
90
|
+
}
|
|
91
|
+
const pos = links[ln].index;
|
|
92
|
+
if (pos > lastPos) {
|
|
93
|
+
const token = new state.Token('text', '', 0);
|
|
94
|
+
token.content = text.slice(lastPos, pos);
|
|
95
|
+
token.level = level;
|
|
96
|
+
nodes.push(token);
|
|
97
|
+
}
|
|
98
|
+
let token = new state.Token('link_open', 'a', 1);
|
|
99
|
+
token.attrs = [['href', fullUrl]];
|
|
100
|
+
token.level = level++;
|
|
101
|
+
token.markup = 'linkify';
|
|
102
|
+
token.info = 'auto';
|
|
103
|
+
nodes.push(token);
|
|
104
|
+
token = new state.Token('text', '', 0);
|
|
105
|
+
token.content = urlText;
|
|
106
|
+
token.level = level;
|
|
107
|
+
nodes.push(token);
|
|
108
|
+
token = new state.Token('link_close', 'a', -1);
|
|
109
|
+
token.level = --level;
|
|
110
|
+
token.markup = 'linkify';
|
|
111
|
+
token.info = 'auto';
|
|
112
|
+
nodes.push(token);
|
|
113
|
+
lastPos = links[ln].lastIndex;
|
|
114
|
+
}
|
|
115
|
+
if (lastPos < text.length) {
|
|
116
|
+
const token = new state.Token('text', '', 0);
|
|
117
|
+
token.content = text.slice(lastPos);
|
|
118
|
+
token.level = level;
|
|
119
|
+
nodes.push(token);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// replace current node
|
|
123
|
+
blockTokens[j].children = tokens = arrayReplaceAt(tokens, i, nodes);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
export default (md => md.core.ruler.push('custom-linkify', linkify));
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// File has been copied to packages/editor/editor-plugin-ai/src/provider/markdown-transformer/md/newline-md-plugin.ts
|
|
2
|
+
// If changes are made to this file, please make the same update in the linked file.
|
|
3
|
+
|
|
4
|
+
// ED-15363: modified version of the original newline plugin
|
|
5
|
+
// https://github.com/markdown-it/markdown-it/blob/master/lib/rules_inline/newline.js
|
|
6
|
+
const newline = (state, silent) => {
|
|
7
|
+
let pmax,
|
|
8
|
+
// ED-15363: unread variables
|
|
9
|
+
// max,
|
|
10
|
+
// ws,
|
|
11
|
+
pos = state.pos;
|
|
12
|
+
if (state.src.charCodeAt(pos) !== 0x0a /* \n */) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
pmax = state.pending.length - 1;
|
|
16
|
+
// ED-15363: unread variable
|
|
17
|
+
// max = state.posMax;
|
|
18
|
+
|
|
19
|
+
// ' \n' -> hardbreak
|
|
20
|
+
// Lookup in pending chars is bad practice! Don't copy to other rules!
|
|
21
|
+
// Pending string is stored in concat mode, indexed lookups will cause
|
|
22
|
+
// convertion to flat mode.
|
|
23
|
+
if (!silent) {
|
|
24
|
+
if (pmax >= 0 && state.pending.charCodeAt(pmax) === 0x20) {
|
|
25
|
+
if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 0x20) {
|
|
26
|
+
// ED-15363: We commented out this logic to preserve trailing whitespaces
|
|
27
|
+
// for each line of text when pasting plain text
|
|
28
|
+
|
|
29
|
+
// // Find whitespaces tail of pending chars.
|
|
30
|
+
// ws = pmax - 1;
|
|
31
|
+
// while (ws >= 1 && state.pending.charCodeAt(ws - 1) === 0x20) {
|
|
32
|
+
// ws--;
|
|
33
|
+
// }
|
|
34
|
+
// state.pending = state.pending.slice(0, ws);
|
|
35
|
+
state.push('hardbreak', 'br', 0);
|
|
36
|
+
} else {
|
|
37
|
+
state.pending = state.pending.slice(0, -1);
|
|
38
|
+
state.push('softbreak', 'br', 0);
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
state.push('softbreak', 'br', 0);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
pos++;
|
|
45
|
+
|
|
46
|
+
// ED-15363: We commented out this logic from the original library to
|
|
47
|
+
// preserve leading whitespaces for each line of text when pasting plain
|
|
48
|
+
// text (to preserve whitespace-based indentation).
|
|
49
|
+
|
|
50
|
+
// // skip heading spaces for next line
|
|
51
|
+
// while (pos < max && isSpace(state.src.charCodeAt(pos))) {
|
|
52
|
+
// pos++;
|
|
53
|
+
// }
|
|
54
|
+
|
|
55
|
+
state.pos = pos;
|
|
56
|
+
return true;
|
|
57
|
+
};
|
|
58
|
+
export default (md => md.inline.ruler.at('newline', newline));
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// File has been copied to packages/editor/editor-plugin-ai/src/provider/markdown-transformer/md/paragraph-md-plugin.ts
|
|
2
|
+
// If changes are made to this file, please make the same update in the linked file.
|
|
3
|
+
|
|
4
|
+
// ED-15363: modified version of the original paragraph plugin
|
|
5
|
+
// https://github.com/markdown-it/markdown-it/blob/master/lib/rules_block/paragraph.js
|
|
6
|
+
|
|
7
|
+
const paragraph = (state, startLine) => {
|
|
8
|
+
let content,
|
|
9
|
+
terminate,
|
|
10
|
+
i,
|
|
11
|
+
l,
|
|
12
|
+
token,
|
|
13
|
+
oldParentType,
|
|
14
|
+
nextLine = startLine + 1,
|
|
15
|
+
terminatorRules = state.md.block.ruler.getRules('paragraph'),
|
|
16
|
+
endLine = state.lineMax;
|
|
17
|
+
oldParentType = state.parentType;
|
|
18
|
+
state.parentType = 'paragraph';
|
|
19
|
+
|
|
20
|
+
// jump line-by-line until empty one or EOF
|
|
21
|
+
for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
|
|
22
|
+
// this would be a code block normally, but after paragraph
|
|
23
|
+
// it's considered a lazy continuation regardless of what's there
|
|
24
|
+
if (state.sCount[nextLine] - state.blkIndent > 3) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// quirk for blockquotes, this line should already be checked by that rule
|
|
29
|
+
if (state.sCount[nextLine] < 0) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Some tags can terminate paragraph without empty line.
|
|
34
|
+
terminate = false;
|
|
35
|
+
for (i = 0, l = terminatorRules.length; i < l; i++) {
|
|
36
|
+
if (terminatorRules[i](state, nextLine, endLine, true)) {
|
|
37
|
+
terminate = true;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (terminate) {
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ED-15363: We removed .trim() from this logic from the original library to
|
|
47
|
+
// preserve leading whitespaces at the beginning and end of paragraph blocks
|
|
48
|
+
// when pasting plain text (to preserve whitespace-based indentation, at the
|
|
49
|
+
// beginning and end of paragraphs).
|
|
50
|
+
|
|
51
|
+
// content = state.getLines(startLine, nextLine, state.blkIndent, false) .trim()
|
|
52
|
+
content = state.getLines(startLine, nextLine, state.blkIndent, false);
|
|
53
|
+
state.line = nextLine;
|
|
54
|
+
token = state.push('paragraph_open', 'p', 1);
|
|
55
|
+
token.map = [startLine, state.line];
|
|
56
|
+
token = state.push('inline', '', 0);
|
|
57
|
+
token.content = content;
|
|
58
|
+
token.map = [startLine, state.line];
|
|
59
|
+
token.children = [];
|
|
60
|
+
token = state.push('paragraph_close', 'p', -1);
|
|
61
|
+
state.parentType = oldParentType;
|
|
62
|
+
return true;
|
|
63
|
+
};
|
|
64
|
+
export default (md => md.block.ruler.at('paragraph', paragraph));
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// File has been copied to packages/editor/editor-plugin-ai/src/provider/markdown-transformer/md/index.ts
|
|
2
|
+
// If changes are made to this file, please make the same update in the linked file.
|
|
3
|
+
import MarkdownIt from 'markdown-it';
|
|
4
|
+
import ignoreListHeading from './md-plugins/ignore-list-heading-md-plugin';
|
|
5
|
+
import linkify from './md-plugins/linkify-md-plugin';
|
|
6
|
+
import newline from './md-plugins/newline-md-plugin';
|
|
7
|
+
import paragraph from './md-plugins/paragraph-md-plugin';
|
|
8
|
+
export const md = MarkdownIt('zero', {
|
|
9
|
+
html: false
|
|
10
|
+
});
|
|
11
|
+
md.enable([
|
|
12
|
+
// Process html entity - {, ¯, ", ...
|
|
13
|
+
'entity',
|
|
14
|
+
// Process escaped chars and hardbreaks
|
|
15
|
+
'escape', 'newline']);
|
|
16
|
+
md.use(paragraph);
|
|
17
|
+
|
|
18
|
+
// enable modified version of linkify plugin
|
|
19
|
+
// @see https://product-fabric.atlassian.net/browse/ED-3097
|
|
20
|
+
md.use(linkify);
|
|
21
|
+
md.use(newline);
|
|
22
|
+
md.use(ignoreListHeading);
|