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

remove inner debounce

parent b1132774
No related branches found
No related tags found
1 merge request!298Multiple configs
......@@ -5,6 +5,7 @@ import { Wax } from 'wax-prosemirror-core';
import { EditoriaLayout, EditoriaMobileLayout } from './layout';
import { config, configMobile } from './config';
import { demo } from './demo';
import { debounce } from 'lodash';
const renderImage = file => {
const reader = new FileReader();
......@@ -50,7 +51,9 @@ const Editoria = () => {
value={`<p> some text</p><h2>h2</h2><h3>a head</h3><h4>fff</h4><h1>ttt</h1>`}
// readonly
layout={layout}
// onChange={source => console.log(source)}
onChange={debounce(source => {
console.log(source);
}, 3000)}
user={user}
/>
</>
......
......@@ -51,49 +51,44 @@ const Wax = props => {
if (!application) return null;
const WaxOnchange = onChange || (v => true);
const finalOnChange = schema =>
debounce(
content => {
/* HACK alter toDOM of footnote, because of how PM treats inline nodes
const finalOnChange = schema => content => {
/* HACK alter toDOM of footnote, because of how PM treats inline nodes
with content */
const notes = [];
each(schema.nodes, node => {
if (node.groups.includes('notes')) notes.push(node);
});
if (notes.length > 0) {
notes.forEach(note => {
const old = schema.nodes[note.name].spec.toDOM;
schema.nodes[note.name].spec.toDOM = node => {
// eslint-disable-next-line prefer-rest-params
old.apply(this);
if (node) return [note.name, node.attrs, 0];
};
});
}
if (targetFormat === 'JSON') {
WaxOnchange(content);
} else {
const serialize = serializer(schema);
WaxOnchange(serialize(content));
}
if (notes.length > 0) {
notes.forEach(note => {
const old = schema.nodes[note.name].spec.toDOM;
schema.nodes[note.name].spec.toDOM = node => {
// eslint-disable-next-line prefer-rest-params
old.apply(this);
if (node) return [note.name, node.attrs];
};
});
}
},
1000,
{ maxWait: 5000 },
);
const notes = [];
each(schema.nodes, node => {
if (node.groups.includes('notes')) notes.push(node);
});
if (notes.length > 0) {
notes.forEach(note => {
const old = schema.nodes[note.name].spec.toDOM;
schema.nodes[note.name].spec.toDOM = node => {
// eslint-disable-next-line prefer-rest-params
old.apply(this);
if (node) return [note.name, node.attrs, 0];
};
});
}
if (targetFormat === 'JSON') {
WaxOnchange(content);
} else {
const serialize = serializer(schema);
WaxOnchange(serialize(content));
}
if (notes.length > 0) {
notes.forEach(note => {
const old = schema.nodes[note.name].spec.toDOM;
schema.nodes[note.name].spec.toDOM = node => {
// eslint-disable-next-line prefer-rest-params
old.apply(this);
if (node) return [note.name, node.attrs];
};
});
}
};
const TrackChange = application.config.get('config.EnableTrackChangeService');
const Layout = application.container.get('Layout');
......
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