Using CDN

For a static page where installing a package is impractical, load the browser build and its CSS from a CDN. The demo below reads the package version while the site is built and creates an editor through the global NabiNote object.

Save the code below as and open it in a browser — you can see it working right away.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>NABI NOTE</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nabi-note@1.0.0/dist/nabi.css">
  <style>
    html, body { height: 100%; margin: 0; }
    /* Minimum editor height — keeps it from looking like a single-line box on first load. Change freely. */
    #app { height: 100vh; }
    #editor { flex: 1; min-height: 0; overflow-y: auto; }
  </style>
</head>
<body>

<div id="app" class="nabi">
  <div id="chrome" class="nabi-toolbar">
    <div class="nabi-toolbar-row">
      <span id="tools"></span>
      <div id="toolbar"></div>
    </div>
    <div id="context"></div>
  </div>
  <div id="editor" class="nabi-content"></div>
</div>

<script src="https://cdn.jsdelivr.net/npm/nabi-note@1.0.0/dist/browser/nabi-note.min.js"></script>
<script>
  var N = NabiNote
  var app = document.querySelector('#app')
  var surface = document.querySelector('#editor')

  // Every wing except upload.
  // Of the typefaces, only sans and serif are kept.
  // Systems support different typefaces, so mono and cursive need a web font imported separately
  // before every platform recognizes them. See the "Typeface" page for the details.
  var wings = N.wings().allBasic().use('save').use('open').use('tf', { values: ['sans', 'serif'] })

  var made = N.createNabiWith(wings, {
    locale: 'en',
    ask: {
      message: function (text) { window.alert(text) },
      confirm: function (text) { return window.confirm(text) }
    }
  })
  var nabi = made.nabi
  var registry = made.registry

  N.mountSurface({ nabi: nabi, registry: registry, root: surface, locale: 'en' })
  N.mountPickedMark({ nabi: nabi, surface: surface })

  var settle = N.watchSettle(document, { surface: surface })
  var shared = { nabi: nabi, registry: registry, surface: surface, settle: settle, locale: 'en' }

  var history = N.mountLocalHistory({ nabi: nabi, storage: N.browserHistoryStorage(window) })
  var file = N.mountFile({
    nabi: nabi, registry: registry, store: N.browserFileStore(document),
    name: function () { return 'note' }, locale: 'en'
  })

  var toolbar = N.mountToolbar(Object.assign({}, shared, {
    root: document.querySelector('#toolbar'),
    file: file,
    onHost: function (w) {
      if (w !== 'localHistory') return
      N.openHistoryPanel({
        history: history, surface: surface, locale: 'en', sessionId: history.sessionId,
        render: function (record) {
          return N.renderStoredHtml(JSON.parse(record.body), registry) || ''
        }
      })
    }
  }))
  var context = N.mountContextToolbar(Object.assign({}, shared, { root: document.querySelector('#context') }))

  N.mountHints({ toolbar: toolbar, context: context, root: document.querySelector('#chrome'), surface: surface })
  N.mountViewTools({ nabi: nabi, surface: surface, root: app, container: document.querySelector('#tools'), locale: 'en' })

  nabi.setHtml('')

  // Example callback for when the value changes
  // nabi.onChange(function () { user_callback(nabi.getJson()) })
</script>

</body>
</html>

Notes for NABI NOTE

  • In deployed code, pin CSS and browser JavaScript to the same version. A URL without a version, such as latest, can change behavior when a new release is published.
  • The browser bundle exposes the root API through window.NabiNote. nabi-note/ssr, nabi-note/viewer, and nabi-note/diff are not separate global bundles.
  • File saving and local history in this demo run in the user's browser. Send getJson() output to your application API for server storage or account sync.
  • Upload requires the upload wing, a real upload function, and the necessary image or link wing. Your upload server is responsible for file validation.
  • The browser build wires its HTML parser internally. setHtml(), opening an HTML file, and pasting HTML do not need a parser option or a private API.

CDN loading changes only how the library is loaded. Its storage format and input validation are the same as the npm package; see Basic usage as well.