mirror of
https://github.com/codex-team/editor.js
synced 2026-03-15 23:25:47 +01:00
codex -> codex.eritor totally
This commit is contained in:
parent
4336036d5c
commit
cb1c328548
9 changed files with 46 additions and 5043 deletions
5001
codex-editor.js
5001
codex-editor.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -927,13 +927,13 @@ module.exports = (function (callbacks) {
|
|||
|
||||
};
|
||||
|
||||
callbacks.showCommentButtonClicked = function() {
|
||||
callbacks.showCommentButtonClicked = function () {
|
||||
|
||||
var block = codex.content.currentNode;
|
||||
var block = editor.content.currentNode;
|
||||
|
||||
codex.comments.add(block);
|
||||
editor.comments.add(block);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
return callbacks;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
let editor = codex.editor;
|
||||
|
||||
var comments = function(comments) {
|
||||
module.exports = function (comments) {
|
||||
|
||||
var draw = {
|
||||
|
||||
commentsField: function(blockId) {
|
||||
commentsField: function (blockId) {
|
||||
|
||||
var field = editor.draw.node('DIV', 'ce-comments-field');
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ var comments = function(comments) {
|
|||
|
||||
},
|
||||
|
||||
input: function(text) {
|
||||
input: function (text) {
|
||||
|
||||
var wrapper = editor.draw.node('DIV', 'ce-comment'),
|
||||
input = editor.draw.node('DIV', 'ce-comment__input', {'contentEditable': 'true', 'textContent':text||''}),
|
||||
|
|
@ -35,19 +35,19 @@ var comments = function(comments) {
|
|||
|
||||
},
|
||||
|
||||
comment: function(data) {
|
||||
comment: function (data) {
|
||||
|
||||
if (!data.text) return;
|
||||
|
||||
var wrapper = editor.draw.node('DIV', 'ce-comment'),
|
||||
text = editor.draw.node('DIV', 'ce-comment__text', {'textContent': data.text}),
|
||||
date = new Date().toLocaleDateString('en-US',{
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: 'numeric',
|
||||
minute: 'numeric',
|
||||
hour12: false
|
||||
}),
|
||||
date = new Date().toLocaleDateString('en-US', {
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: 'numeric',
|
||||
minute: 'numeric',
|
||||
hour12: false
|
||||
}),
|
||||
time = editor.draw.node('DIV', 'ce-comment__time', {'textContent': date}),
|
||||
deleteBtn = editor.draw.node('DIV', 'ce-comment__delete', {'textContent': 'Delete'}),
|
||||
editBtn = editor.draw.node('DIV', 'ce-comment__edit', {'textContent': 'Edit'});
|
||||
|
|
@ -71,7 +71,7 @@ var comments = function(comments) {
|
|||
|
||||
var callbacks = {
|
||||
|
||||
commentClicked: function(e) {
|
||||
commentClicked: function (e) {
|
||||
|
||||
var field = e.path[2],
|
||||
wrapper = e.path[1],
|
||||
|
|
@ -80,15 +80,15 @@ var comments = function(comments) {
|
|||
if (input.textContent.trim() == '') return;
|
||||
|
||||
var comment = draw.comment({
|
||||
text: input.textContent,
|
||||
edited: wrapper.dataset.edited
|
||||
text: input.textContent,
|
||||
edited: wrapper.dataset.edited
|
||||
});
|
||||
|
||||
field.replaceChild(comment, wrapper);
|
||||
|
||||
},
|
||||
|
||||
editClicked: function(e) {
|
||||
editClicked: function (e) {
|
||||
|
||||
|
||||
var field = e.path[2],
|
||||
|
|
@ -101,7 +101,7 @@ var comments = function(comments) {
|
|||
|
||||
},
|
||||
|
||||
deleteClicked: function(e) {
|
||||
deleteClicked: function (e) {
|
||||
|
||||
var field = e.path[2],
|
||||
wrapper = e.path[1];
|
||||
|
|
@ -114,20 +114,20 @@ var comments = function(comments) {
|
|||
|
||||
var methods = {
|
||||
|
||||
getCoords: function(block) {
|
||||
getCoords: function (block) {
|
||||
|
||||
var rect = block.getBoundingClientRect();
|
||||
|
||||
return {
|
||||
x: pageXOffset + rect.left,
|
||||
y: pageYOffset + rect.top
|
||||
}
|
||||
x: window.pageXOffset + rect.left,
|
||||
y: window.pageYOffset + rect.top
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
comments.add = function(block) {
|
||||
comments.add = function (block) {
|
||||
|
||||
var blockId = block.dataset.id;
|
||||
|
||||
|
|
@ -151,6 +151,4 @@ var comments = function(comments) {
|
|||
|
||||
return comments;
|
||||
|
||||
}({});
|
||||
|
||||
module.exports = comments;
|
||||
}({});
|
||||
|
|
@ -36,7 +36,7 @@ module.exports = (function (draw) {
|
|||
/**
|
||||
* Comments side bar
|
||||
*/
|
||||
draw.commentsSidebar = function() {
|
||||
draw.commentsSidebar = function () {
|
||||
|
||||
var sidebar = draw.node('DIV', 'ce-comments-sidebar');
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ module.exports = (function (draw) {
|
|||
|
||||
};
|
||||
|
||||
draw.ceBlock = function() {
|
||||
draw.ceBlock = function () {
|
||||
|
||||
var block = document.createElement('DIV');
|
||||
|
||||
|
|
@ -230,6 +230,7 @@ module.exports = (function (draw) {
|
|||
toggler.innerHTML = '<i class="ce-icon-newspaper"></i>';
|
||||
|
||||
return toggler;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -135,9 +135,9 @@ module.exports = (function (saver) {
|
|||
|
||||
};
|
||||
|
||||
saver.saveComments = function() {
|
||||
saver.saveComments = function () {
|
||||
|
||||
var fields = codex.nodes.commentsSidebar.querySelectorAll('.ce-comments-field');
|
||||
var fields = editor.nodes.commentsSidebar.querySelectorAll('.ce-comments-field');
|
||||
|
||||
for (var i = 0 ; i < fields.length; i++) {
|
||||
|
||||
|
|
@ -152,23 +152,24 @@ module.exports = (function (saver) {
|
|||
if (!text) continue;
|
||||
|
||||
var comment = {
|
||||
edited : comments[j].dataset.edited,
|
||||
text : text.textContent,
|
||||
time : time.textContent
|
||||
edited : comments[j].dataset.edited,
|
||||
text : text.textContent,
|
||||
time : time.textContent
|
||||
};
|
||||
|
||||
|
||||
commentsData.push(comment);
|
||||
|
||||
}
|
||||
|
||||
if (!commentsData.length) continue;
|
||||
|
||||
var fieldData = {
|
||||
blockId : fields[i].dataset.blockId,
|
||||
comments : commentsData
|
||||
blockId : fields[i].dataset.blockId,
|
||||
comments : commentsData
|
||||
};
|
||||
|
||||
codex.state.comments.push(fieldData);
|
||||
editor.state.comments.push(fieldData);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,13 +82,13 @@ module.exports = (function (ui) {
|
|||
toolbarContent = editor.draw.toolbarContent();
|
||||
plusButton = editor.draw.plusButton();
|
||||
showSettingsButton = editor.draw.settingsButton();
|
||||
showCommentButton = codex.draw.commentButton();
|
||||
showCommentButton = editor.draw.commentButton();
|
||||
showTrashButton = editor.toolbar.settings.makeRemoveBlockButton();
|
||||
blockSettings = editor.draw.blockSettings();
|
||||
blockButtons = editor.draw.blockButtons();
|
||||
toolbox = editor.draw.toolbox();
|
||||
redactor = editor.draw.redactor();
|
||||
commentsSidebar = codex.draw.commentsSidebar();
|
||||
commentsSidebar = editor.draw.commentsSidebar();
|
||||
|
||||
/** settings */
|
||||
var defaultSettings = editor.draw.defaultSettings(),
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue