fix: Message wrap

This commit is contained in:
Sidharth Vinod
2024-06-30 12:49:36 +05:30
parent cf72d33335
commit 29a3967c0e

View File

@@ -46,7 +46,7 @@ const state = new ImperativeState<SequenceState>(() => ({
export const addBox = function (data: { text: string; color: string; wrap: boolean }) { export const addBox = function (data: { text: string; color: string; wrap: boolean }) {
state.records.boxes.push({ state.records.boxes.push({
name: data.text, name: data.text,
wrap: (data.wrap === undefined && autoWrap()) ?? !!data.wrap, wrap: data.wrap ?? autoWrap(),
fill: data.color, fill: data.color,
actorKeys: [], actorKeys: [],
}); });
@@ -81,17 +81,17 @@ export const addActor = function (
// Don't allow null descriptions, either // Don't allow null descriptions, either
if (description?.text == null) { if (description?.text == null) {
description = { text: name, wrap: null, type }; description = { text: name, type };
} }
if (type == null || description.text == null) { if (type == null || description.text == null) {
description = { text: name, wrap: null, type }; description = { text: name, type };
} }
state.records.actors.set(id, { state.records.actors.set(id, {
box: assignedBox, box: assignedBox,
name: name, name: name,
description: description.text, description: description.text,
wrap: (description.wrap === undefined && autoWrap()) ?? !!description.wrap, wrap: description.wrap ?? autoWrap(),
prevActor: state.records.prevActor, prevActor: state.records.prevActor,
links: {}, links: {},
properties: {}, properties: {},
@@ -232,6 +232,7 @@ const extractWrap = (text?: string): { cleanedText?: string; wrap?: boolean } =>
if (!text) { if (!text) {
return {}; return {};
} }
text = text.trim();
const wrap = const wrap =
/^:?wrap:/.exec(text) !== null ? true : /^:?nowrap:/.exec(text) !== null ? false : undefined; /^:?wrap:/.exec(text) !== null ? true : /^:?nowrap:/.exec(text) !== null ? false : undefined;
const cleanedText = (wrap === undefined ? text : text.replace(/^:?(?:no)?wrap:/, '')).trim(); const cleanedText = (wrap === undefined ? text : text.replace(/^:?(?:no)?wrap:/, '')).trim();