From 8a6ee41d1f5f163548b6797bedd003eea37dd2e9 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Thu, 7 Sep 2023 10:23:59 +1200 Subject: [PATCH 1/2] FIX Allow wrapping an image in a link (#1397) Relies on logic added to silverstripe/admin, so we need to bump the constraint as well. Also migrates some behat fixture logic to the behat-extension module, so that it can be used by other modules for their related behat tests. --- client/dist/js/TinyMCE_sslink-file.js | 2 +- client/src/entwine/TinyMCE_sslink-file.js | 5 +- composer.json | 2 +- tests/behat/features/insert-an-image.feature | 14 +++++ tests/behat/src/FixtureContext.php | 64 -------------------- 5 files changed, 17 insertions(+), 70 deletions(-) diff --git a/client/dist/js/TinyMCE_sslink-file.js b/client/dist/js/TinyMCE_sslink-file.js index 64dd7407e..404f79d3f 100644 --- a/client/dist/js/TinyMCE_sslink-file.js +++ b/client/dist/js/TinyMCE_sslink-file.js @@ -1 +1 @@ -!function(e){function o(n){if(t[n])return t[n].exports;var s=t[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,o),s.l=!0,s.exports}var t={};o.m=e,o.c=t,o.i=function(e){return e},o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},o.p="",o(o.s="./client/src/entwine/TinyMCE_sslink-file.js")}({"./client/src/entwine/TinyMCE_sslink-file.js":function(e,o,t){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(o,"__esModule",{value:!0});var s=t(2),r=n(s),a=t(30),d=n(a),l=t(0),i=n(l),u=t(6),_=n(u),c=t(7),h=n(c),f=t(10),p=n(f),m=t(12),j=n(m),v=t(3),y=n(v),g=t("./client/src/state/modal/ModalActions.js"),b=function(e){if(e&&e.__esModule)return e;var o={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(o[t]=e[t]);return o.default=e,o}(g);d.default.addAction("sslink",{text:r.default._t("AssetAdmin.LINKLABEL_FILE","Link to a file"),onclick:function(e){return e.execCommand("sslinkfile")},priority:80},editorIdentifier).addCommandWithUrlTest("sslinkfile",/^\[file_link/);var S={init:function(e){e.addCommand("sslinkfile",function(){(0,h.default)("#"+e.id).entwine("ss").openLinkFileDialog()})}},x="insert-link__dialog-wrapper--file",C=(0,v.loadComponent)(j.default);h.default.entwine("ss",function(e){e("textarea.htmleditor").entwine({openLinkFileDialog:function(){var o=e("#"+x);o.length||(o=e('
'),e("body").append(o)),o.addClass("insert-link__dialog-wrapper"),o.setElement(this),o.open()}}),e(".js-injector-boot #"+x).entwine({renderModal:function(e){var o=this,t=y.default.reducer.store.dispatch;t(b.initFormStack("insert-link","admin"));var n=function(){t(b.reset()),o.close()},s=function(){return o.handleInsert.apply(o,arguments)},r=this.getOriginalAttributes(),a=tinymce.activeEditor.selection,d=this.getFolderId(),l=a.getContent()||"",u=a.getNode().tagName,c="A"!==u&&""===l.trim();_.default.render(i.default.createElement(C,{isOpen:e,type:"insert-link",folderId:d,onInsert:s,onClosed:n,title:!1,bodyClassName:"modal__dialog",className:"insert-link__dialog-wrapper--internal",fileAttributes:r,requireLinkText:c}),this[0])},buildAttributes:function(e){return{href:p.default.serialise({name:"file_link",properties:{id:e.ID}},!0)+(e.Anchor&&e.Anchor.length?"#"+e.Anchor:""),target:e.TargetBlank?"_blank":"",title:e.Description}},getFolderId:function(){var e=this.getElement();if(!e)return null;var o=Number(e.data("config").upload_folder_id);return isNaN(o)?null:o},getOriginalAttributes:function(){var o=this.getElement().getEditor(),t=e(o.getSelectedNode()),n=(t.attr("href")||"").split("#");if(!n[0])return{};var s=p.default.match("file_link",!1,n[0]);return s?{ID:s.properties.id?parseInt(s.properties.id,10):0,Anchor:n[1]||"",Description:t.attr("title"),TargetBlank:!!t.attr("target")}:{}}})}),tinymce.PluginManager.add("sslinkfile",function(e){return S.init(e)}),o.default=S},"./client/src/state/modal/ModalActionTypes.js":function(e,o,t){"use strict";Object.defineProperty(o,"__esModule",{value:!0}),o.default={DEFINE_IMAGE_SIZE_PRESETS:"DEFINE_IMAGE_SIZE_PRESETS",INIT_FORM_SCHEMA_STACK:"INIT_FORM_SCHEMA_STACK",POP_FORM_SCHEMA:"POP_FORM_SCHEMA",PUSH_FORM_SCHEMA:"PUSH_FORM_SCHEMA",RESET:"RESET",RESET_FORM_STACK:"RESET_FORM_STACK"}},"./client/src/state/modal/ModalActions.js":function(e,o,t){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function s(e){return{type:c.default.DEFINE_IMAGE_SIZE_PRESETS,payload:{imageSizePresets:e}}}function r(e,o){return function(t,n){var s=n(),r=(0,f.default)(s.form.formState,e+".values"),a=(0,f.default)(s.form.formSchemas,o+".schema.fields");if(r){var d=Object.keys(r).filter(function(e){return null!==r[e]&&(0,j.default)(e,a)}).map(function(e){return{name:e,value:r[e]}});t((0,p.setSchemaStateOverrides)(o,{fields:d}))}}}function a(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return{type:c.default.PUSH_FORM_SCHEMA,payload:{formSchema:{type:e,nextType:o}}}}function d(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return{type:c.default.INIT_FORM_SCHEMA_STACK,payload:{formSchema:{type:e,nextType:o}}}}function l(){return{type:c.default.POP_FORM_SCHEMA}}function i(){return{type:c.default.RESET}}function u(){return{type:c.default.RESET_FORM_STACK}}Object.defineProperty(o,"__esModule",{value:!0}),o.defineImageSizePresets=s,o.stashFormValues=r,o.pushFormStackEntry=a,o.initFormStack=d,o.popFormStackEntry=l,o.reset=i,o.resetFormStack=u;var _=t("./client/src/state/modal/ModalActionTypes.js"),c=n(_),h=t("./node_modules/redux-form/lib/structure/plain/getIn.js"),f=n(h),p=t(8),m=t("./client/src/state/modal/helpers.js"),j=n(m)},"./client/src/state/modal/helpers.js":function(e,o,t){"use strict";function n(e,o){var t=void 0;for(t=0;t-1}var s=t("./node_modules/lodash/_assocIndexOf.js");e.exports=n},"./node_modules/lodash/_listCacheSet.js":function(e,o,t){function n(e,o){var t=this.__data__,n=s(t,e);return n<0?(++this.size,t.push([e,o])):t[n][1]=o,this}var s=t("./node_modules/lodash/_assocIndexOf.js");e.exports=n},"./node_modules/lodash/_mapCacheClear.js":function(e,o,t){function n(){this.size=0,this.__data__={hash:new s,map:new(a||r),string:new s}}var s=t("./node_modules/lodash/_Hash.js"),r=t("./node_modules/lodash/_ListCache.js"),a=t("./node_modules/lodash/_Map.js");e.exports=n},"./node_modules/lodash/_mapCacheDelete.js":function(e,o,t){function n(e){var o=s(this,e).delete(e);return this.size-=o?1:0,o}var s=t("./node_modules/lodash/_getMapData.js");e.exports=n},"./node_modules/lodash/_mapCacheGet.js":function(e,o,t){function n(e){return s(this,e).get(e)}var s=t("./node_modules/lodash/_getMapData.js");e.exports=n},"./node_modules/lodash/_mapCacheHas.js":function(e,o,t){function n(e){return s(this,e).has(e)}var s=t("./node_modules/lodash/_getMapData.js");e.exports=n},"./node_modules/lodash/_mapCacheSet.js":function(e,o,t){function n(e,o){var t=s(this,e),n=t.size;return t.set(e,o),this.size+=t.size==n?0:1,this}var s=t("./node_modules/lodash/_getMapData.js");e.exports=n},"./node_modules/lodash/_memoizeCapped.js":function(e,o,t){function n(e){var o=s(e,function(e){return t.size===r&&t.clear(),e}),t=o.cache;return o}var s=t("./node_modules/lodash/memoize.js"),r=500;e.exports=n},"./node_modules/lodash/_nativeCreate.js":function(e,o,t){var n=t("./node_modules/lodash/_getNative.js"),s=n(Object,"create");e.exports=s},"./node_modules/lodash/_objectToString.js":function(e,o){function t(e){return s.call(e)}var n=Object.prototype,s=n.toString;e.exports=t},"./node_modules/lodash/_root.js":function(e,o,t){var n=t("./node_modules/lodash/_freeGlobal.js"),s="object"==typeof self&&self&&self.Object===Object&&self,r=n||s||Function("return this")();e.exports=r},"./node_modules/lodash/_stringToPath.js":function(e,o,t){var n=t("./node_modules/lodash/_memoizeCapped.js"),s=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,a=n(function(e){var o=[];return 46===e.charCodeAt(0)&&o.push(""),e.replace(s,function(e,t,n,s){o.push(n?s.replace(r,"$1"):t||e)}),o});e.exports=a},"./node_modules/lodash/_toKey.js":function(e,o,t){function n(e){if("string"==typeof e||s(e))return e;var o=e+"";return"0"==o&&1/e==-r?"-0":o}var s=t("./node_modules/lodash/isSymbol.js"),r=1/0;e.exports=n},"./node_modules/lodash/_toSource.js":function(e,o){function t(e){if(null!=e){try{return s.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var n=Function.prototype,s=n.toString;e.exports=t},"./node_modules/lodash/eq.js":function(e,o){function t(e,o){return e===o||e!==e&&o!==o}e.exports=t},"./node_modules/lodash/isArray.js":function(e,o){var t=Array.isArray;e.exports=t},"./node_modules/lodash/isFunction.js":function(e,o,t){function n(e){if(!r(e))return!1;var o=s(e);return o==d||o==l||o==a||o==i}var s=t("./node_modules/lodash/_baseGetTag.js"),r=t("./node_modules/lodash/isObject.js"),a="[object AsyncFunction]",d="[object Function]",l="[object GeneratorFunction]",i="[object Proxy]";e.exports=n},"./node_modules/lodash/isObject.js":function(e,o){function t(e){var o=typeof e;return null!=e&&("object"==o||"function"==o)}e.exports=t},"./node_modules/lodash/isObjectLike.js":function(e,o){function t(e){return null!=e&&"object"==typeof e}e.exports=t},"./node_modules/lodash/isSymbol.js":function(e,o,t){function n(e){return"symbol"==typeof e||r(e)&&s(e)==a}var s=t("./node_modules/lodash/_baseGetTag.js"),r=t("./node_modules/lodash/isObjectLike.js"),a="[object Symbol]";e.exports=n},"./node_modules/lodash/memoize.js":function(e,o,t){function n(e,o){if("function"!=typeof e||null!=o&&"function"!=typeof o)throw new TypeError(r);var t=function(){var n=arguments,s=o?o.apply(this,n):n[0],r=t.cache;if(r.has(s))return r.get(s);var a=e.apply(this,n);return t.cache=r.set(s,a)||r,a};return t.cache=new(n.Cache||s),t}var s=t("./node_modules/lodash/_MapCache.js"),r="Expected a function";n.Cache=s,e.exports=n},"./node_modules/lodash/toPath.js":function(e,o,t){function n(e){return a(e)?s(e,i):d(e)?[e]:r(l(u(e)))}var s=t("./node_modules/lodash/_arrayMap.js"),r=t("./node_modules/lodash/_copyArray.js"),a=t("./node_modules/lodash/isArray.js"),d=t("./node_modules/lodash/isSymbol.js"),l=t("./node_modules/lodash/_stringToPath.js"),i=t("./node_modules/lodash/_toKey.js"),u=t("./node_modules/lodash/toString.js");e.exports=n},"./node_modules/lodash/toString.js":function(e,o,t){function n(e){return null==e?"":s(e)}var s=t("./node_modules/lodash/_baseToString.js");e.exports=n},"./node_modules/redux-form/lib/structure/plain/getIn.js":function(e,o,t){"use strict";Object.defineProperty(o,"__esModule",{value:!0});var n=t("./node_modules/lodash/toPath.js"),s=function(e){return e&&e.__esModule?e:{default:e}}(n),r=function(e,o){if(!e)return e;var t=(0,s.default)(o),n=t.length;if(n){for(var r=e,a=0;a'),e("body").append(o)),o.addClass("insert-link__dialog-wrapper"),o.setElement(this),o.open()}}),e(".js-injector-boot #"+S).entwine({renderModal:function(e){var o=this,t=y.default.reducer.store.dispatch;t(b.initFormStack("insert-link","admin"));var n=function(){t(b.reset()),o.close()},s=function(){return o.handleInsert.apply(o,arguments)},r=this.getOriginalAttributes(),a=this.getFolderId(),d=this.getRequireLinkText();_.default.render(i.default.createElement(C,{isOpen:e,type:"insert-link",folderId:a,onInsert:s,onClosed:n,title:!1,bodyClassName:"modal__dialog",className:"insert-link__dialog-wrapper--internal",fileAttributes:r,requireLinkText:d}),this[0])},buildAttributes:function(e){return{href:p.default.serialise({name:"file_link",properties:{id:e.ID}},!0)+(e.Anchor&&e.Anchor.length?"#"+e.Anchor:""),target:e.TargetBlank?"_blank":"",title:e.Description}},getFolderId:function(){var e=this.getElement();if(!e)return null;var o=Number(e.data("config").upload_folder_id);return isNaN(o)?null:o},getOriginalAttributes:function(){var o=this.getElement().getEditor(),t=e(o.getSelectedNode()),n=(t.attr("href")||"").split("#");if(!n[0])return{};var s=p.default.match("file_link",!1,n[0]);return s?{ID:s.properties.id?parseInt(s.properties.id,10):0,Anchor:n[1]||"",Description:t.attr("title"),TargetBlank:!!t.attr("target")}:{}}})}),tinymce.PluginManager.add("sslinkfile",function(e){return x.init(e)}),o.default=x},"./client/src/state/modal/ModalActionTypes.js":function(e,o,t){"use strict";Object.defineProperty(o,"__esModule",{value:!0}),o.default={DEFINE_IMAGE_SIZE_PRESETS:"DEFINE_IMAGE_SIZE_PRESETS",INIT_FORM_SCHEMA_STACK:"INIT_FORM_SCHEMA_STACK",POP_FORM_SCHEMA:"POP_FORM_SCHEMA",PUSH_FORM_SCHEMA:"PUSH_FORM_SCHEMA",RESET:"RESET",RESET_FORM_STACK:"RESET_FORM_STACK"}},"./client/src/state/modal/ModalActions.js":function(e,o,t){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function s(e){return{type:c.default.DEFINE_IMAGE_SIZE_PRESETS,payload:{imageSizePresets:e}}}function r(e,o){return function(t,n){var s=n(),r=(0,f.default)(s.form.formState,e+".values"),a=(0,f.default)(s.form.formSchemas,o+".schema.fields");if(r){var d=Object.keys(r).filter(function(e){return null!==r[e]&&(0,j.default)(e,a)}).map(function(e){return{name:e,value:r[e]}});t((0,p.setSchemaStateOverrides)(o,{fields:d}))}}}function a(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return{type:c.default.PUSH_FORM_SCHEMA,payload:{formSchema:{type:e,nextType:o}}}}function d(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return{type:c.default.INIT_FORM_SCHEMA_STACK,payload:{formSchema:{type:e,nextType:o}}}}function l(){return{type:c.default.POP_FORM_SCHEMA}}function i(){return{type:c.default.RESET}}function u(){return{type:c.default.RESET_FORM_STACK}}Object.defineProperty(o,"__esModule",{value:!0}),o.defineImageSizePresets=s,o.stashFormValues=r,o.pushFormStackEntry=a,o.initFormStack=d,o.popFormStackEntry=l,o.reset=i,o.resetFormStack=u;var _=t("./client/src/state/modal/ModalActionTypes.js"),c=n(_),h=t("./node_modules/redux-form/lib/structure/plain/getIn.js"),f=n(h),p=t(8),m=t("./client/src/state/modal/helpers.js"),j=n(m)},"./client/src/state/modal/helpers.js":function(e,o,t){"use strict";function n(e,o){var t=void 0;for(t=0;t-1}var s=t("./node_modules/lodash/_assocIndexOf.js");e.exports=n},"./node_modules/lodash/_listCacheSet.js":function(e,o,t){function n(e,o){var t=this.__data__,n=s(t,e);return n<0?(++this.size,t.push([e,o])):t[n][1]=o,this}var s=t("./node_modules/lodash/_assocIndexOf.js");e.exports=n},"./node_modules/lodash/_mapCacheClear.js":function(e,o,t){function n(){this.size=0,this.__data__={hash:new s,map:new(a||r),string:new s}}var s=t("./node_modules/lodash/_Hash.js"),r=t("./node_modules/lodash/_ListCache.js"),a=t("./node_modules/lodash/_Map.js");e.exports=n},"./node_modules/lodash/_mapCacheDelete.js":function(e,o,t){function n(e){var o=s(this,e).delete(e);return this.size-=o?1:0,o}var s=t("./node_modules/lodash/_getMapData.js");e.exports=n},"./node_modules/lodash/_mapCacheGet.js":function(e,o,t){function n(e){return s(this,e).get(e)}var s=t("./node_modules/lodash/_getMapData.js");e.exports=n},"./node_modules/lodash/_mapCacheHas.js":function(e,o,t){function n(e){return s(this,e).has(e)}var s=t("./node_modules/lodash/_getMapData.js");e.exports=n},"./node_modules/lodash/_mapCacheSet.js":function(e,o,t){function n(e,o){var t=s(this,e),n=t.size;return t.set(e,o),this.size+=t.size==n?0:1,this}var s=t("./node_modules/lodash/_getMapData.js");e.exports=n},"./node_modules/lodash/_memoizeCapped.js":function(e,o,t){function n(e){var o=s(e,function(e){return t.size===r&&t.clear(),e}),t=o.cache;return o}var s=t("./node_modules/lodash/memoize.js"),r=500;e.exports=n},"./node_modules/lodash/_nativeCreate.js":function(e,o,t){var n=t("./node_modules/lodash/_getNative.js"),s=n(Object,"create");e.exports=s},"./node_modules/lodash/_objectToString.js":function(e,o){function t(e){return s.call(e)}var n=Object.prototype,s=n.toString;e.exports=t},"./node_modules/lodash/_root.js":function(e,o,t){var n=t("./node_modules/lodash/_freeGlobal.js"),s="object"==typeof self&&self&&self.Object===Object&&self,r=n||s||Function("return this")();e.exports=r},"./node_modules/lodash/_stringToPath.js":function(e,o,t){var n=t("./node_modules/lodash/_memoizeCapped.js"),s=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,a=n(function(e){var o=[];return 46===e.charCodeAt(0)&&o.push(""),e.replace(s,function(e,t,n,s){o.push(n?s.replace(r,"$1"):t||e)}),o});e.exports=a},"./node_modules/lodash/_toKey.js":function(e,o,t){function n(e){if("string"==typeof e||s(e))return e;var o=e+"";return"0"==o&&1/e==-r?"-0":o}var s=t("./node_modules/lodash/isSymbol.js"),r=1/0;e.exports=n},"./node_modules/lodash/_toSource.js":function(e,o){function t(e){if(null!=e){try{return s.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var n=Function.prototype,s=n.toString;e.exports=t},"./node_modules/lodash/eq.js":function(e,o){function t(e,o){return e===o||e!==e&&o!==o}e.exports=t},"./node_modules/lodash/isArray.js":function(e,o){var t=Array.isArray;e.exports=t},"./node_modules/lodash/isFunction.js":function(e,o,t){function n(e){if(!r(e))return!1;var o=s(e);return o==d||o==l||o==a||o==i}var s=t("./node_modules/lodash/_baseGetTag.js"),r=t("./node_modules/lodash/isObject.js"),a="[object AsyncFunction]",d="[object Function]",l="[object GeneratorFunction]",i="[object Proxy]";e.exports=n},"./node_modules/lodash/isObject.js":function(e,o){function t(e){var o=typeof e;return null!=e&&("object"==o||"function"==o)}e.exports=t},"./node_modules/lodash/isObjectLike.js":function(e,o){function t(e){return null!=e&&"object"==typeof e}e.exports=t},"./node_modules/lodash/isSymbol.js":function(e,o,t){function n(e){return"symbol"==typeof e||r(e)&&s(e)==a}var s=t("./node_modules/lodash/_baseGetTag.js"),r=t("./node_modules/lodash/isObjectLike.js"),a="[object Symbol]";e.exports=n},"./node_modules/lodash/memoize.js":function(e,o,t){function n(e,o){if("function"!=typeof e||null!=o&&"function"!=typeof o)throw new TypeError(r);var t=function(){var n=arguments,s=o?o.apply(this,n):n[0],r=t.cache;if(r.has(s))return r.get(s);var a=e.apply(this,n);return t.cache=r.set(s,a)||r,a};return t.cache=new(n.Cache||s),t}var s=t("./node_modules/lodash/_MapCache.js"),r="Expected a function";n.Cache=s,e.exports=n},"./node_modules/lodash/toPath.js":function(e,o,t){function n(e){return a(e)?s(e,i):d(e)?[e]:r(l(u(e)))}var s=t("./node_modules/lodash/_arrayMap.js"),r=t("./node_modules/lodash/_copyArray.js"),a=t("./node_modules/lodash/isArray.js"),d=t("./node_modules/lodash/isSymbol.js"),l=t("./node_modules/lodash/_stringToPath.js"),i=t("./node_modules/lodash/_toKey.js"),u=t("./node_modules/lodash/toString.js");e.exports=n},"./node_modules/lodash/toString.js":function(e,o,t){function n(e){return null==e?"":s(e)}var s=t("./node_modules/lodash/_baseToString.js");e.exports=n},"./node_modules/redux-form/lib/structure/plain/getIn.js":function(e,o,t){"use strict";Object.defineProperty(o,"__esModule",{value:!0});var n=t("./node_modules/lodash/toPath.js"),s=function(e){return e&&e.__esModule?e:{default:e}}(n),r=function(e,o){if(!e)return e;var t=(0,s.default)(o),n=t.length;if(n){for(var r=e,a=0;a { const handleInsert = (...args) => this.handleInsert(...args); const attrs = this.getOriginalAttributes(); - const selection = tinymce.activeEditor.selection; const folderId = this.getFolderId(); - const selectionContent = selection.getContent() || ''; - const tagName = selection.getNode().tagName; - const requireLinkText = tagName !== 'A' && selectionContent.trim() === ''; + const requireLinkText = this.getRequireLinkText(); // create/update the react component ReactDOM.render( diff --git a/composer.json b/composer.json index 255ad6a45..d3ab700ab 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "require": { "php": "^7.4 || ^8.0", "silverstripe/framework": "^4.11", - "silverstripe/admin": "^1.7", + "silverstripe/admin": "^1.13", "silverstripe/graphql": "^3.5 || ^4" }, "require-dev": { diff --git a/tests/behat/features/insert-an-image.feature b/tests/behat/features/insert-an-image.feature index 2ef4f929b..42cc5192d 100644 --- a/tests/behat/features/insert-an-image.feature +++ b/tests/behat/features/insert-an-image.feature @@ -154,3 +154,17 @@ Feature: Insert an image into a page Then I should see the "Form_fileInsertForm" form And the "Description" field should contain "My file" And I should see "Link to file" in the "button[name=action_insert]" element + + Scenario: I can wrap an image in a link to a file + Given I fill in the "Content" HTML field with "

" + When I select the image "file1.jpg" in the "Content" HTML field + And I press the "Insert link" HTML field button + And I click "Link to a file" in the ".mce-menu" element + And I select the file named "folder1" in the gallery + And I click on the file named "file1" in the gallery + Then I should see the "Form_fileInsertForm" form + And I should not see "Link text" + And I press the "Link to file" button + Then the "Content" HTML field should contain "" + # Required to avoid "unsaved changed" browser dialog + And I press the "Save" button diff --git a/tests/behat/src/FixtureContext.php b/tests/behat/src/FixtureContext.php index b62b93c4b..35a4b29a8 100644 --- a/tests/behat/src/FixtureContext.php +++ b/tests/behat/src/FixtureContext.php @@ -442,70 +442,6 @@ public function iShouldSeeTheTableGalleryFolderInPosition(string $name, string $ Assert::assertNotNull($title, sprintf('Folder at position %s should be named %s', $position, $name)); } - /** - * Selects the first image match in the HTML editor (tinymce) - * - * @When /^I select the image "([^"]+)" in the "([^"]+)" HTML field$/ - * @param string $filename - * @param string $field - */ - public function iSelectTheImageInHtmlField($filename, $field) - { - $this->selectInTheHtmlField("img[src*='$filename']", $field); - } - - /** - * Selects the first match of $select in the given HTML editor (tinymce) - */ - protected function selectInTheHtmlField(string $select, string $field) - { - $inputField = $this->getHtmlField($field); - $inputField->getParent()->find('css', 'iframe')->click(); - $inputFieldId = $inputField->getAttribute('id'); - $js = <<getMainContext()->getSession()->executeScript($js); - } - - /** - * Locate an HTML editor field - * - * @param string $locator Raw html field identifier as passed from - * @return NodeElement - */ - protected function getHtmlField($locator) - { - $locator = str_replace('\\"', '"', $locator ?? ''); - $page = $this->getMainContext()->getSession()->getPage(); - $element = $page->find('css', 'textarea.htmleditor[name=\'' . $locator . '\']'); - if ($element) { - return $element; - } - $label = $page->findAll('xpath', sprintf('//label[contains(text(), \'%s\')]', $locator)); - if (!empty($label)) { - Assert::assertCount(1, $label, "Found more than one element containing the phrase \"$locator\""); - $label = array_shift($label); - $fieldId = $label->getAttribute('for'); - $element = $page->find('css', '#' . $fieldId); - } - Assert::assertNotNull($element, sprintf('HTML field "%s" not found', $locator)); - return $element; - } - /** * @When /^I scroll the editor details panel to the top$/ */ From 03973f987a3a0b56890c5013af02899528ebab18 Mon Sep 17 00:00:00 2001 From: Sabina Talipova <87288324+sabina-talipova@users.noreply.github.com> Date: Thu, 7 Sep 2023 13:24:05 +1200 Subject: [PATCH 2/2] FIX Image tag is converted to shortcode even if it doesn't have parent node (#1395) --- client/dist/js/TinyMCE_ssmedia.js | 2 +- client/src/entwine/TinyMCE_ssmedia.js | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/client/dist/js/TinyMCE_ssmedia.js b/client/dist/js/TinyMCE_ssmedia.js index 4ad4fb8b6..93204ffbf 100644 --- a/client/dist/js/TinyMCE_ssmedia.js +++ b/client/dist/js/TinyMCE_ssmedia.js @@ -1 +1 @@ -!function(e){function t(n){if(o[n])return o[n].exports;var s=o[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,t),s.l=!0,s.exports}var o={};t.m=e,t.c=o,t.i=function(e){return e},t.d=function(e,o,n){t.o(e,o)||Object.defineProperty(e,o,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,"a",o),o},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s="./client/src/entwine/TinyMCE_ssmedia.js")}({"./client/src/entwine/TinyMCE_ssmedia.js":function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function s(e,t){var o={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(o[n]=e[n]);return o}var a=o(7),r=n(a),i=o(2),d=n(i),l=o(0),u=n(l),c=o(6),h=n(c),_=o(3),f=n(_),m=o(12),p=n(m),v=o(10),g=n(v),j=o("./client/src/entwine/TinyMCE_ssmedia_sizepressets.js"),y=o("./client/src/state/modal/ModalActions.js"),b=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t.default=e,t}(y),x=(0,_.loadComponent)(p.default),S='img[data-shortcode="image"]';!function(){var e={init:function(e){var t=d.default._t("AssetAdmin.INSERT_FROM_FILES","Insert from Files"),o=d.default._t("AssetAdmin.EDIT_IMAGE","Edit image"),n=d.default._t("AssetAdmin.FILE","File");e.addButton("ssmedia",{title:t,icon:"image",cmd:"ssmedia",stateSelector:S}),e.addMenuItem("ssmedia",{text:n,icon:"image",cmd:"ssmedia"}),e.addButton("ssmediaedit",{title:o,icon:"editimage",cmd:"ssmedia"});var s=e.getParam("image_size_presets"),a=[];s&&(a=(0,j.imageSizePresetButtons)(e,s)),e.addContextToolbar(function(t){return e.dom.is(t,S)},a.join(" ")+" | ssmediaedit"),e.addCommand("ssmedia",function(){(0,r.default)("#"+e.id).entwine("ss").openMediaDialog()}),e.on("BeforeExecCommand",function(t){var o=t.command,n=t.ui,s=t.value;"mceAdvImage"!==o&&"mceImage"!==o||(t.preventDefault(),e.execCommand("ssmedia",n,s))}),e.on("SaveContent",function(e){var t=(0,r.default)(e.content);t.find(S).add(t.filter(S)).each(function(){var e=(0,r.default)(this),t={src:e.attr("src"),id:e.data("id"),width:e.attr("width"),height:e.attr("height"),class:e.attr("class"),title:e.attr("title"),alt:e.attr("alt"),loading:e.data("loading")},o=g.default.serialise({name:"image",properties:(0,v.sanitiseShortCodeProperties)(t),wrapped:!1});e.replaceWith(o)}),e.content="",t.each(function(){void 0!==this.outerHTML&&(e.content+=this.outerHTML)})}),e.on("BeforeSetContent",function(e){for(var t=e.content,o=g.default.match("image",!1,t);o;){var n=o.properties,s=(0,r.default)("").attr(Object.assign({},n,{id:void 0,"data-id":n.id,"data-shortcode":"image","data-loading":n.loading})).addClass("ss-htmleditorfield-file image");t=t.replace(o.original,(0,r.default)("
").append(s).html()),o=g.default.match("image",!1,t)}e.content=t})}};tinymce.PluginManager.add("ssmedia",function(t){return e.init(t)})}(),r.default.entwine("ss",function(e){e(".js-injector-boot #insert-media-react__dialog-wrapper").entwine({Element:null,Data:{},onunmatch:function(){this._clearModal()},_clearModal:function(){h.default.unmountComponentAtNode(this[0])},open:function(){var e=f.default.reducer.store.dispatch;e(b.initFormStack("insert-media","admin"));var t=tinymce.activeEditor.getParam("image_size_presets");e(b.defineImageSizePresets(t)),this._renderModal(!0)},close:function(){(0,f.default.reducer.store.dispatch)(b.reset()),this._renderModal(!1)},_renderModal:function(e){var t=this,o=function(){return t.close()},n=function(){return t._handleInsert.apply(t,arguments)},a=this.getOriginalAttributes(),r=(a.url,s(a,["url"])),i=r.hasOwnProperty("ID")&&null!==r.ID,d=this.getFolderId(),l=tinymce.activeEditor.selection,c=l.getContent()||"",_=l.getNode().tagName,f="A"!==_&&("IMG"===_||""===c.trim());h.default.render(u.default.createElement(x,{title:!1,isOpen:e,folderId:d,onInsert:n,onClosed:o,bodyClassName:"modal__dialog",className:"insert-media-react__dialog-wrapper",requireLinkText:f,fileAttributes:r,fileSelected:i}),this[0])},_handleInsert:function(e,t){var o=!1;this.setData(Object.assign({},e,t));try{switch(t?t.category:"image"){case"image":o=this.insertImage();break;default:o=this.insertFile()}}catch(e){this.statusMessage(e,"bad")}return o&&this.close(),Promise.resolve()},getFolderId:function(){var e=this.getElement();if(!e)return null;var t=Number(e.data("config").upload_folder_id);return isNaN(t)?null:t},getOriginalAttributes:function(){var t=this.getElement();if(!t)return{};var o=t.getEditor().getSelectedNode();if(!o)return{};var n=e(o),s=(n.attr("href")||"").split("#");if(s[0]){var a=g.default.match("file_link",!1,s[0]);if(a)return{ID:a.properties.id?parseInt(a.properties.id,10):0,Anchor:s[1]||"",Description:n.attr("title"),TargetBlank:!!n.attr("target")}}var r=n.parent(".captionImage").find(".caption"),i={url:n.attr("src"),AltText:n.attr("alt"),Width:n.attr("width"),Height:n.attr("height"),Loading:n.attr("data-loading"),TitleTooltip:n.attr("title"),Alignment:this.findPosition(n.attr("class")),Caption:r.text(),ID:n.attr("data-id")};return["Width","Height","ID"].forEach(function(e){i[e]="string"==typeof i[e]?parseInt(i[e],10):null}),i},findPosition:function(e){var t=["leftAlone","center","rightAlone","left","right"];if("string"!=typeof e)return"";var o=e.split(" ");return t.find(function(e){return o.indexOf(e)>-1})},getAttributes:function(){var e=this.getData();return{src:e.url,alt:e.AltText,width:e.Width,height:e.Height,title:e.TitleTooltip,class:e.Alignment,"data-id":e.ID,"data-shortcode":"image","data-loading":e.Loading}},getExtraData:function(){var e=this.getData();return{CaptionText:e&&e.Caption}},insertFile:function(){var t=this.getData(),o=this.getElement().getEditor(),n=e(o.getSelectedNode()),s=g.default.serialise({name:"file_link",properties:{id:t.ID}},!0),a=tinymce.activeEditor.selection,r=a.getContent()||"",i=r||t.Text||t.filename;n.is("a")&&n.html()&&(i="");var d={href:s,target:t.TargetBlank?"_blank":"",title:t.Description};if(n.is("img")){i=t.Text||t.filename;var l=e("").attr(d).text(i);n.replaceWith(l),o.addUndo(),o.repaint()}else this.insertLinkInEditor(d,i);return!0},insertImage:function(){var t=this.getElement();if(!t)return!1;var o=t.getEditor();if(!o)return!1;var n=e(o.getSelectedNode()),s=this.getAttributes(),a=this.getExtraData(),r=n&&n.is("img,a")?n:null;r&&r.parent().is(".captionImage")&&(r=r.parent());var i=n&&n.is("img")?n:e("");i.attr(s).addClass("ss-htmleditorfield-file image");var d=i.parent(".captionImage"),l=d.find(".caption");a.CaptionText?(d.length||(d=e("
")),d.attr("class","captionImage "+s.class).removeAttr("data-mce-style").width(s.width),l.length||(l=e('

').appendTo(d)),l.attr("class","caption "+s.class).text(a.CaptionText)):(d=null,l=null);var u=d||i;return r&&r.not(u).length&&r.replaceWith(u),d&&d.prepend(i),r||(o.repaint(),o.insertContent(e("
").append(u).html(),{skip_undo:1})),o.addUndo(),o.repaint(),!0},statusMessage:function(t,o){var n=e("
").text(t).html();e.noticeAdd({text:n,type:o,stayTime:5e3,inEffect:{left:"0",opacity:"show"}})}})})},"./client/src/entwine/TinyMCE_ssmedia_sizepressets.js":function(e,t,o){"use strict";function n(e,t){var o=t.name,n=t.width,s=t.text,a="ssmedia"+o;e.on("init",function(){e.formatter.register(a,{selector:"img",attributes:{width:n?n.toString():""}})});var r=function(){var t=e.selection.getNode();return"IMG"!==t.tagName&&t.children.item("img")&&(t=t.children.item("img")),t&&"IMG"===t.tagName?t:void 0},i=function(e){var t=r();e.disabled(!(!t||!n)&&t.naturalWidth1&&void 0!==arguments[1]?arguments[1]:void 0;return{type:h.default.PUSH_FORM_SCHEMA,payload:{formSchema:{type:e,nextType:t}}}}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return{type:h.default.INIT_FORM_SCHEMA_STACK,payload:{formSchema:{type:e,nextType:t}}}}function d(){return{type:h.default.POP_FORM_SCHEMA}}function l(){return{type:h.default.RESET}}function u(){return{type:h.default.RESET_FORM_STACK}}Object.defineProperty(t,"__esModule",{value:!0}),t.defineImageSizePresets=s,t.stashFormValues=a,t.pushFormStackEntry=r,t.initFormStack=i,t.popFormStackEntry=d,t.reset=l,t.resetFormStack=u;var c=o("./client/src/state/modal/ModalActionTypes.js"),h=n(c),_=o("./node_modules/redux-form/lib/structure/plain/getIn.js"),f=n(_),m=o(8),p=o("./client/src/state/modal/helpers.js"),v=n(p)},"./client/src/state/modal/helpers.js":function(e,t,o){"use strict";function n(e,t){var o=void 0;for(o=0;o-1}var s=o("./node_modules/lodash/_assocIndexOf.js");e.exports=n},"./node_modules/lodash/_listCacheSet.js":function(e,t,o){function n(e,t){var o=this.__data__,n=s(o,e);return n<0?(++this.size,o.push([e,t])):o[n][1]=t,this}var s=o("./node_modules/lodash/_assocIndexOf.js");e.exports=n},"./node_modules/lodash/_mapCacheClear.js":function(e,t,o){function n(){this.size=0,this.__data__={hash:new s,map:new(r||a),string:new s}}var s=o("./node_modules/lodash/_Hash.js"),a=o("./node_modules/lodash/_ListCache.js"),r=o("./node_modules/lodash/_Map.js");e.exports=n},"./node_modules/lodash/_mapCacheDelete.js":function(e,t,o){function n(e){var t=s(this,e).delete(e);return this.size-=t?1:0,t}var s=o("./node_modules/lodash/_getMapData.js");e.exports=n},"./node_modules/lodash/_mapCacheGet.js":function(e,t,o){function n(e){return s(this,e).get(e)}var s=o("./node_modules/lodash/_getMapData.js");e.exports=n},"./node_modules/lodash/_mapCacheHas.js":function(e,t,o){function n(e){return s(this,e).has(e)}var s=o("./node_modules/lodash/_getMapData.js");e.exports=n},"./node_modules/lodash/_mapCacheSet.js":function(e,t,o){function n(e,t){var o=s(this,e),n=o.size;return o.set(e,t),this.size+=o.size==n?0:1,this}var s=o("./node_modules/lodash/_getMapData.js");e.exports=n},"./node_modules/lodash/_memoizeCapped.js":function(e,t,o){function n(e){var t=s(e,function(e){return o.size===a&&o.clear(),e}),o=t.cache;return t}var s=o("./node_modules/lodash/memoize.js"),a=500;e.exports=n},"./node_modules/lodash/_nativeCreate.js":function(e,t,o){var n=o("./node_modules/lodash/_getNative.js"),s=n(Object,"create");e.exports=s},"./node_modules/lodash/_objectToString.js":function(e,t){function o(e){return s.call(e)}var n=Object.prototype,s=n.toString;e.exports=o},"./node_modules/lodash/_root.js":function(e,t,o){var n=o("./node_modules/lodash/_freeGlobal.js"),s="object"==typeof self&&self&&self.Object===Object&&self,a=n||s||Function("return this")();e.exports=a},"./node_modules/lodash/_stringToPath.js":function(e,t,o){var n=o("./node_modules/lodash/_memoizeCapped.js"),s=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,a=/\\(\\)?/g,r=n(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(s,function(e,o,n,s){t.push(n?s.replace(a,"$1"):o||e)}),t});e.exports=r},"./node_modules/lodash/_toKey.js":function(e,t,o){function n(e){if("string"==typeof e||s(e))return e;var t=e+"";return"0"==t&&1/e==-a?"-0":t}var s=o("./node_modules/lodash/isSymbol.js"),a=1/0;e.exports=n},"./node_modules/lodash/_toSource.js":function(e,t){function o(e){if(null!=e){try{return s.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var n=Function.prototype,s=n.toString;e.exports=o},"./node_modules/lodash/eq.js":function(e,t){function o(e,t){return e===t||e!==e&&t!==t}e.exports=o},"./node_modules/lodash/isArray.js":function(e,t){var o=Array.isArray;e.exports=o},"./node_modules/lodash/isFunction.js":function(e,t,o){function n(e){if(!a(e))return!1;var t=s(e);return t==i||t==d||t==r||t==l}var s=o("./node_modules/lodash/_baseGetTag.js"),a=o("./node_modules/lodash/isObject.js"),r="[object AsyncFunction]",i="[object Function]",d="[object GeneratorFunction]",l="[object Proxy]";e.exports=n},"./node_modules/lodash/isObject.js":function(e,t){function o(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}e.exports=o},"./node_modules/lodash/isObjectLike.js":function(e,t){function o(e){return null!=e&&"object"==typeof e}e.exports=o},"./node_modules/lodash/isSymbol.js":function(e,t,o){function n(e){return"symbol"==typeof e||a(e)&&s(e)==r}var s=o("./node_modules/lodash/_baseGetTag.js"),a=o("./node_modules/lodash/isObjectLike.js"),r="[object Symbol]";e.exports=n},"./node_modules/lodash/memoize.js":function(e,t,o){function n(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError(a);var o=function(){var n=arguments,s=t?t.apply(this,n):n[0],a=o.cache;if(a.has(s))return a.get(s);var r=e.apply(this,n);return o.cache=a.set(s,r)||a,r};return o.cache=new(n.Cache||s),o}var s=o("./node_modules/lodash/_MapCache.js"),a="Expected a function";n.Cache=s,e.exports=n},"./node_modules/lodash/toPath.js":function(e,t,o){function n(e){return r(e)?s(e,l):i(e)?[e]:a(d(u(e)))}var s=o("./node_modules/lodash/_arrayMap.js"),a=o("./node_modules/lodash/_copyArray.js"),r=o("./node_modules/lodash/isArray.js"),i=o("./node_modules/lodash/isSymbol.js"),d=o("./node_modules/lodash/_stringToPath.js"),l=o("./node_modules/lodash/_toKey.js"),u=o("./node_modules/lodash/toString.js");e.exports=n},"./node_modules/lodash/toString.js":function(e,t,o){function n(e){return null==e?"":s(e)}var s=o("./node_modules/lodash/_baseToString.js");e.exports=n},"./node_modules/redux-form/lib/structure/plain/getIn.js":function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=o("./node_modules/lodash/toPath.js"),s=function(e){return e&&e.__esModule?e:{default:e}}(n),a=function(e,t){if(!e)return e;var o=(0,s.default)(t),n=o.length;if(n){for(var a=e,r=0;r=0||Object.prototype.hasOwnProperty.call(e,n)&&(o[n]=e[n]);return o}var a=o(7),r=n(a),i=o(2),d=n(i),l=o(0),u=n(l),c=o(6),h=n(c),_=o(3),f=n(_),m=o(12),p=n(m),v=o(10),g=n(v),j=o("./client/src/entwine/TinyMCE_ssmedia_sizepressets.js"),y=o("./client/src/state/modal/ModalActions.js"),b=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t.default=e,t}(y),x=(0,_.loadComponent)(p.default),S='img[data-shortcode="image"]';!function(){var e={init:function(e){var t=d.default._t("AssetAdmin.INSERT_FROM_FILES","Insert from Files"),o=d.default._t("AssetAdmin.EDIT_IMAGE","Edit image"),n=d.default._t("AssetAdmin.FILE","File");e.addButton("ssmedia",{title:t,icon:"image",cmd:"ssmedia",stateSelector:S}),e.addMenuItem("ssmedia",{text:n,icon:"image",cmd:"ssmedia"}),e.addButton("ssmediaedit",{title:o,icon:"editimage",cmd:"ssmedia"});var s=e.getParam("image_size_presets"),a=[];s&&(a=(0,j.imageSizePresetButtons)(e,s)),e.addContextToolbar(function(t){return e.dom.is(t,S)},a.join(" ")+" | ssmediaedit"),e.addCommand("ssmedia",function(){(0,r.default)("#"+e.id).entwine("ss").openMediaDialog()}),e.on("BeforeExecCommand",function(t){var o=t.command,n=t.ui,s=t.value;"mceAdvImage"!==o&&"mceImage"!==o||(t.preventDefault(),e.execCommand("ssmedia",n,s))}),e.on("SaveContent",function(e){var t=(0,r.default)("
"+e.content+"
");t.find(S).add(t.filter(S)).each(function(){var e=(0,r.default)(this),t={src:e.attr("src"),id:e.data("id"),width:e.attr("width"),height:e.attr("height"),class:e.attr("class"),title:e.attr("title"),alt:e.attr("alt"),loading:e.data("loading")},o=g.default.serialise({name:"image",properties:(0,v.sanitiseShortCodeProperties)(t),wrapped:!1});e.replaceWith(o)}),e.content="",t.each(function(){void 0!==this.innerHTML&&(e.content+=this.innerHTML)})}),e.on("BeforeSetContent",function(e){for(var t=e.content,o=g.default.match("image",!1,t);o;){var n=o.properties,s=(0,r.default)("").attr(Object.assign({},n,{id:void 0,"data-id":n.id,"data-shortcode":"image","data-loading":n.loading})).addClass("ss-htmleditorfield-file image");t=t.replace(o.original,(0,r.default)("
").append(s).html()),o=g.default.match("image",!1,t)}e.content=t})}};tinymce.PluginManager.add("ssmedia",function(t){return e.init(t)})}(),r.default.entwine("ss",function(e){e(".js-injector-boot #insert-media-react__dialog-wrapper").entwine({Element:null,Data:{},onunmatch:function(){this._clearModal()},_clearModal:function(){h.default.unmountComponentAtNode(this[0])},open:function(){var e=f.default.reducer.store.dispatch;e(b.initFormStack("insert-media","admin"));var t=tinymce.activeEditor.getParam("image_size_presets");e(b.defineImageSizePresets(t)),this._renderModal(!0)},close:function(){(0,f.default.reducer.store.dispatch)(b.reset()),this._renderModal(!1)},_renderModal:function(e){var t=this,o=function(){return t.close()},n=function(){return t._handleInsert.apply(t,arguments)},a=this.getOriginalAttributes(),r=(a.url,s(a,["url"])),i=r.hasOwnProperty("ID")&&null!==r.ID,d=this.getFolderId(),l=tinymce.activeEditor.selection,c=l.getContent()||"",_=l.getNode().tagName,f="A"!==_&&("IMG"===_||""===c.trim());h.default.render(u.default.createElement(x,{title:!1,isOpen:e,folderId:d,onInsert:n,onClosed:o,bodyClassName:"modal__dialog",className:"insert-media-react__dialog-wrapper",requireLinkText:f,fileAttributes:r,fileSelected:i}),this[0])},_handleInsert:function(e,t){var o=!1;this.setData(Object.assign({},e,t));try{switch(t?t.category:"image"){case"image":o=this.insertImage();break;default:o=this.insertFile()}}catch(e){this.statusMessage(e,"bad")}return o&&this.close(),Promise.resolve()},getFolderId:function(){var e=this.getElement();if(!e)return null;var t=Number(e.data("config").upload_folder_id);return isNaN(t)?null:t},getOriginalAttributes:function(){var t=this.getElement();if(!t)return{};var o=t.getEditor().getSelectedNode();if(!o)return{};var n=e(o),s=(n.attr("href")||"").split("#");if(s[0]){var a=g.default.match("file_link",!1,s[0]);if(a)return{ID:a.properties.id?parseInt(a.properties.id,10):0,Anchor:s[1]||"",Description:n.attr("title"),TargetBlank:!!n.attr("target")}}var r=n.parent(".captionImage").find(".caption"),i={url:n.attr("src"),AltText:n.attr("alt"),Width:n.attr("width"),Height:n.attr("height"),Loading:n.attr("data-loading"),TitleTooltip:n.attr("title"),Alignment:this.findPosition(n.attr("class")),Caption:r.text(),ID:n.attr("data-id")};return["Width","Height","ID"].forEach(function(e){i[e]="string"==typeof i[e]?parseInt(i[e],10):null}),i},findPosition:function(e){var t=["leftAlone","center","rightAlone","left","right"];if("string"!=typeof e)return"";var o=e.split(" ");return t.find(function(e){return o.indexOf(e)>-1})},getAttributes:function(){var e=this.getData();return{src:e.url,alt:e.AltText,width:e.Width,height:e.Height,title:e.TitleTooltip,class:e.Alignment,"data-id":e.ID,"data-shortcode":"image","data-loading":e.Loading}},getExtraData:function(){var e=this.getData();return{CaptionText:e&&e.Caption}},insertFile:function(){var t=this.getData(),o=this.getElement().getEditor(),n=e(o.getSelectedNode()),s=g.default.serialise({name:"file_link",properties:{id:t.ID}},!0),a=tinymce.activeEditor.selection,r=a.getContent()||"",i=r||t.Text||t.filename;n.is("a")&&n.html()&&(i="");var d={href:s,target:t.TargetBlank?"_blank":"",title:t.Description};if(n.is("img")){i=t.Text||t.filename;var l=e("").attr(d).text(i);n.replaceWith(l),o.addUndo(),o.repaint()}else this.insertLinkInEditor(d,i);return!0},insertImage:function(){var t=this.getElement();if(!t)return!1;var o=t.getEditor();if(!o)return!1;var n=e(o.getSelectedNode()),s=this.getAttributes(),a=this.getExtraData(),r=n&&n.is("img,a")?n:null;r&&r.parent().is(".captionImage")&&(r=r.parent());var i=n&&n.is("img")?n:e("");i.attr(s).addClass("ss-htmleditorfield-file image");var d=i.parent(".captionImage"),l=d.find(".caption");a.CaptionText?(d.length||(d=e("
")),d.attr("class","captionImage "+s.class).removeAttr("data-mce-style").width(s.width),l.length||(l=e('

').appendTo(d)),l.attr("class","caption "+s.class).text(a.CaptionText)):(d=null,l=null);var u=d||i;return r&&r.not(u).length&&r.replaceWith(u),d&&d.prepend(i),r||(o.repaint(),o.insertContent(e("
").append(u).html(),{skip_undo:1})),o.addUndo(),o.repaint(),!0},statusMessage:function(t,o){var n=e("
").text(t).html();e.noticeAdd({text:n,type:o,stayTime:5e3,inEffect:{left:"0",opacity:"show"}})}})})},"./client/src/entwine/TinyMCE_ssmedia_sizepressets.js":function(e,t,o){"use strict";function n(e,t){var o=t.name,n=t.width,s=t.text,a="ssmedia"+o;e.on("init",function(){e.formatter.register(a,{selector:"img",attributes:{width:n?n.toString():""}})});var r=function(){var t=e.selection.getNode();return"IMG"!==t.tagName&&t.children.item("img")&&(t=t.children.item("img")),t&&"IMG"===t.tagName?t:void 0},i=function(e){var t=r();e.disabled(!(!t||!n)&&t.naturalWidth1&&void 0!==arguments[1]?arguments[1]:void 0;return{type:h.default.PUSH_FORM_SCHEMA,payload:{formSchema:{type:e,nextType:t}}}}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return{type:h.default.INIT_FORM_SCHEMA_STACK,payload:{formSchema:{type:e,nextType:t}}}}function d(){return{type:h.default.POP_FORM_SCHEMA}}function l(){return{type:h.default.RESET}}function u(){return{type:h.default.RESET_FORM_STACK}}Object.defineProperty(t,"__esModule",{value:!0}),t.defineImageSizePresets=s,t.stashFormValues=a,t.pushFormStackEntry=r,t.initFormStack=i,t.popFormStackEntry=d,t.reset=l,t.resetFormStack=u;var c=o("./client/src/state/modal/ModalActionTypes.js"),h=n(c),_=o("./node_modules/redux-form/lib/structure/plain/getIn.js"),f=n(_),m=o(8),p=o("./client/src/state/modal/helpers.js"),v=n(p)},"./client/src/state/modal/helpers.js":function(e,t,o){"use strict";function n(e,t){var o=void 0;for(o=0;o-1}var s=o("./node_modules/lodash/_assocIndexOf.js");e.exports=n},"./node_modules/lodash/_listCacheSet.js":function(e,t,o){function n(e,t){var o=this.__data__,n=s(o,e);return n<0?(++this.size,o.push([e,t])):o[n][1]=t,this}var s=o("./node_modules/lodash/_assocIndexOf.js");e.exports=n},"./node_modules/lodash/_mapCacheClear.js":function(e,t,o){function n(){this.size=0,this.__data__={hash:new s,map:new(r||a),string:new s}}var s=o("./node_modules/lodash/_Hash.js"),a=o("./node_modules/lodash/_ListCache.js"),r=o("./node_modules/lodash/_Map.js");e.exports=n},"./node_modules/lodash/_mapCacheDelete.js":function(e,t,o){function n(e){var t=s(this,e).delete(e);return this.size-=t?1:0,t}var s=o("./node_modules/lodash/_getMapData.js");e.exports=n},"./node_modules/lodash/_mapCacheGet.js":function(e,t,o){function n(e){return s(this,e).get(e)}var s=o("./node_modules/lodash/_getMapData.js");e.exports=n},"./node_modules/lodash/_mapCacheHas.js":function(e,t,o){function n(e){return s(this,e).has(e)}var s=o("./node_modules/lodash/_getMapData.js");e.exports=n},"./node_modules/lodash/_mapCacheSet.js":function(e,t,o){function n(e,t){var o=s(this,e),n=o.size;return o.set(e,t),this.size+=o.size==n?0:1,this}var s=o("./node_modules/lodash/_getMapData.js");e.exports=n},"./node_modules/lodash/_memoizeCapped.js":function(e,t,o){function n(e){var t=s(e,function(e){return o.size===a&&o.clear(),e}),o=t.cache;return t}var s=o("./node_modules/lodash/memoize.js"),a=500;e.exports=n},"./node_modules/lodash/_nativeCreate.js":function(e,t,o){var n=o("./node_modules/lodash/_getNative.js"),s=n(Object,"create");e.exports=s},"./node_modules/lodash/_objectToString.js":function(e,t){function o(e){return s.call(e)}var n=Object.prototype,s=n.toString;e.exports=o},"./node_modules/lodash/_root.js":function(e,t,o){var n=o("./node_modules/lodash/_freeGlobal.js"),s="object"==typeof self&&self&&self.Object===Object&&self,a=n||s||Function("return this")();e.exports=a},"./node_modules/lodash/_stringToPath.js":function(e,t,o){var n=o("./node_modules/lodash/_memoizeCapped.js"),s=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,a=/\\(\\)?/g,r=n(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(s,function(e,o,n,s){t.push(n?s.replace(a,"$1"):o||e)}),t});e.exports=r},"./node_modules/lodash/_toKey.js":function(e,t,o){function n(e){if("string"==typeof e||s(e))return e;var t=e+"";return"0"==t&&1/e==-a?"-0":t}var s=o("./node_modules/lodash/isSymbol.js"),a=1/0;e.exports=n},"./node_modules/lodash/_toSource.js":function(e,t){function o(e){if(null!=e){try{return s.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var n=Function.prototype,s=n.toString;e.exports=o},"./node_modules/lodash/eq.js":function(e,t){function o(e,t){return e===t||e!==e&&t!==t}e.exports=o},"./node_modules/lodash/isArray.js":function(e,t){var o=Array.isArray;e.exports=o},"./node_modules/lodash/isFunction.js":function(e,t,o){function n(e){if(!a(e))return!1;var t=s(e);return t==i||t==d||t==r||t==l}var s=o("./node_modules/lodash/_baseGetTag.js"),a=o("./node_modules/lodash/isObject.js"),r="[object AsyncFunction]",i="[object Function]",d="[object GeneratorFunction]",l="[object Proxy]";e.exports=n},"./node_modules/lodash/isObject.js":function(e,t){function o(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}e.exports=o},"./node_modules/lodash/isObjectLike.js":function(e,t){function o(e){return null!=e&&"object"==typeof e}e.exports=o},"./node_modules/lodash/isSymbol.js":function(e,t,o){function n(e){return"symbol"==typeof e||a(e)&&s(e)==r}var s=o("./node_modules/lodash/_baseGetTag.js"),a=o("./node_modules/lodash/isObjectLike.js"),r="[object Symbol]";e.exports=n},"./node_modules/lodash/memoize.js":function(e,t,o){function n(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError(a);var o=function(){var n=arguments,s=t?t.apply(this,n):n[0],a=o.cache;if(a.has(s))return a.get(s);var r=e.apply(this,n);return o.cache=a.set(s,r)||a,r};return o.cache=new(n.Cache||s),o}var s=o("./node_modules/lodash/_MapCache.js"),a="Expected a function";n.Cache=s,e.exports=n},"./node_modules/lodash/toPath.js":function(e,t,o){function n(e){return r(e)?s(e,l):i(e)?[e]:a(d(u(e)))}var s=o("./node_modules/lodash/_arrayMap.js"),a=o("./node_modules/lodash/_copyArray.js"),r=o("./node_modules/lodash/isArray.js"),i=o("./node_modules/lodash/isSymbol.js"),d=o("./node_modules/lodash/_stringToPath.js"),l=o("./node_modules/lodash/_toKey.js"),u=o("./node_modules/lodash/toString.js");e.exports=n},"./node_modules/lodash/toString.js":function(e,t,o){function n(e){return null==e?"":s(e)}var s=o("./node_modules/lodash/_baseToString.js");e.exports=n},"./node_modules/redux-form/lib/structure/plain/getIn.js":function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=o("./node_modules/lodash/toPath.js"),s=function(e){return e&&e.__esModule?e:{default:e}}(n),a=function(e,t){if(!e)return e;var o=(0,s.default)(t),n=o.length;if(n){for(var a=e,r=0;r { - const content = jQuery(o.content); - + const content = jQuery(`
${o.content}
`); // Transform [image] shortcodes content.find(filter) .add(content.filter(filter)) @@ -103,13 +102,13 @@ const filter = 'img[data-shortcode="image"]'; el.replaceWith(shortCode); }); - // Insert outerHTML in order to retain all nodes incl.