@maxbill/dsh-file-explorer 1.0.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -57,7 +57,7 @@ window.__ModuleLoader__.load({
57
57
  var VIEW_OPTIONS = [
58
58
  { id: "icons", label: "图标", icon: "viewGrid" },
59
59
  { id: "list", label: "列表", icon: "viewList" },
60
- { id: "grouped", label: "分类", icon: "squares" },
60
+ { id: "grouped", label: "分类", icon: "viewGrouped" },
61
61
  ];
62
62
 
63
63
 
@@ -108,7 +108,7 @@ window.__ModuleLoader__.load({
108
108
  "关于 文件管理器": "About File Explorer",
109
109
  "关闭关于": "Close about",
110
110
  "文件管理器": "File Explorer",
111
- "轻量级本地文件管理:浏览、预览、批量选择与常用操作。": "A lightweight local file manager: browse, preview, multi-select and the usual operations.",
111
+ "浏览 · 预览 · 编辑 · 整理 —— 并把文件直接交给 Agent": "Browse · preview · edit · organise — and hand files straight to the agent.",
112
112
  "预览": "Preview",
113
113
  "详情": "Details",
114
114
  "隐藏": "Hidden",
@@ -822,6 +822,13 @@ window.__ModuleLoader__.load({
822
822
  .dfx-upload { display: flex; align-items: center; gap: 8px; padding: 4px 12px; font-size: 12px; color: var(--dsw-alias-label-secondary, #6b6b6b); }
823
823
  .dfx-upload-bar { flex: 1 1 auto; height: 3px; border-radius: 2px; background: rgba(127, 127, 127, .2); overflow: hidden; }
824
824
  .dfx-upload-fill { height: 100%; background: #5b5bd6; transition: width 120ms linear; }
825
+ .dfx-editor-conflict {
826
+ display: flex; align-items: center; gap: 8px; margin: 0 0 8px; padding: 8px 10px;
827
+ border-radius: 8px; font-size: 12px;
828
+ color: var(--dsw-alias-label-warning, #8a5a00);
829
+ background: rgba(214, 136, 0, .1);
830
+ border: 1px solid var(--dsw-alias-border-warning, rgba(214, 136, 0, .4));
831
+ }
825
832
  .dfx-editor { display: flex; flex-direction: column; gap: 6px; height: 100%; }
826
833
  .dfx-editor textarea {
827
834
  flex: 1 1 auto; min-height: 240px; resize: none; width: 100%;
@@ -864,7 +871,7 @@ window.__ModuleLoader__.load({
864
871
  .dfx-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
865
872
  .dfx-name-text--dim { color: var(--dsw-alias-label-tertiary, #8f8f8f); }
866
873
  .dfx-cell { color: var(--dsw-alias-label-secondary, #6f6f6f); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
867
- .dfx-empty { padding: 28px 16px; color: var(--dsw-alias-label-tertiary, #8f8f8f); text-align: center; }
874
+ .dfx-empty { padding: 28px 16px; color: var(--dsw-alias-label-tertiary, #8f8f8f); text-align: center; line-height: 1.7; }
868
875
  .dfx-notice { margin: 14px; padding: 12px 14px; border-radius: 10px; background: var(--dsw-alias-bg-layer-2, #f7f7f7); border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .08)); color: var(--dsw-alias-label-secondary, #5c5c5c); }
869
876
  .dfx-notice--error { border-color: var(--dsw-alias-border-danger, rgba(220, 60, 60, .35)); color: var(--dsw-alias-label-danger, #c0392b); }
870
877
  .dfx-preview { display: flex; flex-direction: column; flex: 0 0 auto; width: 42%; min-width: 260px; max-width: 620px; min-height: 0; border-left: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .08)); background: var(--dsw-alias-bg-layer-2, #fbfbfb); }
@@ -902,7 +909,170 @@ window.__ModuleLoader__.load({
902
909
  padding: 1px 5px; border-radius: 5px; font-size: 12px;
903
910
  background: var(--dsw-alias-bg-layer-2, #f4f4f4); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
904
911
  }
905
- .dfx-md-pre { margin: 8px 0; }
912
+ .dfx-md-pre { margin: 0; }
913
+ .dfx-md-fence { position: relative; margin: 8px 0; }
914
+ .dfx-md-lang {
915
+ position: absolute; top: 5px; right: 9px; font-size: 10px; letter-spacing: .05em;
916
+ text-transform: uppercase; color: var(--dsw-alias-label-tertiary, #8f8f8f); pointer-events: none;
917
+ }
918
+ .dfx-md-table { margin: 8px 0; }
919
+ .dfx-md-table .dfx-table td { white-space: normal; }
920
+ .dfx-md-html { margin: 8px 0; overflow-x: auto; }
921
+ .dfx-md-html h1, .dfx-md-html h2, .dfx-md-html h3, .dfx-md-html h4 { margin: 4px 0; font-size: 15px; line-height: 1.4; }
922
+ .dfx-md-html p { margin: 6px 0; }
923
+ .dfx-md-html img { max-width: 100%; height: auto; vertical-align: middle; }
924
+ .dfx-md-html table { border-collapse: collapse; width: 100%; font-size: 11.5px; }
925
+ .dfx-md-html th, .dfx-md-html td { border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .1)); padding: 6px 8px; text-align: center; vertical-align: middle; }
926
+ .dfx-md-html sub { font-size: 10.5px; color: var(--dsw-alias-label-secondary, #5c5c5c); }
927
+ .dfx-md-html a { color: var(--dfx-brand, #3b6cf6); text-decoration: none; }
928
+ .dfx-md-html hr { border: 0; border-top: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .1)); }
929
+ .dfx-md-task { list-style: none; margin-left: -16px; display: flex; align-items: baseline; gap: 6px; }
930
+ .dfx-md-check {
931
+ flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
932
+ width: 12px; height: 12px; border-radius: 3px; font-size: 9px; line-height: 1;
933
+ border: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, .28)); color: #fff;
934
+ }
935
+ .dfx-md-check--on { background: var(--dfx-brand, #3b6cf6); border-color: var(--dfx-brand, #3b6cf6); }
936
+ .dfx-md-hr { border: 0; border-top: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .1)); margin: 12px 0; }
937
+ .dfx-md-img { display: block; max-width: 100%; margin: 8px 0; border-radius: 8px; }
938
+ .dfx-notice--warn { border-color: var(--dsw-alias-border-warning, rgba(214, 136, 0, .38)); color: var(--dsw-alias-label-warning, #8a5a00); }
939
+ .dfx-seg {
940
+ display: inline-flex; align-items: center; gap: 2px; margin-left: auto; padding: 2px;
941
+ border-radius: 8px; background: var(--dsw-alias-bg-layer-2, #f2f2f2);
942
+ border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .08));
943
+ }
944
+ .dfx-seg-btn {
945
+ height: 20px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent;
946
+ color: var(--dsw-alias-label-secondary, #5c5c5c); font: inherit; font-size: 11px; line-height: 20px; cursor: pointer;
947
+ }
948
+ .dfx-seg-btn:hover { color: var(--dsw-alias-label-primary, #1b1b1b); }
949
+ .dfx-seg-btn--on {
950
+ background: var(--dsw-alias-bg-layer-1, #fff); color: var(--dsw-alias-label-primary, #1b1b1b);
951
+ box-shadow: 0 1px 2px rgba(0, 0, 0, .1);
952
+ }
953
+ .dfx-search-mode {
954
+ flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
955
+ width: 22px; height: 22px; margin-left: 2px; padding: 0; border: 0; border-radius: 6px;
956
+ background: transparent; color: var(--dsw-alias-label-tertiary, #8f8f8f); cursor: pointer;
957
+ }
958
+ .dfx-search-mode:hover { color: var(--dsw-alias-label-primary, #1b1b1b); background: var(--dsw-alias-bg-layer-2, rgba(0, 0, 0, .05)); }
959
+ .dfx-search-mode--on { color: var(--dfx-brand, #3b6cf6); background: rgba(59, 108, 246, .12); }
960
+ /* Search results are one column even when the grid view is active. */
961
+ .dfx-rows.dfx-rows--flat { display: block; }
962
+ .dfx-searchsum {
963
+ display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
964
+ padding: 8px 12px 6px; font-size: 11px; color: var(--dsw-alias-label-tertiary, #8f8f8f);
965
+ }
966
+ .dfx-searchsum-count { font-size: 12px; font-weight: 600; color: var(--dsw-alias-label-primary, #1b1b1b); white-space: nowrap; }
967
+ .dfx-searchsum-chip {
968
+ padding: 1px 7px; border-radius: 999px; font-size: 10.5px; line-height: 15px; white-space: nowrap;
969
+ background: var(--dsw-alias-bg-layer-2, rgba(0, 0, 0, .05)); color: var(--dsw-alias-label-secondary, #5c5c5c);
970
+ }
971
+ .dfx-searchsum-chip--warn { color: var(--dsw-alias-label-warning, #8a5a00); background: rgba(214, 136, 0, .12); }
972
+ .dfx-searchsum-meta { margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
973
+ .dfx-tile-snippet, .dfx-row-sub {
974
+ min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
975
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10.5px;
976
+ color: var(--dsw-alias-label-tertiary, #8f8f8f);
977
+ }
978
+ .dfx-tile-line {
979
+ position: absolute; top: 6px; right: 8px; padding: 0 4px; border-radius: 4px;
980
+ font-size: 10px; line-height: 14px; font-variant-numeric: tabular-nums;
981
+ color: var(--dfx-brand, #3b6cf6); background: rgba(59, 108, 246, .12);
982
+ }
983
+ .dfx-row--hit { height: auto; min-height: 42px; padding-top: 4px; padding-bottom: 5px; align-items: center; row-gap: 1px; }
984
+ .dfx-row--hit .dfx-row-sub--full { grid-column: 1 / -1; margin: 0 0 0 24px; }
985
+ .dfx-row--grouped.dfx-row--hit { height: auto; min-height: 40px; padding: 3px 8px; }
986
+ .dfx-row-sub { flex: 1 1 auto; margin-left: 8px; }
987
+ .dfx-hit-line {
988
+ flex: 0 0 auto; margin-right: 5px; padding: 0 4px; border-radius: 4px; font-weight: 500;
989
+ font-size: 10px; color: var(--dfx-brand, #3b6cf6); background: rgba(59, 108, 246, .12);
990
+ }
991
+ .dfx-hit {
992
+ background: rgba(255, 196, 0, .3); color: inherit; border-radius: 3px;
993
+ padding: 0 1px; box-shadow: inset 0 -1px 0 rgba(214, 136, 0, .35);
994
+ }
995
+ .dfx-search-empty {
996
+ display: flex; flex-direction: column; align-items: center; gap: 6px;
997
+ padding: 40px 16px; text-align: center; color: var(--dsw-alias-label-tertiary, #8f8f8f);
998
+ }
999
+ .dfx-search-empty-icon { display: inline-flex; opacity: .65; }
1000
+ .dfx-search-empty-title { font-size: 12.5px; color: var(--dsw-alias-label-secondary, #5c5c5c); }
1001
+ .dfx-search-empty-hint { font-size: 11px; }
1002
+ .dfx-drop-target { outline: 2px solid var(--dfx-brand, #3b6cf6); outline-offset: -2px; border-radius: 8px; }
1003
+ .dfx-pill--warn {
1004
+ color: var(--dsw-alias-label-warning, #8a5a00);
1005
+ border-color: var(--dsw-alias-border-warning, rgba(214, 136, 0, .4));
1006
+ background: rgba(214, 136, 0, .1);
1007
+ }
1008
+ .dfx-quick-backdrop {
1009
+ position: absolute; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
1010
+ padding: 24px; background: rgba(16, 18, 22, .45);
1011
+ }
1012
+ .dfx-quick {
1013
+ display: flex; flex-direction: column; width: min(880px, 100%); max-height: 100%;
1014
+ border-radius: 12px; overflow: hidden;
1015
+ background: var(--dsw-alias-bg-layer-1, #fff);
1016
+ box-shadow: 0 18px 48px rgba(0, 0, 0, .28);
1017
+ }
1018
+ .dfx-quick-head {
1019
+ display: flex; align-items: center; gap: 8px; padding: 8px 10px;
1020
+ border-bottom: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .08));
1021
+ }
1022
+ .dfx-quick-title { font-weight: 600; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1023
+ .dfx-quick-size { margin-left: auto; font-size: 11px; color: var(--dsw-alias-label-tertiary, #8f8f8f); }
1024
+ .dfx-quick-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px 14px 16px; display: flex; flex-direction: column; }
1025
+ .dfx-quick-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
1026
+ .dfx-quick-image { max-width: 100%; max-height: 100%; align-self: center; border-radius: 8px; }
1027
+ .dfx-quick-media { width: 100%; max-height: 100%; }
1028
+ .dfx-quick-frame { flex: 1 1 auto; width: 100%; min-height: 420px; border: 0; border-radius: 8px; background: #fff; }
1029
+ .dfx-quick-note { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
1030
+ .dfx-json { padding: 0 0 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 20px; }
1031
+ .dfx-json-tools { display: flex; gap: 6px; justify-content: flex-end; margin: 0 0 4px; }
1032
+ .dfx-json-tool {
1033
+ height: 22px; padding: 0 9px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 11px;
1034
+ border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .1));
1035
+ background: var(--dsw-alias-bg-layer-1, #fff); color: var(--dsw-alias-label-secondary, #5c5c5c);
1036
+ }
1037
+ .dfx-json-tool:hover { color: var(--dsw-alias-label-primary, #1b1b1b); border-color: var(--dsw-alias-border-l2, rgba(0, 0, 0, .2)); }
1038
+ .dfx-json-body { display: flex; flex-direction: column; }
1039
+ .dfx-json-line { display: flex; align-items: stretch; border-radius: 4px; }
1040
+ .dfx-json-line:hover { background: var(--dsw-alias-bg-layer-2, rgba(0, 0, 0, .03)); }
1041
+ .dfx-json-gutter {
1042
+ flex: 0 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 1px;
1043
+ width: 52px; padding-right: 8px; user-select: none; color: var(--dsw-alias-label-tertiary, #b3b3b3);
1044
+ }
1045
+ .dfx-json-no { min-width: 20px; text-align: right; font-size: 11px; font-variant-numeric: tabular-nums; }
1046
+ .dfx-json-fold {
1047
+ flex: 0 0 auto; width: 14px; height: 16px; padding: 0; border: 0; background: transparent;
1048
+ display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
1049
+ color: var(--dsw-alias-label-tertiary, #9a9a9a);
1050
+ }
1051
+ .dfx-json-fold:hover { color: var(--dsw-alias-label-primary, #1b1b1b); }
1052
+ .dfx-json-fold--none { cursor: default; }
1053
+ .dfx-json-chevron { display: inline-block; transition: transform .12s ease; font-size: 12px; line-height: 1; }
1054
+ .dfx-json-chevron::before { content: "\\203A"; }
1055
+ .dfx-json-chevron--open { transform: rotate(90deg); }
1056
+ .dfx-json-code {
1057
+ flex: 1 1 auto; min-width: 0; display: block; white-space: pre; padding-right: 14px;
1058
+ background-image: repeating-linear-gradient(to right, transparent 0 17px, var(--dsw-json-guide, rgba(0, 0, 0, .07)) 17px 18px);
1059
+ background-repeat: no-repeat;
1060
+ }
1061
+ .dfx-json-key { color: #24292f; }
1062
+ .dfx-json-idx { color: var(--dsw-alias-label-tertiary, #a3a3a3); }
1063
+ .dfx-json-punct { color: #9aa0a6; }
1064
+ .dfx-json-str { color: #0f766e; }
1065
+ .dfx-json-num { color: #0b6e99; }
1066
+ .dfx-json-bool { color: #b0245b; }
1067
+ .dfx-json-null { color: #a13d63; font-style: italic; }
1068
+ .dfx-json-note { margin-top: 8px; font-size: 11px; color: var(--dsw-alias-label-tertiary, #9a9a9a); }
1069
+ html[data-ds-theme-source="dark"] .dfx-json-key { color: #e6edf3; }
1070
+ html[data-ds-theme-source="dark"] .dfx-json-str { color: #56d4b0; }
1071
+ html[data-ds-theme-source="dark"] .dfx-json-num { color: #6cb6ff; }
1072
+ html[data-ds-theme-source="dark"] .dfx-json-bool { color: #ff8fab; }
1073
+ html[data-ds-theme-source="dark"] .dfx-json-null { color: #f0a8c0; }
1074
+ html[data-ds-theme-source="dark"] .dfx-json-punct { color: #8b949e; }
1075
+ html[data-ds-theme-source="dark"] .dfx-json-code { --dsw-json-guide: rgba(255, 255, 255, .12); }
906
1076
  .dfx-tablewrap { overflow: auto; border-radius: 10px; border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .1)); }
907
1077
  .dfx-table { border-collapse: collapse; font-size: 12px; min-width: 100%; }
908
1078
  .dfx-table th, .dfx-table td {
@@ -939,7 +1109,6 @@ window.__ModuleLoader__.load({
939
1109
  .dfx-embed-link { font-size: 12px; color: var(--dfx-brand); text-decoration: none; }
940
1110
  .dfx-embed-link:hover { text-decoration: underline; }
941
1111
  .dfx-media { width: 100%; border-radius: 10px; background: var(--dsw-alias-bg-layer-2, #f7f7f7); }
942
- .dfx-html { width: 100%; height: 360px; border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .1)); border-radius: 10px; background: #fff; }
943
1112
  .dfx-preview-foot { display: flex; align-items: center; gap: 6px; padding: 8px 12px; flex: 0 0 auto; border-top: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .07)); }
944
1113
  .dfx-panemode { display: flex; align-items: center; gap: 1px; padding: 2px; margin-left: auto; border-radius: 8px; background: var(--dsw-alias-bg-layer-2, #f2f2f2); flex: 0 0 auto; }
945
1114
  .dfx-panemode button {
@@ -949,12 +1118,15 @@ window.__ModuleLoader__.load({
949
1118
  .dfx-panemode button[aria-pressed="true"] { background: var(--dsw-alias-bg-layer-1, #fff); color: var(--dsw-alias-label-primary, #1b1b1b); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }
950
1119
  .dfx-panemode button:disabled { opacity: .38; cursor: default; box-shadow: none; background: transparent; }
951
1120
  .dfx-info { display: flex; flex-direction: column; padding: 2px 0 6px; }
1121
+ .dfx-info-name { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
1122
+ .dfx-info-row:first-child .dfx-info-value { font-weight: 600; }
952
1123
  .dfx-info-row {
953
- display: grid; grid-template-columns: 66px minmax(0, 1fr); gap: 10px; align-items: baseline;
1124
+ display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 10px; align-items: baseline;
954
1125
  padding: 8px 2px; border-bottom: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .06)); font-size: 12px;
955
1126
  }
956
1127
  .dfx-info-row:last-child { border-bottom: 0; }
957
- .dfx-info-label { color: var(--dsw-alias-label-tertiary, #8f8f8f); }
1128
+ .dfx-info-label { display: inline-flex; align-items: center; gap: 6px; color: var(--dsw-alias-label-tertiary, #8f8f8f); }
1129
+ .dfx-info-label svg { flex: 0 0 auto; opacity: .8; }
958
1130
  .dfx-info-value { color: var(--dsw-alias-label-primary, #1b1b1b); word-break: break-all; font-variant-numeric: tabular-nums; user-select: text; }
959
1131
  .dfx-pill {
960
1132
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px;
@@ -993,6 +1165,7 @@ window.__ModuleLoader__.load({
993
1165
  gap: 2px; padding: 8px 12px 14px; align-content: start;
994
1166
  }
995
1167
  .dfx-tile {
1168
+ position: relative;
996
1169
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px;
997
1170
  padding: 10px 6px 8px; border-radius: 10px; cursor: pointer; user-select: none;
998
1171
  transition: background-color 120ms ease;
@@ -1268,6 +1441,7 @@ window.__ModuleLoader__.load({
1268
1441
  fill: "none", stroke: "none",
1269
1442
  "aria-hidden": "true", focusable: "false",
1270
1443
  }, (artwork.parts || []).map(function (part, index) {
1444
+
1271
1445
  return h("path", {
1272
1446
  key: index,
1273
1447
  d: part.d,
@@ -1401,7 +1575,24 @@ window.__ModuleLoader__.load({
1401
1575
  text: ["M5 6h14", "M12 6v12", "M9 18h6"],
1402
1576
  external: ["M14 4h6v6", "M20 4l-8 8", "M18.5 14v5.5A1.5 1.5 0 0 1 17 21H5.5A1.5 1.5 0 0 1 4 19.5V8a1.5 1.5 0 0 1 1.5-1.5H11"],
1403
1577
  squares: ["M4 5.5A1.5 1.5 0 0 1 5.5 4h6A1.5 1.5 0 0 1 13 5.5v6A1.5 1.5 0 0 1 11.5 13h-6A1.5 1.5 0 0 1 4 11.5z", "M11 15.5A1.5 1.5 0 0 1 12.5 14h6a1.5 1.5 0 0 1 1.5 1.5v4a1.5 1.5 0 0 1-1.5 1.5h-6a1.5 1.5 0 0 1-1.5-1.5z"],
1404
- viewList: ["M4 7h.01", "M8 7h12", "M4 12h.01", "M8 12h12", "M4 17h.01", "M8 17h12"],
1578
+ // A folder with a folder inside it: search this folder and its children.
1579
+ folderNested: [
1580
+ "M3.4 8.4a1.6 1.6 0 0 1 1.6-1.6h3.1l1.5 1.8h7.4a1.6 1.6 0 0 1 1.6 1.6v7a1.6 1.6 0 0 1-1.6 1.6H5a1.6 1.6 0 0 1-1.6-1.6z",
1581
+ "M11.2 12.4h1.9l1.1 1.3h2.9a1.2 1.2 0 0 1 1.2 1.2v2.8a1.2 1.2 0 0 1-1.2 1.2h-5.9a1.2 1.2 0 0 1-1.2-1.2v-4.1a1.2 1.2 0 0 1 1.2-1.2z",
1582
+ ],
1583
+ viewList: ["M3.6 7.2h3.4", "M9.4 7.2h11", "M3.6 12h3.4", "M9.4 12h11", "M3.6 16.8h3.4", "M9.4 16.8h7.4"],
1584
+ // Two stacked sections, each with its own header row: the grouped view.
1585
+ viewGrouped: ["M5.4 5h13.2a1.6 1.6 0 0 1 1.6 1.6v10.8a1.6 1.6 0 0 1-1.6 1.6H5.4a1.6 1.6 0 0 1-1.6-1.6V6.6A1.6 1.6 0 0 1 5.4 5z", "M3.8 9.6h16.4", "M3.8 14.2h16.4"],
1586
+ // The tick and the cross of its neighbours side by side: invert the selection.
1587
+ // Label icons for the details list.
1588
+ // All drawn inside the same 16x16 optical box (4..20), so the sizes match at 13px.
1589
+ infoName: ["M5.2 4h9.4l4.2 4.2v11.8H5.2z", "M14.6 4v4.2h4.2"],
1590
+ infoSize: ["M12 3.8 19.8 8v8L12 20.2 4.2 16V8z", "M4.2 8 12 12.2 19.8 8", "M12 12.2v8"],
1591
+ infoPlace: ["M12 20.2s6.6-6.4 6.6-10.4A6.6 6.6 0 0 0 5.4 9.8c0 4 6.6 10.4 6.6 10.4z", "M12 12.4a2.2 2.2 0 1 0 0-4.4 2.2 2.2 0 0 0 0 4.4"],
1592
+ infoBorn: ["M6.2 5.8h11.6a1.8 1.8 0 0 1 1.8 1.8v10.6a1.8 1.8 0 0 1-1.8 1.8H6.2a1.8 1.8 0 0 1-1.8-1.8V7.6a1.8 1.8 0 0 1 1.8-1.8z", "M4.4 10.2h15.2", "M8.2 3.8v3.6", "M15.8 3.8v3.6"],
1593
+ infoTime: ["M12 19.5a7.5 7.5 0 1 0 0-15 7.5 7.5 0 0 0 0 15z", "M12 8.2V12l2.9 1.8"],
1594
+ infoAcl: ["M5.2 10.6h13.6v9.2H5.2z", "M8.4 10.6V8.2a3.6 3.6 0 0 1 7.2 0v2.4"],
1595
+ viewInvert: ["M6.4 9.4h10.2l-2.9-2.9", "M17.6 14.6H7.4l2.9 2.9"],
1405
1596
  viewGrid: ["M4 4.5h6v6H4z", "M14 4.5h6v6h-6z", "M4 13.5h6v6H4z", "M14 13.5h6v6h-6z"],
1406
1597
  info: ["M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18z", "M12 11v5.5", "M12 7.6h.01"],
1407
1598
  chevronDown: ["M6 9.5l6 6 6-6"],
@@ -1605,8 +1796,9 @@ window.__ModuleLoader__.load({
1605
1796
  bmp: "image", ico: "image", svg: "image",
1606
1797
  pdf: "pdf",
1607
1798
  md: "markdown", markdown: "markdown",
1608
- html: "html", htm: "html",
1799
+ // html / htm are deliberately not rendered: they open as source text.
1609
1800
  csv: "csv", tsv: "csv",
1801
+ json: "json",
1610
1802
  xlsx: "sheet", xlsm: "sheet",
1611
1803
  docx: "doc", docm: "doc",
1612
1804
  mp3: "audio", wav: "audio", m4a: "audio", aac: "audio", flac: "audio",
@@ -1615,7 +1807,7 @@ window.__ModuleLoader__.load({
1615
1807
  };
1616
1808
 
1617
1809
  /** Preview kinds that need the file's text before they can render. */
1618
- var TEXT_PREVIEW_KINDS = { text: 1, markdown: 1, csv: 1 };
1810
+ var TEXT_PREVIEW_KINDS = { text: 1, markdown: 1, csv: 1, json: 1 };
1619
1811
 
1620
1812
  /**
1621
1813
  * Pick a renderer for one entry, mirroring what DSH's own document preview
@@ -1637,16 +1829,19 @@ window.__ModuleLoader__.load({
1637
1829
  * @param {object} h - element factory
1638
1830
  * @returns {Array} nodes
1639
1831
  */
1640
- function markdownInline(line, h) {
1832
+ function markdownInline(line, h, baseDir) {
1641
1833
  var nodes = [];
1642
- var pattern = /(\*\*[^*]+\*\*|\x60[^\x60]+\x60|\[[^\]]+\]\([^)]+\)|\*[^*]+\*)/g;
1834
+ var pattern = /(!\[[^\]]*\]\([^)]+\)|\*\*[^*]+\*\*|\x60[^\x60]+\x60|\[[^\]]+\]\([^)]+\)|\*[^*]+\*)/g;
1643
1835
  var last = 0;
1644
1836
  var match = pattern.exec(line);
1645
1837
  var key = 0;
1646
1838
  while (match) {
1647
1839
  if (match.index > last) nodes.push(line.slice(last, match.index));
1648
1840
  var token = match[0];
1649
- if (token.slice(0, 2) === "**") {
1841
+ if (token.charAt(0) === "!") {
1842
+ var image = token.slice(2, -1).split("](");
1843
+ nodes.push(h("img", { key: "md" + key, className: "dfx-md-img", src: mdAssetUrl(image[1], baseDir), alt: image[0], loading: "lazy" }));
1844
+ } else if (token.slice(0, 2) === "**") {
1650
1845
  nodes.push(h("strong", { key: "md" + key }, token.slice(2, -2)));
1651
1846
  } else if (token.charCodeAt(0) === 96) {
1652
1847
  nodes.push(h("code", { key: "md" + key, className: "dfx-md-code" }, token.slice(1, -1)));
@@ -1670,51 +1865,314 @@ window.__ModuleLoader__.load({
1670
1865
  * @param {object} h - element factory
1671
1866
  * @returns {Array} nodes
1672
1867
  */
1673
- function renderMarkdown(text, h) {
1868
+ /** Split one markdown table row into trimmed cells. */
1869
+ function markdownTableRow(line) {
1870
+ return String(line).trim().replace(/^\|/, "").replace(/\|$/, "").split("|").map(function (cell) {
1871
+ return cell.trim();
1872
+ });
1873
+ }
1874
+
1875
+ /** Column alignments from the "|---|:--:|---:|" separator, or null. */
1876
+ function markdownTableAlign(line) {
1877
+ if (String(line).indexOf("|") < 0) return null;
1878
+ var cells = markdownTableRow(line);
1879
+ if (cells.length === 0) return null;
1880
+ var align = [];
1881
+ for (var i = 0; i < cells.length; i += 1) {
1882
+ var cell = cells[i].replace(/\s/g, "");
1883
+ if (!/^:?-{2,}:?$/.test(cell)) return null;
1884
+ var left = cell.charAt(0) === ":";
1885
+ var right = cell.charAt(cell.length - 1) === ":";
1886
+ align.push(left && right ? "center" : right ? "right" : "left");
1887
+ }
1888
+ return align;
1889
+ }
1890
+
1891
+
1892
+ /** Resolve a relative image path against the file being previewed. */
1893
+ function mdAssetUrl(src, baseDir) {
1894
+ var value = String(src || "");
1895
+ if (!value || /^(https?:|data:|mailto:|#|\/)/i.test(value) || !baseDir) return value;
1896
+ var parts = String(baseDir).split("/").filter(Boolean);
1897
+ value.replace(/^\.\//, "").split("/").forEach(function (segment) {
1898
+ if (segment === ".." || segment === "." || segment === "") {
1899
+ if (segment === "..") parts.pop();
1900
+ } else {
1901
+ parts.push(segment);
1902
+ }
1903
+ });
1904
+ return API + "/raw?path=" + encodeURIComponent("/" + parts.join("/"));
1905
+ }
1906
+
1907
+ /** Block-level HTML tags we are willing to render inside the preview. */
1908
+ var MD_HTML_BLOCKS = { div: 1, p: 1, h1: 1, h2: 1, h3: 1, h4: 1, h5: 1, h6: 1, table: 1, ul: 1, ol: 1, center: 1, section: 1, details: 1, blockquote: 1, figure: 1, img: 1 };
1909
+ var MD_HTML_VOID = { img: 1, br: 1, hr: 1, input: 1, source: 1, meta: 1, link: 1, wbr: 1 };
1910
+ var MD_HTML_ALLOWED = { DIV: 1, P: 1, H1: 1, H2: 1, H3: 1, H4: 1, H5: 1, H6: 1, IMG: 1, A: 1, B: 1, STRONG: 1, I: 1, EM: 1, BR: 1, SUB: 1, SUP: 1, SMALL: 1, TABLE: 1, THEAD: 1, TBODY: 1, TR: 1, TD: 1, TH: 1, UL: 1, OL: 1, LI: 1, SPAN: 1, CENTER: 1, HR: 1, CODE: 1, DETAILS: 1, SUMMARY: 1, BLOCKQUOTE: 1 };
1911
+
1912
+ /** Net open-tag count for one line of HTML (void and self-closing tags ignored). */
1913
+ function mdHtmlDepth(line) {
1914
+ var depth = 0;
1915
+ var re = /<\/?([a-zA-Z][\w-]*)([^>]*)>/g;
1916
+ var match = re.exec(line);
1917
+ while (match) {
1918
+ var tag = match[1].toLowerCase();
1919
+ var closing = match[0].charAt(1) === "/";
1920
+ var selfClose = /\/>$/.test(match[0]);
1921
+ if (!MD_HTML_VOID[tag] && !selfClose) depth += closing ? -1 : 1;
1922
+ match = re.exec(line);
1923
+ }
1924
+ return depth;
1925
+ }
1926
+
1927
+ /** Drop anything that could run code, keep the layout attributes READMEs use. */
1928
+ function mdSanitizeHtml(html, baseDir) {
1929
+ try {
1930
+ var doc = new DOMParser().parseFromString(html, "text/html");
1931
+ var walk = function (node) {
1932
+ Array.prototype.slice.call(node.childNodes).forEach(function (child) {
1933
+ if (child.nodeType !== 1) return;
1934
+ if (!MD_HTML_ALLOWED[child.tagName]) { child.remove(); return; }
1935
+ Array.prototype.slice.call(child.attributes).forEach(function (attr) {
1936
+ var name = attr.name.toLowerCase();
1937
+ var value = String(attr.value || "");
1938
+ if (name.indexOf("on") === 0 || name === "style" || name === "srcdoc") child.removeAttribute(attr.name);
1939
+ else if ((name === "href" || name === "src") && /^\s*(javascript|data):/i.test(value) && !/^\s*data:image\//i.test(value)) child.removeAttribute(attr.name);
1940
+ });
1941
+ walk(child);
1942
+ });
1943
+ };
1944
+ walk(doc.body);
1945
+ Array.prototype.slice.call(doc.body.querySelectorAll("img")).forEach(function (img) {
1946
+ var src = img.getAttribute("src");
1947
+ if (src) img.setAttribute("src", mdAssetUrl(src, baseDir));
1948
+ });
1949
+ return doc.body.innerHTML;
1950
+ } catch (error) {
1951
+ return "";
1952
+ }
1953
+ }
1954
+ /**
1955
+ * Render markdown into a small element tree: headings, lists (ordered,
1956
+ * bulleted, task), tables, quotes, fenced code, rules, images and links.
1957
+ * @param {string} text - markdown source
1958
+ * @param {object} h - element factory
1959
+ * @returns {Array} nodes
1960
+ */
1961
+ function renderMarkdown(text, h, baseDir) {
1674
1962
  var lines = String(text || "").split(/\r?\n/);
1675
1963
  var out = [];
1676
1964
  var list = null;
1965
+ var listTag = "ul";
1677
1966
  var fence = null;
1678
1967
  var fenceLines = [];
1679
- lines.forEach(function (line, index) {
1968
+ var fenceLang = "";
1969
+ var flushList = function (index) {
1970
+ if (!list) return;
1971
+ out.push(h(listTag, { key: "mdl" + index, className: "dfx-md-list" }, list));
1972
+ list = null;
1973
+ };
1974
+ var index = 0;
1975
+ while (index < lines.length) {
1976
+ var line = lines[index];
1680
1977
  if (line.slice(0, 3) === "\x60\x60\x60") {
1681
1978
  if (fence === null) {
1682
- fence = line.slice(3).trim();
1979
+ fence = "open";
1683
1980
  fenceLines = [];
1981
+ fenceLang = line.slice(3).trim();
1684
1982
  } else {
1685
- out.push(h("pre", { key: "md" + index, className: "dfx-pre dfx-md-pre" }, fenceLines.join("\n")));
1983
+ flushList(index);
1984
+ out.push(h("div", { key: "mdf" + index, className: "dfx-md-fence" },
1985
+ fenceLang ? h("span", { className: "dfx-md-lang" }, fenceLang) : null,
1986
+ h("pre", { className: "dfx-pre dfx-md-pre" }, fenceLines.join("\n"))));
1686
1987
  fence = null;
1687
1988
  fenceLines = [];
1989
+ fenceLang = "";
1688
1990
  }
1689
- return;
1991
+ index += 1;
1992
+ continue;
1690
1993
  }
1691
- if (fence !== null) { fenceLines.push(line); return; }
1994
+ if (fence !== null) { fenceLines.push(line); index += 1; continue; }
1995
+
1996
+ var htmlTag = line.match(/^\s*<([a-zA-Z][\w-]*)/);
1997
+ if (htmlTag && MD_HTML_BLOCKS[htmlTag[1].toLowerCase()]) {
1998
+ flushList(index);
1999
+ var htmlLines = [];
2000
+ var htmlDepth = 0;
2001
+ var htmlCursor = index;
2002
+ while (htmlCursor < lines.length) {
2003
+ var htmlLine = lines[htmlCursor];
2004
+ if (htmlLines.length > 0 && htmlDepth <= 0 && htmlLine.trim() === "") break;
2005
+ htmlLines.push(htmlLine);
2006
+ htmlDepth += mdHtmlDepth(htmlLine);
2007
+ htmlCursor += 1;
2008
+ if (htmlDepth <= 0 && /^\s*<\/(div|table|p|h[1-6]|ul|ol|center|section|details)>\s*$/.test(htmlLine.trim())) break;
2009
+ }
2010
+ out.push(h("div", {
2011
+ key: "mdh" + index,
2012
+ className: "dfx-md-html",
2013
+ dangerouslySetInnerHTML: { __html: mdSanitizeHtml(htmlLines.join("\n"), baseDir) },
2014
+ }));
2015
+ index = htmlCursor;
2016
+ continue;
2017
+ }
2018
+
1692
2019
  var head = line.match(/^(#{1,6})\s+(.*)$/);
1693
2020
  if (head) {
1694
- if (list) { out.push(h("ul", { key: "mdl" + index, className: "dfx-md-list" }, list)); list = null; }
1695
- out.push(h("h" + (head[1].length + 2), { key: "md" + index, className: "dfx-md-h" }, markdownInline(head[2], h)));
1696
- return;
2021
+ flushList(index);
2022
+ out.push(h("h" + (head[1].length + 2), { key: "md" + index, className: "dfx-md-h" }, markdownInline(head[2], h, baseDir)));
2023
+ index += 1;
2024
+ continue;
2025
+ }
2026
+
2027
+ var align = line.indexOf("|") >= 0 && index + 1 < lines.length ? markdownTableAlign(lines[index + 1]) : null;
2028
+ if (align) {
2029
+ flushList(index);
2030
+ var header = markdownTableRow(line);
2031
+ var body = [];
2032
+ var cursor = index + 2;
2033
+ while (cursor < lines.length && lines[cursor].indexOf("|") >= 0 && lines[cursor].trim() !== "") {
2034
+ body.push(markdownTableRow(lines[cursor]));
2035
+ cursor += 1;
2036
+ }
2037
+ out.push(h("div", { key: "mdt" + index, className: "dfx-tablewrap dfx-md-table" },
2038
+ h("table", { className: "dfx-table" },
2039
+ h("thead", null, h("tr", null, header.map(function (cell, cellIndex) {
2040
+ return h("th", { key: "th" + cellIndex, style: { textAlign: align[cellIndex] || "left" } }, markdownInline(cell, h, baseDir));
2041
+ }))),
2042
+ h("tbody", null, body.map(function (cells, rowIndex) {
2043
+ return h("tr", { key: "tr" + rowIndex }, cells.map(function (cell, cellIndex) {
2044
+ return h("td", { key: "td" + cellIndex, style: { textAlign: align[cellIndex] || "left" } }, markdownInline(cell, h, baseDir));
2045
+ }));
2046
+ })))));
2047
+ index = cursor;
2048
+ continue;
2049
+ }
2050
+
2051
+ if (/^\s*([-*_])(\s*\1){2,}\s*$/.test(line)) {
2052
+ flushList(index);
2053
+ out.push(h("hr", { key: "mdhr" + index, className: "dfx-md-hr" }));
2054
+ index += 1;
2055
+ continue;
1697
2056
  }
1698
- var bullet = line.match(/^\s*[-*+]\s+(.*)$/);
2057
+
2058
+ var task = line.match(/^\s*[-*+]\s+\[([ xX])\]\s+(.*)$/);
2059
+ if (task) {
2060
+ if (!list) { list = []; listTag = "ul"; }
2061
+ list.push(h("li", { key: "mdi" + index, className: "dfx-md-task" },
2062
+ h("span", { className: "dfx-md-check" + (task[1] === " " ? "" : " dfx-md-check--on"), "aria-hidden": "true" }, task[1] === " " ? "" : "✓"),
2063
+ markdownInline(task[2], h, baseDir)));
2064
+ index += 1;
2065
+ continue;
2066
+ }
2067
+
2068
+ var bullet = line.match(/^(\s*)[-*+]\s+(.*)$/);
1699
2069
  if (bullet) {
1700
- if (!list) list = [];
1701
- list.push(h("li", { key: "mdi" + index }, markdownInline(bullet[1], h)));
1702
- return;
2070
+ if (!list) { list = []; listTag = "ul"; }
2071
+ else if (listTag !== "ul") { flushList(index); list = []; listTag = "ul"; }
2072
+ var level = Math.floor(bullet[1].replace(/\t/g, " ").length / 2);
2073
+ list.push(h("li", { key: "mdi" + index, style: level ? { marginLeft: (level * 12) + "px" } : undefined }, markdownInline(bullet[2], h, baseDir)));
2074
+ index += 1;
2075
+ continue;
2076
+ }
2077
+
2078
+ var ordered = line.match(/^\s*(\d+)[.)]\s+(.*)$/);
2079
+ if (ordered) {
2080
+ if (!list) { list = []; listTag = "ol"; }
2081
+ else if (listTag !== "ol") { flushList(index); list = []; listTag = "ol"; }
2082
+ list.push(h("li", { key: "mdo" + index }, markdownInline(ordered[2], h, baseDir)));
2083
+ index += 1;
2084
+ continue;
1703
2085
  }
1704
- if (list) { out.push(h("ul", { key: "mdl" + index, className: "dfx-md-list" }, list)); list = null; }
2086
+
2087
+ flushList(index);
1705
2088
  var quote = line.match(/^>\s?(.*)$/);
1706
2089
  if (quote) {
1707
- out.push(h("blockquote", { key: "md" + index, className: "dfx-md-quote" }, markdownInline(quote[1], h)));
1708
- return;
2090
+ out.push(h("blockquote", { key: "md" + index, className: "dfx-md-quote" }, markdownInline(quote[1], h, baseDir)));
2091
+ index += 1;
2092
+ continue;
1709
2093
  }
1710
- if (line.trim() === "") return;
1711
- out.push(h("p", { key: "md" + index, className: "dfx-md-p" }, markdownInline(line, h)));
1712
- });
1713
- if (list) out.push(h("ul", { key: "mdl-end", className: "dfx-md-list" }, list));
1714
- if (fenceLines.length > 0) out.push(h("pre", { key: "md-fence", className: "dfx-pre dfx-md-pre" }, fenceLines.join("\n")));
2094
+ if (line.trim() === "") { index += 1; continue; }
2095
+ var image = line.trim().match(/^!\[([^\]]*)\]\(([^)\s]+)\)$/);
2096
+ if (image) {
2097
+ out.push(h("img", { key: "mdi" + index, className: "dfx-md-img", src: mdAssetUrl(image[2], baseDir), alt: image[1], loading: "lazy" }));
2098
+ index += 1;
2099
+ continue;
2100
+ }
2101
+ out.push(h("p", { key: "md" + index, className: "dfx-md-p" }, markdownInline(line, h, baseDir)));
2102
+ index += 1;
2103
+ }
2104
+ flushList("end");
2105
+ if (fence !== null && fenceLines.length > 0) {
2106
+ out.push(h("div", { key: "mdf-end", className: "dfx-md-fence" },
2107
+ fenceLang ? h("span", { className: "dfx-md-lang" }, fenceLang) : null,
2108
+ h("pre", { className: "dfx-pre dfx-md-pre" }, fenceLines.join("\n"))));
2109
+ }
1715
2110
  return out;
1716
2111
  }
1717
2112
 
2113
+ /** One JSON value as a coloured token, with long strings clipped. */
2114
+ function jsonTokenOf(value) {
2115
+ if (value === null) return { kind: "null", text: "null" };
2116
+ if (typeof value === "string") {
2117
+ var quoted = JSON.stringify(value);
2118
+ if (quoted.length > 180) return { kind: "str", text: quoted.slice(0, 180) + "…\"", full: quoted };
2119
+ return { kind: "str", text: quoted };
2120
+ }
2121
+ if (typeof value === "number") return { kind: "num", text: String(value) };
2122
+ return { kind: "bool", text: String(value) };
2123
+ }
2124
+
2125
+ /**
2126
+ * Pretty-print parsed JSON into source lines, recording the line range of
2127
+ * every branch so the viewer can fold it like an editor.
2128
+ * @param {*} value - parsed JSON
2129
+ * @param {number} budget - maximum output lines
2130
+ * @returns {object} { lines, folds, truncated }
2131
+ */
2132
+ function jsonSourceOf(value, budget) {
2133
+ var lines = [];
2134
+ var folds = [];
2135
+ var left = budget;
2136
+ var truncated = false;
2137
+ var punct = function (text) { return { kind: "punct", text: text }; };
2138
+ var walk = function (node, key, depth, isLast, isIndex) {
2139
+ if (left <= 0) { truncated = true; return; }
2140
+ left -= 1;
2141
+ var head = [];
2142
+ if (key !== null && !isIndex) {
2143
+ head.push({ kind: "key", text: JSON.stringify(key) });
2144
+ head.push(punct(": "));
2145
+ }
2146
+ var tail = isLast ? [] : [punct(",")];
2147
+ if (node && typeof node === "object") {
2148
+ var isArray = Array.isArray(node);
2149
+ var keys = isArray ? node.map(function (_, index) { return index; }) : Object.keys(node);
2150
+ if (keys.length === 0) {
2151
+ lines.push({ depth: depth, tokens: head.concat([punct(isArray ? "[]" : "{}")], tail) });
2152
+ return;
2153
+ }
2154
+ var open = lines.length;
2155
+ lines.push({
2156
+ depth: depth,
2157
+ tokens: head.concat([punct(isArray ? "[" : "{")]),
2158
+ tail: (isArray ? "]" : "}") + (isLast ? "" : ","),
2159
+ });
2160
+ keys.forEach(function (childKey, index) {
2161
+ walk(node[childKey], String(childKey), depth + 1, index === keys.length - 1, isArray);
2162
+ });
2163
+ var close = lines.length;
2164
+ lines.push({ depth: depth, tokens: [punct(isArray ? "]" : "}")].concat(tail) });
2165
+ lines[open].end = close;
2166
+ folds.push(open);
2167
+ return;
2168
+ }
2169
+ var token = jsonTokenOf(node);
2170
+ lines.push({ depth: depth, tokens: head.concat([{ kind: token.kind, text: token.text, full: token.full }], tail) });
2171
+ };
2172
+ walk(value, null, 0, true, false);
2173
+ return { lines: lines, folds: folds, truncated: truncated };
2174
+ }
2175
+
1718
2176
  /**
1719
2177
  * Parse delimited text into a capped table of cells.
1720
2178
  * @param {string} text - csv/tsv source
@@ -1822,8 +2280,8 @@ window.__ModuleLoader__.load({
1822
2280
  * @param {string} text - new contents
1823
2281
  * @returns {Promise<object>} { ok, body }
1824
2282
  */
1825
- function apiWrite(targetPath, text) {
1826
- return apiPost("/write", { path: targetPath }, { text: text });
2283
+ function apiWrite(targetPath, text, version) {
2284
+ return apiPost("/write", { path: targetPath }, { text: text, version: version || null });
1827
2285
  }
1828
2286
 
1829
2287
  /**
@@ -1978,7 +2436,7 @@ window.__ModuleLoader__.load({
1978
2436
  h("h2", { className: "dfx-about-name" }, t("文件管理器")),
1979
2437
  h("span", { className: "dfx-about-version" }, "v" + version)),
1980
2438
  h("div", { className: "dfx-about-body" },
1981
- h("p", { className: "dfx-about-blurb" }, t("轻量级本地文件管理:浏览、预览、批量选择与常用操作。")),
2439
+ h("p", { className: "dfx-about-blurb" }, t("浏览 · 预览 · 编辑 · 整理 —— 并把文件直接交给 Agent")),
1982
2440
  h("div", { className: "dfx-about-rows" }, rows.map(function (row) {
1983
2441
  var valueNode = row.href
1984
2442
  ? h("a", {
@@ -2058,7 +2516,7 @@ window.__ModuleLoader__.load({
2058
2516
  h("div", { className: "dfx-opt-section" },
2059
2517
  h("div", { className: "dfx-opt-heading" }, t("分类视图")),
2060
2518
  h("div", { className: "dfx-opt-row" },
2061
- h("span", { className: "dfx-opt-label" }, glyph("squares", 15), t("分组外观")),
2519
+ h("span", { className: "dfx-opt-label" }, glyph("viewGrouped", 15), t("分组外观")),
2062
2520
  h("div", { className: "dfx-seg" }, GROUP_STYLES.map(function (option) {
2063
2521
  return h("button", {
2064
2522
  key: option.id,
@@ -2264,6 +2722,27 @@ window.__ModuleLoader__.load({
2264
2722
  var [status, setStatus] = useState("loading");
2265
2723
  var [error, setError] = useState(null);
2266
2724
  var [query, setQuery] = useState("");
2725
+ /** Search scope: the current folder only, or the whole subtree; and names versus contents. */
2726
+ var [searchDeep, setSearchDeep] = useState(false);
2727
+ var [searchMode, setSearchMode] = useState("name");
2728
+ var [searchResult, setSearchResult] = useState(null);
2729
+ var [searchBusy, setSearchBusy] = useState(false);
2730
+ /** The previewed file changed on disk since it was opened. */
2731
+ var [previewStale, setPreviewStale] = useState(false);
2732
+ /** Set when a save is refused because the file changed underneath. */
2733
+ var [editorConflict, setEditorConflict] = useState(null);
2734
+ /** Quick Look overlay: the entry and the payload loaded for it. */
2735
+ var [quickLook, setQuickLook] = useState(null);
2736
+ /** The Quick Look overlay, focused while it is open. */
2737
+ var quickRef = useRef(null);
2738
+ /** Latest selection, so a background refresh can keep it. */
2739
+ var selectionRef = useRef(null);
2740
+ var [quickData, setQuickData] = useState(null);
2741
+ /** Folder row the drag is currently over. */
2742
+ var [dropTarget, setDropTarget] = useState(null);
2743
+ var watchRef = useRef({ dir: null, preview: null, busy: false });
2744
+ var loadRef = useRef(null);
2745
+ var previewPathRef = useRef(null);
2267
2746
  var [showHidden, setShowHiddenState] = useState(readStoredHidden);
2268
2747
  /** Show or hide dotfiles, and remember it. */
2269
2748
  var setShowHidden = function (next) {
@@ -2312,6 +2791,8 @@ window.__ModuleLoader__.load({
2312
2791
  var [preview, setPreview] = useState(null);
2313
2792
  var [previewStatus, setPreviewStatus] = useState("idle");
2314
2793
  var [activeSheet, setActiveSheet] = useState(0);
2794
+ var [jsonOpen, setJsonOpen] = useState({});
2795
+ var [jsonRaw, setJsonRaw] = useState(false);
2315
2796
 
2316
2797
  var [details, setDetails] = useState(null);
2317
2798
  var [detailsStatus, setDetailsStatus] = useState("idle");
@@ -2340,6 +2821,8 @@ window.__ModuleLoader__.load({
2340
2821
  langRef.current = langPref;
2341
2822
  var navSeqRef = useRef(0);
2342
2823
  var requestSeq = useRef(0);
2824
+ /** The last folder opened from this spot; a second double-click from the same gesture is ignored. */
2825
+ var openGuardRef = useRef({ at: 0, x: -1, y: -1, path: null });
2343
2826
  var rowsRef = useRef(null);
2344
2827
  var searchRef = useRef(null);
2345
2828
  var previewRef = useRef(null);
@@ -2432,6 +2915,11 @@ window.__ModuleLoader__.load({
2432
2915
  };
2433
2916
  }, [menu]);
2434
2917
 
2918
+ useEffect(function () {
2919
+ setJsonOpen({});
2920
+ setJsonRaw(false);
2921
+ }, [preview && preview.entry ? preview.entry.path : null]);
2922
+
2435
2923
  var openPreview = useCallback(function (entry) {
2436
2924
  if (!entry || entry.dir) {
2437
2925
  setPreview(null);
@@ -2439,6 +2927,7 @@ window.__ModuleLoader__.load({
2439
2927
  return;
2440
2928
  }
2441
2929
  var kind = previewKindOf(entry);
2930
+ setPreviewStale(false);
2442
2931
  setActiveSheet(0);
2443
2932
  if (kind === "doc") {
2444
2933
  setPreviewStatus("loading");
@@ -2629,9 +3118,29 @@ window.__ModuleLoader__.load({
2629
3118
  selectEntry(entry);
2630
3119
  }
2631
3120
 
2632
- var openEntry = useCallback(function (entry) {
3121
+ var openEntry = useCallback(function (entry, event) {
2633
3122
  if (!entry) return;
2634
- if (entry.dir) { load(entry.path, undefined, "in"); return; }
3123
+ if (entry.dir) {
3124
+ // A fast double-click can deliver a second dblclick after the listing
3125
+ // has already changed under the pointer, which opens a folder two
3126
+ // levels down. Two guards keep that from happening while deliberate
3127
+ // navigation stays instant:
3128
+ // * another folder within 300 ms of the previous open — always a
3129
+ // repeat of the same gesture, wherever the pointer is;
3130
+ // * another folder within 900 ms at (nearly) the same spot — the
3131
+ // listing moved under a pointer that never moved.
3132
+ var now = Date.now();
3133
+ var guard = openGuardRef.current;
3134
+ var x = event && typeof event.clientX === "number" ? event.clientX : -1;
3135
+ var y = event && typeof event.clientY === "number" ? event.clientY : -1;
3136
+ var other = Boolean(guard.path) && guard.path !== entry.path;
3137
+ var sameSpot = x >= 0 && y >= 0 && guard.x >= 0 && guard.y >= 0
3138
+ && Math.abs(x - guard.x) < 12 && Math.abs(y - guard.y) < 12;
3139
+ if (other && (now - guard.at < 300 || (sameSpot && now - guard.at < 900))) return;
3140
+ openGuardRef.current = { at: now, x: x, y: y, path: entry.path };
3141
+ load(entry.path, undefined, "in");
3142
+ return;
3143
+ }
2635
3144
  setPaneMode("preview");
2636
3145
  openPreview(entry);
2637
3146
  }, [load, openPreview]);
@@ -2657,6 +3166,195 @@ window.__ModuleLoader__.load({
2657
3166
  });
2658
3167
  }, [load, notify]);
2659
3168
 
3169
+ loadRef.current = load;
3170
+
3171
+ /** Run the host search when the query asks for more than this folder. */
3172
+ useEffect(function () {
3173
+ var needle = query.trim();
3174
+ var deep = searchDeep || searchMode === "content";
3175
+ if (!needle || !deep || !listing) {
3176
+ setSearchResult(null);
3177
+ setSearchBusy(false);
3178
+ return undefined;
3179
+ }
3180
+ var folder = listing.path;
3181
+ var timer = setTimeout(function () {
3182
+ setSearchBusy(true);
3183
+ apiGet("/search", {
3184
+ path: folder,
3185
+ query: needle,
3186
+ mode: searchMode,
3187
+ hidden: showHidden ? "1" : "0",
3188
+ }).then(function (result) {
3189
+ setSearchBusy(false);
3190
+ if (result.ok) setSearchResult(result.body);
3191
+ else setSearchResult({ hits: [], error: (result.body && result.body.message) || t("搜索失败") });
3192
+ }, function (failure) {
3193
+ setSearchBusy(false);
3194
+ setSearchResult({ hits: [], error: String((failure && failure.message) || failure) });
3195
+ });
3196
+ }, 260);
3197
+ return function () { clearTimeout(timer); };
3198
+ }, [query, searchDeep, searchMode, showHidden, listing && listing.path]);
3199
+
3200
+ /** Re-baseline the watcher whenever the folder or the previewed file changes. */
3201
+ useEffect(function () {
3202
+ watchRef.current = { dir: null, preview: null, busy: false };
3203
+ }, [listing && listing.path, preview && preview.entry ? preview.entry.path : null]);
3204
+
3205
+ /** Poll a cheap fingerprint so files an agent writes show up on their own. */
3206
+ useEffect(function () {
3207
+ var timer = setInterval(function () {
3208
+ if (typeof document !== "undefined" && document.visibilityState === "hidden") return;
3209
+ var current = listingRef.current;
3210
+ if (!current || watchRef.current.busy) return;
3211
+ var previewPath = previewPathRef.current;
3212
+ watchRef.current.busy = true;
3213
+ apiGet("/watch", { path: current.path, preview: previewPath }).then(function (result) {
3214
+ watchRef.current.busy = false;
3215
+ if (!result.ok || !result.body) return;
3216
+ var body = result.body;
3217
+ var last = watchRef.current;
3218
+ var listingChanged = last.dir !== null && body.dir !== last.dir;
3219
+ last.dir = body.dir;
3220
+ if (previewPath) {
3221
+ if (last.preview !== null && body.preview !== last.preview) setPreviewStale(true);
3222
+ last.preview = body.preview;
3223
+ } else {
3224
+ last.preview = null;
3225
+ }
3226
+ var live = listingRef.current;
3227
+ if (listingChanged && loadRef.current && live && live.path === current.path) {
3228
+ var keep = selectionRef.current ? selectionRef.current.path : null;
3229
+ loadRef.current(current.path, keep, "neutral");
3230
+ }
3231
+ }, function () { watchRef.current.busy = false; });
3232
+ }, 1600);
3233
+ return function () { clearInterval(timer); };
3234
+ }, []);
3235
+
3236
+ selectionRef.current = selected;
3237
+
3238
+ /** Focus the Quick Look overlay while it is open, so keys reach it. */
3239
+ useEffect(function () {
3240
+ if (!quickLook) return;
3241
+ var node = quickRef.current;
3242
+ if (node && node.focus) {
3243
+ try { node.focus(); } catch (error) { /* focus is best effort */ }
3244
+ }
3245
+ }, [quickLook]);
3246
+
3247
+ /** Load the Quick Look payload for the entry on screen. */
3248
+ useEffect(function () {
3249
+ if (!quickLook) { setQuickData(null); return undefined; }
3250
+ var alive = true;
3251
+ var kind = previewKindOf(quickLook);
3252
+ if (!TEXT_PREVIEW_KINDS[kind]) {
3253
+ setQuickData({ kind: kind });
3254
+ return function () { alive = false; };
3255
+ }
3256
+ setQuickData({ kind: kind, loading: true });
3257
+ apiGet("/read", { path: quickLook.path }).then(function (result) {
3258
+ if (!alive) return;
3259
+ if (!result.ok) setQuickData({ kind: kind, error: (result.body && result.body.message) || t("无法读取文件") });
3260
+ else setQuickData({ kind: kind, body: result.body });
3261
+ }, function (failure) {
3262
+ if (alive) setQuickData({ kind: kind, error: String((failure && failure.message) || failure) });
3263
+ });
3264
+ return function () { alive = false; };
3265
+ }, [quickLook]);
3266
+
3267
+ /** Move dragged rows into a folder; the caller has already ended the drag. */
3268
+ var moveInto = function (targetDir, rows) {
3269
+ var sources = (rows || []).filter(function (row) {
3270
+ return row && row.path && row.path !== targetDir && targetDir.indexOf(row.path + "/") !== 0;
3271
+ }).map(function (row) { return row.path; });
3272
+ if (sources.length === 0) return;
3273
+ mutate({
3274
+ route: "/transfer",
3275
+ body: { sources: sources, target: targetDir, mode: "move" },
3276
+ success: tf("已移动 {n} 项", { n: String(sources.length) }),
3277
+ });
3278
+ };
3279
+
3280
+ /** Drop a dragged row onto a folder row to move it there. */
3281
+ var dirDrop = function (entry) {
3282
+ if (!entry || !entry.dir) return {};
3283
+ var blocked = dragEntries && dragEntries.some(function (row) {
3284
+ return row.path === entry.path || entry.path.indexOf(row.path + "/") === 0;
3285
+ });
3286
+ return {
3287
+ onDragOver: function (event) {
3288
+ if (!dragEntries || dragEntries.length === 0 || blocked || !event || !event.dataTransfer) return;
3289
+ event.preventDefault();
3290
+ event.stopPropagation();
3291
+ event.dataTransfer.dropEffect = "move";
3292
+ setDropTarget(entry.path);
3293
+ },
3294
+ onDragLeave: function () {
3295
+ setDropTarget(function (previous) { return previous === entry.path ? null : previous; });
3296
+ },
3297
+ onDrop: function (event) {
3298
+ if (!dragEntries || dragEntries.length === 0 || blocked || !event) return;
3299
+ event.preventDefault();
3300
+ event.stopPropagation();
3301
+ var rows = dragEntries;
3302
+ setDropTarget(null);
3303
+ endDrag();
3304
+ moveInto(entry.path, rows);
3305
+ },
3306
+ };
3307
+ };
3308
+
3309
+ /** Jump from one search result to the item it names. */
3310
+ var openSearchHit = function (hit) {
3311
+ if (!hit) return;
3312
+ if (hit.dir) { load(hit.path, null, "in"); return; }
3313
+ load(hit.parent, hit.path, "neutral");
3314
+ let open = { path: hit.path, name: hit.name, dir: false, size: hit.size, mtime: hit.mtime };
3315
+ openPreview(open);
3316
+ };
3317
+
3318
+ /** The Quick Look overlay body for whatever was loaded. */
3319
+ var quickLookBody = function () {
3320
+ if (!quickLook) return null;
3321
+ if (!quickData) return h("div", { className: "dfx-empty" }, t("正在加载…"));
3322
+ if (quickData.error) {
3323
+ return h("div", { className: "dfx-notice dfx-notice--error" }, tf("无法预览:{reason}", { reason: quickData.error }));
3324
+ }
3325
+ var kind = quickData.kind;
3326
+ var raw = API + "/raw?path=" + encodeURIComponent(quickLook.path);
3327
+ if (kind === "image") return h("img", { className: "dfx-quick-image", src: raw, alt: quickLook.name });
3328
+ if (kind === "pdf") return h("iframe", { className: "dfx-quick-frame", src: raw, title: quickLook.name });
3329
+ if (kind === "audio") return h("audio", { className: "dfx-quick-media", src: raw, controls: true, autoPlay: true });
3330
+ if (kind === "video") return h("video", { className: "dfx-quick-media", src: raw, controls: true, autoPlay: true });
3331
+ if (kind === "sheet" || kind === "doc") {
3332
+ return h("div", { className: "dfx-quick-note" },
3333
+ h("p", null, t("表格与文档在右侧预览中打开更清楚。")),
3334
+ h("button", {
3335
+ type: "button",
3336
+ className: "dfx-pill dfx-pill--primary",
3337
+ onClick: function () { var entry = quickLook; setQuickLook(null); setPaneMode("preview"); openPreview(entry); },
3338
+ }, t("打开右侧预览")));
3339
+ }
3340
+ if (!quickData.body) return h("div", { className: "dfx-empty" }, t("正在加载…"));
3341
+ var payload = quickData.body;
3342
+ if (kind === "markdown") return h("div", { className: "dfx-md dfx-quick-scroll" }, renderMarkdown(payload.text, h, parentOf(quickLook.path)));
3343
+ if (kind === "json") return h("div", { className: "dfx-quick-scroll" }, jsonPane(payload.text));
3344
+ if (kind === "csv") {
3345
+ var tableRows = parseDelimited(payload.text, /\.tsv$/i.test(quickLook.name) ? " " : ",");
3346
+ return h("div", { className: "dfx-quick-scroll" }, h("div", { className: "dfx-tablewrap" }, h("table", { className: "dfx-table" },
3347
+ h("tbody", null, tableRows.slice(0, 200).map(function (cells, rowIndex) {
3348
+ return h("tr", { key: "r" + rowIndex }, cells.map(function (cell, cellIndex) {
3349
+ return rowIndex === 0
3350
+ ? h("th", { key: "c" + cellIndex }, cell)
3351
+ : h("td", { key: "c" + cellIndex }, cell);
3352
+ }));
3353
+ })))));
3354
+ }
3355
+ return h("pre", { className: "dfx-pre dfx-quick-scroll" }, payload.text);
3356
+ };
3357
+
2660
3358
  var copyText = useCallback(function (text, success) {
2661
3359
  var write = navigator.clipboard && navigator.clipboard.writeText
2662
3360
  ? navigator.clipboard.writeText(text)
@@ -3199,11 +3897,11 @@ window.__ModuleLoader__.load({
3199
3897
  : [];
3200
3898
  return uploadRows.concat([
3201
3899
  { separator: true },
3202
- { id: "undo", label: undoStack.length > 0 ? t("撤销 ") + undoStack[0].label : t("撤销"), icon: "undo", disabled: undoStack.length === 0 },
3900
+ { id: "undo", label: undoStack.length > 0 ? t("撤销 ") + undoStack[0].label : t("撤销"), icon: "undo", hint: accel("Z"), disabled: undoStack.length === 0 },
3203
3901
  { separator: true },
3204
3902
  { id: "all", label: t("全部选择"), icon: "check", hint: accel("A") },
3205
3903
  { id: "none", label: t("全部取消"), icon: "close", hint: IS_MAC ? "⌘⇧A" : "Ctrl+Shift+A" },
3206
- { id: "invert", label: t("反向选择"), icon: "squares", hint: IS_MAC ? "⌘⌥A" : "Ctrl+Alt+A" },
3904
+ { id: "invert", label: t("反向选择"), icon: "viewInvert", hint: IS_MAC ? "⌘⌥A" : "Ctrl+Alt+A" },
3207
3905
  { separator: true },
3208
3906
  { id: "options", label: t("选项"), icon: "sliders" },
3209
3907
  { id: "about", label: t("关于"), icon: "info" },
@@ -3393,16 +4091,35 @@ window.__ModuleLoader__.load({
3393
4091
  event.preventDefault();
3394
4092
  return;
3395
4093
  }
3396
- if (meta && (event.key === "1" || event.key === "2")) {
4094
+ if (meta && (event.key === "1" || event.key === "2" || event.key === "3")) {
3397
4095
  changeView(VIEW_MODES[Number(event.key) - 1]);
3398
4096
  event.preventDefault();
3399
4097
  return;
3400
4098
  }
4099
+ if (meta && (event.key === "z" || event.key === "Z")) {
4100
+ if (undoStack.length === 0) return;
4101
+ event.preventDefault();
4102
+ event.stopPropagation();
4103
+ runUndo();
4104
+ return;
4105
+ }
3401
4106
  if (meta && (event.key === "a" || event.key === "A")) {
3402
4107
  if (event.shiftKey) { clearSelection(); } else if (event.altKey) { invertSelection(); } else { selectAllRows(); }
3403
4108
  event.preventDefault();
3404
4109
  return;
3405
4110
  }
4111
+ if ((event.key === " " || event.code === "Space") && selected && !editor && !dialog) {
4112
+ event.preventDefault();
4113
+ if (quickLook) { setQuickLook(null); return; }
4114
+ setQuickLook(selected);
4115
+ return;
4116
+ }
4117
+ if ((event.key === "Escape" || event.code === "Escape") && quickLook) {
4118
+ event.preventDefault();
4119
+ event.stopPropagation();
4120
+ setQuickLook(null);
4121
+ return;
4122
+ }
3406
4123
  if (event.key === "Escape" && !meta) {
3407
4124
  clearSelection();
3408
4125
  return;
@@ -3573,35 +4290,123 @@ window.__ModuleLoader__.load({
3573
4290
  saveColumns(next);
3574
4291
  }
3575
4292
 
4293
+ /** Wrap every occurrence of the query, so hits can be spotted at a glance. */
4294
+ var highlightMatch = function (text, needle) {
4295
+ var value = String(text || "");
4296
+ var term = String(needle || "").trim();
4297
+ if (!term) return value;
4298
+ var lower = value.toLowerCase();
4299
+ var target = term.toLowerCase();
4300
+ var parts = [];
4301
+ var from = 0;
4302
+ var at = lower.indexOf(target, from);
4303
+ var guard = 0;
4304
+ while (at !== -1 && guard < 12) {
4305
+ if (at > from) parts.push(value.slice(from, at));
4306
+ parts.push(h("mark", { className: "dfx-hit", key: "m" + parts.length }, value.slice(at, at + term.length)));
4307
+ from = at + term.length;
4308
+ at = lower.indexOf(target, from);
4309
+ guard += 1;
4310
+ }
4311
+ if (from === 0) return value;
4312
+ if (from < value.length) parts.push(value.slice(from));
4313
+ return parts;
4314
+ };
4315
+
4316
+ /** Keep a hit's preview kind aligned with the listing's kind names. */
4317
+ var KIND_ALIAS = { markdown: "text", json: "text", csv: "text", tsv: "text", html: "text" };
4318
+
4319
+ /** Turn search hits into the same entry objects the views already draw. */
4320
+ var searchEntries = function () {
4321
+ var hits = (searchResult && searchResult.hits) || [];
4322
+ return hits.map(function (hit) {
4323
+ var preview = hit.dir ? null : previewKindOf({ name: hit.name });
4324
+ var kind = hit.dir ? "folder" : KIND_ALIAS[preview] || preview || "other";
4325
+ return {
4326
+ name: hit.name,
4327
+ path: hit.path,
4328
+ dir: !!hit.dir,
4329
+ size: hit.size,
4330
+ mtime: hit.mtime,
4331
+ hidden: !!hit.hidden,
4332
+ kind: kind,
4333
+ hit: hit,
4334
+ snippet: String(hit.text || ""),
4335
+ };
4336
+ });
4337
+ };
4338
+
4339
+ /** A hit lives in another folder, so selecting one only marks it. */
4340
+ var selectSearchHit = function (entry) {
4341
+ setSelectedPaths([entry.path]);
4342
+ setSelected(entry);
4343
+ };
4344
+
4345
+ /** Count / mode / budget bar above the result list. */
4346
+ var searchSummary = function () {
4347
+ if (!searchResult) return null;
4348
+ var hits = searchResult.hits || [];
4349
+ var content = searchResult.mode === "content";
4350
+ return h("div", { className: "dfx-searchsum" },
4351
+ h("span", { className: "dfx-searchsum-count" }, tf("{n} 个结果", { n: String(hits.length) })),
4352
+ h("span", { className: "dfx-searchsum-chip" }, content ? t("内容") : t("名称")),
4353
+ searchResult.truncated ? h("span", { className: "dfx-searchsum-chip dfx-searchsum-chip--warn" }, t("已截断")) : null,
4354
+ h("span", { className: "dfx-searchsum-meta" }, tf("扫描 {n} 项 · {ms} ms", {
4355
+ n: String(searchResult.scanned || 0),
4356
+ ms: String(searchResult.tookMs || 0),
4357
+ })));
4358
+ };
4359
+
4360
+ /** The hit snippet line shared by tiles and rows. */
4361
+ var hitSnippet = function (entry, className) {
4362
+ if (!entry || !entry.hit || !entry.snippet) return null;
4363
+ return h("span", { className: className, title: entry.snippet },
4364
+ h("b", { className: "dfx-hit-line" }, ":" + String(entry.hit.line || 0)),
4365
+ highlightMatch(entry.snippet, query));
4366
+ };
4367
+
4368
+ var entries = searchResult ? searchEntries() : rows;
3576
4369
  var body = null;
3577
4370
  if (status === "error") {
3578
4371
  body = h("div", { className: "dfx-notice dfx-notice--error" }, tf("读取失败:{reason}", { reason: error || t("未知错误") }));
3579
4372
  } else if (status === "loading" && !listing) {
3580
4373
  body = h("div", { className: "dfx-empty" }, t("正在加载…"));
3581
- } else if (rows.length === 0) {
3582
- body = h("div", { className: "dfx-empty" }, query ? t("没有匹配的条目") : t("此目录为空"));
4374
+ } else if (searchResult && searchResult.error) {
4375
+ body = h("div", { className: "dfx-notice dfx-notice--error" }, String(searchResult.error));
4376
+ } else if (searchResult && searchBusy && entries.length === 0) {
4377
+ body = h("div", { className: "dfx-empty" }, t("正在搜索…"));
4378
+ } else if (entries.length === 0) {
4379
+ body = searchResult
4380
+ ? h("div", { className: "dfx-search-empty" },
4381
+ h("span", { className: "dfx-search-empty-icon" }, glyph("search", 22)),
4382
+ h("span", { className: "dfx-search-empty-title" }, tf("没有找到“{q}”", { q: query.trim() })),
4383
+ h("span", { className: "dfx-search-empty-hint" }, t("换个关键词,或打开递归 / 内容搜索再试")))
4384
+ : h("div", { className: "dfx-empty" }, query ? t("没有匹配的条目") : t("此目录为空"));
3583
4385
  } else if (view === "icons") {
3584
- body = rows.map(function (entry) {
4386
+ body = entries.map(function (entry) {
3585
4387
  return h("div", {
3586
- key: entry.path,
3587
- className: "dfx-tile" + (selectedPaths.indexOf(entry.path) !== -1 ? " dfx-tile--sel" : ""),
4388
+ key: entry.path + (entry.hit ? ":" + String(entry.hit.line) : ""),
4389
+ "data-entry-path": entry.path,
4390
+ "data-entry-dir": entry.dir ? "1" : "",
4391
+ className: "dfx-tile" + (selectedPaths.indexOf(entry.path) !== -1 ? " dfx-tile--sel" : "") + (dropTarget === entry.path ? " dfx-drop-target" : ""),
3588
4392
  title: gitTitle(entry) || entry.name,
3589
4393
  draggable: true,
3590
4394
  onDragStart: function (event) { startDrag(event, entry); },
3591
- onClick: function (event) { applyClick(entry, event); },
3592
- onDoubleClick: function () { openEntry(entry); },
3593
- onContextMenu: function (event) { openRowMenu(event, entry); },
4395
+ onClick: function (event) { if (entry.hit) { selectSearchHit(entry); return; } applyClick(entry, event); },
4396
+ onDoubleClick: function (event) { if (entry.hit) { openSearchHit(entry.hit); return; } openEntry(entry, event); },
4397
+ onContextMenu: function (event) { if (entry.hit) { event.preventDefault(); return; } openRowMenu(event, entry); },
3594
4398
  },
3595
4399
  h("span", { className: "dfx-tile-icon" + (entry.dir ? " dfx-tile-icon--folder" : "") }, glyph(entryShape(entry), 44)),
3596
4400
  h("span", {
3597
4401
  className: "dfx-tile-name" + (entry.hidden ? " dfx-name-text--dim" : ""),
3598
4402
  title: entry.name,
3599
- }, clampLabel(entry.name, 30), gitBadge(entry)));
4403
+ }, entry.hit ? highlightMatch(clampLabel(entry.name, 30), query) : clampLabel(entry.name, 30), gitBadge(entry)),
4404
+ entry.hit ? h("span", { className: "dfx-tile-line", title: ":" + String(entry.hit.line || 0) }, ":" + String(entry.hit.line || 0)) : null);
3600
4405
  });
3601
4406
  } else if (view === "grouped") {
3602
4407
  var groups = [];
3603
4408
  var byKind = {};
3604
- rows.forEach(function (entry) {
4409
+ entries.forEach(function (entry) {
3605
4410
  var key = entry.dir ? "folder" : entry.kind || "other";
3606
4411
  if (!byKind[key]) {
3607
4412
  byKind[key] = { kind: key, dir: !!entry.dir, entries: [], total: 0 };
@@ -3646,40 +4451,48 @@ window.__ModuleLoader__.load({
3646
4451
  h("div", { className: "dfx-group-body" },
3647
4452
  group.entries.map(function (entry) {
3648
4453
  return h("div", {
3649
- key: entry.path,
3650
- className: "dfx-row dfx-row--grouped" + (selectedPaths.indexOf(entry.path) !== -1 ? " dfx-row--sel" : ""),
4454
+ key: entry.path + (entry.hit ? ":" + String(entry.hit.line) : ""),
4455
+ "data-entry-path": entry.path,
4456
+ "data-entry-dir": entry.dir ? "1" : "",
4457
+ className: "dfx-row dfx-row--grouped" + (entry.hit ? " dfx-row--hit" : "") + (selectedPaths.indexOf(entry.path) !== -1 ? " dfx-row--sel" : "") + (dropTarget === entry.path ? " dfx-drop-target" : ""),
3651
4458
  title: gitTitle(entry) || entry.name,
3652
4459
  draggable: true,
3653
4460
  onDragStart: function (event) { startDrag(event, entry); },
3654
- onClick: function (event) { applyClick(entry, event); },
3655
- onDoubleClick: function () { openEntry(entry); },
3656
- onContextMenu: function (event) { openRowMenu(event, entry); },
4461
+ onClick: function (event) { if (entry.hit) { selectSearchHit(entry); return; } applyClick(entry, event); },
4462
+ onDoubleClick: function (event) { if (entry.hit) { openSearchHit(entry.hit); return; } openEntry(entry, event); },
4463
+ onContextMenu: function (event) { if (entry.hit) { event.preventDefault(); return; } openRowMenu(event, entry); },
3657
4464
  },
3658
4465
  h("div", { className: "dfx-name" },
3659
4466
  h("span", { className: "dfx-name-icon" + (entry.dir ? " dfx-name-icon--folder" : "") }, glyph(entryShape(entry), 16)),
3660
- h("span", { className: "dfx-name-text" + (entry.hidden ? " dfx-name-text--dim" : ""), title: entry.name }, entry.name, gitBadge(entry))),
4467
+ h("span", { className: "dfx-name-text" + (entry.hidden ? " dfx-name-text--dim" : ""), title: entry.name },
4468
+ entry.hit ? highlightMatch(entry.name, query) : entry.name, gitBadge(entry))),
3661
4469
  h("div", { className: "dfx-cell" }, entry.dir ? "" : formatSize(entry.size)),
3662
- h("div", { className: "dfx-cell" }, formatDate(entry.mtime)));
4470
+ h("div", { className: "dfx-cell" }, formatDate(entry.mtime)),
4471
+ hitSnippet(entry, "dfx-row-sub dfx-row-sub--full"));
3663
4472
  })));
3664
4473
  }));
3665
4474
  } else {
3666
- body = rows.map(function (entry) {
4475
+ body = entries.map(function (entry) {
3667
4476
  return h("div", {
3668
- key: entry.path,
3669
- className: "dfx-row" + (selectedPaths.indexOf(entry.path) !== -1 ? " dfx-row--sel" : ""),
4477
+ key: entry.path + (entry.hit ? ":" + String(entry.hit.line) : ""),
4478
+ "data-entry-path": entry.path,
4479
+ "data-entry-dir": entry.dir ? "1" : "",
4480
+ className: "dfx-row" + (entry.hit ? " dfx-row--hit" : "") + (selectedPaths.indexOf(entry.path) !== -1 ? " dfx-row--sel" : "") + (dropTarget === entry.path ? " dfx-drop-target" : ""),
3670
4481
  title: gitTitle(entry) || entry.name,
3671
4482
  draggable: true,
3672
4483
  onDragStart: function (event) { startDrag(event, entry); },
3673
- onClick: function (event) { applyClick(entry, event); },
3674
- onDoubleClick: function () { openEntry(entry); },
3675
- onContextMenu: function (event) { openRowMenu(event, entry); },
4484
+ onClick: function (event) { if (entry.hit) { selectSearchHit(entry); return; } applyClick(entry, event); },
4485
+ onDoubleClick: function (event) { if (entry.hit) { openSearchHit(entry.hit); return; } openEntry(entry, event); },
4486
+ onContextMenu: function (event) { if (entry.hit) { event.preventDefault(); return; } openRowMenu(event, entry); },
3676
4487
  },
3677
4488
  h("div", { className: "dfx-name" },
3678
4489
  h("span", { className: "dfx-name-icon" + (entry.dir ? " dfx-name-icon--folder" : "") }, glyph(entryShape(entry), 16)),
3679
- h("span", { className: "dfx-name-text" + (entry.hidden ? " dfx-name-text--dim" : ""), title: entry.name }, entry.name, gitBadge(entry))),
4490
+ h("span", { className: "dfx-name-text" + (entry.hidden ? " dfx-name-text--dim" : ""), title: entry.name },
4491
+ entry.hit ? highlightMatch(entry.name, query) : entry.name, gitBadge(entry))),
3680
4492
  h("div", { className: "dfx-cell" }, kindLabel(entry)),
3681
4493
  h("div", { className: "dfx-cell" }, entry.dir ? "" : formatSize(entry.size)),
3682
- h("div", { className: "dfx-cell" }, formatDate(entry.mtime)));
4494
+ h("div", { className: "dfx-cell" }, formatDate(entry.mtime)),
4495
+ hitSnippet(entry, "dfx-row-sub dfx-row-sub--full"));
3683
4496
  });
3684
4497
  }
3685
4498
 
@@ -3740,8 +4553,17 @@ window.__ModuleLoader__.load({
3740
4553
  setDragEntries(chosen);
3741
4554
  setDropHot(false);
3742
4555
  var mention = "@" + entry.path + (entry.dir ? "/" : "") + " ";
3743
- event.dataTransfer.effectAllowed = "copy";
4556
+ event.dataTransfer.effectAllowed = "copyMove";
3744
4557
  event.dataTransfer.setData("text/plain", mention);
4558
+ if (chosen.length === 1 && !chosen[0].dir) {
4559
+ // Chromium understands DownloadURL, so dropping outside the browser
4560
+ // (Finder, Explorer) saves the original bytes.
4561
+ try {
4562
+ var origin = typeof location !== "undefined" && location.origin ? location.origin : "";
4563
+ event.dataTransfer.setData("DownloadURL",
4564
+ "application/octet-stream:" + chosen[0].name + ":" + origin + API + "/raw?path=" + encodeURIComponent(chosen[0].path));
4565
+ } catch (ignored) { /* the drop is simply a copy of the path text */ }
4566
+ }
3745
4567
  event.dataTransfer.setData("application/x-dsh-file-explorer", JSON.stringify({
3746
4568
  path: entry.path,
3747
4569
  dir: !!entry.dir,
@@ -3763,7 +4585,8 @@ window.__ModuleLoader__.load({
3763
4585
  * @returns {void}
3764
4586
  */
3765
4587
  function startEditing(entry, payload) {
3766
- setEditor({ entry: entry, text: payload.text || "", mtime: payload.mtime, size: payload.size });
4588
+ setEditorConflict(null);
4589
+ setEditor({ entry: entry, text: payload.text || "", mtime: payload.mtime, size: payload.size, version: payload.version || null });
3767
4590
  }
3768
4591
 
3769
4592
  /**
@@ -3784,8 +4607,17 @@ window.__ModuleLoader__.load({
3784
4607
  if (!editor) return;
3785
4608
  var current = editor;
3786
4609
  var run = function () {
3787
- apiWrite(current.entry.path, current.text).then(function (result) {
3788
- if (!result.ok) { notify(t((result.body && result.body.message) || "保存失败"), "error"); return; }
4610
+ apiWrite(current.entry.path, current.text, overwrite ? null : current.version).then(function (result) {
4611
+ if (!result.ok) {
4612
+ var message = t((result.body && result.body.message) || "保存失败");
4613
+ if (!overwrite && String(message).indexOf("修改") !== -1) {
4614
+ setEditorConflict(message);
4615
+ return;
4616
+ }
4617
+ notify(message, "error");
4618
+ return;
4619
+ }
4620
+ setEditorConflict(null);
3789
4621
  notify(t("已保存"), "info");
3790
4622
  setEditor(null);
3791
4623
  openPreview(current.entry);
@@ -3793,21 +4625,10 @@ window.__ModuleLoader__.load({
3793
4625
  if (listingNow) load(listingNow.path, current.entry.path, "neutral");
3794
4626
  }, function () { notify(t("保存失败"), "error"); });
3795
4627
  };
3796
- if (overwrite) { run(); return; }
3797
- apiGet("/stat", { path: current.entry.path }).then(function (result) {
3798
- var info = result.body || {};
3799
- if (result.ok && (info.mtime !== current.mtime || info.size !== current.size)) {
3800
- setDialog({
3801
- kind: "confirm",
3802
- title: t("文件已被修改"),
3803
- message: t("这个文件在打开之后被外部修改了。仍要用当前内容覆盖吗?"),
3804
- confirmLabel: t("覆盖保存"),
3805
- onSubmit: function () { saveEditing(true); },
3806
- });
3807
- return;
3808
- }
3809
- run();
3810
- }, run);
4628
+ // The host holds the version guard: a stale write answers 409 and the
4629
+ // editor shows an inline "reload / overwrite" banner instead of a
4630
+ // second confirmation dialog.
4631
+ run();
3811
4632
  }
3812
4633
 
3813
4634
  /** The editor pane: textarea plus dirty marker and save controls. */
@@ -3815,6 +4636,13 @@ window.__ModuleLoader__.load({
3815
4636
  if (!editor) return null;
3816
4637
  var dirty = editor.text !== (preview && preview.body && preview.body.text !== undefined ? preview.body.text : editor.text);
3817
4638
  return h("div", { className: "dfx-editor" },
4639
+ editorConflict
4640
+ ? h("div", { className: "dfx-editor-conflict" },
4641
+ h("span", null, editorConflict),
4642
+ h("span", { style: { flex: "1 1 auto" } }),
4643
+ h("button", { type: "button", className: "dfx-pill", onClick: function () { setEditorConflict(null); cancelEditing(); if (preview && preview.entry) openPreview(preview.entry); } }, t("重新加载")),
4644
+ h("button", { type: "button", className: "dfx-pill dfx-pill--warn", onClick: function () { setEditorConflict(null); saveEditing(true); } }, t("覆盖保存")))
4645
+ : null,
3818
4646
  h("textarea", {
3819
4647
  value: editor.text,
3820
4648
  spellCheck: false,
@@ -3827,7 +4655,7 @@ window.__ModuleLoader__.load({
3827
4655
  },
3828
4656
  onChange: function (event) {
3829
4657
  var next = event.target.value;
3830
- setEditor(function (previous) { return previous ? { entry: previous.entry, text: next, mtime: previous.mtime, size: previous.size } : previous; });
4658
+ setEditor(function (previous) { return previous ? { entry: previous.entry, text: next, mtime: previous.mtime, size: previous.size, version: previous.version } : previous; });
3831
4659
  },
3832
4660
  }),
3833
4661
  h("div", { className: "dfx-editor-bar" },
@@ -3868,30 +4696,32 @@ window.__ModuleLoader__.load({
3868
4696
  /** Definition list rendered by the details pane. */
3869
4697
  var infoRows = function (data) {
3870
4698
  var rows = [
3871
- [t("名称"), data.name],
3872
- [t("类型"), kindLabel({ dir: data.dir, kind: data.kind })],
3873
- [t("大小"), data.dir ? (data.items === null ? "—" : tf("{n} 项", { n: data.items })) : formatSize(data.size)],
3874
- [t("位置"), data.parent],
3875
- [t("创建时间"), formatDate(data.birthtime)],
3876
- [t("修改时间"), formatDate(data.mtime)],
3877
- [t("权限"), data.mode + " · " + data.modeOctal],
4699
+ { key: t("名称"), value: data.name, icon: "infoName" },
4700
+ { key: t("类型"), value: kindLabel({ dir: data.dir, kind: data.kind }), icon: "tag" },
4701
+ { key: t("大小"), value: data.dir ? (data.items === null ? "—" : tf("{n} 项", { n: data.items })) : formatSize(data.size), icon: "infoSize" },
4702
+ { key: t("位置"), value: data.parent, icon: "infoPlace" },
4703
+ { key: t("创建时间"), value: formatDate(data.birthtime), icon: "infoBorn" },
4704
+ { key: t("修改时间"), value: formatDate(data.mtime), icon: "infoTime" },
4705
+ { key: t("权限"), value: data.mode + " · " + data.modeOctal, icon: "infoAcl" },
3878
4706
  ];
3879
- if (data.link) rows.push([t("符号链接"), t("是")]);
4707
+ if (data.link) rows.push({ key: t("符号链接"), value: t("是"), icon: "link" });
3880
4708
  return h("div", { className: "dfx-info" }, rows.map(function (row) {
3881
- return h("div", { key: row[0], className: "dfx-info-row" },
3882
- h("span", { className: "dfx-info-label" }, row[0]),
3883
- h("span", { className: "dfx-info-value" }, row[1]));
4709
+ return h("div", { key: row.key, className: "dfx-info-row" },
4710
+ h("span", { className: "dfx-info-label" }, glyph(row.icon, 13), h("span", null, row.key)),
4711
+ h("span", { className: "dfx-info-value" }, row.value));
3884
4712
  }));
3885
4713
  };
3886
4714
 
3887
4715
  /** Copy-path and reveal actions, identical in both panes. */
3888
4716
  var paneFooter = function (entry) {
3889
4717
  if (!entry) return null;
4718
+
3890
4719
  return h("div", { className: "dfx-preview-foot" },
3891
4720
  h("button", { type: "button", className: "dfx-pill", onClick: function () { copyText(entry.path, t("已复制路径")); } },
3892
4721
  glyph("copy", 12), t("复制路径")),
3893
4722
  remoteMode ? null : h("button", { type: "button", className: "dfx-pill", onClick: function () { revealPath(entry.path); } },
3894
- glyph("reveal", 12), t("在访达中显示")));
4723
+ glyph("reveal", 12), t("在访达中显示")),
4724
+ );
3895
4725
  };
3896
4726
 
3897
4727
  var selectionEntriesNow = selectionEntries();
@@ -3902,6 +4732,94 @@ window.__ModuleLoader__.load({
3902
4732
  }, 0);
3903
4733
  var sortName = sort === "size" ? t("大小") : sort === "mtime" ? t("修改时间") : t("名称");
3904
4734
 
4735
+ /** Fold one JSON branch in or out. */
4736
+ var toggleJson = function (path, open) {
4737
+ setJsonOpen(function (previous) {
4738
+ var next = Object.assign({}, previous);
4739
+ next[path] = open;
4740
+ return next;
4741
+ });
4742
+ };
4743
+
4744
+ /** Fold or unfold the branch that opens on one line. */
4745
+ var toggleFold = function (line, open) {
4746
+ setJsonOpen(function (previous) {
4747
+ var next = Object.assign({}, previous);
4748
+ next[line] = open;
4749
+ return next;
4750
+ });
4751
+ };
4752
+
4753
+ /** One parsed JSON document, pretty-printed with line numbers and folding. */
4754
+ var jsonPane = function (text) {
4755
+ var parsed = null;
4756
+ var failure = null;
4757
+ try {
4758
+ parsed = JSON.parse(String(text || "").trim() || "null");
4759
+ } catch (error) {
4760
+ failure = String((error && error.message) || error);
4761
+ }
4762
+ if (failure) {
4763
+ return h("div", { className: "dfx-json" },
4764
+ h("div", { className: "dfx-notice dfx-notice--warn" }, tf("不是合法的 JSON:{reason}", { reason: failure })),
4765
+ h("pre", { className: "dfx-pre" }, text));
4766
+ }
4767
+ var punct = function (value) { return { kind: "punct", text: value }; };
4768
+ var source = jsonSourceOf(parsed, 4000);
4769
+ var isFolded = function (line) { return jsonOpen[line] === false; };
4770
+ var rows = [];
4771
+ var skipTo = -1;
4772
+ source.lines.forEach(function (line, index) {
4773
+ if (index <= skipTo) return;
4774
+ var hasFold = line.end !== undefined;
4775
+ var folded = hasFold && isFolded(index);
4776
+ if (folded) skipTo = line.end;
4777
+ var tokens = folded ? line.tokens.concat([punct(" … "), punct(line.tail)]) : line.tokens;
4778
+ rows.push(h("div", {
4779
+ key: "l" + index,
4780
+ className: "dfx-json-line" + (folded ? " dfx-json-line--folded" : ""),
4781
+ },
4782
+ h("span", { className: "dfx-json-gutter" },
4783
+ hasFold
4784
+ ? h("button", {
4785
+ type: "button",
4786
+ className: "dfx-json-fold",
4787
+ "aria-label": folded ? t("展开") : t("折叠"),
4788
+ "aria-expanded": folded ? "false" : "true",
4789
+ onClick: function () { toggleFold(index, folded); },
4790
+ }, h("span", { className: "dfx-json-chevron" + (folded ? "" : " dfx-json-chevron--open") }))
4791
+ : h("span", { className: "dfx-json-fold dfx-json-fold--none" }),
4792
+ h("span", { className: "dfx-json-no" }, String(index + 1))),
4793
+ h("span", {
4794
+ className: "dfx-json-code",
4795
+ style: {
4796
+ paddingLeft: (line.depth * 18) + "px",
4797
+ backgroundSize: line.depth ? (line.depth * 18) + "px 100%" : "0 0",
4798
+ },
4799
+ }, tokens.map(function (token, tokenIndex) {
4800
+ return h("span", { key: "t" + tokenIndex, className: "dfx-json-" + token.kind, title: token.full }, token.text);
4801
+ }))));
4802
+ });
4803
+ return h("div", { className: "dfx-json" },
4804
+ h("div", { className: "dfx-json-tools" },
4805
+ h("button", { type: "button", className: "dfx-json-tool", onClick: function () { copyText(text, t("已复制 JSON")); } }, t("复制")),
4806
+ h("button", { type: "button", className: "dfx-json-tool", onClick: function () { setJsonOpen({}); } }, t("展开全部")),
4807
+ h("button", {
4808
+ type: "button",
4809
+ className: "dfx-json-tool",
4810
+ onClick: function () {
4811
+ var next = {};
4812
+ source.folds.forEach(function (line) { next[line] = false; });
4813
+ setJsonOpen(next);
4814
+ },
4815
+ }, t("折叠全部"))),
4816
+ h("div", { className: "dfx-json-body" }, rows),
4817
+ source.truncated
4818
+ ? h("div", { className: "dfx-json-note" }, tf("只显示前 {n} 行,其余未展开。", { n: String(source.lines.length) }))
4819
+ : null);
4820
+ };
4821
+
4822
+ previewPathRef.current = preview && preview.entry && !preview.entry.dir ? preview.entry.path : null;
3905
4823
  var showInfoPane = paneVisible && !!selected && (selected.dir || paneMode === "info");
3906
4824
  var previewPane = null;
3907
4825
  if (!paneVisible) {
@@ -3933,8 +4851,8 @@ window.__ModuleLoader__.load({
3933
4851
  // Binary files also land in the "text" fallback; never let the editor
3934
4852
  // write them back, it would corrupt the bytes it cannot round-trip.
3935
4853
  var BINARY_NAME = /\.(zip|gz|tgz|tar|bz2|xz|7z|rar|dmg|pkg|exe|bin|iso|class|jar|woff2?|ttf|otf|eot|ico|icns|mp[34]|m4a|wav|flac|ogg|mov|avi|mkv|psd|ai|sketch|sqlite|db)$/i;
3936
- var canEdit = (renderAs === "text" || renderAs === "markdown" || renderAs === "csv") && !BINARY_NAME.test(preview.entry.name);
3937
- var textKind = renderAs === "text" || renderAs === "markdown" || renderAs === "csv";
4854
+ var canEdit = (renderAs === "text" || renderAs === "markdown" || renderAs === "csv" || renderAs === "json") && !BINARY_NAME.test(preview.entry.name);
4855
+ var textKind = renderAs === "text" || renderAs === "markdown" || renderAs === "csv" || renderAs === "json";
3938
4856
  var lineCount = textKind ? lineCountOf(payload.text) : 0;
3939
4857
  var metaFacts = [{ text: formatSize(payload.size) }];
3940
4858
  if (lineCount) metaFacts.push({ text: tf("{n} 行", { n: String(lineCount) }) });
@@ -3951,6 +4869,29 @@ window.__ModuleLoader__.load({
3951
4869
  }, fact.text),
3952
4870
  ];
3953
4871
  }),
4872
+ previewStale
4873
+ ? h("button", {
4874
+ type: "button",
4875
+ className: "dfx-pill dfx-pill--warn",
4876
+ title: t("文件在打开后被修改,重新加载后继续编辑"),
4877
+ onClick: function () { openPreview(preview.entry); },
4878
+ }, t("已变更 · 重新加载"))
4879
+ : null,
4880
+ renderAs === "json"
4881
+ ? h("div", { className: "dfx-seg", role: "group", "aria-label": t("JSON 视图") },
4882
+ h("button", {
4883
+ type: "button",
4884
+ className: "dfx-seg-btn" + (jsonRaw ? "" : " dfx-seg-btn--on"),
4885
+ "aria-pressed": jsonRaw ? "false" : "true",
4886
+ onClick: function () { setJsonRaw(false); },
4887
+ }, t("格式化")),
4888
+ h("button", {
4889
+ type: "button",
4890
+ className: "dfx-seg-btn" + (jsonRaw ? " dfx-seg-btn--on" : ""),
4891
+ "aria-pressed": jsonRaw ? "true" : "false",
4892
+ onClick: function () { setJsonRaw(true); },
4893
+ }, t("源码")))
4894
+ : null,
3954
4895
  canEdit && !(editor && editor.entry.path === preview.entry.path)
3955
4896
  ? h("button", {
3956
4897
  type: "button",
@@ -3964,7 +4905,9 @@ window.__ModuleLoader__.load({
3964
4905
  } else if (renderAs === "text") {
3965
4906
  inner = h("pre", { className: "dfx-pre" }, payload.text);
3966
4907
  } else if (renderAs === "markdown") {
3967
- inner = h("div", { className: "dfx-md" }, renderMarkdown(payload.text, h));
4908
+ inner = h("div", { className: "dfx-md" }, renderMarkdown(payload.text, h, parentOf(preview.entry.path)));
4909
+ } else if (renderAs === "json") {
4910
+ inner = jsonRaw ? h("pre", { className: "dfx-pre" }, payload.text) : jsonPane(payload.text);
3968
4911
  } else if (renderAs === "csv") {
3969
4912
  var tableRows = parseDelimited(payload.text, preview.entry.name.slice(-4).toLowerCase() === ".tsv" ? "\t" : ",");
3970
4913
  inner = tableRows.length === 0
@@ -4037,8 +4980,7 @@ window.__ModuleLoader__.load({
4037
4980
  inner = h("audio", { className: "dfx-media", controls: true, src: rawUrl }, null);
4038
4981
  } else if (renderAs === "video") {
4039
4982
  inner = h("video", { className: "dfx-media", controls: true, src: rawUrl }, null);
4040
- } else if (renderAs === "html") {
4041
- inner = h("iframe", { className: "dfx-html", src: rawUrl, sandbox: "", title: preview.entry.name });
4983
+
4042
4984
  } else if (payload.kind === "too-large") {
4043
4985
  inner = h("div", { className: "dfx-empty" }, t("文件过大,未生成预览"));
4044
4986
  } else {
@@ -4170,6 +5112,40 @@ window.__ModuleLoader__.load({
4170
5112
  }
4171
5113
  }
4172
5114
 
5115
+ var quickLookNode = quickLook
5116
+ ? h("div", {
5117
+ className: "dfx-quick-backdrop",
5118
+ role: "presentation",
5119
+ onClick: function (event) { if (event.target === event.currentTarget) setQuickLook(null); },
5120
+ },
5121
+ h("div", {
5122
+ className: "dfx-quick",
5123
+ role: "dialog",
5124
+ "aria-modal": "true",
5125
+ "aria-label": quickLook.name,
5126
+ ref: quickRef,
5127
+ tabIndex: -1,
5128
+ onKeyDown: function (event) {
5129
+ if (event.key !== "Escape" && event.code !== "Escape" && event.key !== " " && event.code !== "Space") return;
5130
+ event.preventDefault();
5131
+ event.stopPropagation();
5132
+ setQuickLook(null);
5133
+ },
5134
+ },
5135
+ h("div", { className: "dfx-quick-head" },
5136
+ h("span", { className: "dfx-name-icon" }, glyph(entryShape(quickLook), 16)),
5137
+ h("span", { className: "dfx-quick-title" }, quickLook.name),
5138
+ h("span", { className: "dfx-quick-size" }, formatSize(quickLook.size || 0)),
5139
+ h("button", {
5140
+ type: "button",
5141
+ className: "dfx-tool",
5142
+ title: t("关闭"),
5143
+ "aria-label": t("关闭"),
5144
+ onClick: function () { setQuickLook(null); },
5145
+ }, glyph("close", 14))),
5146
+ h("div", { className: "dfx-quick-body" }, quickLookBody())))
5147
+ : null;
5148
+
4173
5149
  var dropStrip = dragEntries && dragEntries.length > 0
4174
5150
  ? h("div", {
4175
5151
  className: "dfx-dropzone" + (dropHot ? " dfx-dropzone--hot" : ""),
@@ -4199,7 +5175,26 @@ window.__ModuleLoader__.load({
4199
5175
  h("span", { className: "dfx-dropzone-hint" }, t("文件作为附件,文件夹作为引用")))
4200
5176
  : null;
4201
5177
 
4202
- return h("div", { className: "dfx-root", ref: rootRef, onDragEnd: endDrag },
5178
+ return h("div", {
5179
+ className: "dfx-root",
5180
+ ref: rootRef,
5181
+ onDragEnd: endDrag,
5182
+ onDragOver: function (event) {
5183
+ if (dragEntries || !event || !event.dataTransfer || !event.dataTransfer.types) return;
5184
+ var types = event.dataTransfer.types;
5185
+ var files = Array.prototype.indexOf.call(types, "Files") !== -1;
5186
+ if (!files) return;
5187
+ event.preventDefault();
5188
+ event.dataTransfer.dropEffect = "copy";
5189
+ },
5190
+ onDrop: function (event) {
5191
+ if (dragEntries || !event || !event.dataTransfer) return;
5192
+ var dropped = event.dataTransfer.files;
5193
+ if (!dropped || dropped.length === 0) return;
5194
+ event.preventDefault();
5195
+ uploadFiles(dropped);
5196
+ },
5197
+ },
4203
5198
  h("div", { className: "dfx-bar" },
4204
5199
  h("div", { className: "dfx-bar-actions" },
4205
5200
  h("button", {
@@ -4251,15 +5246,33 @@ window.__ModuleLoader__.load({
4251
5246
  },
4252
5247
  onBlur: function () { setAddressDraft(null); },
4253
5248
  })),
4254
- h("label", { className: "dfx-search" },
5249
+ h("div", { className: "dfx-search" },
4255
5250
  glyph("search", 13),
4256
5251
  h("input", {
4257
5252
  ref: searchRef,
4258
5253
  type: "search",
4259
5254
  value: query,
4260
- placeholder: t("筛选当前目录"),
5255
+ placeholder: searchMode === "content" ? t("搜索文件内容") : searchDeep ? t("搜索子文件夹") : t("筛选当前目录"),
4261
5256
  onChange: function (event) { setQuery(event.target.value); },
4262
- }))),
5257
+ }),
5258
+ h("button", {
5259
+ type: "button",
5260
+ className: "dfx-search-mode dfx-tip dfx-tip--right" + (searchDeep ? " dfx-search-mode--on" : ""),
5261
+ title: t("在子文件夹中搜索"),
5262
+ "data-tip": t("在子文件夹中搜索"),
5263
+ "aria-label": t("在子文件夹中搜索"),
5264
+ "aria-pressed": searchDeep ? "true" : "false",
5265
+ onClick: function () { setSearchDeep(!searchDeep); },
5266
+ }, glyph("folderNested", 13)),
5267
+ h("button", {
5268
+ type: "button",
5269
+ className: "dfx-search-mode dfx-tip dfx-tip--right" + (searchMode === "content" ? " dfx-search-mode--on" : ""),
5270
+ title: t("搜索文件内容"),
5271
+ "data-tip": t("搜索文件内容"),
5272
+ "aria-label": t("搜索文件内容"),
5273
+ "aria-pressed": searchMode === "content" ? "true" : "false",
5274
+ onClick: function () { setSearchMode(searchMode === "content" ? "name" : "content"); },
5275
+ }, glyph("text", 13)))),
4263
5276
  h("div", { className: "dfx-toolbar", role: "toolbar", "aria-label": t("文件操作") },
4264
5277
  workspacesRef.current
4265
5278
  ? h("button", {
@@ -4371,6 +5384,7 @@ window.__ModuleLoader__.load({
4371
5384
  }, glyph("pane", 16)))),
4372
5385
  h("div", { className: "dfx-body" },
4373
5386
  h("div", { className: "dfx-listpane" + (resizing ? " dfx-listpane--resizing" : ""), style: columnStyle },
5387
+ searchSummary(),
4374
5388
  view === "icons" || view === "grouped" ? null : h("div", {
4375
5389
  key: "head-" + navMotion.seq,
4376
5390
  className: "dfx-head" + motionClass("dfx-head"),
@@ -4393,15 +5407,45 @@ window.__ModuleLoader__.load({
4393
5407
  : null,
4394
5408
  h("div", {
4395
5409
  key: "rows-" + navMotion.seq,
4396
- className: "dfx-rows" + (view === "icons" ? " dfx-rows--grid" : "") + motionClass("dfx-rows"),
5410
+ className: "dfx-rows"
5411
+ + (view === "icons" && entries.length > 0 && status !== "error" ? " dfx-rows--grid" : "")
5412
+ + (view === "icons" && (entries.length === 0 || status === "error") ? " dfx-rows--flat" : "")
5413
+ + motionClass("dfx-rows"),
4397
5414
  ref: rowsRef,
4398
5415
  tabIndex: 0,
4399
5416
  onKeyDown: onKeyDown,
4400
5417
  onContextMenu: openAreaMenu,
4401
5418
  onScroll: function () { if (menu) setMenu(null); },
5419
+ onDragOver: function (event) {
5420
+ if (!dragEntries || dragEntries.length === 0 || !event || !event.dataTransfer) return;
5421
+ var row = event.target && event.target.closest ? event.target.closest("[data-entry-path]") : null;
5422
+ var target = row && row.getAttribute("data-entry-dir") === "1" ? row.getAttribute("data-entry-path") : (listing ? listing.path : null);
5423
+ if (!target) return;
5424
+ var blocked = dragEntries.some(function (item) { return item.path === target || target.indexOf(item.path + "/") === 0; });
5425
+ if (blocked) return;
5426
+ event.preventDefault();
5427
+ event.dataTransfer.dropEffect = "move";
5428
+ setDropTarget(target);
5429
+ },
5430
+ onDragLeave: function (event) {
5431
+ if (event && event.target === event.currentTarget) setDropTarget(null);
5432
+ },
5433
+ onDrop: function (event) {
5434
+ if (!dragEntries || dragEntries.length === 0 || !event) return;
5435
+ var row = event.target && event.target.closest ? event.target.closest("[data-entry-path]") : null;
5436
+ var target = row && row.getAttribute("data-entry-dir") === "1" ? row.getAttribute("data-entry-path") : (listing ? listing.path : null);
5437
+ if (!target) return;
5438
+ event.preventDefault();
5439
+ event.stopPropagation();
5440
+ var rows = dragEntries;
5441
+ setDropTarget(null);
5442
+ endDrag();
5443
+ moveInto(target, rows);
5444
+ },
4402
5445
  }, body)),
4403
5446
  previewPane),
4404
5447
  dropStrip,
5448
+ quickLookNode,
4405
5449
  h("div", { className: "dfx-foot" },
4406
5450
  h("span", null, tf("{n} 项", { n: rows.length })),
4407
5451
  listing && listing.truncated ? h(Fragment, null,