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

HTML 块复制/剪切后粘贴,块内容转义与解析错误 #4245

Closed
Zuoqiu-Yingyi opened this issue Mar 14, 2022 · 5 comments
Closed

HTML 块复制/剪切后粘贴,块内容转义与解析错误 #4245

Zuoqiu-Yingyi opened this issue Mar 14, 2022 · 5 comments
Assignees
Labels
Milestone

Comments

@Zuoqiu-Yingyi
Copy link
Contributor

描述问题 Describe the problem


示例 1

HTML 块内容:
<ruby><rt></rt>
 好<rt> hǎo</rt>
 世<rt> shì</rt>
 界<rt> jiè</rt>
</ruby><br>

Hello World
复制后剪贴板内内容:
<div><protyle-html data-content="&amp;lt;ruby&amp;gt;
你&amp;lt;rt&amp;gt;nǐ&amp;lt;/rt&amp;gt;
 好&amp;lt;rt&amp;gt; hǎo&amp;lt;/rt&amp;gt;
 世&amp;lt;rt&amp;gt; shì&amp;lt;/rt&amp;gt;
 界&amp;lt;rt&amp;gt; jiè&amp;lt;/rt&amp;gt;
&amp;lt;/ruby&amp;gt;&amp;lt;br&amp;gt;

Hello World"></protyle-html><span style="position: absolute"></span></div>
粘贴后样式:

image
其中 HTML 块内容:

<div><protyle-html data-content="&lt;ruby&gt;
你&lt;rt&gt;nǐ&lt;/rt&gt;
 好&lt;rt&gt; hǎo&lt;/rt&gt;
 世&lt;rt&gt; shì&lt;/rt&gt;
 界&lt;rt&gt; jiè&lt;/rt&gt;
&lt;/ruby&gt;&lt;br&gt;

错误产生原因推测:
复制后换行符为转义, 粘贴时解析为一个错误的 HTML 块与一个段落块


示例 2

HTML 块内容:
<u>12345</u> <kbd>67890</kbd>
复制后剪贴板内内容:
<div><protyle-html data-content="&lt;u&gt;12345&lt;/u&gt; &lt;kbd&gt;67890&lt;/kbd&gt;"></protyle-html><span style="position: absolute"></span></div>
粘贴后 HTML 块内容:
<div><protyle-html data-content="<u>12345</u> <kbd>67890</kbd>"></protyle-html><span style="position: absolute"></span></div>

错误产生原因推测:
粘贴后解析时仅将 data-content 属性中的转义字符恢复, 未移除 protyle-html 标签, div 标签与 span 标签


期待的结果 Expected result

复制/剪切后再粘贴的 HTML 块内容前后保持一致

版本环境 Version environment

  • Version: 1.9.0
@88250 88250 added this to the 1.9.1 milestone Mar 15, 2022
@88250 88250 added the Bug label Mar 15, 2022
@88250 88250 changed the title HTML 块复制/剪切后粘贴, 块内容转义与解析错误 HTML 块复制/剪切后粘贴,块内容转义与解析错误 Mar 15, 2022
@88250

This comment was marked as outdated.

@88250
Copy link
Member

88250 commented Mar 15, 2022

以前确认问题,下个版本修复,谢谢。

@Zuoqiu-Yingyi
Copy link
Contributor Author

使用的是 块标菜单 - 复制 - 复制 吗?

@Zuoqiu-Yingyi
Copy link
Contributor Author

@88250 这个 bug 在 v1.9.7 中又出现了, 不过是一个 HTML 块在粘贴时会分割为多个 HTML 块

如下 HTML 块 剪切/复制 后再粘贴会粘贴为两个 HTML 块, 内容分别是 <style> 标签与 <div> 标签

<style>
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    body {
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 100vh;
        background: #091921;
    }

    .clock {
        width: 350px;
        height: 350px;
        display: flex;
        justify-content: center;
        align-items: center;
        background-size: cover;
        border: 4px solid #091921;
        border-radius: 50%;
        box-shadow: 0 -15px 15px rgba(255, 255, 255, 0.05),
            inset 0 -15px 15px rgba(255, 255, 255, 0.05),
            0 15px 15px rgba(0, 0, 0, 0.3),
            inset 0 -15px 15px rgba(0, 0, 0, 0.3);
    }

    .clock:before {
        content: '';
        position: absolute;
        width: 15px;
        height: 15px;
        background-color: #fff;
        border-radius: 50%;
        z-index: 100;
    }

    .clock .hour,
    .clock .min,
    .clock .sec {
        position: absolute;
    }

    .clock .hour,
    .hr {
        width: 160px;
        height: 160px;
    }

    .clock .min,
    .mn {
        width: 190px;
        height: 190px;
    }

    .clock .sec,
    .sc {
        width: 230px;
        height: 230px;
    }

    .hr,
    .mn,
    .sc {
        display: flex;
        justify-content: center;
        position: absolute;
        border-radius: 50%;
    }

    .hr:before {
        content: '';
        position: absolute;
        width: 8px;
        height: 80px;
        background-color: #ff105e;
        z-index: 10;
        border-radius: 6px 6px 0 0;
    }

    .mn:before {
        content: '';
        position: absolute;
        width: 4px;
        height: 90px;
        background-color: #fff;
        z-index: 11;
        border-radius: 6px 6px 0 0;
    }

    .sc:before {
        content: '';
        position: absolute;
        width: 2px;
        height: 150px;
        background-color: #fff;
        z-index: 12;
        border-radius: 6px 6px 0 0;
    }
</style>

<div class="clock">
    <div class="hour">
        <div class="hr" id="hr"></div>
    </div>
    <div class="min">
        <div class="mn" id="mn"></div>
    </div>
    <div class="sec">
        <div class="sc" id="sc"></div>
    </div>
</div>

@88250
Copy link
Member

88250 commented Apr 8, 2022

@Zuoqiu-Yingyi 手工创建 HTML 块后在编辑框里输入,直接粘贴的话是按照 Markdown 标准解析为多个块。

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

No branches or pull requests

3 participants