X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/7509ad5d22654faa0abd75465de9f3fa632b1f3a..21cd91531dd9c6e88d00da03f6b2f3ad88fb0da0:/src/editor/plugins/core.js diff --git a/src/editor/plugins/core.js b/src/editor/plugins/core.js deleted file mode 100644 index c4991f8..0000000 --- a/src/editor/plugins/core.js +++ /dev/null @@ -1,86 +0,0 @@ -define([ - -], function() { - -'use strict'; - -var breakContentTransformation = { - impl: function(args) { - var node = this.context, - newNodes, emptyNode, emptyText; - newNodes = node.transform('smartxml.split', {offset: args.offset}); - [newNodes.first, newNodes.second].some(function(newNode) { - if(!(newNode.contents().length)) { - newNode.transform('smartxml.append', {text: ''}); - return true; // break - } - }); - return _.extend(newNodes, {emptyText: emptyText}); - }, - isAllowed: function() { - - } -}; - - -var breakContentAction = function(document, context) { //@ editor.getDocument(); editor.getContext('...') - var textNode = context.cursor.currentNode; - if(textNode) { - var result, goto; - - result = textNode.transform('core.break-content', {offset: context.cursor.offset}); - - if(result.emptyText) { - goto = result.createdEmpty; - gotoOptions = {}; - } else { - goto = result.second; - gotoOptions = {caretTo: 'start'}; - } - - context.setCurrentElement(goto, gotoOptions); - } -} -breakContentAction.isAllowed = function(document, context) { - /* globals Node */ - var node = context.cursor.currentNode; - return node.nodeType === Node.TEXT_NODE; -} - -return { - keyHandlers: [ - {key: 'ENTER', target: 'main-document-area', handler: function(editor) { - var action = editor.getAction('core.break-document-content'); - if(action.isAllowed()) { - action.execute(); - } - }}, - {key: 'ENTER', target: 'main-document-area', actionHandler: 'core.break-document-content'} - ], - - documentActions: [ - { - name: 'core.break-document-content', - context: 'main-document-area', - label: 'break here' - icon: 'core:some-name', - action: breakContentAction - } - ], - - // zapisywanie dokumentu: - - documentTransformations: [ - {name: 'core.break-content', textNode: true, t: breakContentTransformation}, - - // transformacja z poziomu smartxml - {name: 'core.wrap-with', textNode: true, t: wrapWith} - - // list plugin: - {name: 'list.remove-list', elementNode: 'list', t: null} - // hipotetyczna akcja na itemie listy - {name: 'list.extract', elementNode: 'item', requiresParent: 'list', requiresInParents: '?'} - ] -}; - -}); \ No newline at end of file