Pad: Convert line endings in text from padDefaultContent hook

This commit is contained in:
Richard Hansen 2022-02-23 21:08:41 -05:00
parent cd43625be8
commit b733ed9ab0
2 changed files with 14 additions and 7 deletions

View file

@ -387,15 +387,10 @@ Pad.prototype.init = async function (text, authorId = '') {
}
} else {
if (text == null) {
const context = {
pad: this,
authorId,
type: 'text',
content: exports.cleanText(settings.defaultPadText),
};
const context = {pad: this, authorId, type: 'text', content: settings.defaultPadText};
await hooks.aCallAll('padDefaultContent', context);
if (context.type !== 'text') throw new Error(`unsupported content type: ${context.type}`);
text = context.content;
text = exports.cleanText(context.content);
}
const firstChangeset = Changeset.makeSplice('\n', 0, 0, text);
await this.appendRevision(firstChangeset, authorId);