@kubohiroya/turbowarp-plus-editor-project-folder 0.19.1 → 0.20.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/README.ja.md +0 -2
- package/dist/browser-projects.d.ts +8 -2
- package/dist/explorer.js +1 -1
- package/dist/index.js +102 -9
- package/dist/{shared-CeJrx6Ve.js → shared-DkIVN2xk.js} +0 -18
- package/package.json +1 -1
- package/src/browser-project-dialog.ts +3 -1
- package/src/browser-projects.ts +55 -2
- package/src/text-file-editor.ts +1 -22
package/README.ja.md
CHANGED
|
@@ -113,8 +113,6 @@ TurboWarp Plus Editor は、ブロックパレットの設定を画面状態(`
|
|
|
113
113
|
|
|
114
114
|
この OPFS 対応は、ローカル連携の URL から開いた Editor の保存領域が対象です。通常の配信サイトとローカル連携では OPFS の保存領域が異なるため、配信サイトで既に作業している OPFS を直接共有しません。通常の配信サイトを開いたまま外部編集するための別オリジン接続は、この実装には含みません。
|
|
115
115
|
|
|
116
|
-
通常表示で内容の高さが表示領域より小さいときは、スクロール領域の上に操作ボタンの高さに合わせた空欄を設け、先頭行がボタンに隠れないようにします。内容の編集、画面サイズの変更、タブの再表示に応じて再計算します。差分表示にも、操作ボタンが差分や表示範囲の切り替えに重ならない空欄を設けています。
|
|
117
|
-
|
|
118
116
|
編集画面の右下には、ファイル全体と現在の表示範囲を示すミニマップを表示します。クリック・ドラッグで移動でき、ミニマップにフォーカスすると矢印・Page Up/Page Down・Home/End キーでもスクロールできます。編集、スクロール、パネルのサイズ変更、タブの再表示に追従します。差分表示では編集用のミニマップを隠します。
|
|
119
117
|
|
|
120
118
|
切り戻す場合はこの UI 変更を revert し、パッケージと Editor を再ビルドします。ファイル形式の変更やデータ移行はありません。対象のヘッドレス検証は `node --test test/text-file.browser.js` で実行します。
|
|
@@ -11,8 +11,8 @@ export interface BrowserProject {
|
|
|
11
11
|
id: string;
|
|
12
12
|
title: string;
|
|
13
13
|
/**
|
|
14
|
-
* A folder inside the stored folder, `''` for the stored folder itself. Only for
|
|
15
|
-
* project at the root of the stored folder,
|
|
14
|
+
* A folder inside the stored folder, `''` for the stored folder itself. Only for entries kept by an earlier version:
|
|
15
|
+
* the Editor opens the project at the root of the stored folder, and `moveProjectToRoot` moves such a project there.
|
|
16
16
|
*/
|
|
17
17
|
projectPath: string;
|
|
18
18
|
createdAt: number;
|
|
@@ -35,6 +35,12 @@ export interface BrowserProjects {
|
|
|
35
35
|
root(id: string): Promise<FileSystemDirectoryHandle | null>;
|
|
36
36
|
/** The folder `projectPath` inside the entry's stored folder. Opening uses `root` instead. */
|
|
37
37
|
directory(id: string): Promise<FileSystemDirectoryHandle | null>;
|
|
38
|
+
/**
|
|
39
|
+
* Moves the project of an entry kept by an earlier version, in the folder `projectPath`, to the root of the stored
|
|
40
|
+
* folder, where the Editor opens it, and records that. Nothing moves when a name in that folder is already taken
|
|
41
|
+
* at the root. Resolves with whether the project is at the root.
|
|
42
|
+
*/
|
|
43
|
+
moveProjectToRoot(id: string): Promise<boolean>;
|
|
38
44
|
/** The entry that holds `handle`, or `null` when it is not in the browser's storage. */
|
|
39
45
|
find(handle: FileSystemHandle): Promise<BrowserProject | null>;
|
|
40
46
|
touch(id: string): Promise<void>;
|
package/dist/explorer.js
CHANGED
|
@@ -1463,7 +1463,7 @@ function createFilePreview(directory, documentId, { name, path }, locale, readBa
|
|
|
1463
1463
|
status.textContent = message.large;
|
|
1464
1464
|
return;
|
|
1465
1465
|
}
|
|
1466
|
-
const [bytes, { decodeText, mountTextFile }] = await Promise.all([file.arrayBuffer(), import("./shared-
|
|
1466
|
+
const [bytes, { decodeText, mountTextFile }] = await Promise.all([file.arrayBuffer(), import("./shared-DkIVN2xk.js")]);
|
|
1467
1467
|
if (disposed) return;
|
|
1468
1468
|
const content = decodeText(bytes);
|
|
1469
1469
|
if (content === null) {
|
package/dist/index.js
CHANGED
|
@@ -1041,6 +1041,40 @@ async function writeText(directory, name, text) {
|
|
|
1041
1041
|
throw error;
|
|
1042
1042
|
}
|
|
1043
1043
|
}
|
|
1044
|
+
var manifestFiles = ["project.source.json", "sb3-source.json"];
|
|
1045
|
+
async function copyEntry(entry, target) {
|
|
1046
|
+
if (entry.kind === "file") {
|
|
1047
|
+
const file = await entry.getFile();
|
|
1048
|
+
const writable = await (await target.getFileHandle(entry.name, { create: true })).createWritable();
|
|
1049
|
+
try {
|
|
1050
|
+
await writable.write(file);
|
|
1051
|
+
await writable.close();
|
|
1052
|
+
} catch (error) {
|
|
1053
|
+
await writable.abort().catch(() => {});
|
|
1054
|
+
throw error;
|
|
1055
|
+
}
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1058
|
+
const directory = await target.getDirectoryHandle(entry.name, { create: true });
|
|
1059
|
+
var _iteratorAbruptCompletion = false;
|
|
1060
|
+
var _didIteratorError = false;
|
|
1061
|
+
var _iteratorError;
|
|
1062
|
+
try {
|
|
1063
|
+
for (var _iterator = _asyncIterator(entry.values()), _step; _iteratorAbruptCompletion = !(_step = await _iterator.next()).done; _iteratorAbruptCompletion = false) {
|
|
1064
|
+
const child = _step.value;
|
|
1065
|
+
await copyEntry(child, directory);
|
|
1066
|
+
}
|
|
1067
|
+
} catch (err) {
|
|
1068
|
+
_didIteratorError = true;
|
|
1069
|
+
_iteratorError = err;
|
|
1070
|
+
} finally {
|
|
1071
|
+
try {
|
|
1072
|
+
if (_iteratorAbruptCompletion && _iterator.return != null) await _iterator.return();
|
|
1073
|
+
} finally {
|
|
1074
|
+
if (_didIteratorError) throw _iteratorError;
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1044
1078
|
async function resolvePath(root, path) {
|
|
1045
1079
|
let directory = root;
|
|
1046
1080
|
for (const part of path ? path.split("/") : []) directory = await directory.getDirectoryHandle(part);
|
|
@@ -1101,12 +1135,12 @@ function openBrowserProjects(view) {
|
|
|
1101
1135
|
async list() {
|
|
1102
1136
|
const { info } = await folders();
|
|
1103
1137
|
const found = [];
|
|
1104
|
-
var
|
|
1105
|
-
var
|
|
1106
|
-
var
|
|
1138
|
+
var _iteratorAbruptCompletion2 = false;
|
|
1139
|
+
var _didIteratorError2 = false;
|
|
1140
|
+
var _iteratorError2;
|
|
1107
1141
|
try {
|
|
1108
|
-
for (var
|
|
1109
|
-
const entry =
|
|
1142
|
+
for (var _iterator2 = _asyncIterator(info.values()), _step2; _iteratorAbruptCompletion2 = !(_step2 = await _iterator2.next()).done; _iteratorAbruptCompletion2 = false) {
|
|
1143
|
+
const entry = _step2.value;
|
|
1110
1144
|
{
|
|
1111
1145
|
const id = entry.kind === "file" && entry.name.endsWith(".json") ? entry.name.slice(0, -5) : "";
|
|
1112
1146
|
if (!idPattern.test(id)) continue;
|
|
@@ -1115,13 +1149,13 @@ function openBrowserProjects(view) {
|
|
|
1115
1149
|
}
|
|
1116
1150
|
}
|
|
1117
1151
|
} catch (err) {
|
|
1118
|
-
|
|
1119
|
-
|
|
1152
|
+
_didIteratorError2 = true;
|
|
1153
|
+
_iteratorError2 = err;
|
|
1120
1154
|
} finally {
|
|
1121
1155
|
try {
|
|
1122
|
-
if (
|
|
1156
|
+
if (_iteratorAbruptCompletion2 && _iterator2.return != null) await _iterator2.return();
|
|
1123
1157
|
} finally {
|
|
1124
|
-
if (
|
|
1158
|
+
if (_didIteratorError2) throw _iteratorError2;
|
|
1125
1159
|
}
|
|
1126
1160
|
}
|
|
1127
1161
|
return found.sort((a, b) => b.updatedAt - a.updatedAt || a.title.localeCompare(b.title));
|
|
@@ -1159,6 +1193,64 @@ function openBrowserProjects(view) {
|
|
|
1159
1193
|
throw error;
|
|
1160
1194
|
}
|
|
1161
1195
|
},
|
|
1196
|
+
moveProjectToRoot: (id) => exclusive(id, async () => {
|
|
1197
|
+
const project = await readInfo(id);
|
|
1198
|
+
const top = project && await root(id);
|
|
1199
|
+
if (!project || !top) return false;
|
|
1200
|
+
if (!project.projectPath) return true;
|
|
1201
|
+
const parts = project.projectPath.split("/");
|
|
1202
|
+
let source;
|
|
1203
|
+
try {
|
|
1204
|
+
source = await resolvePath(top, project.projectPath);
|
|
1205
|
+
} catch (error) {
|
|
1206
|
+
if (missing(error)) return false;
|
|
1207
|
+
throw error;
|
|
1208
|
+
}
|
|
1209
|
+
const taken = /* @__PURE__ */ new Set();
|
|
1210
|
+
var _iteratorAbruptCompletion3 = false;
|
|
1211
|
+
var _didIteratorError3 = false;
|
|
1212
|
+
var _iteratorError3;
|
|
1213
|
+
try {
|
|
1214
|
+
for (var _iterator3 = _asyncIterator(top.values()), _step3; _iteratorAbruptCompletion3 = !(_step3 = await _iterator3.next()).done; _iteratorAbruptCompletion3 = false) {
|
|
1215
|
+
const entry = _step3.value;
|
|
1216
|
+
taken.add(entry.name);
|
|
1217
|
+
}
|
|
1218
|
+
} catch (err) {
|
|
1219
|
+
_didIteratorError3 = true;
|
|
1220
|
+
_iteratorError3 = err;
|
|
1221
|
+
} finally {
|
|
1222
|
+
try {
|
|
1223
|
+
if (_iteratorAbruptCompletion3 && _iterator3.return != null) await _iterator3.return();
|
|
1224
|
+
} finally {
|
|
1225
|
+
if (_didIteratorError3) throw _iteratorError3;
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
const entries = [];
|
|
1229
|
+
var _iteratorAbruptCompletion4 = false;
|
|
1230
|
+
var _didIteratorError4 = false;
|
|
1231
|
+
var _iteratorError4;
|
|
1232
|
+
try {
|
|
1233
|
+
for (var _iterator4 = _asyncIterator(source.values()), _step4; _iteratorAbruptCompletion4 = !(_step4 = await _iterator4.next()).done; _iteratorAbruptCompletion4 = false) {
|
|
1234
|
+
const entry = _step4.value;
|
|
1235
|
+
entries.push(entry);
|
|
1236
|
+
}
|
|
1237
|
+
} catch (err) {
|
|
1238
|
+
_didIteratorError4 = true;
|
|
1239
|
+
_iteratorError4 = err;
|
|
1240
|
+
} finally {
|
|
1241
|
+
try {
|
|
1242
|
+
if (_iteratorAbruptCompletion4 && _iterator4.return != null) await _iterator4.return();
|
|
1243
|
+
} finally {
|
|
1244
|
+
if (_didIteratorError4) throw _iteratorError4;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
if (entries.some((entry) => taken.has(entry.name))) return false;
|
|
1248
|
+
entries.sort((a, b) => Number(manifestFiles.includes(a.name)) - Number(manifestFiles.includes(b.name)));
|
|
1249
|
+
for (const entry of entries) await copyEntry(entry, top);
|
|
1250
|
+
await (await resolvePath(top, parts.slice(0, -1).join("/"))).removeEntry(parts[parts.length - 1], { recursive: true });
|
|
1251
|
+
await writeInfo(_objectSpread2(_objectSpread2({}, project), {}, { projectPath: "" }));
|
|
1252
|
+
return true;
|
|
1253
|
+
}),
|
|
1162
1254
|
async find(handle) {
|
|
1163
1255
|
const path = await (await folders()).projects.resolve(handle).catch(() => null);
|
|
1164
1256
|
return (path === null || path === void 0 ? void 0 : path.length) && idPattern.test(path[0]) ? readInfo(path[0]) : null;
|
|
@@ -1613,6 +1705,7 @@ function chooseBrowserProject({ document, projects, locale = "en", purpose, titl
|
|
|
1613
1705
|
return element;
|
|
1614
1706
|
};
|
|
1615
1707
|
item.append(text, button(message.open, async () => {
|
|
1708
|
+
await projects.moveProjectToRoot(project.id);
|
|
1616
1709
|
const directory = await projects.root(project.id);
|
|
1617
1710
|
if (!directory) return render();
|
|
1618
1711
|
finish({
|
|
@@ -30016,7 +30016,6 @@ max-height:40%;overflow:auto;border-radius:.3rem;background:var(--ui-primary,#ff
|
|
|
30016
30016
|
box-sizing:border-box;max-width:calc(100% - 2rem);margin:0;padding:.65rem 1rem;border-radius:.35rem;
|
|
30017
30017
|
background:#323232;color:#fff;font-size:.9em;box-shadow:0 2px 8px rgba(0,0,0,.3);pointer-events:none}
|
|
30018
30018
|
.twpf-file-edit,.twpf-file-diff{flex:1;min-height:0}
|
|
30019
|
-
.twpf-file-edit.twpf-file-short{padding-top:var(--twpf-toolbar-height,3.25rem)}
|
|
30020
30019
|
.twpf-file-diff{padding-top:var(--twpf-toolbar-height,3.25rem)}
|
|
30021
30020
|
.twpf-file-edit>.cm-editor{height:100%}
|
|
30022
30021
|
.twpf-text-file .cm-scroller{overflow:auto}
|
|
@@ -30293,10 +30292,8 @@ function mountTextFile(parent, options) {
|
|
|
30293
30292
|
parent.append(shell);
|
|
30294
30293
|
const toolbarObserver = browser && new browser.ResizeObserver(() => {
|
|
30295
30294
|
panel.style.setProperty("--twpf-toolbar-height", `calc(${toolbar.getBoundingClientRect().height}px + 1rem)`);
|
|
30296
|
-
measureToolbarSpace();
|
|
30297
30295
|
});
|
|
30298
30296
|
toolbarObserver === null || toolbarObserver === void 0 || toolbarObserver.observe(toolbar);
|
|
30299
|
-
toolbarObserver === null || toolbarObserver === void 0 || toolbarObserver.observe(editPane);
|
|
30300
30297
|
const editing = new Compartment();
|
|
30301
30298
|
const view = new EditorView({
|
|
30302
30299
|
parent: editPane,
|
|
@@ -30314,23 +30311,9 @@ function mountTextFile(parent, options) {
|
|
|
30314
30311
|
keymap.of([...defaultKeymap, ...historyKeymap]),
|
|
30315
30312
|
EditorView.updateListener.of((update) => {
|
|
30316
30313
|
if (update.docChanged) updateSaveState(void 0, true);
|
|
30317
|
-
if (update.docChanged || update.geometryChanged) measureToolbarSpace();
|
|
30318
30314
|
})
|
|
30319
30315
|
]
|
|
30320
30316
|
});
|
|
30321
|
-
function measureToolbarSpace() {
|
|
30322
|
-
if (disposed || comparison) return;
|
|
30323
|
-
view.requestMeasure({
|
|
30324
|
-
key: editPane,
|
|
30325
|
-
read: (view) => {
|
|
30326
|
-
const available = editPane.clientHeight;
|
|
30327
|
-
return available ? view.contentHeight < available : null;
|
|
30328
|
-
},
|
|
30329
|
-
write: (short) => {
|
|
30330
|
-
if (!disposed && !comparison && short !== null) editPane.classList.toggle("twpf-file-short", short);
|
|
30331
|
-
}
|
|
30332
|
-
});
|
|
30333
|
-
}
|
|
30334
30317
|
const dirty = () => !view.state.doc.eq(savedDoc);
|
|
30335
30318
|
const serialize = () => bom + (newline === "\n" ? view.state.doc.toString() : view.state.doc.toString().replace(/\n/gu, newline));
|
|
30336
30319
|
let wasDirty = false;
|
|
@@ -30508,7 +30491,6 @@ function mountTextFile(parent, options) {
|
|
|
30508
30491
|
++readVersion;
|
|
30509
30492
|
baselineLoading = false;
|
|
30510
30493
|
destroyDiff();
|
|
30511
|
-
measureToolbarSpace();
|
|
30512
30494
|
}
|
|
30513
30495
|
}
|
|
30514
30496
|
async function loadBaseline() {
|
package/package.json
CHANGED
|
@@ -222,8 +222,10 @@ export function chooseBrowserProject({document, projects, locale = 'en', purpose
|
|
|
222
222
|
return element;
|
|
223
223
|
};
|
|
224
224
|
item.append(text,
|
|
225
|
-
// The project is at the root of the stored folder, as on the device.
|
|
225
|
+
// The project is at the root of the stored folder, as on the device. A folder kept by an earlier
|
|
226
|
+
// version, with its project in project/, moves it there first.
|
|
226
227
|
button(message.open, async () => {
|
|
228
|
+
await projects.moveProjectToRoot(project.id);
|
|
227
229
|
const directory = await projects.root(project.id);
|
|
228
230
|
if (!directory) return render();
|
|
229
231
|
finish({project, directory});
|
package/src/browser-projects.ts
CHANGED
|
@@ -12,8 +12,8 @@ export interface BrowserProject {
|
|
|
12
12
|
id: string;
|
|
13
13
|
title: string;
|
|
14
14
|
/**
|
|
15
|
-
* A folder inside the stored folder, `''` for the stored folder itself. Only for
|
|
16
|
-
* project at the root of the stored folder,
|
|
15
|
+
* A folder inside the stored folder, `''` for the stored folder itself. Only for entries kept by an earlier version:
|
|
16
|
+
* the Editor opens the project at the root of the stored folder, and `moveProjectToRoot` moves such a project there.
|
|
17
17
|
*/
|
|
18
18
|
projectPath: string;
|
|
19
19
|
createdAt: number;
|
|
@@ -34,6 +34,12 @@ export interface BrowserProjects {
|
|
|
34
34
|
root(id: string): Promise<FileSystemDirectoryHandle | null>;
|
|
35
35
|
/** The folder `projectPath` inside the entry's stored folder. Opening uses `root` instead. */
|
|
36
36
|
directory(id: string): Promise<FileSystemDirectoryHandle | null>;
|
|
37
|
+
/**
|
|
38
|
+
* Moves the project of an entry kept by an earlier version, in the folder `projectPath`, to the root of the stored
|
|
39
|
+
* folder, where the Editor opens it, and records that. Nothing moves when a name in that folder is already taken
|
|
40
|
+
* at the root. Resolves with whether the project is at the root.
|
|
41
|
+
*/
|
|
42
|
+
moveProjectToRoot(id: string): Promise<boolean>;
|
|
37
43
|
/** The entry that holds `handle`, or `null` when it is not in the browser's storage. */
|
|
38
44
|
find(handle: FileSystemHandle): Promise<BrowserProject | null>;
|
|
39
45
|
touch(id: string): Promise<void>;
|
|
@@ -90,6 +96,26 @@ async function writeText(directory: FileSystemDirectoryHandle, name: string, tex
|
|
|
90
96
|
}
|
|
91
97
|
}
|
|
92
98
|
|
|
99
|
+
// The files that make a folder a project folder go last, so a copy cut short is no project folder.
|
|
100
|
+
const manifestFiles = ['project.source.json', 'sb3-source.json'];
|
|
101
|
+
|
|
102
|
+
async function copyEntry(entry: FileSystemHandle, target: FileSystemDirectoryHandle): Promise<void> {
|
|
103
|
+
if (entry.kind === 'file') {
|
|
104
|
+
const file = await (entry as FileSystemFileHandle).getFile();
|
|
105
|
+
const writable = await (await target.getFileHandle(entry.name, {create: true})).createWritable();
|
|
106
|
+
try {
|
|
107
|
+
await writable.write(file);
|
|
108
|
+
await writable.close();
|
|
109
|
+
} catch (error) {
|
|
110
|
+
await writable.abort().catch(() => {});
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const directory = await target.getDirectoryHandle(entry.name, {create: true});
|
|
116
|
+
for await (const child of (entry as IterableDirectory).values()) await copyEntry(child, directory);
|
|
117
|
+
}
|
|
118
|
+
|
|
93
119
|
async function resolvePath(root: FileSystemDirectoryHandle, path: string) {
|
|
94
120
|
let directory = root;
|
|
95
121
|
for (const part of path ? path.split('/') : []) directory = await directory.getDirectoryHandle(part);
|
|
@@ -179,6 +205,33 @@ export function openBrowserProjects(view: Window): BrowserProjects | null {
|
|
|
179
205
|
throw error;
|
|
180
206
|
}
|
|
181
207
|
},
|
|
208
|
+
moveProjectToRoot: id => exclusive(id, async () => {
|
|
209
|
+
const project = await readInfo(id);
|
|
210
|
+
const top = project && await root(id);
|
|
211
|
+
if (!project || !top) return false;
|
|
212
|
+
if (!project.projectPath) return true;
|
|
213
|
+
const parts = project.projectPath.split('/');
|
|
214
|
+
let source: FileSystemDirectoryHandle;
|
|
215
|
+
try {
|
|
216
|
+
source = await resolvePath(top, project.projectPath);
|
|
217
|
+
} catch (error) {
|
|
218
|
+
if (missing(error)) return false;
|
|
219
|
+
throw error;
|
|
220
|
+
}
|
|
221
|
+
// `project/` itself is a name at the root, so a project holding a `project` entry stays where it is.
|
|
222
|
+
const taken = new Set<string>();
|
|
223
|
+
for await (const entry of (top as IterableDirectory).values()) taken.add(entry.name);
|
|
224
|
+
const entries: FileSystemHandle[] = [];
|
|
225
|
+
for await (const entry of (source as IterableDirectory).values()) entries.push(entry);
|
|
226
|
+
if (entries.some(entry => taken.has(entry.name))) return false;
|
|
227
|
+
entries.sort((a, b) => Number(manifestFiles.includes(a.name)) - Number(manifestFiles.includes(b.name)));
|
|
228
|
+
for (const entry of entries) await copyEntry(entry, top);
|
|
229
|
+
// The old folder goes only after the copy is complete.
|
|
230
|
+
const parent = await resolvePath(top, parts.slice(0, -1).join('/'));
|
|
231
|
+
await parent.removeEntry(parts[parts.length - 1], {recursive: true});
|
|
232
|
+
await writeInfo({...project, projectPath: ''});
|
|
233
|
+
return true;
|
|
234
|
+
}),
|
|
182
235
|
async find(handle) {
|
|
183
236
|
const path = await (await folders()).projects.resolve(handle).catch(() => null);
|
|
184
237
|
return path?.length && idPattern.test(path[0]) ? readInfo(path[0]) : null;
|
package/src/text-file-editor.ts
CHANGED
|
@@ -95,7 +95,6 @@ max-height:40%;overflow:auto;border-radius:.3rem;background:var(--ui-primary,#ff
|
|
|
95
95
|
box-sizing:border-box;max-width:calc(100% - 2rem);margin:0;padding:.65rem 1rem;border-radius:.35rem;
|
|
96
96
|
background:#323232;color:#fff;font-size:.9em;box-shadow:0 2px 8px rgba(0,0,0,.3);pointer-events:none}
|
|
97
97
|
.twpf-file-edit,.twpf-file-diff{flex:1;min-height:0}
|
|
98
|
-
.twpf-file-edit.twpf-file-short{padding-top:var(--twpf-toolbar-height,3.25rem)}
|
|
99
98
|
.twpf-file-diff{padding-top:var(--twpf-toolbar-height,3.25rem)}
|
|
100
99
|
.twpf-file-edit>.cm-editor{height:100%}
|
|
101
100
|
.twpf-text-file .cm-scroller{overflow:auto}
|
|
@@ -329,10 +328,8 @@ export function mountTextFile(parent: HTMLElement, options: TextFileOptions) {
|
|
|
329
328
|
parent.append(shell);
|
|
330
329
|
const toolbarObserver = browser && new browser.ResizeObserver(() => {
|
|
331
330
|
panel.style.setProperty('--twpf-toolbar-height', `calc(${toolbar.getBoundingClientRect().height}px + 1rem)`);
|
|
332
|
-
measureToolbarSpace();
|
|
333
331
|
});
|
|
334
332
|
toolbarObserver?.observe(toolbar);
|
|
335
|
-
toolbarObserver?.observe(editPane);
|
|
336
333
|
|
|
337
334
|
const editing = new Compartment();
|
|
338
335
|
const view = new EditorView({
|
|
@@ -342,26 +339,9 @@ export function mountTextFile(parent: HTMLElement, options: TextFileOptions) {
|
|
|
342
339
|
highlightActiveLine(), textMinimap(message.minimap),
|
|
343
340
|
EditorView.contentAttributes.of({'aria-label': options.path}),
|
|
344
341
|
keymap.of([...defaultKeymap, ...historyKeymap]),
|
|
345
|
-
EditorView.updateListener.of(update => {
|
|
346
|
-
if (update.docChanged) updateSaveState(undefined, true);
|
|
347
|
-
if (update.docChanged || update.geometryChanged) measureToolbarSpace();
|
|
348
|
-
})
|
|
342
|
+
EditorView.updateListener.of(update => {if (update.docChanged) updateSaveState(undefined, true);})
|
|
349
343
|
]
|
|
350
344
|
});
|
|
351
|
-
function measureToolbarSpace() {
|
|
352
|
-
if (disposed || comparison) return;
|
|
353
|
-
view.requestMeasure({
|
|
354
|
-
key: editPane,
|
|
355
|
-
read: view => {
|
|
356
|
-
// Include the reserved space when comparing, so adding it cannot flip the decision back.
|
|
357
|
-
const available = editPane.clientHeight;
|
|
358
|
-
return available ? view.contentHeight < available : null;
|
|
359
|
-
},
|
|
360
|
-
write: short => {
|
|
361
|
-
if (!disposed && !comparison && short !== null) editPane.classList.toggle('twpf-file-short', short);
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
345
|
const dirty = () => !view.state.doc.eq(savedDoc);
|
|
366
346
|
const serialize = () => bom + (newline === '\n' ? view.state.doc.toString() : view.state.doc.toString().replace(/\n/gu, newline));
|
|
367
347
|
|
|
@@ -544,7 +524,6 @@ export function mountTextFile(parent: HTMLElement, options: TextFileOptions) {
|
|
|
544
524
|
++readVersion;
|
|
545
525
|
baselineLoading = false;
|
|
546
526
|
destroyDiff();
|
|
547
|
-
measureToolbarSpace();
|
|
548
527
|
}
|
|
549
528
|
}
|
|
550
529
|
|