Migrate vhosts from Apache to OpenLiteSpeed

LiteSpeed has 2 branches , LiteSpeed Enterprise , which reads Apache conf , and OpenLiteSpeed which is what you see above.

Can I edit it without the webUI, and how can I add some Apache directives to it?

Yes, you can

Let's say I want to add this Apache directive to my LiteSpeed vhost, for example

it will be little hard to write directly the configuration directives on OLS without using webadmin console.

as in your example , it will be something like this

context /protected/{
  required user test
  authName Protected
  allowBrowse 1
  location protected/
  realm SampleProtectedArea

  accessControl {
    deny
    allow *
  }
}

realm SampleProtectedArea {
  userDB {
    cacheTimeout 60
    maxCacheSize 200
    location /path/to/htpasswd
  }

  groupDB {
    cacheTimeout 60
    maxCacheSize 200
    location /path/to/htgroup
  }
}