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

Automatically remove blank lines in HTML blocks #7921

Closed
3 tasks done
Zuoqiu-Yingyi opened this issue Apr 7, 2023 · 4 comments
Closed
3 tasks done

Automatically remove blank lines in HTML blocks #7921

Zuoqiu-Yingyi opened this issue Apr 7, 2023 · 4 comments
Assignees

Comments

@Zuoqiu-Yingyi
Copy link
Contributor

Zuoqiu-Yingyi commented Apr 7, 2023

HTML 块存在空行时造成运行时异常

Is there an existing issue for this?

  • I have searched the existing issues

Can the issue be reproduced with the default theme (daylight/midnight)?

  • I was able to reproduce the issue with the default theme

Could the issue be due to extensions?

  • I've ruled out the possibility that the extension is causing the problem.

Describe the problem

HTML 块存在空行时提示 形成了多个 HTML 块,为防止数据丢失请使用 <div> 标签包裹并去掉空行, 然后点击编辑按钮进行编辑时出现运行时异常
When there are empty lines in the HTML block, prompts Multiple HTML blocks are formed. To prevent data loss, please use <div> tags to wrap and remove blank lines, and then click the Edit button to edit a runtime exception when editing

Expected result

HTML 块在保存时自动移除空行
HTML blocks automatically remove empty lines when saved

Screenshot or screen recording presentation

No response

Version environment

- Version: 2.8.4-dev1
- Operating System: 
- Browser (if used):

Log file

E 2023/04/07 21:39:36 transaction.go:861: get node [20230407213820-etg2jy8] in tree [20230407212329-u4jaait] failed

More information

No response

@88250 88250 changed the title HTML 块存在空行时造成运行时异常 | HTML block with blank line parsing errors cause run-time exceptions HTML block with blank line parsing errors cause run-time exceptions Apr 7, 2023
@88250
Copy link
Member

88250 commented Apr 9, 2023

麻烦给出原始的 HTML 块内容。

@Zuoqiu-Yingyi
Copy link
Contributor Author

麻烦给出原始的 HTML 块内容。

<div>
    <button id="button">
        更新用户指南
    </button>
    <script type="module">
        {
            /* 自定义 ID */
            const CUSTOM_ID = "E4555D40-2E2B-4C40-9598-AE05B77CEB9F";
            /**
             * HTML 块中的脚本获取当前块相关信息
             * @param {string} customID 内部定义的 ID
             * @returns {string} id 当前 HTML 块 ID
             * @returns {HTMLElement} block 当前 HTML 块
             * @returns {HTMLElement} shadowRoot 当前 HTML 块 shadowRoot
             */
            function This(customID) {
                let protyle = document.querySelector(`protyle-html[data-content*="${customID}"]`);
                if (protyle) {
                    let block = protyle.parentElement.parentElement;
                    return {
                        id: block.dataset.nodeId,
                        block: block,
                        shadowRoot: protyle.shadowRoot,
                    };
                } else return null;
            }

            const NOTEBOOKS_ID_LIST = [
                "20210808180117-czj9bvb", // 简体中文用户指南
                "20211226090932-5lcq56f", // 繁体中文用户指南
                "20210808180117-6v0mkxr", // 英文用户指南
            ]; // 用户指南笔记本 ID 列表
            const URL = "/api/notebook/openNotebook"; // 重新打开笔记本的 API
            const THIS = This(CUSTOM_ID); // 获取当前 HTML 块相关信息
            const BUTTON = THIS.shadowRoot.getElementById("button"); // 获取按钮元素

            async function reOpenUserGuide() {
                NOTEBOOKS_ID_LIST.forEach(notebook_id => {
                    fetch(URL, {
                        body: JSON.stringify({
                            notebook: notebook_id,
                        }),
                        method: 'POST',
                    });
                });
            }

            BUTTON.addEventListener("click", reOpenUserGuide);
        }
    </script>
</div>

@88250 88250 changed the title HTML block with blank line parsing errors cause run-time exceptions Automatically remove blank lines in HTML blocks Apr 11, 2023
@88250 88250 added this to the 2.8.5 milestone Apr 11, 2023
Vanessa219 added a commit that referenced this issue Apr 12, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Zuoqiu-Yingyi added a commit to Zuoqiu-Yingyi/siyuan that referenced this issue Apr 14, 2023
88250 pushed a commit that referenced this issue Apr 14, 2023
@Zuoqiu-Yingyi
Copy link
Contributor Author

Zuoqiu-Yingyi commented Apr 15, 2023

貌似还是没完全修好

2.8.5-dev2 中 HTML 块内插入如下内容

<div>
    123
</div>

关闭输入框后再打开输入框, 结尾会多出一个 标签, 如下所示

<div>
    123
</div>
</div>

@Zuoqiu-Yingyi
Copy link
Contributor Author

应该定位到问题了, 稍后我提交一个 PR

Zuoqiu-Yingyi added a commit to Zuoqiu-Yingyi/siyuan that referenced this issue Apr 15, 2023
commit 5f06c8c
Merge: 3e9f5a3 d22a269
Author: Vanessa <lly219@gmail.com>
Date:   Sat Apr 15 11:39:25 2023 +0800

    Merge remote-tracking branch 'origin/dev' into dev

commit 3e9f5a3
Author: Vanessa <lly219@gmail.com>
Date:   Sat Apr 15 11:39:09 2023 +0800

    :art: fix siyuan-note#8005

