summaryrefslogtreecommitdiff
path: root/dist/classes/MessageFormattingRule.js
diff options
context:
space:
mode:
Diffstat (limited to 'dist/classes/MessageFormattingRule.js')
-rw-r--r--dist/classes/MessageFormattingRule.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/dist/classes/MessageFormattingRule.js b/dist/classes/MessageFormattingRule.js
index 729a5d9..a7b7806 100644
--- a/dist/classes/MessageFormattingRule.js
+++ b/dist/classes/MessageFormattingRule.js
@@ -1,7 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MessageFormattingRule = void 0;
+/**
+ * A rule used to apply formatting styles to a message
+ */
class MessageFormattingRule {
+ /**
+ * @param data - Data to reconstruct the formatting rule
+ * @param text - Non-formatted message text
+ * @internal
+ */
constructor(data, text) {
this.styling = data.style;
this.start = data.start;
@@ -9,6 +17,12 @@ class MessageFormattingRule {
this.end = data.start + data.length;
this.extract = text?.substring(this.start, this.end);
}
+ /**
+ * Build a formatting rule
+ * @param style - The style to apply
+ * @param start - The start position
+ * @param length - The length of the rule
+ */
static build(style, start, length) {
return new MessageFormattingRule({
style,
@@ -16,6 +30,9 @@ class MessageFormattingRule {
length
});
}
+ /**
+ * Convert the formatting rule to a format that can be passed to signal-cli
+ */
toCLIFormat() {
return this.start + ":" + this.length + ":" + this.styling;
}