ulDelimiterStyleStrategy.ts
TLDR
This file, ulDelimiterStyleStrategy.ts
, is a TypeScript module in the Demo Projects project. It exports a function createULDelimiterStyleStrategy
which returns an object implementing the InlineStrategy
interface. The strategy is used for applying a specific CSS style to unordered list delimiters in a Markdown editor.
Methods
createULDelimiterStyleStrategy
This method is a factory function that creates and returns an InlineStrategy
object. The created strategy applies the CSS style 'UL-DELIMITER'
to unordered list delimiters found in a block of text.
END
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {InlineStrategy} from '../pluginStrategy'
import findRangesWithRegex from '../utils/findRangesWithRegex'
const createULDelimiterStyleStrategy = (): InlineStrategy => {
const ulDelimiterRegex = /^\* /g
return {
style: 'UL-DELIMITER',
findStyleRanges: (block) => {
const text = block.getText()
const ulDelimiterRanges = findRangesWithRegex(text, ulDelimiterRegex)
return ulDelimiterRanges
},
styles: {
fontWeight: 'bold',
},
}
}
export default createULDelimiterStyleStrategy