Skip to content

Commit

Permalink
[Feature] Description has now \n support
Browse files Browse the repository at this point in the history
  • Loading branch information
ThymonA committed Dec 9, 2020
1 parent cd8f984 commit 41c1d1e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- Event-based callbacks
- Uses `2 msec` while menu open and idle.
- Documentation on [menuv.fivem.io/api/](https://menuv.fivem.io/api/)
- Themes: **[default](https://i.imgur.com/KSkeiQm.png)** or **[native](https://i.imgur.com/KSkeiQm.png)**

## Compile files
**[MenuV](https://github.com/ThymonA/menuv)** uses [VueJS 2.6.11 or newer](https://vuejs.org/v2/guide/installation.html#NPM) and [TypeScript 3.8.3 or newer](https://www.npmjs.com/package/typescript) with [NodeJS Package Manager](https://nodejs.org/en/). You need to have [NPM a.k.a NodeJS Package Manager](https://nodejs.org/en/download/) installed on your system in order to compile **[MenuV](https://github.com/ThymonA/menuv)** files.
Expand Down
8 changes: 7 additions & 1 deletion app/menuv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export default VUE.extend({
const index = this.index || 0;

if (index >= 0 && index < this.items.length) {
return this.ENSURE(this.items[index].description, '');
return this.NL2BR(this.ENSURE(this.items[index].description, ''), true, false);
}

return '';
Expand Down Expand Up @@ -719,6 +719,12 @@ export default VUE.extend({
if (newIndex < 0) { return -1; }

return newIndex;
},
NL2BR: function(text: string, replaceMode: boolean, isXhtml: boolean) {
var breakTag = (isXhtml) ? '<br />' : '<br>';
var replaceStr = (replaceMode) ? '$1'+ breakTag : '$1'+ breakTag +'$2';

return (text + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, replaceStr);
}
}
});

0 comments on commit 41c1d1e

Please sign in to comment.