@codady/coax 0.0.2 → 0.0.4

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 (43) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +331 -166
  3. package/dist/coax.cjs.js +450 -271
  4. package/dist/coax.cjs.min.js +4 -4
  5. package/dist/coax.esm.js +444 -271
  6. package/dist/coax.esm.min.js +4 -4
  7. package/dist/coax.umd.js +466 -266
  8. package/dist/coax.umd.min.js +4 -4
  9. package/examples/.htaccess +0 -0
  10. package/examples/append-highlight.html +82 -0
  11. package/examples/color-selector.html +412 -0
  12. package/examples/deepseek-highlight.html +100 -0
  13. package/examples/js-highlight.html +1 -1
  14. package/examples/md-highlight.html +60 -0
  15. package/examples/nginx.htaccess +0 -0
  16. package/examples/replace-highlight.html +69 -0
  17. package/examples/stream-highlight.html +64 -0
  18. package/examples/theme-highlight.html +69 -0
  19. package/package.json +4 -4
  20. package/rollup.config.js +3 -3
  21. package/script-note.js +2 -2
  22. package/src/Coax.js +25 -414
  23. package/src/Coax.ts +28 -443
  24. package/src/components/Coax.js +528 -0
  25. package/src/components/Coax.ts +556 -0
  26. package/src/modules.js +12 -0
  27. package/src/modules.ts +23 -0
  28. package/src/rules/css.js +11 -0
  29. package/src/rules/css.ts +11 -0
  30. package/src/rules/html.js +13 -0
  31. package/src/rules/html.ts +13 -0
  32. package/src/rules/javascript.js +10 -0
  33. package/src/rules/javascript.ts +10 -0
  34. package/src/rules/markdown.js +29 -0
  35. package/src/rules/markdown.ts +41 -0
  36. package/src/rules/ruleCss - /345/211/257/346/234/254.js" +10 -0
  37. package/src/rules/ruleHTML - /345/211/257/346/234/254.js" +12 -0
  38. package/src/rules/ruleJs - /345/211/257/346/234/254.js" +10 -0
  39. package/src/rules/ruleTs - /345/211/257/346/234/254.js" +12 -0
  40. package/src/rules/typescript.js +12 -0
  41. package/src/rules/typescript.ts +12 -0
  42. package/src/tools/copy.js +26 -0
  43. package/src/tools/copy.ts +29 -0
