diff --git a/README.md b/README.md index fee41d1..bd0f282 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # HTML5 Text Editor A simple text editor designed to experiement with and demonstrate the -new Native File System APIs. +new File System Access APIs. This is not an officially supported Google product. diff --git a/package.json b/package.json index e833c1b..07cd5f2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "text-editor", - "description": "Text Editor - Demo for the HTML5 Native File System.", - "version": "0.0.12", + "description": "Text Editor - Demo for the HTML5 File System Access API.", + "version": "0.0.13", "repository": { "type": "git", "url": "https://github.com/GoogleChromeLabs/text-editor.git" diff --git a/src/humans.txt b/src/humans.txt index ba092b4..37e55c9 100644 --- a/src/humans.txt +++ b/src/humans.txt @@ -9,4 +9,4 @@ Twitter: @petele /* TECHNOLOGY COLOPHON */ - HTML5, CSS3, Native File System APIs + HTML5, CSS3, File System Access APIs diff --git a/src/index.html b/src/index.html index 26e68f5..c8846e5 100644 --- a/src/index.html +++ b/src/index.html @@ -24,7 +24,7 @@ - + @@ -46,7 +46,7 @@ - + @@ -55,7 +55,7 @@ - + @@ -169,20 +169,17 @@

The - Native File System API + File System Access API is not supported in this browser yet, and Text Editor is running in legacy mode. In legacy mode, the file modified indicators are not shown. - If you're running Chrome, you can enable the Native File System - APIs by enabling the #native-file-system-api - flag in chrome://flags.
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",