immutable#OrderedSet JavaScript Examples
The following examples show how to use
immutable#OrderedSet.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: customHTML2Content.js From spring-boot-ecommerce with Apache License 2.0 | 6 votes |
createContentBlock = function createContentBlock(blockData, contentState) {
var key = blockData.key,
type = blockData.type,
text = blockData.text,
data = blockData.data,
inlineStyles = blockData.inlineStyles,
entityData = blockData.entityData;
var blockSpec = {
type: type != null ? type : 'unstyled',
text: text != null ? text : '',
key: key != null ? key : genKey(),
data: null,
characterList: List([])
};
if (data) {
blockSpec.data = fromJS(data);
}
if (inlineStyles || entityData) {
var entityKey = void 0;
if (entityData) {
var _type = entityData.type,
mutability = entityData.mutability,
_data = entityData.data;
contentState.createEntity(_type, mutability, _data);
entityKey = contentState.getLastCreatedEntityKey();
} else {
entityKey = null;
}
var style = OrderedSet(inlineStyles || []);
var charData = CharacterMetadata.create({ style: style, entityKey: entityKey });
blockSpec.characterList = List(Repeat(charData, text.length));
}
return new ContentBlock(blockSpec);
}
Example #2
Source File: convertFromHTML.js From the-eye-knows-the-garbage with MIT License | 6 votes |
function getWhitespaceChunk(inEntity) {
var entities = new Array(1);
if (inEntity) {
entities[0] = inEntity;
}
return {
text: SPACE,
inlines: [OrderedSet()],
entities: entities,
blocks: []
};
}
Example #3
Source File: convertFromHTML.js From the-eye-knows-the-garbage with MIT License | 6 votes |
function getSoftNewlineChunk(block, depth) {
var flat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Map();
if (flat === true) {
return {
text: '\r',
inlines: [OrderedSet()],
entities: new Array(1),
blocks: [{
type: block,
data: data,
depth: Math.max(0, Math.min(MAX_DEPTH, depth))
}],
isNewline: true
};
}
return {
text: '\n',
inlines: [OrderedSet()],
entities: new Array(1),
blocks: []
};
}
Example #4
Source File: convertFromHTML.js From the-eye-knows-the-garbage with MIT License | 6 votes |
function getBlockDividerChunk(block, depth) {
var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Map();
return {
text: '\r',
inlines: [OrderedSet()],
entities: new Array(1),
blocks: [{
type: block,
data: data,
depth: Math.max(0, Math.min(MAX_DEPTH, depth))
}]
};
}
Example #5
Source File: getHTML.js From spring-boot-ecommerce with Apache License 2.0 | 5 votes |
EMPTY_SET = OrderedSet()
Example #6
Source File: convertFromHTML.js From the-eye-knows-the-garbage with MIT License | 5 votes |
function baseProcessInlineTag(tag, node) {
var inlineStyles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : OrderedSet();
return processInlineTag(tag, node, inlineStyles);
}
Example #7
Source File: convertFromHTML.js From the-eye-knows-the-garbage with MIT License | 5 votes |
function getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder) {
html = html.trim().replace(REGEX_CR, '').replace(REGEX_NBSP, SPACE);
var safeBody = DOMBuilder(html);
if (!safeBody) {
return null;
} // Sometimes we aren't dealing with content that contains nice semantic
// tags. In this case, use divs to separate everything out into paragraphs
// and hope for the best.
var workingBlocks = containsSemanticBlockMarkup(html) ? blockTags.concat(['div']) : ['div']; // Start with -1 block depth to offset the fact that we are passing in a fake
// UL block to sta rt with.
var chunk = genFragment(safeBody, OrderedSet(), 'ul', null, workingBlocks, -1, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options); // join with previous block to prevent weirdness on paste
if (chunk.text.indexOf('\r') === 0) {
chunk = {
text: chunk.text.slice(1),
inlines: chunk.inlines.slice(1),
entities: chunk.entities.slice(1),
blocks: chunk.blocks
};
} // Kill block delimiter at the end
if (chunk.text.slice(-1) === '\r') {
chunk.text = chunk.text.slice(0, -1);
chunk.inlines = chunk.inlines.slice(0, -1);
chunk.entities = chunk.entities.slice(0, -1);
chunk.blocks.pop();
} // If we saw no block tags, put an unstyled one in
if (chunk.blocks.length === 0) {
chunk.blocks.push({
type: 'unstyled',
data: Map(),
depth: 0
});
} // Sometimes we start with text that isn't in a block, which is then
// followed by blocks. Need to fix up the blocks to add in
// an unstyled block for this content
if (chunk.text.split('\r').length === chunk.blocks.length + 1) {
chunk.blocks.unshift({
type: 'unstyled',
data: Map(),
depth: 0
});
}
return chunk;
}