camper/web/static/grapesjs-preset-webpage@1.0...

3 lines
11 KiB
JavaScript
Raw Normal View History

Replace Gutenberg with GrapesJS for pages I simply can not use Gutenberg without having it choking in its own over-engineered architecture: using it inside a form, submits it when clicking the button to change a paragraph’s text size; and using the custom text size in pixels causes the paragraph component to fail. The issue with paragraph’s custom text size is that block-editor’s typography hook expects the font size to be a string, such as '12px' or '1em', to call startsWith on it, but the paragraph sets an integer, always assuming that the units are pixels. Integers do not have a startsWith method. Looking at the Gutenberg distributed with the current version of WordPress, 6.3, seems that now paragraph has a selector for the units, therefore never sets just the integer. That made me think that the components used by the Isolated Block Editor are “mismatched”: maybe in a previous version of block-editor it was always passed as an integer too? I downloaded the source code of the Isolated Block Editor and tried to update @wordpress/block-library from version 8.14.0 to the current version, 8.16.0, but fails with an error saying that 'core/paragraph' is not registered, when, as far as i could check, it was. Seems that something changed in @wordpress/blocks between version 12.14.0 and 12.16.0, so i tried to upgrade that module as well; it did not work because @wordpress/data was not updated —do not remember the actual error message—. Upgrading to @wordpress/data from 9.7.0 to 9.9.0 made the registration of the 'isolated/editor' subregistry to be apparently ignored, because the posterior select('isolated/editor') within a withSelect hook returns undefined. At this point, i gave up: it is obvious that the people that shit JavaScript for Gutenberg do not care for semantic versioning, and there are a lot of moving parts to fix just to be able to use a simple paragraph block! It seems, however, that there are not many open-source, block-based _layout_ editors out there: mainly GrapesJS and Craft.JS. Craft.JS, however, has no way to output HTML[0], requiring hacks such as using React to generate the HTML and then pasted that shit onto the page; totally useless for me. I am not a fan of GrapesJS either: it seems that the “text block” is a content-editable div, and semantic HTML can go fuck itself, apparently. Typical webshit mentality. By strapping another huge dependency like CKEditor, but only up to the already out-of-support version 4, i can write headers, paragraphs and list. That’s something, i guess. [0]: https://github.com/prevwong/craft.js/issues/42 Part of #33.
2023-08-11 00:38:49 +00:00
/*! grapesjs-preset-webpage - 1.0.3 */
!function(e,n){'object'==typeof exports&&'object'==typeof module?module.exports=n():'function'==typeof define&&define.amd?define([],n):'object'==typeof exports?exports["grapesjs-preset-webpage"]=n():e["grapesjs-preset-webpage"]=n()}('undefined'!=typeof globalThis?globalThis:'undefined'!=typeof window?window:this,(()=>(()=>{"use strict";var e={d:(n,t)=>{for(var o in t)e.o(t,o)&&!e.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:t[o]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n),r:e=>{'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})}},n={};e.r(n),e.d(n,{default:()=>u});var t=void 0&&(void 0).__assign||function(){return t=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},t.apply(this,arguments)};var o='gjs-open-import-webpage',r='set-device-desktop',i='set-device-tablet',a='set-device-mobile',c='canvas-clear',l=void 0&&(void 0).__assign||function(){return l=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},l.apply(this,arguments)};const s=function(e,n){var t=e.Commands,s=n.textCleanCanvas;!function(e,n){var t=e.getConfig('stylePrefix'),r=n.modalImportLabel,i=n.modalImportContent;e.Commands.add(o,{codeViewer:null,container:null,run:function(e){var t='function'==typeof i?i(e):i,r=this.getCodeViewer();e.Modal.open({title:n.modalImportTitle,content:this.getContainer()}).onceClose((function(){return e.stopCommand(o)})),r.setContent(null!=t?t:''),r.refresh(),setTimeout((function(){return r.focus()}),0)},stop:function(){e.Modal.close()},getContainer:function(){if(!this.container){var o=this.getCodeViewer(),i=document.createElement('div');if(i.className="".concat(t,"import-container"),r){var a=document.createElement('div');a.className="".concat(t,"import-label"),a.innerHTML=r,i.appendChild(a)}i.appendChild(o.getElement());var c=document.createElement('button');c.type='button',c.innerHTML=n.modalImportButton,c.className="".concat(t,"btn-prim ").concat(t,"btn-import"),c.onclick=function(){e.Css.clear(),e.setComponents(o.getContent().trim()),e.Modal.close()},i.appendChild(c),this.container=i}return this.container},getCodeViewer:function(){return this.codeViewer||(this.codeViewer=e.CodeManager.createViewer(l({codeName:'htmlmixed',theme:'hopscotch',readOnly:!1},n.importViewerOptions))),this.codeViewer}})}(e,n),t.add(r,{run:function(e){return e.setDevice('Desktop')},stop:function(){}}),t.add(i,{run:function(e){return e.setDevice('Tablet')},stop:function(){}}),t.add(a,{run:function(e){return e.setDevice('Mobile portrait')},stop:function(){}}),t.add(c,(function(e){return confirm(s)&&e.runCommand('core:canvas-clear')}))};var d=void 0&&(void 0).__assign||function(){return d=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},d.apply(this,arguments)};const u=function(e,n){void 0===n&&(n={});var l=d({blocks:['link-block','quote','text-basic'],block:function(){return{}},modalImportTitle:'Import',modalImportButton:'Import',modalImportLabel:'',modalImportContent:'',importViewerOptions:{},textCleanCanvas:'Are you sure you want to clear the canvas?',showStylesOnChange:!0,useCustomTheme:!0},n);if(l.useCustomTheme&&'undefined'!=typeof window){var u='gjs-',m='';[['one','#463a3c'],['two','#b9a5a6'],['three','#804f7b'],['four','#d97aa6']].forEach((function(e){var n=e[0],t=e[1];m+="\n .".concat(u).concat(n,"-bg {\n background-color: ").concat(t,";\n }\n\n .").concat(u).concat(n,"-color {\n color: ").concat(t,";\n }\n\n .").concat(u).concat(n,"-color-h:hover {\n color: ").concat(t,";\n }\n ")}));var p=document.createElement('style');p.innerText=m,document.head.appendChild(p)}!function(e,n){var o=function(o,r){n.blocks.indexOf(o)>=0&&e.Bl
//# sourceMappingURL=index.js.map