How to use the prosemirror-transform.StepMap function in prosemirror-transform

To help you get started, we’ve selected a few prosemirror-transform examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pubpub / pubpub-editor / stories / stepTestStories.js View on Github external
newMap.forEach((oldStart, oldEnd, newStart, newEnd) => {
				console.log(om_oldStart, om_oldEnd, om_newStart, om_newEnd);
				console.log(oldStart, oldEnd, newStart, newEnd);
				// const offsetStart = Math.max(0, om_newStart - newStart);
				// const offsetEnd = Math.max(0, om_newEnd - newEnd);
				const offsetStart =
					om_newStart > newStart && om_newStart < newEnd ? newEnd - om_newStart : 0;
				const offsetEnd =
					om_newEnd > newStart && om_newEnd < newEnd ? newEnd - om_newEnd : 0;
				// Math.max(0, newStart - om_newStart);
				// const offsetEnd = Math.max(0, newEnd - om_newEnd);
				const offset = offsetStart - offsetEnd;
				const thisNewStepMap = new StepMap([
					om_newStart,
					om_oldEnd - om_oldStart,
					om_newEnd - om_newStart - offset,
				]);
				newestMapping.appendMap(thisNewStepMap);
			});
		});
github pubpub / pubpub-editor / src / plugins / changes.js View on Github external
additionalSteps.map((as) => {
			if (as.slice) {
				const size = as.slice.size;
				return new StepMap(as.from - size, 0, as.size);
			}
			return as.getMap();
		}),
	);