2017-01-10 19:22:40 +01:00
|
|
|
/**
|
|
|
|
* Codex Editor Parser Module
|
|
|
|
*
|
|
|
|
* @author Codex Team
|
|
|
|
* @version 1.1
|
|
|
|
*/
|
2016-12-07 19:25:31 +01:00
|
|
|
|
2017-02-01 18:25:59 +01:00
|
|
|
module.exports = (function (parser) {
|
2016-12-07 19:25:31 +01:00
|
|
|
|
2017-02-13 18:54:18 +01:00
|
|
|
let editor = codex.editor;
|
|
|
|
|
2016-12-07 19:25:31 +01:00
|
|
|
/** inserting text */
|
2017-02-01 18:25:59 +01:00
|
|
|
parser.insertPastedContent = function (blockType, tag) {
|
2016-12-07 19:25:31 +01:00
|
|
|
|
2017-02-01 18:25:59 +01:00
|
|
|
editor.content.insertBlock({
|
2017-01-10 19:22:40 +01:00
|
|
|
type : blockType.type,
|
|
|
|
block : blockType.render({
|
|
|
|
text : tag.innerHTML
|
2016-12-07 19:25:31 +01:00
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check DOM node for display style: separated block or child-view
|
|
|
|
*/
|
|
|
|
parser.isFirstLevelBlock = function (node) {
|
|
|
|
|
2017-02-01 18:25:59 +01:00
|
|
|
return node.nodeType == editor.core.nodeTypes.TAG &&
|
|
|
|
node.classList.contains(editor.ui.className.BLOCK_CLASSNAME);
|
2016-12-07 19:25:31 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
return parser;
|
|
|
|
|
|
|
|
})({});
|