roosterjs-editor-adapter 0.26.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/LICENSE +25 -0
- package/README.md +262 -0
- package/lib/corePlugins/BridgePlugin.d.ts +73 -0
- package/lib/corePlugins/BridgePlugin.js +124 -0
- package/lib/corePlugins/BridgePlugin.js.map +1 -0
- package/lib/corePlugins/EditPlugin.d.ts +6 -0
- package/lib/corePlugins/EditPlugin.js +89 -0
- package/lib/corePlugins/EditPlugin.js.map +1 -0
- package/lib/editor/DarkColorHandlerImpl.d.ts +6 -0
- package/lib/editor/DarkColorHandlerImpl.js +134 -0
- package/lib/editor/DarkColorHandlerImpl.js.map +1 -0
- package/lib/editor/EditorAdapter.d.ts +341 -0
- package/lib/editor/EditorAdapter.js +843 -0
- package/lib/editor/EditorAdapter.js.map +1 -0
- package/lib/editor/utils/buildRangeEx.d.ts +5 -0
- package/lib/editor/utils/buildRangeEx.js +81 -0
- package/lib/editor/utils/buildRangeEx.js.map +1 -0
- package/lib/editor/utils/eventConverter.d.ts +15 -0
- package/lib/editor/utils/eventConverter.js +463 -0
- package/lib/editor/utils/eventConverter.js.map +1 -0
- package/lib/editor/utils/insertNode.d.ts +7 -0
- package/lib/editor/utils/insertNode.js +147 -0
- package/lib/editor/utils/insertNode.js.map +1 -0
- package/lib/editor/utils/selectionConverter.d.ts +10 -0
- package/lib/editor/utils/selectionConverter.js +79 -0
- package/lib/editor/utils/selectionConverter.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -0
- package/lib/publicTypes/BeforePasteAdapterEvent.d.ts +15 -0
- package/lib/publicTypes/BeforePasteAdapterEvent.js +3 -0
- package/lib/publicTypes/BeforePasteAdapterEvent.js.map +1 -0
- package/lib/publicTypes/EditorAdapterOptions.d.ts +20 -0
- package/lib/publicTypes/EditorAdapterOptions.js +3 -0
- package/lib/publicTypes/EditorAdapterOptions.js.map +1 -0
- package/lib-amd/corePlugins/BridgePlugin.d.ts +73 -0
- package/lib-amd/corePlugins/BridgePlugin.js +122 -0
- package/lib-amd/corePlugins/BridgePlugin.js.map +1 -0
- package/lib-amd/corePlugins/EditPlugin.d.ts +6 -0
- package/lib-amd/corePlugins/EditPlugin.js +90 -0
- package/lib-amd/corePlugins/EditPlugin.js.map +1 -0
- package/lib-amd/editor/DarkColorHandlerImpl.d.ts +6 -0
- package/lib-amd/editor/DarkColorHandlerImpl.js +135 -0
- package/lib-amd/editor/DarkColorHandlerImpl.js.map +1 -0
- package/lib-amd/editor/EditorAdapter.d.ts +341 -0
- package/lib-amd/editor/EditorAdapter.js +836 -0
- package/lib-amd/editor/EditorAdapter.js.map +1 -0
- package/lib-amd/editor/utils/buildRangeEx.d.ts +5 -0
- package/lib-amd/editor/utils/buildRangeEx.js +82 -0
- package/lib-amd/editor/utils/buildRangeEx.js.map +1 -0
- package/lib-amd/editor/utils/eventConverter.d.ts +15 -0
- package/lib-amd/editor/utils/eventConverter.js +463 -0
- package/lib-amd/editor/utils/eventConverter.js.map +1 -0
- package/lib-amd/editor/utils/insertNode.d.ts +7 -0
- package/lib-amd/editor/utils/insertNode.js +148 -0
- package/lib-amd/editor/utils/insertNode.js.map +1 -0
- package/lib-amd/editor/utils/selectionConverter.d.ts +10 -0
- package/lib-amd/editor/utils/selectionConverter.js +79 -0
- package/lib-amd/editor/utils/selectionConverter.js.map +1 -0
- package/lib-amd/index.d.ts +3 -0
- package/lib-amd/index.js +7 -0
- package/lib-amd/index.js.map +1 -0
- package/lib-amd/publicTypes/BeforePasteAdapterEvent.d.ts +15 -0
- package/lib-amd/publicTypes/BeforePasteAdapterEvent.js +5 -0
- package/lib-amd/publicTypes/BeforePasteAdapterEvent.js.map +1 -0
- package/lib-amd/publicTypes/EditorAdapterOptions.d.ts +20 -0
- package/lib-amd/publicTypes/EditorAdapterOptions.js +5 -0
- package/lib-amd/publicTypes/EditorAdapterOptions.js.map +1 -0
- package/lib-mjs/corePlugins/BridgePlugin.d.ts +73 -0
- package/lib-mjs/corePlugins/BridgePlugin.js +120 -0
- package/lib-mjs/corePlugins/BridgePlugin.js.map +1 -0
- package/lib-mjs/corePlugins/EditPlugin.d.ts +6 -0
- package/lib-mjs/corePlugins/EditPlugin.js +85 -0
- package/lib-mjs/corePlugins/EditPlugin.js.map +1 -0
- package/lib-mjs/editor/DarkColorHandlerImpl.d.ts +6 -0
- package/lib-mjs/editor/DarkColorHandlerImpl.js +130 -0
- package/lib-mjs/editor/DarkColorHandlerImpl.js.map +1 -0
- package/lib-mjs/editor/EditorAdapter.d.ts +341 -0
- package/lib-mjs/editor/EditorAdapter.js +840 -0
- package/lib-mjs/editor/EditorAdapter.js.map +1 -0
- package/lib-mjs/editor/utils/buildRangeEx.d.ts +5 -0
- package/lib-mjs/editor/utils/buildRangeEx.js +77 -0
- package/lib-mjs/editor/utils/buildRangeEx.js.map +1 -0
- package/lib-mjs/editor/utils/eventConverter.d.ts +15 -0
- package/lib-mjs/editor/utils/eventConverter.js +458 -0
- package/lib-mjs/editor/utils/eventConverter.js.map +1 -0
- package/lib-mjs/editor/utils/insertNode.d.ts +7 -0
- package/lib-mjs/editor/utils/insertNode.js +143 -0
- package/lib-mjs/editor/utils/insertNode.js.map +1 -0
- package/lib-mjs/editor/utils/selectionConverter.d.ts +10 -0
- package/lib-mjs/editor/utils/selectionConverter.js +74 -0
- package/lib-mjs/editor/utils/selectionConverter.js.map +1 -0
- package/lib-mjs/index.d.ts +3 -0
- package/lib-mjs/index.js +2 -0
- package/lib-mjs/index.js.map +1 -0
- package/lib-mjs/publicTypes/BeforePasteAdapterEvent.d.ts +15 -0
- package/lib-mjs/publicTypes/BeforePasteAdapterEvent.js +2 -0
- package/lib-mjs/publicTypes/BeforePasteAdapterEvent.js.map +1 -0
- package/lib-mjs/publicTypes/EditorAdapterOptions.d.ts +20 -0
- package/lib-mjs/publicTypes/EditorAdapterOptions.js +2 -0
- package/lib-mjs/publicTypes/EditorAdapterOptions.js.map +1 -0
- package/package.json +21 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { createRange, getBlockElementAtNode, getFirstLastBlockElement, isBlockElement, isVoidHtmlElement, Position, safeInstanceOf, toArray, wrap, adjustInsertPosition, getRegionsFromRange, splitTextNode, splitParentNode, } from 'roosterjs-editor-dom';
|
|
2
|
+
function getInitialRange(selection, option) {
|
|
3
|
+
// Selection start replaces based on the current selection.
|
|
4
|
+
// Range inserts based on a provided range.
|
|
5
|
+
// Both have the potential to use the current selection to restore cursor position
|
|
6
|
+
// So in both cases we need to store the selection state.
|
|
7
|
+
var range = (selection === null || selection === void 0 ? void 0 : selection.type) == 'range' ? selection.range : null;
|
|
8
|
+
var rangeToRestore = null;
|
|
9
|
+
if (option.position == 5 /* Range */) {
|
|
10
|
+
rangeToRestore = range;
|
|
11
|
+
range = option.range;
|
|
12
|
+
}
|
|
13
|
+
else if (range) {
|
|
14
|
+
rangeToRestore = range.cloneRange();
|
|
15
|
+
}
|
|
16
|
+
return { range: range, rangeToRestore: rangeToRestore };
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
* Insert a DOM node into editor content
|
|
21
|
+
*/
|
|
22
|
+
export function insertNode(contentDiv, selection, node, option) {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
switch (option.position) {
|
|
25
|
+
case 0 /* Begin */:
|
|
26
|
+
case 1 /* End */: {
|
|
27
|
+
var isBegin = option.position == 0 /* Begin */;
|
|
28
|
+
var block = getFirstLastBlockElement(contentDiv, isBegin);
|
|
29
|
+
var insertedNode_1;
|
|
30
|
+
if (block) {
|
|
31
|
+
var refNode = isBegin ? block.getStartNode() : block.getEndNode();
|
|
32
|
+
if (option.insertOnNewLine ||
|
|
33
|
+
refNode.nodeType == 3 /* Text */ ||
|
|
34
|
+
isVoidHtmlElement(refNode)) {
|
|
35
|
+
// For insert on new line, or refNode is text or void html element (HR, BR etc.)
|
|
36
|
+
// which cannot have children, i.e. <div>hello<br>world</div>. 'hello', 'world' are the
|
|
37
|
+
// first and last node. Insert before 'hello' or after 'world', but still inside DIV
|
|
38
|
+
if (safeInstanceOf(node, 'DocumentFragment')) {
|
|
39
|
+
// if the node to be inserted is DocumentFragment, use its childNodes as insertedNode
|
|
40
|
+
// because insertBefore() returns an empty DocumentFragment
|
|
41
|
+
insertedNode_1 = toArray(node.childNodes);
|
|
42
|
+
(_a = refNode.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(node, isBegin ? refNode : refNode.nextSibling);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
insertedNode_1 = (_b = refNode.parentNode) === null || _b === void 0 ? void 0 : _b.insertBefore(node, isBegin ? refNode : refNode.nextSibling);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// if the refNode can have child, use appendChild (which is like to insert as first/last child)
|
|
50
|
+
// i.e. <div>hello</div>, the content will be inserted before/after hello
|
|
51
|
+
insertedNode_1 = refNode.insertBefore(node, isBegin ? refNode.firstChild : null);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// No first block, this can happen when editor is empty. Use appendChild to insert the content in contentDiv
|
|
56
|
+
insertedNode_1 = contentDiv.appendChild(node);
|
|
57
|
+
}
|
|
58
|
+
// Final check to see if the inserted node is a block. If not block and the ask is to insert on new line,
|
|
59
|
+
// add a DIV wrapping
|
|
60
|
+
if (insertedNode_1 && option.insertOnNewLine) {
|
|
61
|
+
var nodes = Array.isArray(insertedNode_1) ? insertedNode_1 : [insertedNode_1];
|
|
62
|
+
if (!isBlockElement(nodes[0]) || !isBlockElement(nodes[nodes.length - 1])) {
|
|
63
|
+
wrap(nodes);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
case 2 /* DomEnd */:
|
|
69
|
+
// Use appendChild to insert the node at the end of the content div.
|
|
70
|
+
var insertedNode = contentDiv.appendChild(node);
|
|
71
|
+
// Final check to see if the inserted node is a block. If not block and the ask is to insert on new line,
|
|
72
|
+
// add a DIV wrapping
|
|
73
|
+
if (insertedNode && option.insertOnNewLine && !isBlockElement(insertedNode)) {
|
|
74
|
+
wrap(insertedNode);
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
case 5 /* Range */:
|
|
78
|
+
case 3 /* SelectionStart */:
|
|
79
|
+
var _c = getInitialRange(selection, option), range = _c.range, rangeToRestore = _c.rangeToRestore;
|
|
80
|
+
if (!range) {
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
// if to replace the selection and the selection is not collapsed, remove the the content at selection first
|
|
84
|
+
if (option.replaceSelection && !range.collapsed) {
|
|
85
|
+
range.deleteContents();
|
|
86
|
+
}
|
|
87
|
+
var pos = Position.getStart(range);
|
|
88
|
+
var blockElement = void 0;
|
|
89
|
+
if (option.insertOnNewLine && option.insertToRegionRoot) {
|
|
90
|
+
pos = adjustInsertPositionRegionRoot(contentDiv, range, pos);
|
|
91
|
+
}
|
|
92
|
+
else if (option.insertOnNewLine &&
|
|
93
|
+
(blockElement = getBlockElementAtNode(contentDiv, pos.normalize().node))) {
|
|
94
|
+
pos = adjustInsertPositionNewLine(blockElement, contentDiv, pos);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
pos = adjustInsertPosition(contentDiv, node, pos, range);
|
|
98
|
+
}
|
|
99
|
+
var nodeForCursor = node.nodeType == 11 /* DocumentFragment */ ? node.lastChild : node;
|
|
100
|
+
range = createRange(pos);
|
|
101
|
+
range.insertNode(node);
|
|
102
|
+
if (option.updateCursor && nodeForCursor) {
|
|
103
|
+
rangeToRestore = createRange(new Position(nodeForCursor, -3 /* After */).normalize());
|
|
104
|
+
}
|
|
105
|
+
return rangeToRestore
|
|
106
|
+
? {
|
|
107
|
+
type: 'range',
|
|
108
|
+
range: rangeToRestore,
|
|
109
|
+
isReverted: false,
|
|
110
|
+
}
|
|
111
|
+
: undefined;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function adjustInsertPositionRegionRoot(contentDiv, range, position) {
|
|
115
|
+
var region = getRegionsFromRange(contentDiv, range, 0 /* Table */)[0];
|
|
116
|
+
var node = position.node;
|
|
117
|
+
if (region) {
|
|
118
|
+
if (node.nodeType == 3 /* Text */ && !position.isAtEnd) {
|
|
119
|
+
node = splitTextNode(node, position.offset, true /*returnFirstPart*/);
|
|
120
|
+
}
|
|
121
|
+
if (node != region.rootNode) {
|
|
122
|
+
while (node && node.parentNode != region.rootNode) {
|
|
123
|
+
splitParentNode(node, false /*splitBefore*/);
|
|
124
|
+
node = node.parentNode;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (node) {
|
|
128
|
+
position = new Position(node, -3 /* After */);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return position;
|
|
132
|
+
}
|
|
133
|
+
function adjustInsertPositionNewLine(blockElement, contentDiv, pos) {
|
|
134
|
+
var tempPos = new Position(blockElement.getEndNode(), -3 /* After */);
|
|
135
|
+
if (safeInstanceOf(tempPos.node, 'HTMLTableRowElement')) {
|
|
136
|
+
var div = contentDiv.ownerDocument.createElement('div');
|
|
137
|
+
var range = createRange(pos);
|
|
138
|
+
range.insertNode(div);
|
|
139
|
+
tempPos = new Position(div, 0 /* Begin */);
|
|
140
|
+
}
|
|
141
|
+
return tempPos;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=insertNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insertNode.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-editor-adapter/lib/editor/utils/insertNode.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,WAAW,EACX,qBAAqB,EACrB,wBAAwB,EACxB,cAAc,EACd,iBAAiB,EACjB,QAAQ,EACR,cAAc,EACd,OAAO,EACP,IAAI,EACJ,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,EACb,eAAe,GAClB,MAAM,sBAAsB,CAAC;A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IAAI,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,qBAAqB,CAAC,EAAE;QACrD,IAAM,GAAG,GAAG,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC1D,IAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;QAC/B,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACtB,OAAO,GAAG,IAAI,QAAQ,CAAC,GAAG,gBAAqB,CAAC;KACnD;IACD,OAAO,OAAO,CAAC;AACnB,CAAC","sourcesContent":["import { ContentPosition, NodeType, PositionType, RegionType } from 'roosterjs-editor-types';\r\nimport type { BlockElement, InsertOption, NodePosition } from 'roosterjs-editor-types';\r\nimport {\r\n createRange,\r\n getBlockElementAtNode,\r\n getFirstLastBlockElement,\r\n isBlockElement,\r\n isVoidHtmlElement,\r\n Position,\r\n safeInstanceOf,\r\n toArray,\r\n wrap,\r\n adjustInsertPosition,\r\n getRegionsFromRange,\r\n splitTextNode,\r\n splitParentNode,\r\n} from 'roosterjs-editor-dom';\r\nimport type { DOMSelection } from 'roosterjs-content-model-types';\r\n\r\nfunction getInitialRange(\r\n selection: DOMSelection | null,\r\n option: InsertOption\r\n): { range: Range | null; rangeToRestore: Range | null } {\r\n // Selection start replaces based on the current selection.\r\n // Range inserts based on a provided range.\r\n // Both have the potential to use the current selection to restore cursor position\r\n // So in both cases we need to store the selection state.\r\n let range = selection?.type == 'range' ? selection.range : null;\r\n let rangeToRestore = null;\r\n\r\n if (option.position == ContentPosition.Range) {\r\n rangeToRestore = range;\r\n range = option.range;\r\n } else if (range) {\r\n rangeToRestore = range.cloneRange();\r\n }\r\n\r\n return { range, rangeToRestore };\r\n}\r\n\r\n/**\r\n * @internal\r\n * Insert a DOM node into editor content\r\n */\r\nexport function insertNode(\r\n contentDiv: HTMLDivElement,\r\n selection: DOMSelection | null,\r\n node: Node,\r\n option: InsertOption\r\n): DOMSelection | undefined {\r\n switch (option.position) {\r\n case ContentPosition.Begin:\r\n case ContentPosition.End: {\r\n const isBegin = option.position == ContentPosition.Begin;\r\n const block = getFirstLastBlockElement(contentDiv, isBegin);\r\n let insertedNode: Node | Node[] | undefined;\r\n if (block) {\r\n const refNode = isBegin ? block.getStartNode() : block.getEndNode();\r\n if (\r\n option.insertOnNewLine ||\r\n refNode.nodeType == NodeType.Text ||\r\n isVoidHtmlElement(refNode)\r\n ) {\r\n // For insert on new line, or refNode is text or void html element (HR, BR etc.)\r\n // which cannot have children, i.e. <div>hello<br>world</div>. 'hello', 'world' are the\r\n // first and last node. Insert before 'hello' or after 'world', but still inside DIV\r\n if (safeInstanceOf(node, 'DocumentFragment')) {\r\n // if the node to be inserted is DocumentFragment, use its childNodes as insertedNode\r\n // because insertBefore() returns an empty DocumentFragment\r\n insertedNode = toArray(node.childNodes);\r\n refNode.parentNode?.insertBefore(\r\n node,\r\n isBegin ? refNode : refNode.nextSibling\r\n );\r\n } else {\r\n insertedNode = refNode.parentNode?.insertBefore(\r\n node,\r\n isBegin ? refNode : refNode.nextSibling\r\n );\r\n }\r\n } else {\r\n // if the refNode can have child, use appendChild (which is like to insert as first/last child)\r\n // i.e. <div>hello</div>, the content will be inserted before/after hello\r\n insertedNode = refNode.insertBefore(node, isBegin ? refNode.firstChild : null);\r\n }\r\n } else {\r\n // No first block, this can happen when editor is empty. Use appendChild to insert the content in contentDiv\r\n insertedNode = contentDiv.appendChild(node);\r\n }\r\n\r\n // Final check to see if the inserted node is a block. If not block and the ask is to insert on new line,\r\n // add a DIV wrapping\r\n if (insertedNode && option.insertOnNewLine) {\r\n const nodes = Array.isArray(insertedNode) ? insertedNode : [insertedNode];\r\n if (!isBlockElement(nodes[0]) || !isBlockElement(nodes[nodes.length - 1])) {\r\n wrap(nodes);\r\n }\r\n }\r\n\r\n break;\r\n }\r\n case ContentPosition.DomEnd:\r\n // Use appendChild to insert the node at the end of the content div.\r\n const insertedNode = contentDiv.appendChild(node);\r\n // Final check to see if the inserted node is a block. If not block and the ask is to insert on new line,\r\n // add a DIV wrapping\r\n if (insertedNode && option.insertOnNewLine && !isBlockElement(insertedNode)) {\r\n wrap(insertedNode);\r\n }\r\n break;\r\n case ContentPosition.Range:\r\n case ContentPosition.SelectionStart:\r\n let { range, rangeToRestore } = getInitialRange(selection, option);\r\n if (!range) {\r\n break;\r\n }\r\n\r\n // if to replace the selection and the selection is not collapsed, remove the the content at selection first\r\n if (option.replaceSelection && !range.collapsed) {\r\n range.deleteContents();\r\n }\r\n\r\n let pos: NodePosition = Position.getStart(range);\r\n let blockElement: BlockElement | null;\r\n\r\n if (option.insertOnNewLine && option.insertToRegionRoot) {\r\n pos = adjustInsertPositionRegionRoot(contentDiv, range, pos);\r\n } else if (\r\n option.insertOnNewLine &&\r\n (blockElement = getBlockElementAtNode(contentDiv, pos.normalize().node))\r\n ) {\r\n pos = adjustInsertPositionNewLine(blockElement, contentDiv, pos);\r\n } else {\r\n pos = adjustInsertPosition(contentDiv, node, pos, range);\r\n }\r\n\r\n const nodeForCursor =\r\n node.nodeType == NodeType.DocumentFragment ? node.lastChild : node;\r\n\r\n range = createRange(pos);\r\n range.insertNode(node);\r\n\r\n if (option.updateCursor && nodeForCursor) {\r\n rangeToRestore = createRange(\r\n new Position(nodeForCursor, PositionType.After).normalize()\r\n );\r\n }\r\n\r\n return rangeToRestore\r\n ? {\r\n type: 'range',\r\n range: rangeToRestore,\r\n isReverted: false,\r\n }\r\n : undefined;\r\n }\r\n}\r\n\r\nfunction adjustInsertPositionRegionRoot(\r\n contentDiv: HTMLDivElement,\r\n range: Range,\r\n position: NodePosition\r\n) {\r\n const region = getRegionsFromRange(contentDiv, range, RegionType.Table)[0];\r\n let node: Node | null = position.node;\r\n\r\n if (region) {\r\n if (node.nodeType == NodeType.Text && !position.isAtEnd) {\r\n node = splitTextNode(node as Text, position.offset, true /*returnFirstPart*/);\r\n }\r\n\r\n if (node != region.rootNode) {\r\n while (node && node.parentNode != region.rootNode) {\r\n splitParentNode(node, false /*splitBefore*/);\r\n node = node.parentNode;\r\n }\r\n }\r\n\r\n if (node) {\r\n position = new Position(node, PositionType.After);\r\n }\r\n }\r\n\r\n return position;\r\n}\r\n\r\nfunction adjustInsertPositionNewLine(\r\n blockElement: BlockElement,\r\n contentDiv: HTMLDivElement,\r\n pos: Position\r\n) {\r\n let tempPos = new Position(blockElement.getEndNode(), PositionType.After);\r\n if (safeInstanceOf(tempPos.node, 'HTMLTableRowElement')) {\r\n const div = contentDiv.ownerDocument.createElement('div');\r\n const range = createRange(pos);\r\n range.insertNode(div);\r\n tempPos = new Position(div, PositionType.Begin);\r\n }\r\n return tempPos;\r\n}\r\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DOMSelection } from 'roosterjs-content-model-types';
|
|
2
|
+
import type { SelectionRangeEx } from 'roosterjs-editor-types';
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare function convertRangeExToDomSelection(rangeEx: SelectionRangeEx | null): DOMSelection | null;
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare function convertDomSelectionToRangeEx(selection: DOMSelection | null): SelectionRangeEx;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createRange } from 'roosterjs-editor-dom';
|
|
2
|
+
import { createTableRanges } from 'roosterjs-content-model-core';
|
|
3
|
+
// In theory, all functions below are not necessary. We keep these functions here only for compatibility with old IEditor interface
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export function convertRangeExToDomSelection(rangeEx) {
|
|
8
|
+
switch (rangeEx === null || rangeEx === void 0 ? void 0 : rangeEx.type) {
|
|
9
|
+
case 2 /* ImageSelection */:
|
|
10
|
+
return {
|
|
11
|
+
type: 'image',
|
|
12
|
+
image: rangeEx.image,
|
|
13
|
+
};
|
|
14
|
+
case 0 /* Normal */:
|
|
15
|
+
return rangeEx.ranges.length > 0
|
|
16
|
+
? {
|
|
17
|
+
type: 'range',
|
|
18
|
+
range: rangeEx.ranges[0],
|
|
19
|
+
isReverted: false,
|
|
20
|
+
}
|
|
21
|
+
: null;
|
|
22
|
+
case 1 /* TableSelection */:
|
|
23
|
+
return rangeEx.coordinates
|
|
24
|
+
? {
|
|
25
|
+
type: 'table',
|
|
26
|
+
table: rangeEx.table,
|
|
27
|
+
firstColumn: rangeEx.coordinates.firstCell.x,
|
|
28
|
+
firstRow: rangeEx.coordinates.firstCell.y,
|
|
29
|
+
lastColumn: rangeEx.coordinates.lastCell.x,
|
|
30
|
+
lastRow: rangeEx.coordinates.lastCell.y,
|
|
31
|
+
}
|
|
32
|
+
: null;
|
|
33
|
+
default:
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
export function convertDomSelectionToRangeEx(selection) {
|
|
41
|
+
switch (selection === null || selection === void 0 ? void 0 : selection.type) {
|
|
42
|
+
case 'image':
|
|
43
|
+
return {
|
|
44
|
+
type: 2 /* ImageSelection */,
|
|
45
|
+
image: selection.image,
|
|
46
|
+
areAllCollapsed: false,
|
|
47
|
+
ranges: [createRange(selection.image)],
|
|
48
|
+
};
|
|
49
|
+
case 'range':
|
|
50
|
+
return {
|
|
51
|
+
type: 0 /* Normal */,
|
|
52
|
+
ranges: [selection.range],
|
|
53
|
+
areAllCollapsed: selection.range.collapsed,
|
|
54
|
+
};
|
|
55
|
+
case 'table':
|
|
56
|
+
return {
|
|
57
|
+
type: 1 /* TableSelection */,
|
|
58
|
+
ranges: createTableRanges(selection),
|
|
59
|
+
areAllCollapsed: false,
|
|
60
|
+
table: selection.table,
|
|
61
|
+
coordinates: {
|
|
62
|
+
firstCell: { x: selection.firstColumn, y: selection.firstRow },
|
|
63
|
+
lastCell: { x: selection.lastColumn, y: selection.lastRow },
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
default:
|
|
67
|
+
return {
|
|
68
|
+
type: 0 /* Normal */,
|
|
69
|
+
ranges: [],
|
|
70
|
+
areAllCollapsed: true,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=selectionConverter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectionConverter.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-editor-adapter/lib/editor/utils/selectionConverter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAKjE,mIAAmI;AAEnI;;GAEG;AACH,MAAM,UAAU,4BAA4B,CACxC,OAAgC;IAEhC,QAAQ,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,EAAE;QACnB;YACI,OAAO;gBACH,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,OAAO,CAAC,KAAK;aACvB,CAAC;QAEN;YACI,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;gBAC5B,CAAC,CAAC;oBACI,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;oBACxB,UAAU,EAAE,KAAK;iBACpB;gBACH,CAAC,CAAC,IAAI,CAAC;QAEf;YACI,OAAO,OAAO,CAAC,WAAW;gBACtB,CAAC,CAAC;oBACI,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,OAAO,CAAC,KAAK;oBACpB,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;oBAC5C,QAAQ,EAAE,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;oBACzC,UAAU,EAAE,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;oBAC1C,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;iBAC1C;gBACH,CAAC,CAAC,IAAI,CAAC;QAEf;YACI,OAAO,IAAI,CAAC;KACnB;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,4BAA4B,CAAC,SAA8B;IACvE,QAAQ,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,EAAE;QACrB,KAAK,OAAO;YACR,OAAO;gBACH,IAAI,wBAAoC;gBACxC,KAAK,EAAE,SAAS,CAAC,KAAK;gBACtB,eAAe,EAAE,KAAK;gBACtB,MAAM,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;aACzC,CAAC;QAEN,KAAK,OAAO;YACR,OAAO;gBACH,IAAI,gBAA4B;gBAChC,MAAM,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC;gBACzB,eAAe,EAAE,SAAS,CAAC,KAAK,CAAC,SAAS;aAC7C,CAAC;QAEN,KAAK,OAAO;YACR,OAAO;gBACH,IAAI,wBAAoC;gBACxC,MAAM,EAAE,iBAAiB,CAAC,SAAS,CAAC;gBACpC,eAAe,EAAE,KAAK;gBACtB,KAAK,EAAE,SAAS,CAAC,KAAK;gBACtB,WAAW,EAAE;oBACT,SAAS,EAAE,EAAE,CAAC,EAAE,SAAS,CAAC,WAAW,EAAE,CAAC,EAAE,SAAS,CAAC,QAAQ,EAAE;oBAC9D,QAAQ,EAAE,EAAE,CAAC,EAAE,SAAS,CAAC,UAAU,EAAE,CAAC,EAAE,SAAS,CAAC,OAAO,EAAE;iBAC9D;aACJ,CAAC;QAEN;YACI,OAAO;gBACH,IAAI,gBAA4B;gBAChC,MAAM,EAAE,EAAE;gBACV,eAAe,EAAE,IAAI;aACxB,CAAC;KACT;AACL,CAAC","sourcesContent":["import { createRange } from 'roosterjs-editor-dom';\r\nimport { createTableRanges } from 'roosterjs-content-model-core';\r\nimport { SelectionRangeTypes } from 'roosterjs-editor-types';\r\nimport type { DOMSelection } from 'roosterjs-content-model-types';\r\nimport type { SelectionRangeEx } from 'roosterjs-editor-types';\r\n\r\n// In theory, all functions below are not necessary. We keep these functions here only for compatibility with old IEditor interface\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function convertRangeExToDomSelection(\r\n rangeEx: SelectionRangeEx | null\r\n): DOMSelection | null {\r\n switch (rangeEx?.type) {\r\n case SelectionRangeTypes.ImageSelection:\r\n return {\r\n type: 'image',\r\n image: rangeEx.image,\r\n };\r\n\r\n case SelectionRangeTypes.Normal:\r\n return rangeEx.ranges.length > 0\r\n ? {\r\n type: 'range',\r\n range: rangeEx.ranges[0],\r\n isReverted: false,\r\n }\r\n : null;\r\n\r\n case SelectionRangeTypes.TableSelection:\r\n return rangeEx.coordinates\r\n ? {\r\n type: 'table',\r\n table: rangeEx.table,\r\n firstColumn: rangeEx.coordinates.firstCell.x,\r\n firstRow: rangeEx.coordinates.firstCell.y,\r\n lastColumn: rangeEx.coordinates.lastCell.x,\r\n lastRow: rangeEx.coordinates.lastCell.y,\r\n }\r\n : null;\r\n\r\n default:\r\n return null;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function convertDomSelectionToRangeEx(selection: DOMSelection | null): SelectionRangeEx {\r\n switch (selection?.type) {\r\n case 'image':\r\n return {\r\n type: SelectionRangeTypes.ImageSelection,\r\n image: selection.image,\r\n areAllCollapsed: false,\r\n ranges: [createRange(selection.image)],\r\n };\r\n\r\n case 'range':\r\n return {\r\n type: SelectionRangeTypes.Normal,\r\n ranges: [selection.range],\r\n areAllCollapsed: selection.range.collapsed,\r\n };\r\n\r\n case 'table':\r\n return {\r\n type: SelectionRangeTypes.TableSelection,\r\n ranges: createTableRanges(selection),\r\n areAllCollapsed: false,\r\n table: selection.table,\r\n coordinates: {\r\n firstCell: { x: selection.firstColumn, y: selection.firstRow },\r\n lastCell: { x: selection.lastColumn, y: selection.lastRow },\r\n },\r\n };\r\n\r\n default:\r\n return {\r\n type: SelectionRangeTypes.Normal,\r\n ranges: [],\r\n areAllCollapsed: true,\r\n };\r\n }\r\n}\r\n"]}
|
package/lib-mjs/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-editor-adapter/lib/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export { EditorAdapterOptions } from './publicTypes/EditorAdapterOptions';\r\nexport { BeforePasteAdapterEvent } from './publicTypes/BeforePasteAdapterEvent';\r\n\r\nexport { EditorAdapter } from './editor/EditorAdapter';\r\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { BeforePasteEvent } from 'roosterjs-editor-types';
|
|
2
|
+
import type { DomToModelOptionForSanitizing, MergePastedContentFunc } from 'roosterjs-content-model-types';
|
|
3
|
+
/**
|
|
4
|
+
* A temporary event type to be compatible with both legacy plugin and EditorAdapter
|
|
5
|
+
*/
|
|
6
|
+
export interface BeforePasteAdapterEvent extends BeforePasteEvent {
|
|
7
|
+
/**
|
|
8
|
+
* domToModel Options to use when creating the content model from the paste fragment
|
|
9
|
+
*/
|
|
10
|
+
readonly domToModelOption: DomToModelOptionForSanitizing;
|
|
11
|
+
/**
|
|
12
|
+
* customizedMerge Customized merge function to use when merging the paste fragment into the editor
|
|
13
|
+
*/
|
|
14
|
+
customizedMerge?: MergePastedContentFunc;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BeforePasteAdapterEvent.js","sourceRoot":"","sources":["../../../../packages/roosterjs-editor-adapter/lib/publicTypes/BeforePasteAdapterEvent.ts"],"names":[],"mappings":"","sourcesContent":["import type { BeforePasteEvent } from 'roosterjs-editor-types';\r\nimport type {\r\n DomToModelOptionForSanitizing,\r\n MergePastedContentFunc,\r\n} from 'roosterjs-content-model-types';\r\n\r\n/**\r\n * A temporary event type to be compatible with both legacy plugin and EditorAdapter\r\n */\r\nexport interface BeforePasteAdapterEvent extends BeforePasteEvent {\r\n /**\r\n * domToModel Options to use when creating the content model from the paste fragment\r\n */\r\n readonly domToModelOption: DomToModelOptionForSanitizing;\r\n\r\n /**\r\n * customizedMerge Customized merge function to use when merging the paste fragment into the editor\r\n */\r\n customizedMerge?: MergePastedContentFunc;\r\n}\r\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { StandaloneEditorOptions } from 'roosterjs-content-model-types';
|
|
2
|
+
import type { EditorPlugin, ExperimentalFeatures } from 'roosterjs-editor-types';
|
|
3
|
+
/**
|
|
4
|
+
* Options for editor adapter
|
|
5
|
+
*/
|
|
6
|
+
export interface EditorAdapterOptions extends StandaloneEditorOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Initial HTML content
|
|
9
|
+
* Default value is whatever already inside the editor content DIV
|
|
10
|
+
*/
|
|
11
|
+
initialContent?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Specify the enabled experimental features
|
|
14
|
+
*/
|
|
15
|
+
experimentalFeatures?: ExperimentalFeatures[];
|
|
16
|
+
/**
|
|
17
|
+
* Legacy plugins using IEditor interface
|
|
18
|
+
*/
|
|
19
|
+
legacyPlugins?: EditorPlugin[];
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorAdapterOptions.js","sourceRoot":"","sources":["../../../../packages/roosterjs-editor-adapter/lib/publicTypes/EditorAdapterOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { StandaloneEditorOptions } from 'roosterjs-content-model-types';\r\nimport type { EditorPlugin, ExperimentalFeatures } from 'roosterjs-editor-types';\r\n\r\n/**\r\n * Options for editor adapter\r\n */\r\nexport interface EditorAdapterOptions extends StandaloneEditorOptions {\r\n /**\r\n * Initial HTML content\r\n * Default value is whatever already inside the editor content DIV\r\n */\r\n initialContent?: string;\r\n\r\n /**\r\n * Specify the enabled experimental features\r\n */\r\n experimentalFeatures?: ExperimentalFeatures[];\r\n\r\n /**\r\n * Legacy plugins using IEditor interface\r\n */\r\n legacyPlugins?: EditorPlugin[];\r\n}\r\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "roosterjs-editor-adapter",
|
|
3
|
+
"description": "An adapter on top of Content Model based editor to work with legacy roosterjs editor",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"tslib": "^2.3.1",
|
|
6
|
+
"roosterjs-editor-types": "^8.60.0",
|
|
7
|
+
"roosterjs-editor-dom": "^8.60.0",
|
|
8
|
+
"roosterjs-content-model-core": "^0.26.0",
|
|
9
|
+
"roosterjs-content-model-dom": "^0.26.0",
|
|
10
|
+
"roosterjs-content-model-types": "^0.26.0"
|
|
11
|
+
},
|
|
12
|
+
"version": "0.26.0",
|
|
13
|
+
"main": "./lib/index.js",
|
|
14
|
+
"typings": "./lib/index.d.ts",
|
|
15
|
+
"module": "./lib-mjs/index.js",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/Microsoft/roosterjs"
|
|
20
|
+
}
|
|
21
|
+
}
|