Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-file-.../lib/codemirr.../lib
File: codemirror.js
display.input.focus();
[1500] Fix | Delete
if (webkit) window.scrollTo(null, oldScrollY);
[1501] Fix | Delete
display.input.reset();
[1502] Fix | Delete
// Adds "Select all" to context menu in FF
[1503] Fix | Delete
if (!cm.somethingSelected()) te.value = input.prevInput = " ";
[1504] Fix | Delete
input.contextMenuPending = true;
[1505] Fix | Delete
display.selForContextMenu = cm.doc.sel;
[1506] Fix | Delete
clearTimeout(display.detectingSelectAll);
[1507] Fix | Delete
[1508] Fix | Delete
// Select-all will be greyed out if there's nothing to select, so
[1509] Fix | Delete
// this adds a zero-width space so that we can later check whether
[1510] Fix | Delete
// it got selected.
[1511] Fix | Delete
function prepareSelectAllHack() {
[1512] Fix | Delete
if (te.selectionStart != null) {
[1513] Fix | Delete
var selected = cm.somethingSelected();
[1514] Fix | Delete
var extval = "\u200b" + (selected ? te.value : "");
[1515] Fix | Delete
te.value = "\u21da"; // Used to catch context-menu undo
[1516] Fix | Delete
te.value = extval;
[1517] Fix | Delete
input.prevInput = selected ? "" : "\u200b";
[1518] Fix | Delete
te.selectionStart = 1; te.selectionEnd = extval.length;
[1519] Fix | Delete
// Re-set this, in case some other handler touched the
[1520] Fix | Delete
// selection in the meantime.
[1521] Fix | Delete
display.selForContextMenu = cm.doc.sel;
[1522] Fix | Delete
}
[1523] Fix | Delete
}
[1524] Fix | Delete
function rehide() {
[1525] Fix | Delete
input.contextMenuPending = false;
[1526] Fix | Delete
input.wrapper.style.cssText = oldWrapperCSS
[1527] Fix | Delete
te.style.cssText = oldCSS;
[1528] Fix | Delete
if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos);
[1529] Fix | Delete
[1530] Fix | Delete
// Try to detect the user choosing select-all
[1531] Fix | Delete
if (te.selectionStart != null) {
[1532] Fix | Delete
if (!ie || (ie && ie_version < 9)) prepareSelectAllHack();
[1533] Fix | Delete
var i = 0, poll = function() {
[1534] Fix | Delete
if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
[1535] Fix | Delete
te.selectionEnd > 0 && input.prevInput == "\u200b")
[1536] Fix | Delete
operation(cm, commands.selectAll)(cm);
[1537] Fix | Delete
else if (i++ < 10) display.detectingSelectAll = setTimeout(poll, 500);
[1538] Fix | Delete
else display.input.reset();
[1539] Fix | Delete
};
[1540] Fix | Delete
display.detectingSelectAll = setTimeout(poll, 200);
[1541] Fix | Delete
}
[1542] Fix | Delete
}
[1543] Fix | Delete
[1544] Fix | Delete
if (ie && ie_version >= 9) prepareSelectAllHack();
[1545] Fix | Delete
if (captureRightClick) {
[1546] Fix | Delete
e_stop(e);
[1547] Fix | Delete
var mouseup = function() {
[1548] Fix | Delete
off(window, "mouseup", mouseup);
[1549] Fix | Delete
setTimeout(rehide, 20);
[1550] Fix | Delete
};
[1551] Fix | Delete
on(window, "mouseup", mouseup);
[1552] Fix | Delete
} else {
[1553] Fix | Delete
setTimeout(rehide, 50);
[1554] Fix | Delete
}
[1555] Fix | Delete
},
[1556] Fix | Delete
[1557] Fix | Delete
readOnlyChanged: function(val) {
[1558] Fix | Delete
if (!val) this.reset();
[1559] Fix | Delete
},
[1560] Fix | Delete
[1561] Fix | Delete
setUneditable: nothing,
[1562] Fix | Delete
[1563] Fix | Delete
needsContentAttribute: false
[1564] Fix | Delete
}, TextareaInput.prototype);
[1565] Fix | Delete
[1566] Fix | Delete
// CONTENTEDITABLE INPUT STYLE
[1567] Fix | Delete
[1568] Fix | Delete
function ContentEditableInput(cm) {
[1569] Fix | Delete
this.cm = cm;
[1570] Fix | Delete
this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null;
[1571] Fix | Delete
this.polling = new Delayed();
[1572] Fix | Delete
this.gracePeriod = false;
[1573] Fix | Delete
}
[1574] Fix | Delete
[1575] Fix | Delete
ContentEditableInput.prototype = copyObj({
[1576] Fix | Delete
init: function(display) {
[1577] Fix | Delete
var input = this, cm = input.cm;
[1578] Fix | Delete
var div = input.div = display.lineDiv;
[1579] Fix | Delete
disableBrowserMagic(div, cm.options.spellcheck);
[1580] Fix | Delete
[1581] Fix | Delete
on(div, "paste", function(e) {
[1582] Fix | Delete
if (signalDOMEvent(cm, e) || handlePaste(e, cm)) return
[1583] Fix | Delete
// IE doesn't fire input events, so we schedule a read for the pasted content in this way
[1584] Fix | Delete
if (ie_version <= 11) setTimeout(operation(cm, function() {
[1585] Fix | Delete
if (!input.pollContent()) regChange(cm);
[1586] Fix | Delete
}), 20)
[1587] Fix | Delete
})
[1588] Fix | Delete
[1589] Fix | Delete
on(div, "compositionstart", function(e) {
[1590] Fix | Delete
var data = e.data;
[1591] Fix | Delete
input.composing = {sel: cm.doc.sel, data: data, startData: data};
[1592] Fix | Delete
if (!data) return;
[1593] Fix | Delete
var prim = cm.doc.sel.primary();
[1594] Fix | Delete
var line = cm.getLine(prim.head.line);
[1595] Fix | Delete
var found = line.indexOf(data, Math.max(0, prim.head.ch - data.length));
[1596] Fix | Delete
if (found > -1 && found <= prim.head.ch)
[1597] Fix | Delete
input.composing.sel = simpleSelection(Pos(prim.head.line, found),
[1598] Fix | Delete
Pos(prim.head.line, found + data.length));
[1599] Fix | Delete
});
[1600] Fix | Delete
on(div, "compositionupdate", function(e) {
[1601] Fix | Delete
input.composing.data = e.data;
[1602] Fix | Delete
});
[1603] Fix | Delete
on(div, "compositionend", function(e) {
[1604] Fix | Delete
var ours = input.composing;
[1605] Fix | Delete
if (!ours) return;
[1606] Fix | Delete
if (e.data != ours.startData && !/\u200b/.test(e.data))
[1607] Fix | Delete
ours.data = e.data;
[1608] Fix | Delete
// Need a small delay to prevent other code (input event,
[1609] Fix | Delete
// selection polling) from doing damage when fired right after
[1610] Fix | Delete
// compositionend.
[1611] Fix | Delete
setTimeout(function() {
[1612] Fix | Delete
if (!ours.handled)
[1613] Fix | Delete
input.applyComposition(ours);
[1614] Fix | Delete
if (input.composing == ours)
[1615] Fix | Delete
input.composing = null;
[1616] Fix | Delete
}, 50);
[1617] Fix | Delete
});
[1618] Fix | Delete
[1619] Fix | Delete
on(div, "touchstart", function() {
[1620] Fix | Delete
input.forceCompositionEnd();
[1621] Fix | Delete
});
[1622] Fix | Delete
[1623] Fix | Delete
on(div, "input", function() {
[1624] Fix | Delete
if (input.composing) return;
[1625] Fix | Delete
if (cm.isReadOnly() || !input.pollContent())
[1626] Fix | Delete
runInOp(input.cm, function() {regChange(cm);});
[1627] Fix | Delete
});
[1628] Fix | Delete
[1629] Fix | Delete
function onCopyCut(e) {
[1630] Fix | Delete
if (signalDOMEvent(cm, e)) return
[1631] Fix | Delete
if (cm.somethingSelected()) {
[1632] Fix | Delete
lastCopied = {lineWise: false, text: cm.getSelections()};
[1633] Fix | Delete
if (e.type == "cut") cm.replaceSelection("", null, "cut");
[1634] Fix | Delete
} else if (!cm.options.lineWiseCopyCut) {
[1635] Fix | Delete
return;
[1636] Fix | Delete
} else {
[1637] Fix | Delete
var ranges = copyableRanges(cm);
[1638] Fix | Delete
lastCopied = {lineWise: true, text: ranges.text};
[1639] Fix | Delete
if (e.type == "cut") {
[1640] Fix | Delete
cm.operation(function() {
[1641] Fix | Delete
cm.setSelections(ranges.ranges, 0, sel_dontScroll);
[1642] Fix | Delete
cm.replaceSelection("", null, "cut");
[1643] Fix | Delete
});
[1644] Fix | Delete
}
[1645] Fix | Delete
}
[1646] Fix | Delete
if (e.clipboardData) {
[1647] Fix | Delete
e.clipboardData.clearData();
[1648] Fix | Delete
var content = lastCopied.text.join("\n")
[1649] Fix | Delete
// iOS exposes the clipboard API, but seems to discard content inserted into it
[1650] Fix | Delete
e.clipboardData.setData("Text", content);
[1651] Fix | Delete
if (e.clipboardData.getData("Text") == content) {
[1652] Fix | Delete
e.preventDefault();
[1653] Fix | Delete
return
[1654] Fix | Delete
}
[1655] Fix | Delete
}
[1656] Fix | Delete
// Old-fashioned briefly-focus-a-textarea hack
[1657] Fix | Delete
var kludge = hiddenTextarea(), te = kludge.firstChild;
[1658] Fix | Delete
cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
[1659] Fix | Delete
te.value = lastCopied.text.join("\n");
[1660] Fix | Delete
var hadFocus = document.activeElement;
[1661] Fix | Delete
selectInput(te);
[1662] Fix | Delete
setTimeout(function() {
[1663] Fix | Delete
cm.display.lineSpace.removeChild(kludge);
[1664] Fix | Delete
hadFocus.focus();
[1665] Fix | Delete
if (hadFocus == div) input.showPrimarySelection()
[1666] Fix | Delete
}, 50);
[1667] Fix | Delete
}
[1668] Fix | Delete
on(div, "copy", onCopyCut);
[1669] Fix | Delete
on(div, "cut", onCopyCut);
[1670] Fix | Delete
},
[1671] Fix | Delete
[1672] Fix | Delete
prepareSelection: function() {
[1673] Fix | Delete
var result = prepareSelection(this.cm, false);
[1674] Fix | Delete
result.focus = this.cm.state.focused;
[1675] Fix | Delete
return result;
[1676] Fix | Delete
},
[1677] Fix | Delete
[1678] Fix | Delete
showSelection: function(info, takeFocus) {
[1679] Fix | Delete
if (!info || !this.cm.display.view.length) return;
[1680] Fix | Delete
if (info.focus || takeFocus) this.showPrimarySelection();
[1681] Fix | Delete
this.showMultipleSelections(info);
[1682] Fix | Delete
},
[1683] Fix | Delete
[1684] Fix | Delete
showPrimarySelection: function() {
[1685] Fix | Delete
var sel = window.getSelection(), prim = this.cm.doc.sel.primary();
[1686] Fix | Delete
var curAnchor = domToPos(this.cm, sel.anchorNode, sel.anchorOffset);
[1687] Fix | Delete
var curFocus = domToPos(this.cm, sel.focusNode, sel.focusOffset);
[1688] Fix | Delete
if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
[1689] Fix | Delete
cmp(minPos(curAnchor, curFocus), prim.from()) == 0 &&
[1690] Fix | Delete
cmp(maxPos(curAnchor, curFocus), prim.to()) == 0)
[1691] Fix | Delete
return;
[1692] Fix | Delete
[1693] Fix | Delete
var start = posToDOM(this.cm, prim.from());
[1694] Fix | Delete
var end = posToDOM(this.cm, prim.to());
[1695] Fix | Delete
if (!start && !end) return;
[1696] Fix | Delete
[1697] Fix | Delete
var view = this.cm.display.view;
[1698] Fix | Delete
var old = sel.rangeCount && sel.getRangeAt(0);
[1699] Fix | Delete
if (!start) {
[1700] Fix | Delete
start = {node: view[0].measure.map[2], offset: 0};
[1701] Fix | Delete
} else if (!end) { // FIXME dangerously hacky
[1702] Fix | Delete
var measure = view[view.length - 1].measure;
[1703] Fix | Delete
var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map;
[1704] Fix | Delete
end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]};
[1705] Fix | Delete
}
[1706] Fix | Delete
[1707] Fix | Delete
try { var rng = range(start.node, start.offset, end.offset, end.node); }
[1708] Fix | Delete
catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
[1709] Fix | Delete
if (rng) {
[1710] Fix | Delete
if (!gecko && this.cm.state.focused) {
[1711] Fix | Delete
sel.collapse(start.node, start.offset);
[1712] Fix | Delete
if (!rng.collapsed) sel.addRange(rng);
[1713] Fix | Delete
} else {
[1714] Fix | Delete
sel.removeAllRanges();
[1715] Fix | Delete
sel.addRange(rng);
[1716] Fix | Delete
}
[1717] Fix | Delete
if (old && sel.anchorNode == null) sel.addRange(old);
[1718] Fix | Delete
else if (gecko) this.startGracePeriod();
[1719] Fix | Delete
}
[1720] Fix | Delete
this.rememberSelection();
[1721] Fix | Delete
},
[1722] Fix | Delete
[1723] Fix | Delete
startGracePeriod: function() {
[1724] Fix | Delete
var input = this;
[1725] Fix | Delete
clearTimeout(this.gracePeriod);
[1726] Fix | Delete
this.gracePeriod = setTimeout(function() {
[1727] Fix | Delete
input.gracePeriod = false;
[1728] Fix | Delete
if (input.selectionChanged())
[1729] Fix | Delete
input.cm.operation(function() { input.cm.curOp.selectionChanged = true; });
[1730] Fix | Delete
}, 20);
[1731] Fix | Delete
},
[1732] Fix | Delete
[1733] Fix | Delete
showMultipleSelections: function(info) {
[1734] Fix | Delete
removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors);
[1735] Fix | Delete
removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection);
[1736] Fix | Delete
},
[1737] Fix | Delete
[1738] Fix | Delete
rememberSelection: function() {
[1739] Fix | Delete
var sel = window.getSelection();
[1740] Fix | Delete
this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset;
[1741] Fix | Delete
this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset;
[1742] Fix | Delete
},
[1743] Fix | Delete
[1744] Fix | Delete
selectionInEditor: function() {
[1745] Fix | Delete
var sel = window.getSelection();
[1746] Fix | Delete
if (!sel.rangeCount) return false;
[1747] Fix | Delete
var node = sel.getRangeAt(0).commonAncestorContainer;
[1748] Fix | Delete
return contains(this.div, node);
[1749] Fix | Delete
},
[1750] Fix | Delete
[1751] Fix | Delete
focus: function() {
[1752] Fix | Delete
if (this.cm.options.readOnly != "nocursor") this.div.focus();
[1753] Fix | Delete
},
[1754] Fix | Delete
blur: function() { this.div.blur(); },
[1755] Fix | Delete
getField: function() { return this.div; },
[1756] Fix | Delete
[1757] Fix | Delete
supportsTouch: function() { return true; },
[1758] Fix | Delete
[1759] Fix | Delete
receivedFocus: function() {
[1760] Fix | Delete
var input = this;
[1761] Fix | Delete
if (this.selectionInEditor())
[1762] Fix | Delete
this.pollSelection();
[1763] Fix | Delete
else
[1764] Fix | Delete
runInOp(this.cm, function() { input.cm.curOp.selectionChanged = true; });
[1765] Fix | Delete
[1766] Fix | Delete
function poll() {
[1767] Fix | Delete
if (input.cm.state.focused) {
[1768] Fix | Delete
input.pollSelection();
[1769] Fix | Delete
input.polling.set(input.cm.options.pollInterval, poll);
[1770] Fix | Delete
}
[1771] Fix | Delete
}
[1772] Fix | Delete
this.polling.set(this.cm.options.pollInterval, poll);
[1773] Fix | Delete
},
[1774] Fix | Delete
[1775] Fix | Delete
selectionChanged: function() {
[1776] Fix | Delete
var sel = window.getSelection();
[1777] Fix | Delete
return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset ||
[1778] Fix | Delete
sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset;
[1779] Fix | Delete
},
[1780] Fix | Delete
[1781] Fix | Delete
pollSelection: function() {
[1782] Fix | Delete
if (!this.composing && !this.gracePeriod && this.selectionChanged()) {
[1783] Fix | Delete
var sel = window.getSelection(), cm = this.cm;
[1784] Fix | Delete
this.rememberSelection();
[1785] Fix | Delete
var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
[1786] Fix | Delete
var head = domToPos(cm, sel.focusNode, sel.focusOffset);
[1787] Fix | Delete
if (anchor && head) runInOp(cm, function() {
[1788] Fix | Delete
setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll);
[1789] Fix | Delete
if (anchor.bad || head.bad) cm.curOp.selectionChanged = true;
[1790] Fix | Delete
});
[1791] Fix | Delete
}
[1792] Fix | Delete
},
[1793] Fix | Delete
[1794] Fix | Delete
pollContent: function() {
[1795] Fix | Delete
var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary();
[1796] Fix | Delete
var from = sel.from(), to = sel.to();
[1797] Fix | Delete
if (from.line < display.viewFrom || to.line > display.viewTo - 1) return false;
[1798] Fix | Delete
[1799] Fix | Delete
var fromIndex;
[1800] Fix | Delete
if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
[1801] Fix | Delete
var fromLine = lineNo(display.view[0].line);
[1802] Fix | Delete
var fromNode = display.view[0].node;
[1803] Fix | Delete
} else {
[1804] Fix | Delete
var fromLine = lineNo(display.view[fromIndex].line);
[1805] Fix | Delete
var fromNode = display.view[fromIndex - 1].node.nextSibling;
[1806] Fix | Delete
}
[1807] Fix | Delete
var toIndex = findViewIndex(cm, to.line);
[1808] Fix | Delete
if (toIndex == display.view.length - 1) {
[1809] Fix | Delete
var toLine = display.viewTo - 1;
[1810] Fix | Delete
var toNode = display.lineDiv.lastChild;
[1811] Fix | Delete
} else {
[1812] Fix | Delete
var toLine = lineNo(display.view[toIndex + 1].line) - 1;
[1813] Fix | Delete
var toNode = display.view[toIndex + 1].node.previousSibling;
[1814] Fix | Delete
}
[1815] Fix | Delete
[1816] Fix | Delete
var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
[1817] Fix | Delete
var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
[1818] Fix | Delete
while (newText.length > 1 && oldText.length > 1) {
[1819] Fix | Delete
if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; }
[1820] Fix | Delete
else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; }
[1821] Fix | Delete
else break;
[1822] Fix | Delete
}
[1823] Fix | Delete
[1824] Fix | Delete
var cutFront = 0, cutEnd = 0;
[1825] Fix | Delete
var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length);
[1826] Fix | Delete
while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))
[1827] Fix | Delete
++cutFront;
[1828] Fix | Delete
var newBot = lst(newText), oldBot = lst(oldText);
[1829] Fix | Delete
var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),
[1830] Fix | Delete
oldBot.length - (oldText.length == 1 ? cutFront : 0));
[1831] Fix | Delete
while (cutEnd < maxCutEnd &&
[1832] Fix | Delete
newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
[1833] Fix | Delete
++cutEnd;
[1834] Fix | Delete
[1835] Fix | Delete
newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd);
[1836] Fix | Delete
newText[0] = newText[0].slice(cutFront);
[1837] Fix | Delete
[1838] Fix | Delete
var chFrom = Pos(fromLine, cutFront);
[1839] Fix | Delete
var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0);
[1840] Fix | Delete
if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
[1841] Fix | Delete
replaceRange(cm.doc, newText, chFrom, chTo, "+input");
[1842] Fix | Delete
return true;
[1843] Fix | Delete
}
[1844] Fix | Delete
},
[1845] Fix | Delete
[1846] Fix | Delete
ensurePolled: function() {
[1847] Fix | Delete
this.forceCompositionEnd();
[1848] Fix | Delete
},
[1849] Fix | Delete
reset: function() {
[1850] Fix | Delete
this.forceCompositionEnd();
[1851] Fix | Delete
},
[1852] Fix | Delete
forceCompositionEnd: function() {
[1853] Fix | Delete
if (!this.composing || this.composing.handled) return;
[1854] Fix | Delete
this.applyComposition(this.composing);
[1855] Fix | Delete
this.composing.handled = true;
[1856] Fix | Delete
this.div.blur();
[1857] Fix | Delete
this.div.focus();
[1858] Fix | Delete
},
[1859] Fix | Delete
applyComposition: function(composing) {
[1860] Fix | Delete
if (this.cm.isReadOnly())
[1861] Fix | Delete
operation(this.cm, regChange)(this.cm)
[1862] Fix | Delete
else if (composing.data && composing.data != composing.startData)
[1863] Fix | Delete
operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel);
[1864] Fix | Delete
},
[1865] Fix | Delete
[1866] Fix | Delete
setUneditable: function(node) {
[1867] Fix | Delete
node.contentEditable = "false"
[1868] Fix | Delete
},
[1869] Fix | Delete
[1870] Fix | Delete
onKeyPress: function(e) {
[1871] Fix | Delete
e.preventDefault();
[1872] Fix | Delete
if (!this.cm.isReadOnly())
[1873] Fix | Delete
operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
[1874] Fix | Delete
},
[1875] Fix | Delete
[1876] Fix | Delete
readOnlyChanged: function(val) {
[1877] Fix | Delete
this.div.contentEditable = String(val != "nocursor")
[1878] Fix | Delete
},
[1879] Fix | Delete
[1880] Fix | Delete
onContextMenu: nothing,
[1881] Fix | Delete
resetPosition: nothing,
[1882] Fix | Delete
[1883] Fix | Delete
needsContentAttribute: true
[1884] Fix | Delete
}, ContentEditableInput.prototype);
[1885] Fix | Delete
[1886] Fix | Delete
function posToDOM(cm, pos) {
[1887] Fix | Delete
var view = findViewForLine(cm, pos.line);
[1888] Fix | Delete
if (!view || view.hidden) return null;
[1889] Fix | Delete
var line = getLine(cm.doc, pos.line);
[1890] Fix | Delete
var info = mapFromLineView(view, line, pos.line);
[1891] Fix | Delete
[1892] Fix | Delete
var order = getOrder(line), side = "left";
[1893] Fix | Delete
if (order) {
[1894] Fix | Delete
var partPos = getBidiPartAt(order, pos.ch);
[1895] Fix | Delete
side = partPos % 2 ? "right" : "left";
[1896] Fix | Delete
}
[1897] Fix | Delete
var result = nodeAndOffsetInLineMap(info.map, pos.ch, side);
[1898] Fix | Delete
result.offset = result.collapse == "right" ? result.end : result.start;
[1899] Fix | Delete
return result;
[1900] Fix | Delete
}
[1901] Fix | Delete
[1902] Fix | Delete
function badPos(pos, bad) { if (bad) pos.bad = true; return pos; }
[1903] Fix | Delete
[1904] Fix | Delete
function domToPos(cm, node, offset) {
[1905] Fix | Delete
var lineNode;
[1906] Fix | Delete
if (node == cm.display.lineDiv) {
[1907] Fix | Delete
lineNode = cm.display.lineDiv.childNodes[offset];
[1908] Fix | Delete
if (!lineNode) return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true);
[1909] Fix | Delete
node = null; offset = 0;
[1910] Fix | Delete
} else {
[1911] Fix | Delete
for (lineNode = node;; lineNode = lineNode.parentNode) {
[1912] Fix | Delete
if (!lineNode || lineNode == cm.display.lineDiv) return null;
[1913] Fix | Delete
if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) break;
[1914] Fix | Delete
}
[1915] Fix | Delete
}
[1916] Fix | Delete
for (var i = 0; i < cm.display.view.length; i++) {
[1917] Fix | Delete
var lineView = cm.display.view[i];
[1918] Fix | Delete
if (lineView.node == lineNode)
[1919] Fix | Delete
return locateNodeInLineView(lineView, node, offset);
[1920] Fix | Delete
}
[1921] Fix | Delete
}
[1922] Fix | Delete
[1923] Fix | Delete
function locateNodeInLineView(lineView, node, offset) {
[1924] Fix | Delete
var wrapper = lineView.text.firstChild, bad = false;
[1925] Fix | Delete
if (!node || !contains(wrapper, node)) return badPos(Pos(lineNo(lineView.line), 0), true);
[1926] Fix | Delete
if (node == wrapper) {
[1927] Fix | Delete
bad = true;
[1928] Fix | Delete
node = wrapper.childNodes[offset];
[1929] Fix | Delete
offset = 0;
[1930] Fix | Delete
if (!node) {
[1931] Fix | Delete
var line = lineView.rest ? lst(lineView.rest) : lineView.line;
[1932] Fix | Delete
return badPos(Pos(lineNo(line), line.text.length), bad);
[1933] Fix | Delete
}
[1934] Fix | Delete
}
[1935] Fix | Delete
[1936] Fix | Delete
var textNode = node.nodeType == 3 ? node : null, topNode = node;
[1937] Fix | Delete
if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {
[1938] Fix | Delete
textNode = node.firstChild;
[1939] Fix | Delete
if (offset) offset = textNode.nodeValue.length;
[1940] Fix | Delete
}
[1941] Fix | Delete
while (topNode.parentNode != wrapper) topNode = topNode.parentNode;
[1942] Fix | Delete
var measure = lineView.measure, maps = measure.maps;
[1943] Fix | Delete
[1944] Fix | Delete
function find(textNode, topNode, offset) {
[1945] Fix | Delete
for (var i = -1; i < (maps ? maps.length : 0); i++) {
[1946] Fix | Delete
var map = i < 0 ? measure.map : maps[i];
[1947] Fix | Delete
for (var j = 0; j < map.length; j += 3) {
[1948] Fix | Delete
var curNode = map[j + 2];
[1949] Fix | Delete
if (curNode == textNode || curNode == topNode) {
[1950] Fix | Delete
var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]);
[1951] Fix | Delete
var ch = map[j] + offset;
[1952] Fix | Delete
if (offset < 0 || curNode != textNode) ch = map[j + (offset ? 1 : 0)];
[1953] Fix | Delete
return Pos(line, ch);
[1954] Fix | Delete
}
[1955] Fix | Delete
}
[1956] Fix | Delete
}
[1957] Fix | Delete
}
[1958] Fix | Delete
var found = find(textNode, topNode, offset);
[1959] Fix | Delete
if (found) return badPos(found, bad);
[1960] Fix | Delete
[1961] Fix | Delete
// FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems
[1962] Fix | Delete
for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {
[1963] Fix | Delete
found = find(after, after.firstChild, 0);
[1964] Fix | Delete
if (found)
[1965] Fix | Delete
return badPos(Pos(found.line, found.ch - dist), bad);
[1966] Fix | Delete
else
[1967] Fix | Delete
dist += after.textContent.length;
[1968] Fix | Delete
}
[1969] Fix | Delete
for (var before = topNode.previousSibling, dist = offset; before; before = before.previousSibling) {
[1970] Fix | Delete
found = find(before, before.firstChild, -1);
[1971] Fix | Delete
if (found)
[1972] Fix | Delete
return badPos(Pos(found.line, found.ch + dist), bad);
[1973] Fix | Delete
else
[1974] Fix | Delete
dist += before.textContent.length;
[1975] Fix | Delete
}
[1976] Fix | Delete
}
[1977] Fix | Delete
[1978] Fix | Delete
function domTextBetween(cm, from, to, fromLine, toLine) {
[1979] Fix | Delete
var text = "", closing = false, lineSep = cm.doc.lineSeparator();
[1980] Fix | Delete
function recognizeMarker(id) { return function(marker) { return marker.id == id; }; }
[1981] Fix | Delete
function walk(node) {
[1982] Fix | Delete
if (node.nodeType == 1) {
[1983] Fix | Delete
var cmText = node.getAttribute("cm-text");
[1984] Fix | Delete
if (cmText != null) {
[1985] Fix | Delete
if (cmText == "") cmText = node.textContent.replace(/\u200b/g, "");
[1986] Fix | Delete
text += cmText;
[1987] Fix | Delete
return;
[1988] Fix | Delete
}
[1989] Fix | Delete
var markerID = node.getAttribute("cm-marker"), range;
[1990] Fix | Delete
if (markerID) {
[1991] Fix | Delete
var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
[1992] Fix | Delete
if (found.length && (range = found[0].find()))
[1993] Fix | Delete
text += getBetween(cm.doc, range.from, range.to).join(lineSep);
[1994] Fix | Delete
return;
[1995] Fix | Delete
}
[1996] Fix | Delete
if (node.getAttribute("contenteditable") == "false") return;
[1997] Fix | Delete
for (var i = 0; i < node.childNodes.length; i++)
[1998] Fix | Delete
walk(node.childNodes[i]);
[1999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function