@worktile/theia 19.3.5 → 19.4.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.
|
@@ -10,7 +10,7 @@ import { cloneDeep, map, assign, defaults, groupBy, uniq, isEqual } from 'lodash
|
|
|
10
10
|
export { assign, cloneDeep, debounce, defaults, groupBy, isEqual, map, uniq } from 'lodash';
|
|
11
11
|
import { Editor, Element, Span, Range, Path, Node, Point, Text, Transforms, Operation, createEditor } from 'slate';
|
|
12
12
|
import * as i4 from 'slate-angular';
|
|
13
|
-
import { FAKE_LEFT_BLOCK_CARD_OFFSET, FAKE_RIGHT_BLOCK_CARD_OFFSET, getClipboardData, AngularEditor, hotkeys, getPlainText as getPlainText$1, createClipboardData, setClipboardData,
|
|
13
|
+
import { FAKE_LEFT_BLOCK_CARD_OFFSET, FAKE_RIGHT_BLOCK_CARD_OFFSET, getClipboardData, AngularEditor, hotkeys, getPlainText as getPlainText$1, createClipboardData, setClipboardData, BaseElementComponent, IS_SAFARI, ELEMENT_TO_COMPONENT, BaseTextComponent, SlateModule, hasBlockCard, isCardLeft, SlateChildrenOutlet, defaultScrollSelectionIntoView, getDataTransferClipboard, withAngular } from 'slate-angular';
|
|
14
14
|
import { HistoryEditor, withHistory } from 'slate-history';
|
|
15
15
|
import { NODE_TO_PARENT, NODE_TO_INDEX, NODE_TO_ELEMENT, EDITOR_TO_ELEMENT } from 'slate-dom';
|
|
16
16
|
import { TheiaConverter } from '@atinc/selene';
|
|
@@ -1772,6 +1772,18 @@ const extractFragment = async (data, deleteKey = ELEMENT_UNIQUE_ID) => {
|
|
|
1772
1772
|
}
|
|
1773
1773
|
return null;
|
|
1774
1774
|
};
|
|
1775
|
+
const extractFragmentByHTML = async (data, deleteKey = ELEMENT_UNIQUE_ID) => {
|
|
1776
|
+
const clipboardData = await getClipboardData(data);
|
|
1777
|
+
let elements = clipboardData?.elements;
|
|
1778
|
+
if (!elements && clipboardData?.html) {
|
|
1779
|
+
const htmlDom = new DOMParser().parseFromString(clipboardData?.html, 'text/html');
|
|
1780
|
+
const fragment = TheiaConverter.convertToTheia(Array.from(htmlDom.body.children));
|
|
1781
|
+
if (fragment && fragment.length > 0) {
|
|
1782
|
+
return fragment;
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
return null;
|
|
1786
|
+
};
|
|
1775
1787
|
function deleteElementKey(nodes, key) {
|
|
1776
1788
|
nodes.forEach(node => {
|
|
1777
1789
|
if (node[key]) {
|
|
@@ -2206,10 +2218,6 @@ const setClipboardDataByDom = async (e, fragment, data) => {
|
|
|
2206
2218
|
function copyNode(e, element, thyNotifyService, locale) {
|
|
2207
2219
|
const copyFailTips = (locale && locale() && locale().copyFailed) ?? '复制失败';
|
|
2208
2220
|
const copySuccessTips = (locale && locale() && locale().copySuccess) ?? '复制成功';
|
|
2209
|
-
if (!isClipboardWriteSupported()) {
|
|
2210
|
-
thyNotifyService?.error(copyFailTips);
|
|
2211
|
-
return;
|
|
2212
|
-
}
|
|
2213
2221
|
const fragment = cloneDeep(element);
|
|
2214
2222
|
return setClipboardDataByDom(e, fragment)
|
|
2215
2223
|
.then(() => {
|
|
@@ -11120,27 +11128,28 @@ const createResetTypePlugin = createPluginFactory({
|
|
|
11120
11128
|
const withDeserializeHTML = (editor) => {
|
|
11121
11129
|
const { customInsertFragmentData } = editor;
|
|
11122
11130
|
editor.customInsertFragmentData = async (data) => {
|
|
11123
|
-
const
|
|
11124
|
-
if (
|
|
11125
|
-
const htmlDom = new DOMParser().parseFromString(clipboardData?.html, 'text/html');
|
|
11126
|
-
const fragment = TheiaConverter.convertToTheia(Array.from(htmlDom.body.children));
|
|
11131
|
+
const fragmentFromHTML = await extractFragmentByHTML(data);
|
|
11132
|
+
if (fragmentFromHTML) {
|
|
11127
11133
|
// 识别粘贴的 HTML 只有纯链接, 跳至 link
|
|
11128
|
-
if (
|
|
11134
|
+
if (fragmentFromHTML.length === 1 && fragmentFromHTML.every(block => isUrl(block?.children?.[0]?.['text']))) {
|
|
11129
11135
|
return customInsertFragmentData(data);
|
|
11130
11136
|
}
|
|
11131
11137
|
// 无法识别HTML内容时后退一下:识别纯文本
|
|
11132
|
-
if (
|
|
11138
|
+
if (fragmentFromHTML.every(block => block.type === ElementKinds.paragraph && isLogicEmptyParagraphElement(editor, block))) {
|
|
11133
11139
|
return customInsertFragmentData(data);
|
|
11134
11140
|
}
|
|
11135
11141
|
// 识出纯图片并且粘贴板中存在文件则不进行处理, hook 直接右键复制图片的场景,流转到上传图片流程
|
|
11136
11142
|
// 后续需要做识别html图片后自动上传处理
|
|
11137
|
-
if (
|
|
11143
|
+
if (fragmentFromHTML.length === 1 && fragmentFromHTML[0].type === ElementKinds.image && data.files.length > 0) {
|
|
11144
|
+
return customInsertFragmentData(data);
|
|
11145
|
+
}
|
|
11146
|
+
if (fragmentFromHTML.length === 1 && fragmentFromHTML[0].type === ElementKinds.table) {
|
|
11138
11147
|
return customInsertFragmentData(data);
|
|
11139
11148
|
}
|
|
11140
11149
|
// 过滤 text 节点的 color/background-color 属性
|
|
11141
|
-
|
|
11150
|
+
fragmentFromHTML.forEach(node => filterTextFormat(node));
|
|
11142
11151
|
// base 64 图片处理
|
|
11143
|
-
recursionNodes(
|
|
11152
|
+
recursionNodes(fragmentFromHTML, (node) => {
|
|
11144
11153
|
const isImage = Element.isElement(node) && node.type === ElementKinds.image;
|
|
11145
11154
|
if (isImage) {
|
|
11146
11155
|
const isBase64 = ImageEditor.isBase64(node?.originUrl);
|
|
@@ -11152,11 +11161,11 @@ const withDeserializeHTML = (editor) => {
|
|
|
11152
11161
|
}
|
|
11153
11162
|
}
|
|
11154
11163
|
});
|
|
11155
|
-
const isContinue = insertDataByInvalidType(editor,
|
|
11164
|
+
const isContinue = insertDataByInvalidType(editor, fragmentFromHTML);
|
|
11156
11165
|
if (!isContinue) {
|
|
11157
11166
|
return true;
|
|
11158
11167
|
}
|
|
11159
|
-
Transforms.insertFragment(editor,
|
|
11168
|
+
Transforms.insertFragment(editor, fragmentFromHTML);
|
|
11160
11169
|
return true;
|
|
11161
11170
|
}
|
|
11162
11171
|
return customInsertFragmentData(data);
|
|
@@ -17765,7 +17774,10 @@ const withTable = (editor) => {
|
|
|
17765
17774
|
setFragmentData(data, originEvent);
|
|
17766
17775
|
};
|
|
17767
17776
|
editor.customInsertFragmentData = async (data) => {
|
|
17768
|
-
|
|
17777
|
+
let fragment = await extractFragment(data);
|
|
17778
|
+
if (!fragment) {
|
|
17779
|
+
fragment = await extractFragmentByHTML(data);
|
|
17780
|
+
}
|
|
17769
17781
|
if (fragment) {
|
|
17770
17782
|
const opts = new TableOptions();
|
|
17771
17783
|
if (isSelectionInTable(opts, editor) &&
|
|
@@ -18970,5 +18982,5 @@ const withTestPlugin = (plugins, initValue) => {
|
|
|
18970
18982
|
* Generated bundle index. Do not edit.
|
|
18971
18983
|
*/
|
|
18972
18984
|
|
|
18973
|
-
export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETE_BACKWARD_TYPES, BLOCK_HIDDEN_CLASS, BasicTest, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, ColorEditor, ColumnResizeNotifierSource, ColumnResizingStore, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DISABLED_OPERATE_TYPES, DataTransferFaker, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DropdownMode, ELEMENT_UNIQUE_ID, EditorPresetConfigFactoryMock, ElementKinds, ErrorCodes, FontSizeTypes, FontSizes, HEADING_TYPES, HeaderLevelMap, HeadingEditor, HoveredCellInfo, HrEditor, IS_MAC, ImageEditor, IndentEditor, Indents, InlineCodeEditor, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LOWEST_TEXT_CONTAINER_TYPES, LayoutTypes, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, MentionEditor, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PluginKeys, PluginMenuIcons, PluginMenuSvgs, Position, QUICK_INSERT_HOTKEY, QuickInsertEditor, ResizeRef, SLA_TABLE_CELL_SELECTOR, SLA_TABLE_SELECTOR, STANDARD_HEADING_TYPES, ScrollDirection, SpecialBackgroundColor, TAB_SPACE, THE_EDITOR_BG_COLOR, THE_EDITOR_COLOR, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_ORIGIN_ANCHOR, THE_EDITOR_POPOVER_REF, THE_EDITOR_PREVIOUS_SELECTION, THE_EDITOR_UUID, THE_I18N_DE_DE, THE_I18N_EN_US, THE_I18N_JA_JP, THE_I18N_LOCALE_ID, THE_I18N_RU_RU, THE_I18N_ZH_HANS, THE_I18N_ZH_HANT, THE_IMAGE_SERVICE_TOKEN, THE_LISTBOX_PARENT_GROUP_TOKEN, THE_LISTBOX_PARENT_OPTION_TOKEN, THE_LISTBOX_TOKEN, THE_MODE_PROVIDER, THE_MODE_TOKEN, THE_PLUGIN_MENU_REF, THE_PRESET_CONFIG_TOKEN, TableCellEventDispatcher, TableEditor, TableHeaderBackgroundColor, TablePosition, TheBaseElement, TheBaseSuggestion, TheBaseToolbarDropdown, TheBaseToolbarItem, TheColumnResizeDirective, TheColumnResizeOverlayHandle, TheContextMenu, TheContextService, TheConversionHint, TheDataMode, TheDefaultElement, TheEditor, TheEditorComponent, TheEditorModule, TheI18nService, TheImage, TheInlineToolbar, TheListboxDirective, TheListboxGroupDirective, TheListboxOptionDirective, TheLocaleType, TheMode, TheModeConfig, ThePluginMenu, ThePluginMenuComponent, ThePluginMenuItemType, ThePreventDefaultDirective, index$1 as TheQueries, TheQuickInsert, TheTableSelect, TheTemplate, TheText, TheToolbarComponent, TheToolbarDropdown, TheToolbarGroup, TheToolbarGroupToken, TheToolbarItem, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, autoFocus, base64toBlob, bottomLeftPosition, bottomRightPosition, buildPluginMenu, buildPluginMenuItemMap, buildQuickInsertMenus, calcPrintColumnWidth, calcSpanForColumn, calcSpanForRow, calculateHeaderRowHeight, calculateRowControls, coercePixelsFromCssValue, combinePlugins, copyNode, createCell, createEmptyContent, createEmptyParagraph, createMentionPlugin, createPluginFactory, createRow, createTable, createTablePosition, createTest1Plugin, createTestPlugin, createToolbar, createVerticalAlignPlugin, customPluginMock, customPluginMockKey, dataDeserialize, dataSerializing, deDeLocale, deleteElementKey, enUsLocale, errorImageUrlMock, expandPreviousHeadings, extractFragment, filterTextFormat, fixBlockWithoutParagraph, fixBlockWithoutText, flattenDeepPlugins, getCellPositionsFromRange, getCollapsedStandardHeadingAbove, getColsTotalWidth, getColumnsWidth, getDirtyElements, getEditorScrollContainer, getEditorUUID, getElementClassByPrefix, getElementHeight, getElementWidth, getEndBlock, getFollowElements, getGridColumns, getMode, getNextCell, getOriginCell, getPlugin, getPluginOptions, getPlugins, getPreviousRelatedHeadingElements, getRowsTotalHeight, getSelectCellNode, getSelectedCellPositions, getStartBlock, getTableByCell, getTableByRow, getTheDefaultPluginMenu, getToolbarClass, hasHeaderRow, headingOptions, htmlToTheia, idCreator, inValidTypes, initializeDefaultMenuIcons, injectTranslations, insertDataByInvalidType, internalPlugins, isCleanEmptyParagraph, isColorIndicator, isColorInput, isColorPanel, isDirectionKeydown, isHeadingElement, isInside, isMobileMode, isPrintMode, isPureEmptyParagraph, isRangeInTable, isRectangularInTableCells, isSelectedAllCell, isSelectionInTable, isStandardHeadingElement, isStandardHeadingElementByType, isUrl, isVirtualKey, jaJpLocale, matchOptions, mergeArray, mergeDeepPlugins, mergeElementOptions, mergeOptions, nestedStructureByKey, normalizeValue, originOptions, plainToTheia, pluginKey, pluginKey1, pluginsByKey, reSelection, recursionNodes, refocus, ruRuLocale, setClipboardDataByDom, setEditorUUID, theTethysIconRegistryFaker, toggleHeadingRelatedElement, topLeftPosition, topRightPosition, uniqueCellPosition, updatePopoverPosition, useElementStyle, withMention, withTestPlugin, withTheia, zhHansLocale, zhHantLocale };
|
|
18985
|
+
export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETE_BACKWARD_TYPES, BLOCK_HIDDEN_CLASS, BasicTest, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, ColorEditor, ColumnResizeNotifierSource, ColumnResizingStore, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DISABLED_OPERATE_TYPES, DataTransferFaker, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DropdownMode, ELEMENT_UNIQUE_ID, EditorPresetConfigFactoryMock, ElementKinds, ErrorCodes, FontSizeTypes, FontSizes, HEADING_TYPES, HeaderLevelMap, HeadingEditor, HoveredCellInfo, HrEditor, IS_MAC, ImageEditor, IndentEditor, Indents, InlineCodeEditor, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LOWEST_TEXT_CONTAINER_TYPES, LayoutTypes, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, MentionEditor, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PluginKeys, PluginMenuIcons, PluginMenuSvgs, Position, QUICK_INSERT_HOTKEY, QuickInsertEditor, ResizeRef, SLA_TABLE_CELL_SELECTOR, SLA_TABLE_SELECTOR, STANDARD_HEADING_TYPES, ScrollDirection, SpecialBackgroundColor, TAB_SPACE, THE_EDITOR_BG_COLOR, THE_EDITOR_COLOR, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_ORIGIN_ANCHOR, THE_EDITOR_POPOVER_REF, THE_EDITOR_PREVIOUS_SELECTION, THE_EDITOR_UUID, THE_I18N_DE_DE, THE_I18N_EN_US, THE_I18N_JA_JP, THE_I18N_LOCALE_ID, THE_I18N_RU_RU, THE_I18N_ZH_HANS, THE_I18N_ZH_HANT, THE_IMAGE_SERVICE_TOKEN, THE_LISTBOX_PARENT_GROUP_TOKEN, THE_LISTBOX_PARENT_OPTION_TOKEN, THE_LISTBOX_TOKEN, THE_MODE_PROVIDER, THE_MODE_TOKEN, THE_PLUGIN_MENU_REF, THE_PRESET_CONFIG_TOKEN, TableCellEventDispatcher, TableEditor, TableHeaderBackgroundColor, TablePosition, TheBaseElement, TheBaseSuggestion, TheBaseToolbarDropdown, TheBaseToolbarItem, TheColumnResizeDirective, TheColumnResizeOverlayHandle, TheContextMenu, TheContextService, TheConversionHint, TheDataMode, TheDefaultElement, TheEditor, TheEditorComponent, TheEditorModule, TheI18nService, TheImage, TheInlineToolbar, TheListboxDirective, TheListboxGroupDirective, TheListboxOptionDirective, TheLocaleType, TheMode, TheModeConfig, ThePluginMenu, ThePluginMenuComponent, ThePluginMenuItemType, ThePreventDefaultDirective, index$1 as TheQueries, TheQuickInsert, TheTableSelect, TheTemplate, TheText, TheToolbarComponent, TheToolbarDropdown, TheToolbarGroup, TheToolbarGroupToken, TheToolbarItem, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, autoFocus, base64toBlob, bottomLeftPosition, bottomRightPosition, buildPluginMenu, buildPluginMenuItemMap, buildQuickInsertMenus, calcPrintColumnWidth, calcSpanForColumn, calcSpanForRow, calculateHeaderRowHeight, calculateRowControls, coercePixelsFromCssValue, combinePlugins, copyNode, createCell, createEmptyContent, createEmptyParagraph, createMentionPlugin, createPluginFactory, createRow, createTable, createTablePosition, createTest1Plugin, createTestPlugin, createToolbar, createVerticalAlignPlugin, customPluginMock, customPluginMockKey, dataDeserialize, dataSerializing, deDeLocale, deleteElementKey, enUsLocale, errorImageUrlMock, expandPreviousHeadings, extractFragment, extractFragmentByHTML, filterTextFormat, fixBlockWithoutParagraph, fixBlockWithoutText, flattenDeepPlugins, getCellPositionsFromRange, getCollapsedStandardHeadingAbove, getColsTotalWidth, getColumnsWidth, getDirtyElements, getEditorScrollContainer, getEditorUUID, getElementClassByPrefix, getElementHeight, getElementWidth, getEndBlock, getFollowElements, getGridColumns, getMode, getNextCell, getOriginCell, getPlugin, getPluginOptions, getPlugins, getPreviousRelatedHeadingElements, getRowsTotalHeight, getSelectCellNode, getSelectedCellPositions, getStartBlock, getTableByCell, getTableByRow, getTheDefaultPluginMenu, getToolbarClass, hasHeaderRow, headingOptions, htmlToTheia, idCreator, inValidTypes, initializeDefaultMenuIcons, injectTranslations, insertDataByInvalidType, internalPlugins, isCleanEmptyParagraph, isColorIndicator, isColorInput, isColorPanel, isDirectionKeydown, isHeadingElement, isInside, isMobileMode, isPrintMode, isPureEmptyParagraph, isRangeInTable, isRectangularInTableCells, isSelectedAllCell, isSelectionInTable, isStandardHeadingElement, isStandardHeadingElementByType, isUrl, isVirtualKey, jaJpLocale, matchOptions, mergeArray, mergeDeepPlugins, mergeElementOptions, mergeOptions, nestedStructureByKey, normalizeValue, originOptions, plainToTheia, pluginKey, pluginKey1, pluginsByKey, reSelection, recursionNodes, refocus, ruRuLocale, setClipboardDataByDom, setEditorUUID, theTethysIconRegistryFaker, toggleHeadingRelatedElement, topLeftPosition, topRightPosition, uniqueCellPosition, updatePopoverPosition, useElementStyle, withMention, withTestPlugin, withTheia, zhHansLocale, zhHantLocale };
|
|
18974
18986
|
//# sourceMappingURL=worktile-theia.mjs.map
|