Merge pull request #1738 from rinsuki/features/ts-noimplicitany-true
[WIP] noImplicitAny: true
This commit is contained in:
@ -3,18 +3,18 @@
|
||||
*/
|
||||
|
||||
import * as fontawesome from '@fortawesome/fontawesome';
|
||||
import * as regular from '@fortawesome/fontawesome-free-regular';
|
||||
import * as solid from '@fortawesome/fontawesome-free-solid';
|
||||
import * as brands from '@fortawesome/fontawesome-free-brands';
|
||||
import regular from '@fortawesome/fontawesome-free-regular';
|
||||
import solid from '@fortawesome/fontawesome-free-solid';
|
||||
import brands from '@fortawesome/fontawesome-free-brands';
|
||||
|
||||
fontawesome.library.add(regular, solid, brands);
|
||||
|
||||
export const pattern = /%fa:(.+?)%/g;
|
||||
|
||||
export const replacement = (match, key) => {
|
||||
export const replacement = (match: string, key: string) => {
|
||||
const args = key.split(' ');
|
||||
let prefix = 'fas';
|
||||
const classes = [];
|
||||
const classes: string[] = [];
|
||||
let transform = '';
|
||||
let name;
|
||||
|
||||
@ -34,12 +34,12 @@ export const replacement = (match, key) => {
|
||||
}
|
||||
});
|
||||
|
||||
const icon = fontawesome.icon({ prefix, iconName: name }, {
|
||||
classes: classes
|
||||
const icon = fontawesome.icon({ prefix, iconName: name } as fontawesome.IconLookup, {
|
||||
classes: classes,
|
||||
transform: fontawesome.parse.transform(transform)
|
||||
});
|
||||
|
||||
if (icon) {
|
||||
icon.transform = fontawesome.parse.transform(transform);
|
||||
return `<i data-fa class="${name}">${icon.html[0]}</i>`;
|
||||
} else {
|
||||
console.warn(`'${name}' not found in fa`);
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Replace i18n texts
|
||||
*/
|
||||
|
||||
import locale from '../../locales';
|
||||
import locale, { isAvailableLanguage, LocaleObject, LocaleObjectChildren } from '../../locales';
|
||||
|
||||
export default class Replacer {
|
||||
private lang: string;
|
||||
@ -16,19 +16,19 @@ export default class Replacer {
|
||||
this.replacement = this.replacement.bind(this);
|
||||
}
|
||||
|
||||
private get(path: string, key: string) {
|
||||
const texts = locale[this.lang];
|
||||
|
||||
if (texts == null) {
|
||||
private get(path: string, key: string): string {
|
||||
if (!isAvailableLanguage(this.lang)) {
|
||||
console.warn(`lang '${this.lang}' is not supported`);
|
||||
return key; // Fallback
|
||||
}
|
||||
|
||||
let text = texts;
|
||||
const texts = locale[this.lang];
|
||||
|
||||
let text: LocaleObjectChildren = texts;
|
||||
|
||||
if (path) {
|
||||
if (text.hasOwnProperty(path)) {
|
||||
text = text[path];
|
||||
text = text[path] as LocaleObject;
|
||||
} else {
|
||||
console.warn(`path '${path}' not found in '${this.lang}'`);
|
||||
return key; // Fallback
|
||||
@ -38,7 +38,7 @@ export default class Replacer {
|
||||
// Check the key existance
|
||||
const error = key.split('.').some(k => {
|
||||
if (text.hasOwnProperty(k)) {
|
||||
text = text[k];
|
||||
text = (text as LocaleObject)[k];
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@ -48,12 +48,15 @@ export default class Replacer {
|
||||
if (error) {
|
||||
console.warn(`key '${key}' not found in '${path}' of '${this.lang}'`);
|
||||
return key; // Fallback
|
||||
} else if (typeof text !== "string") {
|
||||
console.warn(`key '${key}' is not string in '${path}' of '${this.lang}'`);
|
||||
return key; // Fallback
|
||||
} else {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
public replacement(match, key) {
|
||||
public replacement(match: string, key: string) {
|
||||
let path = null;
|
||||
|
||||
if (key.indexOf('|') != -1) {
|
||||
|
@ -19,9 +19,10 @@ import generateVars from '../vars';
|
||||
|
||||
const langs = Object.keys(locales);
|
||||
|
||||
const kebab = string => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase();
|
||||
const kebab = (string: string) => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase();
|
||||
|
||||
const parseParam = param => {
|
||||
// WIP type
|
||||
const parseParam = (param: any) => {
|
||||
const id = param.type.match(/^id\((.+?)\)|^id/);
|
||||
const entity = param.type.match(/^entity\((.+?)\)/);
|
||||
const isObject = /^object/.test(param.type);
|
||||
@ -57,7 +58,7 @@ const parseParam = param => {
|
||||
return param;
|
||||
};
|
||||
|
||||
const sortParams = params => {
|
||||
const sortParams = (params: Array<{name: string}>) => {
|
||||
params.sort((a, b) => {
|
||||
if (a.name < b.name)
|
||||
return -1;
|
||||
@ -68,14 +69,15 @@ const sortParams = params => {
|
||||
return params;
|
||||
};
|
||||
|
||||
const extractDefs = params => {
|
||||
let defs = [];
|
||||
// WIP type
|
||||
const extractDefs = (params: any[]) => {
|
||||
let defs: any[] = [];
|
||||
|
||||
params.forEach(param => {
|
||||
if (param.def) {
|
||||
defs.push({
|
||||
name: param.defName,
|
||||
params: sortParams(param.def.map(p => parseParam(p)))
|
||||
params: sortParams(param.def.map((p: any) => parseParam(p)))
|
||||
});
|
||||
|
||||
const childDefs = extractDefs(param.def);
|
||||
@ -109,8 +111,10 @@ gulp.task('doc:api:endpoints', async () => {
|
||||
path: ep.endpoint
|
||||
},
|
||||
desc: ep.desc,
|
||||
// @ts-ignore
|
||||
params: sortParams(ep.params.map(p => parseParam(p))),
|
||||
paramDefs: extractDefs(ep.params),
|
||||
// @ts-ignore
|
||||
res: ep.res ? sortParams(ep.res.map(p => parseParam(p))) : null,
|
||||
resDefs: ep.res ? extractDefs(ep.res) : null,
|
||||
};
|
||||
@ -155,7 +159,8 @@ gulp.task('doc:api:entities', async () => {
|
||||
const vars = {
|
||||
name: entity.name,
|
||||
desc: entity.desc,
|
||||
props: sortParams(entity.props.map(p => parseParam(p))),
|
||||
// WIP type
|
||||
props: sortParams(entity.props.map((p: any) => parseParam(p))),
|
||||
propDefs: extractDefs(entity.props),
|
||||
};
|
||||
langs.forEach(lang => {
|
||||
|
@ -8,8 +8,8 @@ import * as glob from 'glob';
|
||||
import * as gulp from 'gulp';
|
||||
import * as pug from 'pug';
|
||||
import * as mkdirp from 'mkdirp';
|
||||
import stylus = require('gulp-stylus');
|
||||
import cssnano = require('gulp-cssnano');
|
||||
const stylus = require('gulp-stylus');
|
||||
const cssnano = require('gulp-cssnano');
|
||||
|
||||
import I18nReplacer from '../../build/i18n';
|
||||
import fa from '../../build/fa';
|
||||
|
@ -38,7 +38,7 @@ export default async function(): Promise<{ [key: string]: any }> {
|
||||
vars['docs'][name]['title'][lang] = fs.readFileSync(x, 'utf-8').match(/^h1 (.+?)\r?\n/)[1];
|
||||
});
|
||||
|
||||
vars['kebab'] = string => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase();
|
||||
vars['kebab'] = (string: string) => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase();
|
||||
|
||||
vars['config'] = config;
|
||||
|
||||
|
@ -7,7 +7,7 @@ import * as crypto from 'crypto';
|
||||
import * as _gm from 'gm';
|
||||
import * as debug from 'debug';
|
||||
import fileType = require('file-type');
|
||||
import prominence = require('prominence');
|
||||
const prominence = require('prominence');
|
||||
|
||||
import DriveFile, { IMetadata, getDriveFileBucket, IDriveFile } from '../../models/drive-file';
|
||||
import DriveFolder from '../../models/drive-folder';
|
||||
@ -33,7 +33,7 @@ const writeChunks = (name: string, readable: stream.Readable, type: string, meta
|
||||
readable.pipe(writeStream);
|
||||
}));
|
||||
|
||||
const writeThumbnailChunks = (name: string, readable: stream.Readable, originalId) =>
|
||||
const writeThumbnailChunks = (name: string, readable: stream.Readable, originalId: mongodb.ObjectID) =>
|
||||
getDriveFileThumbnailBucket()
|
||||
.then(bucket => new Promise((resolve, reject) => {
|
||||
const writeStream = bucket.openUploadStream(name, {
|
||||
@ -89,7 +89,7 @@ export default async function(
|
||||
const calcHash = new Promise<string>((res, rej) => {
|
||||
const readable = fs.createReadStream(path);
|
||||
const hash = crypto.createHash('md5');
|
||||
const chunks = [];
|
||||
const chunks: Buffer[] = [];
|
||||
readable
|
||||
.on('error', rej)
|
||||
.pipe(hash)
|
||||
@ -201,7 +201,7 @@ export default async function(
|
||||
return driveFolder;
|
||||
};
|
||||
|
||||
const properties = {};
|
||||
const properties: {[key: string]: any} = {};
|
||||
|
||||
let propPromises: Array<Promise<void>> = [];
|
||||
|
||||
|
@ -8,10 +8,12 @@ import * as request from 'request';
|
||||
import { IDriveFile, validateFileName } from '../../models/drive-file';
|
||||
import create from './add-file';
|
||||
import config from '../../config';
|
||||
import { IUser } from '../../models/user';
|
||||
import * as mongodb from "mongodb";
|
||||
|
||||
const log = debug('misskey:drive:upload-from-url');
|
||||
|
||||
export default async (url: string, user, folderId = null, uri: string = null): Promise<IDriveFile> => {
|
||||
export default async (url: string, user: IUser, folderId: mongodb.ObjectID = null, uri: string = null): Promise<IDriveFile> => {
|
||||
log(`REQUESTED: ${url}`);
|
||||
|
||||
let name = URL.parse(url).pathname.split('/').pop();
|
||||
|
@ -33,7 +33,7 @@ class NotificationManager {
|
||||
reason: Reason;
|
||||
}> = [];
|
||||
|
||||
constructor(user, note) {
|
||||
constructor(user: IUser, note: any) {
|
||||
this.user = user;
|
||||
this.note = note;
|
||||
}
|
||||
@ -451,7 +451,7 @@ export default async (user: IUser, data: {
|
||||
// $ne: note._id
|
||||
// }
|
||||
//});
|
||||
const existRenote = null;
|
||||
const existRenote: INote | null = null;
|
||||
//#endregion
|
||||
|
||||
if (!existRenote) {
|
||||
|
@ -36,7 +36,7 @@ export default async (user: IUser, note: INote, reaction: string) => new Promise
|
||||
|
||||
res();
|
||||
|
||||
const inc = {};
|
||||
const inc: {[key: string]: number} = {};
|
||||
inc[`reactionCounts.${reaction}`] = 1;
|
||||
|
||||
// Increment reactions count
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { lib as emojilib } from 'emojilib';
|
||||
const { lib: emojilib } = require('emojilib');
|
||||
import { JSDOM } from 'jsdom';
|
||||
import config from '../config';
|
||||
import { INote } from '../models/note';
|
||||
import { TextElement } from './parse';
|
||||
|
||||
const handlers: {[key: string]: (window: any, token: any, mentionedRemoteUsers: INote["mentionedRemoteUsers"]) => void} = {
|
||||
bold({ document }, { bold }) {
|
||||
@ -90,7 +91,7 @@ const handlers: {[key: string]: (window: any, token: any, mentionedRemoteUsers:
|
||||
}
|
||||
};
|
||||
|
||||
export default (tokens, mentionedRemoteUsers: INote['mentionedRemoteUsers'] = []) => {
|
||||
export default (tokens: TextElement[], mentionedRemoteUsers: INote['mentionedRemoteUsers'] = []) => {
|
||||
const { window } = new JSDOM('');
|
||||
|
||||
for (const token of tokens) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
function escape(text) {
|
||||
function escape(text: string) {
|
||||
return text
|
||||
.replace(/>/g, '>')
|
||||
.replace(/</g, '<');
|
||||
@ -110,7 +110,14 @@ const symbols = [
|
||||
'?'
|
||||
];
|
||||
|
||||
const elements = [
|
||||
type Token = {
|
||||
html: string
|
||||
next: number
|
||||
};
|
||||
|
||||
type Element = (code: string, i: number, source: string) => (Token | null);
|
||||
|
||||
const elements: Element[] = [
|
||||
// comment
|
||||
code => {
|
||||
if (code.substr(0, 2) != '//') return null;
|
||||
@ -305,7 +312,7 @@ export default (source: string, lang?: string) => {
|
||||
|
||||
let i = 0;
|
||||
|
||||
function push(token) {
|
||||
function push(token: Token) {
|
||||
html += token.html;
|
||||
code = code.substr(token.next);
|
||||
i += token.next;
|
||||
|
@ -2,7 +2,13 @@
|
||||
* Bold
|
||||
*/
|
||||
|
||||
module.exports = text => {
|
||||
export type TextElementBold = {
|
||||
type: "bold"
|
||||
content: string
|
||||
bold: string
|
||||
};
|
||||
|
||||
export default function(text: string) {
|
||||
const match = text.match(/^\*\*(.+?)\*\*/);
|
||||
if (!match) return null;
|
||||
const bold = match[0];
|
||||
@ -10,5 +16,5 @@ module.exports = text => {
|
||||
type: 'bold',
|
||||
content: bold,
|
||||
bold: bold.substr(2, bold.length - 4)
|
||||
};
|
||||
};
|
||||
} as TextElementBold;
|
||||
}
|
||||
|
@ -4,7 +4,14 @@
|
||||
|
||||
import genHtml from '../core/syntax-highlighter';
|
||||
|
||||
module.exports = text => {
|
||||
export type TextElementCode = {
|
||||
type: "code"
|
||||
content: string
|
||||
code: string
|
||||
html: string
|
||||
};
|
||||
|
||||
export default function(text: string) {
|
||||
const match = text.match(/^```([\s\S]+?)```/);
|
||||
if (!match) return null;
|
||||
const code = match[0];
|
||||
@ -13,5 +20,5 @@ module.exports = text => {
|
||||
content: code,
|
||||
code: code.substr(3, code.length - 6).trim(),
|
||||
html: genHtml(code.substr(3, code.length - 6).trim())
|
||||
};
|
||||
};
|
||||
} as TextElementCode;
|
||||
}
|
||||
|
@ -2,7 +2,13 @@
|
||||
* Emoji
|
||||
*/
|
||||
|
||||
module.exports = text => {
|
||||
export type TextElementEmoji = {
|
||||
type: "emoji"
|
||||
content: string
|
||||
emoji: string
|
||||
};
|
||||
|
||||
export default function(text: string) {
|
||||
const match = text.match(/^:[a-zA-Z0-9+-_]+:/);
|
||||
if (!match) return null;
|
||||
const emoji = match[0];
|
||||
@ -10,5 +16,5 @@ module.exports = text => {
|
||||
type: 'emoji',
|
||||
content: emoji,
|
||||
emoji: emoji.substr(1, emoji.length - 2)
|
||||
};
|
||||
};
|
||||
} as TextElementEmoji;
|
||||
}
|
||||
|
@ -2,7 +2,13 @@
|
||||
* Hashtag
|
||||
*/
|
||||
|
||||
module.exports = (text, i) => {
|
||||
export type TextElementHashtag = {
|
||||
type: "hashtag"
|
||||
content: string
|
||||
hashtag: string
|
||||
};
|
||||
|
||||
export default function(text: string, i: number) {
|
||||
if (!(/^\s#[^\s]+/.test(text) || (i == 0 && /^#[^\s]+/.test(text)))) return null;
|
||||
const isHead = text[0] == '#';
|
||||
const hashtag = text.match(/^\s?#[^\s]+/)[0];
|
||||
@ -15,5 +21,5 @@ module.exports = (text, i) => {
|
||||
content: isHead ? hashtag : hashtag.substr(1),
|
||||
hashtag: isHead ? hashtag.substr(1) : hashtag.substr(2)
|
||||
});
|
||||
return res;
|
||||
};
|
||||
return res as TextElementHashtag[];
|
||||
}
|
||||
|
@ -4,7 +4,14 @@
|
||||
|
||||
import genHtml from '../core/syntax-highlighter';
|
||||
|
||||
module.exports = text => {
|
||||
export type TextElementInlineCode = {
|
||||
type: "inline-code"
|
||||
content: string
|
||||
code: string
|
||||
html: string
|
||||
};
|
||||
|
||||
export default function(text: string) {
|
||||
const match = text.match(/^`(.+?)`/);
|
||||
if (!match) return null;
|
||||
const code = match[0];
|
||||
@ -13,5 +20,5 @@ module.exports = text => {
|
||||
content: code,
|
||||
code: code.substr(1, code.length - 2).trim(),
|
||||
html: genHtml(code.substr(1, code.length - 2).trim())
|
||||
};
|
||||
};
|
||||
} as TextElementInlineCode;
|
||||
}
|
||||
|
@ -2,7 +2,15 @@
|
||||
* Link
|
||||
*/
|
||||
|
||||
module.exports = text => {
|
||||
export type TextElementLink = {
|
||||
type: "link"
|
||||
content: string
|
||||
title: string
|
||||
url: string
|
||||
silent: boolean
|
||||
};
|
||||
|
||||
export default function(text: string) {
|
||||
const match = text.match(/^\??\[([^\[\]]+?)\]\((https?:\/\/[\w\/:%#@\$&\?!\(\)\[\]~\.=\+\-]+?)\)/);
|
||||
if (!match) return null;
|
||||
const silent = text[0] == '?';
|
||||
@ -15,5 +23,5 @@ module.exports = text => {
|
||||
title: title,
|
||||
url: url,
|
||||
silent: silent
|
||||
};
|
||||
};
|
||||
} as TextElementLink;
|
||||
}
|
||||
|
@ -3,7 +3,14 @@
|
||||
*/
|
||||
import parseAcct from '../../../acct/parse';
|
||||
|
||||
module.exports = text => {
|
||||
export type TextElementMention = {
|
||||
type: "mention"
|
||||
content: string
|
||||
username: string
|
||||
host: string
|
||||
};
|
||||
|
||||
export default function(text: string) {
|
||||
const match = text.match(/^@[a-z0-9_]+(?:@[a-z0-9\.\-]+[a-z0-9])?/i);
|
||||
if (!match) return null;
|
||||
const mention = match[0];
|
||||
@ -13,5 +20,5 @@ module.exports = text => {
|
||||
content: mention,
|
||||
username,
|
||||
host
|
||||
};
|
||||
};
|
||||
} as TextElementMention;
|
||||
}
|
||||
|
@ -2,7 +2,13 @@
|
||||
* Quoted text
|
||||
*/
|
||||
|
||||
module.exports = text => {
|
||||
export type TextElementQuote = {
|
||||
type: "quote"
|
||||
content: string
|
||||
quote: string
|
||||
};
|
||||
|
||||
export default function(text: string) {
|
||||
const match = text.match(/^"([\s\S]+?)\n"/);
|
||||
if (!match) return null;
|
||||
const quote = match[0];
|
||||
@ -10,5 +16,5 @@ module.exports = text => {
|
||||
type: 'quote',
|
||||
content: quote,
|
||||
quote: quote.substr(1, quote.length - 2).trim(),
|
||||
};
|
||||
};
|
||||
} as TextElementQuote;
|
||||
}
|
||||
|
@ -2,7 +2,13 @@
|
||||
* Search
|
||||
*/
|
||||
|
||||
module.exports = text => {
|
||||
export type TextElementSearch = {
|
||||
type: "search"
|
||||
content: string
|
||||
query: string
|
||||
};
|
||||
|
||||
export default function(text: string) {
|
||||
const match = text.match(/^(.+?) 検索(\n|$)/);
|
||||
if (!match) return null;
|
||||
return {
|
||||
@ -10,4 +16,4 @@ module.exports = text => {
|
||||
content: match[0],
|
||||
query: match[1]
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -2,7 +2,13 @@
|
||||
* Title
|
||||
*/
|
||||
|
||||
module.exports = text => {
|
||||
export type TextElementTitle = {
|
||||
type: "title"
|
||||
content: string
|
||||
title: string
|
||||
};
|
||||
|
||||
export default function(text: string) {
|
||||
const match = text.match(/^【(.+?)】\n/);
|
||||
if (!match) return null;
|
||||
const title = match[0];
|
||||
@ -10,5 +16,5 @@ module.exports = text => {
|
||||
type: 'title',
|
||||
content: title,
|
||||
title: title.substr(1, title.length - 3)
|
||||
};
|
||||
};
|
||||
} as TextElementTitle;
|
||||
}
|
||||
|
@ -2,7 +2,13 @@
|
||||
* URL
|
||||
*/
|
||||
|
||||
module.exports = text => {
|
||||
export type TextElementUrl = {
|
||||
type: "url"
|
||||
content: string
|
||||
url: string
|
||||
};
|
||||
|
||||
export default function(text: string) {
|
||||
const match = text.match(/^https?:\/\/[\w\/:%#@\$&\?!\(\)\[\]~\.=\+\-]+/);
|
||||
if (!match) return null;
|
||||
const url = match[0];
|
||||
@ -10,5 +16,5 @@ module.exports = text => {
|
||||
type: 'url',
|
||||
content: url,
|
||||
url: url
|
||||
};
|
||||
};
|
||||
} as TextElementUrl;
|
||||
}
|
||||
|
@ -2,6 +2,18 @@
|
||||
* Misskey Text Analyzer
|
||||
*/
|
||||
|
||||
import { TextElementBold } from "./elements/bold";
|
||||
import { TextElementCode } from "./elements/code";
|
||||
import { TextElementEmoji } from "./elements/emoji";
|
||||
import { TextElementHashtag } from "./elements/hashtag";
|
||||
import { TextElementInlineCode } from "./elements/inline-code";
|
||||
import { TextElementLink } from "./elements/link";
|
||||
import { TextElementMention } from "./elements/mention";
|
||||
import { TextElementQuote } from "./elements/quote";
|
||||
import { TextElementSearch } from "./elements/search";
|
||||
import { TextElementTitle } from "./elements/title";
|
||||
import { TextElementUrl } from "./elements/url";
|
||||
|
||||
const elements = [
|
||||
require('./elements/bold'),
|
||||
require('./elements/title'),
|
||||
@ -14,17 +26,31 @@ const elements = [
|
||||
require('./elements/quote'),
|
||||
require('./elements/emoji'),
|
||||
require('./elements/search')
|
||||
];
|
||||
].map(element => element.default as TextElementProcessor);
|
||||
|
||||
export default (source: string): any[] => {
|
||||
export type TextElement = {type: "text", content: string}
|
||||
| TextElementBold
|
||||
| TextElementCode
|
||||
| TextElementEmoji
|
||||
| TextElementHashtag
|
||||
| TextElementInlineCode
|
||||
| TextElementLink
|
||||
| TextElementMention
|
||||
| TextElementQuote
|
||||
| TextElementSearch
|
||||
| TextElementTitle
|
||||
| TextElementUrl;
|
||||
export type TextElementProcessor = (text: string, i: number) => TextElement | TextElement[];
|
||||
|
||||
export default (source: string): TextElement[] => {
|
||||
|
||||
if (source == '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const tokens = [];
|
||||
const tokens: TextElement[] = [];
|
||||
|
||||
function push(token) {
|
||||
function push(token: TextElement) {
|
||||
if (token != null) {
|
||||
tokens.push(token);
|
||||
source = source.substr(token.content.length);
|
||||
@ -59,9 +85,8 @@ export default (source: string): any[] => {
|
||||
}
|
||||
|
||||
// テキストを纏める
|
||||
tokens[0] = [tokens[0]];
|
||||
return tokens.reduce((a, b) => {
|
||||
if (a[a.length - 1].type == 'text' && b.type == 'text') {
|
||||
if (a.length && a[a.length - 1].type == 'text' && b.type == 'text') {
|
||||
const tail = a.pop();
|
||||
return a.concat({
|
||||
type: 'text',
|
||||
@ -70,5 +95,5 @@ export default (source: string): any[] => {
|
||||
} else {
|
||||
return a.concat(b);
|
||||
}
|
||||
});
|
||||
}, [] as TextElement[]);
|
||||
};
|
||||
|
Reference in New Issue
Block a user