Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename field "items" to "blocks" in Editor's config #351

Merged
merged 2 commits into from
Jul 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12,286 changes: 4,268 additions & 8,018 deletions build/codex-editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/codex-editor.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
},
initialBlock: 'text', /** this Tool will be used as default */
data: { /** Initial Editor data */
items: [
blocks: [
{
type : 'text',
data : {
Expand Down
12 changes: 6 additions & 6 deletions src/codex.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export default class CodexEditor {
set configuration(config) {
/**
* Initlai block type
* Uses in case when there is no items passed
* Uses in case when there is no blocks passed
* @type {{type: (*), data: {text: null}}}
*/
let initialBlock = {
Expand All @@ -167,14 +167,14 @@ export default class CodexEditor {
this.config.onReady = config.onReady || function () {};

/**
* Initialize items to pass data to the Renderer
* Initialize Blocks to pass data to the Renderer
*/
if (_.isEmpty(this.config.data)) {
this.config.data = {};
this.config.data.items = [ initialBlock ];
this.config.data.blocks = [ initialBlock ];
} else {
if (!this.config.data.items || this.config.data.items.length === 0) {
this.config.data.items = [ initialBlock ];
if (!this.config.data.blocks || this.config.data.blocks.length === 0) {
this.config.data.blocks = [ initialBlock ];
}
}

Expand Down Expand Up @@ -343,6 +343,6 @@ export default class CodexEditor {
Promise.resolve()
);

return this.moduleInstances.Renderer.render(this.config.data.items);
return this.moduleInstances.Renderer.render(this.config.data.blocks);
}
};
2 changes: 1 addition & 1 deletion src/components/interfaces/input-output-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default interface IInputOutputData {
/**
* Saved Blocks
*/
readonly items: IBlockToolData[];
readonly blocks: IBlockToolData[];

/**
* Editor's version
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/api-blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default class BlocksAPI extends Module implements IBlocksAPI {
*/
public render(data: IInputOutputData): void {
this.Editor.BlockManager.clear();
this.Editor.Renderer.render(data.items);
this.Editor.Renderer.render(data.blocks);
}

/**
Expand Down
36 changes: 18 additions & 18 deletions src/components/modules/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,41 @@ export default class Renderer extends Module {
}

/**
* @typedef {Object} RendererItems
* @typedef {Object} RendererBlocks
* @property {String} type - tool name
* @property {Object} data - tool data
*/

/**
* @example
*
* items: [
* {
* type : 'paragraph',
* data : {
* text : 'Hello from Codex!'
* }
* },
* {
* type : 'paragraph',
* data : {
* text : 'Leave feedback if you like it!'
* }
* },
* blocks: [
* {
* type : 'paragraph',
* data : {
* text : 'Hello from Codex!'
* }
* },
* {
* type : 'paragraph',
* data : {
* text : 'Leave feedback if you like it!'
* }
* },
* ]
*
*/

/**
* Make plugin blocks from array of plugin`s data
* @param {RendererItems[]} items
* @param {RendererBlocks[]} blocks
*/
render(items) {
render(blocks) {
let chainData = [];

for (let i = 0; i < items.length; i++) {
for (let i = 0; i < blocks.length; i++) {
chainData.push({
function: () => this.insertBlock(items[i])
function: () => this.insertBlock(blocks[i])
});
}

Expand Down
10 changes: 5 additions & 5 deletions src/components/modules/saver.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class Saver extends Module {
* @return {SavedData}
*/
makeOutput(allExtractedData) {
let items = [],
let blocks = [],
totalTime = 0;

console.groupCollapsed('[CodexEditor saving]:');
Expand All @@ -66,7 +66,7 @@ export default class Saver extends Module {
/** Group process info */
console.log(`«${extraction.tool}» saving info`, extraction);
totalTime += extraction.time;
items.push({
blocks.push({
type: extraction.tool,
data: extraction.data
});
Expand All @@ -76,9 +76,9 @@ export default class Saver extends Module {
console.groupEnd();

return {
time : +new Date(),
items : items,
version : VERSION,
time: +new Date(),
blocks: blocks,
version: VERSION,
};
}
}
Expand Down