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

Change font family based on block type + inline style #48

Open
joshfeinsilber opened this issue Oct 18, 2018 · 2 comments
Open

Change font family based on block type + inline style #48

joshfeinsilber opened this issue Oct 18, 2018 · 2 comments

Comments

@joshfeinsilber
Copy link

Hi there!

I am looking to have one font family for a bold header-one, and a different font family for a bold header-two. Is there any way to do this? Currently, the custom styles allows us to specify styles for block type and inline style separately, but not together.

Thanks so much!

@summercity
Copy link

Any update on this? I am facing the same issue...

Thank you so much!

@summercity
Copy link

summercity commented Jun 11, 2019

I was able to do a workaround.

Note the item = block

  1. Use 'code-block'
    eg. if (item.type === 'header-one') { item.type = 'code-block' }

  2. Create custom css element and exclude default text styles
    if (!this.isEmpty(item.inlineStyleRanges)) {
    item.inlineStyleRanges.map(i => {
    if (i.style != 'ITALIC'
    && i.style != 'BOLD'
    && i.style != 'LINK'
    && i.style != 'UNDERLINE'
    && i.style != 'STRIKETHROUGH' ) {
    if(originalType === 'header-one') {
    i.style = i.style + '-one';
    } else if (originalType === 'header-two') {
    i.style = i.style + '-two';
    } else if (originalType === 'header-three') {
    i.style = i.style + '-three';
    } else if (originalType === 'header-four') {
    i.style = i.style + '-four';
    } else if (originalType === 'header-five') {
    i.style = i.style + '-five';
    } else if (originalType === 'header-six') {
    i.style = i.style + '-six';
    }
    }

                         })
                     }
    
  3. Map CSS to corresponding custom elements
    'merriweather': {
    fontFamily: 'Merriweather',
    },
    'merriweather-one': {
    fontFamily: 'Merriweather',
    fontSize: 32,
    },
    'merriweather-two': {
    fontFamily: 'Merriweather',
    fontSize: 24
    },
    'dancing script': {
    fontFamily: 'Dancing Script',
    },
    'dancing script-two': {
    fontFamily: 'Dancing Script',
    fontSize: 24
    },

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

No branches or pull requests

2 participants