Coder Social home page Coder Social logo

editor-style technique about flynt HOT 2 CLOSED

flyntwp avatar flyntwp commented on June 5, 2024
editor-style technique

from flynt.

Comments (2)

koukouchris avatar koukouchris commented on June 5, 2024

Hello @proteinone,

This is very similar to our approach, when adding editor styles.
We also add a new entry in the build-config.js because this will create a new, separate bundle.

/assets/editor-style.js would look like this:
import './editor-style.scss'

We usually only add global styles and not component specific ones. So that is why you do not necessarily need the import stuff in the editor-style.js.

We add editor styles on /inc/assets.php

add_action('admin_init', function () {
    add_editor_style(Asset::requireUrl('assets/editor-style.css'));
});

We handle all asset loading in inc/assets.php and do not create an extra tinyMce.php, but this is just preference.

The Asset::requireUrl is a helper to resolve the correct path of a given assets.
This most of the time just makes a difference when you run npm run build, then all assets are revisioned, so they get a content hash added to their filename.

Thanks for the feedback! Glad you're enjoying Flynt!

from flynt.

proteinone avatar proteinone commented on June 5, 2024

Thanks @koukouchris !

Great to hear we were on the right path : )

I completely agree about the editor-style.js, we don't need component level styles either.

And the assets.php looks like a better place to enqueue the file also. Good idea.

from flynt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.