biso24-editor 1.3.0

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 (104) hide show
  1. package/CKEditor4/.eslintrc.json +4 -0
  2. package/CKEditor4/CHANGES.md +2182 -0
  3. package/CKEditor4/LICENSE.md +1436 -0
  4. package/CKEditor4/README.md +39 -0
  5. package/CKEditor4/SECURITY.md +10 -0
  6. package/CKEditor4/adapters/jquery.js +158 -0
  7. package/CKEditor4/bender-runner.config.json +16 -0
  8. package/CKEditor4/build-config.js +100 -0
  9. package/CKEditor4/ckeditor.js +30065 -0
  10. package/CKEditor4/config.js +39 -0
  11. package/CKEditor4/contents.css +161 -0
  12. package/CKEditor4/lang/vi.js +475 -0
  13. package/CKEditor4/plugins/a11yhelp/dialogs/a11yhelp.js +143 -0
  14. package/CKEditor4/plugins/a11yhelp/dialogs/lang/vi.js +122 -0
  15. package/CKEditor4/plugins/ajax/plugin.js +241 -0
  16. package/CKEditor4/plugins/autocomplete/plugin.js +1655 -0
  17. package/CKEditor4/plugins/autocomplete/skins/default.css +38 -0
  18. package/CKEditor4/plugins/custompaste/plugin.js +57 -0
  19. package/CKEditor4/plugins/dialog/dialogDefinition.js +4 -0
  20. package/CKEditor4/plugins/dialog/styles/dialog.css +18 -0
  21. package/CKEditor4/plugins/font/lang/vi.js +14 -0
  22. package/CKEditor4/plugins/font/plugin.js +535 -0
  23. package/CKEditor4/plugins/icons.png +0 -0
  24. package/CKEditor4/plugins/icons_hidpi.png +0 -0
  25. package/CKEditor4/plugins/image2/dialogs/image2.js +558 -0
  26. package/CKEditor4/plugins/image2/icons/hidpi/image.png +0 -0
  27. package/CKEditor4/plugins/image2/icons/image.png +0 -0
  28. package/CKEditor4/plugins/image2/lang/vi.js +21 -0
  29. package/CKEditor4/plugins/image2/plugin.js +1708 -0
  30. package/CKEditor4/plugins/justify/icons/hidpi/justifyblock.png +0 -0
  31. package/CKEditor4/plugins/justify/icons/hidpi/justifycenter.png +0 -0
  32. package/CKEditor4/plugins/justify/icons/hidpi/justifyleft.png +0 -0
  33. package/CKEditor4/plugins/justify/icons/hidpi/justifyright.png +0 -0
  34. package/CKEditor4/plugins/justify/icons/justifyblock.png +0 -0
  35. package/CKEditor4/plugins/justify/icons/justifycenter.png +0 -0
  36. package/CKEditor4/plugins/justify/icons/justifyleft.png +0 -0
  37. package/CKEditor4/plugins/justify/icons/justifyright.png +0 -0
  38. package/CKEditor4/plugins/justify/plugin.js +266 -0
  39. package/CKEditor4/plugins/justify_group/icons/hidpi/justifycenter.png +0 -0
  40. package/CKEditor4/plugins/justify_group/icons/justifycenter.png +0 -0
  41. package/CKEditor4/plugins/justify_group/plugin.js +64 -0
  42. package/CKEditor4/plugins/lineheight/LICENSE +22 -0
  43. package/CKEditor4/plugins/lineheight/README.md +2 -0
  44. package/CKEditor4/plugins/lineheight/lang/vi.js +3 -0
  45. package/CKEditor4/plugins/lineheight/plugin.js +99 -0
  46. package/CKEditor4/plugins/lineheight/readme.txt +30 -0
  47. package/CKEditor4/plugins/link/dialogs/anchor.js +82 -0
  48. package/CKEditor4/plugins/link/dialogs/link.js +777 -0
  49. package/CKEditor4/plugins/link/images/anchor.png +0 -0
  50. package/CKEditor4/plugins/link/images/hidpi/anchor.png +0 -0
  51. package/CKEditor4/plugins/magicline/images/hidpi/icon-rtl.png +0 -0
  52. package/CKEditor4/plugins/magicline/images/hidpi/icon.png +0 -0
  53. package/CKEditor4/plugins/magicline/images/icon-rtl.png +0 -0
  54. package/CKEditor4/plugins/magicline/images/icon.png +0 -0
  55. package/CKEditor4/plugins/mentions/plugin.js +471 -0
  56. package/CKEditor4/plugins/menubutton/plugin.js +99 -0
  57. package/CKEditor4/plugins/pastefromword/filter/default.js +849 -0
  58. package/CKEditor4/plugins/pastetools/filter/common.js +445 -0
  59. package/CKEditor4/plugins/pastetools/filter/image.js +163 -0
  60. package/CKEditor4/plugins/pdffile/icons/exporttopdf.png +0 -0
  61. package/CKEditor4/plugins/pdffile/icons/hidpi/exporttopdf.png +0 -0
  62. package/CKEditor4/plugins/pdffile/plugin.js +36 -0
  63. package/CKEditor4/plugins/placeholder_button/plugin.js +31 -0
  64. package/CKEditor4/plugins/sourcedialog/dialogs/sourcedialog.js +88 -0
  65. package/CKEditor4/plugins/sourcedialog/icons/hidpi/sourcedialog-rtl.png +0 -0
  66. package/CKEditor4/plugins/sourcedialog/icons/hidpi/sourcedialog.png +0 -0
  67. package/CKEditor4/plugins/sourcedialog/icons/sourcedialog-rtl.png +0 -0
  68. package/CKEditor4/plugins/sourcedialog/icons/sourcedialog.png +0 -0
  69. package/CKEditor4/plugins/sourcedialog/lang/vi.js +9 -0
  70. package/CKEditor4/plugins/sourcedialog/plugin.js +30 -0
  71. package/CKEditor4/plugins/textmatch/plugin.js +331 -0
  72. package/CKEditor4/plugins/textwatcher/plugin.js +295 -0
  73. package/CKEditor4/plugins/widget/images/handle.png +0 -0
  74. package/CKEditor4/plugins/wordfile/icons/exporttoword.png +0 -0
  75. package/CKEditor4/plugins/wordfile/icons/hidpi/exporttoword.png +0 -0
  76. package/CKEditor4/plugins/wordfile/icons/hidpi/importfromword.png +0 -0
  77. package/CKEditor4/plugins/wordfile/icons/importfromword.png +0 -0
  78. package/CKEditor4/plugins/wordfile/plugin.js +161 -0
  79. package/CKEditor4/skins/moono-lisa/dialog.css +685 -0
  80. package/CKEditor4/skins/moono-lisa/dialog_ie.css +721 -0
  81. package/CKEditor4/skins/moono-lisa/dialog_ie8.css +746 -0
  82. package/CKEditor4/skins/moono-lisa/dialog_iequirks.css +724 -0
  83. package/CKEditor4/skins/moono-lisa/editor.css +1551 -0
  84. package/CKEditor4/skins/moono-lisa/editor_gecko.css +1556 -0
  85. package/CKEditor4/skins/moono-lisa/editor_ie.css +1588 -0
  86. package/CKEditor4/skins/moono-lisa/editor_ie8.css +1639 -0
  87. package/CKEditor4/skins/moono-lisa/editor_iequirks.css +1632 -0
  88. package/CKEditor4/skins/moono-lisa/icons.png +0 -0
  89. package/CKEditor4/skins/moono-lisa/icons_hidpi.png +0 -0
  90. package/CKEditor4/skins/moono-lisa/images/arrow.png +0 -0
  91. package/CKEditor4/skins/moono-lisa/images/close.png +0 -0
  92. package/CKEditor4/skins/moono-lisa/images/hidpi/close.png +0 -0
  93. package/CKEditor4/skins/moono-lisa/images/hidpi/lock-open.png +0 -0
  94. package/CKEditor4/skins/moono-lisa/images/hidpi/lock.png +0 -0
  95. package/CKEditor4/skins/moono-lisa/images/hidpi/refresh.png +0 -0
  96. package/CKEditor4/skins/moono-lisa/images/lock-open.png +0 -0
  97. package/CKEditor4/skins/moono-lisa/images/lock.png +0 -0
  98. package/CKEditor4/skins/moono-lisa/images/refresh.png +0 -0
  99. package/CKEditor4/skins/moono-lisa/images/spinner.gif +0 -0
  100. package/CKEditor4/skins/moono-lisa/readme.md +46 -0
  101. package/CKEditor4/styles.js +136 -0
  102. package/CKEditor4/vendor/promise.js +385 -0
  103. package/README.md +3 -0
  104. package/package.json +9 -0
