- });
-};
-
-$.extend(Selection.prototype, {
- toDocumentFragment: function() {
- var doc = this.canvas.wlxmlDocument,
- anchorElement = this.canvas.getDocumentElement(this.nativeSelection.anchorNode),
- focusElement = this.canvas.getDocumentElement(this.nativeSelection.focusNode),
- anchorNode = anchorElement ? anchorElement.wlxmlNode : null,
- focusNode = focusElement ? focusElement.wlxmlNode : null;
- if(this.type === 'caret') {
- return doc.createFragment(doc.CaretFragment, {node: anchorNode, offset: this.nativeSelection.anchorOffset});
- }
- if(this.type === 'textSelection') {
- if(anchorNode.isSiblingOf(focusNode)) {
- return doc.createFragment(doc.TextRangeFragment, {
- node1: anchorNode,
- offset1: this.nativeSelection.anchorOffset,
- node2: focusNode,
- offset2: this.nativeSelection.focusOffset,
- });
- }
- else {
- var siblingParents = doc.getSiblingParents({node1: anchorNode, node2: focusNode});
- return doc.createFragment(doc.RangeFragment, {
- node1: siblingParents.node1,
- node2: siblingParents.node2
- });
- }
+ if(menu.actions.length) {
+ menu.updateContextParam('fragment', this.getSelection().toDocumentFragment());
+ this.sandbox.showContextMenu(menu, {x: coors.x, y: coors.y});