如何使用Tinymce的getContent() API方法获取完整内容。

huangapple go评论75阅读模式
英文:

How to Get Full Content using Tinymce getContent() API method

问题

I have a form that uses tinymce and has content like the image above. Then, I want to preview that content to PDF page using getContent() API method with code like below.

<script nonce="{{ csp_nonce() }}">
    var options = {
        selector: "#body_sp3d",
        menubar: 'file edit view insert format tools table help',
        plugins: [
            "advlist autolink autosave lists link image charmap print preview hr anchor pagebreak",
            "searchreplace wordcount visualblocks visualchars code fullscreen",
            "insertdatetime nonbreaking save table directionality",
            "template paste textpattern"
        ],
        toolbar: "fullscreen restoredraft insertfile undo redo toc | styleselect fontselect fontsizeselect | bold italic | alignleft aligncenter alignright alignjustify codesample | bullist numlist outdent indent toc",
    };
    tinymce.init(options);
</script>
<script>
    $(document).ready(function() {
        $('#previewSp3d').on('click', function() {
            //get content from tinyMCE editor and set to #content_sp3d
            var body_sp3d        = tinymce.get('body_sp3d').getContent();
            var no_sp3d          = $('#no_sp3d').val();
            var penerima_sp3d    = $('#penerima_sp3d').val();
            var klasifikasi_sp3d = $('#klasifikasi_sp3d').val();
            var url              = "{{ route('preview.sp3d')}}";
            var full_url         = url + '?no_sp3d=' + no_sp3d + '&penerima_sp3d=' + penerima_sp3d + '&body_sp3d=' + body_sp3d + '&klasifikasi_sp3d=' + klasifikasi_sp3d;

            $('#previewSp3d').attr('href', full_url);
        });
    });
</script>

But, only part of the content is previewed, not all content can be displayed on the PDF page. How do I get all the content in the form to be displayed on the PDF page? Thanks

英文:

如何使用Tinymce的getContent() API方法获取完整内容。

I have a form that uses tinymce and has content like the image above. Then, I want to preview that content to PDF page using getContent() API method with code like below.

&lt;script nonce=&quot;{{ csp_nonce() }}&quot;&gt;
    var options = {
        selector: &quot;#body_sp3d&quot;,
        menubar: &#39;file edit view insert format tools table help&#39;,
        plugins: [
            &quot;advlist autolink autosave lists link image charmap print preview hr anchor pagebreak&quot;,
            &quot;searchreplace wordcount visualblocks visualchars code fullscreen&quot;,
            &quot;insertdatetime nonbreaking save table directionality&quot;,
            &quot;template paste textpattern&quot;
        ],
        toolbar: &quot;fullscreen restoredraft insertfile undo redo toc | styleselect fontselect fontsizeselect | bold italic | alignleft aligncenter alignright alignjustify codesample | bullist numlist outdent indent toc&quot;,
    };
    tinymce.init(options);
&lt;/script&gt;
&lt;script&gt;
    $(document).ready(function() {
        $(&#39;#previewSp3d&#39;).on(&#39;click&#39;, function() {
            //get content from tinyMCE editor and set to #content_sp3d
            var body_sp3d        = tinymce.get(&#39;body_sp3d&#39;).getContent();
            var no_sp3d          = $(&#39;#no_sp3d&#39;).val();
            var penerima_sp3d    = $(&#39;#penerima_sp3d&#39;).val();
            var klasifikasi_sp3d = $(&#39;#klasifikasi_sp3d&#39;).val();
            var url              = &quot;{{ route(&#39;preview.sp3d&#39;)}}&quot;;
            var full_url         = url + &#39;?no_sp3d=&#39; + no_sp3d + &#39;&amp;penerima_sp3d=&#39; + penerima_sp3d + &#39;&amp;body_sp3d=&#39; + body_sp3d + &#39;&amp;klasifikasi_sp3d=&#39; + klasifikasi_sp3d;

            $(&#39;#previewSp3d&#39;).attr(&#39;href&#39;, full_url);
        });
    });
&lt;/script&gt;

如何使用Tinymce的getContent() API方法获取完整内容。

But, only part of the content is previewed, not all content can be displayed on the PDF page. How do I get all the content in the form to be displayed on the PDF page? Thanks

答案1

得分: 0

已解决。在body_sp3d中包含了&nbsp字符。

英文:

SOLVED. at body_sp3d contains &nbsp character

huangapple
  • 本文由 发表于 2023年6月13日 13:53:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76462010.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定