Better quote style support

This commit is contained in:
Bryan Ashby 2020-12-27 00:08:45 -07:00
parent 94d4a52530
commit 4533dc3e01
No known key found for this signature in database
GPG Key ID: B49EB437951D2542
3 changed files with 11 additions and 10 deletions

View File

@ -18,7 +18,7 @@ This document attempts to track **major** changes and additions in ENiGMA½. For
* Default hash tags can now be set in file areas. Simply supply an array or list of values in a file area block via `hashTags`.
* Added ability to pass an `env` value (map) to `abracadabra` doors. See [Local Doors](./docs/modding/local-doors.md]).
* `dropFileType` is now optional when launching doors with `abracadabra`. It can also be explicitly set to `none`.
* FSE in *view* mode can now stylize quote indicators. Supply `quoteStyleLevel1` in the `config` block. This can be a single string or an array of two strings (one to style the quotee's initials and the next for the '>' character). See the `messageAreaViewPost` menu `config` block in the default `luciano_blocktronics` `theme.hjson` file for an example. An additional level style (e.g. for nested quotes) may be added in the future.
* FSE in *view* mode can now stylize quote indicators. Supply `quoteStyleLevel1` in the `config` block. This can be a single string or an array of two strings (one to style the quotee's initials, the next for the '>' character, and finally the quoted text). See the `messageAreaViewPost` menu `config` block in the default `luciano_blocktronics` `theme.hjson` file for an example. An additional level style (e.g. for nested quotes) may be added in the future.
## 0.0.11-beta
* Upgraded from `alpha` to `beta` -- The software is far along and mature enough at this point!

View File

@ -542,6 +542,7 @@
quoteStyleLevel1: [
"|00|11",
"|00|08",
"|00|03",
]
}

View File

@ -444,19 +444,19 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
// - Origins
//
if (this.menuConfig.config.quoteStyleLevel1) {
let quoteStyleLevel1 = this.menuConfig.config.quoteStyleLevel1;
// can be a single style to cover XX> or an array to cover XX and >
if (!Array.isArray(quoteStyleLevel1)) {
quoteStyleLevel1 = [ quoteStyleLevel1 ];
let styleL1 = this.menuConfig.config.quoteStyleLevel1;
// can be a single style to cover 'XX> TEXT' or an array to cover 'XX', '>', and TEXT
if (!Array.isArray(styleL1)) {
styleL1 = [ styleL1 ];
}
if (quoteStyleLevel1.length < 2) {
quoteStyleLevel1.push(quoteStyleLevel1);
while (styleL1.length < 3) {
styleL1.push(styleL1);
}
const QuoteRegex = /^ ([A-Za-z0-9]{1,2})>([ ]+)/gm;
msg = msg.replace(QuoteRegex, (m, initials, spc) => {
const QuoteRegex = /^ ([A-Za-z0-9]{1,2})>([ ]+)([^\r\n]*\r?\n)/gm;
msg = msg.replace(QuoteRegex, (m, initials, spc, text) => {
return pipeToAnsi(
` ${quoteStyleLevel1[0]}${initials}${quoteStyleLevel1[1]}>${bodyMessageView.styleSGR1}${spc}`
` ${styleL1[0]}${initials}${styleL1[1]}>${spc}${styleL1[2]}${text}${bodyMessageView.styleSGR1}`
);
});
}