UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

31 lines 1.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var prosemirror_1 = require("../prosemirror"); function defaultInputRuleHandler(inputRule) { var originalHandler = inputRule.handler; inputRule.handler = function (state, match, start, end) { // Skip any input rule inside code // https://product-fabric.atlassian.net/wiki/spaces/E/pages/37945345/Editor+content+feature+rules#Editorcontent/featurerules-Rawtextblocks if (state.selection.$from.parent.type.spec.code) { return; } return originalHandler(state, match, start, end); }; return inputRule; } exports.defaultInputRuleHandler = defaultInputRuleHandler; function createInputRule(match, handler) { return defaultInputRuleHandler(new prosemirror_1.InputRule(match, handler)); } exports.createInputRule = createInputRule; // ProseMirror uses the Unicode Character 'OBJECT REPLACEMENT CHARACTER' (U+FFFC) as text representation for // leaf nodes, i.e. nodes that don't have any content or text property (e.g. hardBreak, emoji, mention, rule) // It was introduced because of https://github.com/ProseMirror/prosemirror/issues/262 // This can be used in an input rule regex to be able to include or exclude such nodes. exports.leafNodeReplacementCharacter = '\ufffc'; // tslint:disable:no-bitwise exports.uuid = function () { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = Math.random() * 16 | 0; return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); }); }; //# sourceMappingURL=utils.js.map