zhangchao 4 年之前
父節點
當前提交
8fc4e2874f
共有 1 個檔案被更改,包括 38 行新增3 行删除
  1. 38
    3
      src/editor.html

+ 38
- 3
src/editor.html 查看文件

@@ -919,6 +919,7 @@
919 919
 				// zss_editor.focusContent();
920 920
 
921 921
 				setTimeout(function() {
922
+					zss_editor.setContentFocusHandler()
922 923
 					ReactNativeWebView.postMessage(JSON.stringify({type: 'ZSS_INITIALIZED'}))
923 924
 				}, 20);
924 925
 
@@ -1061,6 +1062,9 @@
1061 1062
 				try {
1062 1063
 					var range = selection.getRangeAt(0);
1063 1064
 					zss_editor.currentSelection = {"startContainer": range.startContainer, "startOffset":range.startOffset,"endContainer":range.endContainer, "endOffset":range.endOffset};
1065
+					if (range.endOffset === range.startOffset) {
1066
+						zss_editor.insertHTML('<div class="caret_placeholder">&nbsp;&nbsp;</div>');
1067
+					}
1064 1068
 				} catch (err) {}
1065 1069
 			}
1066 1070
 
@@ -1072,7 +1076,7 @@
1072 1076
 					range.setStart(zss_editor.currentSelection.startContainer, zss_editor.currentSelection.startOffset);
1073 1077
 					range.setEnd(zss_editor.currentSelection.endContainer, zss_editor.currentSelection.endOffset);
1074 1078
 					selection.addRange(range);
1075
-				} catch (err) {}
1079
+				} catch (err) { }
1076 1080
 			}
1077 1081
 
1078 1082
 			zss_editor.getSelectedNode = function() {
@@ -1355,7 +1359,9 @@
1355 1359
 			zss_editor.insertEmoji = function(url) {
1356 1360
 				zss_editor.restorerange();
1357 1361
 				document.execCommand('insertHTML', false, '<img class="emoji" src="' + encodeHtmlEntities(url) + '"/>');
1358
-				zss_editor.blurContentEditor()
1362
+				zss_editor.backuprange();
1363
+				zss_editor.blurContentEditor();
1364
+				
1359 1365
 				zss_editor.enabledEditingItems();
1360 1366
 			}
1361 1367
 
@@ -1640,6 +1646,7 @@
1640 1646
 
1641 1647
 			zss_editor.setContentFocusHandler = function() {
1642 1648
 				addFocusEvent('zss_editor_content', function() {
1649
+					$('.caret_placeholder').remove();
1643 1650
 					ReactNativeWebView.postMessage(JSON.stringify({type: 'CONTENT_FOCUSED'}))
1644 1651
 				});
1645 1652
 			}
@@ -1657,11 +1664,30 @@
1657 1664
 			zss_editor.setPlatform = function(platform) {
1658 1665
 				zss_editor.platform = platform;
1659 1666
 			}
1660
-
1661 1667
 			//end
1662 1668
 		</script>
1663 1669
 
1664 1670
 		<style type="text/css">
1671
+			@keyframes fade {
1672
+				from {
1673
+					opacity: 1.0;
1674
+				}
1675
+				15% {
1676
+					opacity: 1.0;
1677
+				}
1678
+				40% {
1679
+					opacity: 0;
1680
+				}
1681
+				60% {
1682
+					opacity: 0;
1683
+				}
1684
+				85% {
1685
+					opacity: 1.0;
1686
+				}
1687
+				to {
1688
+					opacity: 1.0;
1689
+				}
1690
+			}
1665 1691
 			/* Default ZSSRichTextEditor Styling */
1666 1692
 			* {
1667 1693
 				outline: 0px solid transparent;
@@ -1750,6 +1776,15 @@
1750 1776
 				display: inline-block;
1751 1777
 				vertical-align: top;
1752 1778
 			}
1779
+
1780
+			.caret_placeholder {
1781
+				display: inline-block;
1782
+				height: 19px;
1783
+				width: 2px;
1784
+				background-color: rgb(90, 149, 211);
1785
+				overflow: hidden;
1786
+				animation: fade 1.2s infinite;
1787
+			}
1753 1788
 		</style>
1754 1789
 
1755 1790
 		<style type="text/css">