Text Editor is a simple text editor similar to notepad that makes
it easy to edit text files on your local file system. It shows how
- to easily use the new HTML5 Native File System APIs. To learn more
- about the Native File System APIs and how this demo was built, check out
-
- The native file system APIs article on Web Fundamentals, or see the
+ to easily use the new HTML5 File System Access APIs. To learn more
+ about the File System Access APIs and how this demo was built, check out
+
+ The file system access APIs article on Web Fundamentals, or see the
source code on GitHub.
Written by
Pete LePage.
diff --git a/src/inline-scripts/app.js b/src/inline-scripts/app.js
index 367d9fe..99380b7 100644
--- a/src/inline-scripts/app.js
+++ b/src/inline-scripts/app.js
@@ -33,15 +33,15 @@ const app = {
monoSpace: false,
wordWrap: true,
},
- hasNativeFS: 'chooseFileSystemEntries' in window ||
+ hasFSAccess: 'chooseFileSystemEntries' in window ||
'showOpenFilePicker' in window,
isMac: navigator.userAgent.includes('Mac OS X'),
};
// Verify the APIs we need are supported, show a polite warning if not.
-if (app.hasNativeFS) {
+if (app.hasFSAccess) {
document.getElementById('not-supported').classList.add('hidden');
- gaEvent('File System APIs', 'Native');
+ gaEvent('File System APIs', 'FSAccess');
} else {
document.getElementById('lblLegacyFS').classList.toggle('hidden', false);
document.getElementById('butSave').classList.toggle('hidden', true);
@@ -73,8 +73,8 @@ app.openFile = async (fileHandle) => {
return;
}
- // If the Native File System API is not supported, use the legacy file apis.
- if (!app.hasNativeFS) {
+ // If the File System Access API is not supported, use the legacy file apis.
+ if (!app.hasFSAccess) {
gaEvent('FileAction', 'Open', 'Legacy');
const file = await app.getFileLegacy();
if (file) {
@@ -86,13 +86,13 @@ app.openFile = async (fileHandle) => {
// If a fileHandle is provided, verify we have permission to read/write it,
// otherwise, show the file open prompt and allow the user to select the file.
if (fileHandle) {
- gaEvent('FileAction', 'OpenRecent', 'Native');
+ gaEvent('FileAction', 'OpenRecent', 'FSAccess');
if (await verifyPermission(fileHandle, true) === false) {
console.error(`User did not grant permission to '${fileHandle.name}'`);
return;
}
} else {
- gaEvent('FileAction', 'Open', 'Native');
+ gaEvent('FileAction', 'Open', 'FSAccess');
try {
fileHandle = await getFileHandle();
} catch (ex) {
@@ -157,13 +157,13 @@ app.saveFile = async () => {
* Saves a new file to disk.
*/
app.saveFileAs = async () => {
- if (!app.hasNativeFS) {
+ if (!app.hasFSAccess) {
gaEvent('FileAction', 'Save As', 'Legacy');
app.saveAsLegacy(app.file.name, app.getText());
app.setFocus();
return;
}
- gaEvent('FileAction', 'Save As', 'Native');
+ gaEvent('FileAction', 'Save As', 'FSAccess');
let fileHandle;
try {
fileHandle = await getNewFileHandle();
@@ -186,7 +186,7 @@ app.saveFileAs = async () => {
const msg = 'Unable to save file.';
console.error(msg, ex);
alert(msg);
- gaEvent('Error', 'Unable to write file', 'Native');
+ gaEvent('Error', 'Unable to write file', 'FSAccess');
return;
}
app.setFocus();
diff --git a/src/inline-scripts/ui.js b/src/inline-scripts/ui.js
index b2440ac..80d2fa7 100644
--- a/src/inline-scripts/ui.js
+++ b/src/inline-scripts/ui.js
@@ -69,7 +69,7 @@
* @param {boolean} val True if the file has been modified.
*/
app.setModified = (val) => {
- if (!app.hasNativeFS) {
+ if (!app.hasFSAccess) {
return;
}
app.file.isModified = val;
diff --git a/src/manifest.json b/src/manifest.json
index 465568a..e8b1ffe 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -1,7 +1,7 @@
{
"name": "Text Editor",
"short_name": "TextEdit",
- "description": "Text Editor - Demo for the HTML5 Native File System.",
+ "description": "Text Editor - Demo for the HTML5 File System Access API.",
"start_url": "./",
"display": "standalone",
"theme_color": "#1a237e",