mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-22 12:13:48 +01:00
commit
d5d6f49f2f
@ -5,6 +5,10 @@ import config from '../config';
|
|||||||
import { INote } from '../models/note';
|
import { INote } from '../models/note';
|
||||||
import { TextElement } from './parse';
|
import { TextElement } from './parse';
|
||||||
|
|
||||||
|
function intersperse<T>(sep: T, xs: T[]): T[] {
|
||||||
|
return [].concat(...xs.map(x => [sep, x])).slice(1);
|
||||||
|
}
|
||||||
|
|
||||||
const handlers: { [key: string]: (window: any, token: any, mentionedRemoteUsers: INote['mentionedRemoteUsers']) => void } = {
|
const handlers: { [key: string]: (window: any, token: any, mentionedRemoteUsers: INote['mentionedRemoteUsers']) => void } = {
|
||||||
bold({ document }, { bold }) {
|
bold({ document }, { bold }) {
|
||||||
const b = document.createElement('b');
|
const b = document.createElement('b');
|
||||||
@ -80,12 +84,9 @@ const handlers: { [key: string]: (window: any, token: any, mentionedRemoteUsers:
|
|||||||
},
|
},
|
||||||
|
|
||||||
text({ document }, { content }) {
|
text({ document }, { content }) {
|
||||||
const t = content.split('\n');
|
const nodes = (content as string).split('\n').map(x => document.createTextNode(x));
|
||||||
for (let i = 0; i < t.length; i++) {
|
for (const x of intersperse(document.createElement('br'), nodes)) {
|
||||||
document.body.appendChild(document.createTextNode(t[i]));
|
document.body.appendChild(x);
|
||||||
if (i != t.length - 1) {
|
|
||||||
document.body.appendChild(document.createElement('br'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user