commit d22a269
Author: Liang Ding <d@b3log.org>
Date:   Sat Apr 15 11:26:06 2023 +0800

    :memo: Add explanation of what "SiYuan" means to the SiYuan User Guide Fix siyuan-note#8004

commit 1ad395c
Author: Vanessa <lly219@gmail.com>
Date:   Fri Apr 14 23:03:14 2023 +0800

    :rotating_light:

commit 2ee6b54
Author: Vanessa <lly219@gmail.com>
Date:   Fri Apr 14 23:02:44 2023 +0800

    :bug: fix siyuan-note#7979

commit 671f182
Author: Vanessa <lly219@gmail.com>
Date:   Fri Apr 14 22:42:21 2023 +0800

    :rotating_light:

commit 7557c77
Merge: 8680611 d79f97d
Author: Vanessa <lly219@gmail.com>
Date:   Fri Apr 14 22:26:52 2023 +0800

    Merge remote-tracking branch 'origin/dev' into dev

commit 8680611
Author: Vanessa <lly219@gmail.com>
Date:   Fri Apr 14 22:26:34 2023 +0800

    :art: fix siyuan-note#7979

commit d79f97d
Author: 绛亽 <83791825+Soltus@users.noreply.github.com>
Date:   Fri Apr 14 20:59:03 2023 +0800

    Update package.json (siyuan-note#8002)

commit 73b6ee5
Author: Liang Ding <d@b3log.org>
Date:   Fri Apr 14 20:55:59 2023 +0800

    :octocat: Security report just in English

commit ffd148e
Author: Liang Ding <d@b3log.org>
Date:   Fri Apr 14 20:54:49 2023 +0800

    :octocat: PR template just in English

commit 867852a
Author: Liang Ding <d@b3log.org>
Date:   Fri Apr 14 20:39:09 2023 +0800

    :art: Add OCR-related operations to the picture menu siyuan-note#7203

commit acffdeb
Author: Liang Ding <d@b3log.org>
Date:   Fri Apr 14 20:31:41 2023 +0800

    :art: Add OCR-related operations to the picture menu siyuan-note#7203

commit dfe0f4c
Author: Liang Ding <d@b3log.org>
Date:   Fri Apr 14 20:25:58 2023 +0800

    :art: Add OCR-related operations to the picture menu siyuan-note#7203

commit 2231d08
Author: Vanessa <lly219@gmail.com>
Date:   Fri Apr 14 20:21:09 2023 +0800

    :lipstick: fix siyuan-note#7986

commit b15cfb0
Merge: a339747 de440b8
Author: Vanessa <lly219@gmail.com>
Date:   Fri Apr 14 20:10:02 2023 +0800

    Merge remote-tracking branch 'origin/dev' into dev

commit a339747
Author: Vanessa <lly219@gmail.com>
Date:   Fri Apr 14 20:09:44 2023 +0800

    :art: fix siyuan-note#7982

commit de440b8
Author: Liang Ding <d@b3log.org>
Date:   Fri Apr 14 20:05:36 2023 +0800

    :arrow_up: Upgrade PNPM version

commit 6d7d8a8
Author: Liang Ding <d@b3log.org>
Date:   Fri Apr 14 20:02:24 2023 +0800

    :art: Reduce holding time of open user guide tip

commit 35c954d
Author: Liang Ding <d@b3log.org>
Date:   Fri Apr 14 20:02:07 2023 +0800

    :art: Reduce holding time of open user guide tip

commit dd2a1b2
Author: Vanessa <lly219@gmail.com>
Date:   Fri Apr 14 16:51:54 2023 +0800

    :art: siyuan-note#7203

commit c2ca60c
Merge: 7d8f725 28f3920
Author: Vanessa <lly219@gmail.com>
Date:   Fri Apr 14 16:44:56 2023 +0800

    Merge remote-tracking branch 'origin/dev' into dev

commit 7d8f725
Author: Vanessa <lly219@gmail.com>
Date:   Fri Apr 14 16:44:42 2023 +0800

    :art: siyuan-note#7954

commit 28f3920
Author: 颖逸 <49649786+Zuoqiu-Yingyi@users.noreply.github.com>
Date:   Fri Apr 14 16:38:35 2023 +0800

    :art: fix siyuan-note#7921 (siyuan-note#7997)

commit 862d0db
Author: Liang Ding <d@b3log.org>
Date:   Fri Apr 14 16:36:04 2023 +0800

    :art: Spaced repetition interface supports review by document selection siyuan-note#7954

commit 4529221
Author: Vanessa <lly219@gmail.com>
Date:   Fri Apr 14 16:32:52 2023 +0800

    :art: siyuan-note#7954

commit e7091c3
Merge: e4a77c9 d7bea02
Author: Vanessa <lly219@gmail.com>
Date:   Fri Apr 14 16:27:43 2023 +0800

    Merge remote-tracking branch 'origin/dev' into dev

commit e4a77c9
Author: Vanessa <lly219@gmail.com>
Date:   Fri Apr 14 16:27:28 2023 +0800

    :art: siyuan-note#7954
Zuoqiu-Yingyi added a commit to Zuoqiu-Yingyi/siyuan that referenced this issue Apr 15, 2023
Zuoqiu-Yingyi added a commit to Zuoqiu-Yingyi/siyuan that referenced this issue Apr 15, 2023
88250 pushed a commit that referenced this issue Apr 17, 2023
@88250 88250 removed this from the 2.8.5 milestone Apr 18, 2023
@88250 88250 removed the Enhancement label Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants