@king-design/vue 3.8.0-beta.1 → 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.
- package/components/bubble/bubble.d.ts +2 -0
- package/components/bubble/index.spec.js +183 -10
- package/components/bubble/useBubbleDisplay.js +60 -22
- package/components/bubbleList/index.spec.js +77 -0
- package/components/sender/index.spec.js +345 -279
- package/components/sender/sender.d.ts +1 -1
- package/components/sender/sender.js +1 -1
- package/components/sender/useAutoResize.js +7 -6
- package/components/xmarkdown/index.spec.js +416 -318
- package/components/xmarkdown/useXMarkdownDisplay.js +60 -23
- package/components/xmarkdown/xmarkdown.d.ts +2 -0
- package/dist/index.js +419 -343
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/index.d.ts +2 -2
- package/index.js +2 -2
- 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
|
|
20
|
+
_waitFor = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee34(check, retries, interval) {
|
|
21
21
|
var i;
|
|
22
|
-
return _regeneratorRuntime.wrap(function
|
|
23
|
-
while (1) switch (
|
|
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
|
-
|
|
34
|
+
_context71.next = 11;
|
|
35
35
|
break;
|
|
36
36
|
}
|
|
37
37
|
if (!check()) {
|
|
38
|
-
|
|
38
|
+
_context71.next = 6;
|
|
39
39
|
break;
|
|
40
40
|
}
|
|
41
|
-
return
|
|
41
|
+
return _context71.abrupt("return", true);
|
|
42
42
|
case 6:
|
|
43
|
-
|
|
43
|
+
_context71.next = 8;
|
|
44
44
|
return wait(interval);
|
|
45
45
|
case 8:
|
|
46
46
|
i++;
|
|
47
|
-
|
|
47
|
+
_context71.next = 3;
|
|
48
48
|
break;
|
|
49
49
|
case 11:
|
|
50
|
-
return
|
|
50
|
+
return _context71.abrupt("return", check());
|
|
51
51
|
case 12:
|
|
52
52
|
case "end":
|
|
53
|
-
return
|
|
53
|
+
return _context71.stop();
|
|
54
54
|
}
|
|
55
|
-
},
|
|
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
|
|
818
|
-
var Demo, _mount16, instance, element,
|
|
819
|
-
return _regeneratorRuntime.wrap(function _callee16$(
|
|
820
|
-
while (1) switch (
|
|
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
|
-
|
|
844
|
-
|
|
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 =
|
|
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,49 @@ describe('XMarkdown', function () {
|
|
|
859
957
|
h1.__kpcStableProbe = 'kept';
|
|
860
958
|
paragraph.__kpcStableParagraphProbe = 'kept';
|
|
861
959
|
instance.set('content', '# 标题\n\n一段稳定的话。\n\n# 新标题');
|
|
862
|
-
|
|
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 =
|
|
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
|
-
|
|
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 =
|
|
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
|
|
983
|
+
return _context38.stop();
|
|
886
984
|
}
|
|
887
|
-
},
|
|
985
|
+
}, _callee18);
|
|
888
986
|
})));
|
|
889
|
-
it('should keep spacing before open code block while streaming', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
890
|
-
var Demo,
|
|
891
|
-
return _regeneratorRuntime.wrap(function
|
|
892
|
-
while (1) switch (
|
|
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 (
|
|
895
|
-
_inheritsLoose(Demo,
|
|
992
|
+
Demo = /*#__PURE__*/function (_Component19) {
|
|
993
|
+
_inheritsLoose(Demo, _Component19);
|
|
896
994
|
function Demo() {
|
|
897
|
-
var
|
|
898
|
-
var
|
|
899
|
-
for (var
|
|
900
|
-
args[
|
|
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
|
-
|
|
903
|
-
|
|
904
|
-
return
|
|
1000
|
+
_this19 = _Component19.call.apply(_Component19, _concatInstanceProperty(_context39 = [this]).call(_context39, args)) || this;
|
|
1001
|
+
_this19.XMarkdown = XMarkdown;
|
|
1002
|
+
return _this19;
|
|
905
1003
|
}
|
|
906
1004
|
Demo.defaults = function defaults() {
|
|
907
1005
|
return {
|
|
@@ -912,38 +1010,38 @@ describe('XMarkdown', function () {
|
|
|
912
1010
|
return Demo;
|
|
913
1011
|
}(Component);
|
|
914
1012
|
Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={this.get('content')}\n streaming={this.get('streaming')}\n />\n ";
|
|
915
|
-
|
|
916
|
-
|
|
1013
|
+
_mount19 = mount(Demo), element = _mount19[1];
|
|
1014
|
+
_context40.next = 5;
|
|
917
1015
|
return waitFor(function () {
|
|
918
1016
|
return !!element.querySelector('.k-xmarkdown-tail > .k-xmarkdown-code-block');
|
|
919
1017
|
});
|
|
920
1018
|
case 5:
|
|
921
|
-
ready =
|
|
1019
|
+
ready = _context40.sent;
|
|
922
1020
|
expect(ready).to.be.true;
|
|
923
1021
|
codeBlock = element.querySelector('.k-xmarkdown-tail > .k-xmarkdown-code-block');
|
|
924
1022
|
expect(getComputedStyle(codeBlock).marginTop).to.eql('12px');
|
|
925
1023
|
case 9:
|
|
926
1024
|
case "end":
|
|
927
|
-
return
|
|
1025
|
+
return _context40.stop();
|
|
928
1026
|
}
|
|
929
|
-
},
|
|
1027
|
+
}, _callee19);
|
|
930
1028
|
})));
|
|
931
|
-
it('should progressively fill table cells while streaming a new row', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
932
|
-
var Demo,
|
|
933
|
-
return _regeneratorRuntime.wrap(function
|
|
934
|
-
while (1) switch (
|
|
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) {
|
|
935
1033
|
case 0:
|
|
936
|
-
Demo = /*#__PURE__*/function (
|
|
937
|
-
_inheritsLoose(Demo,
|
|
1034
|
+
Demo = /*#__PURE__*/function (_Component20) {
|
|
1035
|
+
_inheritsLoose(Demo, _Component20);
|
|
938
1036
|
function Demo() {
|
|
939
|
-
var
|
|
940
|
-
var
|
|
941
|
-
for (var
|
|
942
|
-
args[
|
|
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];
|
|
943
1041
|
}
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
return
|
|
1042
|
+
_this20 = _Component20.call.apply(_Component20, _concatInstanceProperty(_context41 = [this]).call(_context41, args)) || this;
|
|
1043
|
+
_this20.XMarkdown = XMarkdown;
|
|
1044
|
+
return _this20;
|
|
947
1045
|
}
|
|
948
1046
|
Demo.defaults = function defaults() {
|
|
949
1047
|
return {
|
|
@@ -954,46 +1052,46 @@ describe('XMarkdown', function () {
|
|
|
954
1052
|
return Demo;
|
|
955
1053
|
}(Component);
|
|
956
1054
|
Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={this.get('content')}\n streaming={this.get('streaming')}\n />\n ";
|
|
957
|
-
|
|
958
|
-
|
|
1055
|
+
_mount20 = mount(Demo), instance = _mount20[0], element = _mount20[1];
|
|
1056
|
+
_context42.next = 5;
|
|
959
1057
|
return waitFor(function () {
|
|
960
1058
|
return element.querySelectorAll('.k-xmarkdown-table-wrap td').length === 3;
|
|
961
1059
|
});
|
|
962
1060
|
case 5:
|
|
963
|
-
ready =
|
|
1061
|
+
ready = _context42.sent;
|
|
964
1062
|
expect(ready).to.be.true;
|
|
965
1063
|
instance.set('content', ['| A | B | C |', '| --- | --- | --- |', '| 1 | 2'].join('\n'));
|
|
966
|
-
|
|
1064
|
+
_context42.next = 10;
|
|
967
1065
|
return waitFor(function () {
|
|
968
1066
|
var cells = element.querySelectorAll('.k-xmarkdown-table-wrap td');
|
|
969
1067
|
return cells.length === 3 && cells[1].textContent === '2';
|
|
970
1068
|
});
|
|
971
1069
|
case 10:
|
|
972
|
-
filled =
|
|
1070
|
+
filled = _context42.sent;
|
|
973
1071
|
expect(filled).to.be.true;
|
|
974
1072
|
expect(element.querySelector('.k-xmarkdown-tail [data-kpc-xmarkdown-tail="true"]')).to.eql(null);
|
|
975
1073
|
case 13:
|
|
976
1074
|
case "end":
|
|
977
|
-
return
|
|
1075
|
+
return _context42.stop();
|
|
978
1076
|
}
|
|
979
|
-
},
|
|
1077
|
+
}, _callee20);
|
|
980
1078
|
})));
|
|
981
|
-
it('should keep previous stable DOM across multiple append-only promotions', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
982
|
-
var Demo,
|
|
983
|
-
return _regeneratorRuntime.wrap(function
|
|
984
|
-
while (1) switch (
|
|
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) {
|
|
985
1083
|
case 0:
|
|
986
|
-
Demo = /*#__PURE__*/function (
|
|
987
|
-
_inheritsLoose(Demo,
|
|
1084
|
+
Demo = /*#__PURE__*/function (_Component21) {
|
|
1085
|
+
_inheritsLoose(Demo, _Component21);
|
|
988
1086
|
function Demo() {
|
|
989
|
-
var
|
|
990
|
-
var
|
|
991
|
-
for (var
|
|
992
|
-
args[
|
|
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];
|
|
993
1091
|
}
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
return
|
|
1092
|
+
_this21 = _Component21.call.apply(_Component21, _concatInstanceProperty(_context43 = [this]).call(_context43, args)) || this;
|
|
1093
|
+
_this21.XMarkdown = XMarkdown;
|
|
1094
|
+
return _this21;
|
|
997
1095
|
}
|
|
998
1096
|
Demo.defaults = function defaults() {
|
|
999
1097
|
return {
|
|
@@ -1004,13 +1102,13 @@ describe('XMarkdown', function () {
|
|
|
1004
1102
|
return Demo;
|
|
1005
1103
|
}(Component);
|
|
1006
1104
|
Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={this.get('content')}\n streaming={this.get('streaming')}\n />\n ";
|
|
1007
|
-
|
|
1008
|
-
|
|
1105
|
+
_mount21 = mount(Demo), instance = _mount21[0], element = _mount21[1];
|
|
1106
|
+
_context44.next = 5;
|
|
1009
1107
|
return waitFor(function () {
|
|
1010
1108
|
return !!element.querySelector('.k-xmarkdown-stable h1');
|
|
1011
1109
|
});
|
|
1012
1110
|
case 5:
|
|
1013
|
-
ready =
|
|
1111
|
+
ready = _context44.sent;
|
|
1014
1112
|
expect(ready).to.be.true;
|
|
1015
1113
|
stableContainer = element.querySelector('.k-xmarkdown-stable');
|
|
1016
1114
|
tailContainer = element.querySelector('.k-xmarkdown-tail');
|
|
@@ -1019,20 +1117,20 @@ describe('XMarkdown', function () {
|
|
|
1019
1117
|
firstHeading.__kpcFirstStableHeading = 'kept';
|
|
1020
1118
|
firstParagraph.__kpcFirstStableParagraph = 'kept';
|
|
1021
1119
|
instance.set('content', '# 标题\n\n第一段稳定内容。\n\n# 第二个标题');
|
|
1022
|
-
|
|
1120
|
+
_context44.next = 16;
|
|
1023
1121
|
return waitFor(function () {
|
|
1024
1122
|
return !!tailContainer.querySelector('[data-kpc-xmarkdown-tail="true"]');
|
|
1025
1123
|
}, 30, 20);
|
|
1026
1124
|
case 16:
|
|
1027
|
-
firstTailReady =
|
|
1125
|
+
firstTailReady = _context44.sent;
|
|
1028
1126
|
expect(firstTailReady).to.be.true;
|
|
1029
1127
|
instance.set('content', '# 标题\n\n第一段稳定内容。\n\n# 第二个标题\n\n第二段稳定内容。\n\n');
|
|
1030
|
-
|
|
1128
|
+
_context44.next = 21;
|
|
1031
1129
|
return waitFor(function () {
|
|
1032
1130
|
return stableContainer.querySelectorAll('h1').length === 2;
|
|
1033
1131
|
}, 30, 20);
|
|
1034
1132
|
case 21:
|
|
1035
|
-
firstPromotionReady =
|
|
1133
|
+
firstPromotionReady = _context44.sent;
|
|
1036
1134
|
expect(firstPromotionReady).to.be.true;
|
|
1037
1135
|
expect(stableContainer.querySelector('h1').__kpcFirstStableHeading).to.eql('kept');
|
|
1038
1136
|
expect(stableContainer.querySelector('p').__kpcFirstStableParagraph).to.eql('kept');
|
|
@@ -1041,20 +1139,20 @@ describe('XMarkdown', function () {
|
|
|
1041
1139
|
secondHeading.__kpcSecondStableHeading = 'kept';
|
|
1042
1140
|
secondParagraph.__kpcSecondStableParagraph = 'kept';
|
|
1043
1141
|
instance.set('content', '# 标题\n\n第一段稳定内容。\n\n# 第二个标题\n\n第二段稳定内容。\n\n## 第三个标题');
|
|
1044
|
-
|
|
1142
|
+
_context44.next = 32;
|
|
1045
1143
|
return waitFor(function () {
|
|
1046
1144
|
return !!tailContainer.querySelector('[data-kpc-xmarkdown-tail="true"]');
|
|
1047
1145
|
}, 30, 20);
|
|
1048
1146
|
case 32:
|
|
1049
|
-
secondTailReady =
|
|
1147
|
+
secondTailReady = _context44.sent;
|
|
1050
1148
|
expect(secondTailReady).to.be.true;
|
|
1051
1149
|
instance.set('content', '# 标题\n\n第一段稳定内容。\n\n# 第二个标题\n\n第二段稳定内容。\n\n## 第三个标题\n\n第三段稳定内容。');
|
|
1052
|
-
|
|
1150
|
+
_context44.next = 37;
|
|
1053
1151
|
return waitFor(function () {
|
|
1054
1152
|
return stableContainer.querySelectorAll('h1').length === 2 && stableContainer.querySelectorAll('h2').length === 1;
|
|
1055
1153
|
}, 30, 20);
|
|
1056
1154
|
case 37:
|
|
1057
|
-
secondPromotionReady =
|
|
1155
|
+
secondPromotionReady = _context44.sent;
|
|
1058
1156
|
expect(secondPromotionReady).to.be.true;
|
|
1059
1157
|
expect(stableContainer.querySelector('h1').__kpcFirstStableHeading).to.eql('kept');
|
|
1060
1158
|
expect(stableContainer.querySelector('p').__kpcFirstStableParagraph).to.eql('kept');
|
|
@@ -1062,26 +1160,26 @@ describe('XMarkdown', function () {
|
|
|
1062
1160
|
expect(stableContainer.querySelectorAll('p')[1].__kpcSecondStableParagraph).to.eql('kept');
|
|
1063
1161
|
case 43:
|
|
1064
1162
|
case "end":
|
|
1065
|
-
return
|
|
1163
|
+
return _context44.stop();
|
|
1066
1164
|
}
|
|
1067
|
-
},
|
|
1165
|
+
}, _callee21);
|
|
1068
1166
|
})));
|
|
1069
|
-
it('should render typing suffix only when enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1070
|
-
var Demo,
|
|
1071
|
-
return _regeneratorRuntime.wrap(function
|
|
1072
|
-
while (1) switch (
|
|
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) {
|
|
1073
1171
|
case 0:
|
|
1074
|
-
Demo = /*#__PURE__*/function (
|
|
1075
|
-
_inheritsLoose(Demo,
|
|
1172
|
+
Demo = /*#__PURE__*/function (_Component22) {
|
|
1173
|
+
_inheritsLoose(Demo, _Component22);
|
|
1076
1174
|
function Demo() {
|
|
1077
|
-
var
|
|
1078
|
-
var
|
|
1079
|
-
for (var
|
|
1080
|
-
args[
|
|
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];
|
|
1081
1179
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
return
|
|
1180
|
+
_this22 = _Component22.call.apply(_Component22, _concatInstanceProperty(_context45 = [this]).call(_context45, args)) || this;
|
|
1181
|
+
_this22.XMarkdown = XMarkdown;
|
|
1182
|
+
return _this22;
|
|
1085
1183
|
}
|
|
1086
1184
|
Demo.defaults = function defaults() {
|
|
1087
1185
|
return {
|
|
@@ -1091,8 +1189,8 @@ describe('XMarkdown', function () {
|
|
|
1091
1189
|
return Demo;
|
|
1092
1190
|
}(Component);
|
|
1093
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 ";
|
|
1094
|
-
|
|
1095
|
-
|
|
1192
|
+
_mount22 = mount(Demo), element = _mount22[1];
|
|
1193
|
+
_context46.next = 5;
|
|
1096
1194
|
return waitFor(function () {
|
|
1097
1195
|
return !!element.querySelector('.suffix-enabled .k-xmarkdown-typing-suffix');
|
|
1098
1196
|
});
|
|
@@ -1101,26 +1199,26 @@ describe('XMarkdown', function () {
|
|
|
1101
1199
|
expect(element.querySelector('.suffix-default .k-xmarkdown-typing-suffix')).to.eql(null);
|
|
1102
1200
|
case 7:
|
|
1103
1201
|
case "end":
|
|
1104
|
-
return
|
|
1202
|
+
return _context46.stop();
|
|
1105
1203
|
}
|
|
1106
|
-
},
|
|
1204
|
+
}, _callee22);
|
|
1107
1205
|
})));
|
|
1108
|
-
it('should put unclosed block-level formula into tail container during streaming', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1109
|
-
var Demo,
|
|
1110
|
-
return _regeneratorRuntime.wrap(function
|
|
1111
|
-
while (1) switch (
|
|
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) {
|
|
1112
1210
|
case 0:
|
|
1113
|
-
Demo = /*#__PURE__*/function (
|
|
1114
|
-
_inheritsLoose(Demo,
|
|
1211
|
+
Demo = /*#__PURE__*/function (_Component23) {
|
|
1212
|
+
_inheritsLoose(Demo, _Component23);
|
|
1115
1213
|
function Demo() {
|
|
1116
|
-
var
|
|
1117
|
-
var
|
|
1118
|
-
for (var
|
|
1119
|
-
args[
|
|
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];
|
|
1120
1218
|
}
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
return
|
|
1219
|
+
_this23 = _Component23.call.apply(_Component23, _concatInstanceProperty(_context47 = [this]).call(_context47, args)) || this;
|
|
1220
|
+
_this23.XMarkdown = XMarkdown;
|
|
1221
|
+
return _this23;
|
|
1124
1222
|
}
|
|
1125
1223
|
Demo.defaults = function defaults() {
|
|
1126
1224
|
return {
|
|
@@ -1132,13 +1230,13 @@ describe('XMarkdown', function () {
|
|
|
1132
1230
|
return Demo;
|
|
1133
1231
|
}(Component);
|
|
1134
1232
|
Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={this.get('content')}\n streaming={this.get('streaming')}\n />\n ";
|
|
1135
|
-
|
|
1136
|
-
|
|
1233
|
+
_mount23 = mount(Demo), instance = _mount23[0], element = _mount23[1];
|
|
1234
|
+
_context48.next = 5;
|
|
1137
1235
|
return waitFor(function () {
|
|
1138
1236
|
return !!element.querySelector('.k-xmarkdown-stable h1');
|
|
1139
1237
|
});
|
|
1140
1238
|
case 5:
|
|
1141
|
-
ready =
|
|
1239
|
+
ready = _context48.sent;
|
|
1142
1240
|
expect(ready).to.be.true;
|
|
1143
1241
|
stableContainer = element.querySelector('.k-xmarkdown-stable');
|
|
1144
1242
|
tailContainer = element.querySelector('.k-xmarkdown-tail'); // 标题应该在 stable 中
|
|
@@ -1148,20 +1246,20 @@ describe('XMarkdown', function () {
|
|
|
1148
1246
|
expect(tailContainer.querySelector('[data-kpc-xmarkdown-tail="true"]')).not.to.eql(null);
|
|
1149
1247
|
// 闭合公式后,整个公式应该渲染在 stable 中
|
|
1150
1248
|
instance.set('content', '# 标题\n\n$$\n\\operatorname{score}(x)=\\sum_{i=1}^{n}\n$$');
|
|
1151
|
-
|
|
1249
|
+
_context48.next = 15;
|
|
1152
1250
|
return waitFor(function () {
|
|
1153
1251
|
var _tailContainer$textCo;
|
|
1154
1252
|
// 公式闭合后,tail 应该为空或没有 $$
|
|
1155
1253
|
return tailContainer.innerHTML === '' || !((_tailContainer$textCo = tailContainer.textContent) != null && _includesInstanceProperty(_tailContainer$textCo).call(_tailContainer$textCo, '$$'));
|
|
1156
1254
|
}, 30, 20);
|
|
1157
1255
|
case 15:
|
|
1158
|
-
formulaRendered =
|
|
1256
|
+
formulaRendered = _context48.sent;
|
|
1159
1257
|
expect(formulaRendered).to.be.true;
|
|
1160
1258
|
case 17:
|
|
1161
1259
|
case "end":
|
|
1162
|
-
return
|
|
1260
|
+
return _context48.stop();
|
|
1163
1261
|
}
|
|
1164
|
-
},
|
|
1262
|
+
}, _callee23);
|
|
1165
1263
|
})));
|
|
1166
1264
|
it('should keep incomplete inline tokens in tail cache during streaming', function () {
|
|
1167
1265
|
var cache = createStreamingTailCache();
|
|
@@ -1175,22 +1273,22 @@ describe('XMarkdown', function () {
|
|
|
1175
1273
|
expect(result.stableSource).to.eql('请看[文档](https://example.com)\n');
|
|
1176
1274
|
expect(result.tailText).to.eql('<notice-card tit');
|
|
1177
1275
|
});
|
|
1178
|
-
it('should render raw html when allowHtml and sanitizeOptions are enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1179
|
-
var Demo,
|
|
1180
|
-
return _regeneratorRuntime.wrap(function
|
|
1181
|
-
while (1) switch (
|
|
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) {
|
|
1182
1280
|
case 0:
|
|
1183
|
-
Demo = /*#__PURE__*/function (
|
|
1184
|
-
_inheritsLoose(Demo,
|
|
1281
|
+
Demo = /*#__PURE__*/function (_Component24) {
|
|
1282
|
+
_inheritsLoose(Demo, _Component24);
|
|
1185
1283
|
function Demo() {
|
|
1186
|
-
var
|
|
1187
|
-
var
|
|
1188
|
-
for (var
|
|
1189
|
-
args[
|
|
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];
|
|
1190
1288
|
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
return
|
|
1289
|
+
_this24 = _Component24.call.apply(_Component24, _concatInstanceProperty(_context49 = [this]).call(_context49, args)) || this;
|
|
1290
|
+
_this24.XMarkdown = XMarkdown;
|
|
1291
|
+
return _this24;
|
|
1194
1292
|
}
|
|
1195
1293
|
Demo.defaults = function defaults() {
|
|
1196
1294
|
return {
|
|
@@ -1204,71 +1302,71 @@ describe('XMarkdown', function () {
|
|
|
1204
1302
|
return Demo;
|
|
1205
1303
|
}(Component);
|
|
1206
1304
|
Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n allowHtml\n content={this.get('content')}\n sanitizeOptions={this.get('sanitizeOptions')}\n />\n ";
|
|
1207
|
-
|
|
1208
|
-
|
|
1305
|
+
_mount24 = mount(Demo), element = _mount24[1];
|
|
1306
|
+
_context50.next = 5;
|
|
1209
1307
|
return waitFor(function () {
|
|
1210
1308
|
return !!element.querySelector('notice-card');
|
|
1211
1309
|
});
|
|
1212
1310
|
case 5:
|
|
1213
|
-
ready =
|
|
1311
|
+
ready = _context50.sent;
|
|
1214
1312
|
expect(ready).to.be.true;
|
|
1215
1313
|
expect(element.querySelector('mark').getAttribute('data-track')).to.eql('demo-mark');
|
|
1216
1314
|
expect(element.querySelector('notice-card').getAttribute('title')).to.eql('发布建议');
|
|
1217
1315
|
expect(element.querySelector('notice-card').textContent).to.contain('先补文档,再补单测。');
|
|
1218
1316
|
case 10:
|
|
1219
1317
|
case "end":
|
|
1220
|
-
return
|
|
1318
|
+
return _context50.stop();
|
|
1221
1319
|
}
|
|
1222
|
-
},
|
|
1320
|
+
}, _callee24);
|
|
1223
1321
|
})));
|
|
1224
|
-
it('should keep formula text when enableFormula is false', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1225
|
-
var Demo,
|
|
1226
|
-
return _regeneratorRuntime.wrap(function
|
|
1227
|
-
while (1) switch (
|
|
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) {
|
|
1228
1326
|
case 0:
|
|
1229
|
-
Demo = /*#__PURE__*/function (
|
|
1230
|
-
_inheritsLoose(Demo,
|
|
1327
|
+
Demo = /*#__PURE__*/function (_Component25) {
|
|
1328
|
+
_inheritsLoose(Demo, _Component25);
|
|
1231
1329
|
function Demo() {
|
|
1232
|
-
var
|
|
1233
|
-
var
|
|
1234
|
-
for (var
|
|
1235
|
-
args[
|
|
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];
|
|
1236
1334
|
}
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
return
|
|
1335
|
+
_this25 = _Component25.call.apply(_Component25, _concatInstanceProperty(_context51 = [this]).call(_context51, args)) || this;
|
|
1336
|
+
_this25.XMarkdown = XMarkdown;
|
|
1337
|
+
return _this25;
|
|
1240
1338
|
}
|
|
1241
1339
|
return Demo;
|
|
1242
1340
|
}(Component);
|
|
1243
1341
|
Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n enableFormula={false}\n content={'$E = mc^2$'}\n />\n ";
|
|
1244
|
-
|
|
1245
|
-
|
|
1342
|
+
_mount25 = mount(Demo), element = _mount25[1];
|
|
1343
|
+
_context52.next = 5;
|
|
1246
1344
|
return wait(60);
|
|
1247
1345
|
case 5:
|
|
1248
1346
|
expect(element.querySelector('.katex')).to.eql(null);
|
|
1249
1347
|
expect(element.querySelector('.k-xmarkdown-content').textContent).to.contain('$E = mc^2$');
|
|
1250
1348
|
case 7:
|
|
1251
1349
|
case "end":
|
|
1252
|
-
return
|
|
1350
|
+
return _context52.stop();
|
|
1253
1351
|
}
|
|
1254
|
-
},
|
|
1352
|
+
}, _callee25);
|
|
1255
1353
|
})));
|
|
1256
|
-
it('should support custom formulaDelimiters and formulaMacros', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1257
|
-
var Demo,
|
|
1258
|
-
return _regeneratorRuntime.wrap(function
|
|
1259
|
-
while (1) switch (
|
|
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) {
|
|
1260
1358
|
case 0:
|
|
1261
|
-
Demo = /*#__PURE__*/function (
|
|
1262
|
-
_inheritsLoose(Demo,
|
|
1359
|
+
Demo = /*#__PURE__*/function (_Component26) {
|
|
1360
|
+
_inheritsLoose(Demo, _Component26);
|
|
1263
1361
|
function Demo() {
|
|
1264
|
-
var
|
|
1265
|
-
var
|
|
1266
|
-
for (var
|
|
1267
|
-
args[
|
|
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];
|
|
1268
1366
|
}
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
return
|
|
1367
|
+
_this26 = _Component26.call.apply(_Component26, _concatInstanceProperty(_context53 = [this]).call(_context53, args)) || this;
|
|
1368
|
+
_this26.XMarkdown = XMarkdown;
|
|
1369
|
+
return _this26;
|
|
1272
1370
|
}
|
|
1273
1371
|
Demo.defaults = function defaults() {
|
|
1274
1372
|
return {
|
|
@@ -1280,38 +1378,38 @@ describe('XMarkdown', function () {
|
|
|
1280
1378
|
return Demo;
|
|
1281
1379
|
}(Component);
|
|
1282
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 ";
|
|
1283
|
-
|
|
1284
|
-
|
|
1381
|
+
_mount26 = mount(Demo), element = _mount26[1];
|
|
1382
|
+
_context54.next = 5;
|
|
1285
1383
|
return waitFor(function () {
|
|
1286
1384
|
return !!element.querySelector('.katex');
|
|
1287
1385
|
}, 60, 20);
|
|
1288
1386
|
case 5:
|
|
1289
|
-
ready =
|
|
1387
|
+
ready = _context54.sent;
|
|
1290
1388
|
expect(ready).to.be.true;
|
|
1291
1389
|
expect(element.querySelector('.k-xmarkdown-content').textContent).not.to.contain('\\[');
|
|
1292
1390
|
case 8:
|
|
1293
1391
|
case "end":
|
|
1294
|
-
return
|
|
1392
|
+
return _context54.stop();
|
|
1295
1393
|
}
|
|
1296
|
-
},
|
|
1394
|
+
}, _callee26);
|
|
1297
1395
|
})));
|
|
1298
|
-
it('should support tagAttrs and tagRenderers for custom tags', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1299
|
-
var
|
|
1300
|
-
var Demo,
|
|
1301
|
-
return _regeneratorRuntime.wrap(function
|
|
1302
|
-
while (1) switch (
|
|
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) {
|
|
1303
1401
|
case 0:
|
|
1304
|
-
Demo = /*#__PURE__*/function (
|
|
1305
|
-
_inheritsLoose(Demo,
|
|
1402
|
+
Demo = /*#__PURE__*/function (_Component27) {
|
|
1403
|
+
_inheritsLoose(Demo, _Component27);
|
|
1306
1404
|
function Demo() {
|
|
1307
|
-
var
|
|
1308
|
-
var
|
|
1309
|
-
for (var
|
|
1310
|
-
args[
|
|
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];
|
|
1311
1409
|
}
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1410
|
+
_this27 = _Component27.call.apply(_Component27, _concatInstanceProperty(_context55 = [this]).call(_context55, args)) || this;
|
|
1411
|
+
_this27.XMarkdown = XMarkdown;
|
|
1412
|
+
_this27.tagAttrs = {
|
|
1315
1413
|
a: function a() {
|
|
1316
1414
|
return {
|
|
1317
1415
|
className: 'xmarkdown-enhanced-link',
|
|
@@ -1319,7 +1417,7 @@ describe('XMarkdown', function () {
|
|
|
1319
1417
|
};
|
|
1320
1418
|
}
|
|
1321
1419
|
};
|
|
1322
|
-
|
|
1420
|
+
_this27.tagRenderers = {
|
|
1323
1421
|
'notice-card': function noticeCard(context) {
|
|
1324
1422
|
return createVNode('section', {
|
|
1325
1423
|
className: 'xmarkdown-custom-card'
|
|
@@ -1335,7 +1433,7 @@ describe('XMarkdown', function () {
|
|
|
1335
1433
|
}, 'custom table');
|
|
1336
1434
|
}
|
|
1337
1435
|
};
|
|
1338
|
-
return
|
|
1436
|
+
return _this27;
|
|
1339
1437
|
}
|
|
1340
1438
|
Demo.defaults = function defaults() {
|
|
1341
1439
|
return {
|
|
@@ -1349,20 +1447,20 @@ describe('XMarkdown', function () {
|
|
|
1349
1447
|
return Demo;
|
|
1350
1448
|
}(Component);
|
|
1351
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 ";
|
|
1352
|
-
|
|
1353
|
-
|
|
1450
|
+
_mount27 = mount(Demo), element = _mount27[1];
|
|
1451
|
+
_context57.next = 5;
|
|
1354
1452
|
return waitFor(function () {
|
|
1355
1453
|
return !!element.querySelector('.xmarkdown-custom-card');
|
|
1356
1454
|
});
|
|
1357
1455
|
case 5:
|
|
1358
|
-
ready =
|
|
1456
|
+
ready = _context57.sent;
|
|
1359
1457
|
expect(ready).to.be.true;
|
|
1360
1458
|
expect(element.querySelector('notice-card')).to.eql(null);
|
|
1361
1459
|
expect(element.querySelector('table')).to.eql(null);
|
|
1362
1460
|
expect(element.querySelector('.xmarkdown-custom-card-title').textContent).to.eql('发布建议');
|
|
1363
1461
|
expect(element.querySelector('.xmarkdown-custom-card-body').textContent).to.contain('先补 Demo,再补单测。');
|
|
1364
1462
|
expect(element.querySelector('.xmarkdown-custom-table').textContent).to.contain('custom table');
|
|
1365
|
-
expect(_mapInstanceProperty(
|
|
1463
|
+
expect(_mapInstanceProperty(_context56 = _Array$from(element.querySelector('.k-xmarkdown-stable').children)).call(_context56, function (item) {
|
|
1366
1464
|
return item.tagName.toLowerCase();
|
|
1367
1465
|
})).to.eql(['h1', 'section', 'div', 'p']);
|
|
1368
1466
|
expect(element.querySelector('.k-xmarkdown-stable p:empty')).to.eql(null);
|
|
@@ -1372,30 +1470,30 @@ describe('XMarkdown', function () {
|
|
|
1372
1470
|
expect(link.getAttribute('rel')).to.eql('noopener noreferrer');
|
|
1373
1471
|
case 18:
|
|
1374
1472
|
case "end":
|
|
1375
|
-
return
|
|
1473
|
+
return _context57.stop();
|
|
1376
1474
|
}
|
|
1377
|
-
},
|
|
1475
|
+
}, _callee27);
|
|
1378
1476
|
})));
|
|
1379
|
-
it('should support codeBlockRenderers for code blocks and mermaid blocks', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1380
|
-
var initialize, renderAsync, codeContexts, mermaidContexts, Demo,
|
|
1381
|
-
return _regeneratorRuntime.wrap(function
|
|
1382
|
-
while (1) switch (
|
|
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) {
|
|
1383
1481
|
case 0:
|
|
1384
1482
|
initialize = sinon.stub(mermaid, 'initialize');
|
|
1385
1483
|
renderAsync = sinon.stub(mermaid, 'renderAsync');
|
|
1386
1484
|
codeContexts = [];
|
|
1387
1485
|
mermaidContexts = [];
|
|
1388
|
-
Demo = /*#__PURE__*/function (
|
|
1389
|
-
_inheritsLoose(Demo,
|
|
1486
|
+
Demo = /*#__PURE__*/function (_Component28) {
|
|
1487
|
+
_inheritsLoose(Demo, _Component28);
|
|
1390
1488
|
function Demo() {
|
|
1391
|
-
var
|
|
1392
|
-
var
|
|
1393
|
-
for (var
|
|
1394
|
-
args[
|
|
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];
|
|
1395
1493
|
}
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1494
|
+
_this28 = _Component28.call.apply(_Component28, _concatInstanceProperty(_context58 = [this]).call(_context58, args)) || this;
|
|
1495
|
+
_this28.XMarkdown = XMarkdown;
|
|
1496
|
+
_this28.codeBlockRenderers = {
|
|
1399
1497
|
ts: function ts(context) {
|
|
1400
1498
|
codeContexts.push(context);
|
|
1401
1499
|
return createVNode('section', {
|
|
@@ -1417,7 +1515,7 @@ describe('XMarkdown', function () {
|
|
|
1417
1515
|
}, context.source)]);
|
|
1418
1516
|
}
|
|
1419
1517
|
};
|
|
1420
|
-
return
|
|
1518
|
+
return _this28;
|
|
1421
1519
|
}
|
|
1422
1520
|
Demo.defaults = function defaults() {
|
|
1423
1521
|
return {
|
|
@@ -1427,13 +1525,13 @@ describe('XMarkdown', function () {
|
|
|
1427
1525
|
return Demo;
|
|
1428
1526
|
}(Component);
|
|
1429
1527
|
Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={this.get('content')}\n codeBlockRenderers={this.codeBlockRenderers}\n />\n ";
|
|
1430
|
-
|
|
1431
|
-
|
|
1528
|
+
_mount28 = mount(Demo), element = _mount28[1];
|
|
1529
|
+
_context59.next = 9;
|
|
1432
1530
|
return waitFor(function () {
|
|
1433
1531
|
return !!element.querySelector('.xmarkdown-custom-code-block') && !!element.querySelector('.xmarkdown-custom-mermaid-block');
|
|
1434
1532
|
});
|
|
1435
1533
|
case 9:
|
|
1436
|
-
ready =
|
|
1534
|
+
ready = _context59.sent;
|
|
1437
1535
|
expect(ready).to.be.true;
|
|
1438
1536
|
expect(initialize.called).to.be.false;
|
|
1439
1537
|
expect(renderAsync.called).to.be.false;
|
|
@@ -1446,26 +1544,26 @@ describe('XMarkdown', function () {
|
|
|
1446
1544
|
expect(element.querySelector('.k-xmarkdown-code-toolbar')).to.eql(null);
|
|
1447
1545
|
case 20:
|
|
1448
1546
|
case "end":
|
|
1449
|
-
return
|
|
1547
|
+
return _context59.stop();
|
|
1450
1548
|
}
|
|
1451
|
-
},
|
|
1549
|
+
}, _callee28);
|
|
1452
1550
|
})));
|
|
1453
|
-
it('should refresh renderer when codeBlockRenderers change', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1454
|
-
var Demo,
|
|
1455
|
-
return _regeneratorRuntime.wrap(function
|
|
1456
|
-
while (1) switch (
|
|
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) {
|
|
1457
1555
|
case 0:
|
|
1458
|
-
Demo = /*#__PURE__*/function (
|
|
1459
|
-
_inheritsLoose(Demo,
|
|
1556
|
+
Demo = /*#__PURE__*/function (_Component29) {
|
|
1557
|
+
_inheritsLoose(Demo, _Component29);
|
|
1460
1558
|
function Demo() {
|
|
1461
|
-
var
|
|
1462
|
-
var
|
|
1463
|
-
for (var
|
|
1464
|
-
args[
|
|
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];
|
|
1465
1563
|
}
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
return
|
|
1564
|
+
_this29 = _Component29.call.apply(_Component29, _concatInstanceProperty(_context60 = [this]).call(_context60, args)) || this;
|
|
1565
|
+
_this29.XMarkdown = XMarkdown;
|
|
1566
|
+
return _this29;
|
|
1469
1567
|
}
|
|
1470
1568
|
Demo.defaults = function defaults() {
|
|
1471
1569
|
return {
|
|
@@ -1476,13 +1574,13 @@ describe('XMarkdown', function () {
|
|
|
1476
1574
|
return Demo;
|
|
1477
1575
|
}(Component);
|
|
1478
1576
|
Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={this.get('content')}\n codeBlockRenderers={this.get('codeBlockRenderers')}\n />\n ";
|
|
1479
|
-
|
|
1480
|
-
|
|
1577
|
+
_mount29 = mount(Demo), instance = _mount29[0], element = _mount29[1];
|
|
1578
|
+
_context61.next = 5;
|
|
1481
1579
|
return waitFor(function () {
|
|
1482
1580
|
return !!element.querySelector('.k-xmarkdown-code-toolbar');
|
|
1483
1581
|
});
|
|
1484
1582
|
case 5:
|
|
1485
|
-
initialReady =
|
|
1583
|
+
initialReady = _context61.sent;
|
|
1486
1584
|
expect(initialReady).to.be.true;
|
|
1487
1585
|
expect(element.querySelector('.xmarkdown-refresh-code-block')).to.eql(null);
|
|
1488
1586
|
instance.set('codeBlockRenderers', {
|
|
@@ -1492,36 +1590,36 @@ describe('XMarkdown', function () {
|
|
|
1492
1590
|
}, context.source);
|
|
1493
1591
|
}
|
|
1494
1592
|
});
|
|
1495
|
-
|
|
1593
|
+
_context61.next = 11;
|
|
1496
1594
|
return waitFor(function () {
|
|
1497
1595
|
return !!element.querySelector('.xmarkdown-refresh-code-block');
|
|
1498
1596
|
});
|
|
1499
1597
|
case 11:
|
|
1500
|
-
refreshed =
|
|
1598
|
+
refreshed = _context61.sent;
|
|
1501
1599
|
expect(refreshed).to.be.true;
|
|
1502
1600
|
expect(element.querySelector('.k-xmarkdown-code-toolbar')).to.eql(null);
|
|
1503
1601
|
case 14:
|
|
1504
1602
|
case "end":
|
|
1505
|
-
return
|
|
1603
|
+
return _context61.stop();
|
|
1506
1604
|
}
|
|
1507
|
-
},
|
|
1605
|
+
}, _callee29);
|
|
1508
1606
|
})));
|
|
1509
|
-
it('should support plugins for markdown extension and render tree transform', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1510
|
-
var Demo,
|
|
1511
|
-
return _regeneratorRuntime.wrap(function
|
|
1512
|
-
while (1) switch (
|
|
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) {
|
|
1513
1611
|
case 0:
|
|
1514
|
-
Demo = /*#__PURE__*/function (
|
|
1515
|
-
_inheritsLoose(Demo,
|
|
1612
|
+
Demo = /*#__PURE__*/function (_Component30) {
|
|
1613
|
+
_inheritsLoose(Demo, _Component30);
|
|
1516
1614
|
function Demo() {
|
|
1517
|
-
var
|
|
1518
|
-
var
|
|
1519
|
-
for (var
|
|
1520
|
-
args[
|
|
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];
|
|
1521
1619
|
}
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1620
|
+
_this30 = _Component30.call.apply(_Component30, _concatInstanceProperty(_context62 = [this]).call(_context62, args)) || this;
|
|
1621
|
+
_this30.XMarkdown = XMarkdown;
|
|
1622
|
+
_this30.plugins = [{
|
|
1525
1623
|
extendMarkdown: function extendMarkdown(markdown) {
|
|
1526
1624
|
markdown.core.ruler.push('xmarkdown-heading-plugin', function (state) {
|
|
1527
1625
|
state.tokens.forEach(function (token) {
|
|
@@ -1545,7 +1643,7 @@ describe('XMarkdown', function () {
|
|
|
1545
1643
|
});
|
|
1546
1644
|
}
|
|
1547
1645
|
}];
|
|
1548
|
-
return
|
|
1646
|
+
return _this30;
|
|
1549
1647
|
}
|
|
1550
1648
|
Demo.defaults = function defaults() {
|
|
1551
1649
|
return {
|
|
@@ -1555,38 +1653,38 @@ describe('XMarkdown', function () {
|
|
|
1555
1653
|
return Demo;
|
|
1556
1654
|
}(Component);
|
|
1557
1655
|
Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={this.get('content')}\n plugins={this.plugins}\n />\n ";
|
|
1558
|
-
|
|
1559
|
-
|
|
1656
|
+
_mount30 = mount(Demo), element = _mount30[1];
|
|
1657
|
+
_context63.next = 5;
|
|
1560
1658
|
return waitFor(function () {
|
|
1561
1659
|
return !!element.querySelector('.k-xmarkdown-content blockquote');
|
|
1562
1660
|
});
|
|
1563
1661
|
case 5:
|
|
1564
|
-
ready =
|
|
1662
|
+
ready = _context63.sent;
|
|
1565
1663
|
expect(ready).to.be.true;
|
|
1566
1664
|
expect(element.querySelector('h1').getAttribute('data-plugin-source')).to.eql('markdown-it');
|
|
1567
1665
|
expect(element.querySelector('blockquote').getAttribute('data-plugin-transform')).to.eql('render-tree');
|
|
1568
1666
|
case 9:
|
|
1569
1667
|
case "end":
|
|
1570
|
-
return
|
|
1668
|
+
return _context63.stop();
|
|
1571
1669
|
}
|
|
1572
|
-
},
|
|
1670
|
+
}, _callee30);
|
|
1573
1671
|
})));
|
|
1574
|
-
it('should refresh renderer when plugins change', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1575
|
-
var Demo,
|
|
1576
|
-
return _regeneratorRuntime.wrap(function
|
|
1577
|
-
while (1) switch (
|
|
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) {
|
|
1578
1676
|
case 0:
|
|
1579
|
-
Demo = /*#__PURE__*/function (
|
|
1580
|
-
_inheritsLoose(Demo,
|
|
1677
|
+
Demo = /*#__PURE__*/function (_Component31) {
|
|
1678
|
+
_inheritsLoose(Demo, _Component31);
|
|
1581
1679
|
function Demo() {
|
|
1582
|
-
var
|
|
1583
|
-
var
|
|
1584
|
-
for (var
|
|
1585
|
-
args[
|
|
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];
|
|
1586
1684
|
}
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
return
|
|
1685
|
+
_this31 = _Component31.call.apply(_Component31, _concatInstanceProperty(_context64 = [this]).call(_context64, args)) || this;
|
|
1686
|
+
_this31.XMarkdown = XMarkdown;
|
|
1687
|
+
return _this31;
|
|
1590
1688
|
}
|
|
1591
1689
|
Demo.defaults = function defaults() {
|
|
1592
1690
|
return {
|
|
@@ -1596,13 +1694,13 @@ describe('XMarkdown', function () {
|
|
|
1596
1694
|
return Demo;
|
|
1597
1695
|
}(Component);
|
|
1598
1696
|
Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={'# \u63D2\u4EF6\u5237\u65B0'}\n plugins={this.get('plugins')}\n />\n ";
|
|
1599
|
-
|
|
1600
|
-
|
|
1697
|
+
_mount31 = mount(Demo), instance = _mount31[0], element = _mount31[1];
|
|
1698
|
+
_context65.next = 5;
|
|
1601
1699
|
return waitFor(function () {
|
|
1602
1700
|
return !!element.querySelector('h1');
|
|
1603
1701
|
});
|
|
1604
1702
|
case 5:
|
|
1605
|
-
initialReady =
|
|
1703
|
+
initialReady = _context65.sent;
|
|
1606
1704
|
expect(initialReady).to.be.true;
|
|
1607
1705
|
expect(element.querySelector('h1').getAttribute('data-refresh-plugin')).to.eql(null);
|
|
1608
1706
|
instance.set('plugins', [{
|
|
@@ -1616,23 +1714,23 @@ describe('XMarkdown', function () {
|
|
|
1616
1714
|
});
|
|
1617
1715
|
}
|
|
1618
1716
|
}]);
|
|
1619
|
-
|
|
1717
|
+
_context65.next = 11;
|
|
1620
1718
|
return waitFor(function () {
|
|
1621
1719
|
return element.querySelector('h1').getAttribute('data-refresh-plugin') === 'updated';
|
|
1622
1720
|
});
|
|
1623
1721
|
case 11:
|
|
1624
|
-
refreshed =
|
|
1722
|
+
refreshed = _context65.sent;
|
|
1625
1723
|
expect(refreshed).to.be.true;
|
|
1626
1724
|
case 13:
|
|
1627
1725
|
case "end":
|
|
1628
|
-
return
|
|
1726
|
+
return _context65.stop();
|
|
1629
1727
|
}
|
|
1630
|
-
},
|
|
1728
|
+
}, _callee31);
|
|
1631
1729
|
})));
|
|
1632
|
-
it('should support plugins transforming citation markers from business data', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1633
|
-
var citations, Demo, transformCitationNodes, splitCitationText,
|
|
1634
|
-
return _regeneratorRuntime.wrap(function
|
|
1635
|
-
while (1) switch (
|
|
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) {
|
|
1636
1734
|
case 0:
|
|
1637
1735
|
splitCitationText = function _splitCitationText(text) {
|
|
1638
1736
|
var nextNodes = [];
|
|
@@ -1680,7 +1778,7 @@ describe('XMarkdown', function () {
|
|
|
1680
1778
|
return nextNodes;
|
|
1681
1779
|
};
|
|
1682
1780
|
transformCitationNodes = function _transformCitationNod(nodes, appendSection) {
|
|
1683
|
-
var
|
|
1781
|
+
var _context67;
|
|
1684
1782
|
if (appendSection === void 0) {
|
|
1685
1783
|
appendSection = false;
|
|
1686
1784
|
}
|
|
@@ -1699,7 +1797,7 @@ describe('XMarkdown', function () {
|
|
|
1699
1797
|
}));
|
|
1700
1798
|
});
|
|
1701
1799
|
if (!appendSection || !citations.length) return nextNodes;
|
|
1702
|
-
return _concatInstanceProperty(
|
|
1800
|
+
return _concatInstanceProperty(_context67 = []).call(_context67, nextNodes, [{
|
|
1703
1801
|
type: 'element',
|
|
1704
1802
|
tag: 'section',
|
|
1705
1803
|
attrs: {
|
|
@@ -1715,33 +1813,33 @@ describe('XMarkdown', function () {
|
|
|
1715
1813
|
title: '引用来源一',
|
|
1716
1814
|
link: 'https://example.com/source-1'
|
|
1717
1815
|
}];
|
|
1718
|
-
Demo = /*#__PURE__*/function (
|
|
1719
|
-
_inheritsLoose(Demo,
|
|
1816
|
+
Demo = /*#__PURE__*/function (_Component32) {
|
|
1817
|
+
_inheritsLoose(Demo, _Component32);
|
|
1720
1818
|
function Demo() {
|
|
1721
|
-
var
|
|
1722
|
-
var
|
|
1723
|
-
for (var
|
|
1724
|
-
args[
|
|
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];
|
|
1725
1823
|
}
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1824
|
+
_this32 = _Component32.call.apply(_Component32, _concatInstanceProperty(_context66 = [this]).call(_context66, args)) || this;
|
|
1825
|
+
_this32.XMarkdown = XMarkdown;
|
|
1826
|
+
_this32.plugins = [{
|
|
1729
1827
|
transformRenderTree: function transformRenderTree(nodes) {
|
|
1730
1828
|
return transformCitationNodes(nodes, true);
|
|
1731
1829
|
}
|
|
1732
1830
|
}];
|
|
1733
|
-
return
|
|
1831
|
+
return _this32;
|
|
1734
1832
|
}
|
|
1735
1833
|
return Demo;
|
|
1736
1834
|
}(Component);
|
|
1737
1835
|
Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={'\u6B63\u6587\u5F15\u7528[1][2]'}\n plugins={this.plugins}\n />\n ";
|
|
1738
|
-
|
|
1739
|
-
|
|
1836
|
+
_mount32 = mount(Demo), element = _mount32[1];
|
|
1837
|
+
_context68.next = 8;
|
|
1740
1838
|
return waitFor(function () {
|
|
1741
1839
|
return !!element.querySelector('[data-citation-index="1"]');
|
|
1742
1840
|
});
|
|
1743
1841
|
case 8:
|
|
1744
|
-
ready =
|
|
1842
|
+
ready = _context68.sent;
|
|
1745
1843
|
expect(ready).to.be.true;
|
|
1746
1844
|
expect(element.querySelectorAll('[data-citation-index]').length).to.eql(1);
|
|
1747
1845
|
expect(element.querySelector('[data-citation-index="1"]').getAttribute('href')).to.eql('https://example.com/source-1');
|
|
@@ -1749,49 +1847,49 @@ describe('XMarkdown', function () {
|
|
|
1749
1847
|
expect(element.querySelector('[data-citation-section="true"]').textContent).to.contain('Sources: 1');
|
|
1750
1848
|
case 14:
|
|
1751
1849
|
case "end":
|
|
1752
|
-
return
|
|
1850
|
+
return _context68.stop();
|
|
1753
1851
|
}
|
|
1754
|
-
},
|
|
1852
|
+
}, _callee32);
|
|
1755
1853
|
})));
|
|
1756
|
-
it('should avoid duplicate markdown rendering during initial mount', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1757
|
-
var transformRenderTree, Demo,
|
|
1758
|
-
return _regeneratorRuntime.wrap(function
|
|
1759
|
-
while (1) switch (
|
|
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) {
|
|
1760
1858
|
case 0:
|
|
1761
1859
|
transformRenderTree = sinon.spy(function (nodes) {
|
|
1762
1860
|
return nodes;
|
|
1763
1861
|
});
|
|
1764
|
-
Demo = /*#__PURE__*/function (
|
|
1765
|
-
_inheritsLoose(Demo,
|
|
1862
|
+
Demo = /*#__PURE__*/function (_Component33) {
|
|
1863
|
+
_inheritsLoose(Demo, _Component33);
|
|
1766
1864
|
function Demo() {
|
|
1767
|
-
var
|
|
1768
|
-
var
|
|
1769
|
-
for (var
|
|
1770
|
-
args[
|
|
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];
|
|
1771
1869
|
}
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1870
|
+
_this33 = _Component33.call.apply(_Component33, _concatInstanceProperty(_context69 = [this]).call(_context69, args)) || this;
|
|
1871
|
+
_this33.XMarkdown = XMarkdown;
|
|
1872
|
+
_this33.plugins = [{
|
|
1775
1873
|
transformRenderTree: transformRenderTree
|
|
1776
1874
|
}];
|
|
1777
|
-
return
|
|
1875
|
+
return _this33;
|
|
1778
1876
|
}
|
|
1779
1877
|
return Demo;
|
|
1780
1878
|
}(Component);
|
|
1781
1879
|
Demo.template = "\n const { XMarkdown } = this;\n <XMarkdown\n content={'# \u521D\u59CB\u5316\u6E32\u67D3'}\n plugins={this.plugins}\n />\n ";
|
|
1782
|
-
|
|
1783
|
-
|
|
1880
|
+
_mount33 = mount(Demo), element = _mount33[1];
|
|
1881
|
+
_context70.next = 6;
|
|
1784
1882
|
return waitFor(function () {
|
|
1785
1883
|
return !!element.querySelector('h1');
|
|
1786
1884
|
});
|
|
1787
1885
|
case 6:
|
|
1788
|
-
ready =
|
|
1886
|
+
ready = _context70.sent;
|
|
1789
1887
|
expect(ready).to.be.true;
|
|
1790
1888
|
expect(transformRenderTree.callCount).to.eql(1);
|
|
1791
1889
|
case 9:
|
|
1792
1890
|
case "end":
|
|
1793
|
-
return
|
|
1891
|
+
return _context70.stop();
|
|
1794
1892
|
}
|
|
1795
|
-
},
|
|
1893
|
+
}, _callee33);
|
|
1796
1894
|
})));
|
|
1797
1895
|
});
|