forked from mystiq/hydrogen-web
Rename TextTileFormat to BodyFormat
This commit is contained in:
parent
031ce42831
commit
7cfdd4f663
2 changed files with 8 additions and 8 deletions
|
@ -18,7 +18,7 @@ import {BaseMessageTile} from "./BaseMessageTile.js";
|
||||||
import {stringAsBody} from "../MessageBody.js";
|
import {stringAsBody} from "../MessageBody.js";
|
||||||
import {createEnum} from "../../../../../utils/enum.js";
|
import {createEnum} from "../../../../../utils/enum.js";
|
||||||
|
|
||||||
export const TextTileFormat = createEnum("Plain", "Html");
|
export const BodyFormat = createEnum("Plain", "Html");
|
||||||
|
|
||||||
export class BaseTextTile extends BaseMessageTile {
|
export class BaseTextTile extends BaseMessageTile {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
|
@ -36,7 +36,7 @@ export class BaseTextTile extends BaseMessageTile {
|
||||||
}
|
}
|
||||||
|
|
||||||
_getBodyFormat() {
|
_getBodyFormat() {
|
||||||
return TextTileFormat.Plain;
|
return BodyFormat.Plain;
|
||||||
}
|
}
|
||||||
|
|
||||||
get body() {
|
get body() {
|
||||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {BaseTextTile, TextTileFormat} from "./BaseTextTile.js";
|
import {BaseTextTile, BodyFormat} from "./BaseTextTile.js";
|
||||||
import {parsePlainBody} from "../MessageBody.js";
|
import {parsePlainBody} from "../MessageBody.js";
|
||||||
import {parseHTMLBody} from "../deserialize.js";
|
import {parseHTMLBody} from "../deserialize.js";
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ export class TextTile extends BaseTextTile {
|
||||||
}
|
}
|
||||||
|
|
||||||
_getBody() {
|
_getBody() {
|
||||||
if (this._getBodyFormat() == TextTileFormat.Html) {
|
if (this._getBodyFormat() == BodyFormat.Html) {
|
||||||
return this._getFormattedBody();
|
return this._getFormattedBody();
|
||||||
} else {
|
} else {
|
||||||
return this._getPlainBody();
|
return this._getPlainBody();
|
||||||
|
@ -45,15 +45,15 @@ export class TextTile extends BaseTextTile {
|
||||||
}
|
}
|
||||||
|
|
||||||
_getBodyFormat() {
|
_getBodyFormat() {
|
||||||
if (this._getContent()?.["format"] === "org.matrix.custom.html") {
|
if (this._getContent()?.format === "org.matrix.custom.html") {
|
||||||
return TextTileFormat.Html;
|
return BodyFormat.Html;
|
||||||
} else {
|
} else {
|
||||||
return TextTileFormat.Plain;
|
return BodyFormat.Plain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_parseBody(body, format) {
|
_parseBody(body, format) {
|
||||||
if (format === TextTileFormat.Html) {
|
if (format === BodyFormat.Html) {
|
||||||
return parseHTMLBody(this.platform, this._mediaRepository, body);
|
return parseHTMLBody(this.platform, this._mediaRepository, body);
|
||||||
} else {
|
} else {
|
||||||
return parsePlainBody(body);
|
return parsePlainBody(body);
|
||||||
|
|
Loading…
Reference in a new issue