@@ -0,0 +1,143 @@
1
+ /*
2
+ Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
+ For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ CKEDITOR.dialog.add('a11yHelp', function (f) {
6
+ function m(a) {
7
+ for (var b, c, h = [], d = 0; d < g.length; d++)
8
+ (c = g[d]), (b = a / g[d]), 1 < b && 2 >= b && ((a -= c), h.push(e[c]));
9
+ h.push(e[a] || String.fromCharCode(a));
10
+ return h.join('+');
11
+ }
12
+ function t(a, b) {
13
+ var c = f.getCommandKeystroke(b, !0);
14
+ return c.length ? CKEDITOR.tools.array.map(c, m).join(' / ') : a;
15
+ }
16
+ var a = f.lang.a11yhelp,
17
+ b = f.lang.common.keyboard,
18
+ p = CKEDITOR.tools.getNextId(),
19
+ q = /\$\{(.*?)\}/g,
20
+ g = [CKEDITOR.ALT, CKEDITOR.SHIFT, CKEDITOR.CTRL],
21
+ e = {
22
+ 8: b[8],
23
+ 9: a.tab,
24
+ 13: b[13],
25
+ 16: b[16],
26
+ 17: b[17],
27
+ 18: b[18],
28
+ 19: a.pause,
29
+ 20: a.capslock,
30
+ 27: a.escape,
31
+ 33: a.pageUp,
32
+ 34: a.pageDown,
33
+ 35: b[35],
34
+ 36: b[36],
35
+ 37: a.leftArrow,
36
+ 38: a.upArrow,
37
+ 39: a.rightArrow,
38
+ 40: a.downArrow,
39
+ 45: a.insert,
40
+ 46: b[46],
41
+ 91: a.leftWindowKey,
42
+ 92: a.rightWindowKey,
43
+ 93: a.selectKey,
44
+ 96: a.numpad0,
45
+ 97: a.numpad1,
46
+ 98: a.numpad2,
47
+ 99: a.numpad3,
48
+ 100: a.numpad4,
49
+ 101: a.numpad5,
50
+ 102: a.numpad6,
51
+ 103: a.numpad7,
52
+ 104: a.numpad8,
53
+ 105: a.numpad9,
54
+ 106: a.multiply,
55
+ 107: a.add,
56
+ 109: a.subtract,
57
+ 110: a.decimalPoint,
58
+ 111: a.divide,
59
+ 112: a.f1,
60
+ 113: a.f2,
61
+ 114: a.f3,
62
+ 115: a.f4,
63
+ 116: a.f5,
64
+ 117: a.f6,
65
+ 118: a.f7,
66
+ 119: a.f8,
67
+ 120: a.f9,
68
+ 121: a.f10,
69
+ 122: a.f11,
70
+ 123: a.f12,
71
+ 144: a.numLock,
72
+ 145: a.scrollLock,
73
+ 186: a.semiColon,
74
+ 187: a.equalSign,
75
+ 188: a.comma,
76
+ 189: a.dash,
77
+ 190: a.period,
78
+ 191: a.forwardSlash,
79
+ 192: a.graveAccent,
80
+ 219: a.openBracket,
81
+ 220: a.backSlash,
82
+ 221: a.closeBracket,
83
+ 222: a.singleQuote,
84
+ };
85
+ e[CKEDITOR.ALT] = b[18];
86
+ e[CKEDITOR.SHIFT] = b[16];
87
+ e[CKEDITOR.CTRL] = CKEDITOR.env.mac ? b[224] : b[17];
88
+ return {
89
+ title: a.title,
90
+ minWidth: 600,
91
+ minHeight: 400,
92
+ contents: [
93
+ {
94
+ id: 'info',
95
+ label: f.lang.common.generalTab,
96
+ expand: !0,
97
+ elements: [
98
+ {
99
+ type: 'html',
100
+ id: 'legends',
101
+ style: 'white-space:normal;',
102
+ focus: function () {
103
+ this.getElement().focus();
104
+ },
105
+ html:
106
+ (function () {
107
+ for (
108
+ var b =
109
+ '\x3cdiv class\x3d"cke_accessibility_legend" role\x3d"document" aria-labelledby\x3d"' +
110
+ p +
111
+ '_arialbl" tabIndex\x3d"-1"\x3e%1\x3c/div\x3e\x3cspan id\x3d"' +
112
+ p +
113
+ '_arialbl" class\x3d"cke_voice_label"\x3e' +
114
+ a.contents +
115
+ ' \x3c/span\x3e',
116
+ e = [],
117
+ c = a.legend,
118
+ h = c.length,
119
+ d = 0;
120
+ d < h;
121
+ d++
122
+ ) {
123
+ for (var f = c[d], g = [], r = f.items, m = r.length, n = 0; n < m; n++) {
124
+ var k = r[n],
125
+ l = CKEDITOR.env.edge && k.legendEdge ? k.legendEdge : k.legend,
126
+ l = l.replace(q, t);
127
+ l.match(q) ||
128
+ g.push('\x3cdt\x3e%1\x3c/dt\x3e\x3cdd\x3e%2\x3c/dd\x3e'.replace('%1', k.name).replace('%2', l));
129
+ }
130
+ e.push(
131
+ '\x3ch1\x3e%1\x3c/h1\x3e\x3cdl\x3e%2\x3c/dl\x3e'.replace('%1', f.name).replace('%2', g.join('')),
132
+ );
133
+ }
134
+ return b.replace('%1', e.join(''));
135
+ })() +
136
+ '\x3cstyle type\x3d"text/css"\x3e.cke_accessibility_legend{width:600px;height:400px;padding-right:5px;overflow-y:auto;overflow-x:hidden;}.cke_browser_quirks .cke_accessibility_legend,{height:390px}.cke_accessibility_legend *{white-space:normal;}.cke_accessibility_legend h1{font-size: 20px;border-bottom: 1px solid #AAA;margin: 5px 0px 15px;}.cke_accessibility_legend dl{margin-left: 5px;}.cke_accessibility_legend dt{font-size: 13px;font-weight: bold;}.cke_accessibility_legend dd{margin:10px}\x3c/style\x3e',
137
+ },
138
+ ],
139
+ },
140
+ ],
141
+ buttons: [CKEDITOR.dialog.cancelButton],
142
+ };
143
+ });
@@ -0,0 +1,122 @@
1
+ /*
2
+ Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
+ For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ CKEDITOR.plugins.setLang('a11yhelp', 'vi', {
6
+ title: 'Hướng dẫn trợ năng',
7
+ contents: 'Nội dung Hỗ trợ. Nhấn ESC để đóng hộp thoại.',
8
+ legend: [
9
+ {
10
+ name: 'Chung',
11
+ items: [
12
+ {
13
+ name: 'Thanh công cụ soạn thảo',
14
+ legend:
15
+ 'Nhấn ${toolbarFocus} để điều hướng đến thanh công cụ. Nhấn TAB và SHIFT+TAB để chuyển đến nhóm thanh công cụ khác. Nhấn MŨI TÊN PHẢI hoặc MŨI TÊN TRÁI để chuyển sang nút khác trên thanh công cụ. Nhấn PHÍM CÁCH hoặc ENTER để kích hoạt nút trên thanh công cụ.',
16
+ },
17
+ {
18
+ name: 'Hộp thoại Biên t',
19
+ legend:
20
+ 'Inside a dialog, press TAB to navigate to the next dialog element, press SHIFT+TAB to move to the previous dialog element, press ENTER to submit the dialog, press ESC to cancel the dialog. When a dialog has multiple tabs, the tab list can be reached either with ALT+F10 or with TAB as part of the dialog tabbing order. With tab list focused, move to the next and previous tab with RIGHT and LEFT ARROW, respectively.',
21
+ },
22
+ {
23
+ name: 'Trình đơn Ngữ cảnh cBộ soạn thảo',
24
+ legend:
25
+ 'Nhấn ${contextMenu} hoặc PHÍM ỨNG DỤNG để mở thực đơn ngữ cảnh. Sau đó nhấn TAB hoặc MŨI TÊN XUỐNG để di chuyển đến tuỳ chọn tiếp theo của thực đơn. Nhấn SHIFT+TAB hoặc MŨI TÊN LÊN để quay lại tuỳ chọn trước. Nhấn DẤU CÁCH hoặc ENTER để chọn tuỳ chọn của thực đơn. Nhấn DẤU CÁCH hoặc ENTER hoặc MŨI TÊN SANG PHẢI để mở thực đơn con của tuỳ chọn hiện tại. Nhấn ESC hoặc MŨI TÊN SANG TRÁI để quay trở lại thực đơn gốc. Nhấn ESC để đóng thực đơn ngữ cảnh.',
26
+ },
27
+ {
28
+ name: 'Hộp danh sách trình biên tập',
29
+ legend:
30
+ 'Trong một danh sách chọn, di chuyển đối tượng tiếp theo với phím TAB hoặc phím mũi tên hướng xuống. Di chuyển đến đối tượng trước đó bằng cách nhấn tổ hợp phím SHIFT+TAB hoặc mũi tên hướng lên. Phím khoảng cách hoặc phím ENTER để chọn các tùy chọn trong danh sách. Nhấn phím ESC để đóng lại danh sách chọn.',
31
+ },
32
+ {
33
+ name: 'Thanh đường dẫn các đối tượng',
34
+ legend:
35
+ 'Nhấn ${elementsPathFocus} để điều hướng các đối tượng trong thanh đường dẫn. Di chuyển đến đối tượng tiếp theo bằng phím TAB hoặc phím mũi tên bên phải. Di chuyển đến đối tượng trước đó bằng tổ hợp phím SHIFT+TAB hoặc phím mũi tên bên trái. Nhấn phím khoảng cách hoặc ENTER để chọn đối tượng trong trình soạn thảo.',
36
+ },
37
+ ],
38
+ },
39
+ {
40
+ name: 'Lệnh',
41
+ items: [
42
+ { name: 'Làm lại lện', legend: 'Ấn ${undo}' },
43
+ { name: 'Làm lại lệnh', legend: 'Ấn ${redo}' },
44
+ { name: 'Lệnh in đậm', legend: 'Ấn ${bold}' },
45
+ { name: 'Lệnh in nghiêng', legend: 'Ấn ${italic}' },
46
+ { name: 'Lệnh gạch dưới', legend: 'Ấn ${underline}' },
47
+ { name: 'Lệnh liên kết', legend: 'Nhấn ${link}' },
48
+ { name: 'Lệnh hiển thị thanh công cụ', legend: 'Nhấn${toolbarCollapse}' },
49
+ {
50
+ name: 'Truy cập đến lệnh tập trung vào khoảng cách trước đó',
51
+ legend:
52
+ 'Ấn ${accessPreviousSpace} để truy cập đến phần tập trung khoảng cách sau phần còn sót lại của khoảng cách gần nhất vốn không tác động đến được , thí dụ: hai yếu tố điều chỉnh HR. Lặp lại các phím kết họep này để vươn đến phần khoảng cách.',
53
+ },
54
+ {
55
+ name: 'Truy cập phần đối tượng lệnh khoảng trống',
56
+ legend:
57
+ 'Ấn ${accessNextSpace} để truy cập đến phần tập trung khoảng cách sau phần còn sót lại của khoảng cách gần nhất vốn không tác động đến được , thí dụ: hai yếu tố điều chỉnh HR. Lặp lại các phím kết họep này để vươn đến phần khoảng cách.',
58
+ },
59
+ { name: 'Trợ giúp liên quan', legend: 'Nhấn ${a11yHelp}' },
60
+ {
61
+ name: ' Paste as plain text',
62
+ legend: 'Press ${pastetext}',
63
+ legendEdge: 'Press ${pastetext}, followed by ${paste}',
64
+ },
65
+ ],
66
+ },
67
+ ],
68
+ tab: 'Phím Tab',
69
+ pause: 'Phím Pause',
70
+ capslock: 'Phím Caps Lock',
71
+ escape: 'Phím Escape',
72
+ pageUp: 'Phím Page Up',
73
+ pageDown: 'Phím Page Down',
74
+ leftArrow: 'Phím Left Arrow',
75
+ upArrow: 'Phím Up Arrow',
76
+ rightArrow: 'Phím Right Arrow',
77
+ downArrow: 'Phím Down Arrow',
78
+ insert: 'Chèn',
79
+ leftWindowKey: 'Phím Left Windows',
80
+ rightWindowKey: 'Phím Right Windows ',
81
+ selectKey: 'Chọn phím',
82
+ numpad0: 'Phím 0',
83
+ numpad1: 'Phím 1',
84
+ numpad2: 'Phím 2',
85
+ numpad3: 'Phím 3',
86
+ numpad4: 'Phím 4',
87
+ numpad5: 'Phím 5',
88
+ numpad6: 'Phím 6',
89
+ numpad7: 'Phím 7',
90
+ numpad8: 'Phím 8',
91
+ numpad9: 'Phím 9',
92
+ multiply: 'Nhân',
93
+ add: 'Thêm',
94
+ subtract: 'Trừ',
95
+ decimalPoint: 'Điểm số thập phân',
96
+ divide: 'Chia',
97
+ f1: 'F1',
98
+ f2: 'F2',
99
+ f3: 'F3',
100
+ f4: 'F4',
101
+ f5: 'F5',
102
+ f6: 'F6',
103
+ f7: 'F7',
104
+ f8: 'F8',
105
+ f9: 'F9',
106
+ f10: 'F10',
107
+ f11: 'F11',
108
+ f12: 'F12',
109
+ numLock: 'Num Lock',
110
+ scrollLock: 'Scroll Lock',
111
+ semiColon: 'Dấu chấm phẩy',
112
+ equalSign: 'Đăng nhập bằng',
113
+ comma: 'Dấu phẩy',
114
+ dash: 'Dấu gạch ngang',
115
+ period: 'Phím .',
116
+ forwardSlash: 'Phím /',
117
+ graveAccent: 'Phím `',
118
+ openBracket: 'Open Bracket',
119
+ backSlash: 'Dấu gạch chéo ngược',
120
+ closeBracket: 'Gần giá đỡ',
121
+ singleQuote: 'Trích dẫn',
122
+ });
@@ -0,0 +1,241 @@
1
+ /* global ActiveXObject */
2
+ /**
3
+ * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
4
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
5
+ */
6
+
7
+ /**
8
+ * @fileOverview Defines the {@link CKEDITOR.ajax} object, which stores Ajax methods for
9
+ * data loading.
10
+ */
11
+
12
+ ( function() {
13
+ CKEDITOR.plugins.add( 'ajax', {
14
+ requires: 'xml'
15
+ } );
16
+
17
+ /**
18
+ * Ajax methods for data loading.
19
+ *
20
+ * @class
21
+ * @singleton
22
+ */
23
+ CKEDITOR.ajax = ( function() {
24
+ function createXMLHttpRequest() {
25
+ // In IE, using the native XMLHttpRequest for local files may throw
26
+ // "Access is Denied" errors.
27
+ if ( !CKEDITOR.env.ie || location.protocol != 'file:' ) {
28
+ try {
29
+ return new XMLHttpRequest();
30
+ } catch ( e ) {
31
+ }
32
+ }
33
+
34
+ try {
35
+ return new ActiveXObject( 'Msxml2.XMLHTTP' );
36
+ } catch ( e ) {}
37
+ try {
38
+ return new ActiveXObject( 'Microsoft.XMLHTTP' );
39
+ } catch ( e ) {}
40
+
41
+ return null;
42
+ }
43
+
44
+ function checkStatus( xhr ) {
45
+ // HTTP Status Codes:
46
+ // 2xx : Success
47
+ // 304 : Not Modified
48
+ // 0 : Returned when running locally (file://)
49
+ // 1223 : IE may change 204 to 1223 (see http://dev.jquery.com/ticket/1450)
50
+
51
+ return ( xhr.readyState == 4 && ( ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status === 0 || xhr.status == 1223 ) );
52
+ }
53
+
54
+ function getResponse( xhr, type ) {
55
+ if ( !checkStatus( xhr ) ) {
56
+ return null;
57
+ }
58
+
59
+ switch ( type ) {
60
+ case 'text':
61
+ return xhr.responseText;
62
+ case 'xml':
63
+ var xml = xhr.responseXML;
64
+ return new CKEDITOR.xml( xml && xml.firstChild ? xml : xhr.responseText );
65
+ case 'arraybuffer':
66
+ return xhr.response;
67
+ default:
68
+ return null;
69
+ }
70
+ }
71
+
72
+ function load( url, callback, responseType ) {
73
+ var async = !!callback;
74
+
75
+ var xhr = createXMLHttpRequest();
76
+
77
+ if ( !xhr )
78
+ return null;
79
+
80
+ if ( async && responseType !== 'text' && responseType !== 'xml' ) {
81
+ xhr.responseType = responseType;
82
+ }
83
+
84
+ xhr.open( 'GET', url, async );
85
+
86
+ if ( async ) {
87
+ // TODO: perform leak checks on this closure.
88
+ xhr.onreadystatechange = function() {
89
+ if ( xhr.readyState == 4 ) {
90
+ callback( getResponse( xhr, responseType ) );
91
+ xhr = null;
92
+ }
93
+ };
94
+ }
95
+
96
+ xhr.send( null );
97
+
98
+ return async ? '' : getResponse( xhr, responseType );
99
+ }
100
+
101
+ function post( url, data, contentType, callback, responseType ) {
102
+ var xhr = createXMLHttpRequest();
103
+
104
+ if ( !xhr )
105
+ return null;
106
+
107
+ xhr.open( 'POST', url, true );
108
+
109
+ xhr.onreadystatechange = function() {
110
+ if ( xhr.readyState == 4 ) {
111
+ if ( callback ) {
112
+ callback( getResponse( xhr, responseType ) );
113
+ }
114
+ xhr = null;
115
+ }
116
+ };
117
+
118
+ xhr.setRequestHeader( 'Content-type', contentType || 'application/x-www-form-urlencoded; charset=UTF-8' );
119
+
120
+ xhr.send( data );
121
+ }
122
+
123
+ return {
124
+ /**
125
+ * Loads data from a given URL.
126
+ *
127
+ * // Load data synchronously.
128
+ * var data = CKEDITOR.ajax.load( 'somedata.txt' );
129
+ * alert( data );
130
+ *
131
+ * // Load data asynchronously.
132
+ * var data = CKEDITOR.ajax.load( 'somedata.txt', function( data ) {
133
+ * alert( data );
134
+ * } );
135
+ *
136
+ * @param {String} url The URL from which the data is loaded.
137
+ * @param {Function} [callback] A callback function to be called on
138
+ * data load. If not provided, the data will be loaded synchronously.
139
+ * @param {String} [responseType='text'] Defines type of returned data.
140
+ * Currently supports: `text`, `xml`, `arraybuffer`. This parameter was introduced in `4.16.0`.
141
+ * @returns {String/null} The loaded data for synchronous request. For asynchronous requests -
142
+ * empty string. For invalid requests - `null`.
143
+ */
144
+ load: function( url, callback, responseType ) {
145
+ responseType = responseType || 'text';
146
+
147
+ return load( url, callback, responseType );
148
+ },
149
+
150
+ /**
151
+ * Creates an asynchronous POST `XMLHttpRequest` of the given `url`, `data` and optional `contentType`.
152
+ * Once the request is done, regardless if it is successful or not, the `callback` is called
153
+ * with `XMLHttpRequest#responseText` or `null` as an argument.
154
+ *
155
+ * CKEDITOR.ajax.post( 'url/post.php', 'foo=bar', null, function( data ) {
156
+ * console.log( data );
157
+ * } );
158
+ *
159
+ * CKEDITOR.ajax.post( 'url/post.php', JSON.stringify( { foo: 'bar' } ), 'application/json', function( data ) {
160
+ * console.log( data );
161
+ * } );
162
+ *
163
+ * @since 4.4
164
+ * @param {String} url The URL of the request.
165
+ * @param {String/Object/Array} data Data passed to `XMLHttpRequest#send`.
166
+ * @param {String} [contentType='application/x-www-form-urlencoded; charset=UTF-8'] The value of the `Content-type` header.
167
+ * @param {Function} [callback] A callback executed asynchronously with `XMLHttpRequest#responseText` or `null` as an argument,
168
+ * depending on the `status` of the request.
169
+ */
170
+ post: function( url, data, contentType, callback ) {
171
+ return post( url, data, contentType, callback, 'text' );
172
+ },
173
+
174
+ /**
175
+ * Loads data from a given URL as XML.
176
+ *
177
+ * // Load XML synchronously.
178
+ * var xml = CKEDITOR.ajax.loadXml( 'somedata.xml' );
179
+ * alert( xml.getInnerXml( '//' ) );
180
+ *
181
+ * // Load XML asynchronously.
182
+ * var data = CKEDITOR.ajax.loadXml( 'somedata.xml', function( xml ) {
183
+ * alert( xml.getInnerXml( '//' ) );
184
+ * } );
185
+ *
186
+ * @param {String} url The URL from which the data is loaded.
187
+ * @param {Function} [callback] A callback function to be called on
188
+ * data load. If not provided, the data will be loaded synchronously.
189
+ * @returns {CKEDITOR.xml} An XML object storing the loaded data for synchronous
190
+ * request. For asynchronous requests - empty string. For invalid requests - `null`.
191
+ */
192
+ loadXml: function( url, callback ) {
193
+ return load( url, callback, 'xml' );
194
+ },
195
+
196
+ /**
197
+ * Loads data from a given URL as text.
198
+ *
199
+ * // Load text synchronously.
200
+ * var text = CKEDITOR.ajax.loadText( 'somedata.txt' );
201
+ * alert( text );
202
+ *
203
+ * // Load text asynchronously.
204
+ * var data = CKEDITOR.ajax.loadText( 'somedata.txt', function( textData ) {
205
+ * alert( textData );
206
+ * } );
207
+ *
208
+ * @param {String} url The URL from which the data is loaded.
209
+ * @param {Function} [callback] A callback function to be called on
210
+ * data load. If not provided, the data will be loaded synchronously.
211
+ * @returns {String} String storing the loaded data for synchronous
212
+ * request. For asynchronous requests - empty string. For invalid requests - `null`.
213
+ */
214
+ loadText: function( url, callback ) {
215
+ return load( url, callback, 'text' );
216
+ },
217
+
218
+ /**
219
+ * Loads data from a given URL as binary data.
220
+ *
221
+ * // Load data synchronously.
222
+ * var binaryData = CKEDITOR.ajax.loadBinary( 'somedata.png' );
223
+ * alert( binaryData );
224
+ *
225
+ * // Load data asynchronously.
226
+ * var data = CKEDITOR.ajax.loadBinary( 'somedata.png', function( binaryData ) {
227
+ * alert( binaryData );
228
+ * } );
229
+ *
230
+ * @param {String} url The URL from which the data is loaded.
231
+ * @param {Function} [callback] A callback function to be called on
232
+ * data load. If not provided, the data will be loaded synchronously.
233
+ * @returns {ArrayBuffer} ArrayBuffer storing the loaded data for synchronous
234
+ * request. For asynchronous requests - empty string. For invalid requests - `null`.
235
+ */
236
+ loadBinary: function( url, callback ) {
237
+ return load( url, callback, 'arraybuffer' );
238
+ }
239
+ };
240
+ } )();
241
+ } )();