- var element = documentElement.DocumentTextElement.create({text: text.transformed});
- el.replaceWith(element.dom());
- });
-
- this.d = this.wrapper.children(0);
-
- this.wrapper.on('keyup keydown keypress', function(e) {
- keyboard.handleKey(e, this);
- }.bind(this));
-
- this.wrapper.on('click', '[document-node-element], [document-text-element]', function(e) {
- e.stopPropagation();
- canvas.setCurrentElement(canvas.getDocumentElement(e.currentTarget), {caretTo: false});
- });
-
- var observer = new MutationObserver(function(mutations) {
- mutations.forEach(function(mutation) {
- if(documentElement.DocumentTextElement.isContentContainer(mutation.target)) {
- observer.disconnect();
- if(mutation.target.data === '')
- mutation.target.data = utils.unicode.ZWS;
- else if(mutation.oldValue === utils.unicode.ZWS) {
- mutation.target.data = mutation.target.data.replace(utils.unicode.ZWS, '');
- canvas._moveCaretToTextElement(canvas.getDocumentElement(mutation.target), 'end');
- }
- observer.observe(canvas.d[0], config);
- canvas.publisher('contentChanged');
- }
- });
- });
- var config = { attributes: false, childList: false, characterData: true, subtree: true, characterDataOldValue: true};
- observer.observe(this.d[0], config);
-
-
- this.wrapper.on('mouseover', '[document-node-element], [document-text-element]', function(e) {
- var el = canvas.getDocumentElement(e.currentTarget);
- if(!el)
- return;
- e.stopPropagation();
- if(el instanceof documentElement.DocumentTextElement)
- el = el.parent();
- el.toggleLabel(true);
- });
- this.wrapper.on('mouseout', '[document-node-element], [document-text-element]', function(e) {
- var el = canvas.getDocumentElement(e.currentTarget);
- if(!el)
- return;
- e.stopPropagation();
- if(el instanceof documentElement.DocumentTextElement)
- el = el.parent();
- el.toggleLabel(false);
- });