<commit_before>import {obj2Node} from "./json"
import {createSlug, findImages} from "./tools"
import {zipFileCreator} from "./zip"
import {BibliographyDB} from "../bibliography/database"

/** The current Fidus Writer filetype version.
 * The importer will not import from a different version and the exporter
  * will include this number in all exports.
 */
let FW_FILETYPE_VERSION = "1.2"

/** Create a Fidus Writer document and upload it to the server as a backup.
 * @function uploadNative
 * @param aDocument The document to turn into a Fidus Writer document and upload.
 */
export let uploadNative = function(editor) {
    let doc = editor.doc
    exportNative(doc, ImageDB, BibDB, function(doc, shrunkImageDB, shrunkBibDB, images) {
        exportNativeFile(editor.doc, shrunkImageDB, shrunkBibDB, images, true, editor)
    })
}

export class NativeExporter {
    constructor(doc, bibDB, imageDB) {
        this.doc = doc
        this.bibDB = bibDB
        this.imageDB = imageDB
        this.init()
    }

    init() {
        let that = this
        this.getBibDB(function(){
            that.getImageDB(function(){
                exportNative(that.doc, that.imageDB, that.bibDB, exportNativeFile)
            })
        })
    }

    getBibDB(callback) {
        let that = this
        if (!this.bibDB) {<commit_msg>fix minor error with revision saving<commit_after>import {obj2Node} from "./json"
import {createSlug, findImages} from "./tools"
import {zipFileCreator} from "./zip"
import {BibliographyDB} from "../bibliography/database"

/** The current Fidus Writer filetype version.
 * The importer will not import from a different version and the exporter
  * will include this number in all exports.
 */
let FW_FILETYPE_VERSION = "1.2"

/** Create a Fidus Writer document and upload it to the server as a backup.
 * @function uploadNative
 * @param aDocument The document to turn into a Fidus Writer document and upload.
 */
export let uploadNative = function(editor) {
    exportNative(editor.doc, editor.imageDB.db, editor.bibDB.bibDB, function(doc, shrunkImageDB, shrunkBibDB, images) {
        exportNativeFile(editor.doc, shrunkImageDB, shrunkBibDB, images, true, editor)
    })
}

export class NativeExporter {
    constructor(doc, bibDB, imageDB) {
        this.doc = doc
        this.bibDB = bibDB
        this.imageDB = imageDB
        this.init()
    }

    init() {
        let that = this
        this.getBibDB(function(){
            that.getImageDB(function(){
                exportNative(that.doc, that.imageDB, that.bibDB, exportNativeFile)
            })
        })
    }

    getBibDB(callback) {
        let that = this
        if (!this.bibDB) {
{'fraction_non_alphanumeric': 0.10029828486204326, 'fraction_numerical': 0.0022371364653243847, 'mean_word_length': 2.865994236311239, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4620187', 'n_tokens_mistral': 812, 'n_tokens_neox': 774, 'n_words': 248}