Blazored / TextEditor

Rich text editor for Blazor applications - Uses Quill JS
MIT License
276 stars 58 forks source link

Enabled opportunity to change images in BlazoredTextEditor when it is ReadOnly #13

Closed se-trofimov closed 4 years ago

se-trofimov commented 4 years ago

When I use BlazoredTextEditor as:

<BlazoredTextEditor @ref="@QuillHtml" ReadOnly="@ReadOnly" Theme="@(PanelDisabled?"bubble":"snow")" Placeholder ="">
    <ToolbarContent>
        <select class="ql-header">
            <option selected=""></option>
            <option value="1"></option>
            <option value="2"></option>
            <option value="3"></option>
            <option value="4"></option>
            <option value="5"></option>
        </select>
        <span class="ql-formats">
            <button class="ql-bold"></button>
            <button class="ql-italic"></button>
            <button class="ql-underline"></button>
            <button class="ql-strike"></button>
        </span>
        <span class="ql-formats">
            <select class="ql-color"></select>
            <select class="ql-background"></select>
        </span>
        <span class="ql-formats">
            <button class="ql-list" value="ordered"></button>
            <button class="ql-list" value="bullet"></button>
            <button class="ql-indent" value="-1"></button>
            <button class="ql-indent" value="+1"></button>
            <select class="ql-align">
                <option selected=""></option>
                <option value="center"></option>
                <option value="right"></option>
                <option value="justify"></option>
            </select>
        </span>
        <span class="ql-formats">
            <button class="ql-link"></button>
        </span>
        <span class="ql-formats">
            <button @onclick="ShowImageManager" style="margin-bottom:10px">
                <img src="/StaticImg/file-image.png" style="border:hidden" height="20" />
            </button>
        </span>
    </ToolbarContent>
    <EditorContent>

    </EditorContent>
</BlazoredTextEditor>

I still have the option to change image's size and position when @ReadOnly = true and Theme = bubble How I can fix it?

ADefWebserver commented 4 years ago

The Text Editor simply is a 'wrapper' around the Quill JavaScript control. To allow image resizing we inject this plug-in: https://github.com/Fandom-OSS/quill-blot-formatter That plug-in knows nothing about setting the text box to 'read only' so that is why it still works.

A possible solution would be to wrap line 7, in this code, to not call that line, to load the module, when readOnly is set to true.

However, while you can resize an image, if the user cannot save the results, why is this an issue?

se-trofimov commented 4 years ago

However, while you can resize an image, if the user cannot save the results, why is this an issue?

Because I use TextEditor for showing blog's content with ReadOnly state and user can move and resize image and broking my markup :)

Anyway, really thanks for solution.

ADefWebserver commented 4 years ago

Anyway, really thanks for solution.

Thank you for your understanding.

Yes, I was being 'short sided' when I did not consider disabling the resizing of images if the control was in 'read only' mode :(

However, the reason I don't just go off and keep adding 'new functionality' is that security is my number one concern, and I really only want to make new releases to address any 'security issues' or something that was working one way is no longer working.

I do this because people will automatically update the NuGet package without reading the 'release notes'.

I want this control to be 'just what it is' with 'no surprises' to people using it.