tinymce / tinymce

The world's #1 JavaScript library for rich text editing. Available for React, Vue and Angular
https://www.tiny.cloud
Other
14.86k stars 2.23k forks source link

Font Size Input #9216

Open wolfomat opened 9 months ago

wolfomat commented 9 months ago

📝 Provide detailed reproduction steps (if any)

Look at: https://codepen.io/wolfomat/pen/NWoedGa

  1. Use TinyMCE 6.8.1
  2. Create a minimal Editor using toolbar = 'fontsizeinput'
  3. Define, even it is regarding to the documentation the default, font_size_input_default_unit:'pt',

✔️ Expected result

I'd expect that in the input-box the unit would be for example Npt, where N is any number

❌ Actual result

The shown and used Unit in the font-size-input is PX.

❓ Possible solution

I'd guess that when the editor is initialized, the setting is not evaluated correctly. when changing the pt unit in the font-input-field, the editor will still work.

📃 Other details


If you'd like to see this fixed sooner, add a 👍 reaction to this post.

pennan88 commented 5 months ago

@wolfomat Did you get this to work? I am having the same problem

wolfomat commented 5 months ago

@wolfomat Did you get this to work? I am having the same problem

Hi @pennan88 ; in fact i did not get this to work and it seems to be still persitent in 7.0.0

pennan88 commented 5 months ago

@wolfomat Yes. i noticed that as well. Hopefully it gets fixed someday

luicfrr commented 5 months ago

I think I found a workaround on this issue (in my case this worked. I'm using react):

// Editor.tsx
import { Editor as EditorType } from 'tinymce'
export type TextEditorType = {
  onInit: (editor: EditorType) => void
}
function Editor( {
  onInit
}: TextEditorType ): JSX.Element {
  ..... 
  return (
    <Editor
      onInit={ ( _, editor ) => onInit( editor as unknown as EditorType ) }
      ..... other props
    />
  )
}

// MyComponent.tsx
function MyComponent() {
  ....
  function onEditorInit(editor: EditorType) {
    // this do the trick
    editor.execCommand( "fontSize", false, "10pt" )
  }

  return <Editor
    onInit={onEditorInit}  
  />
}

This forces editor to update it's font size and this also updates fontsizeinput to update it's value.

pennan88 commented 5 months ago

@nonam4 Hello! This did work in react just like you said but sadly i am using Blazor WASM so the same solution did not work, but i think its still on the right path so I'll keep trying different approaches.

renatolopes47 commented 4 months ago

Hi, did anyone got any solution for this? Thanks

LaughingJohn commented 2 weeks ago

Just hit this one myself..