mirror of
https://github.com/codex-team/editor.js
synced 2024-06-13 19:32:28 +02:00
1.4.8. - anchors module updated
This commit is contained in:
parent
b20b96131e
commit
d8297116b8
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
59
example.html
59
example.html
|
@ -184,35 +184,36 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data : {
|
data : {
|
||||||
// items: [
|
items: [
|
||||||
// {
|
{
|
||||||
// type : 'paragraph',
|
type : 'paragraph',
|
||||||
// data : {
|
data : {
|
||||||
// text : 'Привет от CodeX'
|
text : 'Привет от CodeX'
|
||||||
// }
|
}
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// type : 'tweet',
|
type : 'tweet',
|
||||||
// data : {
|
data : {
|
||||||
// "media" : true,
|
"media" : true,
|
||||||
// "conversation" : false,
|
"conversation" : false,
|
||||||
// "user" : null,
|
"user" : null,
|
||||||
// "id" : 12312312312,
|
"id" : 12312312312,
|
||||||
// "text" : null,
|
"text" : null,
|
||||||
// "created_at" : null,
|
"created_at" : null,
|
||||||
// "status_url" : 'ertertert',
|
"status_url" : 'ertertert',
|
||||||
// "caption" : null
|
"caption" : null
|
||||||
// },
|
},
|
||||||
// cover : false
|
cover : false
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// type : 'paragraph',
|
type : 'paragraph',
|
||||||
// data : {
|
data : {
|
||||||
// text : 'Пишите нам на team@ifmo.su'
|
text : 'Пишите нам на team@ifmo.su'
|
||||||
// }
|
},
|
||||||
// },
|
anchor: 'Update',
|
||||||
// ],
|
},
|
||||||
// count: 2
|
],
|
||||||
|
count: 2
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -5,15 +5,13 @@
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let editor = codex.editor;
|
|
||||||
|
|
||||||
module.exports = function (anchors) {
|
module.exports = function (anchors) {
|
||||||
|
|
||||||
|
let editor = codex.editor;
|
||||||
|
|
||||||
anchors.input = null;
|
anchors.input = null;
|
||||||
anchors.currentNode = null;
|
anchors.currentNode = null;
|
||||||
|
|
||||||
const blockWithAnchorClassName = 'ce-block--anchor';
|
|
||||||
|
|
||||||
anchors.settingsOpened = function (currentBlock) {
|
anchors.settingsOpened = function (currentBlock) {
|
||||||
|
|
||||||
anchors.currentNode = currentBlock;
|
anchors.currentNode = currentBlock;
|
||||||
|
@ -29,11 +27,11 @@ module.exports = function (anchors) {
|
||||||
|
|
||||||
if (newAnchor.trim() !== '') {
|
if (newAnchor.trim() !== '') {
|
||||||
|
|
||||||
anchors.currentNode.classList.add(blockWithAnchorClassName);
|
anchors.currentNode.classList.add(editor.ui.className.BLOCK_WITH_ANCHOR);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
anchors.currentNode.classList.remove(blockWithAnchorClassName);
|
anchors.currentNode.classList.remove(editor.ui.className.BLOCK_WITH_ANCHOR);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,6 +194,12 @@ module.exports = (function (content) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (targetBlock.classList.contains(editor.ui.className.BLOCK_WITH_ANCHOR)) {
|
||||||
|
|
||||||
|
newBlock.classList.add(editor.ui.className.BLOCK_WITH_ANCHOR);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saving anchor
|
* Saving anchor
|
||||||
*/
|
*/
|
||||||
|
@ -248,6 +254,12 @@ module.exports = (function (content) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (anchor) {
|
||||||
|
|
||||||
|
newBlock.classList.add(editor.ui.className.BLOCK_WITH_ANCHOR);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (workingBlock) {
|
if (workingBlock) {
|
||||||
|
|
||||||
editor.core.insertAfter(workingBlock, newBlock);
|
editor.core.insertAfter(workingBlock, newBlock);
|
||||||
|
|
|
@ -150,7 +150,7 @@ module.exports = (function (renderer) {
|
||||||
var block,
|
var block,
|
||||||
tool = toolData.tool,
|
tool = toolData.tool,
|
||||||
pluginName = tool.type,
|
pluginName = tool.type,
|
||||||
anchor = toolData.anchor,
|
anchor = tool.anchor,
|
||||||
cover = tool.cover;
|
cover = tool.cover;
|
||||||
|
|
||||||
/** Get first key of object that stores plugin name */
|
/** Get first key of object that stores plugin name */
|
||||||
|
|
|
@ -39,6 +39,11 @@ module.exports = (function (ui) {
|
||||||
*/
|
*/
|
||||||
BLOCK_IN_FEED_MODE : 'ce-block--feed-mode',
|
BLOCK_IN_FEED_MODE : 'ce-block--feed-mode',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const {String} - Block with anchor
|
||||||
|
*/
|
||||||
|
BLOCK_WITH_ANCHOR : 'ce-block--anchor',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const {String} - for all default settings
|
* @const {String} - for all default settings
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "codex.editor",
|
"name": "codex.editor",
|
||||||
"version": "1.4.7",
|
"version": "1.4.8",
|
||||||
"description": "Codex Editor. Native JS, based on API and Open Source",
|
"description": "Codex Editor. Native JS, based on API and Open Source",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue