Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
base Plugin state?
*/
/*
Doesn't need to be a plugin??
*/
/*
How to create a 'current' merged commit?
- Always merge current steps?
- Only show up to last steps?
*/
var _require6 = require('prosemirror-view'),
DecorationSet = _require6.DecorationSet,
Decoration = _require6.Decoration;
function stringToColor(string) {
var alpha = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
var hue = string.split('').reduce(function (sum, char) {
return sum + char.charCodeAt(0);
}, 0) % 360;
return 'hsla(' + hue + ', 100%, 50%, ' + alpha + ')';
}
// Checkpoint a document every 100 steps
var SAVE_EVERY_N_STEPS = 100;
// healDatabase - In case a step corrupts the document (happens surpsiginly often), apply each step individually to find errors
// and then delete all of those steps
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _prosemirrorState = require('prosemirror-state');
var _plugins = require('../plugins');
var _pluginKeys = require('./pluginKeys');
var _schema = require('../schema');
var _require = require('prosemirror-view'),
DecorationSet = _require.DecorationSet,
Decoration = _require.Decoration;
var mentionsPlugin = new _prosemirrorState.Plugin({
state: {
init: function init(config, instance) {
// const set = DecorationSet.empty;
return { decos: DecorationSet.empty, start: null };
},
apply: function apply(transaction, state, prevEditorState, editorState) {
var sel = editorState.selection;
var updateMentions = this.spec.editorView.props.viewHandlers.updateMentions;
if (!sel.empty) {
updateMentions('');
return { decos: DecorationSet.empty, start: null };
init: function init(config, instance) {
var _require = require("prosemirror-view"),
DecorationSet = _require.DecorationSet,
Decoration = _require.Decoration;
return { deco: DecorationSet.empty,
linkedEditor: config.linkedEditor,
originalEditor: config.originalEditor,
showAsAdditions: config.showAsAdditions
};
},
apply: function apply(action, state, prevEditorState, editorState) {
init: function init() {
return _prosemirrorView.DecorationSet.empty;
},
apply: function apply(tr, set) {
var _docOperations = require('../utils/doc-operations');
var _references = require('../references');
var _prosemirrorState = require('prosemirror-state');
var _prosemirrorModel = require('prosemirror-model');
var _prosemirrorTransform = require('prosemirror-transform');
var _pluginKeys = require('./pluginKeys');
var _setup = require('../setup');
var _require = require("prosemirror-view"),
DecorationSet = _require.DecorationSet,
Decoration = _require.Decoration;
/*
Problem:
- problem: remote diffs do not have meta data
*/
var createReferenceDecoration = function createReferenceDecoration(index, node, label) {
return Decoration.node(index, index + 1, {}, { citationID: node.attrs.citationID, label: label });
};
var findCitationNode = function findCitationNode(doc, citationID) {
var citationsNode = doc.child(1);
if (!citationsNode) {
return null;
}
var _references = require('../../references');
var _prosemirrorState = require('prosemirror-state');
var _prosemirrorModel = require('prosemirror-model');
var _plugins = require('../plugins');
var _prosemirrorTransform = require('prosemirror-transform');
var _pluginKeys = require('./pluginKeys');
var _schema = require('../schema');
var _require = require('prosemirror-view'),
DecorationSet = _require.DecorationSet,
Decoration = _require.Decoration;
var createReferenceDecoration = function createReferenceDecoration(index, node, label) {
return Decoration.node(index, index + 1, {}, { citationID: node.attrs.citationID, label: label });
};
var findCitationNode = function findCitationNode(doc, citationID) {
var citationsNode = doc.child(1);
if (!citationsNode) {
return null;
}
var foundNode = (0, _docOperations.findNodeByFunc)(doc, function (_node) {
return _node.type.name === 'citation' && _node.attrs.citationID === citationID;
});
if (!foundNode) {
return null;
var _docOperations = require('../../utils/doc-operations');
var _prosemirrorState = require('prosemirror-state');
var _prosemirrorModel = require('prosemirror-model');
var _plugins = require('../plugins');
var _prosemirrorTransform = require('prosemirror-transform');
var _pluginKeys = require('./pluginKeys');
var _schema = require('../schema');
var _require = require('prosemirror-view'),
DecorationSet = _require.DecorationSet,
Decoration = _require.Decoration;
var createFootnoteDecoration = function createFootnoteDecoration(index, node, label) {
return Decoration.node(index, index + node.nodeSize, {}, { label: label });
};
var createDecorations = function createDecorations(doc, set) {
var nodes = (0, _docOperations.findNodesWithIndex)(doc, 'footnote') || [];
var count = 0;
var decos = nodes.map(function (node, index) {
count++;
var deco = createFootnoteDecoration(node.index, node.node, count);
return deco;
});
var newSet = DecorationSet.create(doc, decos);
apply: function apply(action, state, prevEditorState, editorState) {
var _require2 = require("prosemirror-view"),
DecorationSet = _require2.DecorationSet,
Decoration = _require2.Decoration;
if (action.type === 'transform') {
state.linkedEditor.linkedTransform();
}
if (action.type === 'patch') {
var diffIndex = action.diffIndex;
var diff = state.lastDiff[diffIndex];
//Removals always require an insertion, and possibly a deletion
//
if (diff.removed) {
var textNode = pubSchema.text(text);
var newT = state.tr.replaceWith(to, to, textNode);
var _action = {
type: 'transform',
this._createDecorations = function (editorState) {
var _require = require("prosemirror-view"),
DecorationSet = _require.DecorationSet;
return DecorationSet.empty;
};
apply: function apply(transaction, state, prevEditorState, editorState) {
var sel = transaction.curSelection;
if (sel) {
var decos = [_prosemirrorView.Decoration.inline(sel.$from.pos, sel.$to.pos, { class: 'selection-marker' }, { inclusiveLeft: true,
inclusiveRight: true
})];
var deco = _prosemirrorView.DecorationSet.create(editorState.doc, decos);
return { deco: deco };
}
return state;
}
},