|
@@ -1057,12 +1057,12 @@
|
1057
|
1057
|
}
|
1058
|
1058
|
}
|
1059
|
1059
|
|
1060
|
|
- zss_editor.backuprange = function(){
|
|
1060
|
+ zss_editor.backuprange = function(showCaretPlaceholder){
|
1061
|
1061
|
var selection = window.getSelection();
|
1062
|
1062
|
try {
|
1063
|
1063
|
var range = selection.getRangeAt(0);
|
1064
|
1064
|
zss_editor.currentSelection = {"startContainer": range.startContainer, "startOffset":range.startOffset,"endContainer":range.endContainer, "endOffset":range.endOffset};
|
1065
|
|
- if (range.endOffset === range.startOffset) {
|
|
1065
|
+ if (range.endOffset === range.startOffset && showCaretPlaceholder === true) {
|
1066
|
1066
|
zss_editor.insertHTML('<div class="caret_placeholder"> </div>');
|
1067
|
1067
|
}
|
1068
|
1068
|
} catch (err) {}
|
|
@@ -1260,8 +1260,9 @@
|
1260
|
1260
|
zss_editor.insertLink = function(url, title) {
|
1261
|
1261
|
zss_editor.restorerange();
|
1262
|
1262
|
var sel = window.getSelection();
|
1263
|
|
- sel.deleteFromDocument();
|
|
1263
|
+ // sel.deleteFromDocument();
|
1264
|
1264
|
zss_editor.insertHTML('<a href="'+ url +'">'+ title +'</a>');
|
|
1265
|
+ zss_editor.focusContent();
|
1265
|
1266
|
zss_editor.enabledEditingItems();
|
1266
|
1267
|
}
|
1267
|
1268
|
|
|
@@ -1344,8 +1345,8 @@
|
1344
|
1345
|
|
1345
|
1346
|
}
|
1346
|
1347
|
|
1347
|
|
- zss_editor.prepareInsert = function() {
|
1348
|
|
- zss_editor.backuprange();
|
|
1348
|
+ zss_editor.prepareInsert = function(showCaretPlaceholder) {
|
|
1349
|
+ zss_editor.backuprange(showCaretPlaceholder);
|
1349
|
1350
|
}
|
1350
|
1351
|
|
1351
|
1352
|
zss_editor.insertImage = function(url) {
|
|
@@ -1359,9 +1360,17 @@
|
1359
|
1360
|
zss_editor.insertEmoji = function(url) {
|
1360
|
1361
|
zss_editor.restorerange();
|
1361
|
1362
|
document.execCommand('insertHTML', false, '<img class="emoji" src="' + encodeHtmlEntities(url) + '"/>');
|
1362
|
|
- zss_editor.backuprange();
|
|
1363
|
+ zss_editor.backuprange(true);
|
|
1364
|
+ zss_editor.blurContentEditor();
|
|
1365
|
+ zss_editor.enabledEditingItems();
|
|
1366
|
+
|
|
1367
|
+ }
|
|
1368
|
+
|
|
1369
|
+ zss_editor.deleteEmoji = function(url) {
|
|
1370
|
+ zss_editor.restorerange();
|
|
1371
|
+ document.execCommand('Delete', false, null);
|
|
1372
|
+ zss_editor.backuprange(true);
|
1363
|
1373
|
zss_editor.blurContentEditor();
|
1364
|
|
-
|
1365
|
1374
|
zss_editor.enabledEditingItems();
|
1366
|
1375
|
}
|
1367
|
1376
|
|
|
@@ -1406,6 +1415,7 @@
|
1406
|
1415
|
}
|
1407
|
1416
|
|
1408
|
1417
|
zss_editor.setContentHTML = function(html) {
|
|
1418
|
+ contentIsEmpty = html.length === 0;
|
1409
|
1419
|
setHTML('zss_editor_content', html);
|
1410
|
1420
|
}
|
1411
|
1421
|
|
|
@@ -1590,7 +1600,6 @@
|
1590
|
1600
|
}
|
1591
|
1601
|
|
1592
|
1602
|
zss_editor.focusEditor = function(editorId) {
|
1593
|
|
-
|
1594
|
1603
|
// the following was taken from http://stackoverflow.com/questions/1125292/how-to-move-cursor-to-end-of-contenteditable-entity/3866442#3866442
|
1595
|
1604
|
// and ensures we move the cursor to the end of the editor
|
1596
|
1605
|
var editor = $('#' + editorId);
|
|
@@ -1613,19 +1622,7 @@
|
1613
|
1622
|
}
|
1614
|
1623
|
|
1615
|
1624
|
zss_editor.setCustomCSS = function(customCSS) {
|
1616
|
|
-
|
1617
|
1625
|
document.getElementsByTagName('style')[1].innerHTML=customCSS;
|
1618
|
|
-
|
1619
|
|
- //set focus
|
1620
|
|
- /*editor.focusout(function(){
|
1621
|
|
- var element = $(this);
|
1622
|
|
- if (!element.text().trim().length) {
|
1623
|
|
- element.empty();
|
1624
|
|
- }
|
1625
|
|
- });*/
|
1626
|
|
-
|
1627
|
|
-
|
1628
|
|
-
|
1629
|
1626
|
}
|
1630
|
1627
|
|
1631
|
1628
|
function addFocusEvent(editorId, callbackHandler) {
|
|
@@ -1657,6 +1654,17 @@
|
1657
|
1654
|
});
|
1658
|
1655
|
}
|
1659
|
1656
|
|
|
1657
|
+ var contentIsEmpty = true;
|
|
1658
|
+ zss_editor.setOnChangeEmptyOrNot = function() {
|
|
1659
|
+ $('#zss_editor_content').on('input', function() {
|
|
1660
|
+ if (!this.textContent && this.querySelectorAll('img, li').length === 0 && !contentIsEmpty) {
|
|
1661
|
+ ReactNativeWebView.postMessage(JSON.stringify({type: 'ONCHANGE_EMPTY_OR_NOT', isEmpty: true}))
|
|
1662
|
+ } else if (contentIsEmpty && (this.textContent || this.querySelectorAll('img, li').length > 0)) {
|
|
1663
|
+ ReactNativeWebView.postMessage(JSON.stringify({type: 'ONCHANGE_EMPTY_OR_NOT', isEmpty: false}))
|
|
1664
|
+ }
|
|
1665
|
+ });
|
|
1666
|
+ }
|
|
1667
|
+
|
1660
|
1668
|
zss_editor.setEditorHeight = function(editorHeight) {
|
1661
|
1669
|
zss_editor.editorHeight = editorHeight;
|
1662
|
1670
|
}
|