vditor 3.11.3 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +2 -0
  2. package/dist/css/content-theme/ant-design.css +7 -22
  3. package/dist/css/content-theme/dark.css +7 -16
  4. package/dist/css/content-theme/light.css +7 -15
  5. package/dist/css/content-theme/wechat.css +7 -19
  6. package/dist/index.css +132 -135
  7. package/dist/index.js +3791 -4022
  8. package/dist/index.min.js +1 -1
  9. package/dist/js/lute/lute.min.js +2 -2
  10. package/dist/js/mermaid/mermaid.min.js +516 -467
  11. package/dist/method.js +41 -33
  12. package/dist/method.min.js +1 -1
  13. package/dist/ts/constants.d.ts +1 -0
  14. package/dist/ts/sv/index.d.ts +1 -5
  15. package/dist/ts/sv/process.d.ts +1 -3
  16. package/dist/ts/upload/getElement.d.ts +1 -1
  17. package/dist/ts/upload/index.d.ts +2 -0
  18. package/dist/ts/util/editorCommonEvent.d.ts +1 -1
  19. package/dist/types/index.d.ts +10 -5
  20. package/package.json +1 -1
  21. package/src/assets/less/_reset.less +80 -28
  22. package/src/assets/less/_sv.less +2 -98
  23. package/src/assets/less/_wysiwyg.less +30 -0
  24. package/src/assets/less/index.less +14 -20
  25. package/src/index.ts +46 -14
  26. package/src/ts/constants.ts +1 -0
  27. package/src/ts/export/index.ts +1 -0
  28. package/src/ts/hint/index.ts +9 -4
  29. package/src/ts/ir/highlightToolbarIR.ts +4 -4
  30. package/src/ts/markdown/getMarkdown.ts +3 -3
  31. package/src/ts/markdown/mediaRender.ts +23 -38
  32. package/src/ts/markdown/mermaidRender.ts +1 -1
  33. package/src/ts/markdown/previewRender.ts +1 -0
  34. package/src/ts/markdown/setLute.ts +1 -0
  35. package/src/ts/sv/index.ts +37 -76
  36. package/src/ts/sv/process.ts +48 -164
  37. package/src/ts/sv/processKeydown.ts +19 -186
  38. package/src/ts/toolbar/EditMode.ts +3 -10
  39. package/src/ts/toolbar/Emoji.ts +8 -1
  40. package/src/ts/toolbar/Record.ts +10 -2
  41. package/src/ts/toolbar/index.ts +3 -0
  42. package/src/ts/ui/initUI.ts +7 -3
  43. package/src/ts/undo/index.ts +32 -17
  44. package/src/ts/upload/index.ts +42 -10
  45. package/src/ts/util/editorCommonEvent.ts +18 -9
  46. package/src/ts/util/fixBrowserBehavior.ts +106 -36
  47. package/src/ts/util/selection.ts +11 -3
  48. package/src/ts/wysiwyg/highlightToolbarWYSIWYG.ts +53 -1
  49. package/src/ts/wysiwyg/processKeydown.ts +47 -0
  50. package/dist/ts/sv/combineFootnote.d.ts +0 -6
  51. package/dist/ts/sv/inputEvent.d.ts +0 -1
  52. package/src/ts/sv/combineFootnote.ts +0 -27
  53. package/src/ts/sv/inputEvent.ts +0 -188
@@ -152,12 +152,27 @@
152
152
  margin-bottom: 16px;
153
153
  }
154
154
 
