Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Getting a 404 on mixins.js #2605

Closed
alesub opened this issue Feb 27, 2020 · 2 comments
Closed

[BUG] Getting a 404 on mixins.js #2605

alesub opened this issue Feb 27, 2020 · 2 comments

Comments

@alesub
Copy link

alesub commented Feb 27, 2020

First of all, thank you for this great tool.

  1. I'm using the latest version.
  2. The bug happens with a local copy of GrapesJS.
    1. MacOS - latest Chrome browser
    2. The bug is not present on the demo
  3. Expected behavior: have the editor loading without any errors
  4. What happens instead: I get a 404 error when the editor is appending styles

I'm getting the following error on the console after the editor is started:
mixins.js:27 GET http://example.com/editor/null net::ERR_ABORTED 404 (Not Found)
I replaced the real domain with "example.com", the rest of the URL is real.

On mixins.js, line 27, the instruction is head.insertBefore(link, head.firstChild);, it's part of the function that append styles to the editor. The problem is I'm passing an array of valid URLs, all of them resolve correctly as I see each style applied to the editor's html.

Here's how I'm creating the editor:

var editorSettings = {
	fromElement: true,
	height: '900px',
	width: '600px',
	cssIcons: null,
	storageManager: { type: null },
	noticeOnUnload: false,
	panels: { defaults: [] },
	canvas: {
		styles: [
			'https://fonts.googleapis.com/css?family=Libre+Franklin:400,600,700&display=swap',
			'https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css',
			'/wp-content/plugins/votersguide/public/css/pageTemplate.css?version=1.0.26'
		]
	},
	assetManager: {
		storageType  	: '',
		storeOnChange  : true,
		storeAfterUpload  : true,
		assets    	: [],
		uploadFile: function(e) {
			var postHash = getUrlVars()['g'];
			var nonce = $('#wpNonce').val();
			var files = e.dataTransfer ? e.dataTransfer.files : e.target.files;
			var formData = new FormData();
			for(var i in files){
				formData.append('file-'+i, files[i]) //containing all the selected images from local
			}
			formData.append('action', 'votersguide_editor');
			formData.append('g', postHash);
			formData.append('nonce', nonce);

			$.ajax({
				url: myAjax.ajaxurl,
				type: 'POST',
				data: formData,
				contentType: false,
				crossDomain: true,
				dataType: 'json',
				mimeType: "multipart/form-data",
				processData:false,
				success: function(result){
					var myJSON = [];
					$.each( result['data'], function( key, value ) {
						myJSON[key] = value;
					});
					var images = myJSON;
					editor.AssetManager.add(images); //adding images to asset manager of GrapesJS
				}
			});
		},
	},
};

editorSettings.container = '#'+selectedPage.attr('id');

var editor = grapesjs.init(editorSettings);
@artf
Copy link
Member

artf commented Mar 2, 2020

I think it's coming from cssIcons, seems like I forgot to check the value somewhere

@artf artf closed this as completed in 84fa97b Mar 2, 2020
@alesub
Copy link
Author

alesub commented Mar 2, 2020

Amazing, looking forward for the next release! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants