Skip to content
Snippets Groups Projects
Commit 801f98d5 authored by chris's avatar chris
Browse files

remove placeholder old plugin

parent 9f064f27
No related branches found
No related tags found
1 merge request!45Develop
......@@ -15,7 +15,7 @@ export default class Application {
registerServices() {
this.config.get("services").map(service => {
/*
/*
set App to every service
so services can have access to containers and config
*/
......
......@@ -4,7 +4,6 @@ import applyDevTools from "prosemirror-dev-tools";
import { EditorState } from "prosemirror-state";
import { EditorView } from "prosemirror-view";
import placeholderPlugin from "./config/plugins/placeholderPlugin";
import "prosemirror-view/style/prosemirror.css";
import trackedTransaction from "./config/track-changes/trackedTransaction";
......
......@@ -2,6 +2,5 @@ import { history } from "prosemirror-history";
import { dropCursor } from "prosemirror-dropcursor";
import { gapCursor } from "prosemirror-gapcursor";
import "prosemirror-gapcursor/style/gapcursor.css";
import placeholderPlugin from "./plugins/placeholderPlugin";
export default [dropCursor(), gapCursor(), history(), placeholderPlugin];
export default [dropCursor(), gapCursor(), history()];
import { Plugin, PluginKey } from "prosemirror-state";
import { Decoration, DecorationSet } from "prosemirror-view";
const placeHolder = new PluginKey("placeHolder");
const placeholderPlugin = new Plugin({
key: placeHolder,
state: {
init: function init() {
return DecorationSet.empty;
},
apply: function apply(tr, set) {
// Adjust decoration positions to changes made by the transaction
set = set.map(tr.mapping, tr.doc);
// See if the transaction adds or removes any placeholders
const action = tr.getMeta(this);
if (action && action.add) {
const widget = document.createElement("placeholder");
const deco = Decoration.widget(action.add.pos, widget, {
id: action.add.id
});
set = set.add(tr.doc, [deco]);
} else if (action && action.remove) {
set = set.remove(
set.find(null, null, spec => spec.id === action.remove.id)
);
}
return set;
}
},
props: {
decorations: function decorations(state) {
return this.getState(state);
}
}
});
export default placeholderPlugin;
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment