helix-importer-ui
helix-importer-ui copied to clipboard
Express Importing using import JSON
Introduce a higher-level Importer API that provides a declarative approach to transformations
- offer a clear API for developers to access that follows a consistent pattern
- define a no-code configuration for most common transformation phases
- allow for block-level transformation extensions
- provide default metadata handling to avoid code duplication
- open the door for easier transformation automation
- separate block transformations into their own modules
Transformer Class
export default class Transformer {
static transform(rules, source) {
const {
root,
cleanup: {
start: removeStart = [],
end: removeEnd = [],
},
blocks = [],
} = rules;
// phase 1: get main element
// phase 2: DOM removal - start
// phase 3: block creation
// phase 4: DOM removal - end
return main;
}
/**
* Build a name/value pair block configuration from a selector object.
*
* Selector Object:
* {
* name: value_selector | [condition_selector, value_selector]
* }
*
*
* @param element Root element to query from
* @param params Object of selector conditions
*/
static buildBlockConfig(element, params) {}
/**
* Build a two-dimensional array of block cells from a selector object.
* @param element
* @param cells
*/
static buildBlockCells(element, cells) {}
}
Importer Factory
const createImporter = (rules) => ({
transform: (source) => {
const element = WebImporter.Transformer.transform(rules, source);
return [{
element,
path: generateDocumentPath(source),
}];
},
});