Skip to content

Commit df48a36

Browse files
committed
feat(text-editor tables): set enableTables true if contentType is html
1 parent 68c3fcf commit df48a36

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/components/text-editor/examples/text-editor-with-tables.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Component, h, State } from '@stencil/core';
1414
export class TextEditorWithTablesExample {
1515
@State()
1616
private value: string =
17-
'<table><tbody><tr><td style="background-color: rgb(25, 107, 36);color: white;"><p><strong>Column1</strong></p></td><td style="background-color: rgb(25, 107, 36);color: white;"><p><strong>Column2</strong></p></td></tr><tr><td style="background-color: rgb(193, 240, 200);color: black;"><p>Cell A1</p></td><td style="background-color: rgb(193, 240, 200);color: black;"><p>Cell B1</p></td></tr><tr><td style="color: black;"><p>Cell A2</p></td><td style="background-color: yellow;color: red;"><p>Cell B2</p></td></tr></tbody></table>';
17+
'<table><tbody><tr><td style="background-color: rgb(25, 107, 36);color: white;"><p><strong>Column1</strong></p></td><td style="background-color: rgb(25, 107, 36);color: white;"><p><strong>Column2</strong></p></td></tr><tr><td style="background-color: rgb(193, 240, 200);color: black;"><p>Cell A1</p></td><td style="background-color: rgb(193, 240, 200);color: black;"><p>Cell B1</p></td></tr><tr><td style="color: green;"><p>Cell A2</p></td><td style="background-color: yellow;color: red;"><p>Cell B2</p></td></tr></tbody></table>';
1818

1919
@State()
2020
private readonly = false;

src/components/text-editor/text-editor.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,17 @@ export class TextEditor implements FormComponent<string> {
253253
aria-disabled={this.disabled}
254254
language={this.language}
255255
triggerCharacters={this.triggers}
256-
supportTables={this.enableTables}
256+
supportTables={this.checkForTables()}
257257
/>,
258258
this.renderPlaceholder(),
259259
this.renderHelperLine(),
260260
];
261261
}
262262

263+
private checkForTables() {
264+
return this.enableTables && this.contentType === 'html';
265+
}
266+
263267
private renderLabel() {
264268
if (!this.label) {
265269
return;

0 commit comments

Comments
 (0)