@@ -0,0 +1,528 @@
1
+ /**
2
+ * Last modified: 2026/01/12 14:09:42
3
+ * Coax - A custom web component for syntax highlighting, code display, and interactive features
4
+ *
5
+ */
6
+ import typeWriter from "@codady/utils/typeWriter";
7
+ import parseClasses from "@codady/utils/parseClasses";
8
+ import NAMESPACE from "@codady/utils/namespace";
9
+ import getEl from "@codady/utils/getEl";
10
+ import createTools from "@codady/utils/createTools";
11
+ import createEl from "@codady/utils/createEl";
12
+ class Coax extends HTMLElement {
13
+ // A static Map to hold the configuration for different languages
14
+ static languages = new Map();
15
+ // A static array to hold the tools registered with the component
16
+ static tools = [];
17
+ source; // Source code content to be highlighted
18
+ _renderQueued = false; // Flag to prevent multiple render requests
19
+ baseStylesEl; // Element for base styles
20
+ themeStylesEl; // Element for theme styles
21
+ dynamicStylesEl; // Element for dynamic styles
22
+ highlightedCodeEl; // Element that holds the highlighted code
23
+ headerEl; // Header element (for code name, tools, etc.)
24
+ codeNameEl; // Code name element (shows language or alias)
25
+ codeToolsEl; // Code tools element (for interactive tools like copy)
26
+ codeBodyEl; // Code body element (the container for the code)
27
+ lang = 'plain'; // Language of the code (default is plain text)
28
+ alias = 'Plain Text'; // Alias name for the language (default is 'Plain Text')
29
+ lineString = ''; // The current line's string being typed
30
+ lastLineString = ''; // The last line's string
31
+ speed = 5; // Speed of the typing effect (higher is slower)
32
+ autoScroll = true; // Flag to enable/disable auto-scrolling
33
+ constructor() {
34
+ super();
35
+ // Attach a Shadow DOM to the custom element
36
+ this.attachShadow({ mode: 'open' });
37
+ // Remove leading/trailing whitespace from the raw code content
38
+ this.source = this.textContent?.replace(/^\s*\n|\n\s*$/g, '') || '';
39
+ // Initialize the basic structure of the component
40
+ this.shadowRoot.innerHTML = `
41
+ <style id="base-styles">
42
+ :host {
43
+ --border-width:1px;
44
+ --border-style:solid;
45
+ --radius:9px;
46
+ --height:auto;
47
+ --max-height:500px;
48
+ --radius:9px;
49
+ --padding:1em;
50
+ --font-size:16px;
51
+ --line-height:1.8;
52
+ --background:rgb(247, 247, 247);
53
+ --border-color:rgb(224, 224, 224);
54
+ --color-code:rgb(51, 51, 51);
55
+ --color-index:rgb(153, 153, 153);
56
+ --color-stripe:rgba(0,0,0,0.04);
57
+ --color-hover:rgba(0,0,0,0.06);
58
+ }
59
+ :host([scheme="dark"]){
60
+ --background: #282c34;
61
+ --border-color: transparent;
62
+ --color-code: #abb2bf;
63
+ --color-index:rgb(153, 153, 153);
64
+ --color-stripe:rgba(255,255,255,0.04);
65
+ --color-hover:rgba(255,255,255,0.06);
66
+ }
67
+ @media (prefers-color-scheme: dark) {
68
+ :host{
69
+ --background: #282c34;
70
+ --border-color: transparent;
71
+ --color-code: #abb2bf;
72
+ --color-index:rgb(153, 153, 153);
73
+ --color-stripe:rgba(255,255,255,0.04);
74
+ --color-hover:rgba(255,255,255,0.06);
75
+ }
76
+ }
77
+ :host {
78
+ font-size: var(--${NAMESPACE}-code-font-size,var(--font-size));
79
+ display: block;
80
+ box-sizing:border-box;
81
+ background:var(--${NAMESPACE}-code-background-color,var(--background));
82
+ color:var(--${NAMESPACE}-code-color,var(--color-code));
83
+ border:var(--${NAMESPACE}-code-border-width,var(--border-width)) var(--${NAMESPACE}-code-border-style,var(--border-style)) var(--${NAMESPACE}-code-border-color,var(--border-color));
84
+ transition: border-color 0.3s ease,color 0.3s ease;
85
+ border-radius: var(--${NAMESPACE}-code-radius,var(--radius));
86
+ }
87
+ #code-header{
88
+ line-height:calc(var(--${NAMESPACE}-code-line-height,var(--line-height))*1.5);
89
+ padding-inline-start:var(--${NAMESPACE}-code-padding,var(--padding));
90
+ display:flex;
91
+
92
+ >:first-child{
93
+ flex:auto;
94
+ }
95
+ }
96
+ #code-body{
97
+ padding: var(--${NAMESPACE}-code-padding,var(--padding)) 0;
98
+ height:var(--${NAMESPACE}-code-height,var(--height));
99
+ max-height:var(--${NAMESPACE}-code-max-height,var(--max-height));
100
+ overflow:auto;
101
+ }
102
+ pre,code{
103
+ font-family:"Consolas", "Monaco", "Andale Mono", "Ubuntu Mono", "monospace";
104
+ margin:0; padding:0;
105
+ }
106
+ code>div{
107
+ display:flex;
108
+ padding:0 var(--${NAMESPACE}-code-padding,var(--padding));
109
+ line-height: var(--${NAMESPACE}-code-line-height,var(--line-height));
110
+ box-sizing:border-box;
111
+
112
+ >div{
113
+ flex:auto;
114
+ }
115
+ }
116
+ code>div>div:empty:before{
117
+ content:' ';
118
+ }
119
+ :host([indexed]) code>div:before{
120
+ display:inline-flex;
121
+ color:var(--color-index);
122
+ content: attr(data-index);
123
+ min-width:var(--${NAMESPACE}-code-index-width,2em);
124
+ margin-inline-end:var(--${NAMESPACE}-code-padding,8px);
125
+ }
126
+ :host([striped]) code>div:nth-child(odd){
127
+ background-color:var(--color-stripe);
128
+ }
129
+ :host([hoverable]) code>div:hover{
130
+ background-color:var(--color-hover);
131
+ }
132
+ :host([wrapped]) code>div>div{
133
+ white-space: pre-wrap;
134
+ }
135
+ :host([unnamed]) #code-name{
136
+ display:none;
137
+ }
138
+ .${NAMESPACE}-box-tools{
139
+ >*{
140
+ font-size:14px;
141
+ display:inline-flex;
142
+ align-items:center;
143
+ justify-content:center;
144
+ height:2em;
145
+ line-height:2em;
146
+ aspect-ratio:1/1;
147
+ margin-inline-end:8px;
148
+ transition:all 200ms ease;
149
+ border-radius:6px;
150
+ &:hover{
151
+ cursor:pointer;
152
+ background-color:rgba(0,0,0,.04);
153
+ }
154
+ }
155
+ [rep=icon]{
156
+ display:inline-flex;
157
+ align-items:center;
158
+ justify-content:center;
159
+ }
160
+ }
161
+ [disabled]{
162
+ pointer-event:none;
163
+ }
164
+ </style>
165
+ <style id="dynamic-styles"></style>
166
+ <style id="theme-styles"></style>
167
+ <div id="code-header"><span id="code-name">${this.alias}</span><div id="code-tools"></div></div>
168
+ <div id="code-body">
169
+ <pre><code id="highlight-code"></code></pre>
170
+ </div>
171
+ `;
172
+ // Cache references to various elements
173
+ this.baseStylesEl = getEl('#base-styles', this.shadowRoot);
174
+ this.themeStylesEl = getEl('#theme-styles', this.shadowRoot);
175
+ this.dynamicStylesEl = getEl('#dynamic-styles', this.shadowRoot);
176
+ this.headerEl = getEl('#code-header', this.shadowRoot);
177
+ this.codeNameEl = getEl('#code-name', this.shadowRoot);
178
+ this.codeToolsEl = getEl('#code-tools', this.shadowRoot);
179
+ this.codeBodyEl = getEl('#code-body', this.shadowRoot);
180
+ this.highlightedCodeEl = getEl('#highlight-code', this.shadowRoot);
181
+ this.codeBodyEl.addEventListener('scroll', () => {
182
+ let flag = this.codeBodyEl.scrollTop + this.codeBodyEl.clientHeight < this.codeBodyEl.scrollHeight;
183
+ // Check if the user manually scrolled
184
+ this.autoScroll = !flag;
185
+ });
186
+ }
187
+ /**
188
+ * Registers a new language with a set of syntax highlighting rules.
189
+ * @param name - The name of the programming language (e.g., 'javascript', 'html', etc.)
190
+ * @param config - Configuration for the language, including rules, theme, and optional CSS.
191
+ */
192
+ static register(name, config) {
193
+ // Store the language configuration in the static map
194
+ this.languages.set(name, { ...config });
195
+ }
196
+ /**
197
+ * Registers tools that can be used with the code editor (e.g., copy, download, etc.).
198
+ * @param items - An array of tool items to register.
199
+ */
200
+ static addTools(items) {
201
+ Coax.tools = items;
202
+ }
203
+ /**
204
+ * Mounts the tools to the code tools container.
205
+ * @param toolItems - An array of tool items to be added to the tools container.
206
+ */
207
+ mountTools(toolItems) {
208
+ requestAnimationFrame(() => {
209
+ this.codeToolsEl.innerHTML = '';
210
+ let items = toolItems.map(k => {
211
+ k.action = k.action.bind(this);
212
+ return k;
213
+ });
214
+ this.codeToolsEl.appendChild(createTools(items));
215
+ });
216
+ }
217
+ /**
218
+ * Called when the element is connected to the DOM.
219
+ */
220
+ connectedCallback() {
221
+ this.render();
222
+ }
223
+ /**
224
+ * Observed attributes for changes. These include the language, height, tools, and speed.
225
+ */
226
+ static get observedAttributes() { return ['lang', 'height', 'max-height', 'tools', 'speed']; }
227
+ /**
228
+ * Called when any of the observed attributes change.
229
+ * @param name - The name of the changed attribute.
230
+ * @param oldVal - The old value of the attribute.
231
+ * @param newVal - The new value of the attribute.
232
+ */
233
+ attributeChangedCallback(name, oldVal, newVal) {
234
+ if (oldVal === newVal)
235
+ return;
236
+ if (name === 'height' || name === 'max-height') {
237
+ this.updateStyleByRegExp(name, newVal);
238
+ }
239
+ if (name === 'speed') {
240
+ // Convert to integer (0 or 1)
241
+ this.speed = ~~(!!newVal);
242
+ }
243
+ if (name === 'lang') {
244
+ // Update the language and re-render
245
+ this.lang = newVal;
246
+ this.render();
247
+ }
248
+ if (name === 'tools') {
249
+ if (!newVal)
250
+ this.codeToolsEl.innerHTML = '';
251
+ const tools = parseClasses(newVal), toolItems = Coax.tools.filter(k => tools.includes(k.name));
252
+ if (!toolItems.length)
253
+ return;
254
+ this.mountTools(toolItems);
255
+ }
256
+ }
257
+ /**
258
+ * Updates the base style by replacing specific CSS properties using a regular expression.
259
+ * @param prop - The CSS property name to update (e.g., 'height', 'max-height').
260
+ * @param value - The new value for the property.
261
+ */
262
+ updateStyleByRegExp(prop, value) {
263
+ // 构建正则:匹配属性名后面跟着冒号,直到分号或换行
264
+ // 例如:height:\s*[^;]+;
265
+ const regex = new RegExp(`;\\n\\s*${prop}:\\s*[^;]+;`, 'g');
266
+ // 替换为新的属性值
267
+ this.baseStylesEl.textContent = this.baseStylesEl.textContent.replace(regex, `;\n${prop}: ${value};`);
268
+ }
269
+ /**
270
+ * Retrieves the CSS prefix for the language configuration.
271
+ * @param config - The language configuration object.
272
+ * @returns The CSS prefix.
273
+ */
274
+ getCssPrefix(config) {
275
+ return (config?.cssPrefix || this.lang).replace(/[^a-zA-Z0-9_-]/g, '\\$&');
276
+ }
277
+ /**
278
+ * Highlights a given string according to the language configuration.
279
+ * @param string - The string to highlight.
280
+ * @param config - The language configuration object.
281
+ * @returns The highlighted string with HTML spans.
282
+ */
283
+ getHighLightString(string, config) {
284
+ config = config || Coax.languages.get(this.lang);
285
+ if (!config)
286
+ return string;
287
+ // 如果找到了配置,则进行高亮处理
288
+ const cssPrefix = this.getCssPrefix(config),
289
+ // 获取用于语法高亮的正则表达式
290
+ combinedRegex = new RegExp(config.rules.map((r) => `(${r.pattern.source})`).join('|'), 'g');
291
+ return string.replace(combinedRegex, (match, ...args) => {
292
+ const i = args.findIndex(val => val !== undefined);
293
+ return i !== -1 && config.rules[i] ? `<span class="${NAMESPACE}-${cssPrefix}-${config.rules[i].token}">${match}</span>` : match;
294
+ });
295
+ }
296
+ /**
297
+ * Creates a wrapper element for a line of code.
298
+ * @param index - The line index to assign.
299
+ * @param startIndex - The starting index for the line.
300
+ * @returns A div element wrapping the line of code.
301
+ */
302
+ createLineWrap(index, startIndex) {
303
+ let dataIndex = 0;
304
+ if (index == null && startIndex == null) {
305
+ dataIndex = this.highlightedCodeEl.children.length;
306
+ }
307
+ else {
308
+ const start = startIndex || this.highlightedCodeEl.children.length;
309
+ dataIndex = start + index;
310
+ }
311
+ return createEl('div', { 'data-index': dataIndex }, '<div></div>');
312
+ }
313
+ /**
314
+ * Fills a line of code with highlighted content.
315
+ * @param codeWrap - The element that will contain the highlighted line of code.
316
+ * @param line - The line of code to highlight.
317
+ * @param config - The language configuration object.
318
+ */
319
+ getLineToFill(codeWrap, line, config) {
320
+ config = config || Coax.languages.get(this.lang);
321
+ let highlightedLine = this.getHighLightString(line, config);
322
+ // 将高亮后的内容填充到 div 中
323
+ codeWrap.innerHTML = highlightedLine;
324
+ }
325
+ ;
326
+ /**
327
+ * Highlights new source code and appends it to the code body.
328
+ * @param newCode - The new source code to highlight and append.
329
+ */
330
+ async highlight(newCode) {
331
+ const config = Coax.languages.get(this.lang), startIndex = this.highlightedCodeEl.children.length,
332
+ // 将新源码按行分割
333
+ newCodeLines = newCode ? newCode.split('\n') : [];
334
+ //更新别名
335
+ this.updateName(config);
336
+ if (!newCodeLines.length)
337
+ return true;
338
+ // 如果没有找到配置,则输出原始代码,并不进行高亮处理
339
+ for (let [index, lineString] of newCodeLines.entries()) {
340
+ //如果是空行则跳过
341
+ if (!lineString.trim() && this.hasAttribute('sanitized'))
342
+ continue;
343
+ // 创建一个 div 包裹每一行
344
+ const lineWrap = this.createLineWrap(index, startIndex), codeWrap = lineWrap.lastElementChild;
345
+ //标记完成
346
+ lineWrap.completed = true;
347
+ if (this.hasAttribute('speed')) {
348
+ this.highlightedCodeEl.appendChild(lineWrap);
349
+ //流式打字
350
+ await typeWriter(lineString, {
351
+ speed: this.speed,
352
+ onDuringType: (char, fullText) => {
353
+ codeWrap.innerHTML = fullText;
354
+ }
355
+ });
356
+ this.getLineToFill(codeWrap, lineString, config);
357
+ }
358
+ else {
359
+ //直接打出
360
+ this.getLineToFill(codeWrap, lineString, config);
361
+ //
362
+ this.highlightedCodeEl.appendChild(lineWrap);
363
+ }
364
+ }
365
+ //滚动到最底部
366
+ this.autoScrollCode();
367
+ return true;
368
+ }
369
+ /**
370
+ * Automatically scrolls the code body to the bottom.
371
+ */
372
+ autoScrollCode() {
373
+ if (this.autoScroll) {
374
+ this.codeBodyEl.scrollTop = this.codeBodyEl.scrollHeight;
375
+ }
376
+ }
377
+ /**
378
+ * Injects the theme styles for syntax highlighting (light/dark modes).
379
+ */
380
+ injectThemeStyles() {
381
+ const config = Coax.languages.get(this.lang);
382
+ if (!config)
383
+ return;
384
+ // Get language name, fallback to 'js' if not provided
385
+ let cssPrefix = this.getCssPrefix(config),
386
+ //Generate dynamic CSS classes for each syntax rule
387
+ // 为 rules 中的每一个 name 生成类似 .hl-name { color: var(--ax-code-name); }
388
+ lightStyles = config.rules.map((rule) => `
389
+ .${NAMESPACE}-${cssPrefix}-${rule.token} { color: var(--${NAMESPACE}-${cssPrefix}-${rule.token}${rule.light ? ',' + rule.light : ''});}`).join('\n'), darkStyles = '', schemeStyles = '';
390
+ darkStyles += `:host([scheme="dark"]){`;
391
+ darkStyles += config.rules.map((rule) => `
392
+ ${rule.light ? `
393
+ .${NAMESPACE}-${cssPrefix}-${rule.token} {color: var(--${NAMESPACE}-${cssPrefix}-${rule.token},${rule.dark});}` : ``}`).join('\n');
394
+ darkStyles += `}`;
395
+ schemeStyles = `@media (prefers-color-scheme: dark){
396
+ :host{
397
+ `;
398
+ schemeStyles += config.rules.map((rule) => `
399
+ ${rule.light ? `
400
+ .${NAMESPACE}-${cssPrefix}-${rule.token} { color: var(--${NAMESPACE}-${cssPrefix}-${rule.token},${rule.dark}); }` : ``} `).join('\n');
401
+ schemeStyles += `}`;
402
+ // Set the inner HTML of the shadow root, including styles and highlighted code
403
+ this.dynamicStylesEl.textContent = lightStyles + darkStyles + schemeStyles;
404
+ //附加主题样式
405
+ if (config?.themeStyles) {
406
+ this.themeStylesEl.textContent = config.themeStyles;
407
+ }
408
+ }
409
+ /**
410
+ * Updates the alias name for the language based on the configuration.
411
+ * @param config - The language configuration object.
412
+ */
413
+ updateName(config) {
414
+ if (this.hasAttribute('unnamed'))
415
+ return;
416
+ if (!config) {
417
+ this.codeNameEl.innerHTML = 'Plain Text';
418
+ }
419
+ else {
420
+ //更新别名
421
+ this.alias = config.alias || this.lang;
422
+ this.codeNameEl.innerHTML = this.alias;
423
+ }
424
+ }
425
+ /**
426
+ * Renders the highlighted code within the shadow DOM.
427
+ */
428
+ render(code = this.source) {
429
+ //同时多次改变属性,只执行一次
430
+ if (this._renderQueued)
431
+ return;
432
+ this._renderQueued = true;
433
+ // 使用 requestAnimationFrame 将渲染推迟到下一帧
434
+ requestAnimationFrame(async () => {
435
+ this.clear();
436
+ this.injectThemeStyles();
437
+ //一次性渲染
438
+ await this.highlight(code);
439
+ this._renderQueued = false;
440
+ });
441
+ }
442
+ /**
443
+ * Clears the current content and resets the state.
444
+ */
445
+ clear() {
446
+ this.highlightedCodeEl.innerHTML = this.source = this.lineString = '';
447
+ }
448
+ /**
449
+ * Replaces the existing code with new source code and re-renders.
450
+ * @param newCode - The new source code to replace the existing code.
451
+ */
452
+ async replace(newCode) {
453
+ this.clear();
454
+ await this.highlight(newCode);
455
+ }
456
+ /**
457
+ * Appends new source code to the current content and highlights only the new portion.
458
+ * @param newCode - The new source code to append and highlight.
459
+ */
460
+ async append(newCode) {
461
+ // 将新的代码追加到现有代码末尾
462
+ this.source += `\n${newCode}`;
463
+ // 高亮新的部分
464
+ await this.highlight(newCode);
465
+ }
466
+ /**
467
+ * Retrieves the last line of code that was rendered.
468
+ * @returns An object containing the line wrapper and code wrapper for the last line.
469
+ */
470
+ getLastLine() {
471
+ const lastChild = this.highlightedCodeEl.lastElementChild, lastLine = !lastChild || this.highlightedCodeEl.lastElementChild?.completed ?
472
+ this.createLineWrap() : lastChild;
473
+ return {
474
+ lineWrap: lastLine,
475
+ codeWrap: lastLine.lastElementChild
476
+ };
477
+ }
478
+ /**
479
+ * Marks the current line as completed and updates the displayed code.
480
+ */
481
+ close() {
482
+ const lineWrap = this.highlightedCodeEl.lastElementChild;
483
+ if (!lineWrap)
484
+ return;
485
+ lineWrap.completed = true;
486
+ //行结束前保存
487
+ this.lastLineString = this.lineString;
488
+ this.getLineToFill(lineWrap?.lastElementChild, this.lineString);
489
+ //一行结束,清空临时行文本
490
+ this.lineString = '';
491
+ }
492
+ /**
493
+ * Reopens the last closed line and restores its original content.
494
+ */
495
+ open() {
496
+ const lineWrap = this.highlightedCodeEl.lastElementChild;
497
+ if (!lineWrap)
498
+ return;
499
+ lineWrap.completed = false;
500
+ //恢复最后一行字符串
501
+ (lineWrap?.lastElementChild).textContent = this.lineString = this.lastLineString;
502
+ }
503
+ /**
504
+ * Streams a string of code into the component, either appending or closing the current line.
505
+ * @param str - The code string to stream into the component.
506
+ * @param forceClose - Forcefully close the line if set to `true`.
507
+ */
508
+ stream(str, forceClose = false) {
509
+ const { lineWrap, codeWrap } = this.getLastLine();
510
+ this.highlightedCodeEl.appendChild(lineWrap);
511
+ //汇集
512
+ this.source += str;
513
+ //如果没有遇到换行符号,也可以强制结束
514
+ if (forceClose || (str.startsWith('\n') || str.endsWith('\n'))) {
515
+ //标记完成
516
+ this.close();
517
+ }
518
+ else {
519
+ //插入文本
520
+ codeWrap.innerHTML += str;
521
+ //临时保存行文本
522
+ this.lineString += str;
523
+ }
524
+ //滚动到最底部
525
+ this.autoScrollCode();
526
+ }
527
+ }
528
+ export default Coax;