本文整理汇总了TypeScript中client/actions/edit/articleActions.onChangeArticle函数的典型用法代码示例。如果您正苦于以下问题:TypeScript onChangeArticle函数的具体用法?TypeScript onChangeArticle怎么用?TypeScript onChangeArticle使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了onChangeArticle函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: return
return (dispatch, getState) => {
const {
edit: { article },
} = getState()
const newArticle = cloneDeep(article)
const activeSection = newArticle.sections[sectionIndex]
const isText = activeSection.type === "text"
if (!isText) {
// No action necessary if section is not text
return
} else {
const isEmptyHtml = !clean(stripTags(activeSection.body)).length
const isEmptyH1 = isEmptyHtml && activeSection.body.includes("<h1>")
if (!isEmptyHtml) {
// No action necessary if text is present
return
} else if (isEmptyH1) {
// Preserve empty H1 as section divider
newArticle.sections[sectionIndex].body = "<h1></h1>"
dispatch(onChangeArticle("sections", newArticle.sections))
} else {
// Remove text sections with empty body
dispatch(removeSection(sectionIndex))
}
}
}
示例2: it
it("calls debounced #saveArticle if draft", async () => {
article.published = false
onChangeArticle("title", "New title")(dispatch, getState)
const dispatchedChangeArticleData = dispatch.mock.calls[0][0]
dispatchedChangeArticleData(dispatch, getState)
const dispatchedSaveArticle = dispatch.mock.calls[2][0]
dispatchedSaveArticle(dispatch, getState)
expect(Backbone.sync.mock.calls[0][0]).toBe("update")
})