diff --git a/app/assets/javascripts/tinymce/plugins/placeholder/plugin.js b/app/assets/javascripts/tinymce/plugins/placeholder/plugin.js index 55e5804d9..7e7007445 100644 --- a/app/assets/javascripts/tinymce/plugins/placeholder/plugin.js +++ b/app/assets/javascripts/tinymce/plugins/placeholder/plugin.js @@ -5,8 +5,8 @@ tinymce.PluginManager.add('placeholder', function(editor) { var editorForm = $(editor.getContainer()).closest('form'); var editorToolbar = editorForm.find('.mce-top-part'); var placeholderText = editor.getElement().getAttribute('placeholder') || editor.settings.placeholder; - var placeholderAttrs = editor.settings.placeholder_attrs || { - style: { + var placeholderAttrs = { + style: ` position: 'absolute', top: (editorToolbar.height()) + 'px', left: 0, @@ -15,7 +15,7 @@ tinymce.PluginManager.add('placeholder', function(editor) { width: 'calc(100% - 50px)', overflow: 'hidden', 'white-space': 'pre-wrap' - } + ` }; var contentAreaContainer = editor.getContentAreaContainer(); diff --git a/app/assets/stylesheets/tiny_mce.scss b/app/assets/stylesheets/tiny_mce.scss index 2d4cd4e52..329abcd49 100644 --- a/app/assets/stylesheets/tiny_mce.scss +++ b/app/assets/stylesheets/tiny_mce.scss @@ -38,6 +38,16 @@ position: relative !important; } +.tox.tox-tinymce { + left: -100000px; + position: absolute; + + &.tox-tinymce--loaded { + left: 0; + position: relative; + } +} + .tinymce-placeholder { background: $color-concrete; opacity: .7; @@ -45,8 +55,15 @@ width: 100%; } -.tinymce-save-button, -.tinymce-cancel-button { +.tox-edit-area { + label { + color: $color-silver-chalice !important; + padding: 5px !important; + } +} + +.tinymce-save-button.tox-mbtn, +.tinymce-cancel-button.tox-mbtn { cursor: pointer; .fas { @@ -54,6 +71,10 @@ font-weight: 900; margin-top: 3px; } + + &:hover { + background: transparent !important; + } } .tinymce-save-controls { diff --git a/app/javascript/packs/tiny_mce.js b/app/javascript/packs/tiny_mce.js index e5f227a6e..6e78d4339 100644 --- a/app/javascript/packs/tiny_mce.js +++ b/app/javascript/packs/tiny_mce.js @@ -183,9 +183,10 @@ window.TinyMCE = (() => { } return tinyMCE.init({ - cache_suffix: '?v=6.1.2', // This suffix should be changed any time library is updated + cache_suffix: '?v=6.3.1', // This suffix should be changed any time library is updated selector, convert_urls: false, + promotion: false, menu: { insert: { title: 'Insert', items: 'link codesample inserttable | charmap hr | nonbreaking anchor | insertdatetime customimageuploader marvinjs' }, }, @@ -193,7 +194,7 @@ window.TinyMCE = (() => { toolbar: 'undo redo restoredraft | insert | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table | link | forecolor backcolor | codesample | customimageuploader marvinjs | help', plugins, autoresize_bottom_margin: 20, - // placeholder: options.placeholder, + placeholder: options.placeholder, skin: false, content_css: false, toolbar_sticky: true, @@ -272,13 +273,14 @@ window.TinyMCE = (() => { } ], init_instance_callback: (editor) => { - const editorForm = $(editor.getContainer()).closest('form'); + + const editorContainer = $(editor.getContainer()); + const editorForm = editorContainer.closest('form'); const menuBar = editorForm.find('.tox-menubar'); $('.tinymce-placeholder').css('height', `${$(editor.editorContainer).height()}px`); - $(editor.editorContainer).css('max-height', '0').css('opacity', '0') setTimeout(() => { - $(editor.editorContainer).css('max-height', '').css('opacity', '') + editorContainer.addClass('tox-tinymce--loaded'); $('.tinymce-placeholder').remove(); }, 400); @@ -351,6 +353,8 @@ window.TinyMCE = (() => { SmartAnnotation.init($(editor.contentDocument.activeElement)); SmartAnnotation.preventPropagation('.atwho-user-popover'); initHighlightjsIframe($(editor.iframeElement).contents()); + + if (options.afterInitCallback) { options.afterInitCallback(); } }, setup: (editor) => { editor.on('keydown', (e) => { diff --git a/app/javascript/packs/tinymce/placeholder/plugin.js b/app/javascript/packs/tinymce/placeholder/plugin.js index 3c122feec..b53b77a7f 100644 --- a/app/javascript/packs/tinymce/placeholder/plugin.js +++ b/app/javascript/packs/tinymce/placeholder/plugin.js @@ -6,7 +6,7 @@ tinymce.PluginManager.add('placeholder', (editor) => { // const editorToolbar = editorForm.find('.tox-editor-header'); const placeholderText = editor.getElement().getAttribute('placeholder'); const placeholderAttrs = { - style: { + style: ` position: 'absolute', top: '0px', left: '0px', @@ -15,7 +15,7 @@ tinymce.PluginManager.add('placeholder', (editor) => { width: 'calc(100% - 50px)', overflow: 'hidden', 'white-space': 'pre-wrap' - } + ` }; const contentAreaContainer = editor.getContentAreaContainer(); diff --git a/app/javascript/vue/protocol/container.vue b/app/javascript/vue/protocol/container.vue index 9607fffc8..2966709c5 100644 --- a/app/javascript/vue/protocol/container.vue +++ b/app/javascript/vue/protocol/container.vue @@ -204,7 +204,7 @@ }); }, updateDescription(protocol) { - this.protocol.attributes = protocol.data.attributes + this.protocol.attributes = protocol.attributes }, addStep(position) { $.post(this.urls.add_step_url, {position: position}, (result) => { diff --git a/app/javascript/vue/protocol/step_elements/text.vue b/app/javascript/vue/protocol/step_elements/text.vue index 234bdef27..b6e72675f 100644 --- a/app/javascript/vue/protocol/step_elements/text.vue +++ b/app/javascript/vue/protocol/step_elements/text.vue @@ -79,17 +79,17 @@ methods: { enableEditMode() { if (!this.element.attributes.orderable.urls.update_url) return - if (this.inEditMode == true) return + if (this.inEditMode) return this.inEditMode = true }, disableEditMode() { this.inEditMode = false }, update(data) { - this.element.attributes.orderable.text_view = data.data.attributes.text_view - this.element.attributes.orderable.text = data.data.attributes.text - this.element.attributes.orderable.name = data.data.attributes.name - this.element.attributes.orderable.updated_at = data.data.attributes.updated_at + this.element.attributes.orderable.text_view = data.attributes.text_view + this.element.attributes.orderable.text = data.attributes.text + this.element.attributes.orderable.name = data.attributes.name + this.element.attributes.orderable.updated_at = data.attributes.updated_at this.$emit('update', this.element, true) } } diff --git a/app/javascript/vue/shared/tinymce.vue b/app/javascript/vue/shared/tinymce.vue index 3b87b21c3..8be017633 100644 --- a/app/javascript/vue/shared/tinymce.vue +++ b/app/javascript/vue/shared/tinymce.vue @@ -4,13 +4,13 @@