zhangchao 5 년 전
부모
커밋
8fc4e2874f
1개의 변경된 파일38개의 추가작업 그리고 3개의 파일을 삭제
  1. 38
    3
      src/editor.html

+ 38
- 3
src/editor.html 파일 보기

919
 				// zss_editor.focusContent();
919
 				// zss_editor.focusContent();
920
 
920
 
921
 				setTimeout(function() {
921
 				setTimeout(function() {
922
+					zss_editor.setContentFocusHandler()
922
 					ReactNativeWebView.postMessage(JSON.stringify({type: 'ZSS_INITIALIZED'}))
923
 					ReactNativeWebView.postMessage(JSON.stringify({type: 'ZSS_INITIALIZED'}))
923
 				}, 20);
924
 				}, 20);
924
 
925
 
1061
 				try {
1062
 				try {
1062
 					var range = selection.getRangeAt(0);
1063
 					var range = selection.getRangeAt(0);
1063
 					zss_editor.currentSelection = {"startContainer": range.startContainer, "startOffset":range.startOffset,"endContainer":range.endContainer, "endOffset":range.endOffset};
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
 				} catch (err) {}
1068
 				} catch (err) {}
1065
 			}
1069
 			}
1066
 
1070
 
1072
 					range.setStart(zss_editor.currentSelection.startContainer, zss_editor.currentSelection.startOffset);
1076
 					range.setStart(zss_editor.currentSelection.startContainer, zss_editor.currentSelection.startOffset);
1073
 					range.setEnd(zss_editor.currentSelection.endContainer, zss_editor.currentSelection.endOffset);
1077
 					range.setEnd(zss_editor.currentSelection.endContainer, zss_editor.currentSelection.endOffset);
1074
 					selection.addRange(range);
1078
 					selection.addRange(range);
1075
-				} catch (err) {}
1079
+				} catch (err) { }
1076
 			}
1080
 			}
1077
 
1081
 
1078
 			zss_editor.getSelectedNode = function() {
1082
 			zss_editor.getSelectedNode = function() {
1355
 			zss_editor.insertEmoji = function(url) {
1359
 			zss_editor.insertEmoji = function(url) {
1356
 				zss_editor.restorerange();
1360
 				zss_editor.restorerange();
1357
 				document.execCommand('insertHTML', false, '<img class="emoji" src="' + encodeHtmlEntities(url) + '"/>');
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
 				zss_editor.enabledEditingItems();
1365
 				zss_editor.enabledEditingItems();
1360
 			}
1366
 			}
1361
 
1367
 
1640
 
1646
 
1641
 			zss_editor.setContentFocusHandler = function() {
1647
 			zss_editor.setContentFocusHandler = function() {
1642
 				addFocusEvent('zss_editor_content', function() {
1648
 				addFocusEvent('zss_editor_content', function() {
1649
+					$('.caret_placeholder').remove();
1643
 					ReactNativeWebView.postMessage(JSON.stringify({type: 'CONTENT_FOCUSED'}))
1650
 					ReactNativeWebView.postMessage(JSON.stringify({type: 'CONTENT_FOCUSED'}))
1644
 				});
1651
 				});
1645
 			}
1652
 			}
1657
 			zss_editor.setPlatform = function(platform) {
1664
 			zss_editor.setPlatform = function(platform) {
1658
 				zss_editor.platform = platform;
1665
 				zss_editor.platform = platform;
1659
 			}
1666
 			}
1660
-
1661
 			//end
1667
 			//end
1662
 		</script>
1668
 		</script>
1663
 
1669
 
1664
 		<style type="text/css">
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
 			/* Default ZSSRichTextEditor Styling */
1691
 			/* Default ZSSRichTextEditor Styling */
1666
 			* {
1692
 			* {
1667
 				outline: 0px solid transparent;
1693
 				outline: 0px solid transparent;
1750
 				display: inline-block;
1776
 				display: inline-block;
1751
 				vertical-align: top;
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
 		</style>
1788
 		</style>
1754
 
1789
 
1755
 		<style type="text/css">
1790
 		<style type="text/css">