155
- blockquote {
156
- padding: 0 1em;
157
- color: #6a737d;
158
- border-left: 0.25em solid #eaecef;
155
+ blockquote:not(.callout) {
156
+ position: relative;
157
+ display: flex;
158
+ flex-direction: column;
159
+ padding: 0 0 0 calc(0.25em + 6px);
160
+ color: var(--blockquote-text-color, #5f6368);
161
+ background-color: transparent;
162
+ border: 0;
159
163
  margin: 0 0 16px 0;
160
164
 
165
+ &::before {
166
+ position: absolute;
167
+ top: 6px;
168
+ bottom: 6px;
169
+ left: 2px;
170
+ width: 0.25em;
171
+ content: "";
172
+ background-color: var(--blockquote-border-color, #e0e0e0);
173
+ border-radius: 6px;
174
+ }
175
+
161
176
  & > :first-child {
162
177
  margin-top: 0;
163
178
  }
@@ -165,6 +180,13 @@
165
180
  & > :last-child {
166
181
  margin-bottom: 0;
167
182
  }
183
+
184
+ & > p {
185
+ padding: 4px;
186
+ margin: 2px 0;
187
+ line-height: 1.625;
188
+ border-radius: 6px;
189
+ }
168
190
  }
169
191
 
170
192
  ins > iframe {
@@ -652,69 +674,99 @@
652
674
  .vditor-reset .callout,
653
675
  .vditor-wysiwyg blockquote.callout,
654
676
  .vditor-ir blockquote.callout {
655
- --callout-color: var(--callout-note-color, #0969da);
656
- --callout-background-color: var(--callout-note-background-color, rgba(9, 105, 218, 0.08));
677
+ --callout-color: var(--callout-note-color, #3575f0);
657
678
  position: relative;
679
+ display: flex;
680
+ flex-direction: column;
658
681
  margin: 0 0 16px;
659
- padding: 0.75em 1em;
660
- color: inherit;
661
- background-color: var(--callout-background-color);
682
+ padding: 0 0 0 calc(0.25em + 6px);
683
+ color: var(--blockquote-text-color, #5f6368);
662
684
  border: 0;
663
- border-left: 0.25em solid var(--callout-color);
685
+
686
+ &::before {
687
+ position: absolute;
688
+ top: 6px;
689
+ bottom: 6px;
690
+ left: 2px;
691
+ width: 0.25em;
692
+ content: "";
693
+ background-color: var(--callout-color);
694
+ border-radius: 6px;
695
+ }
664
696
 
665
697
  &[data-subtype="TIP"] {
666
- --callout-color: var(--callout-tip-color, #1a7f37);
667
- --callout-background-color: var(--callout-tip-background-color, rgba(26, 127, 55, 0.08));
698
+ --callout-color: var(--callout-tip-color, #65b84d);
668
699
  }
669
700
 
670
701
  &[data-subtype="IMPORTANT"] {
671
- --callout-color: var(--callout-important-color, #8250df);
672
- --callout-background-color: var(--callout-important-background-color, rgba(130, 80, 223, 0.08));
702
+ --callout-color: var(--callout-important-color, #8957e5);
673
703
  }
674
704
 
675
705
  &[data-subtype="WARNING"] {
676
- --callout-color: var(--callout-warning-color, #9a6700);
677
- --callout-background-color: var(--callout-warning-background-color, rgba(154, 103, 0, 0.08));
706
+ --callout-color: var(--callout-warning-color, #ff9632);
678
707
  }
679
708
 
680
709
  &[data-subtype="CAUTION"] {
681
- --callout-color: var(--callout-caution-color, #cf222e);
682
- --callout-background-color: var(--callout-caution-background-color, rgba(207, 34, 46, 0.08));
710
+ --callout-color: var(--callout-caution-color, #d23f31);
683
711
  }
684
712
 
685
713
  > .callout-info {
686
714
  display: flex;
687
715
  align-items: center;
688
716
  min-height: 1.5em;
689
- margin: 0 0 0.5em;
717
+ margin: 2px 0;
718
+ padding: 4px;
690
719
  color: var(--callout-color);
691
- font-weight: 600;
692
720
 
693
721
  .callout-icon {
694
- display: inline-flex;
722
+ display: flex;
695
723
  align-items: center;
696
- margin-right: 0.35em;
724
+ justify-content: center;
725
+ width: 1.2em;
726
+ height: 1.2em;
727
+ padding: 4px;
728
+ line-height: 1.2em;
729
+ text-align: center;
730
+ font-variant-emoji: emoji;
731
+ border-radius: 6px;
732
+
733
+ &:empty {
734
+ display: none;
735
+ }
697
736
  }
698
737
 
699
738
  .callout-title {
739
+ flex: 1;
700
740
  min-width: 1px;
741
+ margin-left: 4px;
742
+ font-size: 114%;
743
+ font-weight: 500;
744
+ opacity: 0.86;
701
745
  }
702
746
 
703
747
  .callout-img,
704
748
  > .callout-img {
705
- width: 1.2em;
706
749
  height: 1.2em;
707
- margin-right: 0.35em;
708
- object-fit: contain;
750
+ width: 100%;
709
751
  }
710
752
  }
711
753
 
712
- > .callout-content > :last-child,
713
- > :last-child {
714
- margin-bottom: 0;
754
+ > p:not(.callout-info),
755
+ > .callout-content > p {
756
+ padding: 4px;
757
+ margin: 2px 0;
758
+ line-height: 1.625;
759
+ border-radius: 6px;
715
760
  }
716
761
  }
717
762
 
763
+ .vditor-wysiwyg blockquote.callout > .callout-info,
764
+ .vditor-ir blockquote.callout > .callout-info {
765
+ font-size: 114%;
766
+ font-weight: 500;
767
+ opacity: 0.86;
768
+ }
769
+
718
770
  .vditor-wysiwyg__callout-marker {
719
771
  display: none;
720
772
  }
@@ -20,13 +20,12 @@
20
20
  word-break: break-word;
21
21
  word-wrap: break-word;
22
22
 
23
- &[contenteditable="false"] {
23
+ &:disabled {
24
24
  opacity: 0.3;
25
25
  cursor: not-allowed;
26
26
  }
27
27
 
28
- &:empty::before {
29
- content: attr(placeholder);
28
+ &::placeholder {
30
29
  color: var(--second-color);
31
30
  }
32
31
 
@@ -34,99 +33,4 @@
34
33
  background-color: var(--textarea-background-color);
35
34
  }
36
35
 
37
- &:after {
38
- content: "";
39
- height: var(--editor-bottom);
40
- display: block;
41
- }
42
-
43
- span[data-type="newline"] + span[data-type="text"]:empty {
44
- display: inherit;
45
- }
46
-
47
- .sup {
48
- vertical-align: super;
49
- font-size: smaller;
50
- }
51
-
52
- .strong {
53
- font-weight: bold;
54
- }
55
-
56
- .em {
57
- font-style: italic;
58
- }
59
-
60
- .s {
61
- text-decoration: line-through;
62
- }
63
-
64
- .mark:not(.vditor-sv__marker) {
65
- background-color: yellow;
66
- color: black;
67
- }
68
-
69
- .h1 {
70
- font-size: 1.75em;
71
- line-height: 44px;
72
- }
73
-
74
- .h2 {
75
- font-size: 1.55em;
76
- line-height: 38px;
77
- }
78
-
79
- .h3 {
80
- font-size: 1.38em;
81
- line-height: 27px;
82
- }
83
-
84
- .h4 {
85
- font-size: 1.25em;
86
- line-height: 25px;
87
- }
88
-
89
- .h5 {
90
- font-size: 1.13em;
91
- }
92
-
93
- .h6 {
94
- font-size: 1em;
95
- }
96
-
97
- &__marker {
98
- color: var(--second-color);
99
-
100
- &--heading {
101
- color: var(--ir-heading-color);
102
- }
103
-
104
- &--bi {
105
- color: var(--ir-bi-color);
106
- }
107
-
108
- &--link {
109
- color: var(--ir-link-color);
110
- }
111
-
112
- &--title {
113
- color: var(--ir-title-color);
114
- }
115
-
116
- &--bracket {
117
- color: var(--ir-bracket-color);
118
- }
119
-
120
- &--paren {
121
- color: var(--ir-paren-color);
122
- }
123
-
124
- &--info {
125
- color: var(--ir-heading-color);
126
- }
127
-
128
- &--strong {
129
- font-weight: bold;
130
- }
131
- }
132
36
  }
@@ -177,8 +177,38 @@
177
177
  }
178
178
  }
179
179
 
180
+ .vditor-wysiwyg__mobile-toolbar {
181
+ display: none;
182
+ }
183
+
180
184
  @media screen and (max-width: @max-width) {
181
185
  .vditor-wysiwyg {
186
+ &__mobile-toolbar {
187
+ display: block;
188
+ float: left;
189
+ height: 21px;
190
+ position: relative;
191
+ width: 23px;
192
+ }
193
+
194
+ &__mobile-actions {
195
+ box-sizing: border-box;
196
+ flex-wrap: wrap;
197
+ left: 0;
198
+ padding: 5px;
199
+ top: 26px;
200
+ white-space: normal;
201
+
202
+ &.vditor-panel--left {
203
+ left: auto;
204
+ right: 0;
205
+ }
206
+
207
+ &--open {
208
+ display: flex;
209
+ }
210
+ }
211
+
182
212
  h1:before,
183
213
  h2:before,
184
214
  h3:before,
@@ -37,16 +37,13 @@
37
37
  --count-background-color: rgba(27, 31, 35, 0.05);
38
38
  --heading-border-color: #eaecef;
39
39
  --blockquote-color: #6a737d;
40
- --callout-note-color: #0969da;
41
- --callout-note-background-color: rgba(9, 105, 218, 0.08);
42
- --callout-tip-color: #1a7f37;
43
- --callout-tip-background-color: rgba(26, 127, 55, 0.08);
44
- --callout-important-color: #8250df;
45
- --callout-important-background-color: rgba(130, 80, 223, 0.08);
46
- --callout-warning-color: #9a6700;
47
- --callout-warning-background-color: rgba(154, 103, 0, 0.08);
48
- --callout-caution-color: #cf222e;
49
- --callout-caution-background-color: rgba(207, 34, 46, 0.08);
40
+ --blockquote-border-color: #e0e0e0;
41
+ --blockquote-text-color: #5f6368;
42
+ --callout-note-color: #3575f0;
43
+ --callout-tip-color: #65b84d;
44
+ --callout-important-color: #8957e5;
45
+ --callout-warning-color: #ff9632;
46
+ --callout-caution-color: #d23f31;
50
47
 
51
48
  --ir-heading-color: #660e7a;
52
49
  --ir-title-color: #808080;
@@ -77,16 +74,13 @@
77
74
  --count-background-color: rgba(@blurColor, 0.36);
78
75
  --heading-border-color: var(--textarea-text-color);
79
76
  --blockquote-color: var(--toolbar-icon-color);
80
- --callout-note-color: #58a6ff;
81
- --callout-note-background-color: rgba(56, 139, 253, 0.15);
82
- --callout-tip-color: #3fb950;
83
- --callout-tip-background-color: rgba(46, 160, 67, 0.15);
84
- --callout-important-color: #a371f7;
85
- --callout-important-background-color: rgba(163, 113, 247, 0.15);
86
- --callout-warning-color: #d29922;
87
- --callout-warning-background-color: rgba(187, 128, 9, 0.15);
88
- --callout-caution-color: #f85149;
89
- --callout-caution-background-color: rgba(248, 81, 73, 0.15);
77
+ --blockquote-border-color: rgba(230, 230, 230, 0.1);
78
+ --blockquote-text-color: #9aa0a6;
79
+ --callout-note-color: #3575f0;
80
+ --callout-tip-color: #65b84d;
81
+ --callout-important-color: #b388ff;
82
+ --callout-warning-color: #ff9632;
83
+ --callout-caution-color: #d23f31;
90
84
 
91
85
  --ir-heading-color: #9876aa;
92
86
  --ir-title-color: #808080;
package/src/index.ts CHANGED
@@ -13,7 +13,6 @@ import {Outline} from "./ts/outline/index";
13
13
  import {Preview} from "./ts/preview/index";
14
14
  import {Resize} from "./ts/resize/index";
15
15
  import {Editor} from "./ts/sv/index";
16
- import {inputEvent} from "./ts/sv/inputEvent";
17
16
  import {processAfterRender as processSVAfterRender, processPaste} from "./ts/sv/process";
18
17
  import {Tip} from "./ts/tip/index";
19
18
  import {Toolbar} from "./ts/toolbar/index";
@@ -167,10 +166,11 @@ class Vditor extends VditorMethod {
167
166
  this.vditor.toolbar.elements,
168
167
  Constants.EDIT_TOOLBARS.concat(["undo", "redo", "fullscreen", "edit-mode"]),
169
168
  );
170
- this.vditor[this.vditor.currentMode].element.setAttribute(
171
- "contenteditable",
172
- "false",
173
- );
169
+ if (this.vditor.currentMode === "sv") {
170
+ this.vditor.sv.element.disabled = true;
171
+ } else {
172
+ this.vditor[this.vditor.currentMode].element.setAttribute("contenteditable", "false");
173
+ }
174
174
  }
175
175
 
176
176
  /** 解除编辑器禁用 */
@@ -180,7 +180,11 @@ class Vditor extends VditorMethod {
180
180
  Constants.EDIT_TOOLBARS.concat(["undo", "redo", "fullscreen", "edit-mode"]),
181
181
  );
182
182
  this.vditor.undo.resetIcon(this.vditor);
183
- this.vditor[this.vditor.currentMode].element.setAttribute("contenteditable", "true");
183
+ if (this.vditor.currentMode === "sv") {
184
+ this.vditor.sv.element.disabled = false;
185
+ } else {
186
+ this.vditor[this.vditor.currentMode].element.setAttribute("contenteditable", "true");
187
+ }
184
188
  }
185
189
 
186
190
  /** 返回选中的字符串 */
@@ -188,7 +192,10 @@ class Vditor extends VditorMethod {
188
192
  if (this.vditor.currentMode === "wysiwyg") {
189
193
  return getSelectText(this.vditor.wysiwyg.element);
190
194
  } else if (this.vditor.currentMode === "sv") {
191
- return getSelectText(this.vditor.sv.element);
195
+ return this.vditor.sv.element.value.substring(
196
+ this.vditor.sv.element.selectionStart,
197
+ this.vditor.sv.element.selectionEnd,
198
+ );
192
199
  } else if (this.vditor.currentMode === "ir") {
193
200
  return getSelectText(this.vditor.ir.element);
194
201
  }
@@ -201,6 +208,15 @@ class Vditor extends VditorMethod {
201
208
 
202
209
  /** 获取焦点位置 */
203
210
  public getCursorPosition() {
211
+ if (this.vditor.currentMode === "sv") {
212
+ const element = this.vditor.sv.element;
213
+ const lineHeight = parseInt(getComputedStyle(element).lineHeight, 10) || 22;
214
+ const line = element.value.substring(0, element.selectionStart).split("\n").length - 1;
215
+ return {
216
+ left: 0,
217
+ top: line * lineHeight - element.scrollTop,
218
+ };
219
+ }
204
220
  return getCursorPosition(this.vditor[this.vditor.currentMode].element);
205
221
  }
206
222
 
@@ -258,6 +274,14 @@ class Vditor extends VditorMethod {
258
274
 
259
275
  /** 删除选中内容 */
260
276
  public deleteValue() {
277
+ if (this.vditor.currentMode === "sv") {
278
+ if (this.vditor.sv.element.selectionStart === this.vditor.sv.element.selectionEnd) {
279
+ return;
280
+ }
281
+ processPaste(this.vditor, "");
282
+ processSVAfterRender(this.vditor);
283
+ return;
284
+ }
261
285
  if (window.getSelection().isCollapsed) {
262
286
  return;
263
287
  }
@@ -266,11 +290,23 @@ class Vditor extends VditorMethod {
266
290
 
267
291
  /** 更新选中内容 */
268
292
  public updateValue(value: string) {
293
+ if (this.vditor.currentMode === "sv") {
294
+ processPaste(this.vditor, value);
295
+ processSVAfterRender(this.vditor);
296
+ return;
297
+ }
269
298
  document.execCommand("insertHTML", false, value);
270
299
  }
271
300
 
272
301
  /** 在焦点处插入内容,并默认进行 Markdown 渲染 */
273
302
  public insertValue(value: string, render = true) {
303
+ if (this.vditor.currentMode === "sv") {
304
+ processPaste(this.vditor, value);
305
+ if (render) {
306
+ processSVAfterRender(this.vditor);
307
+ }
308
+ return;
309
+ }
274
310
  const range = getEditorRange(this.vditor);
275
311
  range.collapse(true);
276
312
  // https://github.com/Vanessa219/vditor/issues/716
@@ -279,12 +315,7 @@ class Vditor extends VditorMethod {
279
315
  tmpElement.innerHTML = value;
280
316
  range.insertNode(tmpElement.content.cloneNode(true));
281
317
  range.collapse(false);
282
- if (this.vditor.currentMode === "sv") {
283
- this.vditor.sv.preventInput = true;
284
- if (render) {
285
- inputEvent(this.vditor);
286
- }
287
- } else if (this.vditor.currentMode === "wysiwyg") {
318
+ if (this.vditor.currentMode === "wysiwyg") {
288
319
  // 由于 https://github.com/Vanessa219/vditor/issues/1566 不能使用 this.vditor.wysiwyg.preventInput = true;
289
320
  if (render) {
290
321
  input(this.vditor, getSelection().getRangeAt(0));
@@ -314,7 +345,7 @@ class Vditor extends VditorMethod {
314
345
  /** 设置编辑器内容 */
315
346
  public setValue(markdown: string, clearStack = false) {
316
347
  if (this.vditor.currentMode === "sv") {
317
- this.vditor.sv.element.innerHTML = `<div data-block='0'>${this.vditor.lute.SpinVditorSVDOM(markdown)}</div>`;
348
+ this.vditor.sv.element.value = markdown;
318
349
  processSVAfterRender(this.vditor, {
319
350
  enableAddUndoStack: true,
320
351
  enableHint: false,
@@ -526,6 +557,7 @@ class Vditor extends VditorMethod {
526
557
  this.vditor.lute = setLute({
527
558
  autoSpace: this.vditor.options.preview.markdown.autoSpace,
528
559
  callout: this.vditor.options.preview.markdown.callout,
560
+ inlineMath: this.vditor.options.preview.markdown.inlineMath,
529
561
  gfmAutoLink: this.vditor.options.preview.markdown.gfmAutoLink,
530
562
  codeBlockPreview: this.vditor.options.preview.markdown
531
563
  .codeBlockPreview,
@@ -52,6 +52,7 @@ export abstract class Constants {
52
52
  public static readonly MARKDOWN_OPTIONS = {
53
53
  autoSpace: false,
54
54
  callout: true,
55
+ inlineMath: true,
55
56
  gfmAutoLink: true,
56
57
  codeBlockPreview: true,
57
58
  fixTermTypo: false,
@@ -37,6 +37,7 @@ window.addEventListener("message", (e) => {
37
37
  cdn: "${vditor.options.cdn}",
38
38
  markdown: {
39
39
  callout: ${JSON.stringify(vditor.options.preview.markdown.callout)},
40
+ inlineMath: ${JSON.stringify(vditor.options.preview.markdown.inlineMath)},
40
41
  theme: ${JSON.stringify(vditor.options.preview.theme)}
41
42
  },
42
43
  hljs: {
@@ -23,6 +23,10 @@ export class Hint {
23
23
  }
24
24
 
25
25
  public render(vditor: IVditor) {
26
+ if (vditor.currentMode === "sv") {
27
+ this.element.style.display = "none";
28
+ return;
29
+ }
26
30
  if (!window.getSelection().focusNode) {
27
31
  return;
28
32
  }
@@ -128,6 +132,9 @@ ${i === 0 ? "class='vditor-hint--current'" : ""}> ${html}</button>`;
128
132
 
129
133
  public fillEmoji = (element: HTMLElement, vditor: IVditor) => {
130
134
  this.element.style.display = "none";
135
+ if (vditor.currentMode === "sv") {
136
+ return;
137
+ }
131
138
 
132
139
  const value = decodeURIComponent(element.getAttribute("data-value"));
133
140
  const range: Range = window.getSelection().getRangeAt(0);
@@ -172,9 +179,7 @@ ${i === 0 ? "class='vditor-hint--current'" : ""}> ${html}</button>`;
172
179
  range.deleteContents();
173
180
 
174
181
  if (vditor.options.hint.parse) {
175
- if (vditor.currentMode === "sv") {
176
- insertHTML(vditor.lute.SpinVditorSVDOM(value), vditor);
177
- } else if (vditor.currentMode === "wysiwyg") {
182
+ if (vditor.currentMode === "wysiwyg") {
178
183
  insertHTML(vditor.lute.SpinVditorDOM(value), vditor);
179
184
  } else {
180
185
  insertHTML(vditor.lute.SpinVditorIRDOM(value), vditor);
@@ -182,7 +187,7 @@ ${i === 0 ? "class='vditor-hint--current'" : ""}> ${html}</button>`;
182
187
  } else {
183
188
  insertHTML(value, vditor);
184
189
  }
185
- if (this.splitChar === ":" && value.indexOf(":") > -1 && vditor.currentMode !== "sv") {
190
+ if (this.splitChar === ":" && value.indexOf(":") > -1) {
186
191
  range.insertNode(document.createTextNode(" "));
187
192
  }
188
193
  range.collapse(false);
@@ -5,12 +5,12 @@ import {hasClosestByHeadings} from "../util/hasClosestByHeadings";
5
5
  import {getEditorRange, selectIsEditor} from "../util/selection";
6
6
 
7
7
  export const highlightToolbarIR = (vditor: IVditor) => {
8
- clearTimeout(vditor[vditor.currentMode].hlToolbarTimeoutId);
9
- vditor[vditor.currentMode].hlToolbarTimeoutId = window.setTimeout(() => {
10
- if (vditor[vditor.currentMode].element.getAttribute("contenteditable") === "false") {
8
+ clearTimeout(vditor.ir.hlToolbarTimeoutId);
9
+ vditor.ir.hlToolbarTimeoutId = window.setTimeout(() => {
10
+ if (vditor.ir.element.getAttribute("contenteditable") === "false") {
11
11
  return;
12
12
  }
13
- if (!selectIsEditor(vditor[vditor.currentMode].element)) {
13
+ if (!selectIsEditor(vditor.ir.element)) {
14
14
  return;
15
15
  }
16
16
 
@@ -2,11 +2,11 @@ import {code160to32} from "../util/code160to32";
2
2
 
3
3
  export const getMarkdown = (vditor: IVditor) => {
4
4
  if (vditor.currentMode === "sv") {
5
- return code160to32(`${vditor.sv.element.textContent}\n`.replace(/\n\n$/, "\n"));
5
+ return code160to32(`${vditor.sv.element.value}\n`.replace(/\n\n$/, "\n"));
6
6
  } else if (vditor.currentMode === "wysiwyg") {
7
- return vditor.lute.VditorDOM2Md(vditor.wysiwyg.element.innerHTML);
7
+ return code160to32(vditor.lute.VditorDOM2Md(vditor.wysiwyg.element.innerHTML));
8
8
  } else if (vditor.currentMode === "ir") {
9
- return vditor.lute.VditorIRDOM2Md(vditor.ir.element.innerHTML);
9
+ return code160to32(vditor.lute.VditorIRDOM2Md(vditor.ir.element.innerHTML));
10
10
  }
11
11
  return "";
12
12
  };