Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve keyboard block selection and batch operations https://github.com/siyuan-note/siyuan/issues/19017

Daniel962fc8d9c39d
diff --git a/app/guide/20210808180117-6v0mkxr/.siyuan/sort.json b/app/guide/20210808180117-6v0mkxr/.siyuan/sort.json
index 096da50308..8d911fe806 100644
--- a/app/guide/20210808180117-6v0mkxr/.siyuan/sort.json
+++ b/app/guide/20210808180117-6v0mkxr/.siyuan/sort.json
@@ -1 +1 @@
-{"20200923234011-ieuun1p":1,"20200923234602-gy54e67":10,"20200923234731-h3zkwm2":3,"20200924093441-ft2rhps":1,"20200924095938-a9p5450":2,"20200924100110-vcg96wy":1,"20200924100635-ms0p9lb":7,"20200924100717-yzwzn64":23,"20200924100744-br924ar":11,"20200924100808-j9sddk9":2,"20200924100906-0u4zfq3":4,"20200924100950-9op5xi1":19,"20200924101106-19z4kaa":1,"20200924101200-gss5vee":4,"20200924101225-k254i8g":2,"20200924101256-f8b1sbi":3,"20201004194026-s8h2cog":20,"20201117112518-dott91x":6,"20201121224345-rc27qvo":11,"20201204184532-3qm9l8n":12,"20201210233038-3xr19g5":5,"20201222100222-q47d64s":3,"20201222100339-i5hzcph":2,"20201227201128-m1wrouw":22,"20201227201751-gv0fpx2":24,"20210110181011-fbhoesf":6,"20210117215840-jcl17fx":4,"20210127203829-qe2mzof":13,"20210331201142-4g923es":15,"20210505164949-c085p1d":3,"20210613191509-cbkxcbz":7,"20210615213222-vs5tzbd":16,"20210721112159-9p645xm":1,"20210721112206-mhr9wxi":2,"20210721160238-yvhbh0h":4,"20210808180303-6yi0dv5":1,"20210808180303-axh6q1d":4,"20210808180303-h361q1i":2,"20210808180303-l3qg72k":3,"20210808180303-xaduj2o":5,"20210824202056-udkf7wg":9,"20211010212318-3wx2kqb":14,"20220105101227-n5zpr1a":6,"20220415232231-pqcizol":1,"20220628204454-hhxohv5":2,"20220708103401-mgydrfg":3,"20221016204105-qx2aq0g":3,"20221223221636-ms2b4w9":17,"20230104152135-1iei0xa":25,"20230106104821-9nfphwm":1,"20230304000547-ibldj1z":18,"20230405172236-pg3l9eu":6,"20230429115711-ejbts4s":5,"20230506205948-yah52eb":10,"20230802114825-2jkkct7":5,"20230805231614-vqn28eh":7,"20230805231816-h1z9mpc":2,"20230805232018-hgrq0ju":1,"20230805232134-3d6mx2k":2,"20240113110040-7sgw8kl":2,"20240119211017-1vbbt95":4,"20240119212048-0huuevw":5,"20240208172514-9dsv6na":8,"20240317202444-5txwumu":9,"20240517031132-jmr5ihm":26,"20260612192252-sgw2paw":27,"20260613155453-sgecaav":0,"20260613212028-gozdm4e":5,"20260614104204-staofnm":28,"20260614113113-ss78888":7,"20260614113156-1jveexn":8,"20260617123409-cmygnqa":1,"20260804171004-aiagt03":1,"20260804171005-semnt03":2,"20260804190002-oidcen1":21,"20260804185002-secvr03":29,"20260804223002-mcpsv03":3}
+{"20200923234011-ieuun1p":1,"20200923234602-gy54e67":10,"20200923234731-h3zkwm2":3,"20200924093441-ft2rhps":1,"20200924095938-a9p5450":2,"20200924100110-vcg96wy":1,"20200924100635-ms0p9lb":7,"20200924100717-yzwzn64":23,"20200924100744-br924ar":11,"20200924100808-j9sddk9":2,"20200924100906-0u4zfq3":4,"20200924100950-9op5xi1":19,"20200924101106-19z4kaa":1,"20200924101200-gss5vee":4,"20200924101225-k254i8g":2,"20200924101256-f8b1sbi":3,"20201004194026-s8h2cog":20,"20201117112518-dott91x":6,"20201121224345-rc27qvo":11,"20201204184532-3qm9l8n":12,"20201210233038-3xr19g5":5,"20201222100222-q47d64s":3,"20201222100339-i5hzcph":2,"20201227201128-m1wrouw":22,"20201227201751-gv0fpx2":24,"20210110181011-fbhoesf":6,"20210117215840-jcl17fx":4,"20210127203829-qe2mzof":13,"20210331201142-4g923es":15,"20210505164949-c085p1d":3,"20210613191509-cbkxcbz":7,"20210615213222-vs5tzbd":16,"20210721112159-9p645xm":1,"20210721112206-mhr9wxi":2,"20210721160238-yvhbh0h":4,"20210808180303-6yi0dv5":1,"20210808180303-axh6q1d":4,"20210808180303-h361q1i":2,"20210808180303-l3qg72k":3,"20210808180303-xaduj2o":5,"20210824202056-udkf7wg":9,"20211010212318-3wx2kqb":14,"20220105101227-n5zpr1a":6,"20220415232231-pqcizol":1,"20220628204454-hhxohv5":3,"20220708103401-mgydrfg":3,"20221016204105-qx2aq0g":4,"20221223221636-ms2b4w9":17,"20230104152135-1iei0xa":25,"20230106104821-9nfphwm":1,"20230304000547-ibldj1z":18,"20230405172236-pg3l9eu":6,"20230429115711-ejbts4s":5,"20230506205948-yah52eb":10,"20230802114825-2jkkct7":5,"20230805231614-vqn28eh":7,"20230805231816-h1z9mpc":2,"20230805232018-hgrq0ju":1,"20230805232134-3d6mx2k":2,"20240113110040-7sgw8kl":2,"20240119211017-1vbbt95":4,"20240119212048-0huuevw":5,"20240208172514-9dsv6na":8,"20240317202444-5txwumu":9,"20240517031132-jmr5ihm":26,"20260612192252-sgw2paw":27,"20260613155453-sgecaav":0,"20260613212028-gozdm4e":5,"20260614104204-staofnm":28,"20260614113113-ss78888":7,"20260614113156-1jveexn":8,"20260617123409-cmygnqa":1,"20260804171004-aiagt03":1,"20260804171005-semnt03":2,"20260804190002-oidcen1":21,"20260804185002-secvr03":29,"20260804223002-mcpsv03":3,"20260830213256-fgl32qu":2}
\ No newline at end of file
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i.sy
index 8400d034a8..b5ce992e1d 100644
--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i.sy
+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i.sy
@@ -7,7 +7,7 @@
"id": "20210808180303-h361q1i",
"title": "Editor",
"type": "doc",
- "updated": "20260809232000"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -197,6 +197,23 @@
}
]
},
+ {
+ "ID": "20260830213256-hfs4974",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260830213256-hfs4974",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "block-ref",
+ "TextMarkBlockRefID": "20260830213256-fgl32qu",
+ "TextMarkBlockRefSubtype": "d",
+ "TextMarkTextContent": "Select and operate content blocks"
+ }
+ ]
+ },
{
"ID": "20240508004216-zyuk3yd",
"Type": "NodeParagraph",
@@ -232,4 +249,4 @@
]
}
]
-}
\ No newline at end of file
+}
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20260830213256-fgl32qu.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20260830213256-fgl32qu.sy
new file mode 100644
index 0000000000..8b330fd131
--- /dev/null
+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20260830213256-fgl32qu.sy
@@ -0,0 +1,305 @@
+{
+ "ID": "20260830213256-fgl32qu",
+ "Spec": "2",
+ "Type": "NodeDocument",
+ "Properties": {
+ "id": "20260830213256-fgl32qu",
+ "title": "Select and operate content blocks",
+ "type": "doc",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-c2i118b",
+ "Properties": {
+ "id": "20260830213256-c2i118b",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Block selection mode lets you select and operate content blocks with the keyboard without returning to text editing after every action. A light outline indicates the current block; only marked blocks are included in a multi-block selection."
+ }
+ ]
+ },
+ {
+ "Type": "NodeHeading",
+ "ID": "20260830213256-5do6z3r",
+ "HeadingLevel": 2,
+ "Properties": {
+ "id": "20260830213256-5do6z3r",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Enter and exit block selection mode"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-819rhwy",
+ "Properties": {
+ "id": "20260830213256-819rhwy",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Place the caret in a content block and press "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Esc"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " to enter block selection mode. Press "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↑"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " or "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↓"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " to make the previous or next block current. Press "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Esc"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " again to exit and clear all marks."
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-03duw1y",
+ "Properties": {
+ "id": "20260830213256-03duw1y",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Press "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Enter"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " to exit and place the caret at the end of the current block when it is editable. Typing other text also exits the mode and edits the current block. In this mode, "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "A"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " inserts a block after the current block and "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "B"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " inserts one before it. To enter either letter as text, exit block selection mode first."
+ }
+ ]
+ },
+ {
+ "Type": "NodeHeading",
+ "ID": "20260830213256-9z618x3",
+ "HeadingLevel": 2,
+ "Properties": {
+ "id": "20260830213256-9z618x3",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Mark blocks and choose operation targets"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-fuhxdnf",
+ "Properties": {
+ "id": "20260830213256-fuhxdnf",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Press "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Space"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " to mark or unmark the current block without moving away from it. Switch the current block with the arrow keys and repeat this action to mark any number of blocks, including non-contiguous blocks. Use "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Shift"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "+"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↑"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " or "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Shift"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "+"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↓"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " to create a contiguous selection."
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-xkf9bt3",
+ "Properties": {
+ "id": "20260830213256-xkf9bt3",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "When one or more blocks are marked, copying, deleting, cutting, and moving apply only to the marked blocks; an unmarked current block is not implicitly included. When no blocks are marked, the current block is the operation target."
+ }
+ ]
+ },
+ {
+ "Type": "NodeHeading",
+ "ID": "20260830213256-7sdato5",
+ "HeadingLevel": 2,
+ "Properties": {
+ "id": "20260830213256-7sdato5",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Delete and move blocks"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-ernfh4j",
+ "Properties": {
+ "id": "20260830213256-ernfh4j",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "With no marked blocks, both "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Delete"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " and "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Backspace"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " delete the current block. With marked blocks, either key deletes all marked blocks. If the current block is deleted, the former makes the next remaining block current and the latter makes the previous remaining block current when available; an unmarked current block remains current."
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-6ah9tb8",
+ "Properties": {
+ "id": "20260830213256-6ah9tb8",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "A single block or a contiguous selection can be moved up or down with the corresponding block commands. Non-contiguous marked blocks cannot be reordered up or down, but "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Move"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " can move them together to another document."
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-9bb0mci",
+ "Properties": {
+ "id": "20260830213256-9bb0mci",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Block selection mode remains active after deleting, cutting, or moving blocks so you can continue selecting and operating blocks."
+ }
+ ]
+ }
+ ]
+}
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy
index 38d37d71aa..71ffe2d60d 100644
--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy
+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy
@@ -7,7 +7,7 @@
"id": "20200924100950-9op5xi1",
"title": "Shortcuts",
"type": "doc",
- "updated": "20260828200251"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -3987,7 +3987,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20210106154056-koo4wdj",
- "updated": "20260828200251"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -4006,7 +4006,7 @@
"HeadingLevel": 3,
"Properties": {
"id": "20210106154319-v9tt3e2",
- "updated": "20260828200251"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -4026,7 +4026,7 @@
"Properties": {
"colgroup": "||",
"id": "20240112150534-wiik5sl",
- "updated": "20260828200251"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -6212,7 +6212,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "Select/deselect the current block"
+ "Data": "Enter or exit block selection mode"
}
]
},
@@ -6237,7 +6237,69 @@
},
{
"Type": "NodeTableCell",
- "Data": "td"
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Block selection mode remains active after deleting, cutting, or moving blocks; see "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "block-ref",
+ "TextMarkBlockRefID": "20260830213256-fgl32qu",
+ "TextMarkBlockRefSubtype": "d",
+ "TextMarkTextContent": "Select and operate content blocks"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "."
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Mark or unmark the current block"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "​"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Space"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Block selection mode only; supports marking non-contiguous blocks"
+ }
+ ]
}
]
},
@@ -6307,7 +6369,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "When a block is selected, press "
+ "Data": "When block selection mode is active, press "
},
{
"Type": "NodeTextMark",
@@ -6388,7 +6450,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "When a block is selected, press "
+ "Data": "When block selection mode is active, press "
},
{
"Type": "NodeTextMark",
@@ -6413,7 +6475,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "Leave block selection and move the caret to the end"
+ "Data": "Exit block selection mode and move the caret to the end"
}
]
},
@@ -6558,7 +6620,13 @@
},
{
"Type": "NodeTableCell",
- "Data": "td"
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Single block or contiguous block selection only"
+ }
+ ]
}
]
},
@@ -6624,7 +6692,13 @@
},
{
"Type": "NodeTableCell",
- "Data": "td"
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Single block or contiguous block selection only"
+ }
+ ]
}
]
},
diff --git a/app/guide/20210808180117-czj9bvb/.siyuan/sort.json b/app/guide/20210808180117-czj9bvb/.siyuan/sort.json
index 123f6b63f2..86aae6ed38 100644
--- a/app/guide/20210808180117-czj9bvb/.siyuan/sort.json
+++ b/app/guide/20210808180117-czj9bvb/.siyuan/sort.json
@@ -1 +1 @@
-{"20200812220555-lj3enxa":1,"20200813004551-gm0pbn1":19,"20200813004931-q4cu8na":1,"20200813013559-sgbzl5k":3,"20200813093015-u6bopdt":3,"20200813125307-pxsjela":2,"20200813131152-0wk5akh":4,"20200813163359-v04n73b":10,"20200822191536-rm6hwid":4,"20200825162036-4dx365o":1,"20200828105441-r76vmu5":23,"20200905090211-2vixtlf":2,"20200910201551-h4twhas":7,"20200915214115-42b8zma":11,"20200922102318-oz84yu3":2,"20201004184819-nj8ibyg":20,"20201117101902-2ewjjum":6,"20201121212605-9td1a62":11,"20201204181006-7bkppue":12,"20201210103036-1x3vm8t":5,"20201222093044-rx4zjoy":2,"20201222095049-hghafhe":3,"20201227173504-847cs1q":22,"20201227194925-7ipoiv6":24,"20210110175347-2xrwoiq":6,"20210117211155-56n4odu":4,"20210127202655-2334vvv":13,"20210331200042-94gs1hh":15,"20210505163537-oo97zov":3,"20210612224500-ywcms1m":7,"20210615211733-v6rzowm":16,"20210808180320-abz7w6k":2,"20210808180320-fqgskfj":1,"20210808180320-gyngv2x":3,"20210808180320-qgr0b3q":5,"20210808180321-hbvl5c2":6,"20210824201257-cy7icrc":9,"20211010211311-ffz0wbu":14,"20220415190432-r3xqn3r":1,"20220628204444-9n0y9h2":2,"20221016213308-uz5af79":3,"20221223215557-o6gfsoy":17,"20230104144904-39br4c6":25,"20230106101434-e6g4av3":1,"20230303235619-ex5l63e":18,"20230405155631-leo4vc6":6,"20230428153709-hioyy5l":7,"20230429114837-70asb4j":5,"20230506210010-houyyvy":10,"20230519105228-hm0y74i":8,"20230805222417-2lj3dvk":7,"20230805225107-qm1m2f5":2,"20230805230131-sn7obzb":1,"20230805230218-aea8icj":2,"20230808120347-3cob0nb":2,"20230808120347-mw3qrwy":4,"20230808120347-pzvmkik":1,"20230808120348-hynr7og":5,"20230808120348-lgcp9zm":3,"20230808120348-vaxi6eq":6,"20230808120348-yut741f":7,"20240113102857-c63dmo5":2,"20240119205452-o8xp4ve":4,"20240119205543-hknwwrl":5,"20240208113259-nykkvaq":8,"20240317200013-fim8wm8":9,"20240517031028-xqinazo":26,"20260612191136-feqbi1x":27,"20260612191214-ymtlxn2":25,"20260612191251-yhv20we":25,"20260613155453-n1se73o":2,"20260613211020-87z3rss":5,"20260614104254-4ifhixg":28,"20260617122823-56cr2zv":3,"20260804171000-aiagt01":1,"20260804171001-semnt01":2,"20260804190000-oidccn1":21,"20260804185000-secvr01":29,"20260804223000-mcpsv01":3}
+{"20200812220555-lj3enxa":1,"20200813004551-gm0pbn1":19,"20200813004931-q4cu8na":1,"20200813013559-sgbzl5k":3,"20200813093015-u6bopdt":3,"20200813125307-pxsjela":2,"20200813131152-0wk5akh":4,"20200813163359-v04n73b":10,"20200822191536-rm6hwid":4,"20200825162036-4dx365o":1,"20200828105441-r76vmu5":23,"20200905090211-2vixtlf":2,"20200910201551-h4twhas":7,"20200915214115-42b8zma":11,"20200922102318-oz84yu3":2,"20201004184819-nj8ibyg":20,"20201117101902-2ewjjum":6,"20201121212605-9td1a62":11,"20201204181006-7bkppue":12,"20201210103036-1x3vm8t":5,"20201222093044-rx4zjoy":2,"20201222095049-hghafhe":3,"20201227173504-847cs1q":22,"20201227194925-7ipoiv6":24,"20210110175347-2xrwoiq":6,"20210117211155-56n4odu":4,"20210127202655-2334vvv":13,"20210331200042-94gs1hh":15,"20210505163537-oo97zov":3,"20210612224500-ywcms1m":7,"20210615211733-v6rzowm":16,"20210808180320-abz7w6k":2,"20210808180320-fqgskfj":1,"20210808180320-gyngv2x":3,"20210808180320-qgr0b3q":5,"20210808180321-hbvl5c2":6,"20210824201257-cy7icrc":9,"20211010211311-ffz0wbu":14,"20220415190432-r3xqn3r":1,"20220628204444-9n0y9h2":3,"20221016213308-uz5af79":4,"20221223215557-o6gfsoy":17,"20230104144904-39br4c6":25,"20230106101434-e6g4av3":1,"20230303235619-ex5l63e":18,"20230405155631-leo4vc6":6,"20230428153709-hioyy5l":7,"20230429114837-70asb4j":5,"20230506210010-houyyvy":10,"20230519105228-hm0y74i":8,"20230805222417-2lj3dvk":7,"20230805225107-qm1m2f5":2,"20230805230131-sn7obzb":1,"20230805230218-aea8icj":2,"20230808120347-3cob0nb":2,"20230808120347-mw3qrwy":4,"20230808120347-pzvmkik":1,"20230808120348-hynr7og":5,"20230808120348-lgcp9zm":3,"20230808120348-vaxi6eq":6,"20230808120348-yut741f":7,"20240113102857-c63dmo5":2,"20240119205452-o8xp4ve":4,"20240119205543-hknwwrl":5,"20240208113259-nykkvaq":8,"20240317200013-fim8wm8":9,"20240517031028-xqinazo":26,"20260612191136-feqbi1x":27,"20260612191214-ymtlxn2":25,"20260612191251-yhv20we":25,"20260613155453-n1se73o":2,"20260613211020-87z3rss":5,"20260614104254-4ifhixg":28,"20260617122823-56cr2zv":3,"20260804171000-aiagt01":1,"20260804171001-semnt01":2,"20260804190000-oidccn1":21,"20260804185000-secvr01":29,"20260804223000-mcpsv01":3,"20260830213256-ye4cos4":2}
\ No newline at end of file
diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k.sy
index d74df58126..c60f986db3 100644
--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k.sy
+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k.sy
@@ -7,7 +7,7 @@
"id": "20210808180320-abz7w6k",
"title": "编辑器",
"type": "doc",
- "updated": "20260809232000"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -200,6 +200,23 @@
}
]
},
+ {
+ "ID": "20260830213256-w99ex05",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260830213256-w99ex05",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "block-ref",
+ "TextMarkBlockRefID": "20260830213256-ye4cos4",
+ "TextMarkBlockRefSubtype": "d",
+ "TextMarkTextContent": "选择和操作内容块"
+ }
+ ]
+ },
{
"ID": "20240507235438-ow9015t",
"Type": "NodeParagraph",
@@ -235,4 +252,4 @@
]
}
]
-}
\ No newline at end of file
+}
diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20260830213256-ye4cos4.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20260830213256-ye4cos4.sy
new file mode 100644
index 0000000000..8b5b75f442
--- /dev/null
+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20260830213256-ye4cos4.sy
@@ -0,0 +1,305 @@
+{
+ "ID": "20260830213256-ye4cos4",
+ "Spec": "2",
+ "Type": "NodeDocument",
+ "Properties": {
+ "id": "20260830213256-ye4cos4",
+ "title": "选择和操作内容块",
+ "type": "doc",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-05q4uos",
+ "Properties": {
+ "id": "20260830213256-05q4uos",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "块选择模式让你无需在每次操作后返回文本编辑,即可使用键盘选择和操作内容块。浅色轮廓仅表示当前块,只有标记块才会包含在多块选择中。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeHeading",
+ "ID": "20260830213256-ub9wfgv",
+ "HeadingLevel": 2,
+ "Properties": {
+ "id": "20260830213256-ub9wfgv",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "进入和退出块选择模式"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-2bk3bwx",
+ "Properties": {
+ "id": "20260830213256-2bk3bwx",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "将光标置于任意内容块中,按 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Esc"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 进入块选择模式。按 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↑"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 或 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↓"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 将上一块或下一块设为当前块。再次按 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Esc"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 可退出并清除所有标记。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-pnwuo8h",
+ "Properties": {
+ "id": "20260830213256-pnwuo8h",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "对于可编辑块,按 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Enter"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 可退出并将光标定位到当前块末尾。输入其他文本也会退出模式并编辑当前块。在此模式下,"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "A"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 会在当前块后插入块,"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "B"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 会在当前块前插入块。需要将这两个字母作为文本输入时,请先退出块选择模式。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeHeading",
+ "ID": "20260830213256-6elx6xx",
+ "HeadingLevel": 2,
+ "Properties": {
+ "id": "20260830213256-6elx6xx",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "标记块并确定操作对象"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-ggq55pk",
+ "Properties": {
+ "id": "20260830213256-ggq55pk",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "按 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "空格"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 标记或取消标记当前块,标记后当前块不会切换。使用方向键切换当前块并重复上述操作,可以标记任意数量的块,包括不连续的块。使用 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Shift"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "+"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↑"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 或 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Shift"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "+"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↓"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 可以形成连续选择。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-kx3rlyp",
+ "Properties": {
+ "id": "20260830213256-kx3rlyp",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "存在标记块时,复制、删除、剪切和移动等操作仅作用于标记块,未标记的当前块不会被自动包含。没有标记块时,当前块就是操作对象。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeHeading",
+ "ID": "20260830213256-sqt2kmg",
+ "HeadingLevel": 2,
+ "Properties": {
+ "id": "20260830213256-sqt2kmg",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "删除和移动块"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-lm5qtwk",
+ "Properties": {
+ "id": "20260830213256-lm5qtwk",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "没有标记块时,"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Delete"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 和 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Backspace"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 都会删除当前块。存在标记块时,这两个按键都会删除所有标记块。如果当前块被删除,前者会将下一剩余块设为当前块,后者会在可用时将上一剩余块设为当前块;未被删除的当前块会保持不变。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-3ml574k",
+ "Properties": {
+ "id": "20260830213256-3ml574k",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "单个块或连续选择的块可以使用相应的块命令向上或向下移动。不连续的标记块不能直接上下重新排序,但可以使用 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "移动"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 功能将它们一起移到另一个文档。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-fe67bww",
+ "Properties": {
+ "id": "20260830213256-fe67bww",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "删除、剪切或移动块后,块选择模式会保持开启,可以继续选择和操作内容块。"
+ }
+ ]
+ }
+ ]
+}
diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy
index fefd9f302f..04477d7812 100644
--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy
+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy
@@ -7,7 +7,7 @@
"id": "20200813004551-gm0pbn1",
"title": "快捷键",
"type": "doc",
- "updated": "20260828200251"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -3985,7 +3985,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20201227133317-rkh4bji",
- "updated": "20260828200251"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -4000,7 +4000,7 @@
"HeadingLevel": 3,
"Properties": {
"id": "20201227133317-kazyttz",
- "updated": "20260828200251"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -4024,7 +4024,7 @@
"Properties": {
"colgroup": "||",
"id": "20201227133317-vopotjc",
- "updated": "20260828200251"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -6168,7 +6168,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "选择/取消选择当前块"
+ "Data": "进入或退出块选择模式"
}
]
},
@@ -6193,7 +6193,69 @@
},
{
"Type": "NodeTableCell",
- "Data": "td"
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "删除、剪切或移动块后仍保持块选择模式,详见"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "block-ref",
+ "TextMarkBlockRefID": "20260830213256-ye4cos4",
+ "TextMarkBlockRefSubtype": "d",
+ "TextMarkTextContent": "选择和操作内容块"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "。"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "标记或取消标记当前块"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "​"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "空格"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "仅在块选择模式下生效,支持标记不连续的块"
+ }
+ ]
}
]
},
@@ -6263,7 +6325,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "块处于选中状态时可直接按 "
+ "Data": "处于块选择模式时可直接按 "
},
{
"Type": "NodeTextMark",
@@ -6340,7 +6402,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "块处于选中状态时可直接按 "
+ "Data": "处于块选择模式时可直接按 "
},
{
"Type": "NodeTextMark",
@@ -6361,7 +6423,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "退出块选中状态并定位到块末尾"
+ "Data": "退出块选择模式并定位到块末尾"
}
]
},
@@ -6506,7 +6568,13 @@
},
{
"Type": "NodeTableCell",
- "Data": "td"
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "仅支持单个块或连续选择的块"
+ }
+ ]
}
]
},
@@ -6572,7 +6640,13 @@
},
{
"Type": "NodeTableCell",
- "Data": "td"
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "仅支持单个块或连续选择的块"
+ }
+ ]
}
]
},
diff --git a/app/guide/20211226090932-5lcq56f/.siyuan/sort.json b/app/guide/20211226090932-5lcq56f/.siyuan/sort.json
index 192d40c0fc..7f556aaaf6 100644
--- a/app/guide/20211226090932-5lcq56f/.siyuan/sort.json
+++ b/app/guide/20211226090932-5lcq56f/.siyuan/sort.json
@@ -1 +1 @@
-{"20211226114339-dk0gtpr":10,"20211226114929-08ap1r0":11,"20211226115043-afhev0g":4,"20211226115227-r1rty9v":3,"20211226115423-d5z1joq":1,"20211226115825-mhcslw2":1,"20211226120055-9mityht":1,"20211226120147-ib6yy3i":2,"20211226120247-63nd8y5":3,"20211226120349-rbkmozu":4,"20211226120422-bkzsd2e":5,"20211226120508-yzh70eh":6,"20211226120802-77aj0is":7,"20211226120854-dr1jfx2":2,"20211226120933-vnjgwwh":3,"20211226121109-f060fkg":4,"20211226121203-rjjngpz":5,"20211226121319-emrk2yy":1,"20211226121322-9argcys":3,"20211226121329-c5v3dto":24,"20211226121332-irgblss":4,"20211226121438-xaafdo8":2,"20211226121503-k3jma6m":1,"20211226121808-fnxmngk":2,"20211226122358-hctqcn5":23,"20211226122459-08mi5cq":22,"20211226122523-rl8356a":20,"20211226122549-jktxego":19,"20211226122707-8cr09co":16,"20211226122728-cnqf7rz":15,"20211226122814-r1rdpcx":14,"20211226122943-st7fpcj":13,"20211226123004-dplpw0o":12,"20211226123038-4umgpxy":11,"20211226123101-qjw03ab":9,"20211226123130-jpeg5b2":7,"20211226123154-fd5e001":6,"20211226123216-tlxw66f":4,"20211226123241-51pujtr":3,"20211226123302-akitvb1":2,"20220105101348-corstqc":6,"20220415232129-shpzg6r":1,"20220628204420-ui79vkt":2,"20220708102441-u6wopo9":3,"20221016213639-1nag9jj":3,"20221223221501-mops33i":17,"20230104151953-48hwkwf":25,"20230106104645-o838uew":1,"20230304000829-9jwu3po":18,"20230405172131-yb16aax":6,"20230429115206-ob8nl8t":5,"20230506211210-1roopyo":10,"20230805232636-zh0adz2":6,"20230805232719-04mqbcx":2,"20230805232903-erdoerp":1,"20230805232920-5fdco36":2,"20240113110500-dz2ae4n":2,"20240119210914-a2tm8c4":4,"20240119212000-qkldbjm":5,"20240208171522-y7dxcno":8,"20240317202230-l8duv3r":9,"20240508010647-8nuyk31":5,"20240517031052-mgoxs16":26,"20260612191214-ymtlxn2":27,"20260613155453-pxxzmhc":3,"20260613211829-rjgkboa":5,"20260614104322-shrqj15":28,"20260614113156-1jveexn":7,"20260614113219-gcm8mer":8,"20260617124140-ttdzn7n":4,"20260804171002-aiagt02":1,"20260804171003-semnt02":2,"20260804190001-oidctw1":21,"20260804185001-secvr02":29,"20260804223001-mcpsv02":3}
+{"20211226114339-dk0gtpr":10,"20211226114929-08ap1r0":11,"20211226115043-afhev0g":4,"20211226115227-r1rty9v":3,"20211226115423-d5z1joq":1,"20211226115825-mhcslw2":1,"20211226120055-9mityht":1,"20211226120147-ib6yy3i":2,"20211226120247-63nd8y5":3,"20211226120349-rbkmozu":4,"20211226120422-bkzsd2e":5,"20211226120508-yzh70eh":6,"20211226120802-77aj0is":7,"20211226120854-dr1jfx2":2,"20211226120933-vnjgwwh":3,"20211226121109-f060fkg":4,"20211226121203-rjjngpz":5,"20211226121319-emrk2yy":1,"20211226121322-9argcys":3,"20211226121329-c5v3dto":24,"20211226121332-irgblss":4,"20211226121438-xaafdo8":2,"20211226121503-k3jma6m":1,"20211226121808-fnxmngk":2,"20211226122358-hctqcn5":23,"20211226122459-08mi5cq":22,"20211226122523-rl8356a":20,"20211226122549-jktxego":19,"20211226122707-8cr09co":16,"20211226122728-cnqf7rz":15,"20211226122814-r1rdpcx":14,"20211226122943-st7fpcj":13,"20211226123004-dplpw0o":12,"20211226123038-4umgpxy":11,"20211226123101-qjw03ab":9,"20211226123130-jpeg5b2":7,"20211226123154-fd5e001":6,"20211226123216-tlxw66f":4,"20211226123241-51pujtr":3,"20211226123302-akitvb1":2,"20220105101348-corstqc":6,"20220415232129-shpzg6r":1,"20220628204420-ui79vkt":3,"20220708102441-u6wopo9":3,"20221016213639-1nag9jj":4,"20221223221501-mops33i":17,"20230104151953-48hwkwf":25,"20230106104645-o838uew":1,"20230304000829-9jwu3po":18,"20230405172131-yb16aax":6,"20230429115206-ob8nl8t":5,"20230506211210-1roopyo":10,"20230805232636-zh0adz2":6,"20230805232719-04mqbcx":2,"20230805232903-erdoerp":1,"20230805232920-5fdco36":2,"20240113110500-dz2ae4n":2,"20240119210914-a2tm8c4":4,"20240119212000-qkldbjm":5,"20240208171522-y7dxcno":8,"20240317202230-l8duv3r":9,"20240508010647-8nuyk31":5,"20240517031052-mgoxs16":26,"20260612191214-ymtlxn2":27,"20260613155453-pxxzmhc":3,"20260613211829-rjgkboa":5,"20260614104322-shrqj15":28,"20260614113156-1jveexn":7,"20260614113219-gcm8mer":8,"20260617124140-ttdzn7n":4,"20260804171002-aiagt02":1,"20260804171003-semnt02":2,"20260804190001-oidctw1":21,"20260804185001-secvr02":29,"20260804223001-mcpsv02":3,"20260830213256-jbsiw4b":2}
\ No newline at end of file
diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2.sy
index 9e24981765..32d3926151 100644
--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2.sy
+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2.sy
@@ -7,7 +7,7 @@
"id": "20211226120854-dr1jfx2",
"title": "編輯器",
"type": "doc",
- "updated": "20260809232000"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -172,6 +172,23 @@
}
]
},
+ {
+ "ID": "20260830213256-xuht7ig",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260830213256-xuht7ig",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "block-ref",
+ "TextMarkBlockRefID": "20260830213256-jbsiw4b",
+ "TextMarkBlockRefSubtype": "d",
+ "TextMarkTextContent": "選取和操作內容區塊"
+ }
+ ]
+ },
{
"ID": "20240508002750-etdih28",
"Type": "NodeParagraph",
@@ -207,4 +224,4 @@
]
}
]
-}
\ No newline at end of file
+}
diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20260830213256-jbsiw4b.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20260830213256-jbsiw4b.sy
new file mode 100644
index 0000000000..80d0380fc5
--- /dev/null
+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20260830213256-jbsiw4b.sy
@@ -0,0 +1,305 @@
+{
+ "ID": "20260830213256-jbsiw4b",
+ "Spec": "2",
+ "Type": "NodeDocument",
+ "Properties": {
+ "id": "20260830213256-jbsiw4b",
+ "title": "選取和操作內容區塊",
+ "type": "doc",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-fqbt9c2",
+ "Properties": {
+ "id": "20260830213256-fqbt9c2",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "區塊選取模式讓你無須在每次操作後返回文字編輯,即可使用鍵盤選取和操作內容區塊。淺色外框僅表示目前區塊,只有標記區塊才會包含在多個區塊的選取中。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeHeading",
+ "ID": "20260830213256-lp6qpp0",
+ "HeadingLevel": 2,
+ "Properties": {
+ "id": "20260830213256-lp6qpp0",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "進入和退出區塊選取模式"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-y3gtmf5",
+ "Properties": {
+ "id": "20260830213256-y3gtmf5",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "將游標置於任意內容區塊中,按 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Esc"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 進入區塊選取模式。按 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↑"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 或 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↓"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 將上一個或下一個區塊設為目前區塊。再次按 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Esc"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 可退出並清除所有標記。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-caiwuf1",
+ "Properties": {
+ "id": "20260830213256-caiwuf1",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "對於可編輯區塊,按 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Enter"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 可退出並將游標定位至目前區塊末尾。輸入其他文字也會退出模式並編輯目前區塊。在此模式下,"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "A"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 會在目前區塊後插入區塊,"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "B"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 會在目前區塊前插入區塊。需要將這兩個字母作為文字輸入時,請先退出區塊選取模式。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeHeading",
+ "ID": "20260830213256-00a3xlr",
+ "HeadingLevel": 2,
+ "Properties": {
+ "id": "20260830213256-00a3xlr",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "標記區塊並確定操作對象"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-mw51eoh",
+ "Properties": {
+ "id": "20260830213256-mw51eoh",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "按 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "空格"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 標記或取消標記目前區塊,標記後目前區塊不會切換。使用方向鍵切換目前區塊並重複上述操作,可以標記任意數量的區塊,包括不連續的區塊。使用 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Shift"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "+"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↑"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 或 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Shift"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "+"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↓"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 可以形成連續選取。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-i8phbor",
+ "Properties": {
+ "id": "20260830213256-i8phbor",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "存在標記區塊時,複製、刪除、剪下和移動等操作僅套用至標記區塊,未標記的目前區塊不會被自動包含。沒有標記區塊時,目前區塊就是操作對象。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeHeading",
+ "ID": "20260830213256-pi0f512",
+ "HeadingLevel": 2,
+ "Properties": {
+ "id": "20260830213256-pi0f512",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "刪除和移動區塊"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-lm1fi7o",
+ "Properties": {
+ "id": "20260830213256-lm1fi7o",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "沒有標記區塊時,"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Delete"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 和 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Backspace"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 都會刪除目前區塊。存在標記區塊時,這兩個按鍵都會刪除所有標記區塊。如果目前區塊被刪除,前者會將下一個剩餘區塊設為目前區塊,後者會在可用時將上一個剩餘區塊設為目前區塊;未被刪除的目前區塊會保持不變。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-o13wude",
+ "Properties": {
+ "id": "20260830213256-o13wude",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "單個區塊或連續選取的區塊可以使用相應的區塊命令向上或向下移動。不連續的標記區塊不能直接上下重新排序,但可以使用 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "移動"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 功能將它們一起移到另一個文件。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-6v240bs",
+ "Properties": {
+ "id": "20260830213256-6v240bs",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "刪除、剪下或移動區塊後,區塊選取模式會保持啟用,可以繼續選取和操作內容區塊。"
+ }
+ ]
+ }
+ ]
+}
diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy
index 5d2fb2c5b3..43ed7c67f4 100644
--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy
+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy
@@ -7,7 +7,7 @@
"id": "20211226122549-jktxego",
"title": "快捷鍵",
"type": "doc",
- "updated": "20260828200251"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -3979,7 +3979,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20211226122652-htptsmh",
- "updated": "20260828200251"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -3994,7 +3994,7 @@
"HeadingLevel": 3,
"Properties": {
"id": "20211226122652-xp1hi60",
- "updated": "20260828200251"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -4014,7 +4014,7 @@
"Properties": {
"colgroup": "||",
"id": "20240112151141-ggglv0f",
- "updated": "20260828200251"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -6181,7 +6181,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "選取/取消選取目前區塊"
+ "Data": "進入或退出區塊選取模式"
}
]
},
@@ -6206,7 +6206,69 @@
},
{
"Type": "NodeTableCell",
- "Data": "td"
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "刪除、剪下或移動區塊後仍保持區塊選取模式,詳見"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "block-ref",
+ "TextMarkBlockRefID": "20260830213256-jbsiw4b",
+ "TextMarkBlockRefSubtype": "d",
+ "TextMarkTextContent": "選取和操作內容區塊"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "。"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "標記或取消標記目前區塊"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "​"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "空格"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "僅在區塊選取模式下生效,支援標記不連續的區塊"
+ }
+ ]
}
]
},
@@ -6276,7 +6338,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "區塊處於選取狀態時可直接按 "
+ "Data": "處於區塊選取模式時可直接按 "
},
{
"Type": "NodeTextMark",
@@ -6353,7 +6415,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "區塊處於選取狀態時可直接按 "
+ "Data": "處於區塊選取模式時可直接按 "
},
{
"Type": "NodeTextMark",
@@ -6374,7 +6436,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "退出區塊選取狀態並定位至區塊末尾"
+ "Data": "退出區塊選取模式並定位至區塊末尾"
}
]
},
@@ -6519,7 +6581,13 @@
},
{
"Type": "NodeTableCell",
- "Data": "td"
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "僅支援單個區塊或連續選取的區塊"
+ }
+ ]
}
]
},
@@ -6585,7 +6653,13 @@
},
{
"Type": "NodeTableCell",
- "Data": "td"
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "僅支援單個區塊或連續選取的區塊"
+ }
+ ]
}
]
},
diff --git a/app/guide/20240530133126-axarxgx/.siyuan/sort.json b/app/guide/20240530133126-axarxgx/.siyuan/sort.json
index 7c4927e681..6856d908c4 100644
--- a/app/guide/20240530133126-axarxgx/.siyuan/sort.json
+++ b/app/guide/20240530133126-axarxgx/.siyuan/sort.json
@@ -1 +1 @@
-{"20240530101000-0zd9si2":14,"20240530101000-1m5un7l":11,"20240530101000-1vvnhju":6,"20240530101000-35bbvcx":2,"20240530101000-3eaevtp":8,"20240530101000-3ourzoa":2,"20240530101000-3qhz7br":1,"20240530101000-3xv6jjr":9,"20240530101000-40hohog":20,"20240530101000-4cqkoel":25,"20240530101000-4p096e8":1,"20240530101000-4qitucx":1,"20240530101000-58z6rjh":2,"20240530101000-5gi76ax":9,"20240530101000-5k5d5i3":2,"20240530101000-6x9ivi7":12,"20240530101000-75auqcn":6,"20240530101000-78d5w10":4,"20240530101000-7yv4y5z":4,"20240530101000-875snki":7,"20240530101000-8m2dowc":10,"20240530101000-96n5y9v":1,"20240530101000-a91lmk2":3,"20240530101000-bb0qktp":1,"20240530101000-bgv304g":8,"20240530101000-boiita2":4,"20240530101000-bpj42r0":2,"20240530101000-cb37szr":7,"20240530101000-d31i9v5":2,"20240530101000-dro2zi9":5,"20240530101000-dytmky4":24,"20240530101000-e6z5okf":2,"20240530101000-ei5t6tt":18,"20240530101000-f16hpct":22,"20240530101000-flot1gj":6,"20240530101000-g3ugxml":5,"20240530101000-gc0tuyd":3,"20240530101000-gcdp3gl":3,"20240530101000-gvtksyj":1,"20240530101000-h0cp5vx":5,"20240530101000-hkgs92c":4,"20240530101000-hnu6o79":2,"20240530101000-hq9sn3k":1,"20240530101000-jp793ic":3,"20240530101000-mpln2lp":5,"20240530101000-mrlr6e9":4,"20240530101000-na9sys7":1,"20240530101000-odye3ea":3,"20240530101000-qf0xtkd":2,"20240530101000-scr2p21":6,"20240530101000-to5uvpi":13,"20240530101000-txrc7z1":16,"20240530101000-uxno1yp":3,"20240530101000-vejnh1k":1,"20240530101000-vql5s27":5,"20240530101000-wo49zvq":2,"20240530101000-xc13cm6":7,"20240530101000-xq26o73":23,"20240530101000-xr22qn8":4,"20240530101000-xsbxokr":19,"20240530101000-ynpmvl7":17,"20240530101000-zj4k048":3,"20240530101000-znj103k":10,"20240530101000-zprnpfi":15,"20240610233601-ylh1mvk":26,"20260612192417-fb4ueux":27,"20260613155453-sncbsow":1,"20260613211946-ods0v99":5,"20260614104715-xe51jlk":28,"20260614113219-gcm8mer":7,"20260617123701-ju7eee5":2,"20260804171006-aiagt04":1,"20260804171007-semnt04":2,"20260804190003-oidcja1":21,"20260804185003-secvr04":29,"20260804223003-mcpsv04":3}
+{"20240530101000-0zd9si2":14,"20240530101000-1m5un7l":11,"20240530101000-1vvnhju":6,"20240530101000-35bbvcx":2,"20240530101000-3eaevtp":8,"20240530101000-3ourzoa":3,"20240530101000-3qhz7br":1,"20240530101000-3xv6jjr":9,"20240530101000-40hohog":20,"20240530101000-4cqkoel":25,"20240530101000-4p096e8":1,"20240530101000-4qitucx":1,"20240530101000-58z6rjh":2,"20240530101000-5gi76ax":9,"20240530101000-5k5d5i3":2,"20240530101000-6x9ivi7":12,"20240530101000-75auqcn":6,"20240530101000-78d5w10":4,"20240530101000-7yv4y5z":4,"20240530101000-875snki":7,"20240530101000-8m2dowc":10,"20240530101000-96n5y9v":1,"20240530101000-a91lmk2":3,"20240530101000-bb0qktp":1,"20240530101000-bgv304g":8,"20240530101000-boiita2":4,"20240530101000-bpj42r0":2,"20240530101000-cb37szr":7,"20240530101000-d31i9v5":2,"20240530101000-dro2zi9":5,"20240530101000-dytmky4":24,"20240530101000-e6z5okf":2,"20240530101000-ei5t6tt":18,"20240530101000-f16hpct":22,"20240530101000-flot1gj":6,"20240530101000-g3ugxml":5,"20240530101000-gc0tuyd":3,"20240530101000-gcdp3gl":4,"20240530101000-gvtksyj":1,"20240530101000-h0cp5vx":5,"20240530101000-hkgs92c":4,"20240530101000-hnu6o79":2,"20240530101000-hq9sn3k":1,"20240530101000-jp793ic":3,"20240530101000-mpln2lp":5,"20240530101000-mrlr6e9":4,"20240530101000-na9sys7":1,"20240530101000-odye3ea":3,"20240530101000-qf0xtkd":2,"20240530101000-scr2p21":6,"20240530101000-to5uvpi":13,"20240530101000-txrc7z1":16,"20240530101000-uxno1yp":3,"20240530101000-vejnh1k":1,"20240530101000-vql5s27":5,"20240530101000-wo49zvq":2,"20240530101000-xc13cm6":7,"20240530101000-xq26o73":23,"20240530101000-xr22qn8":4,"20240530101000-xsbxokr":19,"20240530101000-ynpmvl7":17,"20240530101000-zj4k048":3,"20240530101000-znj103k":10,"20240530101000-zprnpfi":15,"20240610233601-ylh1mvk":26,"20260612192417-fb4ueux":27,"20260613155453-sncbsow":1,"20260613211946-ods0v99":5,"20260614104715-xe51jlk":28,"20260614113219-gcm8mer":7,"20260617123701-ju7eee5":2,"20260804171006-aiagt04":1,"20260804171007-semnt04":2,"20260804190003-oidcja1":21,"20260804185003-secvr04":29,"20260804223003-mcpsv04":3,"20260830213256-014vk79":2}
\ No newline at end of file
diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-xsbxokr.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-xsbxokr.sy
index 12a51c6806..dafeabdba7 100644
--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-xsbxokr.sy
+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-xsbxokr.sy
@@ -9,7 +9,7 @@
"id": "20240530101000-xsbxokr",
"title": "ショートカット",
"type": "doc",
- "updated": "20260828200251"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -3949,7 +3949,7 @@
"Properties": {
"ID": "20240530101000-twmuxke",
"id": "20240530101000-675gu9g",
- "updated": "20260828200251"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -3975,7 +3975,7 @@
"Properties": {
"ID": "20240530101000-tkbdrth",
"id": "20240530101000-9wkmh8w",
- "updated": "20260828200251"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -3995,7 +3995,7 @@
"Properties": {
"colgroup": "||",
"id": "20240530101000-1isfzez",
- "updated": "20260828200251"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -6203,7 +6203,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "現在のブロックを選択/選択解除"
+ "Data": "ブロック選択モードを開始または終了"
}
]
},
@@ -6228,7 +6228,69 @@
},
{
"Type": "NodeTableCell",
- "Data": "td"
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "ブロックの削除、切り取り、移動後もブロック選択モードを維持します。詳しくは"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "block-ref",
+ "TextMarkBlockRefID": "20260830213256-014vk79",
+ "TextMarkBlockRefSubtype": "d",
+ "TextMarkTextContent": "ブロックの選択と操作"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "を参照してください。"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "現在のブロックをマークまたはマーク解除"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "​"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "スペース"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "ブロック選択モードでのみ有効で、連続していないブロックもマーク可能"
+ }
+ ]
}
]
},
@@ -6298,12 +6360,16 @@
"Children": [
{
"Type": "NodeText",
- "Data": "ブロックが選択されている場合は、修飾キーなしで "
+ "Data": "ブロック選択モードでは、修飾キーなしで "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "B"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " を押すこともできます"
}
]
}
@@ -6375,12 +6441,16 @@
"Children": [
{
"Type": "NodeText",
- "Data": "ブロックが選択されている場合は、修飾キーなしで "
+ "Data": "ブロック選択モードでは、修飾キーなしで "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
"TextMarkTextContent": "A"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " を押すこともできます"
}
]
}
@@ -6396,7 +6466,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "ブロックの選択を解除して末尾に移動"
+ "Data": "ブロック選択モードを終了して末尾に移動"
}
]
},
@@ -6541,7 +6611,13 @@
},
{
"Type": "NodeTableCell",
- "Data": "td"
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "単一のブロックまたは連続して選択されたブロックのみ"
+ }
+ ]
}
]
},
@@ -6607,7 +6683,13 @@
},
{
"Type": "NodeTableCell",
- "Data": "td"
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "単一のブロックまたは連続して選択されたブロックのみ"
+ }
+ ]
}
]
},
diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79.sy
index a538575316..d2984600b3 100644
--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79.sy
+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79.sy
@@ -8,7 +8,7 @@
"id": "20240530101000-hnu6o79",
"title": "エディタ",
"type": "doc",
- "updated": "20260809232000"
+ "updated": "20260830213256"
},
"Children": [
{
@@ -191,6 +191,23 @@
}
]
},
+ {
+ "ID": "20260830213256-frho5s0",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260830213256-frho5s0",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "block-ref",
+ "TextMarkBlockRefID": "20260830213256-014vk79",
+ "TextMarkBlockRefSubtype": "d",
+ "TextMarkTextContent": "ブロックの選択と操作"
+ }
+ ]
+ },
{
"ID": "20240530101000-tzn0itl",
"Type": "NodeParagraph",
@@ -236,4 +253,4 @@
}
}
]
-}
\ No newline at end of file
+}
diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20260830213256-014vk79.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20260830213256-014vk79.sy
new file mode 100644
index 0000000000..865c66e648
--- /dev/null
+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20260830213256-014vk79.sy
@@ -0,0 +1,301 @@
+{
+ "ID": "20260830213256-014vk79",
+ "Spec": "2",
+ "Type": "NodeDocument",
+ "Properties": {
+ "id": "20260830213256-014vk79",
+ "title": "ブロックの選択と操作",
+ "type": "doc",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-lavtepl",
+ "Properties": {
+ "id": "20260830213256-lavtepl",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "ブロック選択モードでは、操作のたびにテキスト編集へ戻ることなく、キーボードでブロックを選択して操作できます。薄い枠線は現在のブロックを示すだけで、複数ブロックの選択に含まれるのはマークしたブロックだけです。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeHeading",
+ "ID": "20260830213256-pjttne5",
+ "HeadingLevel": 2,
+ "Properties": {
+ "id": "20260830213256-pjttne5",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "ブロック選択モードの開始と終了"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-5e9nkff",
+ "Properties": {
+ "id": "20260830213256-5e9nkff",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "任意のブロックにカーソルを置き、"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Esc"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " を押すとブロック選択モードになります。"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↑"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " または "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↓"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " を押すと、前または次のブロックが現在のブロックになります。もう一度 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Esc"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " を押すと、すべてのマークを解除してモードを終了します。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-x9egm28",
+ "Properties": {
+ "id": "20260830213256-x9egm28",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "編集可能なブロックでは、"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Enter"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " を押すとモードを終了し、現在のブロック末尾にカーソルを移動します。ほかのテキストを入力した場合も、モードを終了して現在のブロックを編集します。このモードでは、"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "A"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " で現在のブロックの後に、"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "B"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " で前にブロックを挿入します。これらの文字をテキストとして入力するには、先にブロック選択モードを終了してください。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeHeading",
+ "ID": "20260830213256-51dyjx1",
+ "HeadingLevel": 2,
+ "Properties": {
+ "id": "20260830213256-51dyjx1",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "ブロックのマークと操作対象"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-f0fjx1n",
+ "Properties": {
+ "id": "20260830213256-f0fjx1n",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "スペース"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " を押すと、現在のブロックをマークまたはマーク解除できます。マーク後も現在のブロックは切り替わりません。方向キーで現在のブロックを切り替えてこの操作を繰り返すと、離れた位置にある複数のブロックもマークできます。"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Shift"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "+"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↑"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " または "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Shift"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "+"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "↓"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " で連続選択を作成できます。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-zz29ngh",
+ "Properties": {
+ "id": "20260830213256-zz29ngh",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "マークしたブロックがある場合、コピー、削除、切り取り、移動などの操作はマークしたブロックだけに適用され、マークしていない現在のブロックは自動的に含まれません。マークがない場合は、現在のブロックが操作対象になります。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeHeading",
+ "ID": "20260830213256-j3jfq7v",
+ "HeadingLevel": 2,
+ "Properties": {
+ "id": "20260830213256-j3jfq7v",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "ブロックの削除と移動"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-533l69r",
+ "Properties": {
+ "id": "20260830213256-533l69r",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "マークがない場合、"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Delete"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " と "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Backspace"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " はどちらも現在のブロックを削除します。マークがある場合は、どちらのキーでもマークしたすべてのブロックを削除します。現在のブロックが削除された場合、前者は次の残りのブロックを、後者は可能な場合に前の残りのブロックを現在のブロックにします。マークされていない現在のブロックはそのまま維持されます。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-f7qblmk",
+ "Properties": {
+ "id": "20260830213256-f7qblmk",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "単一のブロックまたは連続選択したブロックは、対応するブロックコマンドで上または下へ移動できます。連続していないマーク済みブロックは上下に並べ替えられませんが、"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "ドキュメントを移動"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " を使用すると、まとめて別のドキュメントへ移動できます。"
+ }
+ ]
+ },
+ {
+ "Type": "NodeParagraph",
+ "ID": "20260830213256-9wz9c32",
+ "Properties": {
+ "id": "20260830213256-9wz9c32",
+ "updated": "20260830213256"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "ブロックの削除、切り取り、移動後もブロック選択モードは維持されるため、続けてほかのブロックを選択して操作できます。"
+ }
+ ]
+ }
+ ]
+}
diff --git a/app/src/ai/editor.ts b/app/src/ai/editor.ts
index 88c95f90e4..43c4b04dc7 100644
--- a/app/src/ai/editor.ts
+++ b/app/src/ai/editor.ts
@@ -19,6 +19,7 @@ import {escapeAriaLabel, escapeHtml} from "../util/escape";
import {isMobile} from "../util/functions";
import {Constants} from "../constants";
import {bindThinkingCardToggle} from "./thinkingCard";
+import {BLOCK_SELECTION_MODE_CLASS} from "../protyle/wysiwyg/blockSelection";
type TAIEditorSourceKind = "selection" | "blocks" | "writing";
type TAIEditorTaskStatus = "streaming" | "done" | "stopped" | "error";
@@ -109,10 +110,10 @@ const updateTaskModel = (task: IAIEditorTask) => {
const normalizeSourceElement = (element: HTMLElement) => {
const clone = element.cloneNode(true) as HTMLElement;
- clone.classList.remove("protyle-wysiwyg--select", "protyle-wysiwyg--hl");
+ clone.classList.remove("protyle-wysiwyg--select", BLOCK_SELECTION_MODE_CLASS, "protyle-wysiwyg--hl");
clone.removeAttribute(Constants.ATTRIBUTE_EDITING);
- clone.querySelectorAll(".protyle-wysiwyg--select, .protyle-wysiwyg--hl").forEach(item => {
- item.classList.remove("protyle-wysiwyg--select", "protyle-wysiwyg--hl");
+ clone.querySelectorAll(`.protyle-wysiwyg--select, .${BLOCK_SELECTION_MODE_CLASS}, .protyle-wysiwyg--hl`).forEach(item => {
+ item.classList.remove("protyle-wysiwyg--select", BLOCK_SELECTION_MODE_CLASS, "protyle-wysiwyg--hl");
});
clone.querySelectorAll(`[${Constants.ATTRIBUTE_EDITING}]`).forEach(item => {
item.removeAttribute(Constants.ATTRIBUTE_EDITING);
diff --git a/app/src/assets/scss/protyle/_protyle.scss b/app/src/assets/scss/protyle/_protyle.scss
index 95bd3ec4d5..d3141c7c89 100644
--- a/app/src/assets/scss/protyle/_protyle.scss
+++ b/app/src/assets/scss/protyle/_protyle.scss
@@ -828,6 +828,7 @@ table + .protyle-action__table {
}
.protyle-wysiwyg--select,
+.protyle-wysiwyg--select-mode,
.protyle-wysiwyg--hl {
.protyle-action__table::before {
display: none;
diff --git a/app/src/assets/scss/protyle/_wysiwyg.scss b/app/src/assets/scss/protyle/_wysiwyg.scss
index 471e8d54ee..05bf7db00f 100644
--- a/app/src/assets/scss/protyle/_wysiwyg.scss
+++ b/app/src/assets/scss/protyle/_wysiwyg.scss
@@ -534,6 +534,7 @@
/* 选中块的高亮覆盖 border */
&.protyle-wysiwyg--select::after,
+ &.protyle-wysiwyg--select-mode::after,
&.protyle-wysiwyg--hl::after {
width: calc(100% + 2px);
height: calc(100% + 2px);
@@ -752,6 +753,7 @@
}
&--select::after,
+ &--select-mode::after,
&--hl::after {
background-color: var(--b3-theme-primary-lightest);
position: absolute;
@@ -765,6 +767,10 @@
border-radius: var(--b3-border-radius);
}
+ &--select-mode::after {
+ box-shadow: inset 0 0 0 1px var(--b3-theme-primary-lighter);
+ }
+
&--hl {
transition: var(--b3-background-transition);
}
diff --git a/app/src/block/cancelSuperBlock.test.ts b/app/src/block/cancelSuperBlock.test.ts
index c4392e2a54..6889191db9 100644
--- a/app/src/block/cancelSuperBlock.test.ts
+++ b/app/src/block/cancelSuperBlock.test.ts
@@ -1,6 +1,30 @@
import {describe, it} from "node:test";
import * as assert from "node:assert/strict";
-import {appendCancelSuperBlockOperations, buildCancelSuperBlockOperations} from "./cancelSuperBlock";
+import {
+ appendCancelSuperBlockOperations,
+ buildCancelSuperBlockOperations,
+ resolveCancelSuperBlockChildren
+} from "./cancelSuperBlock";
+
+describe("resolveCancelSuperBlockChildren", () => {
+ it("uses promoted children when a nested super block was already canceled", () => {
+ const result = resolveCancelSuperBlockChildren([{
+ id: "inner-super-block",
+ folded: false,
+ }, {
+ id: "deleted-sibling",
+ folded: false,
+ }], new Set(["deleted-sibling"]), new Map([["inner-super-block", {
+ childIDs: ["folded-heading", "heading-child"],
+ foldedHeadingIDs: ["folded-heading"],
+ }]]));
+
+ assert.deepEqual(result, {
+ childIDs: ["folded-heading", "heading-child"],
+ foldedHeadingIDs: ["folded-heading"],
+ });
+ });
+});
describe("buildCancelSuperBlockOperations", () => {
it("moves every direct child with stable forward and undo anchors", () => {
diff --git a/app/src/block/cancelSuperBlock.ts b/app/src/block/cancelSuperBlock.ts
index 3b68f4a1f6..25fc33fac0 100644
--- a/app/src/block/cancelSuperBlock.ts
+++ b/app/src/block/cancelSuperBlock.ts
@@ -7,6 +7,44 @@ type TCancelSuperBlockOperationOptions = {
parentID?: string,
};
+export interface ISuperBlockChildReplacement {
+ childIDs: string[];
+ foldedHeadingIDs: string[];
+}
+
+export const resolveCancelSuperBlockChildren = (
+ children: Array<{id: string, folded: boolean}>,
+ excludedChildIDs?: Set<string>,
+ childReplacements?: Map<string, ISuperBlockChildReplacement>
+) => {
+ const childIDs: string[] = [];
+ const foldedHeadingIDs: string[] = [];
+ children.forEach(child => {
+ if (excludedChildIDs?.has(child.id)) {
+ return;
+ }
+ const replacement = childReplacements?.get(child.id);
+ if (replacement) {
+ replacement.childIDs.forEach(id => {
+ if (!excludedChildIDs?.has(id)) {
+ childIDs.push(id);
+ }
+ });
+ replacement.foldedHeadingIDs.forEach(id => {
+ if (!excludedChildIDs?.has(id)) {
+ foldedHeadingIDs.push(id);
+ }
+ });
+ } else {
+ childIDs.push(child.id);
+ if (child.folded) {
+ foldedHeadingIDs.push(child.id);
+ }
+ }
+ });
+ return {childIDs, foldedHeadingIDs};
+};
+
const genFoldOperations = (headingIDs: string[], action: "foldHeading" | "unfoldHeading") => {
return headingIDs.map(id => ({action, id}) as IOperation);
};
diff --git a/app/src/block/util.ts b/app/src/block/util.ts
index d7aa671cee..63ca8dcdc8 100644
--- a/app/src/block/util.ts
+++ b/app/src/block/util.ts
@@ -17,7 +17,11 @@ import {fetchPost, fetchSyncPost} from "../util/fetch";
import {openFileById} from "../editor/util";
import {openMobileFileById} from "../mobile/editor";
import {mathRender} from "../protyle/render/mathRender";
-import {buildCancelSuperBlockOperations} from "./cancelSuperBlock";
+import {
+ buildCancelSuperBlockOperations,
+ resolveCancelSuperBlockChildren,
+ type ISuperBlockChildReplacement
+} from "./cancelSuperBlock";
import {shouldFocusJumpTarget, shouldFocusParentDocumentTitle} from "./jumpToParent";
import {getHorizontalSuperBlockChild} from "./superBlock";
@@ -28,6 +32,7 @@ export const getCancelSBOperations = async (nodeElement: Element, options: {
fallbackParentID?: string,
resolveMissingPosition?: boolean,
excludedChildIDs?: Set<string>,
+ childReplacements?: Map<string, ISuperBlockChildReplacement>,
}) => {
const id = nodeElement.getAttribute("data-node-id");
const visibleChildElements = Array.from(nodeElement.children).filter(item =>
@@ -43,11 +48,21 @@ export const getCancelSBOperations = async (nodeElement: Element, options: {
template.innerHTML = response.data?.dom || "";
const fullSuperBlockElement = template.content.querySelector(`[data-node-id="${id}"]`);
if (!fullSuperBlockElement) {
- return {doOperations: [], undoOperations: [], previousId: options.previousID};
+ return {
+ doOperations: [] as IOperation[],
+ undoOperations: [] as IOperation[],
+ childIDs: [] as string[],
+ foldedHeadingIDs: [] as string[],
+ previousId: options.previousID
+ };
}
operationChildElements = Array.from(fullSuperBlockElement.children).filter(item =>
item.hasAttribute("data-node-id") && !options.excludedChildIDs?.has(item.getAttribute("data-node-id")));
}
+ const {childIDs, foldedHeadingIDs} = resolveCancelSuperBlockChildren(operationChildElements.map(item => ({
+ id: item.getAttribute("data-node-id"),
+ folded: item.getAttribute("data-type") === "NodeHeading" && item.getAttribute("fold") === "1",
+ })), options.excludedChildIDs, options.childReplacements);
const sbElement = nodeElement.cloneNode() as HTMLElement;
sbElement.innerHTML = nodeElement.lastElementChild.outerHTML;
let previousId = options.previousID;
@@ -72,21 +87,23 @@ export const getCancelSBOperations = async (nodeElement: Element, options: {
const operationData = buildCancelSuperBlockOperations({
id,
data: sbElement.outerHTML,
- childIDs: operationChildElements.map(item => item.getAttribute("data-node-id")),
- foldedHeadingIDs: operationChildElements.filter(item =>
- item.getAttribute("data-type") === "NodeHeading" && item.getAttribute("fold") === "1"
- ).map(item => item.getAttribute("data-node-id")),
+ childIDs,
+ foldedHeadingIDs,
previousID: previousId,
parentID,
});
const focusId = visibleChildElements[visibleChildElements.length - 1]?.getAttribute("data-node-id") || previousId;
return {
...operationData,
+ childIDs,
+ foldedHeadingIDs,
previousId: focusId
};
};
-export const cancelSB = async (protyle: IProtyle, nodeElement: Element, range?: Range) => {
+export const cancelSB = async (protyle: IProtyle, nodeElement: Element, range?: Range,
+ excludedChildIDs?: Set<string>,
+ childReplacements?: Map<string, ISuperBlockChildReplacement>) => {
nodeElement.classList.remove("protyle-wysiwyg--select");
nodeElement.removeAttribute("select-start");
nodeElement.removeAttribute("select-end");
@@ -94,6 +111,8 @@ export const cancelSB = async (protyle: IProtyle, nodeElement: Element, range?:
notebookID: protyle.notebookId,
fallbackParentID: protyle.block.rootID,
resolveMissingPosition: protyle.block.showAll || !!protyle.options.backlinkData,
+ excludedChildIDs,
+ childReplacements,
});
if (operationData.doOperations.length === 0) {
return operationData;
diff --git a/app/src/boot/globalEvent/command/panel.ts b/app/src/boot/globalEvent/command/panel.ts
index 37506d25a3..c6c5c3dd6d 100644
--- a/app/src/boot/globalEvent/command/panel.ts
+++ b/app/src/boot/globalEvent/command/panel.ts
@@ -475,7 +475,7 @@ export const execByCommand = async (options: {
}
movePathTo({
cb: (toPath) => {
- hintMoveBlock(toPath[0], selectElements, protyle);
+ void hintMoveBlock(toPath[0], selectElements, protyle);
},
flashcard: false,
rootIDs: [protyle.block.rootID],
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index 048c54dc7a..05237efdf3 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -35,7 +35,7 @@ import {
updateBatchTransaction,
updateTransaction
} from "../wysiwyg/transaction";
-import {removeBlock} from "../wysiwyg/remove";
+import {removeBlockPreservingSelectionMode} from "../wysiwyg/remove";
import {focusBlock, focusByRange, getBlockElementsByRange, getEditorRange, selectBlocksByRange} from "../util/selection";
import {hideElements} from "../ui/hideElements";
import {markGutterForFoldRestore} from "../ui/gutterVisibility";
@@ -112,6 +112,7 @@ import {
setOrderedListStart
} from "../wysiwyg/list";
import {applyHeadingLevelUpdates, getHeadingLevelUpdateOperations} from "../util/headingTransform";
+import {getBlockSelectionModeElement} from "../wysiwyg/blockSelection";
import {
getBacklinkGutterContentTop,
getContainerGutterSpace,
@@ -1423,7 +1424,7 @@ export class Gutter {
click: () => {
movePathTo({
cb: (toPath) => {
- hintMoveBlock(toPath[0], selectsElement, protyle);
+ void hintMoveBlock(toPath[0], selectsElement, protyle);
},
flashcard: false
});
@@ -1456,7 +1457,8 @@ export class Gutter {
accelerator: "⌫",
click: () => {
protyle.breadcrumb?.hide();
- removeBlock(protyle, selectsElement[0], getEditorRange(selectsElement[0]), "Backspace");
+ void removeBlockPreservingSelectionMode(protyle, selectsElement[0],
+ getEditorRange(selectsElement[0]), "Backspace");
}
}).element);
@@ -1591,7 +1593,8 @@ export class Gutter {
}
const embedContext = getEmbedGutterOperationContext(nodeElement);
const selectsElement = protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select");
- if (!embedContext && selectsElement.length > 1) {
+ if (!embedContext && (selectsElement.length > 1 ||
+ getBlockSelectionModeElement(protyle.wysiwyg.element) && selectsElement.length > 0)) {
window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_BLOCK_MULTI);
const match = Array.from(selectsElement).find(item => {
if (id === item.getAttribute("data-node-id") ||
@@ -2007,7 +2010,7 @@ export class Gutter {
click: () => {
movePathTo({
cb: (toPath) => {
- hintMoveBlock(toPath[0], [nodeElement], protyle);
+ void hintMoveBlock(toPath[0], [nodeElement], protyle);
},
flashcard: false,
});
@@ -2036,7 +2039,8 @@ export class Gutter {
accelerator: "⌫",
click: () => {
protyle.breadcrumb?.hide();
- removeBlock(protyle, nodeElement, getEditorRange(nodeElement), "Backspace");
+ void removeBlockPreservingSelectionMode(protyle, nodeElement, getEditorRange(nodeElement),
+ "Backspace");
}
}).element);
}
diff --git a/app/src/protyle/hint/extend.ts b/app/src/protyle/hint/extend.ts
index fd6a9822e8..f6c91c96e0 100644
--- a/app/src/protyle/hint/extend.ts
+++ b/app/src/protyle/hint/extend.ts
@@ -8,11 +8,17 @@ import {processRender} from "../util/processCode";
import {highlightRender} from "../render/highlightRender";
import {focusBlock, focusByRange, getEditorRange} from "../util/selection";
import {hasClosestBlock, hasClosestByClassName} from "../util/hasClosest";
-import {getContenteditableElement, getTopAloneElement} from "../wysiwyg/getBlock";
+import {
+ getContenteditableElement,
+ getNextBlock,
+ getPreviousBlock,
+ getSbChildBlockCount,
+ getTopAloneElement
+} from "../wysiwyg/getBlock";
import {replaceFileName} from "../../editor/rename";
import {transaction} from "../wysiwyg/transaction";
import {getAssetExtension, getAssetName, getDisplayName, isEncryptedBox} from "../../util/pathName";
-import {genEmptyElement} from "../../block/util";
+import {cancelSB, genEmptyElement, rebalanceSbWidth, refreshSbResize} from "../../block/util";
import {getOrderedListStart, updateListOrder} from "../wysiwyg/list";
import {escapeHtml, escapeSearchHighlight, stripSearchMark} from "../../util/escape";
import {zoomOut} from "../../menus/protyle";
@@ -36,6 +42,13 @@ import {
TBuiltinInlineStyleID,
} from "../toolbar/inlineStyle";
import {confirmDialog} from "../../dialog/confirmDialog";
+import {
+ getBlockSelectionModeElement,
+ getBlockSelectionStatusIDs,
+ getDeleteSelectionCandidate,
+ setBlockSelectionModeElement
+} from "../wysiwyg/blockSelection";
+import {countBlockWord} from "../../layout/status";
interface ITemplateDocTreePlan {
id: string;
@@ -713,7 +726,7 @@ export const hintRenderAssets = (value: string, protyle: IProtyle) => {
hideElements(["util"], protyle);
};
-export const hintMoveBlock = (pathString: string, sourceElements: Element[], protyle: IProtyle) => {
+export const hintMoveBlock = async (pathString: string, sourceElements: Element[], protyle: IProtyle) => {
if (pathString === "/") {
return;
}
@@ -722,18 +735,31 @@ export const hintMoveBlock = (pathString: string, sourceElements: Element[], pro
return;
}
const doOperations: IOperation[] = [];
- let topSourceElement: Element;
- const parentElement = sourceElements[0].parentElement;
- const listStart = getOrderedListStart(parentElement);
- let sideElement;
- sourceElements.forEach((item, index) => {
- if (index === sourceElements.length - 1 &&
- // 动态加载过慢,导致 item 被移除
- item.parentElement) {
- topSourceElement = getTopAloneElement(item);
- sideElement = topSourceElement.nextElementSibling || topSourceElement.previousElementSibling;
- if (topSourceElement === item) {
- topSourceElement = undefined;
+ const selectionModeElement = getBlockSelectionModeElement(protyle.wysiwyg.element);
+ const sourceParents = new Map<Element, number | undefined>();
+ const sourceSuperBlocks = new Map<Element, Set<string>>();
+ sourceElements.forEach(item => {
+ if (item.parentElement && !sourceParents.has(item.parentElement)) {
+ sourceParents.set(item.parentElement, getOrderedListStart(item.parentElement));
+ }
+ });
+ const candidateElements = Array.from(new Set(sourceElements.filter(item => item.parentElement)
+ .map(item => getTopAloneElement(item))));
+ const sideElement = getDeleteSelectionCandidate(candidateElements, "remove",
+ getPreviousBlock, getNextBlock)?.element;
+ sourceElements.forEach((item) => {
+ let topSourceElement: Element;
+ // 动态加载过慢时 item 可能已被移除,此时仍提交移动操作,但不再处理本地容器。
+ if (item.parentElement) {
+ const topElement = getTopAloneElement(item);
+ if (topElement.parentElement?.getAttribute("data-type") === "NodeSuperBlock") {
+ if (!sourceSuperBlocks.has(topElement.parentElement)) {
+ sourceSuperBlocks.set(topElement.parentElement, new Set());
+ }
+ sourceSuperBlocks.get(topElement.parentElement).add(topElement.getAttribute("data-node-id"));
+ }
+ if (topElement !== item) {
+ topSourceElement = topElement;
}
}
doOperations.push({
@@ -742,18 +768,21 @@ export const hintMoveBlock = (pathString: string, sourceElements: Element[], pro
parentID,
});
item.remove();
+ if (topSourceElement) {
+ doOperations.push({
+ action: "delete",
+ id: topSourceElement.getAttribute("data-node-id"),
+ });
+ topSourceElement.remove();
+ }
});
- // 删除空元素
- if (topSourceElement) {
- doOperations.push({
- action: "delete",
- id: topSourceElement.getAttribute("data-node-id"),
- });
- topSourceElement.remove();
- } else if (parentElement.classList.contains("list") && parentElement.getAttribute("data-subtype") === "o" &&
- parentElement.childElementCount > 1) {
- updateListOrder(parentElement, listStart);
- Array.from(parentElement.children).forEach((item) => {
+ sourceParents.forEach((listStart, sourceParent) => {
+ if (!sourceParent.isConnected || !sourceParent.classList.contains("list") ||
+ sourceParent.getAttribute("data-subtype") !== "o" || sourceParent.childElementCount <= 1) {
+ return;
+ }
+ updateListOrder(sourceParent, listStart);
+ Array.from(sourceParent.children).forEach((item) => {
if (item.classList.contains("protyle-attr")) {
return;
}
@@ -764,12 +793,71 @@ export const hintMoveBlock = (pathString: string, sourceElements: Element[], pro
data: item.outerHTML
});
});
- } else if (protyle.block.showAll && parentElement.classList.contains("protyle-wysiwyg") && parentElement.childElementCount === 0) {
+ });
+ const getElementDepth = (element: Element) => {
+ let depth = 0;
+ let parentElement = element.parentElement;
+ while (parentElement) {
+ depth++;
+ parentElement = parentElement.parentElement;
+ }
+ return depth;
+ };
+ const childReplacements = new Map<string, {
+ childIDs: string[],
+ foldedHeadingIDs: string[]
+ }>();
+ const sortedSuperBlocks = Array.from(sourceSuperBlocks.entries())
+ .sort(([first], [second]) => getElementDepth(second) - getElementDepth(first));
+ for (const [superBlock, excludedChildIDs] of sortedSuperBlocks) {
+ if (!superBlock.isConnected) {
+ continue;
+ }
+ if (getSbChildBlockCount(superBlock) === 1) {
+ const cancelOperations = await cancelSB(protyle, superBlock, undefined, excludedChildIDs,
+ childReplacements);
+ doOperations.push(...cancelOperations.doOperations);
+ if (cancelOperations.doOperations.length > 0) {
+ childReplacements.set(superBlock.getAttribute("data-node-id"), {
+ childIDs: cancelOperations.childIDs || [],
+ foldedHeadingIDs: cancelOperations.foldedHeadingIDs || [],
+ });
+ }
+ } else {
+ refreshSbResize(superBlock);
+ rebalanceSbWidth(superBlock).forEach(change => {
+ const targetElement = superBlock.querySelector(`[data-node-id="${change.id}"]`);
+ if (targetElement) {
+ doOperations.push({
+ action: "setAttrs",
+ id: change.id,
+ data: JSON.stringify({style: targetElement.getAttribute("style") || ""})
+ });
+ }
+ });
+ }
+ }
+ const editorElement = protyle.wysiwyg.element;
+ if (protyle.block.showAll && editorElement.childElementCount === 0) {
+ const focusID = protyle.block.parent2ID;
setTimeout(() => {
- zoomOut({protyle, id: protyle.block.parent2ID, focusId: protyle.block.parent2ID});
+ zoomOut({
+ protyle,
+ id: focusID,
+ focusId: focusID,
+ callback: selectionModeElement ? () => {
+ const targetElement = editorElement.querySelector<HTMLElement>(`[data-node-id="${focusID}"]`) ||
+ editorElement.querySelector<HTMLElement>("[data-node-id]");
+ if (targetElement) {
+ setBlockSelectionModeElement(editorElement, targetElement);
+ focusBlock(targetElement);
+ countBlockWord(getBlockSelectionStatusIDs(editorElement), protyle.block.rootID);
+ }
+ } : undefined,
+ });
}, Constants.TIMEOUT_INPUT * 2 + 100);
- } else if (parentElement.classList.contains("protyle-wysiwyg") && parentElement.innerHTML === "" &&
- !hasClosestByClassName(parentElement, "block__edit", true) &&
+ } else if (editorElement.innerHTML === "" &&
+ !hasClosestByClassName(editorElement, "block__edit", true) &&
protyle.block.id === protyle.block.rootID) {
// 根文档原内容为空
const newId = Lute.NewNodeID();
@@ -780,10 +868,32 @@ export const hintMoveBlock = (pathString: string, sourceElements: Element[], pro
data: newElement.outerHTML,
parentID: protyle.block.parentID
});
- parentElement.innerHTML = newElement.outerHTML;
- focusBlock(newElement);
- } else if (sideElement) {
- focusBlock(sideElement);
+ editorElement.innerHTML = newElement.outerHTML;
+ if (!selectionModeElement) {
+ focusBlock(editorElement.firstElementChild);
+ }
+ } else if (sideElement?.isConnected && editorElement.contains(sideElement) &&
+ sideElement.getAttribute("data-node-id")) {
+ if (!selectionModeElement) {
+ focusBlock(sideElement);
+ }
+ }
+ if (selectionModeElement) {
+ let nextSelectionModeElement: Element;
+ const isValidSelectionModeElement = (element?: Element) => !!element && element.isConnected &&
+ editorElement.contains(element) && !!element.getAttribute("data-node-id");
+ if (isValidSelectionModeElement(selectionModeElement)) {
+ nextSelectionModeElement = selectionModeElement;
+ } else if (isValidSelectionModeElement(sideElement)) {
+ nextSelectionModeElement = sideElement;
+ } else {
+ nextSelectionModeElement = editorElement.querySelector<HTMLElement>("[data-node-id]");
+ }
+ if (nextSelectionModeElement) {
+ setBlockSelectionModeElement(editorElement, nextSelectionModeElement);
+ focusBlock(nextSelectionModeElement);
+ countBlockWord(getBlockSelectionStatusIDs(editorElement), protyle.block.rootID);
+ }
}
// 跨文档不支持撤销
transaction(protyle, doOperations);
diff --git a/app/src/protyle/util/clear.ts b/app/src/protyle/util/clear.ts
index a8802df218..d5ed5cb8d8 100644
--- a/app/src/protyle/util/clear.ts
+++ b/app/src/protyle/util/clear.ts
@@ -3,6 +3,7 @@ import {resetAVRowSelect} from "../render/av/virtualScroll";
import {hasClosestByClassName} from "./hasClosest";
import {Constants} from "../../constants";
import {clearAVCellSelectionState, clearAVItemSelectionState} from "../render/av/selectionState";
+import {BLOCK_SELECTION_MODE_CLASS} from "../wysiwyg/blockSelection";
const getAVElements = (element: Element) => {
const elements: HTMLElement[] = [];
@@ -34,7 +35,10 @@ const clearViewState = (element: Element) => {
export const clearBlockElement = (element: Element, keepRefcount = false) => {
clearViewState(element);
- element.classList.remove("protyle-wysiwyg--select", "protyle-wysiwyg--hl");
+ element.classList.remove("protyle-wysiwyg--select", BLOCK_SELECTION_MODE_CLASS, "protyle-wysiwyg--hl");
+ element.querySelectorAll(`.${BLOCK_SELECTION_MODE_CLASS}`).forEach(item => {
+ item.classList.remove(BLOCK_SELECTION_MODE_CLASS);
+ });
element.removeAttribute(Constants.CUSTOM_RIFF_DECKS);
if (!keepRefcount) {
element.removeAttribute("refcount");
diff --git a/app/src/protyle/wysiwyg/blockSelection.test.ts b/app/src/protyle/wysiwyg/blockSelection.test.ts
new file mode 100644
index 0000000000..33065097d6
--- /dev/null
+++ b/app/src/protyle/wysiwyg/blockSelection.test.ts
@@ -0,0 +1,236 @@
+import {describe, it} from "node:test";
+import * as assert from "node:assert/strict";
+import {
+ BLOCK_SELECTION_MODE_CLASS,
+ BLOCK_SELECTION_CLASS,
+ captureBlockSelectionModeState,
+ getBlockSelectionToggle,
+ getDeleteSelectionCandidate,
+ isContinuousBlockSelection,
+ restoreBlockSelectionModeState
+} from "./blockSelection";
+
+class TestElement {
+ parentElement: TestElement | null = null;
+ children: TestElement[] = [];
+ private attributes = new Map<string, string>();
+ private classes = new Set<string>();
+ classList = {
+ add: (...names: string[]) => names.forEach(name => this.classes.add(name)),
+ contains: (name: string) => this.classes.has(name),
+ remove: (...names: string[]) => names.forEach(name => this.classes.delete(name)),
+ };
+
+ constructor(public name: string, public block = true) {
+ }
+
+ append(...elements: TestElement[]) {
+ elements.forEach(element => {
+ element.parentElement = this;
+ this.children.push(element);
+ });
+ return this;
+ }
+
+ contains(element: TestElement) {
+ let currentElement: TestElement | null = element;
+ while (currentElement) {
+ if (currentElement === this) {
+ return true;
+ }
+ currentElement = currentElement.parentElement;
+ }
+ return false;
+ }
+
+ getAttribute(name: string) {
+ if (name === "data-node-id") {
+ return this.block ? this.name : null;
+ }
+ return this.attributes.get(name) || null;
+ }
+
+ setAttribute(name: string, value: string) {
+ this.attributes.set(name, value);
+ }
+
+ removeAttribute(name: string) {
+ this.attributes.delete(name);
+ }
+
+ querySelectorAll(selector: string) {
+ const elements: TestElement[] = [];
+ const visit = (element: TestElement) => {
+ element.children.forEach(child => {
+ if ((selector === "[data-node-id]" && child.block) ||
+ (selector.startsWith(".") && child.classList.contains(selector.slice(1)))) {
+ elements.push(child);
+ }
+ visit(child);
+ });
+ };
+ visit(this);
+ return elements;
+ }
+}
+
+const asElement = (element: TestElement) => element as unknown as Element;
+
+const getNextBlock = (element: Element) => {
+ const testElement = element as unknown as TestElement;
+ const siblings = testElement.parentElement?.children || [];
+ for (let index = siblings.indexOf(testElement) + 1; index < siblings.length; index++) {
+ if (siblings[index].block) {
+ return asElement(siblings[index]);
+ }
+ }
+ return undefined;
+};
+
+const getPreviousBlock = (element: Element) => {
+ const testElement = element as unknown as TestElement;
+ const siblings = testElement.parentElement?.children || [];
+ for (let index = siblings.indexOf(testElement) - 1; index >= 0; index--) {
+ if (siblings[index].block) {
+ return asElement(siblings[index]);
+ }
+ }
+ return undefined;
+};
+
+describe("getBlockSelectionToggle", () => {
+ it("adds and removes the target without changing unrelated marks", () => {
+ const root = new TestElement("root", false);
+ const first = new TestElement("first");
+ const second = new TestElement("second");
+ root.append(first, second);
+
+ assert.deepEqual(getBlockSelectionToggle([asElement(first)], asElement(second)),
+ [asElement(first), asElement(second)]);
+ assert.deepEqual(getBlockSelectionToggle([asElement(first), asElement(second)], asElement(second)),
+ [asElement(first)]);
+ });
+
+ it("keeps parent and child marks mutually exclusive", () => {
+ const root = new TestElement("root", false);
+ const parent = new TestElement("parent");
+ const child = new TestElement("child");
+ const sibling = new TestElement("sibling");
+ root.append(parent.append(child), sibling);
+
+ assert.deepEqual(getBlockSelectionToggle([asElement(parent), asElement(sibling)], asElement(child)),
+ [asElement(sibling), asElement(child)]);
+ assert.deepEqual(getBlockSelectionToggle([asElement(child), asElement(sibling)], asElement(parent)),
+ [asElement(sibling), asElement(parent)]);
+ });
+});
+
+describe("block selection mode state", () => {
+ it("restores the active block and marked endpoints after replacing a subtree", () => {
+ const editor = new TestElement("editor", false);
+ const oldRoot = new TestElement("root");
+ const oldChild = new TestElement("child");
+ editor.append(oldRoot.append(oldChild));
+ oldChild.classList.add(BLOCK_SELECTION_MODE_CLASS, BLOCK_SELECTION_CLASS);
+ oldChild.setAttribute("select-start", "true");
+ oldChild.setAttribute("select-end", "true");
+ const state = captureBlockSelectionModeState(asElement(oldRoot));
+
+ const newRoot = new TestElement("root");
+ const newChild = new TestElement("child");
+ newRoot.append(newChild);
+ editor.children = [newRoot];
+ newRoot.parentElement = editor;
+ const restoredSelectionModeElement = restoreBlockSelectionModeState(asElement(editor), asElement(newRoot), state);
+
+ assert.equal(restoredSelectionModeElement, asElement(newChild));
+ assert.equal(newChild.classList.contains(BLOCK_SELECTION_MODE_CLASS), true);
+ assert.equal(newChild.classList.contains(BLOCK_SELECTION_CLASS), true);
+ assert.equal(newChild.getAttribute("select-start"), "true");
+ assert.equal(newChild.getAttribute("select-end"), "true");
+ });
+});
+
+describe("isContinuousBlockSelection", () => {
+ it("accepts one block and adjacent blocks while skipping non-block siblings", () => {
+ const root = new TestElement("root", false);
+ const first = new TestElement("first");
+ const attribute = new TestElement("attribute", false);
+ const second = new TestElement("second");
+ root.append(first, attribute, second);
+
+ assert.equal(isContinuousBlockSelection([asElement(first)], getNextBlock), true);
+ assert.equal(isContinuousBlockSelection([asElement(first), asElement(second)], getNextBlock), true);
+ });
+
+ it("rejects empty, non-contiguous, and cross-parent selections", () => {
+ const firstRoot = new TestElement("firstRoot", false);
+ const secondRoot = new TestElement("secondRoot", false);
+ const first = new TestElement("first");
+ const second = new TestElement("second");
+ const third = new TestElement("third");
+ const other = new TestElement("other");
+ firstRoot.append(first, second, third);
+ secondRoot.append(other);
+
+ assert.equal(isContinuousBlockSelection([], getNextBlock), false);
+ assert.equal(isContinuousBlockSelection([asElement(first), asElement(third)], getNextBlock), false);
+ assert.equal(isContinuousBlockSelection([asElement(first), asElement(other)], getNextBlock), false);
+ });
+});
+
+describe("getDeleteSelectionCandidate", () => {
+ const createBlocks = () => {
+ const root = new TestElement("root", false);
+ const blocks = ["A", "B", "C", "D", "E"].map(name => new TestElement(name));
+ root.append(...blocks);
+ return blocks;
+ };
+
+ it("uses the next block for Delete and the previous block for Backspace", () => {
+ const blocks = createBlocks();
+
+ assert.deepEqual(getDeleteSelectionCandidate(blocks.slice(1, 3).map(asElement), "Delete",
+ getPreviousBlock, getNextBlock), {element: asElement(blocks[3]), side: "after"});
+ assert.deepEqual(getDeleteSelectionCandidate(blocks.slice(1, 3).map(asElement), "Backspace",
+ getPreviousBlock, getNextBlock), {element: asElement(blocks[0]), side: "before"});
+ });
+
+ it("uses the outside edges for non-contiguous marks", () => {
+ const blocks = createBlocks();
+ const targets = [asElement(blocks[1]), asElement(blocks[3])];
+
+ assert.deepEqual(getDeleteSelectionCandidate(targets, "Delete", getPreviousBlock, getNextBlock),
+ {element: asElement(blocks[4]), side: "after"});
+ assert.deepEqual(getDeleteSelectionCandidate(targets, "Backspace", getPreviousBlock, getNextBlock),
+ {element: asElement(blocks[0]), side: "before"});
+ });
+
+ it("falls back to the opposite side and returns no candidate when every block is deleted", () => {
+ const blocks = createBlocks();
+
+ assert.deepEqual(getDeleteSelectionCandidate(blocks.slice(3).map(asElement), "Delete",
+ getPreviousBlock, getNextBlock), {element: asElement(blocks[2]), side: "before"});
+ assert.deepEqual(getDeleteSelectionCandidate(blocks.slice(0, 2).map(asElement), "Backspace",
+ getPreviousBlock, getNextBlock), {element: asElement(blocks[2]), side: "after"});
+ assert.equal(getDeleteSelectionCandidate(blocks.map(asElement), "Delete",
+ getPreviousBlock, getNextBlock), undefined);
+ });
+
+ it("skips candidates that are also being deleted", () => {
+ const blocks = createBlocks();
+ const targets = [asElement(blocks[1]), asElement(blocks[3])];
+ const getNextWithDeletedCandidate = (element: Element) => {
+ if (element === asElement(blocks[3])) {
+ return asElement(blocks[1]);
+ }
+ if (element === asElement(blocks[1])) {
+ return asElement(blocks[4]);
+ }
+ return getNextBlock(element);
+ };
+
+ assert.deepEqual(getDeleteSelectionCandidate(targets, "Delete", getPreviousBlock,
+ getNextWithDeletedCandidate), {element: asElement(blocks[4]), side: "after"});
+ });
+});
diff --git a/app/src/protyle/wysiwyg/blockSelection.ts b/app/src/protyle/wysiwyg/blockSelection.ts
new file mode 100644
index 0000000000..0b214bf60d
--- /dev/null
+++ b/app/src/protyle/wysiwyg/blockSelection.ts
@@ -0,0 +1,203 @@
+export const BLOCK_SELECTION_MODE_CLASS = "protyle-wysiwyg--select-mode";
+export const BLOCK_SELECTION_CLASS = "protyle-wysiwyg--select";
+
+type TAdjacentBlock = (element: Element) => Element | false | null | undefined;
+
+export interface IBlockSelectionModeState {
+ activeID?: string;
+ selections: Array<{
+ id: string;
+ selectStart?: string;
+ selectEnd?: string;
+ }>;
+}
+
+const getNextBlockSibling = (element: Element) => {
+ let nextElement = element.nextElementSibling;
+ while (nextElement && !nextElement.getAttribute("data-node-id")) {
+ nextElement = nextElement.nextElementSibling;
+ }
+ return nextElement;
+};
+
+const clearSelectionState = (element: Element) => {
+ element.classList.remove(BLOCK_SELECTION_CLASS);
+ element.removeAttribute("select-start");
+ element.removeAttribute("select-end");
+};
+
+export const getBlockSelectionModeElement = (editorElement: Element) =>
+ editorElement.querySelector<HTMLElement>(`.${BLOCK_SELECTION_MODE_CLASS}`) || undefined;
+
+export const setBlockSelectionModeElement = (editorElement: Element, targetElement: Element) => {
+ if (!editorElement.contains(targetElement) || !targetElement.getAttribute("data-node-id")) {
+ return undefined;
+ }
+ editorElement.querySelectorAll(`.${BLOCK_SELECTION_MODE_CLASS}`).forEach(item => {
+ if (item !== targetElement) {
+ item.classList.remove(BLOCK_SELECTION_MODE_CLASS);
+ }
+ });
+ targetElement.classList.add(BLOCK_SELECTION_MODE_CLASS);
+ return targetElement as HTMLElement;
+};
+
+export const clearBlockSelection = (editorElement: Element) => {
+ editorElement.querySelectorAll(`.${BLOCK_SELECTION_CLASS}`).forEach(clearSelectionState);
+};
+
+export const clearBlockSelectionMode = (editorElement: Element, clearMarks = false) => {
+ editorElement.querySelectorAll(`.${BLOCK_SELECTION_MODE_CLASS}`).forEach(item => {
+ item.classList.remove(BLOCK_SELECTION_MODE_CLASS);
+ });
+ if (clearMarks) {
+ clearBlockSelection(editorElement);
+ }
+};
+
+export const captureBlockSelectionModeState = (rootElement: Element): IBlockSelectionModeState => {
+ const elements = [rootElement, ...Array.from(rootElement.querySelectorAll("[data-node-id]"))];
+ const selectionModeElement = elements.find(item => item.classList.contains(BLOCK_SELECTION_MODE_CLASS));
+ return {
+ activeID: selectionModeElement?.getAttribute("data-node-id") || undefined,
+ selections: elements.filter(item => item.classList.contains(BLOCK_SELECTION_CLASS)).flatMap(item => {
+ const id = item.getAttribute("data-node-id");
+ return id ? [{
+ id,
+ selectStart: item.getAttribute("select-start") || undefined,
+ selectEnd: item.getAttribute("select-end") || undefined,
+ }] : [];
+ }),
+ };
+};
+
+export const restoreBlockSelectionModeState = (editorElement: Element, rootElement: Element,
+ state: IBlockSelectionModeState) => {
+ const elements = [rootElement, ...Array.from(rootElement.querySelectorAll("[data-node-id]"))];
+ const findElement = (id: string) => elements.find(item => item.getAttribute("data-node-id") === id);
+ state.selections.forEach(selection => {
+ const element = findElement(selection.id);
+ if (!element) {
+ return;
+ }
+ element.classList.add(BLOCK_SELECTION_CLASS);
+ if (selection.selectStart) {
+ element.setAttribute("select-start", selection.selectStart);
+ }
+ if (selection.selectEnd) {
+ element.setAttribute("select-end", selection.selectEnd);
+ }
+ });
+ if (state.activeID) {
+ const selectionModeElement = findElement(state.activeID);
+ if (selectionModeElement) {
+ setBlockSelectionModeElement(editorElement, selectionModeElement);
+ return selectionModeElement as HTMLElement;
+ }
+ }
+ return undefined;
+};
+
+export const cleanBlockSelectionModeHTML = (html: string) => {
+ if (!html.includes(BLOCK_SELECTION_MODE_CLASS)) {
+ return html;
+ }
+ const template = document.createElement("template");
+ template.innerHTML = html;
+ const selectionModeElements = template.content.querySelectorAll(`.${BLOCK_SELECTION_MODE_CLASS}`);
+ if (selectionModeElements.length === 0) {
+ return html;
+ }
+ selectionModeElements.forEach(item => item.classList.remove(BLOCK_SELECTION_MODE_CLASS));
+ return template.innerHTML;
+};
+
+export const getBlockSelectionToggle = (selectedElements: Element[], targetElement: Element) => {
+ if (selectedElements.includes(targetElement)) {
+ return selectedElements.filter(item => item !== targetElement);
+ }
+ return selectedElements.filter(item => !item.contains(targetElement) && !targetElement.contains(item))
+ .concat(targetElement);
+};
+
+export const toggleBlockSelection = (editorElement: Element, targetElement: Element) => {
+ const selectedElements = Array.from(editorElement.querySelectorAll(`.${BLOCK_SELECTION_CLASS}`));
+ const nextSelection = getBlockSelectionToggle(selectedElements, targetElement);
+ const nextSelectionSet = new Set(nextSelection);
+ selectedElements.forEach(item => {
+ if (!nextSelectionSet.has(item)) {
+ clearSelectionState(item);
+ }
+ });
+ if (!targetElement.classList.contains(BLOCK_SELECTION_CLASS) && nextSelectionSet.has(targetElement)) {
+ targetElement.classList.add(BLOCK_SELECTION_CLASS);
+ }
+ nextSelection.forEach(item => {
+ item.removeAttribute("select-start");
+ item.removeAttribute("select-end");
+ });
+ return Array.from(editorElement.querySelectorAll<HTMLElement>(`.${BLOCK_SELECTION_CLASS}`));
+};
+
+export const getBlockOperationElements = (editorElement: Element, currentElement?: Element) => {
+ const markedElements = Array.from(editorElement.querySelectorAll<HTMLElement>(`.${BLOCK_SELECTION_CLASS}`));
+ if (markedElements.length > 0) {
+ return markedElements;
+ }
+ return currentElement ? [currentElement as HTMLElement] : [];
+};
+
+export const getBlockSelectionStatusIDs = (editorElement: Element) => {
+ const operationElements = getBlockOperationElements(editorElement, getBlockSelectionModeElement(editorElement));
+ return operationElements.map(item => item.getAttribute("data-node-id")).filter(Boolean);
+};
+
+export const isContinuousBlockSelection = (elements: Element[], getNext: TAdjacentBlock = getNextBlockSibling) => {
+ const uniqueElements = Array.from(new Set(elements));
+ if (uniqueElements.length === 0) {
+ return false;
+ }
+ const parentElement = uniqueElements[0].parentElement;
+ if (!parentElement || uniqueElements.some(item => item.parentElement !== parentElement)) {
+ return false;
+ }
+ return uniqueElements.every((item, index) => index === uniqueElements.length - 1 ||
+ getNext(item) === uniqueElements[index + 1]);
+};
+
+export const getDeleteSelectionCandidate = (elements: Element[], type: "Delete" | "Backspace" | "remove",
+ getPrevious: TAdjacentBlock, getNext: TAdjacentBlock) => {
+ const targets = Array.from(new Set(elements));
+ if (targets.length === 0) {
+ return undefined;
+ }
+ const isDeleted = (element: Element) => targets.some(target => target === element || target.contains(element));
+ const findCandidate = (startElement: Element, getAdjacent: TAdjacentBlock) => {
+ const visited = new Set<Element>();
+ let candidate = getAdjacent(startElement);
+ while (candidate && (isDeleted(candidate) || visited.has(candidate))) {
+ if (visited.has(candidate)) {
+ return undefined;
+ }
+ visited.add(candidate);
+ candidate = getAdjacent(candidate);
+ }
+ return candidate || undefined;
+ };
+ const firstElement = targets[0];
+ const lastElement = targets[targets.length - 1];
+ if (type === "Backspace") {
+ const previousElement = findCandidate(firstElement, getPrevious);
+ if (previousElement) {
+ return {element: previousElement, side: "before" as const};
+ }
+ const nextElement = findCandidate(lastElement, getNext);
+ return nextElement ? {element: nextElement, side: "after" as const} : undefined;
+ }
+ const nextElement = findCandidate(lastElement, getNext);
+ if (nextElement) {
+ return {element: nextElement, side: "after" as const};
+ }
+ const previousElement = findCandidate(firstElement, getPrevious);
+ return previousElement ? {element: previousElement, side: "before" as const} : undefined;
+};
diff --git a/app/src/protyle/wysiwyg/enter.ts b/app/src/protyle/wysiwyg/enter.ts
index 92bfa926b3..1be9203b0d 100644
--- a/app/src/protyle/wysiwyg/enter.ts
+++ b/app/src/protyle/wysiwyg/enter.ts
@@ -33,18 +33,35 @@ import {hasClosestByAttribute, hasClosestByClassName} from "../util/hasClosest";
import {blockRender} from "../render/blockRender";
import {isCodeBlockFenceBeforeCaret} from "./codeBlockEnter";
import {isEmptyListItemBlock, shouldCreateListItemChildOnEnter} from "./listContext";
+import {
+ BLOCK_SELECTION_CLASS,
+ clearBlockSelectionMode,
+ getBlockSelectionModeElement
+} from "./blockSelection";
export const enter = async (blockElement: HTMLElement, range: Range, protyle: IProtyle) => {
+ const selectionModeElement = getBlockSelectionModeElement(protyle.wysiwyg.element);
+ if (selectionModeElement) {
+ blockElement = selectionModeElement;
+ }
const embedResultElement = hasClosestByClassName(blockElement, "protyle-wysiwyg__embed");
const embedContext = getEmbedChildOperationContext(blockElement);
if (embedResultElement && !embedContext && !blockElement.classList.contains("code-block")) {
+ if (selectionModeElement) {
+ clearBlockSelectionMode(protyle.wysiwyg.element, true);
+ }
return;
}
const disableElement = isNotEditBlock(blockElement);
- if (!disableElement && blockElement.classList.contains("protyle-wysiwyg--select")) {
+ const isBlockMode = !!selectionModeElement || blockElement.classList.contains(BLOCK_SELECTION_CLASS);
+ if (!disableElement && isBlockMode) {
setLastNodeRange(getContenteditableElement(blockElement), range, false);
range.collapse(false);
- hideElements(["select"], protyle);
+ if (selectionModeElement) {
+ clearBlockSelectionMode(protyle.wysiwyg.element, true);
+ } else {
+ hideElements(["select"], protyle);
+ }
return;
}
protyle.observerLoad?.disconnect();
@@ -52,7 +69,10 @@ export const enter = async (blockElement: HTMLElement, range: Range, protyle: IP
if (disableElement ||
// https://github.com/siyuan-note/siyuan/issues/10633
blockElement.classList.contains("table")) {
- if (blockElement.classList.contains("protyle-wysiwyg--select") && blockElement.classList.contains("render-node")) {
+ if (selectionModeElement) {
+ clearBlockSelectionMode(protyle.wysiwyg.element, true);
+ }
+ if (isBlockMode && blockElement.classList.contains("render-node")) {
protyle.toolbar.showRender(protyle, blockElement);
} else {
insertEmptyBlock(protyle, "afterend");
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index 93cbafd273..81f5a7ec1c 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -78,7 +78,7 @@ import {
IBlockRefCheckTargets,
ICrossBlockComposition,
prepareCrossBlockComposition,
- removeBlock,
+ removeBlockPreservingSelectionMode,
removeCrossBlockRange
} from "./remove";
import {highlightRender} from "../render/highlightRender";
@@ -202,6 +202,14 @@ import {LargeListVirtualizer} from "./listVirtualization";
import {forEachPluginSubscriber} from "../../plugin/EventBusCore";
import {syncRootAttributes} from "../util/syncRootAttributes";
import {isDirectCalloutStructureClick} from "./calloutClick";
+import {
+ BLOCK_SELECTION_CLASS,
+ clearBlockSelectionMode,
+ cleanBlockSelectionModeHTML,
+ getBlockSelectionModeElement,
+ getBlockSelectionStatusIDs,
+ toggleBlockSelection
+} from "./blockSelection";
interface IShiftClickBlockPoint {
blockElement: HTMLElement;
@@ -725,6 +733,7 @@ export class WYSIWYG {
if (!nodeElement) {
return;
}
+ const selectionModeElement = getBlockSelectionModeElement(protyle.wysiwyg.element);
const selectImgElement = nodeElement.querySelector(".img--select");
const selectAVElement = nodeElement.querySelector(".av__row--select, .av__cell--select") ||
(getAVSelectedCells(nodeElement).length > 0 ||
@@ -749,12 +758,15 @@ export class WYSIWYG {
}
}
}
- let selectElements = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));
+ let selectElements = Array.from(protyle.wysiwyg.element.querySelectorAll(`.${BLOCK_SELECTION_CLASS}`));
if (selectElements.length === 0 && range.toString() === "" && !range.cloneContents().querySelector("img") &&
!selectImgElement && !selectAVElement && !selectTableElement) {
- nodeElement.classList.add("protyle-wysiwyg--select");
- countBlockWord([nodeElement.getAttribute("data-node-id")]);
- selectElements = [nodeElement];
+ const copyElement = selectionModeElement || nodeElement;
+ if (!selectionModeElement) {
+ copyElement.classList.add(BLOCK_SELECTION_CLASS);
+ countBlockWord([copyElement.getAttribute("data-node-id")]);
+ }
+ selectElements = [copyElement];
}
let html = "";
let textPlain = "";
@@ -803,6 +815,7 @@ export class WYSIWYG {
} else {
itemHTML = removeEmbed(item);
}
+ itemHTML = cleanBlockSelectionModeHTML(itemHTML);
if (item.getAttribute("data-type") === "NodeListItem") {
if (!listHTML) {
listHTML = `<div data-subtype="${item.getAttribute("data-subtype")}" data-node-id="${Lute.NewNodeID()}" data-type="NodeList" class="list">`;
@@ -1079,6 +1092,13 @@ export class WYSIWYG {
// 右键
return;
}
+ if (getBlockSelectionModeElement(this.element)) {
+ const preserveMarks = isOnlyMeta(event) || event.shiftKey;
+ clearBlockSelectionMode(this.element, !preserveMarks);
+ if (!preserveMarks) {
+ countBlockWord([], protyle.block.rootID);
+ }
+ }
if (getAVTemplateInteractiveElement(event.target)) {
event.stopPropagation();
return;
@@ -1202,29 +1222,8 @@ export class WYSIWYG {
ctrlElement = embedBlockElement;
}
ctrlElement = getTopAloneElement(ctrlElement) as HTMLElement;
- if (ctrlElement.classList.contains("protyle-wysiwyg--select")) {
- ctrlElement.classList.remove("protyle-wysiwyg--select");
- ctrlElement.removeAttribute("select-start");
- ctrlElement.removeAttribute("select-end");
- } else {
- ctrlElement.classList.add("protyle-wysiwyg--select");
- }
- ctrlElement.querySelectorAll(".protyle-wysiwyg--select").forEach(item => {
- item.classList.remove("protyle-wysiwyg--select");
- item.removeAttribute("select-start");
- item.removeAttribute("select-end");
- });
- const ctrlParentElement = hasClosestByClassName(ctrlElement.parentElement, "protyle-wysiwyg--select");
- if (ctrlParentElement) {
- ctrlParentElement.classList.remove("protyle-wysiwyg--select");
- ctrlParentElement.removeAttribute("select-start");
- ctrlParentElement.removeAttribute("select-end");
- }
- const ids: string[] = [];
- protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select").forEach(item => {
- ids.push(item.getAttribute("data-node-id"));
- });
- countBlockWord(ids);
+ toggleBlockSelection(protyle.wysiwyg.element, ctrlElement);
+ countBlockWord(getBlockSelectionStatusIDs(protyle.wysiwyg.element));
}
return;
}
@@ -2948,8 +2947,10 @@ export class WYSIWYG {
event.preventDefault();
return;
}
+ const selectionModeElement = getBlockSelectionModeElement(protyle.wysiwyg.element);
+ const hasMarkedBlocks = !!protyle.wysiwyg.element.querySelector(`.${BLOCK_SELECTION_CLASS}`);
const calloutTitleElement = hasClosestByClassName(range.startContainer, "callout-title");
- if (calloutTitleElement && calloutTitleElement.contains(range.endContainer)) {
+ if (!hasMarkedBlocks && calloutTitleElement && calloutTitleElement.contains(range.endContainer)) {
setInsertWbrHTML(nodeElement, range, protyle);
return;
}
@@ -2957,7 +2958,7 @@ export class WYSIWYG {
const embedElement = isInEmbedBlock(nodeElement);
const isSameBlockTextCut = !range.collapsed && range.toString() !== "" &&
hasClosestBlock(range.endContainer) === nodeElement;
- if (embedElement && !embedElement.classList.contains("protyle-wysiwyg--select") &&
+ if (!hasMarkedBlocks && embedElement && !embedElement.classList.contains(BLOCK_SELECTION_CLASS) &&
!isSameBlockTextCut) {
event.stopPropagation();
event.preventDefault();
@@ -2989,15 +2990,28 @@ export class WYSIWYG {
}
}
}
- let selectElements = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));
+ let selectElements = Array.from(protyle.wysiwyg.element.querySelectorAll(`.${BLOCK_SELECTION_CLASS}`));
const cloneElement = range.cloneContents();
let autoSelectedBlock = false;
+ let autoSelectedElement: HTMLElement;
if (selectElements.length === 0 && range.toString() === "" && !cloneElement.querySelector("img") &&
!selectImgElement && !selectAVElement && !selectTableElement) {
- nodeElement.classList.add("protyle-wysiwyg--select");
- selectElements = [nodeElement];
+ autoSelectedElement = selectionModeElement || nodeElement;
+ autoSelectedElement.classList.add(BLOCK_SELECTION_CLASS);
+ selectElements = [autoSelectedElement];
autoSelectedBlock = true;
}
+ const clearAutoSelectedBlock = () => {
+ if (!autoSelectedBlock || !autoSelectedElement?.isConnected) {
+ return;
+ }
+ autoSelectedElement.classList.remove(BLOCK_SELECTION_CLASS);
+ autoSelectedElement.removeAttribute("select-start");
+ autoSelectedElement.removeAttribute("select-end");
+ if (selectionModeElement) {
+ countBlockWord(getBlockSelectionStatusIDs(protyle.wysiwyg.element), protyle.block.rootID);
+ }
+ };
const selectedStateElements = [...selectElements];
const endElement = hasClosestBlock(range.endContainer);
const cutCrossBlockRange = selectedStateElements.length === 0 && !range.collapsed &&
@@ -3095,6 +3109,7 @@ export class WYSIWYG {
id: item.getAttribute("data-node-id"),
});
if (deleteResponse.code !== 0) {
+ clearAutoSelectedBlock();
return;
}
deleteResponse.data.doOperations.forEach((operation: IOperation) => {
@@ -3113,6 +3128,7 @@ export class WYSIWYG {
} else {
itemHTML = removeEmbed(item);
}
+ itemHTML = cleanBlockSelectionModeHTML(itemHTML);
if (item.getAttribute("data-type") === "NodeListItem") {
if (!listHTML) {
listHTML = `<div data-subtype="${item.getAttribute("data-subtype")}" data-node-id="${Lute.NewNodeID()}" data-type="NodeList" class="list">`;
@@ -3136,12 +3152,11 @@ export class WYSIWYG {
deletedIDs: uniqueCheckIDs,
notebook: protyle.notebookId,
}, protyle)) {
- if (autoSelectedBlock) {
- nodeElement.classList.remove("protyle-wysiwyg--select");
- }
+ clearAutoSelectedBlock();
return;
}
if (selectedStateElements.some(item => !item.isConnected || !item.classList.contains("protyle-wysiwyg--select"))) {
+ clearAutoSelectedBlock();
return;
}
needClipboardWrite = true;
@@ -3405,11 +3420,16 @@ export class WYSIWYG {
undefined, false, false, false, cutAVCells);
}
if (cutBlockSelection && clipboardWriteSucceeded) {
- const removed = await removeBlock(protyle, nodeElement, range, "remove", true);
- if (removed && cutNextElement && cutNextElement.isConnected) {
+ const removed = await removeBlockPreservingSelectionMode(protyle, nodeElement, range,
+ "remove", true);
+ if (!removed && autoSelectedBlock) {
+ clearAutoSelectedBlock();
+ } else if (removed && !selectionModeElement && cutNextElement && cutNextElement.isConnected) {
// Ctrl+X 剪切后光标应跳到下一行行首 https://github.com/siyuan-note/siyuan/issues/5485
focusBlock(cutNextElement);
}
+ } else if (autoSelectedBlock && selectionModeElement?.isConnected) {
+ clearAutoSelectedBlock();
}
}
});
@@ -3426,7 +3446,8 @@ export class WYSIWYG {
const x = event.clientX || event.detail.x;
const y = event.clientY || event.detail.y;
const selectElements = protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select");
- if (selectElements.length > 1) {
+ if (selectElements.length > 1 ||
+ getBlockSelectionModeElement(protyle.wysiwyg.element) && selectElements.length > 0) {
// 多选块
hideElements(["util"], protyle);
protyle.gutter.renderMenu(protyle, selectElements[0]);
@@ -3879,6 +3900,11 @@ export class WYSIWYG {
// 但搜狗输入法选中后继续输入不走 keydown,isComposition 阻止了 keyup 记录,因此需在此记录。
const range = getEditorRange(protyle.wysiwyg.element);
const nodeElement = hasClosestBlock(range.startContainer);
+ const selectionModeElement = getBlockSelectionModeElement(protyle.wysiwyg.element);
+ if (selectionModeElement) {
+ clearBlockSelectionMode(protyle.wysiwyg.element, true);
+ countBlockWord([], protyle.block.rootID);
+ }
if (nodeElement) {
const startCell = hasClosestByTag(range.startContainer, "TD") || hasClosestByTag(range.startContainer, "TH");
if (startCell && !isAfterInlineMath(range)) {
@@ -3897,7 +3923,7 @@ export class WYSIWYG {
crossBlockComposition = prepareCrossBlockComposition(
protyle, range, nodeElement, endElement);
}
- if (!isMac() && nodeElement && !crossBlockComposition) {
+ if ((selectionModeElement || !isMac()) && nodeElement && !crossBlockComposition) {
setInsertWbrHTML(nodeElement, range, protyle);
}
event.stopPropagation();
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index 19e3048894..c5615792f0 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -31,6 +31,7 @@ import {
getImageBlockRefCheckTargets,
getRangeBlockRefCheckTargets,
removeBlock,
+ removeBlockPreservingSelectionMode,
removeCrossBlockRange,
removeImage
} from "./remove";
@@ -122,6 +123,31 @@ import {isMobile} from "../../util/functions";
import {confirmBlockRef} from "../../util/checkBlockRef";
import {scheduleCaretScroll} from "./caretScroll";
import {scrollPage} from "../scroll/page";
+import {
+ BLOCK_SELECTION_CLASS,
+ clearBlockSelectionMode,
+ clearBlockSelection,
+ getBlockSelectionModeElement,
+ getBlockSelectionStatusIDs,
+ isContinuousBlockSelection,
+ setBlockSelectionModeElement,
+ toggleBlockSelection
+} from "./blockSelection";
+
+const countBlockSelectionMode = (protyle: IProtyle) => {
+ countBlockWord(getBlockSelectionStatusIDs(protyle.wysiwyg.element), protyle.block.rootID);
+};
+
+const syncBlockSelectionModeToSelectionEnd = (protyle: IProtyle, direction: "up" | "down") => {
+ const selectElements = Array.from(protyle.wysiwyg.element.querySelectorAll<HTMLElement>(
+ `.${BLOCK_SELECTION_CLASS}`));
+ const targetElement = selectElements.find(item => item.getAttribute("select-end") === "true") ||
+ (direction === "up" ? selectElements[0] : selectElements[selectElements.length - 1]);
+ if (targetElement) {
+ setBlockSelectionModeElement(protyle.wysiwyg.element, targetElement);
+ focusBlock(targetElement);
+ }
+};
export const getContentByInlineHTML = (range: Range, cb: (content: string) => void) => {
let html = "";
@@ -279,6 +305,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (!nodeElement) {
return;
}
+ const blockSelectionModeElement = getBlockSelectionModeElement(protyle.wysiwyg.element);
const calloutTitleElement = hasClosestByClassName(range.startContainer, "callout-title");
if (document.querySelector(".av__panel")) {
@@ -288,23 +315,32 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
return;
}
- if (nodeElement.classList.contains("protyle-wysiwyg--select") && isNotCtrl(event) && !event.shiftKey && !event.altKey &&
+ if ((nodeElement.classList.contains(BLOCK_SELECTION_CLASS) || blockSelectionModeElement) &&
+ isNotCtrl(event) && !event.shiftKey && !event.altKey &&
!isInEmbedBlock(nodeElement)) {
if (event.key.toLowerCase() === "a") {
event.stopPropagation();
event.preventDefault();
protyle.wysiwyg.element.blur();
+ if (blockSelectionModeElement) {
+ clearBlockSelectionMode(protyle.wysiwyg.element, true);
+ countBlockWord([], protyle.block.rootID);
+ }
// 阻止中文输入的残留
setTimeout(() => {
- insertEmptyBlock(protyle, "afterend");
+ insertEmptyBlock(protyle, "afterend", blockSelectionModeElement);
}, 100);
return false;
} else if (event.key.toLowerCase() === "b") {
event.stopPropagation();
event.preventDefault();
protyle.wysiwyg.element.blur();
+ if (blockSelectionModeElement) {
+ clearBlockSelectionMode(protyle.wysiwyg.element, true);
+ countBlockWord([], protyle.block.rootID);
+ }
setTimeout(() => {
- insertEmptyBlock(protyle, "beforebegin");
+ insertEmptyBlock(protyle, "beforebegin", blockSelectionModeElement);
}, 100);
return false;
}
@@ -336,14 +372,14 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
// 有可能输入 shift+. ,因此需要使用 event.key 来进行判断
if (typeof event.key === "string" && event.key !== "PageUp" && event.key !== "PageDown" && event.key !== "Home" && event.key !== "End" && event.key.indexOf("Arrow") === -1 &&
event.key !== "Escape" && event.key !== "Shift" && event.key !== "Meta" && event.key !== "Alt" && event.key !== "Control" && event.key !== "CapsLock" &&
- !isNotEditBlock(nodeElement) && !/^F\d{1,2}$/.test(event.key) &&
+ !blockSelectionModeElement && !isNotEditBlock(nodeElement) && !/^F\d{1,2}$/.test(event.key) &&
// 微软双拼使用 compositionstart,否则 focusByRange 导致无法输入文字
event.key !== "Process") {
setInsertWbrHTML(nodeElement, range, protyle);
protyle.wysiwyg.preventKeyup = true;
}
- if (calloutTitleElement && !event.isComposing) {
+ if (calloutTitleElement && !event.isComposing && !blockSelectionModeElement) {
if (matchHotKey("⌘A", event)) {
range.selectNodeContents(calloutTitleElement);
focusByRange(range);
@@ -383,7 +419,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (!event.altKey && isNotCtrl(event) && !event.isComposing &&
(event.key === "ArrowUp" || event.key === "ArrowDown") &&
- !protyle.wysiwyg.element.querySelector(".protyle-wysiwyg--select")) {
+ !blockSelectionModeElement && !protyle.wysiwyg.element.querySelector(`.${BLOCK_SELECTION_CLASS}`)) {
scheduleCaretScroll(protyle, event.key === "ArrowUp" ? "up" : "down");
}
@@ -392,13 +428,16 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
}
if (!event.altKey && !event.shiftKey && isNotCtrl(event) && (event.key === "ArrowDown" || event.key === "ArrowUp")) {
- const selectElements = protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select");
- if (selectElements.length > 0) {
+ const selectElements = protyle.wysiwyg.element.querySelectorAll(`.${BLOCK_SELECTION_CLASS}`);
+ if (blockSelectionModeElement || selectElements.length > 0) {
event.preventDefault();
event.stopPropagation();
- hideElements(["select"], protyle);
+ if (!blockSelectionModeElement) {
+ hideElements(["select"], protyle);
+ }
if (event.key === "ArrowDown") {
- const currentSelectElement = selectElements[selectElements.length - 1] as HTMLElement;
+ const currentSelectElement = blockSelectionModeElement ||
+ selectElements[selectElements.length - 1] as HTMLElement;
let nextElement = getNextBlock(currentSelectElement) as HTMLElement;
if (nextElement) {
if (nextElement.getBoundingClientRect().width === 0) {
@@ -424,8 +463,13 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
nextElement = currentSelectElement;
}
- nextElement.classList.add("protyle-wysiwyg--select");
- countBlockWord([nextElement.getAttribute("data-node-id")]);
+ if (blockSelectionModeElement) {
+ setBlockSelectionModeElement(protyle.wysiwyg.element, nextElement);
+ countBlockSelectionMode(protyle);
+ } else {
+ nextElement.classList.add(BLOCK_SELECTION_CLASS);
+ countBlockWord([nextElement.getAttribute("data-node-id")]);
+ }
const bottom = nextElement.getBoundingClientRect().bottom - protyle.contentElement.getBoundingClientRect().bottom;
if (bottom > 0) {
protyle.contentElement.scrollTop = protyle.contentElement.scrollTop + bottom;
@@ -433,7 +477,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
}
focusBlock(nextElement);
} else if (event.key === "ArrowUp") {
- let previousElement: HTMLElement = getPreviousBlock(selectElements[0]) as HTMLElement;
+ const currentSelectElement = blockSelectionModeElement || selectElements[0] as HTMLElement;
+ let previousElement: HTMLElement = getPreviousBlock(currentSelectElement) as HTMLElement;
if (previousElement) {
previousElement = getLastBlock(previousElement) as HTMLElement;
if (previousElement.getBoundingClientRect().width === 0) {
@@ -442,7 +487,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (foldElement) {
previousElement = getFirstBlock(foldElement) as HTMLElement;
} else {
- previousElement = selectElements[0] as HTMLElement;
+ previousElement = currentSelectElement;
}
} else if (previousElement) {
// https://github.com/siyuan-note/siyuan/issues/3913
@@ -458,15 +503,24 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
focusByRange(titleRange);
event.stopPropagation();
event.preventDefault();
+ if (blockSelectionModeElement) {
+ clearBlockSelectionMode(protyle.wysiwyg.element, true);
+ countBlockWord([], protyle.block.rootID);
+ }
} else if (protyle.contentElement.scrollTop !== 0) {
protyle.contentElement.scrollTop = 0;
protyle.scroll.lastScrollTop = 8;
} else {
- previousElement = selectElements[0] as HTMLElement;
+ previousElement = currentSelectElement;
}
if (previousElement) {
- previousElement.classList.add("protyle-wysiwyg--select");
- countBlockWord([previousElement.getAttribute("data-node-id")]);
+ if (blockSelectionModeElement) {
+ setBlockSelectionModeElement(protyle.wysiwyg.element, previousElement);
+ countBlockSelectionMode(protyle);
+ } else {
+ previousElement.classList.add(BLOCK_SELECTION_CLASS);
+ countBlockWord([previousElement.getAttribute("data-node-id")]);
+ }
const top = previousElement.getBoundingClientRect().top - protyle.contentElement.getBoundingClientRect().top;
if (top < 0) {
protyle.contentElement.scrollTop = protyle.contentElement.scrollTop + top;
@@ -479,16 +533,57 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
}
}
- // 仅处理以下快捷键操作
- if (event.key !== "PageUp" && event.key !== "PageDown" && event.key !== "Home" && event.key !== "End" && event.key.indexOf("Arrow") === -1 &&
- isNotCtrl(event) && event.key !== "Escape" && !event.shiftKey && !event.altKey && !/^F\d{1,2}$/.test(event.key) &&
- event.key !== "Enter" && event.key !== "Tab" && event.key !== "Backspace" && event.key !== "Delete" && event.key !== "ContextMenu") {
+ if (blockSelectionModeElement && !event.altKey && !event.shiftKey && isNotCtrl(event) &&
+ (event.key === " " || event.code === "Space")) {
+ event.preventDefault();
+ event.stopPropagation();
+ if (!event.repeat) {
+ let targetElement: Element = isInEmbedBlock(blockSelectionModeElement) || blockSelectionModeElement;
+ targetElement = getTopAloneElement(targetElement);
+ const selectionModeTarget = setBlockSelectionModeElement(protyle.wysiwyg.element, targetElement);
+ if (!selectionModeTarget) {
+ return;
+ }
+ toggleBlockSelection(protyle.wysiwyg.element, selectionModeTarget);
+ countBlockSelectionMode(protyle);
+ if (selectionModeTarget !== blockSelectionModeElement) {
+ focusBlock(selectionModeTarget);
+ }
+ }
+ return;
+ }
+
+ const isSingleCharacter = typeof event.key === "string" && event.key.length === 1;
+ const isSelectionModeTextInput = !!blockSelectionModeElement && isSingleCharacter &&
+ (isNotCtrl(event) && !event.altKey || event.getModifierState("AltGraph"));
+ const isRegularTextInput = !blockSelectionModeElement && isSingleCharacter &&
+ isNotCtrl(event) && !event.shiftKey && !event.altKey;
+ if (isSelectionModeTextInput || isRegularTextInput) {
event.stopPropagation();
+ let inputRange = range;
+ let inputNodeElement = nodeElement;
+ if (blockSelectionModeElement) {
+ clearBlockSelectionMode(protyle.wysiwyg.element, true);
+ countBlockWord([], protyle.block.rootID);
+ if (!isNotEditBlock(blockSelectionModeElement)) {
+ if (!blockSelectionModeElement.contains(inputRange.startContainer)) {
+ focusBlock(blockSelectionModeElement);
+ inputRange = getEditorRange(protyle.wysiwyg.element);
+ }
+ const editingBlockElement = hasClosestBlock(inputRange.startContainer);
+ if (editingBlockElement) {
+ inputNodeElement = editingBlockElement;
+ setInsertWbrHTML(editingBlockElement, inputRange, protyle);
+ protyle.wysiwyg.preventKeyup = true;
+ }
+ }
+ }
hideElements(["select"], protyle);
// https://github.com/siyuan-note/siyuan/issues/14743
- if (nodeElement && getContenteditableElement(nodeElement) &&
- range.endContainer.nodeType === 1 && (range.endContainer as HTMLElement).classList.contains("protyle-attr")) {
- range.collapse(true);
+ if (inputNodeElement && getContenteditableElement(inputNodeElement) &&
+ inputRange.endContainer.nodeType === 1 &&
+ (inputRange.endContainer as HTMLElement).classList.contains("protyle-attr")) {
+ inputRange.collapse(true);
}
return false;
}
@@ -541,6 +636,20 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
return;
}
+ if (blockSelectionModeElement && event.shiftKey && !event.altKey && isNotCtrl(event) &&
+ (event.key === "ArrowUp" || event.key === "ArrowDown")) {
+ const selectElements = Array.from(protyle.wysiwyg.element.querySelectorAll<HTMLElement>(
+ `.${BLOCK_SELECTION_CLASS}`));
+ if (!isContinuousBlockSelection(selectElements) ||
+ !blockSelectionModeElement.classList.contains(BLOCK_SELECTION_CLASS) ||
+ blockSelectionModeElement.getAttribute("select-end") !== "true") {
+ clearBlockSelection(protyle.wysiwyg.element);
+ blockSelectionModeElement.classList.add(BLOCK_SELECTION_CLASS);
+ blockSelectionModeElement.setAttribute("select-start", "true");
+ blockSelectionModeElement.setAttribute("select-end", "true");
+ }
+ }
+
if (matchHotKey(window.siyuan.config.keymap.editor.general.expandUp.custom, event)) {
upSelect({
protyle, event, nodeElement, editorElement, range,
@@ -563,6 +672,9 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
}
}
});
+ if (blockSelectionModeElement) {
+ syncBlockSelectionModeToSelectionEnd(protyle, "up");
+ }
return;
}
@@ -589,6 +701,9 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
}
}
});
+ if (blockSelectionModeElement) {
+ syncBlockSelectionModeToSelectionEnd(protyle, "down");
+ }
return;
}
@@ -626,6 +741,9 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
}
}
});
+ if (blockSelectionModeElement) {
+ syncBlockSelectionModeToSelectionEnd(protyle, "up");
+ }
return;
}
@@ -673,6 +791,9 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
}
}
});
+ if (blockSelectionModeElement) {
+ syncBlockSelectionModeToSelectionEnd(protyle, "down");
+ }
return;
}
@@ -747,6 +868,10 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
}
const centerBlockElement = hasClosestBlock(centerElement);
if (centerBlockElement && centerBlockElement !== nodeElement) {
+ if (blockSelectionModeElement) {
+ setBlockSelectionModeElement(protyle.wysiwyg.element, centerBlockElement);
+ countBlockSelectionMode(protyle);
+ }
focusBlock(centerBlockElement, undefined, false);
}
event.stopPropagation();
@@ -1090,8 +1215,15 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
await removeCrossBlockRange(protyle, range, nodeElement, endElement);
return;
}
- if (protyle.wysiwyg.element.querySelector(".protyle-wysiwyg--select")) {
- removeBlock(protyle, nodeElement, range, event.key === "Backspace" ? "Backspace" : "Delete");
+ if (blockSelectionModeElement) {
+ await removeBlockPreservingSelectionMode(protyle, nodeElement, range,
+ event.key === "Backspace" ? "Backspace" : "Delete");
+ event.stopPropagation();
+ event.preventDefault();
+ return;
+ }
+ if (protyle.wysiwyg.element.querySelector(`.${BLOCK_SELECTION_CLASS}`)) {
+ await removeBlock(protyle, nodeElement, range, event.key === "Backspace" ? "Backspace" : "Delete");
event.stopPropagation();
event.preventDefault();
return;
@@ -1431,6 +1563,9 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
event.stopPropagation();
event.preventDefault();
await enter(nodeElement, range, protyle);
+ if (blockSelectionModeElement) {
+ countBlockWord([], protyle.block.rootID);
+ }
return;
}
@@ -1680,13 +1815,16 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
} else if (!window.siyuan.menus.menu.element.classList.contains("fn__none")) {
// 防止 ESC 时选中当前块
window.siyuan.menus.menu.remove(true);
- } else if (nodeElement.classList.contains("protyle-wysiwyg--select")) {
+ } else if (blockSelectionModeElement) {
+ clearBlockSelectionMode(protyle.wysiwyg.element, true);
+ countBlockWord([], protyle.block.rootID);
+ } else if (nodeElement.classList.contains(BLOCK_SELECTION_CLASS)) {
hideElements(["select"], protyle);
countBlockWord([], protyle.block.rootID);
} else {
hideElements(["select"], protyle);
range.collapse(false);
- nodeElement.classList.add("protyle-wysiwyg--select");
+ setBlockSelectionModeElement(protyle.wysiwyg.element, nodeElement);
countBlockWord([nodeElement.getAttribute("data-node-id")], protyle.block.rootID);
}
}
@@ -1934,15 +2072,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (selectElements.length > 0) {
event.preventDefault();
event.stopPropagation();
- let isContinuous = true;
- selectElements.forEach((item, index) => {
- if (item.nextElementSibling && selectElements[index + 1]) {
- if (selectElements[index + 1] !== item.nextElementSibling) {
- isContinuous = false;
- }
- }
- });
- if (isContinuous &&
+ if (isContinuousBlockSelection(Array.from(selectElements)) &&
(selectElements[0].classList.contains("li") || selectElements[0].parentElement.classList.contains("li"))) {
await listOutdent(protyle, Array.from(selectElements), range);
}
@@ -1968,15 +2098,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (selectElements.length > 0) {
event.preventDefault();
event.stopPropagation();
- let isContinuous = true;
- selectElements.forEach((item, index) => {
- if (item.nextElementSibling && selectElements[index + 1]) {
- if (selectElements[index + 1] !== item.nextElementSibling) {
- isContinuous = false;
- }
- }
- });
- if (isContinuous &&
+ if (isContinuousBlockSelection(Array.from(selectElements)) &&
(selectElements[0].classList.contains("li") || selectElements[0].parentElement.classList.contains("li"))) {
await listIndent(protyle, Array.from(selectElements), range);
}
@@ -2376,9 +2498,26 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
// tab 需等待 list 和 table 处理完成
if (event.key === "Tab" && isNotCtrl(event) && !event.altKey) {
event.preventDefault();
- if (nodeType === "NodeCodeBlock") {
+ let tabNodeElement = nodeElement;
+ let tabRange = range;
+ if (blockSelectionModeElement && !event.shiftKey) {
+ tabNodeElement = blockSelectionModeElement;
+ if (!tabNodeElement.contains(tabRange.startContainer)) {
+ focusBlock(tabNodeElement);
+ tabRange = getEditorRange(protyle.wysiwyg.element);
+ }
+ const editingBlockElement = hasClosestBlock(tabRange.startContainer);
+ if (editingBlockElement) {
+ tabNodeElement = editingBlockElement;
+ setInsertWbrHTML(editingBlockElement, tabRange, protyle);
+ protyle.wysiwyg.preventKeyup = true;
+ }
+ clearBlockSelectionMode(protyle.wysiwyg.element, true);
+ countBlockWord([], protyle.block.rootID);
+ }
+ if (tabNodeElement.getAttribute("data-type") === "NodeCodeBlock") {
if (selectText !== "" || !event.shiftKey) {
- tabCodeBlock(protyle, nodeElement, range, event.shiftKey);
+ tabCodeBlock(protyle, tabNodeElement, tabRange, event.shiftKey);
return true;
}
return;
@@ -2557,8 +2696,13 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
}
// 置于最后,太多快捷键会使用到选中元素
- if (isNotCtrl(event) && event.key !== "Backspace" && event.key !== "Escape" && event.key !== "Delete" && !event.shiftKey && !event.altKey && event.key !== "Enter") {
+ if (isNotCtrl(event) && event.key !== "Backspace" && event.key !== "Escape" && event.key !== "Delete" &&
+ !event.shiftKey && !event.altKey && event.key !== "Enter" && event.key !== "Process") {
hideElements(["select"], protyle);
+ if (blockSelectionModeElement) {
+ clearBlockSelectionMode(protyle.wysiwyg.element, true);
+ countBlockWord([], protyle.block.rootID);
+ }
}
if (matchHotKey("⌘B", event) || matchHotKey("⌘I", event) || matchHotKey("⌘U", event)) {
diff --git a/app/src/protyle/wysiwyg/move.ts b/app/src/protyle/wysiwyg/move.ts
index d6180f4f40..808e423444 100644
--- a/app/src/protyle/wysiwyg/move.ts
+++ b/app/src/protyle/wysiwyg/move.ts
@@ -6,13 +6,21 @@ import {preventScroll} from "../scroll/preventScroll";
import {scrollCenter} from "../../util/highlightById";
import {focusByWbr} from "../util/selection";
import {refreshSbResize} from "../../block/util";
+import {
+ BLOCK_SELECTION_CLASS,
+ getBlockSelectionModeElement,
+ isContinuousBlockSelection
+} from "./blockSelection";
export const moveToUp = (protyle: IProtyle, nodeElement: HTMLElement, range: Range) => {
let previousElement: Element;
let oldListHTML = "";
- let sourceElements = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));
+ let sourceElements: Element[] = Array.from(protyle.wysiwyg.element.querySelectorAll<HTMLElement>(`.${BLOCK_SELECTION_CLASS}`));
+ if (sourceElements.length > 1 && !isContinuousBlockSelection(sourceElements)) {
+ return;
+ }
if (sourceElements.length === 0) {
- let sourceElement = getTopAloneElement(nodeElement);
+ let sourceElement = getTopAloneElement(getBlockSelectionModeElement(protyle.wysiwyg.element) || nodeElement);
const foldElement = hasClosestByAttribute(sourceElement, "fold", "1");
if (foldElement) {
sourceElement = foldElement;
@@ -22,6 +30,7 @@ export const moveToUp = (protyle: IProtyle, nodeElement: HTMLElement, range: Ran
}
sourceElements = [sourceElement];
}
+ const rangeIsInSource = sourceElements.some(item => item.contains(range.startContainer));
const type = sourceElements[0].getAttribute("data-type");
// 子列表
if (type === "NodeListItem" &&
@@ -29,7 +38,9 @@ export const moveToUp = (protyle: IProtyle, nodeElement: HTMLElement, range: Ran
sourceElements[0].parentElement.previousElementSibling?.previousElementSibling?.classList.contains("protyle-action")) {
if (sourceElements[0].parentElement.parentElement.previousElementSibling?.classList.contains("li")) {
previousElement = sourceElements[0].parentElement.parentElement.previousElementSibling.querySelector(".list");
- range.insertNode(document.createElement("wbr"));
+ if (rangeIsInSource) {
+ range.insertNode(document.createElement("wbr"));
+ }
oldListHTML = sourceElements[0].parentElement.parentElement.parentElement.outerHTML;
if (!previousElement) {
const newId = Lute.NewNodeID();
@@ -44,14 +55,18 @@ export const moveToUp = (protyle: IProtyle, nodeElement: HTMLElement, range: Ran
sourceElements[0].previousElementSibling?.previousElementSibling?.classList.contains("protyle-action")) {
if (sourceElements[0].parentElement.previousElementSibling?.classList.contains("li")) {
previousElement = sourceElements[0].parentElement.previousElementSibling.querySelector(".list");
- range.insertNode(document.createElement("wbr"));
+ if (rangeIsInSource) {
+ range.insertNode(document.createElement("wbr"));
+ }
oldListHTML = sourceElements[0].parentElement.parentElement.outerHTML;
if (!previousElement) {
// 目标 li 无子列表:直接整体移动源列表,与其他块移动保持一致
sourceElements[0].parentElement.previousElementSibling.lastElementChild.insertAdjacentElement("beforebegin", sourceElements[0]);
updateTransaction(protyle, sourceElements[0].parentElement.parentElement, oldListHTML);
preventScroll(protyle);
- focusByWbr(sourceElements[0], range);
+ if (rangeIsInSource) {
+ focusByWbr(sourceElements[0], range);
+ }
scrollCenter(protyle);
return;
}
@@ -85,7 +100,9 @@ export const moveToUp = (protyle: IProtyle, nodeElement: HTMLElement, range: Ran
}
updateTransaction(protyle, previousElement.parentElement.parentElement.parentElement, oldListHTML);
preventScroll(protyle);
- focusByWbr(previousElement.parentElement, range);
+ if (rangeIsInSource) {
+ focusByWbr(previousElement.parentElement, range);
+ }
scrollCenter(protyle);
return;
}
@@ -121,9 +138,12 @@ export const moveToUp = (protyle: IProtyle, nodeElement: HTMLElement, range: Ran
export const moveToDown = (protyle: IProtyle, nodeElement: HTMLElement, range: Range) => {
let nextElement: Element;
let oldListHTML = "";
- let sourceElements = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));
+ let sourceElements: Element[] = Array.from(protyle.wysiwyg.element.querySelectorAll<HTMLElement>(`.${BLOCK_SELECTION_CLASS}`));
+ if (sourceElements.length > 1 && !isContinuousBlockSelection(sourceElements)) {
+ return;
+ }
if (sourceElements.length === 0) {
- let sourceElement = getTopAloneElement(nodeElement);
+ let sourceElement = getTopAloneElement(getBlockSelectionModeElement(protyle.wysiwyg.element) || nodeElement);
const foldElement = hasClosestByAttribute(sourceElement, "fold", "1");
if (foldElement) {
sourceElement = foldElement;
@@ -133,6 +153,7 @@ export const moveToDown = (protyle: IProtyle, nodeElement: HTMLElement, range: R
}
sourceElements = [sourceElement];
}
+ const rangeIsInSource = sourceElements.some(item => item.contains(range.startContainer));
const type = sourceElements[0].getAttribute("data-type");
// 子列表
if (type === "NodeListItem" &&
@@ -140,7 +161,9 @@ export const moveToDown = (protyle: IProtyle, nodeElement: HTMLElement, range: R
sourceElements[0].parentElement.parentElement?.classList.contains("li")) {
if (sourceElements[0].parentElement.parentElement.nextElementSibling?.classList.contains("li")) {
nextElement = sourceElements[0].parentElement.parentElement.nextElementSibling.querySelector(".list > .li");
- range.insertNode(document.createElement("wbr"));
+ if (rangeIsInSource) {
+ range.insertNode(document.createElement("wbr"));
+ }
oldListHTML = sourceElements[0].parentElement.parentElement.parentElement.outerHTML;
if (!nextElement) {
const newId = Lute.NewNodeID();
@@ -155,14 +178,18 @@ export const moveToDown = (protyle: IProtyle, nodeElement: HTMLElement, range: R
sourceElements[0].parentElement?.classList.contains("li")) {
if (sourceElements[0].parentElement.nextElementSibling?.classList.contains("li")) {
nextElement = sourceElements[0].parentElement.nextElementSibling.querySelector(".list > .li");
- range.insertNode(document.createElement("wbr"));
+ if (rangeIsInSource) {
+ range.insertNode(document.createElement("wbr"));
+ }
oldListHTML = sourceElements[0].parentElement.parentElement.outerHTML;
if (!nextElement) {
// 目标 li 无子列表:直接整体移动源列表,与其他块移动保持一致
sourceElements[0].parentElement.nextElementSibling.lastElementChild.insertAdjacentElement("beforebegin", sourceElements[0]);
updateTransaction(protyle, sourceElements[0].parentElement.parentElement, oldListHTML);
preventScroll(protyle);
- focusByWbr(sourceElements[0], range);
+ if (rangeIsInSource) {
+ focusByWbr(sourceElements[0], range);
+ }
scrollCenter(protyle);
return;
}
@@ -189,7 +216,9 @@ export const moveToDown = (protyle: IProtyle, nodeElement: HTMLElement, range: R
}
updateTransaction(protyle, nextElement.parentElement.parentElement.parentElement, oldListHTML);
preventScroll(protyle);
- focusByWbr(nextElement.parentElement, range);
+ if (rangeIsInSource) {
+ focusByWbr(nextElement.parentElement, range);
+ }
scrollCenter(protyle);
return;
}
diff --git a/app/src/protyle/wysiwyg/remove.ts b/app/src/protyle/wysiwyg/remove.ts
index 5febe090d0..2e82d60b4b 100644
--- a/app/src/protyle/wysiwyg/remove.ts
+++ b/app/src/protyle/wysiwyg/remove.ts
@@ -4,6 +4,7 @@ import {
focusByRange,
focusByWbr,
getBlockRanges,
+ getEditorRange,
getSelectionOffset,
getUndoFocusContext,
restoreFocusContext,
@@ -71,6 +72,15 @@ import {
import {confirmBlockRef} from "../../util/checkBlockRef";
import {input} from "./input";
import {isWindows} from "../util/compatibility";
+import {
+ BLOCK_SELECTION_MODE_CLASS,
+ BLOCK_SELECTION_CLASS,
+ getBlockSelectionModeElement,
+ getBlockSelectionStatusIDs,
+ getDeleteSelectionCandidate,
+ setBlockSelectionModeElement
+} from "./blockSelection";
+import {countBlockWord} from "../../layout/status";
export interface IBlockRefCheckTargets {
elements: HTMLElement[];
@@ -961,7 +971,8 @@ export const removeCrossBlockRange = async (protyle: IProtyle, selectedRange: Ra
};
export const removeBlock = async (protyle: IProtyle, blockElement: Element, range: Range,
- type: "Delete" | "Backspace" | "remove", skipRefCheck = false) => {
+ type: "Delete" | "Backspace" | "remove", skipRefCheck = false,
+ restoreSelectionModeAfterZoom = false) => {
const selectElements = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));
if (selectElements?.length > 0) {
const selectedTopElement = selectElements.length === 1 ? getTopAloneElement(selectElements[0]) : undefined;
@@ -1046,25 +1057,17 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang
preventScroll(protyle);
const deletes: IOperation[] = [];
const inserts: IOperation[] = [];
- let sideElement: Element | boolean;
- let sideIsNext = false;
- if (type === "Backspace") {
- sideElement = getPreviousBlockSibling(selectElements[0]);
- if (!sideElement) {
- sideIsNext = true;
- sideElement = selectElements[selectElements.length - 1].nextElementSibling;
- }
- } else {
- sideElement = selectElements[selectElements.length - 1].nextElementSibling;
- sideIsNext = true;
- if (!sideElement) {
- sideIsNext = false;
- sideElement = getPreviousBlockSibling(selectElements[0]);
- }
- }
- let listElement: Element;
- let listStart: number | undefined;
- let topParentElement: Element;
+ const candidateElements = Array.from(new Set(selectElements.map(item => getTopAloneElement(item))));
+ const selectionCandidate = getDeleteSelectionCandidate(candidateElements, type,
+ getPreviousBlock, getNextBlock);
+ let sideElement = selectionCandidate?.element;
+ let sideIsNext = selectionCandidate?.side === "after";
+ if (!sideElement && !protyle.options.backlinkData) {
+ sideElement = protyle.wysiwyg.element;
+ sideIsNext = false;
+ }
+ const orderedLists = new Map<Element, number | undefined>();
+ const superBlockParents = new Map<Element, Set<string>>();
hideElements(["select"], protyle);
const unfoldData: {
[key: string]: {
@@ -1073,32 +1076,19 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang
}
} = {};
for (let i = 0; i < selectElements.length; i++) {
- const item = selectElements[i];
- const topElement = getTopAloneElement(item);
- topParentElement = topElement.parentElement;
+ const topElement = getTopAloneElement(selectElements[i]);
+ const topParentElement = topElement.parentElement;
+ if (topParentElement?.getAttribute("data-type") === "NodeSuperBlock") {
+ if (!superBlockParents.has(topParentElement)) {
+ superBlockParents.set(topParentElement, new Set());
+ }
+ superBlockParents.get(topParentElement).add(topElement.getAttribute("data-node-id"));
+ }
const id = topElement.getAttribute("data-node-id");
deletes.push({
action: "delete",
id,
});
- if (type === "Backspace") {
- sideElement = getPreviousBlock(topElement);
- if (!sideElement) {
- sideIsNext = true;
- sideElement = getNextBlock(topElement);
- }
- } else {
- sideElement = getNextBlock(topElement);
- sideIsNext = true;
- if (!sideElement) {
- sideIsNext = false;
- sideElement = getPreviousBlock(topElement);
- }
- }
- if (!sideElement && !protyle.options.backlinkData) {
- sideElement = topElement.parentElement || protyle.wysiwyg.element.firstElementChild;
- sideIsNext = false;
- }
if (topElement.getAttribute("data-type") === "NodeHeading" && topElement.getAttribute("fold") === "1") {
const foldTransaction = foldTransactions.get(id) || await fetchSyncPost("/api/block/getHeadingDeleteTransaction", {id});
deletes.push(...foldTransaction.data.doOperations.slice(1));
@@ -1162,13 +1152,9 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang
parentID: getOperationParentID(topElement, protyle.block.parentID)
});
if (topElement.getAttribute("data-subtype") === "o" && topElement.classList.contains("li")) {
- if (listElement !== topElement.parentElement) {
- listElement = topElement.parentElement;
- listStart = getOrderedListStart(listElement);
+ if (!orderedLists.has(topElement.parentElement)) {
+ orderedLists.set(topElement.parentElement, getOrderedListStart(topElement.parentElement));
}
- } else {
- listElement = undefined;
- listStart = undefined;
}
// https://github.com/siyuan-note/siyuan/issues/12327
if (topElement.parentElement.classList.contains("li") && topElement.parentElement.childElementCount === 4 &&
@@ -1188,13 +1174,29 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang
});
if (sideElement) {
if (protyle.block.showAll && sideElement.classList.contains("protyle-wysiwyg") && protyle.wysiwyg.element.childElementCount === 0) {
+ const focusID = protyle.block.parent2ID;
setTimeout(() => {
if (document.contains(protyle.element)) {
- zoomOut({protyle, id: protyle.block.parent2ID, focusId: protyle.block.parent2ID});
+ zoomOut({
+ protyle,
+ id: focusID,
+ focusId: focusID,
+ callback: restoreSelectionModeAfterZoom ? () => {
+ const targetElement = protyle.wysiwyg.element.querySelector<HTMLElement>(
+ `[data-node-id="${focusID}"]`) ||
+ protyle.wysiwyg.element.querySelector<HTMLElement>("[data-node-id]");
+ if (targetElement) {
+ setBlockSelectionModeElement(protyle.wysiwyg.element, targetElement);
+ focusBlock(targetElement);
+ countBlockWord(getBlockSelectionStatusIDs(protyle.wysiwyg.element),
+ protyle.block.rootID);
+ }
+ } : undefined,
+ });
}
}, Constants.TIMEOUT_INPUT * 2 + 100);
} else {
- if ((sideElement.classList.contains("protyle-wysiwyg") && protyle.wysiwyg.element.childElementCount === 0)) {
+ if (sideElement.classList.contains("protyle-wysiwyg") && protyle.wysiwyg.element.childElementCount === 0) {
const newID = Lute.NewNodeID();
const emptyElement = genEmptyElement(false, true, newID);
sideElement.insertAdjacentElement("afterbegin", emptyElement);
@@ -1214,59 +1216,104 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang
// https://github.com/siyuan-note/siyuan/issues/5485
// https://github.com/siyuan-note/siyuan/issues/10389
// https://github.com/siyuan-note/siyuan/issues/10899
- if (type !== "Backspace" && sideIsNext) {
- focusBlock(sideElement as Element);
- } else {
- focusBlock(sideElement as Element, undefined, false);
- }
- scrollCenter(protyle, sideElement as Element);
- if (listElement) {
- inserts.push({
- action: "update",
- id: listElement.getAttribute("data-node-id"),
- data: listElement.outerHTML
- });
- listElement.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
- updateListOrder(listElement, listStart);
- deletes.push({
- action: "update",
- id: listElement.getAttribute("data-node-id"),
- data: listElement.outerHTML
- });
+ if (sideElement) {
+ if (type !== "Backspace" && sideIsNext) {
+ focusBlock(sideElement);
+ } else {
+ focusBlock(sideElement, undefined, false);
+ }
+ scrollCenter(protyle, sideElement);
}
}
}
+ orderedLists.forEach((listStart, listElement) => {
+ if (!listElement.isConnected) {
+ return;
+ }
+ inserts.push({
+ action: "update",
+ id: listElement.getAttribute("data-node-id"),
+ data: listElement.outerHTML
+ });
+ listElement.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
+ updateListOrder(listElement, listStart);
+ deletes.push({
+ action: "update",
+ id: listElement.getAttribute("data-node-id"),
+ data: listElement.outerHTML
+ });
+ });
if (focusedOrderOperations) {
deletes.push(...focusedOrderOperations.doOperations);
inserts.splice(0, 0, ...focusedOrderOperations.undoOperations);
}
if (deletes.length > 0) {
- if (topParentElement && topParentElement.getAttribute("data-type") === "NodeSuperBlock" && getSbChildBlockCount(topParentElement) === 1) {
- const sbData = await cancelSB(protyle, topParentElement, range);
- transaction(protyle, deletes.concat(sbData.doOperations), sbData.undoOperations.concat(inserts.reverse()));
- } else {
- // 超级块删除子块后剩余多个子块时,刷新拖拽手柄(被删块两侧手柄需移除/重建)
- if (topParentElement && topParentElement.getAttribute("data-type") === "NodeSuperBlock") {
- refreshSbResize(topParentElement);
- const widthChanges = rebalanceSbWidth(topParentElement);
+ const getElementDepth = (element: Element) => {
+ let depth = 0;
+ let parentElement = element.parentElement;
+ while (parentElement) {
+ depth++;
+ parentElement = parentElement.parentElement;
+ }
+ return depth;
+ };
+ const parentUndoOperationGroups: IOperation[][] = [];
+ const childReplacements = new Map<string, {
+ childIDs: string[],
+ foldedHeadingIDs: string[]
+ }>();
+ const sortedSuperBlocks = Array.from(superBlockParents.entries())
+ .sort(([first], [second]) => getElementDepth(second) - getElementDepth(first));
+ for (const [superBlock, excludedChildIDs] of sortedSuperBlocks) {
+ if (!superBlock.isConnected) {
+ continue;
+ }
+ if (getSbChildBlockCount(superBlock) === 1) {
+ const sbData = await cancelSB(protyle, superBlock, undefined, excludedChildIDs,
+ childReplacements);
+ deletes.push(...sbData.doOperations);
+ parentUndoOperationGroups.push(sbData.undoOperations);
+ if (sbData.doOperations.length > 0) {
+ childReplacements.set(superBlock.getAttribute("data-node-id"), {
+ childIDs: sbData.childIDs || [],
+ foldedHeadingIDs: sbData.foldedHeadingIDs || [],
+ });
+ }
+ } else {
+ // 超级块删除子块后剩余多个子块时,刷新拖拽手柄(被删块两侧手柄需移除/重建)
+ refreshSbResize(superBlock);
+ const widthChanges = rebalanceSbWidth(superBlock);
+ const widthUndoOperations: IOperation[] = [];
widthChanges.forEach(change => {
- const targetEl = topParentElement.querySelector(`[data-node-id="${change.id}"]`);
+ const targetEl = superBlock.querySelector(`[data-node-id="${change.id}"]`);
if (targetEl) {
deletes.push({
action: "setAttrs",
id: change.id,
data: JSON.stringify({style: targetEl.getAttribute("style") || ""})
});
- inserts.push({
+ widthUndoOperations.push({
action: "setAttrs",
id: change.id,
data: JSON.stringify({style: change.oldStyle})
});
}
});
+ if (widthUndoOperations.length > 0) {
+ parentUndoOperationGroups.push(widthUndoOperations);
+ }
}
- transaction(protyle, deletes, inserts.reverse());
}
+ if (sideElement?.isConnected && protyle.wysiwyg.element.contains(sideElement)) {
+ if (type !== "Backspace" && sideIsNext) {
+ focusBlock(sideElement);
+ } else {
+ focusBlock(sideElement, undefined, false);
+ }
+ scrollCenter(protyle, sideElement);
+ }
+ const parentUndoOperations = parentUndoOperationGroups.reverse().flat();
+ transaction(protyle, deletes, parentUndoOperations.concat(inserts.reverse()));
}
hideElements(["util"], protyle);
@@ -1732,6 +1779,39 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang
focusByWbr(protyle.wysiwyg.element, range);
};
+export const removeBlockPreservingSelectionMode = async (protyle: IProtyle, blockElement: Element, range: Range,
+ type: "Delete" | "Backspace" | "remove",
+ skipRefCheck = false) => {
+ const editorElement = protyle.wysiwyg.element;
+ const selectionModeElement = getBlockSelectionModeElement(editorElement);
+ if (!selectionModeElement) {
+ return removeBlock(protyle, blockElement, range, type, skipRefCheck);
+ }
+ const temporarySelection = !editorElement.querySelector(`.${BLOCK_SELECTION_CLASS}`);
+ if (temporarySelection) {
+ selectionModeElement.classList.add(BLOCK_SELECTION_CLASS);
+ }
+ selectionModeElement.classList.remove(BLOCK_SELECTION_MODE_CLASS);
+ const removed = await removeBlock(protyle, blockElement, range, type, skipRefCheck, true);
+ if (!removed && temporarySelection && selectionModeElement.isConnected) {
+ selectionModeElement.classList.remove(BLOCK_SELECTION_CLASS);
+ selectionModeElement.removeAttribute("select-start");
+ selectionModeElement.removeAttribute("select-end");
+ }
+ const currentRange = getEditorRange(editorElement);
+ let nextSelectionModeElement = selectionModeElement.isConnected ? selectionModeElement :
+ hasClosestBlock(currentRange.startContainer) as HTMLElement;
+ if (!nextSelectionModeElement || !editorElement.contains(nextSelectionModeElement)) {
+ nextSelectionModeElement = editorElement.querySelector<HTMLElement>("[data-node-id]");
+ }
+ if (nextSelectionModeElement) {
+ setBlockSelectionModeElement(editorElement, nextSelectionModeElement);
+ focusBlock(nextSelectionModeElement);
+ }
+ countBlockWord(getBlockSelectionStatusIDs(editorElement), protyle.block.rootID);
+ return removed;
+};
+
const canDeleteEmbedElement = (element: Element, type: "Delete" | "Backspace" | "remove",
embedContext: IEmbedChildOperationContext) => {
if (embedContext.targetElement === element || !embedContext.boundaryElement.contains(element)) {
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts
index d41513f8b1..411e83b99f 100644
--- a/app/src/protyle/wysiwyg/transaction.ts
+++ b/app/src/protyle/wysiwyg/transaction.ts
@@ -59,6 +59,34 @@ import {
prepareViewFoldTransaction,
setViewFoldTransient,
} from "../util/viewFold";
+import {
+ captureBlockSelectionModeState,
+ cleanBlockSelectionModeHTML,
+ getBlockSelectionStatusIDs,
+ restoreBlockSelectionModeState
+} from "./blockSelection";
+
+const cleanBlockSelectionModeOperations = (operations?: IOperation[]) => {
+ operations?.forEach(operation => {
+ if (["appendInsert", "insert", "prependInsert", "update"].includes(operation.action) &&
+ typeof operation.data === "string") {
+ operation.data = cleanBlockSelectionModeHTML(operation.data);
+ }
+ if (operation.action === "unfoldHeading" && typeof operation.retData === "string") {
+ operation.retData = cleanBlockSelectionModeHTML(operation.retData);
+ }
+ });
+};
+
+const focusRestoredBlockSelectionMode = (selectionModeElement?: Element) => {
+ if (!selectionModeElement?.isConnected) {
+ return;
+ }
+ const selection = getSelection();
+ if (selection.rangeCount === 0 || !selectionModeElement.contains(selection.getRangeAt(0).startContainer)) {
+ focusBlock(selectionModeElement);
+ }
+};
const removeTopElement = (updateElement: Element, protyle: IProtyle) => {
// 移动到其他文档中,该块需移除
@@ -169,6 +197,7 @@ const promiseTransaction = (options: {
if (operation.action === "update") {
// 当前编辑器中的其他块
let updatedEmbed = false;
+ let restoredSelectionModeElement: HTMLElement;
const updateElements = Array.from(
protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.id}"]`)
@@ -184,8 +213,9 @@ const promiseTransaction = (options: {
item.removeAttribute(Constants.ATTRIBUTE_EDITING);
return;
}
+ const selectionModeState = captureBlockSelectionModeState(item);
const tempElement = document.createElement("template");
- tempElement.innerHTML = getVisibleFoldHeadingHTML(html);
+ tempElement.innerHTML = cleanBlockSelectionModeHTML(getVisibleFoldHeadingHTML(html));
tempElement.content.querySelectorAll(".protyle-wysiwyg--select").forEach(selectItem => {
selectItem.classList.remove("protyle-wysiwyg--select");
});
@@ -194,12 +224,18 @@ const promiseTransaction = (options: {
wbrElement.remove();
}
disposeCustomBlocksInElement(item);
- item.outerHTML = tempElement.innerHTML;
+ item.insertAdjacentHTML("afterend", tempElement.innerHTML);
+ const replacementElement = item.nextElementSibling;
+ item.remove();
+ if (replacementElement) {
+ restoredSelectionModeElement = restoreBlockSelectionModeState(protyle.wysiwyg.element,
+ replacementElement, selectionModeState) || restoredSelectionModeElement;
+ }
updatedEmbed = true;
};
const allTempElement = document.createElement("template");
- allTempElement.innerHTML = getVisibleFoldHeadingHTML(operation.data);
+ allTempElement.innerHTML = cleanBlockSelectionModeHTML(getVisibleFoldHeadingHTML(operation.data));
updateElements.forEach((item) => {
if ((currentEmbedElement && isInEmbedBlock(item, false) === currentEmbedElement) ||
(range && (item === range.startContainer || item.contains(range.startContainer)))) {
@@ -230,6 +266,7 @@ const promiseTransaction = (options: {
highlightRender(protyle.wysiwyg.element);
avRender(protyle.wysiwyg.element, protyle);
}
+ focusRestoredBlockSelectionMode(restoredSelectionModeElement);
return;
}
if (operation.action === "delete" || operation.action === "append") {
@@ -501,10 +538,7 @@ const promiseTransaction = (options: {
}]
}, (response) => {
invalidateViewFoldRequests(protyle);
- const ids: string[] = [];
- protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select").forEach(item => {
- ids.push(item.getAttribute("data-node-id"));
- });
+ const ids = getBlockSelectionStatusIDs(protyle.wysiwyg.element);
countBlockWord(ids, protyle.block.rootID, true);
if (!options.skipSync) {
response.data[0].doOperations.forEach((operation: IOperation) => {
@@ -638,10 +672,13 @@ const updateBlock = (updateElements: Element[], protyle: IProtyle, operation: IO
const data = item.getAttribute("data-subtype") === "echarts" ?
// 图标撤销后无法渲染
protyle.lute.SpinBlockDOM(operation.data) : operation.data;
+ const selectionModeState = captureBlockSelectionModeState(item);
disposeCustomBlocksInElement(item);
item.insertAdjacentHTML("afterend", getVisibleFoldHeadingHTML(data));
item = item.nextElementSibling;
item.previousElementSibling.remove();
+ const restoredSelectionModeElement = restoreBlockSelectionModeState(protyle.wysiwyg.element, item,
+ selectionModeState);
const wbrElement = item.querySelector("wbr");
const codeElement = item.getAttribute("data-type") === "NodeCodeBlock" ? item.querySelector(".hljs") : undefined;
@@ -679,6 +716,7 @@ const updateBlock = (updateElements: Element[], protyle: IProtyle, operation: IO
highlightRender(item);
avRender(item, protyle);
blockRender(protyle, item);
+ focusRestoredBlockSelectionMode(restoredSelectionModeElement);
});
};
@@ -2153,6 +2191,8 @@ export const transaction = (protyle: IProtyle, doOperations: IOperation[], undoO
options?.callback?.();
return;
}
+ cleanBlockSelectionModeOperations(doOperations);
+ cleanBlockSelectionModeOperations(undoOperations);
cleanHeadingNumberOperations(doOperations);
cleanHeadingNumberOperations(undoOperations);
if (!protyle) {
@@ -2293,8 +2333,8 @@ export const updateTransaction = (protyle: IProtyle, element: Element, oldHTML:
refreshSbResize(element);
}
const id = element.getAttribute("data-node-id");
- const newHTML = cleanHeadingNumberHTML(element.outerHTML);
- const cleanOldHTML = cleanHeadingNumberHTML(oldHTML);
+ const newHTML = cleanHeadingNumberHTML(cleanBlockSelectionModeHTML(element.outerHTML));
+ const cleanOldHTML = cleanHeadingNumberHTML(cleanBlockSelectionModeHTML(oldHTML));
if (newHTML === cleanOldHTML.replace("<wbr>", "") && !additionalOperations) {
return;
}