@contentful/field-editor-rich-text 3.17.1 → 3.17.3
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/plugins/DeserializeDocx/createDeserializeDocxPlugin.js +46 -0
- package/dist/cjs/plugins/DeserializeDocx/index.js +11 -0
- package/dist/cjs/plugins/index.js +2 -2
- package/dist/esm/plugins/DeserializeDocx/createDeserializeDocxPlugin.js +36 -0
- package/dist/esm/plugins/DeserializeDocx/index.js +1 -0
- package/dist/esm/plugins/index.js +1 -1
- package/dist/types/plugins/DeserializeDocx/createDeserializeDocxPlugin.d.ts +2 -0
- package/dist/types/plugins/DeserializeDocx/index.d.ts +1 -0
- package/dist/types/plugins/Table/withInsertFragmentTableOverride.d.ts +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "createDeserializeDocxPlugin", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return createDeserializeDocxPlugin;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _platecommon = require("@udecode/plate-common");
|
|
12
|
+
const _plateserializerdocx = require("@udecode/plate-serializer-docx");
|
|
13
|
+
const createDeserializeDocxPlugin = ()=>(0, _plateserializerdocx.createDeserializeDocxPlugin)({
|
|
14
|
+
inject: {
|
|
15
|
+
pluginsByKey: {
|
|
16
|
+
[_platecommon.KEY_DESERIALIZE_HTML]: {
|
|
17
|
+
editor: {
|
|
18
|
+
insertData: {
|
|
19
|
+
transformData: (data, { dataTransfer })=>{
|
|
20
|
+
const rtf = dataTransfer.getData('text/rtf');
|
|
21
|
+
const document = new DOMParser().parseFromString((0, _platecommon.preCleanHtml)(data), 'text/html');
|
|
22
|
+
const { body } = document;
|
|
23
|
+
if (!rtf && !(0, _plateserializerdocx.isDocxContent)(body)) {
|
|
24
|
+
return data;
|
|
25
|
+
}
|
|
26
|
+
(0, _plateserializerdocx.cleanDocxFootnotes)(body);
|
|
27
|
+
(0, _plateserializerdocx.cleanDocxImageElements)(document, rtf, body);
|
|
28
|
+
(0, _platecommon.cleanHtmlEmptyElements)(body);
|
|
29
|
+
(0, _plateserializerdocx.cleanDocxEmptyParagraphs)(body);
|
|
30
|
+
(0, _plateserializerdocx.cleanDocxQuotes)(body);
|
|
31
|
+
(0, _plateserializerdocx.cleanDocxSpans)(body);
|
|
32
|
+
(0, _platecommon.cleanHtmlTextNodes)(body);
|
|
33
|
+
(0, _plateserializerdocx.cleanDocxBrComments)(body);
|
|
34
|
+
(0, _platecommon.cleanHtmlBrElements)(body);
|
|
35
|
+
(0, _platecommon.cleanHtmlLinkElements)(body);
|
|
36
|
+
(0, _platecommon.cleanHtmlFontElements)(body);
|
|
37
|
+
(0, _plateserializerdocx.cleanDocxListElements)(body);
|
|
38
|
+
(0, _platecommon.copyBlockMarksToSpanChild)(body);
|
|
39
|
+
return (0, _platecommon.postCleanHtml)(body.innerHTML);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "createDeserializeDocxPlugin", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _createDeserializeDocxPlugin.createDeserializeDocxPlugin;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _createDeserializeDocxPlugin = require("./createDeserializeDocxPlugin");
|
|
@@ -16,10 +16,10 @@ _export(exports, {
|
|
|
16
16
|
return getPlugins;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
const _plateserializerdocx = require("@udecode/plate-serializer-docx");
|
|
20
19
|
const _Break = require("./Break");
|
|
21
20
|
const _CommandPalette = require("./CommandPalette");
|
|
22
21
|
const _useCommands = require("./CommandPalette/useCommands");
|
|
22
|
+
const _DeserializeDocx = require("./DeserializeDocx");
|
|
23
23
|
const _DragAndDrop = require("./DragAndDrop");
|
|
24
24
|
const _EmbeddedEntityBlock = require("./EmbeddedEntityBlock");
|
|
25
25
|
const _EmbeddedEntityInline = require("./EmbeddedEntityInline");
|
|
@@ -41,7 +41,7 @@ const _Tracking = require("./Tracking");
|
|
|
41
41
|
const _TrailingParagraph = require("./TrailingParagraph");
|
|
42
42
|
const _Voids = require("./Voids");
|
|
43
43
|
const getPlugins = (sdk, onAction, restrictedMarks)=>[
|
|
44
|
-
(0,
|
|
44
|
+
(0, _DeserializeDocx.createDeserializeDocxPlugin)(),
|
|
45
45
|
(0, _Tracking.createTrackingPlugin)(onAction),
|
|
46
46
|
(0, _DragAndDrop.createDragAndDropPlugin)(),
|
|
47
47
|
...Object.values((0, _useCommands.isCommandPromptPluginEnabled)(sdk)).some(Boolean) ? [
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { KEY_DESERIALIZE_HTML, cleanHtmlBrElements, cleanHtmlEmptyElements, cleanHtmlFontElements, cleanHtmlLinkElements, cleanHtmlTextNodes, copyBlockMarksToSpanChild, postCleanHtml, preCleanHtml } from '@udecode/plate-common';
|
|
2
|
+
import { cleanDocxBrComments, cleanDocxEmptyParagraphs, cleanDocxFootnotes, cleanDocxImageElements, cleanDocxListElements, cleanDocxQuotes, cleanDocxSpans, createDeserializeDocxPlugin as originalCreateDeserializeDocxPlugin, isDocxContent } from '@udecode/plate-serializer-docx';
|
|
3
|
+
export const createDeserializeDocxPlugin = ()=>originalCreateDeserializeDocxPlugin({
|
|
4
|
+
inject: {
|
|
5
|
+
pluginsByKey: {
|
|
6
|
+
[KEY_DESERIALIZE_HTML]: {
|
|
7
|
+
editor: {
|
|
8
|
+
insertData: {
|
|
9
|
+
transformData: (data, { dataTransfer })=>{
|
|
10
|
+
const rtf = dataTransfer.getData('text/rtf');
|
|
11
|
+
const document = new DOMParser().parseFromString(preCleanHtml(data), 'text/html');
|
|
12
|
+
const { body } = document;
|
|
13
|
+
if (!rtf && !isDocxContent(body)) {
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
cleanDocxFootnotes(body);
|
|
17
|
+
cleanDocxImageElements(document, rtf, body);
|
|
18
|
+
cleanHtmlEmptyElements(body);
|
|
19
|
+
cleanDocxEmptyParagraphs(body);
|
|
20
|
+
cleanDocxQuotes(body);
|
|
21
|
+
cleanDocxSpans(body);
|
|
22
|
+
cleanHtmlTextNodes(body);
|
|
23
|
+
cleanDocxBrComments(body);
|
|
24
|
+
cleanHtmlBrElements(body);
|
|
25
|
+
cleanHtmlLinkElements(body);
|
|
26
|
+
cleanHtmlFontElements(body);
|
|
27
|
+
cleanDocxListElements(body);
|
|
28
|
+
copyBlockMarksToSpanChild(body);
|
|
29
|
+
return postCleanHtml(body.innerHTML);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createDeserializeDocxPlugin } from './createDeserializeDocxPlugin';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createDeserializeDocxPlugin } from '@udecode/plate-serializer-docx';
|
|
2
1
|
import { createSoftBreakPlugin, createExitBreakPlugin, createResetNodePlugin } from './Break';
|
|
3
2
|
import { createCommandPalettePlugin } from './CommandPalette';
|
|
4
3
|
import { isCommandPromptPluginEnabled } from './CommandPalette/useCommands';
|
|
4
|
+
import { createDeserializeDocxPlugin } from './DeserializeDocx';
|
|
5
5
|
import { createDragAndDropPlugin } from './DragAndDrop';
|
|
6
6
|
import { createEmbeddedAssetBlockPlugin, createEmbeddedEntryBlockPlugin } from './EmbeddedEntityBlock';
|
|
7
7
|
import { createEmbeddedEntityInlinePlugin } from './EmbeddedEntityInline';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createDeserializeDocxPlugin } from './createDeserializeDocxPlugin';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PlateEditor } from '../../internal';
|
|
2
2
|
/**
|
|
3
|
-
* Override insertFragment to remove empty paragraph before table
|
|
3
|
+
* Override insertFragment to remove empty paragraph before table.
|
|
4
4
|
*/
|
|
5
5
|
export declare const withInsertFragmentTableOverride: (editor: PlateEditor) => PlateEditor;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-rich-text",
|
|
3
|
-
"version": "3.17.
|
|
3
|
+
"version": "3.17.3",
|
|
4
4
|
"source": "./src/index.tsx",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@contentful/f36-icons": "^4.1.1",
|
|
45
45
|
"@contentful/f36-tokens": "^4.0.0",
|
|
46
46
|
"@contentful/f36-utils": "^4.19.0",
|
|
47
|
-
"@contentful/field-editor-reference": "^5.22.
|
|
47
|
+
"@contentful/field-editor-reference": "^5.22.2",
|
|
48
48
|
"@contentful/field-editor-shared": "^1.4.5",
|
|
49
49
|
"@contentful/rich-text-plain-text-renderer": "^16.0.4",
|
|
50
50
|
"@contentful/rich-text-types": "16.3.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@udecode/plate-paragraph": "30.1.2",
|
|
58
58
|
"@udecode/plate-reset-node": "30.1.2",
|
|
59
59
|
"@udecode/plate-select": "30.1.2",
|
|
60
|
-
"@udecode/plate-serializer-docx": "
|
|
60
|
+
"@udecode/plate-serializer-docx": "30.1.2",
|
|
61
61
|
"@udecode/plate-serializer-html": "30.1.2",
|
|
62
62
|
"@udecode/plate-table": "30.1.2",
|
|
63
63
|
"@udecode/plate-trailing-block": "30.1.2",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"registry": "https://npm.pkg.github.com/"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "2797489936a29588027974e35926cff9025cd897"
|
|
90
90
|
}
|