@king-design/vue 3.8.0-beta.0 → 3.8.0-beta.2

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 (54) hide show
  1. package/__tests__/__snapshots__/Vue Next Demos.md +74 -74
  2. package/components/bubble/bubble.d.ts +3 -0
  3. package/components/bubble/bubble.vdt.js +6 -2
  4. package/components/bubble/index.spec.js +231 -5
  5. package/components/bubble/styles.js +1 -1
  6. package/components/bubble/useBubbleDisplay.d.ts +1 -0
  7. package/components/bubble/useBubbleDisplay.js +68 -22
  8. package/components/bubbleList/bubbleList.vdt.js +3 -1
  9. package/components/bubbleList/index.spec.js +378 -237
  10. package/components/bubbleList/styles.js +2 -2
  11. package/components/bubbleList/useBubbleList.js +7 -0
  12. package/components/fileCard/fileCard.vdt.js +4 -4
  13. package/components/fileCard/index.spec.js +179 -107
  14. package/components/fileCard/list.d.ts +2 -1
  15. package/components/fileCard/list.vdt.js +7 -5
  16. package/components/fileCard/styles.js +10 -8
  17. package/components/fileCard/useFileCard.d.ts +1 -1
  18. package/components/fileCard/useFileCard.js +6 -35
  19. package/components/media/index.spec.js +774 -585
  20. package/components/media/media.vdt.js +17 -6
  21. package/components/media/mediaAssets.d.ts +2 -0
  22. package/components/media/mediaAssets.js +4 -0
  23. package/components/media/styles.js +5 -3
  24. package/components/media/useMedia.d.ts +6 -2
  25. package/components/media/useMedia.js +28 -6
  26. package/components/sender/index.spec.js +1146 -476
  27. package/components/sender/sender.d.ts +28 -5
  28. package/components/sender/sender.js +17 -6
  29. package/components/sender/sender.vdt.js +121 -49
  30. package/components/sender/styles.js +18 -9
  31. package/components/sender/useAutoResize.js +7 -6
  32. package/components/sender/useSenderDrag.js +12 -3
  33. package/components/sender/useSenderInput.d.ts +3 -0
  34. package/components/sender/useSenderInput.js +20 -3
  35. package/components/sender/useSenderPaste.js +1 -1
  36. package/components/sender/useSenderUpload.js +38 -29
  37. package/components/xmarkdown/index.spec.js +492 -263
  38. package/components/xmarkdown/markdown/streaming.js +41 -8
  39. package/components/xmarkdown/styles.js +2 -2
  40. package/components/xmarkdown/useXMarkdownDisplay.d.ts +1 -0
  41. package/components/xmarkdown/useXMarkdownDisplay.js +69 -24
  42. package/components/xmarkdown/xmarkdown.d.ts +3 -0
  43. package/components/xmarkdown/xmarkdown.vdt.js +6 -2
  44. package/dist/i18n/en-US.js +1 -0
  45. package/dist/i18n/en-US.js.map +1 -1
  46. package/dist/i18n/en-US.min.js +1 -1
  47. package/dist/index.js +795 -512
  48. package/dist/index.js.map +1 -1
  49. package/dist/index.min.js +2 -2
  50. package/i18n/en-US.d.ts +1 -0
  51. package/i18n/en-US.js +1 -0
  52. package/index.d.ts +2 -2
  53. package/index.js +2 -2
  54. package/package.json +1 -1
@@ -17,10 +17,10 @@ describe('XMarkdown', function () {
17
17
  return _waitFor.apply(this, arguments);
18
18
  }
19
19
  function _waitFor() {
20
- _waitFor = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29(check, retries, interval) {
20
+ _waitFor = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee34(check, retries, interval) {
21
21
  var i;
22
- return _regeneratorRuntime.wrap(function _callee29$(_context60) {
23
- while (1) switch (_context60.prev = _context60.next) {
22
+ return _regeneratorRuntime.wrap(function _callee34$(_context71) {
23
+ while (1) switch (_context71.prev = _context71.next) {
24
24
  case 0:
25
25
  if (retries === void 0) {
26
26
  retries = 30;
@@ -31,28 +31,28 @@ describe('XMarkdown', function () {
31
31
  i = 0;
32
32
  case 3:
33
33
  if (!(i < retries)) {
34
- _context60.next = 11;
34
+ _context71.next = 11;
35
35
  break;
36
36
  }
37
37
  if (!check()) {
38
- _context60.next = 6;
38
+ _context71.next = 6;
39
39
  break;
40
40
  }
41
- return _context60.abrupt("return", true);
41
+ return _context71.abrupt("return", true);
42
42
  case 6:
43
- _context60.next = 8;
43
+ _context71.next = 8;
44
44
  return wait(interval);
45
45
  case 8:
46
46
  i++;
47
- _context60.next = 3;
47
+ _context71.next = 3;
48
48
  break;
49
49
  case 11:
50
- return _context60.abrupt("return", check());
50
+ return _context71.abrupt("return", check());
51
51
  case 12:
52
52
  case "end":
53
- return _context60.stop();
53
+ return _context71.stop();
54
54
  }
55
- }, _callee29);
55
+ }, _callee34);
56
56
  }));
57
57
  return _waitFor.apply(this, arguments);
58
58
  }
@@ -814,11 +814,12 @@ describe('XMarkdown', function () {
814
814
  }
815
815
  }, _callee15);
816
816
  })));
