SandboxEdit
Now try live preview, syntax highlighting, fullscreen, autocomplete and all the other delicious stuff.
Tech preview, early stage... (pull the repohead if you like.)
- one
- two
code here
Now try live preview, syntax highlighting, fullscreen, autocomplete and all the other delicious stuff.
Tech preview, early stage... (pull the repohead if you like.)
code here
Console Logger
process.envdoes not exist. In a browser,processis undefined, so your currentisProduction()always falls into thecatchand returnsfalse—meaning logging is always on in production.The best practice for a client-side library like WikiEdit is to let the host application (WackoWiki/PHP) tell you the mode via a config object, with safe fallbacks for standalone use.
Recommended Architecture
window.WikiEditConfig.debug).?we_debug=1) for temporary troubleshooting.localhostfor developer convenience.false(OFF)—safe for production out of the box.1. Host Application Integration (WackoWiki PHP)
In WackoWiki’s template or header where scripts are loaded, have PHP emit the configuration before loading WikiEdit:
This is the most robust approach because the server knows the truth about the environment.
2. The Logger (
src/utils/logger.js)This version has no
process.envdependencies and defaults to silent in production.3. For End Users (Standalone / No PHP Access)
If a user deploys WikiEdit standalone and cannot edit WackoWiki’s PHP, they can set the config manually in their HTML before the script runs:
Or they can temporarily force debug logging on a live site with a URL parameter:
Important Notes
warn/errorin prodwarnanderrorvisible in production (common for tracking bugs), change those lines tomakeLoggerMethod('warn')etc., and only suppressdebug,log,info, andsuccess.IS_DEBUGis evaluated once at module load, the minified production code becomesconst x=()=>{}; logger={debug:x, log:x...}and tree-shaking / minification is more effective than checking a flag on every log call.Summary
window.WikiEditConfig.debug.localhost.?we_debug=1in the URL when debugging a production page.