@tiptap/extension-code-block-lowlight 2.5.0-beta.2 → 2.5.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +136 -136
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +136 -132
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +2714 -2714
- package/dist/index.umd.js.map +1 -1
- package/dist/packages/core/src/CommandManager.d.ts +20 -0
- package/dist/packages/core/src/Editor.d.ts +161 -0
- package/dist/packages/core/src/EventEmitter.d.ts +11 -0
- package/dist/packages/core/src/Extension.d.ts +343 -0
- package/dist/packages/core/src/ExtensionManager.d.ts +55 -0
- package/dist/packages/core/src/InputRule.d.ts +42 -0
- package/dist/packages/core/src/Mark.d.ts +451 -0
- package/dist/packages/core/src/Node.d.ts +611 -0
- package/dist/packages/core/src/NodePos.d.ts +44 -0
- package/dist/packages/core/src/NodeView.d.ts +31 -0
- package/dist/packages/core/src/PasteRule.d.ts +50 -0
- package/dist/packages/core/src/Tracker.d.ts +11 -0
- package/dist/packages/core/src/commands/blur.d.ts +13 -0
- package/dist/packages/core/src/commands/clearContent.d.ts +14 -0
- package/dist/packages/core/src/commands/clearNodes.d.ts +13 -0
- package/dist/packages/core/src/commands/command.d.ts +18 -0
- package/dist/packages/core/src/commands/createParagraphNear.d.ts +13 -0
- package/dist/packages/core/src/commands/cut.d.ts +20 -0
- package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +13 -0
- package/dist/packages/core/src/commands/deleteNode.d.ts +15 -0
- package/dist/packages/core/src/commands/deleteRange.d.ts +14 -0
- package/dist/packages/core/src/commands/deleteSelection.d.ts +13 -0
- package/dist/packages/core/src/commands/enter.d.ts +13 -0
- package/dist/packages/core/src/commands/exitCode.d.ts +13 -0
- package/dist/packages/core/src/commands/extendMarkRange.d.ts +25 -0
- package/dist/packages/core/src/commands/first.d.ts +14 -0
- package/dist/packages/core/src/commands/focus.d.ts +27 -0
- package/dist/packages/core/src/commands/forEach.d.ts +14 -0
- package/dist/packages/core/src/commands/index.d.ts +55 -0
- package/dist/packages/core/src/commands/insertContent.d.ts +34 -0
- package/dist/packages/core/src/commands/insertContentAt.d.ts +47 -0
- package/dist/packages/core/src/commands/join.d.ts +41 -0
- package/dist/packages/core/src/commands/joinItemBackward.d.ts +13 -0
- package/dist/packages/core/src/commands/joinItemForward.d.ts +13 -0
- package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +12 -0
- package/dist/packages/core/src/commands/joinTextblockForward.d.ts +12 -0
- package/dist/packages/core/src/commands/keyboardShortcut.d.ts +14 -0
- package/dist/packages/core/src/commands/lift.d.ts +17 -0
- package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +13 -0
- package/dist/packages/core/src/commands/liftListItem.d.ts +15 -0
- package/dist/packages/core/src/commands/newlineInCode.d.ts +13 -0
- package/dist/packages/core/src/commands/resetAttributes.d.ts +16 -0
- package/dist/packages/core/src/commands/scrollIntoView.d.ts +13 -0
- package/dist/packages/core/src/commands/selectAll.d.ts +13 -0
- package/dist/packages/core/src/commands/selectNodeBackward.d.ts +13 -0
- package/dist/packages/core/src/commands/selectNodeForward.d.ts +13 -0
- package/dist/packages/core/src/commands/selectParentNode.d.ts +13 -0
- package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +13 -0
- package/dist/packages/core/src/commands/selectTextblockStart.d.ts +13 -0
- package/dist/packages/core/src/commands/setContent.d.ts +40 -0
- package/dist/packages/core/src/commands/setMark.d.ts +15 -0
- package/dist/packages/core/src/commands/setMeta.d.ts +15 -0
- package/dist/packages/core/src/commands/setNode.d.ts +16 -0
- package/dist/packages/core/src/commands/setNodeSelection.d.ts +14 -0
- package/dist/packages/core/src/commands/setTextSelection.d.ts +14 -0
- package/dist/packages/core/src/commands/sinkListItem.d.ts +15 -0
- package/dist/packages/core/src/commands/splitBlock.d.ts +17 -0
- package/dist/packages/core/src/commands/splitListItem.d.ts +15 -0
- package/dist/packages/core/src/commands/toggleList.d.ts +18 -0
- package/dist/packages/core/src/commands/toggleMark.d.ts +30 -0
- package/dist/packages/core/src/commands/toggleNode.d.ts +17 -0
- package/dist/packages/core/src/commands/toggleWrap.d.ts +16 -0
- package/dist/packages/core/src/commands/undoInputRule.d.ts +13 -0
- package/dist/packages/core/src/commands/unsetAllMarks.d.ts +13 -0
- package/dist/packages/core/src/commands/unsetMark.d.ts +25 -0
- package/dist/packages/core/src/commands/updateAttributes.d.ts +24 -0
- package/dist/packages/core/src/commands/wrapIn.d.ts +16 -0
- package/dist/packages/core/src/commands/wrapInList.d.ts +16 -0
- package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +5 -0
- package/dist/packages/core/src/extensions/commands.d.ts +3 -0
- package/dist/packages/core/src/extensions/editable.d.ts +2 -0
- package/dist/packages/core/src/extensions/focusEvents.d.ts +2 -0
- package/dist/packages/core/src/extensions/index.d.ts +6 -0
- package/dist/packages/core/src/extensions/keymap.d.ts +2 -0
- package/dist/packages/core/src/extensions/tabindex.d.ts +2 -0
- package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +10 -0
- package/dist/packages/core/src/helpers/createChainableState.d.ts +10 -0
- package/dist/packages/core/src/helpers/createDocument.d.ts +12 -0
- package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +15 -0
- package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +7 -0
- package/dist/packages/core/src/helpers/findChildren.d.ts +9 -0
- package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +10 -0
- package/dist/packages/core/src/helpers/findParentNode.d.ts +16 -0
- package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +17 -0
- package/dist/packages/core/src/helpers/generateHTML.d.ts +8 -0
- package/dist/packages/core/src/helpers/generateJSON.d.ts +8 -0
- package/dist/packages/core/src/helpers/generateText.d.ts +12 -0
- package/dist/packages/core/src/helpers/getAttributes.d.ts +9 -0
- package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +6 -0
- package/dist/packages/core/src/helpers/getChangedRanges.d.ts +11 -0
- package/dist/packages/core/src/helpers/getDebugJSON.d.ts +8 -0
- package/dist/packages/core/src/helpers/getExtensionField.d.ts +9 -0
- package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +2 -0
- package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +3 -0
- package/dist/packages/core/src/helpers/getMarkRange.d.ts +3 -0
- package/dist/packages/core/src/helpers/getMarkType.d.ts +2 -0
- package/dist/packages/core/src/helpers/getMarksBetween.d.ts +3 -0
- package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +11 -0
- package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +3 -0
- package/dist/packages/core/src/helpers/getNodeType.d.ts +2 -0
- package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +3 -0
- package/dist/packages/core/src/helpers/getSchema.d.ts +4 -0
- package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +10 -0
- package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +8 -0
- package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +8 -0
- package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +9 -0
- package/dist/packages/core/src/helpers/getText.d.ts +15 -0
- package/dist/packages/core/src/helpers/getTextBetween.d.ts +14 -0
- package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +8 -0
- package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +8 -0
- package/dist/packages/core/src/helpers/index.d.ts +50 -0
- package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +9 -0
- package/dist/packages/core/src/helpers/isActive.d.ts +2 -0
- package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +2 -0
- package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +2 -0
- package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +2 -0
- package/dist/packages/core/src/helpers/isList.d.ts +2 -0
- package/dist/packages/core/src/helpers/isMarkActive.d.ts +3 -0
- package/dist/packages/core/src/helpers/isNodeActive.d.ts +3 -0
- package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +2 -0
- package/dist/packages/core/src/helpers/isNodeSelection.d.ts +2 -0
- package/dist/packages/core/src/helpers/isTextSelection.d.ts +2 -0
- package/dist/packages/core/src/helpers/posToDOMRect.d.ts +2 -0
- package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +4 -0
- package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +2 -0
- package/dist/packages/core/src/helpers/splitExtensions.d.ts +9 -0
- package/dist/packages/core/src/index.d.ts +24 -0
- package/dist/packages/core/src/inputRules/index.d.ts +5 -0
- package/dist/packages/core/src/inputRules/markInputRule.d.ts +13 -0
- package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +23 -0
- package/dist/packages/core/src/inputRules/textInputRule.d.ts +10 -0
- package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +15 -0
- package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +28 -0
- package/dist/packages/core/src/pasteRules/index.d.ts +3 -0
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +13 -0
- package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +13 -0
- package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +10 -0
- package/dist/packages/core/src/style.d.ts +1 -0
- package/dist/packages/core/src/types.d.ts +250 -0
- package/dist/packages/core/src/utilities/callOrReturn.d.ts +9 -0
- package/dist/packages/core/src/utilities/createStyleTag.d.ts +1 -0
- package/dist/packages/core/src/utilities/deleteProps.d.ts +6 -0
- package/dist/packages/core/src/utilities/elementFromString.d.ts +1 -0
- package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +1 -0
- package/dist/packages/core/src/utilities/findDuplicates.d.ts +1 -0
- package/dist/packages/core/src/utilities/fromString.d.ts +1 -0
- package/dist/packages/core/src/utilities/index.d.ts +20 -0
- package/dist/packages/core/src/utilities/isAndroid.d.ts +1 -0
- package/dist/packages/core/src/utilities/isEmptyObject.d.ts +1 -0
- package/dist/packages/core/src/utilities/isFunction.d.ts +1 -0
- package/dist/packages/core/src/utilities/isMacOS.d.ts +1 -0
- package/dist/packages/core/src/utilities/isNumber.d.ts +1 -0
- package/dist/packages/core/src/utilities/isPlainObject.d.ts +1 -0
- package/dist/packages/core/src/utilities/isRegExp.d.ts +1 -0
- package/dist/packages/core/src/utilities/isString.d.ts +1 -0
- package/dist/packages/core/src/utilities/isiOS.d.ts +1 -0
- package/dist/packages/core/src/utilities/mergeAttributes.d.ts +1 -0
- package/dist/packages/core/src/utilities/mergeDeep.d.ts +1 -0
- package/dist/packages/core/src/utilities/minMax.d.ts +1 -0
- package/dist/packages/core/src/utilities/objectIncludes.d.ts +8 -0
- package/dist/packages/core/src/utilities/removeDuplicates.d.ts +8 -0
- package/dist/packages/extension-code-block/src/code-block.d.ts +59 -0
- package/dist/packages/extension-code-block/src/index.d.ts +3 -0
- package/dist/packages/extension-code-block-lowlight/src/code-block-lowlight.d.ts +18 -18
- package/dist/packages/extension-code-block-lowlight/src/index.d.ts +3 -3
- package/dist/packages/extension-code-block-lowlight/src/lowlight-plugin.d.ts +6 -6
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -7,9 +7,9 @@ var core$1 = require('@tiptap/core');
|
|
|
7
7
|
var state = require('@tiptap/pm/state');
|
|
8
8
|
var view = require('@tiptap/pm/view');
|
|
9
9
|
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
function getDefaultExportFromCjs (x) {
|
|
11
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
12
|
+
}
|
|
13
13
|
|
|
14
14
|
var deepFreezeEs6 = {exports: {}};
|
|
15
15
|
|
|
@@ -2578,142 +2578,142 @@ var core = highlight;
|
|
|
2578
2578
|
highlight.HighlightJS = highlight;
|
|
2579
2579
|
highlight.default = highlight;
|
|
2580
2580
|
|
|
2581
|
-
var HighlightJS = core;
|
|
2582
|
-
|
|
2583
|
-
function parseNodes(nodes, className = []) {
|
|
2584
|
-
return nodes
|
|
2585
|
-
.map(node => {
|
|
2586
|
-
const classes = [...className, ...(node.properties ? node.properties.className : [])];
|
|
2587
|
-
if (node.children) {
|
|
2588
|
-
return parseNodes(node.children, classes);
|
|
2589
|
-
}
|
|
2590
|
-
return {
|
|
2591
|
-
text: node.value,
|
|
2592
|
-
classes,
|
|
2593
|
-
};
|
|
2594
|
-
})
|
|
2595
|
-
.flat();
|
|
2596
|
-
}
|
|
2597
|
-
function getHighlightNodes(result) {
|
|
2598
|
-
// `.value` for lowlight v1, `.children` for lowlight v2
|
|
2599
|
-
return result.value || result.children || [];
|
|
2600
|
-
}
|
|
2601
|
-
function registered(aliasOrLanguage) {
|
|
2602
|
-
return Boolean(HighlightJS.getLanguage(aliasOrLanguage));
|
|
2603
|
-
}
|
|
2604
|
-
function getDecorations({ doc, name, lowlight, defaultLanguage, }) {
|
|
2605
|
-
const decorations = [];
|
|
2606
|
-
core$1.findChildren(doc, node => node.type.name === name).forEach(block => {
|
|
2607
|
-
let from = block.pos + 1;
|
|
2608
|
-
const language = block.node.attrs.language || defaultLanguage;
|
|
2609
|
-
const languages = lowlight.listLanguages();
|
|
2610
|
-
const nodes = language && (languages.includes(language) || registered(language))
|
|
2611
|
-
? getHighlightNodes(lowlight.highlight(language, block.node.textContent))
|
|
2612
|
-
: getHighlightNodes(lowlight.highlightAuto(block.node.textContent));
|
|
2613
|
-
parseNodes(nodes).forEach(node => {
|
|
2614
|
-
const to = from + node.text.length;
|
|
2615
|
-
if (node.classes.length) {
|
|
2616
|
-
const decoration = view.Decoration.inline(from, to, {
|
|
2617
|
-
class: node.classes.join(' '),
|
|
2618
|
-
});
|
|
2619
|
-
decorations.push(decoration);
|
|
2620
|
-
}
|
|
2621
|
-
from = to;
|
|
2622
|
-
});
|
|
2623
|
-
});
|
|
2624
|
-
return view.DecorationSet.create(doc, decorations);
|
|
2625
|
-
}
|
|
2626
|
-
function isFunction(param) {
|
|
2627
|
-
return typeof param === 'function';
|
|
2628
|
-
}
|
|
2629
|
-
function LowlightPlugin({ name, lowlight, defaultLanguage, }) {
|
|
2630
|
-
if (!['highlight', 'highlightAuto', 'listLanguages'].every(api => isFunction(lowlight[api]))) {
|
|
2631
|
-
throw Error('You should provide an instance of lowlight to use the code-block-lowlight extension');
|
|
2632
|
-
}
|
|
2633
|
-
const lowlightPlugin = new state.Plugin({
|
|
2634
|
-
key: new state.PluginKey('lowlight'),
|
|
2635
|
-
state: {
|
|
2636
|
-
init: (_, { doc }) => getDecorations({
|
|
2637
|
-
doc,
|
|
2638
|
-
name,
|
|
2639
|
-
lowlight,
|
|
2640
|
-
defaultLanguage,
|
|
2641
|
-
}),
|
|
2642
|
-
apply: (transaction, decorationSet, oldState, newState) => {
|
|
2643
|
-
const oldNodeName = oldState.selection.$head.parent.type.name;
|
|
2644
|
-
const newNodeName = newState.selection.$head.parent.type.name;
|
|
2645
|
-
const oldNodes = core$1.findChildren(oldState.doc, node => node.type.name === name);
|
|
2646
|
-
const newNodes = core$1.findChildren(newState.doc, node => node.type.name === name);
|
|
2647
|
-
if (transaction.docChanged
|
|
2648
|
-
// Apply decorations if:
|
|
2649
|
-
// selection includes named node,
|
|
2650
|
-
&& ([oldNodeName, newNodeName].includes(name)
|
|
2651
|
-
// OR transaction adds/removes named node,
|
|
2652
|
-
|| newNodes.length !== oldNodes.length
|
|
2653
|
-
// OR transaction has changes that completely encapsulte a node
|
|
2654
|
-
// (for example, a transaction that affects the entire document).
|
|
2655
|
-
// Such transactions can happen during collab syncing via y-prosemirror, for example.
|
|
2656
|
-
|| transaction.steps.some(step => {
|
|
2657
|
-
// @ts-ignore
|
|
2658
|
-
return (
|
|
2659
|
-
// @ts-ignore
|
|
2660
|
-
step.from !== undefined
|
|
2661
|
-
// @ts-ignore
|
|
2662
|
-
&& step.to !== undefined
|
|
2663
|
-
&& oldNodes.some(node => {
|
|
2664
|
-
// @ts-ignore
|
|
2665
|
-
return (
|
|
2666
|
-
// @ts-ignore
|
|
2667
|
-
node.pos >= step.from
|
|
2668
|
-
// @ts-ignore
|
|
2669
|
-
&& node.pos + node.node.nodeSize <= step.to);
|
|
2670
|
-
}));
|
|
2671
|
-
}))) {
|
|
2672
|
-
return getDecorations({
|
|
2673
|
-
doc: transaction.doc,
|
|
2674
|
-
name,
|
|
2675
|
-
lowlight,
|
|
2676
|
-
defaultLanguage,
|
|
2677
|
-
});
|
|
2678
|
-
}
|
|
2679
|
-
return decorationSet.map(transaction.mapping, transaction.doc);
|
|
2680
|
-
},
|
|
2681
|
-
},
|
|
2682
|
-
props: {
|
|
2683
|
-
decorations(state) {
|
|
2684
|
-
return lowlightPlugin.getState(state);
|
|
2685
|
-
},
|
|
2686
|
-
},
|
|
2687
|
-
});
|
|
2688
|
-
return lowlightPlugin;
|
|
2581
|
+
var HighlightJS = /*@__PURE__*/getDefaultExportFromCjs(core);
|
|
2582
|
+
|
|
2583
|
+
function parseNodes(nodes, className = []) {
|
|
2584
|
+
return nodes
|
|
2585
|
+
.map(node => {
|
|
2586
|
+
const classes = [...className, ...(node.properties ? node.properties.className : [])];
|
|
2587
|
+
if (node.children) {
|
|
2588
|
+
return parseNodes(node.children, classes);
|
|
2589
|
+
}
|
|
2590
|
+
return {
|
|
2591
|
+
text: node.value,
|
|
2592
|
+
classes,
|
|
2593
|
+
};
|
|
2594
|
+
})
|
|
2595
|
+
.flat();
|
|
2596
|
+
}
|
|
2597
|
+
function getHighlightNodes(result) {
|
|
2598
|
+
// `.value` for lowlight v1, `.children` for lowlight v2
|
|
2599
|
+
return result.value || result.children || [];
|
|
2600
|
+
}
|
|
2601
|
+
function registered(aliasOrLanguage) {
|
|
2602
|
+
return Boolean(HighlightJS.getLanguage(aliasOrLanguage));
|
|
2603
|
+
}
|
|
2604
|
+
function getDecorations({ doc, name, lowlight, defaultLanguage, }) {
|
|
2605
|
+
const decorations = [];
|
|
2606
|
+
core$1.findChildren(doc, node => node.type.name === name).forEach(block => {
|
|
2607
|
+
let from = block.pos + 1;
|
|
2608
|
+
const language = block.node.attrs.language || defaultLanguage;
|
|
2609
|
+
const languages = lowlight.listLanguages();
|
|
2610
|
+
const nodes = language && (languages.includes(language) || registered(language))
|
|
2611
|
+
? getHighlightNodes(lowlight.highlight(language, block.node.textContent))
|
|
2612
|
+
: getHighlightNodes(lowlight.highlightAuto(block.node.textContent));
|
|
2613
|
+
parseNodes(nodes).forEach(node => {
|
|
2614
|
+
const to = from + node.text.length;
|
|
2615
|
+
if (node.classes.length) {
|
|
2616
|
+
const decoration = view.Decoration.inline(from, to, {
|
|
2617
|
+
class: node.classes.join(' '),
|
|
2618
|
+
});
|
|
2619
|
+
decorations.push(decoration);
|
|
2620
|
+
}
|
|
2621
|
+
from = to;
|
|
2622
|
+
});
|
|
2623
|
+
});
|
|
2624
|
+
return view.DecorationSet.create(doc, decorations);
|
|
2625
|
+
}
|
|
2626
|
+
function isFunction(param) {
|
|
2627
|
+
return typeof param === 'function';
|
|
2628
|
+
}
|
|
2629
|
+
function LowlightPlugin({ name, lowlight, defaultLanguage, }) {
|
|
2630
|
+
if (!['highlight', 'highlightAuto', 'listLanguages'].every(api => isFunction(lowlight[api]))) {
|
|
2631
|
+
throw Error('You should provide an instance of lowlight to use the code-block-lowlight extension');
|
|
2632
|
+
}
|
|
2633
|
+
const lowlightPlugin = new state.Plugin({
|
|
2634
|
+
key: new state.PluginKey('lowlight'),
|
|
2635
|
+
state: {
|
|
2636
|
+
init: (_, { doc }) => getDecorations({
|
|
2637
|
+
doc,
|
|
2638
|
+
name,
|
|
2639
|
+
lowlight,
|
|
2640
|
+
defaultLanguage,
|
|
2641
|
+
}),
|
|
2642
|
+
apply: (transaction, decorationSet, oldState, newState) => {
|
|
2643
|
+
const oldNodeName = oldState.selection.$head.parent.type.name;
|
|
2644
|
+
const newNodeName = newState.selection.$head.parent.type.name;
|
|
2645
|
+
const oldNodes = core$1.findChildren(oldState.doc, node => node.type.name === name);
|
|
2646
|
+
const newNodes = core$1.findChildren(newState.doc, node => node.type.name === name);
|
|
2647
|
+
if (transaction.docChanged
|
|
2648
|
+
// Apply decorations if:
|
|
2649
|
+
// selection includes named node,
|
|
2650
|
+
&& ([oldNodeName, newNodeName].includes(name)
|
|
2651
|
+
// OR transaction adds/removes named node,
|
|
2652
|
+
|| newNodes.length !== oldNodes.length
|
|
2653
|
+
// OR transaction has changes that completely encapsulte a node
|
|
2654
|
+
// (for example, a transaction that affects the entire document).
|
|
2655
|
+
// Such transactions can happen during collab syncing via y-prosemirror, for example.
|
|
2656
|
+
|| transaction.steps.some(step => {
|
|
2657
|
+
// @ts-ignore
|
|
2658
|
+
return (
|
|
2659
|
+
// @ts-ignore
|
|
2660
|
+
step.from !== undefined
|
|
2661
|
+
// @ts-ignore
|
|
2662
|
+
&& step.to !== undefined
|
|
2663
|
+
&& oldNodes.some(node => {
|
|
2664
|
+
// @ts-ignore
|
|
2665
|
+
return (
|
|
2666
|
+
// @ts-ignore
|
|
2667
|
+
node.pos >= step.from
|
|
2668
|
+
// @ts-ignore
|
|
2669
|
+
&& node.pos + node.node.nodeSize <= step.to);
|
|
2670
|
+
}));
|
|
2671
|
+
}))) {
|
|
2672
|
+
return getDecorations({
|
|
2673
|
+
doc: transaction.doc,
|
|
2674
|
+
name,
|
|
2675
|
+
lowlight,
|
|
2676
|
+
defaultLanguage,
|
|
2677
|
+
});
|
|
2678
|
+
}
|
|
2679
|
+
return decorationSet.map(transaction.mapping, transaction.doc);
|
|
2680
|
+
},
|
|
2681
|
+
},
|
|
2682
|
+
props: {
|
|
2683
|
+
decorations(state) {
|
|
2684
|
+
return lowlightPlugin.getState(state);
|
|
2685
|
+
},
|
|
2686
|
+
},
|
|
2687
|
+
});
|
|
2688
|
+
return lowlightPlugin;
|
|
2689
2689
|
}
|
|
2690
2690
|
|
|
2691
|
-
/**
|
|
2692
|
-
* This extension allows you to highlight code blocks with lowlight.
|
|
2693
|
-
* @see https://tiptap.dev/api/nodes/code-block-lowlight
|
|
2694
|
-
*/
|
|
2695
|
-
const CodeBlockLowlight =
|
|
2696
|
-
addOptions() {
|
|
2697
|
-
var _a;
|
|
2698
|
-
return {
|
|
2699
|
-
...(_a = this.parent) === null || _a === void 0 ? void 0 : _a.call(this),
|
|
2700
|
-
lowlight: {},
|
|
2701
|
-
defaultLanguage: null,
|
|
2702
|
-
};
|
|
2703
|
-
},
|
|
2704
|
-
addProseMirrorPlugins() {
|
|
2705
|
-
var _a;
|
|
2706
|
-
return [
|
|
2707
|
-
...((_a = this.parent) === null || _a === void 0 ? void 0 : _a.call(this)) || [],
|
|
2708
|
-
LowlightPlugin({
|
|
2709
|
-
name: this.name,
|
|
2710
|
-
lowlight: this.options.lowlight,
|
|
2711
|
-
defaultLanguage: this.options.defaultLanguage,
|
|
2712
|
-
}),
|
|
2713
|
-
];
|
|
2714
|
-
},
|
|
2691
|
+
/**
|
|
2692
|
+
* This extension allows you to highlight code blocks with lowlight.
|
|
2693
|
+
* @see https://tiptap.dev/api/nodes/code-block-lowlight
|
|
2694
|
+
*/
|
|
2695
|
+
const CodeBlockLowlight = CodeBlock.extend({
|
|
2696
|
+
addOptions() {
|
|
2697
|
+
var _a;
|
|
2698
|
+
return {
|
|
2699
|
+
...(_a = this.parent) === null || _a === void 0 ? void 0 : _a.call(this),
|
|
2700
|
+
lowlight: {},
|
|
2701
|
+
defaultLanguage: null,
|
|
2702
|
+
};
|
|
2703
|
+
},
|
|
2704
|
+
addProseMirrorPlugins() {
|
|
2705
|
+
var _a;
|
|
2706
|
+
return [
|
|
2707
|
+
...((_a = this.parent) === null || _a === void 0 ? void 0 : _a.call(this)) || [],
|
|
2708
|
+
LowlightPlugin({
|
|
2709
|
+
name: this.name,
|
|
2710
|
+
lowlight: this.options.lowlight,
|
|
2711
|
+
defaultLanguage: this.options.defaultLanguage,
|
|
2712
|
+
}),
|
|
2713
|
+
];
|
|
2714
|
+
},
|
|
2715
2715
|
});
|
|
2716
2716
|
|
|
2717
2717
|
exports.CodeBlockLowlight = CodeBlockLowlight;
|
|
2718
|
-
exports
|
|
2718
|
+
exports.default = CodeBlockLowlight;
|
|
2719
2719
|
//# sourceMappingURL=index.cjs.map
|