本文整理匯總了TypeScript中draft-js.Modifier.applyInlineStyle方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Modifier.applyInlineStyle方法的具體用法?TypeScript Modifier.applyInlineStyle怎麽用?TypeScript Modifier.applyInlineStyle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類draft-js.Modifier
的用法示例。
在下文中一共展示了Modifier.applyInlineStyle方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: walkChildren
walkChildren(node, child => {
let end = start + getLength(child)
const selection = SelectionState.createEmpty(blockKey).merge({
anchorOffset: start,
focusKey: blockKey,
focusOffset: end,
})
if (child.type === 'Emph') {
updatedContent = Modifier.applyInlineStyle(updatedContent, selection, 'ITALIC')
} else if (child.type === 'Strong') {
updatedContent = Modifier.applyInlineStyle(updatedContent, selection, 'BOLD')
} else if (child.type === 'Code') {
updatedContent = Modifier.applyInlineStyle(updatedContent, selection, 'CODE')
}
start = end + 1
})
示例2: modifyInlineStyle
export function modifyInlineStyle(
editor: EditorState, selection: SelectionState, {apply, remove}: {apply?: string, remove?: string}
) {
let content = editor.getCurrentContent()
if (remove) {
content = Modifier.removeInlineStyle(content, selection, remove)
}
if (apply) {
content = Modifier.applyInlineStyle(content, selection, apply)
}
return EditorState.push(editor, content, 'change-inline-style')
}