Fix: Empty document filepath triggers a lot of errors. filePath check is added.
Fix: Update _canPreview function to reflect correct logic.
Fix: Fix commonprefix bugs. All tests pass