1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-03-29 02:51:30 +00:00
Files
TiddlyWiki5/core/modules/savers/custom.js
Jeremy Ruston d8b0e041b6 Initial commit
2026-02-19 12:45:27 +00:00

42 lines
969 B
JavaScript

/*\
title: $:/core/modules/savers/custom.js
type: application/javascript
module-type: saver
\*/
"use strict";
var findSaver = function(window) {
try {
return window && window.$tw && window.$tw.customSaver;
} catch (err) {
// Catching the exception is the most reliable way to detect cross-origin iframe errors.
// Uncaught DOMException: Permission denied to access property "$tw" on cross-origin object
console.log({ msg: "custom saver is disabled", reason: err });
return null;
}
}
var saver = findSaver(window) || findSaver(window.parent) || {};
var CustomSaver = function(wiki) {
};
CustomSaver.prototype.save = function(text,method,callback) {
return saver.save(text, method, callback);
};
CustomSaver.prototype.info = {
name: "custom",
priority: saver.priority || 4000,
capabilities: ["save","autosave"]
};
exports.canSave = function(wiki) {
return !!(saver.save);
};
exports.create = function(wiki) {
return new CustomSaver(wiki);
};