817
- it('should split rendered content into stable and tail containers and reuse stable DOM on streaming updates', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
818
- var Demo, _mount16, instance, element, ready, stableContainer, tailContainer, h1, paragraph, hasTail, sameH1, promoted;
819
- return _regeneratorRuntime.wrap(function _callee16$(_context33) {
820
- while (1) switch (_context33.prev = _context33.next) {
817
+ it('should resume typing from previous rendered markdown after remount', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
818
+ var resumedContent, Demo, _mount16, instance, element, contentElement, initialText, continued;
819
+ return _regeneratorRuntime.wrap(function _callee16$(_context34) {
820
+ while (1) switch (_context34.prev = _context34.next) {
821
821
  case 0:
822
+ resumedContent = '# 标题\n\n一段稳定内容。';
822
823
  Demo = /*#__PURE__*/function (_Component16) {
823
824
  _inheritsLoose(Demo, _Component16);
824
825
  function Demo() {
@@ -831,6 +832,103 @@ describe('XMarkdown', function () {
831
832
  _this16.XMarkdown = XMarkdown;
832
833
  return _this16;
833
834
  }
835
+ Demo.defaults = function defaults() {
836
+ return {
837
+ resumedContent: resumedContent,
838
+ content: resumedContent
839
+ };
840
+ };
841
+ return Demo;
842
+ }(Component);
843
+ Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={this.get('content')}\n streaming={true}\n typing={{interval: 16, step: 2, resumeFrom: this.get('resumedContent')}}\n />\n ";
844
+ _mount16 = mount(Demo), instance = _mount16[0], element = _mount16[1];
845
+ contentElement = element.querySelector('.k-xmarkdown-content');
846
+ initialText = contentElement.textContent || '';
847
+ expect(initialText).to.contain('标题');
848
+ expect(initialText).to.contain('一段稳定内容');
849
+ expect(initialText).not.to.contain('继续生成中');
850
+ instance.set({
851
+ content: resumedContent + "\n\n\u7EE7\u7EED\u751F\u6210\u4E2D"
852
+ });
853
+ _context34.next = 12;
854
+ return waitFor(function () {
855
+ var _context33;
856
+ return _includesInstanceProperty(_context33 = contentElement.textContent).call(_context33, '继续');
857
+ });
858
+ case 12:
859
+ continued = _context34.sent;
860
+ expect(continued).to.be.true;
861
+ expect(contentElement.textContent).to.contain('继续');
862
+ case 15:
863
+ case "end":
864
+ return _context34.stop();
865
+ }
866
+ }, _callee16);
867
+ })));
868
+ it('should support content resume mode before appending new markdown text', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17() {
869
+ var Demo, _mount17, instance, element, ready, text;
870
+ return _regeneratorRuntime.wrap(function _callee17$(_context36) {
871
+ while (1) switch (_context36.prev = _context36.next) {
872
+ case 0:
873
+ Demo = /*#__PURE__*/function (_Component17) {
874
+ _inheritsLoose(Demo, _Component17);
875
+ function Demo() {
876
+ var _context35;
877
+ var _this17;
878
+ for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) {
879
+ args[_key17] = arguments[_key17];
880
+ }
881
+ _this17 = _Component17.call.apply(_Component17, _concatInstanceProperty(_context35 = [this]).call(_context35, args)) || this;
882
+ _this17.XMarkdown = XMarkdown;
883
+ return _this17;
884
+ }
885
+ Demo.defaults = function defaults() {
886
+ return {
887
+ content: '# 标题\n\n已经渲染'
888
+ };
889
+ };
890
+ return Demo;
891
+ }(Component);
892
+ Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={this.get('content')}\n streaming={true}\n typing={{interval: 16, step: 2, resumeFrom: 'content'}}\n />\n ";
893
+ _mount17 = mount(Demo), instance = _mount17[0], element = _mount17[1];
894
+ _context36.next = 5;
895
+ return waitFor(function () {
896
+ return !!element.querySelector('.k-xmarkdown-stable h1');
897
+ });
898
+ case 5:
899
+ ready = _context36.sent;
900
+ expect(ready).to.be.true;
901
+ expect(element.querySelector('.k-xmarkdown-content').textContent).to.contain('已经渲染');
902
+ instance.set('content', '# 标题\n\n已经渲染,继续生成');
903
+ _context36.next = 11;
904
+ return wait(20);
905
+ case 11:
906
+ text = element.querySelector('.k-xmarkdown-content').textContent || '';
907
+ expect(text).to.contain('已经渲染');
908
+ expect(text).not.to.contain('继续生成');
909
+ case 14:
910
+ case "end":
911
+ return _context36.stop();
912
+ }
913
+ }, _callee17);
914
+ })));
915
+ it('should split rendered content into stable and tail containers and reuse stable DOM on streaming updates', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() {
916
+ var Demo, _mount18, instance, element, ready, stableContainer, tailContainer, h1, paragraph, hasTail, sameH1, promoted;
917
+ return _regeneratorRuntime.wrap(function _callee18$(_context38) {
918
+ while (1) switch (_context38.prev = _context38.next) {
919
+ case 0:
920
+ Demo = /*#__PURE__*/function (_Component18) {
921
+ _inheritsLoose(Demo, _Component18);
922
+ function Demo() {
923
+ var _context37;
924
+ var _this18;
925
+ for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) {
926
+ args[_key18] = arguments[_key18];
927
+ }
928
+ _this18 = _Component18.call.apply(_Component18, _concatInstanceProperty(_context37 = [this]).call(_context37, args)) || this;
929
+ _this18.XMarkdown = XMarkdown;
930
+ return _this18;
931
+ }
834
932
  Demo.defaults = function defaults() {
835
933
  return {
836
934
  content: '# 标题\n\n一段稳定的话。\n\n',
@@ -840,13 +938,13 @@ describe('XMarkdown', function () {
840
938
  return Demo;
841
939
  }(Component);
842
940
  Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={this.get('content')}\n streaming={this.get('streaming')}\n />\n ";
843
- _mount16 = mount(Demo), instance = _mount16[0], element = _mount16[1];
844
- _context33.next = 5;
941
+ _mount18 = mount(Demo), instance = _mount18[0], element = _mount18[1];
942
+ _context38.next = 5;
845
943
  return waitFor(function () {
846
944
  return !!element.querySelector('.k-xmarkdown-stable h1');
847
945
  });
848
946
  case 5:
849
- ready = _context33.sent;
947
+ ready = _context38.sent;
850
948
  expect(ready).to.be.true;
851
949
  stableContainer = element.querySelector('.k-xmarkdown-stable');
852
950
  tailContainer = element.querySelector('.k-xmarkdown-tail');
@@ -859,49 +957,141 @@ describe('XMarkdown', function () {
859
957
  h1.__kpcStableProbe = 'kept';
860
958
  paragraph.__kpcStableParagraphProbe = 'kept';
861
959
  instance.set('content', '# 标题\n\n一段稳定的话。\n\n# 新标题');
862
- _context33.next = 20;
960
+ _context38.next = 20;
863
961
  return waitFor(function () {
864
962
  return !!tailContainer.querySelector('[data-kpc-xmarkdown-tail="true"]');
865
963
  }, 30, 20);
866
964
  case 20:
867
- hasTail = _context33.sent;
965
+ hasTail = _context38.sent;
868
966
  expect(hasTail).to.be.true;
869
967
  sameH1 = stableContainer.querySelector('h1');
870
968
  expect(sameH1.__kpcStableProbe).to.eql('kept');
871
969
  expect(tailContainer.querySelector('[data-kpc-xmarkdown-tail="true"]')).not.to.eql(null);
872
970
  expect(stableContainer.querySelector('[data-kpc-xmarkdown-tail="true"]')).to.eql(null);
873
971
  instance.set('content', '# 标题\n\n一段稳定的话。\n\n# 新标题\n\n第二段稳定的话。');
874
- _context33.next = 29;
972
+ _context38.next = 29;
875
973
  return waitFor(function () {
876
974
  return !tailContainer.querySelector('[data-kpc-xmarkdown-tail="true"]') && stableContainer.querySelectorAll('h1').length === 2;
877
975
  }, 30, 20);
878
976
  case 29:
879
- promoted = _context33.sent;
977
+ promoted = _context38.sent;
880
978
  expect(promoted).to.be.true;
881
979
  expect(stableContainer.querySelector('h1').__kpcStableProbe).to.eql('kept');
882
980
  expect(stableContainer.querySelector('p').__kpcStableParagraphProbe).to.eql('kept');
883
981
  case 33:
884
982
  case "end":
885
- return _context33.stop();
983
+ return _context38.stop();
886
984
  }
887
- }, _callee16);
985
+ }, _callee18);
888
986
  })));
889
- it('should keep previous stable DOM across multiple append-only promotions', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17() {
890
- var Demo, _mount17, instance, element, ready, stableContainer, tailContainer, firstHeading, firstParagraph, firstTailReady, firstPromotionReady, secondHeading, secondParagraph, secondTailReady, secondPromotionReady;
891
- return _regeneratorRuntime.wrap(function _callee17$(_context35) {
892
- while (1) switch (_context35.prev = _context35.next) {
987
+ it('should keep spacing before open code block while streaming', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19() {
988
+ var Demo, _mount19, element, ready, codeBlock;
989
+ return _regeneratorRuntime.wrap(function _callee19$(_context40) {
990
+ while (1) switch (_context40.prev = _context40.next) {
893
991
  case 0:
894
- Demo = /*#__PURE__*/function (_Component17) {
895
- _inheritsLoose(Demo, _Component17);
992
+ Demo = /*#__PURE__*/function (_Component19) {
993
+ _inheritsLoose(Demo, _Component19);
896
994
  function Demo() {
897
- var _context34;
898
- var _this17;
899
- for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) {
900
- args[_key17] = arguments[_key17];
995
+ var _context39;
996
+ var _this19;
997
+ for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
998
+ args[_key19] = arguments[_key19];
901
999
  }
902
- _this17 = _Component17.call.apply(_Component17, _concatInstanceProperty(_context34 = [this]).call(_context34, args)) || this;
903
- _this17.XMarkdown = XMarkdown;
904
- return _this17;
1000
+ _this19 = _Component19.call.apply(_Component19, _concatInstanceProperty(_context39 = [this]).call(_context39, args)) || this;
1001
+ _this19.XMarkdown = XMarkdown;
1002
+ return _this19;
1003
+ }
1004
+ Demo.defaults = function defaults() {
1005
+ return {
1006
+ content: '上一段内容。\n\n```ts\nconst a = 1;',
1007
+ streaming: true
1008
+ };
1009
+ };
1010
+ return Demo;
1011
+ }(Component);
1012
+ Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={this.get('content')}\n streaming={this.get('streaming')}\n />\n ";
1013
+ _mount19 = mount(Demo), element = _mount19[1];
1014
+ _context40.next = 5;
1015
+ return waitFor(function () {
1016
+ return !!element.querySelector('.k-xmarkdown-tail > .k-xmarkdown-code-block');
1017
+ });
1018
+ case 5:
1019
+ ready = _context40.sent;
1020
+ expect(ready).to.be.true;
1021
+ codeBlock = element.querySelector('.k-xmarkdown-tail > .k-xmarkdown-code-block');
1022
+ expect(getComputedStyle(codeBlock).marginTop).to.eql('12px');
1023
+ case 9:
1024
+ case "end":
1025
+ return _context40.stop();
1026
+ }
1027
+ }, _callee19);
1028
+ })));
1029
+ it('should progressively fill table cells while streaming a new row', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20() {
1030
+ var Demo, _mount20, instance, element, ready, filled;
1031
+ return _regeneratorRuntime.wrap(function _callee20$(_context42) {
1032
+ while (1) switch (_context42.prev = _context42.next) {
1033
+ case 0:
1034
+ Demo = /*#__PURE__*/function (_Component20) {
1035
+ _inheritsLoose(Demo, _Component20);
1036
+ function Demo() {
1037
+ var _context41;
1038
+ var _this20;
1039
+ for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
1040
+ args[_key20] = arguments[_key20];
1041
+ }
1042
+ _this20 = _Component20.call.apply(_Component20, _concatInstanceProperty(_context41 = [this]).call(_context41, args)) || this;
1043
+ _this20.XMarkdown = XMarkdown;
1044
+ return _this20;
1045
+ }
1046
+ Demo.defaults = function defaults() {
1047
+ return {
1048
+ content: ['| A | B | C |', '| --- | --- | --- |', '| 1 |'].join('\n'),
1049
+ streaming: true
1050
+ };
1051
+ };
1052
+ return Demo;
1053
+ }(Component);
1054
+ Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={this.get('content')}\n streaming={this.get('streaming')}\n />\n ";
1055
+ _mount20 = mount(Demo), instance = _mount20[0], element = _mount20[1];
1056
+ _context42.next = 5;
1057
+ return waitFor(function () {
1058
+ return element.querySelectorAll('.k-xmarkdown-table-wrap td').length === 3;
1059
+ });
1060
+ case 5:
1061
+ ready = _context42.sent;
1062
+ expect(ready).to.be.true;
1063
+ instance.set('content', ['| A | B | C |', '| --- | --- | --- |', '| 1 | 2'].join('\n'));
1064
+ _context42.next = 10;
1065
+ return waitFor(function () {
1066
+ var cells = element.querySelectorAll('.k-xmarkdown-table-wrap td');
1067
+ return cells.length === 3 && cells[1].textContent === '2';
1068
+ });
1069
+ case 10:
1070
+ filled = _context42.sent;
1071
+ expect(filled).to.be.true;
1072
+ expect(element.querySelector('.k-xmarkdown-tail [data-kpc-xmarkdown-tail="true"]')).to.eql(null);
1073
+ case 13:
1074
+ case "end":
1075
+ return _context42.stop();
1076
+ }
1077
+ }, _callee20);
1078
+ })));
1079
+ it('should keep previous stable DOM across multiple append-only promotions', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21() {
1080
+ var Demo, _mount21, instance, element, ready, stableContainer, tailContainer, firstHeading, firstParagraph, firstTailReady, firstPromotionReady, secondHeading, secondParagraph, secondTailReady, secondPromotionReady;
1081
+ return _regeneratorRuntime.wrap(function _callee21$(_context44) {
1082
+ while (1) switch (_context44.prev = _context44.next) {
1083
+ case 0:
1084
+ Demo = /*#__PURE__*/function (_Component21) {
1085
+ _inheritsLoose(Demo, _Component21);
1086
+ function Demo() {
1087
+ var _context43;
1088
+ var _this21;
1089
+ for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
1090
+ args[_key21] = arguments[_key21];
1091
+ }
1092
+ _this21 = _Component21.call.apply(_Component21, _concatInstanceProperty(_context43 = [this]).call(_context43, args)) || this;
1093
+ _this21.XMarkdown = XMarkdown;
1094
+ return _this21;
905
1095
  }
906
1096
  Demo.defaults = function defaults() {
907
1097
  return {
@@ -912,13 +1102,13 @@ describe('XMarkdown', function () {
912
1102
  return Demo;
913
1103
  }(Component);
914
1104
  Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={this.get('content')}\n streaming={this.get('streaming')}\n />\n ";
915
- _mount17 = mount(Demo), instance = _mount17[0], element = _mount17[1];
916
- _context35.next = 5;
1105
+ _mount21 = mount(Demo), instance = _mount21[0], element = _mount21[1];
1106
+ _context44.next = 5;
917
1107
  return waitFor(function () {
918
1108
  return !!element.querySelector('.k-xmarkdown-stable h1');
919
1109
  });
920
1110
  case 5:
921
- ready = _context35.sent;
1111
+ ready = _context44.sent;
922
1112
  expect(ready).to.be.true;
923
1113
  stableContainer = element.querySelector('.k-xmarkdown-stable');
924
1114
  tailContainer = element.querySelector('.k-xmarkdown-tail');
@@ -927,20 +1117,20 @@ describe('XMarkdown', function () {
927
1117
  firstHeading.__kpcFirstStableHeading = 'kept';
928
1118
  firstParagraph.__kpcFirstStableParagraph = 'kept';
929
1119
  instance.set('content', '# 标题\n\n第一段稳定内容。\n\n# 第二个标题');
930
- _context35.next = 16;
1120
+ _context44.next = 16;
931
1121
  return waitFor(function () {
932
1122
  return !!tailContainer.querySelector('[data-kpc-xmarkdown-tail="true"]');
933
1123
  }, 30, 20);
934
1124
  case 16:
935
- firstTailReady = _context35.sent;
1125
+ firstTailReady = _context44.sent;
936
1126
  expect(firstTailReady).to.be.true;
937
1127
  instance.set('content', '# 标题\n\n第一段稳定内容。\n\n# 第二个标题\n\n第二段稳定内容。\n\n');
938
- _context35.next = 21;
1128
+ _context44.next = 21;
939
1129
  return waitFor(function () {
940
1130
  return stableContainer.querySelectorAll('h1').length === 2;
941
1131
  }, 30, 20);
942
1132
  case 21:
943
- firstPromotionReady = _context35.sent;
1133
+ firstPromotionReady = _context44.sent;
944
1134
  expect(firstPromotionReady).to.be.true;
945
1135
  expect(stableContainer.querySelector('h1').__kpcFirstStableHeading).to.eql('kept');
946
1136
  expect(stableContainer.querySelector('p').__kpcFirstStableParagraph).to.eql('kept');
@@ -949,20 +1139,20 @@ describe('XMarkdown', function () {
949
1139
  secondHeading.__kpcSecondStableHeading = 'kept';
950
1140
  secondParagraph.__kpcSecondStableParagraph = 'kept';
951
1141
  instance.set('content', '# 标题\n\n第一段稳定内容。\n\n# 第二个标题\n\n第二段稳定内容。\n\n## 第三个标题');
952
- _context35.next = 32;
1142
+ _context44.next = 32;
953
1143
  return waitFor(function () {
954
1144
  return !!tailContainer.querySelector('[data-kpc-xmarkdown-tail="true"]');
955
1145
  }, 30, 20);
956
1146
  case 32:
957
- secondTailReady = _context35.sent;
1147
+ secondTailReady = _context44.sent;
958
1148
  expect(secondTailReady).to.be.true;
959
1149
  instance.set('content', '# 标题\n\n第一段稳定内容。\n\n# 第二个标题\n\n第二段稳定内容。\n\n## 第三个标题\n\n第三段稳定内容。');
960
- _context35.next = 37;
1150
+ _context44.next = 37;
961
1151
  return waitFor(function () {
962
1152
  return stableContainer.querySelectorAll('h1').length === 2 && stableContainer.querySelectorAll('h2').length === 1;
963
1153
  }, 30, 20);
964
1154
  case 37:
965
- secondPromotionReady = _context35.sent;
1155
+ secondPromotionReady = _context44.sent;
966
1156
  expect(secondPromotionReady).to.be.true;
967
1157
  expect(stableContainer.querySelector('h1').__kpcFirstStableHeading).to.eql('kept');
968
1158
  expect(stableContainer.querySelector('p').__kpcFirstStableParagraph).to.eql('kept');
@@ -970,26 +1160,65 @@ describe('XMarkdown', function () {
970
1160
  expect(stableContainer.querySelectorAll('p')[1].__kpcSecondStableParagraph).to.eql('kept');
971
1161
  case 43:
972
1162
  case "end":
973
- return _context35.stop();
1163
+ return _context44.stop();
974
1164
  }
975
- }, _callee17);
1165
+ }, _callee21);
976
1166
  })));
977
- it('should put unclosed block-level formula into tail container during streaming', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() {
978
- var Demo, _mount18, instance, element, ready, stableContainer, tailContainer, formulaRendered;
979
- return _regeneratorRuntime.wrap(function _callee18$(_context37) {
980
- while (1) switch (_context37.prev = _context37.next) {
1167
+ it('should render typing suffix only when enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22() {
1168
+ var Demo, _mount22, element;
1169
+ return _regeneratorRuntime.wrap(function _callee22$(_context46) {
1170
+ while (1) switch (_context46.prev = _context46.next) {
981
1171
  case 0:
982
- Demo = /*#__PURE__*/function (_Component18) {
983
- _inheritsLoose(Demo, _Component18);
1172
+ Demo = /*#__PURE__*/function (_Component22) {
1173
+ _inheritsLoose(Demo, _Component22);
984
1174
  function Demo() {
985
- var _context36;
986
- var _this18;
987
- for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) {
988
- args[_key18] = arguments[_key18];
1175
+ var _context45;
1176
+ var _this22;
1177
+ for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
1178
+ args[_key22] = arguments[_key22];
989
1179
  }
990
- _this18 = _Component18.call.apply(_Component18, _concatInstanceProperty(_context36 = [this]).call(_context36, args)) || this;
991
- _this18.XMarkdown = XMarkdown;
992
- return _this18;
1180
+ _this22 = _Component22.call.apply(_Component22, _concatInstanceProperty(_context45 = [this]).call(_context45, args)) || this;
1181
+ _this22.XMarkdown = XMarkdown;
1182
+ return _this22;
1183
+ }
1184
+ Demo.defaults = function defaults() {
1185
+ return {
1186
+ content: '# 标题\n\n一段内容'
1187
+ };
1188
+ };
1189
+ return Demo;
1190
+ }(Component);
1191
+ Demo.template = "\n const { XMarkdown } = this;\n <div>\n <XMarkdown\n className=\"suffix-enabled\"\n content={this.get('content')}\n streaming={true}\n typing={{interval: 16, step: 2, suffix: true}}\n />\n <XMarkdown\n className=\"suffix-default\"\n content={this.get('content')}\n streaming={true}\n typing={{interval: 16, step: 2}}\n />\n </div>\n ";
1192
+ _mount22 = mount(Demo), element = _mount22[1];
1193
+ _context46.next = 5;
1194
+ return waitFor(function () {
1195
+ return !!element.querySelector('.suffix-enabled .k-xmarkdown-typing-suffix');
1196
+ });
1197
+ case 5:
1198
+ expect(element.querySelector('.suffix-enabled .k-xmarkdown-typing-suffix').querySelectorAll('span').length).to.eql(3);
1199
+ expect(element.querySelector('.suffix-default .k-xmarkdown-typing-suffix')).to.eql(null);
1200
+ case 7:
1201
+ case "end":
1202
+ return _context46.stop();
1203
+ }
1204
+ }, _callee22);
1205
+ })));
1206
+ it('should put unclosed block-level formula into tail container during streaming', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23() {
1207
+ var Demo, _mount23, instance, element, ready, stableContainer, tailContainer, formulaRendered;
1208
+ return _regeneratorRuntime.wrap(function _callee23$(_context48) {
1209
+ while (1) switch (_context48.prev = _context48.next) {
1210
+ case 0:
1211
+ Demo = /*#__PURE__*/function (_Component23) {
1212
+ _inheritsLoose(Demo, _Component23);
1213
+ function Demo() {
1214
+ var _context47;
1215
+ var _this23;
1216
+ for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
1217
+ args[_key23] = arguments[_key23];
1218
+ }
1219
+ _this23 = _Component23.call.apply(_Component23, _concatInstanceProperty(_context47 = [this]).call(_context47, args)) || this;
1220
+ _this23.XMarkdown = XMarkdown;
1221
+ return _this23;
993
1222
  }
994
1223
  Demo.defaults = function defaults() {
995
1224
  return {
@@ -1001,13 +1230,13 @@ describe('XMarkdown', function () {
1001
1230
  return Demo;
1002
1231
  }(Component);
1003
1232
  Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={this.get('content')}\n streaming={this.get('streaming')}\n />\n ";
1004
- _mount18 = mount(Demo), instance = _mount18[0], element = _mount18[1];
1005
- _context37.next = 5;
1233
+ _mount23 = mount(Demo), instance = _mount23[0], element = _mount23[1];
1234
+ _context48.next = 5;
1006
1235
  return waitFor(function () {
1007
1236
  return !!element.querySelector('.k-xmarkdown-stable h1');
1008
1237
  });
1009
1238
  case 5:
1010
- ready = _context37.sent;
1239
+ ready = _context48.sent;
1011
1240
  expect(ready).to.be.true;
1012
1241
  stableContainer = element.querySelector('.k-xmarkdown-stable');
1013
1242
  tailContainer = element.querySelector('.k-xmarkdown-tail'); // 标题应该在 stable 中
@@ -1017,20 +1246,20 @@ describe('XMarkdown', function () {
1017
1246
  expect(tailContainer.querySelector('[data-kpc-xmarkdown-tail="true"]')).not.to.eql(null);
1018
1247
  // 闭合公式后,整个公式应该渲染在 stable 中
1019
1248
  instance.set('content', '# 标题\n\n$$\n\\operatorname{score}(x)=\\sum_{i=1}^{n}\n$$');
1020
- _context37.next = 15;
1249
+ _context48.next = 15;
1021
1250
  return waitFor(function () {
1022
1251
  var _tailContainer$textCo;
1023
1252
  // 公式闭合后,tail 应该为空或没有 $$
1024
1253
  return tailContainer.innerHTML === '' || !((_tailContainer$textCo = tailContainer.textContent) != null && _includesInstanceProperty(_tailContainer$textCo).call(_tailContainer$textCo, '$$'));
1025
1254
  }, 30, 20);
1026
1255
  case 15:
1027
- formulaRendered = _context37.sent;
1256
+ formulaRendered = _context48.sent;
1028
1257
  expect(formulaRendered).to.be.true;
1029
1258
  case 17:
1030
1259
  case "end":
1031
- return _context37.stop();
1260
+ return _context48.stop();
1032
1261
  }
1033
- }, _callee18);
1262
+ }, _callee23);
1034
1263
  })));
1035
1264
  it('should keep incomplete inline tokens in tail cache during streaming', function () {
1036
1265
  var cache = createStreamingTailCache();
@@ -1044,22 +1273,22 @@ describe('XMarkdown', function () {
1044
1273
  expect(result.stableSource).to.eql('请看[文档](https://example.com)\n');
1045
1274
  expect(result.tailText).to.eql('<notice-card tit');
1046
1275
  });
1047
- it('should render raw html when allowHtml and sanitizeOptions are enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19() {
1048
- var Demo, _mount19, element, ready;
1049
- return _regeneratorRuntime.wrap(function _callee19$(_context39) {
1050
- while (1) switch (_context39.prev = _context39.next) {
1276
+ it('should render raw html when allowHtml and sanitizeOptions are enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24() {
1277
+ var Demo, _mount24, element, ready;
1278
+ return _regeneratorRuntime.wrap(function _callee24$(_context50) {
1279
+ while (1) switch (_context50.prev = _context50.next) {
1051
1280
  case 0:
1052
- Demo = /*#__PURE__*/function (_Component19) {
1053
- _inheritsLoose(Demo, _Component19);
1281
+ Demo = /*#__PURE__*/function (_Component24) {
1282
+ _inheritsLoose(Demo, _Component24);
1054
1283
  function Demo() {
1055
- var _context38;
1056
- var _this19;
1057
- for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
1058
- args[_key19] = arguments[_key19];
1284
+ var _context49;
1285
+ var _this24;
1286
+ for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
1287
+ args[_key24] = arguments[_key24];
1059
1288
  }
1060
- _this19 = _Component19.call.apply(_Component19, _concatInstanceProperty(_context38 = [this]).call(_context38, args)) || this;
1061
- _this19.XMarkdown = XMarkdown;
1062
- return _this19;
1289
+ _this24 = _Component24.call.apply(_Component24, _concatInstanceProperty(_context49 = [this]).call(_context49, args)) || this;
1290
+ _this24.XMarkdown = XMarkdown;
1291
+ return _this24;
1063
1292
  }
1064
1293
  Demo.defaults = function defaults() {
1065
1294
  return {
@@ -1073,71 +1302,71 @@ describe('XMarkdown', function () {
1073
1302
  return Demo;
1074
1303
  }(Component);
1075
1304
  Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n allowHtml\n content={this.get('content')}\n sanitizeOptions={this.get('sanitizeOptions')}\n />\n ";
1076
- _mount19 = mount(Demo), element = _mount19[1];
1077
- _context39.next = 5;
1305
+ _mount24 = mount(Demo), element = _mount24[1];
1306
+ _context50.next = 5;
1078
1307
  return waitFor(function () {
1079
1308
  return !!element.querySelector('notice-card');
1080
1309
  });
1081
1310
  case 5:
1082
- ready = _context39.sent;
1311
+ ready = _context50.sent;
1083
1312
  expect(ready).to.be.true;
1084
1313
  expect(element.querySelector('mark').getAttribute('data-track')).to.eql('demo-mark');
1085
1314
  expect(element.querySelector('notice-card').getAttribute('title')).to.eql('发布建议');
1086
1315
  expect(element.querySelector('notice-card').textContent).to.contain('先补文档,再补单测。');
1087
1316
  case 10:
1088
1317
  case "end":
1089
- return _context39.stop();
1318
+ return _context50.stop();
1090
1319
  }
1091
- }, _callee19);
1320
+ }, _callee24);
1092
1321
  })));
1093
- it('should keep formula text when enableFormula is false', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20() {
1094
- var Demo, _mount20, element;
1095
- return _regeneratorRuntime.wrap(function _callee20$(_context41) {
1096
- while (1) switch (_context41.prev = _context41.next) {
1322
+ it('should keep formula text when enableFormula is false', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25() {
1323
+ var Demo, _mount25, element;
1324
+ return _regeneratorRuntime.wrap(function _callee25$(_context52) {
1325
+ while (1) switch (_context52.prev = _context52.next) {
1097
1326
  case 0:
1098
- Demo = /*#__PURE__*/function (_Component20) {
1099
- _inheritsLoose(Demo, _Component20);
1327
+ Demo = /*#__PURE__*/function (_Component25) {
1328
+ _inheritsLoose(Demo, _Component25);
1100
1329
  function Demo() {
1101
- var _context40;
1102
- var _this20;
1103
- for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
1104
- args[_key20] = arguments[_key20];
1330
+ var _context51;
1331
+ var _this25;
1332
+ for (var _len25 = arguments.length, args = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) {
1333
+ args[_key25] = arguments[_key25];
1105
1334
  }
1106
- _this20 = _Component20.call.apply(_Component20, _concatInstanceProperty(_context40 = [this]).call(_context40, args)) || this;
1107
- _this20.XMarkdown = XMarkdown;
1108
- return _this20;
1335
+ _this25 = _Component25.call.apply(_Component25, _concatInstanceProperty(_context51 = [this]).call(_context51, args)) || this;
1336
+ _this25.XMarkdown = XMarkdown;
1337
+ return _this25;
1109
1338
  }
1110
1339
  return Demo;
1111
1340
  }(Component);
1112
1341
  Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n enableFormula={false}\n content={'$E = mc^2$'}\n />\n ";
1113
- _mount20 = mount(Demo), element = _mount20[1];
1114
- _context41.next = 5;
1342
+ _mount25 = mount(Demo), element = _mount25[1];
1343
+ _context52.next = 5;
1115
1344
  return wait(60);
1116
1345
  case 5:
1117
1346
  expect(element.querySelector('.katex')).to.eql(null);
1118
1347
  expect(element.querySelector('.k-xmarkdown-content').textContent).to.contain('$E = mc^2$');
1119
1348
  case 7:
1120
1349
  case "end":
1121
- return _context41.stop();
1350
+ return _context52.stop();
1122
1351
  }
1123
- }, _callee20);
1352
+ }, _callee25);
1124
1353
  })));
1125
- it('should support custom formulaDelimiters and formulaMacros', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21() {
1126
- var Demo, _mount21, element, ready;
1127
- return _regeneratorRuntime.wrap(function _callee21$(_context43) {
1128
- while (1) switch (_context43.prev = _context43.next) {
1354
+ it('should support custom formulaDelimiters and formulaMacros', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26() {
1355
+ var Demo, _mount26, element, ready;
1356
+ return _regeneratorRuntime.wrap(function _callee26$(_context54) {
1357
+ while (1) switch (_context54.prev = _context54.next) {
1129
1358
  case 0:
1130
- Demo = /*#__PURE__*/function (_Component21) {
1131
- _inheritsLoose(Demo, _Component21);
1359
+ Demo = /*#__PURE__*/function (_Component26) {
1360
+ _inheritsLoose(Demo, _Component26);
1132
1361
  function Demo() {
1133
- var _context42;
1134
- var _this21;
1135
- for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
1136
- args[_key21] = arguments[_key21];
1362
+ var _context53;
1363
+ var _this26;
1364
+ for (var _len26 = arguments.length, args = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) {
1365
+ args[_key26] = arguments[_key26];
1137
1366
  }
1138
- _this21 = _Component21.call.apply(_Component21, _concatInstanceProperty(_context42 = [this]).call(_context42, args)) || this;
1139
- _this21.XMarkdown = XMarkdown;
1140
- return _this21;
1367
+ _this26 = _Component26.call.apply(_Component26, _concatInstanceProperty(_context53 = [this]).call(_context53, args)) || this;
1368
+ _this26.XMarkdown = XMarkdown;
1369
+ return _this26;
1141
1370
  }
1142
1371
  Demo.defaults = function defaults() {
1143
1372
  return {
@@ -1149,38 +1378,38 @@ describe('XMarkdown', function () {
1149
1378
  return Demo;
1150
1379
  }(Component);
1151
1380
  Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={'\\\\[f: \\\\RR \\\\to \\\\RR\\\\]'}\n formulaDelimiters={'brackets'}\n formulaMacros={this.get('formulaMacros')}\n />\n ";
1152
- _mount21 = mount(Demo), element = _mount21[1];
1153
- _context43.next = 5;
1381
+ _mount26 = mount(Demo), element = _mount26[1];
1382
+ _context54.next = 5;
1154
1383
  return waitFor(function () {
1155
1384
  return !!element.querySelector('.katex');
1156
1385
  }, 60, 20);
1157
1386
  case 5:
1158
- ready = _context43.sent;
1387
+ ready = _context54.sent;
1159
1388
  expect(ready).to.be.true;
1160
1389
  expect(element.querySelector('.k-xmarkdown-content').textContent).not.to.contain('\\[');
1161
1390
  case 8:
1162
1391
  case "end":
1163
- return _context43.stop();
1392
+ return _context54.stop();
1164
1393
  }
1165
- }, _callee21);
1394
+ }, _callee26);
1166
1395
  })));
1167
- it('should support tagAttrs and tagRenderers for custom tags', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22() {
1168
- var _context45;
1169
- var Demo, _mount22, element, ready, link;
1170
- return _regeneratorRuntime.wrap(function _callee22$(_context46) {
1171
- while (1) switch (_context46.prev = _context46.next) {
1396
+ it('should support tagAttrs and tagRenderers for custom tags', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27() {
1397
+ var _context56;
1398
+ var Demo, _mount27, element, ready, link;
1399
+ return _regeneratorRuntime.wrap(function _callee27$(_context57) {
1400
+ while (1) switch (_context57.prev = _context57.next) {
1172
1401
  case 0:
1173
- Demo = /*#__PURE__*/function (_Component22) {
1174
- _inheritsLoose(Demo, _Component22);
1402
+ Demo = /*#__PURE__*/function (_Component27) {
1403
+ _inheritsLoose(Demo, _Component27);
1175
1404
  function Demo() {
1176
- var _context44;
1177
- var _this22;
1178
- for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
1179
- args[_key22] = arguments[_key22];
1405
+ var _context55;
1406
+ var _this27;
1407
+ for (var _len27 = arguments.length, args = new Array(_len27), _key27 = 0; _key27 < _len27; _key27++) {
1408
+ args[_key27] = arguments[_key27];
1180
1409
  }
1181
- _this22 = _Component22.call.apply(_Component22, _concatInstanceProperty(_context44 = [this]).call(_context44, args)) || this;
1182
- _this22.XMarkdown = XMarkdown;
1183
- _this22.tagAttrs = {
1410
+ _this27 = _Component27.call.apply(_Component27, _concatInstanceProperty(_context55 = [this]).call(_context55, args)) || this;
1411
+ _this27.XMarkdown = XMarkdown;
1412
+ _this27.tagAttrs = {
1184
1413
  a: function a() {
1185
1414
  return {
1186
1415
  className: 'xmarkdown-enhanced-link',
@@ -1188,7 +1417,7 @@ describe('XMarkdown', function () {
1188
1417
  };
1189
1418
  }
1190
1419
  };
1191
- _this22.tagRenderers = {
1420
+ _this27.tagRenderers = {
1192
1421
  'notice-card': function noticeCard(context) {
1193
1422
  return createVNode('section', {
1194
1423
  className: 'xmarkdown-custom-card'
@@ -1204,7 +1433,7 @@ describe('XMarkdown', function () {
1204
1433
  }, 'custom table');
1205
1434
  }
1206
1435
  };
1207
- return _this22;
1436
+ return _this27;
1208
1437
  }
1209
1438
  Demo.defaults = function defaults() {
1210
1439
  return {
@@ -1218,20 +1447,20 @@ describe('XMarkdown', function () {
1218
1447
  return Demo;
1219
1448
  }(Component);
1220
1449
  Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n allowHtml\n content={this.get('content')}\n sanitizeOptions={this.get('sanitizeOptions')}\n tagAttrs={this.tagAttrs}\n tagRenderers={this.tagRenderers}\n />\n ";
1221
- _mount22 = mount(Demo), element = _mount22[1];
1222
- _context46.next = 5;
1450
+ _mount27 = mount(Demo), element = _mount27[1];
1451
+ _context57.next = 5;
1223
1452
  return waitFor(function () {
1224
1453
  return !!element.querySelector('.xmarkdown-custom-card');
1225
1454
  });
1226
1455
  case 5:
1227
- ready = _context46.sent;
1456
+ ready = _context57.sent;
1228
1457
  expect(ready).to.be.true;
1229
1458
  expect(element.querySelector('notice-card')).to.eql(null);
1230
1459
  expect(element.querySelector('table')).to.eql(null);
1231
1460
  expect(element.querySelector('.xmarkdown-custom-card-title').textContent).to.eql('发布建议');
1232
1461
  expect(element.querySelector('.xmarkdown-custom-card-body').textContent).to.contain('先补 Demo,再补单测。');
1233
1462
  expect(element.querySelector('.xmarkdown-custom-table').textContent).to.contain('custom table');
1234
- expect(_mapInstanceProperty(_context45 = _Array$from(element.querySelector('.k-xmarkdown-stable').children)).call(_context45, function (item) {
1463
+ expect(_mapInstanceProperty(_context56 = _Array$from(element.querySelector('.k-xmarkdown-stable').children)).call(_context56, function (item) {
1235
1464
  return item.tagName.toLowerCase();
1236
1465
  })).to.eql(['h1', 'section', 'div', 'p']);
1237
1466
  expect(element.querySelector('.k-xmarkdown-stable p:empty')).to.eql(null);
@@ -1241,30 +1470,30 @@ describe('XMarkdown', function () {
1241
1470
  expect(link.getAttribute('rel')).to.eql('noopener noreferrer');
1242
1471
  case 18:
1243
1472
  case "end":
1244
- return _context46.stop();
1473
+ return _context57.stop();
1245
1474
  }
1246
- }, _callee22);
1475
+ }, _callee27);
1247
1476
  })));
1248
- it('should support codeBlockRenderers for code blocks and mermaid blocks', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23() {
1249
- var initialize, renderAsync, codeContexts, mermaidContexts, Demo, _mount23, element, ready;
1250
- return _regeneratorRuntime.wrap(function _callee23$(_context48) {
1251
- while (1) switch (_context48.prev = _context48.next) {
1477
+ it('should support codeBlockRenderers for code blocks and mermaid blocks', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28() {
1478
+ var initialize, renderAsync, codeContexts, mermaidContexts, Demo, _mount28, element, ready;
1479
+ return _regeneratorRuntime.wrap(function _callee28$(_context59) {
1480
+ while (1) switch (_context59.prev = _context59.next) {
1252
1481
  case 0:
1253
1482
  initialize = sinon.stub(mermaid, 'initialize');
1254
1483
  renderAsync = sinon.stub(mermaid, 'renderAsync');
1255
1484
  codeContexts = [];
1256
1485
  mermaidContexts = [];
1257
- Demo = /*#__PURE__*/function (_Component23) {
1258
- _inheritsLoose(Demo, _Component23);
1486
+ Demo = /*#__PURE__*/function (_Component28) {
1487
+ _inheritsLoose(Demo, _Component28);
1259
1488
  function Demo() {
1260
- var _context47;
1261
- var _this23;
1262
- for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
1263
- args[_key23] = arguments[_key23];
1489
+ var _context58;
1490
+ var _this28;
1491
+ for (var _len28 = arguments.length, args = new Array(_len28), _key28 = 0; _key28 < _len28; _key28++) {
1492
+ args[_key28] = arguments[_key28];
1264
1493
  }
1265
- _this23 = _Component23.call.apply(_Component23, _concatInstanceProperty(_context47 = [this]).call(_context47, args)) || this;
1266
- _this23.XMarkdown = XMarkdown;
1267
- _this23.codeBlockRenderers = {
1494
+ _this28 = _Component28.call.apply(_Component28, _concatInstanceProperty(_context58 = [this]).call(_context58, args)) || this;
1495
+ _this28.XMarkdown = XMarkdown;
1496
+ _this28.codeBlockRenderers = {
1268
1497
  ts: function ts(context) {
1269
1498
  codeContexts.push(context);
1270
1499
  return createVNode('section', {
@@ -1286,7 +1515,7 @@ describe('XMarkdown', function () {
1286
1515
  }, context.source)]);
1287
1516
  }
1288
1517
  };
1289
- return _this23;
1518
+ return _this28;
1290
1519
  }
1291
1520
  Demo.defaults = function defaults() {
1292
1521
  return {
@@ -1296,13 +1525,13 @@ describe('XMarkdown', function () {
1296
1525
  return Demo;
1297
1526
  }(Component);
1298
1527
  Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={this.get('content')}\n codeBlockRenderers={this.codeBlockRenderers}\n />\n ";
1299
- _mount23 = mount(Demo), element = _mount23[1];
1300
- _context48.next = 9;
1528
+ _mount28 = mount(Demo), element = _mount28[1];
1529
+ _context59.next = 9;
1301
1530
  return waitFor(function () {
1302
1531
  return !!element.querySelector('.xmarkdown-custom-code-block') && !!element.querySelector('.xmarkdown-custom-mermaid-block');
1303
1532
  });
1304
1533
  case 9:
1305
- ready = _context48.sent;
1534
+ ready = _context59.sent;
1306
1535
  expect(ready).to.be.true;
1307
1536
  expect(initialize.called).to.be.false;
1308
1537
  expect(renderAsync.called).to.be.false;
@@ -1315,26 +1544,26 @@ describe('XMarkdown', function () {
1315
1544
  expect(element.querySelector('.k-xmarkdown-code-toolbar')).to.eql(null);
1316
1545
  case 20:
1317
1546
  case "end":
1318
- return _context48.stop();
1547
+ return _context59.stop();
1319
1548
  }
1320
- }, _callee23);
1549
+ }, _callee28);
1321
1550
  })));
1322
- it('should refresh renderer when codeBlockRenderers change', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24() {
1323
- var Demo, _mount24, instance, element, initialReady, refreshed;
1324
- return _regeneratorRuntime.wrap(function _callee24$(_context50) {
1325
- while (1) switch (_context50.prev = _context50.next) {
1551
+ it('should refresh renderer when codeBlockRenderers change', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29() {
1552
+ var Demo, _mount29, instance, element, initialReady, refreshed;
1553
+ return _regeneratorRuntime.wrap(function _callee29$(_context61) {
1554
+ while (1) switch (_context61.prev = _context61.next) {
1326
1555
  case 0:
1327
- Demo = /*#__PURE__*/function (_Component24) {
1328
- _inheritsLoose(Demo, _Component24);
1556
+ Demo = /*#__PURE__*/function (_Component29) {
1557
+ _inheritsLoose(Demo, _Component29);
1329
1558
  function Demo() {
1330
- var _context49;
1331
- var _this24;
1332
- for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
1333
- args[_key24] = arguments[_key24];
1559
+ var _context60;
1560
+ var _this29;
1561
+ for (var _len29 = arguments.length, args = new Array(_len29), _key29 = 0; _key29 < _len29; _key29++) {
1562
+ args[_key29] = arguments[_key29];
1334
1563
  }
1335
- _this24 = _Component24.call.apply(_Component24, _concatInstanceProperty(_context49 = [this]).call(_context49, args)) || this;
1336
- _this24.XMarkdown = XMarkdown;
1337
- return _this24;
1564
+ _this29 = _Component29.call.apply(_Component29, _concatInstanceProperty(_context60 = [this]).call(_context60, args)) || this;
1565
+ _this29.XMarkdown = XMarkdown;
1566
+ return _this29;
1338
1567
  }
1339
1568
  Demo.defaults = function defaults() {
1340
1569
  return {
@@ -1345,13 +1574,13 @@ describe('XMarkdown', function () {
1345
1574
  return Demo;
1346
1575
  }(Component);
1347
1576
  Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={this.get('content')}\n codeBlockRenderers={this.get('codeBlockRenderers')}\n />\n ";
1348
- _mount24 = mount(Demo), instance = _mount24[0], element = _mount24[1];
1349
- _context50.next = 5;
1577
+ _mount29 = mount(Demo), instance = _mount29[0], element = _mount29[1];
1578
+ _context61.next = 5;
1350
1579
  return waitFor(function () {
1351
1580
  return !!element.querySelector('.k-xmarkdown-code-toolbar');
1352
1581
  });
1353
1582
  case 5:
1354
- initialReady = _context50.sent;
1583
+ initialReady = _context61.sent;
1355
1584
  expect(initialReady).to.be.true;
1356
1585
  expect(element.querySelector('.xmarkdown-refresh-code-block')).to.eql(null);
1357
1586
  instance.set('codeBlockRenderers', {
@@ -1361,36 +1590,36 @@ describe('XMarkdown', function () {
1361
1590
  }, context.source);
1362
1591
  }
1363
1592
  });
1364
- _context50.next = 11;
1593
+ _context61.next = 11;
1365
1594
  return waitFor(function () {
1366
1595
  return !!element.querySelector('.xmarkdown-refresh-code-block');
1367
1596
  });
1368
1597
  case 11:
1369
- refreshed = _context50.sent;
1598
+ refreshed = _context61.sent;
1370
1599
  expect(refreshed).to.be.true;
1371
1600
  expect(element.querySelector('.k-xmarkdown-code-toolbar')).to.eql(null);
1372
1601
  case 14:
1373
1602
  case "end":
1374
- return _context50.stop();
1603
+ return _context61.stop();
1375
1604
  }
1376
- }, _callee24);
1605
+ }, _callee29);
1377
1606
  })));
1378
- it('should support plugins for markdown extension and render tree transform', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25() {
1379
- var Demo, _mount25, element, ready;
1380
- return _regeneratorRuntime.wrap(function _callee25$(_context52) {
1381
- while (1) switch (_context52.prev = _context52.next) {
1607
+ it('should support plugins for markdown extension and render tree transform', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30() {
1608
+ var Demo, _mount30, element, ready;
1609
+ return _regeneratorRuntime.wrap(function _callee30$(_context63) {
1610
+ while (1) switch (_context63.prev = _context63.next) {
1382
1611
  case 0:
1383
- Demo = /*#__PURE__*/function (_Component25) {
1384
- _inheritsLoose(Demo, _Component25);
1612
+ Demo = /*#__PURE__*/function (_Component30) {
1613
+ _inheritsLoose(Demo, _Component30);
1385
1614
  function Demo() {
1386
- var _context51;
1387
- var _this25;
1388
- for (var _len25 = arguments.length, args = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) {
1389
- args[_key25] = arguments[_key25];
1615
+ var _context62;
1616
+ var _this30;
1617
+ for (var _len30 = arguments.length, args = new Array(_len30), _key30 = 0; _key30 < _len30; _key30++) {
1618
+ args[_key30] = arguments[_key30];
1390
1619
  }
1391
- _this25 = _Component25.call.apply(_Component25, _concatInstanceProperty(_context51 = [this]).call(_context51, args)) || this;
1392
- _this25.XMarkdown = XMarkdown;
1393
- _this25.plugins = [{
1620
+ _this30 = _Component30.call.apply(_Component30, _concatInstanceProperty(_context62 = [this]).call(_context62, args)) || this;
1621
+ _this30.XMarkdown = XMarkdown;
1622
+ _this30.plugins = [{
1394
1623
  extendMarkdown: function extendMarkdown(markdown) {
1395
1624
  markdown.core.ruler.push('xmarkdown-heading-plugin', function (state) {
1396
1625
  state.tokens.forEach(function (token) {
@@ -1414,7 +1643,7 @@ describe('XMarkdown', function () {
1414
1643
  });
1415
1644
  }
1416
1645
  }];
1417
- return _this25;
1646
+ return _this30;
1418
1647
  }
1419
1648
  Demo.defaults = function defaults() {
1420
1649
  return {
@@ -1424,38 +1653,38 @@ describe('XMarkdown', function () {
1424
1653
  return Demo;
1425
1654
  }(Component);
1426
1655
  Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={this.get('content')}\n plugins={this.plugins}\n />\n ";
1427
- _mount25 = mount(Demo), element = _mount25[1];
1428
- _context52.next = 5;
1656
+ _mount30 = mount(Demo), element = _mount30[1];
1657
+ _context63.next = 5;
1429
1658
  return waitFor(function () {
1430
1659
  return !!element.querySelector('.k-xmarkdown-content blockquote');
1431
1660
  });
1432
1661
  case 5:
1433
- ready = _context52.sent;
1662
+ ready = _context63.sent;
1434
1663
  expect(ready).to.be.true;
1435
1664
  expect(element.querySelector('h1').getAttribute('data-plugin-source')).to.eql('markdown-it');
1436
1665
  expect(element.querySelector('blockquote').getAttribute('data-plugin-transform')).to.eql('render-tree');
1437
1666
  case 9:
1438
1667
  case "end":
1439
- return _context52.stop();
1668
+ return _context63.stop();
1440
1669
  }
1441
- }, _callee25);
1670
+ }, _callee30);
1442
1671
  })));
1443
- it('should refresh renderer when plugins change', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26() {
1444
- var Demo, _mount26, instance, element, initialReady, refreshed;
1445
- return _regeneratorRuntime.wrap(function _callee26$(_context54) {
1446
- while (1) switch (_context54.prev = _context54.next) {
1672
+ it('should refresh renderer when plugins change', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31() {
1673
+ var Demo, _mount31, instance, element, initialReady, refreshed;
1674
+ return _regeneratorRuntime.wrap(function _callee31$(_context65) {
1675
+ while (1) switch (_context65.prev = _context65.next) {
1447
1676
  case 0:
1448
- Demo = /*#__PURE__*/function (_Component26) {
1449
- _inheritsLoose(Demo, _Component26);
1677
+ Demo = /*#__PURE__*/function (_Component31) {
1678
+ _inheritsLoose(Demo, _Component31);
1450
1679
  function Demo() {
1451
- var _context53;
1452
- var _this26;
1453
- for (var _len26 = arguments.length, args = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) {
1454
- args[_key26] = arguments[_key26];
1680
+ var _context64;
1681
+ var _this31;
1682
+ for (var _len31 = arguments.length, args = new Array(_len31), _key31 = 0; _key31 < _len31; _key31++) {
1683
+ args[_key31] = arguments[_key31];
1455
1684
  }
1456
- _this26 = _Component26.call.apply(_Component26, _concatInstanceProperty(_context53 = [this]).call(_context53, args)) || this;
1457
- _this26.XMarkdown = XMarkdown;
1458
- return _this26;
1685
+ _this31 = _Component31.call.apply(_Component31, _concatInstanceProperty(_context64 = [this]).call(_context64, args)) || this;
1686
+ _this31.XMarkdown = XMarkdown;
1687
+ return _this31;
1459
1688
  }
1460
1689
  Demo.defaults = function defaults() {
1461
1690
  return {
@@ -1465,13 +1694,13 @@ describe('XMarkdown', function () {
1465
1694
  return Demo;
1466
1695
  }(Component);
1467
1696
  Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={'# \u63D2\u4EF6\u5237\u65B0'}\n plugins={this.get('plugins')}\n />\n ";
1468
- _mount26 = mount(Demo), instance = _mount26[0], element = _mount26[1];
1469
- _context54.next = 5;
1697
+ _mount31 = mount(Demo), instance = _mount31[0], element = _mount31[1];
1698
+ _context65.next = 5;
1470
1699
  return waitFor(function () {
1471
1700
  return !!element.querySelector('h1');
1472
1701
  });
1473
1702
  case 5:
1474
- initialReady = _context54.sent;
1703
+ initialReady = _context65.sent;
1475
1704
  expect(initialReady).to.be.true;
1476
1705
  expect(element.querySelector('h1').getAttribute('data-refresh-plugin')).to.eql(null);
1477
1706
  instance.set('plugins', [{
@@ -1485,23 +1714,23 @@ describe('XMarkdown', function () {
1485
1714
  });
1486
1715
  }
1487
1716
  }]);
1488
- _context54.next = 11;
1717
+ _context65.next = 11;
1489
1718
  return waitFor(function () {
1490
1719
  return element.querySelector('h1').getAttribute('data-refresh-plugin') === 'updated';
1491
1720
  });
1492
1721
  case 11:
1493
- refreshed = _context54.sent;
1722
+ refreshed = _context65.sent;
1494
1723
  expect(refreshed).to.be.true;
1495
1724
  case 13:
1496
1725
  case "end":
1497
- return _context54.stop();
1726
+ return _context65.stop();
1498
1727
  }
1499
- }, _callee26);
1728
+ }, _callee31);
1500
1729
  })));
1501
- it('should support plugins transforming citation markers from business data', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27() {
1502
- var citations, Demo, transformCitationNodes, splitCitationText, _mount27, element, ready;
1503
- return _regeneratorRuntime.wrap(function _callee27$(_context57) {
1504
- while (1) switch (_context57.prev = _context57.next) {
1730
+ it('should support plugins transforming citation markers from business data', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32() {
1731
+ var citations, Demo, transformCitationNodes, splitCitationText, _mount32, element, ready;
1732
+ return _regeneratorRuntime.wrap(function _callee32$(_context68) {
1733
+ while (1) switch (_context68.prev = _context68.next) {
1505
1734
  case 0:
1506
1735
  splitCitationText = function _splitCitationText(text) {
1507
1736
  var nextNodes = [];
@@ -1549,7 +1778,7 @@ describe('XMarkdown', function () {
1549
1778
  return nextNodes;
1550
1779
  };
1551
1780
  transformCitationNodes = function _transformCitationNod(nodes, appendSection) {
1552
- var _context56;
1781
+ var _context67;
1553
1782
  if (appendSection === void 0) {
1554
1783
  appendSection = false;
1555
1784
  }
@@ -1568,7 +1797,7 @@ describe('XMarkdown', function () {
1568
1797
  }));
1569
1798
  });
1570
1799
  if (!appendSection || !citations.length) return nextNodes;
1571
- return _concatInstanceProperty(_context56 = []).call(_context56, nextNodes, [{
1800
+ return _concatInstanceProperty(_context67 = []).call(_context67, nextNodes, [{
1572
1801
  type: 'element',
1573
1802
  tag: 'section',
1574
1803
  attrs: {
@@ -1584,33 +1813,33 @@ describe('XMarkdown', function () {
1584
1813
  title: '引用来源一',
1585
1814
  link: 'https://example.com/source-1'
1586
1815
  }];
1587
- Demo = /*#__PURE__*/function (_Component27) {
1588
- _inheritsLoose(Demo, _Component27);
1816
+ Demo = /*#__PURE__*/function (_Component32) {
1817
+ _inheritsLoose(Demo, _Component32);
1589
1818
  function Demo() {
1590
- var _context55;
1591
- var _this27;
1592
- for (var _len27 = arguments.length, args = new Array(_len27), _key27 = 0; _key27 < _len27; _key27++) {
1593
- args[_key27] = arguments[_key27];
1819
+ var _context66;
1820
+ var _this32;
1821
+ for (var _len32 = arguments.length, args = new Array(_len32), _key32 = 0; _key32 < _len32; _key32++) {
1822
+ args[_key32] = arguments[_key32];
1594
1823
  }
1595
- _this27 = _Component27.call.apply(_Component27, _concatInstanceProperty(_context55 = [this]).call(_context55, args)) || this;
1596
- _this27.XMarkdown = XMarkdown;
1597
- _this27.plugins = [{
1824
+ _this32 = _Component32.call.apply(_Component32, _concatInstanceProperty(_context66 = [this]).call(_context66, args)) || this;
1825
+ _this32.XMarkdown = XMarkdown;
1826
+ _this32.plugins = [{
1598
1827
  transformRenderTree: function transformRenderTree(nodes) {
1599
1828
  return transformCitationNodes(nodes, true);
1600
1829
  }
1601
1830
  }];
1602
- return _this27;
1831
+ return _this32;
1603
1832
  }
1604
1833
  return Demo;
1605
1834
  }(Component);
1606
1835
  Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={'\u6B63\u6587\u5F15\u7528[1][2]'}\n plugins={this.plugins}\n />\n ";
1607
- _mount27 = mount(Demo), element = _mount27[1];
1608
- _context57.next = 8;
1836
+ _mount32 = mount(Demo), element = _mount32[1];
1837
+ _context68.next = 8;
1609
1838
  return waitFor(function () {
1610
1839
  return !!element.querySelector('[data-citation-index="1"]');
1611
1840
  });
1612
1841
  case 8:
1613
- ready = _context57.sent;
1842
+ ready = _context68.sent;
1614
1843
  expect(ready).to.be.true;
1615
1844
  expect(element.querySelectorAll('[data-citation-index]').length).to.eql(1);
1616
1845
  expect(element.querySelector('[data-citation-index="1"]').getAttribute('href')).to.eql('https://example.com/source-1');
@@ -1618,49 +1847,49 @@ describe('XMarkdown', function () {
1618
1847
  expect(element.querySelector('[data-citation-section="true"]').textContent).to.contain('Sources: 1');
1619
1848
  case 14:
1620
1849
  case "end":
1621
- return _context57.stop();
1850
+ return _context68.stop();
1622
1851
  }
1623
- }, _callee27);
1852
+ }, _callee32);
1624
1853
  })));
1625
- it('should avoid duplicate markdown rendering during initial mount', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28() {
1626
- var transformRenderTree, Demo, _mount28, element, ready;
1627
- return _regeneratorRuntime.wrap(function _callee28$(_context59) {
1628
- while (1) switch (_context59.prev = _context59.next) {
1854
+ it('should avoid duplicate markdown rendering during initial mount', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee33() {
1855
+ var transformRenderTree, Demo, _mount33, element, ready;
1856
+ return _regeneratorRuntime.wrap(function _callee33$(_context70) {
1857
+ while (1) switch (_context70.prev = _context70.next) {
1629
1858
  case 0:
1630
1859
  transformRenderTree = sinon.spy(function (nodes) {
1631
1860
  return nodes;
1632
1861
  });
1633
- Demo = /*#__PURE__*/function (_Component28) {
1634
- _inheritsLoose(Demo, _Component28);
1862
+ Demo = /*#__PURE__*/function (_Component33) {
1863
+ _inheritsLoose(Demo, _Component33);
1635
1864
  function Demo() {
1636
- var _context58;
1637
- var _this28;
1638
- for (var _len28 = arguments.length, args = new Array(_len28), _key28 = 0; _key28 < _len28; _key28++) {
1639
- args[_key28] = arguments[_key28];
1865
+ var _context69;
1866
+ var _this33;
1867
+ for (var _len33 = arguments.length, args = new Array(_len33), _key33 = 0; _key33 < _len33; _key33++) {
1868
+ args[_key33] = arguments[_key33];
1640
1869
  }
1641
- _this28 = _Component28.call.apply(_Component28, _concatInstanceProperty(_context58 = [this]).call(_context58, args)) || this;
1642
- _this28.XMarkdown = XMarkdown;
1643
- _this28.plugins = [{
1870
+ _this33 = _Component33.call.apply(_Component33, _concatInstanceProperty(_context69 = [this]).call(_context69, args)) || this;
1871
+ _this33.XMarkdown = XMarkdown;
1872
+ _this33.plugins = [{
1644
1873
  transformRenderTree: transformRenderTree
1645
1874
  }];
1646
- return _this28;
1875
+ return _this33;
1647
1876
  }
1648
1877
  return Demo;
1649
1878
  }(Component);
1650
1879
  Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={'# \u521D\u59CB\u5316\u6E32\u67D3'}\n plugins={this.plugins}\n />\n ";
1651
- _mount28 = mount(Demo), element = _mount28[1];
1652
- _context59.next = 6;
1880
+ _mount33 = mount(Demo), element = _mount33[1];
1881
+ _context70.next = 6;
1653
1882
  return waitFor(function () {
1654
1883
  return !!element.querySelector('h1');
1655
1884
  });
1656
1885
  case 6:
1657
- ready = _context59.sent;
1886
+ ready = _context70.sent;
1658
1887
  expect(ready).to.be.true;
1659
1888
  expect(transformRenderTree.callCount).to.eql(1);
1660
1889
  case 9:
1661
1890
  case "end":
1662
- return _context59.stop();
1891
+ return _context70.stop();
1663
1892
  }
1664
- }, _callee28);
1893
+ }, _callee33);
1665
1894
  })));
1666
1895
  });