tinymce / tinymce-vue

Official TinyMCE Vue component
MIT License
2.06k stars 207 forks source link

The `outputFormat` prop should allow `"raw"` #338

Closed fisker closed 1 year ago

fisker commented 2 years ago

What is the current behavior?

<tinymce-editor output-format="raw"></tinymce-editor>

Cause Vue warning

[Vue warn]: Invalid prop: custom validator check failed for prop "outputFormat". 

Please provide the steps to reproduce and if possible a minimal demo of the problem via codesandbox.io or similar.

I don't think this is necessary, but I can setup one if required.

What is the expected behavior?

According to type definition in core the getContent format should allow "raw", but in Vue component, "raw" is not allowed in the outputFormat prop.

Which versions of TinyMCE, and which browser / OS are affected by this issue? Did this work in previous versions of TinyMCE or tinymce-vue?

Version: @tinymce/tinymce-vue@5.0.0.

Did this work in previous versions of TinyMCE or tinymce-vue?

IDK.


I'm using "raw" because the default "html" format cause \n added between <section style="display: inline-block"/> which is also a bug, but I'm not going to deal with it.

My workaround

import TinymceEditor from '@tinymce/tinymce-vue';

const TinymceEditorSupportsRawFormat = {
  ...TinymceEditor,
  props: {
    ...TinymceEditor.props,
    outputFormat: {
      ...TinymceEditor.props.outputFormat,
      validator: (format) =>
        format === 'html' || format === 'text' || format === 'raw',
    },
  },
};
exalate-issue-sync[bot] commented 2 years ago

Ref: INT-3012

jscasca commented 1 year ago

@fisker the output format raw was intentionally excluded as it contains editor specific attributes and tags designed for internal use only.

If you really REALLY want this content you can access it via the editor ref of the component otherwise we don't recommend using it.

fisker commented 1 year ago

In that case, do you think this should be fixed?

I'm using "raw" because the default "html" format cause \n added between <section style="display: inline-block"/> which is also a bug

jscasca commented 1 year ago

@fisker That is part of the editor behaviour, unfortunately, this repo only deals with the Vue component. You would need to open an issue at the TinyMCE repo since I'm not completely sure what is the editor expected behaviour.

If you want to use the raw option, you can write a custom handler using the editor ref of the component or a fork of this project but know that it is not supported

fisker commented 1 year ago

Thanks anyway.

afan0228 commented 1 year ago

不管怎么说,还是要谢谢你。 Can you provide a complete example, buddy?