-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from thematters/develop
Release: v1.3.0
- Loading branch information
Showing
59 changed files
with
1,733 additions
and
959 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const UPLOAD_FILE_SIZE_LIMIT: number = 1 * 1024 * 1024 | ||
export const UPLOAD_FILE_SIZE_LIMIT: number = 5 * 1024 * 1024 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export const langConvert = { | ||
og2html: (lang: OGLanguage): HTMLLanguage => { | ||
return ({ | ||
zh_HK: 'zh-Hant', | ||
zh_TW: 'zh-Hant', | ||
zh_CN: 'zh-Hans', | ||
en: 'en' | ||
}[lang] || 'zh-Hant') as HTMLLanguage | ||
}, | ||
sys2html: (lang: Language): HTMLLanguage => { | ||
return ({ | ||
zh_hans: 'zh-Hans', | ||
zh_hant: 'zh-Hant', | ||
en: 'en' | ||
}[lang] || 'zh-Hant') as HTMLLanguage | ||
}, | ||
html2sys: (lang: HTMLLanguage): Language => { | ||
return ({ | ||
'zh-Hans': 'zh_hans', | ||
'zh-Hant': 'zh_hant', | ||
en: 'en' | ||
}[lang] || 'zh_hant') as Language | ||
}, | ||
sys2Og: (lang: Language): OGLanguage => { | ||
return ({ | ||
zh_hant: 'zh-HK', | ||
zh_hans: 'zh-CN', | ||
en: 'en' | ||
}[lang] || 'zh_HK') as OGLanguage | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Remove html tag and merge multiple spaces into one. | ||
*/ | ||
export const stripHtml = (html: string | null, replacement = ' ') => | ||
(html || '') | ||
.replace(/(<\/p><p>| )/g, ' ') // replace line break and space first | ||
.replace(/(<([^>]+)>)/gi, replacement) | ||
|
||
export const makeSummary = (html: string, length = 140) => { | ||
// buffer for search | ||
const buffer = 20 | ||
|
||
// split on sentence breaks | ||
const sections = stripHtml(html, '') | ||
.replace(/([?!。?!]|(\.\s))\s*/g, '$1|') | ||
.split('|') | ||
|
||
// grow summary within buffer | ||
let summary = '' | ||
while (summary.length < length - buffer && sections.length > 0) { | ||
const el = sections.shift() || '' | ||
|
||
const addition = | ||
el.length + summary.length > length + buffer | ||
? `${el.substring(0, length - summary.length)}...` | ||
: el | ||
|
||
summary = summary.concat(addition) | ||
} | ||
|
||
return summary | ||
} | ||
|
||
/** | ||
* Removes leading and trailing line breaks from (Quill's) HTML string. | ||
*/ | ||
export const trimLineBreaks = (html: string) => { | ||
const LINE_BREAK = '<p><br></p>' | ||
const re = new RegExp(`(^(${LINE_BREAK})*)|((${LINE_BREAK})*$)`, 'g') | ||
return html.replace(re, '') | ||
} |
Oops, something went wrong.