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

Cannot access SVG files through ToastUI CDN #313

Open
willowiscool opened this issue Jan 24, 2020 · 3 comments
Open

Cannot access SVG files through ToastUI CDN #313

willowiscool opened this issue Jan 24, 2020 · 3 comments
Labels
Enhancement Enhance performance or improve usability of original features. Question

Comments

@willowiscool
Copy link

Version

Latest

Development Environment

OpenSUSE Linux + Firefox

Current Behavior

I modified blackTheme to load the SVG files (icon-a through d) from the ToastUI CDN (URL: https://uicdn.toast.com/tui-image-editor/latest/svg/icon-a.svg). However, the icons are not loading correctly, and I get the error: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://uicdn.toast.com/tui-image-editor/latest/svg/icon-d.svg. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing)

const blackTheme = {
        // ...
  	// main icons
	'menu.normalIcon.path': 'https://uicdn.toast.com/tui-image-editor/latest/svg/icon-d.svg',
	'menu.normalIcon.name': 'icon-d',
	'menu.activeIcon.path': 'https://uicdn.toast.com/tui-image-editor/latest/svg/icon-b.svg',
	'menu.activeIcon.name': 'icon-b',
	'menu.disabledIcon.path': 'https://uicdn.toast.com/tui-image-editor/latest/svg/icon-a.svg',
	'menu.disabledIcon.name': 'icon-a',
	'menu.hoverIcon.path': 'https://uicdn.toast.com/tui-image-editor/latest/svg/icon-c.svg',
	'menu.hoverIcon.name': 'icon-c',
	'menu.iconSize.width': '24px',
	'menu.iconSize.height': '24px',
        // ...
	// submenu icons
	'submenu.normalIcon.path': 'https://uicdn.toast.com/tui-image-editor/latest/svg/icon-d.svg',
	'submenu.normalIcon.name': 'icon-d',
	'submenu.activeIcon.path': 'https://uicdn.toast.com/tui-image-editor/latest/svg/icon-c.svg',
	'submenu.activeIcon.name': 'icon-c',
	'submenu.iconSize.width': '32px',
	'submenu.iconSize.height': '32px',
        // ...
}

Expected Behavior

Expected: no error, and icons load properly

@SebastianStehle
Copy link

@jinwoo-kim-nhn
Copy link
Contributor

Currently, svg does not guarantee normal behavior in an external resource (cross domain) environment.

This part will be carefully improved after further testing.

@jinwoo-kim-nhn jinwoo-kim-nhn added the Enhancement Enhance performance or improve usability of original features. label Jan 31, 2020
@indfnzo
Copy link

indfnzo commented Feb 2, 2020

Perhaps there could be a way to load this locally as well, so as to avoid the image editor from having to fetch the resources at runtime.

Imagine being able to just import the SVG's like so:

import { iconA, iconB, iconC, iconD } from 'tui-image-editor/dist/svg-icons.js';

...and using them on the config like so:

const theme = {
    // ...
    'menu.normalIcon': iconD,
    'menu.activeIcon': iconB,
    'menu.disabledIcon': iconA,
    'menu.hoverIcon': iconC,
    // ...
};

There could simply be an additional JS file (svg-icons.js) on the build where the SVG content is defined as a module:

const iconA = `
    <svg>
        <symbol id="icon-a-ic-apply" viewBox="0 0 24 24">
            <g fill="none" fill-rule="evenodd">
                <path d="M0 0h24v24H0z"/>
                <path stroke="#434343" d="M4 12.011l5 5L20.011 6"/>
            </g>
        </symbol>
        <symbol ...></symbol>
        <!-- other symbols -->
    </svg>
`;

export { iconA, ... };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Enhance performance or improve usability of original features. Question
Projects
None yet
Development

No branches or pull requests

4 participants