@bigbinary/neeto-editor 1.47.32 → 1.47.34
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/Editor.js +22 -273
- package/dist/Editor.js.map +1 -1
- package/dist/FormikEditor.js +1 -1
- package/dist/Menu.js +1 -1
- package/dist/{chunk-zoKBhh5D.js → chunk-airIORki.js} +2 -53
- package/dist/{chunk-zoKBhh5D.js.map → chunk-airIORki.js.map} +1 -1
- package/dist/cjs/Editor.cjs.js +22 -273
- package/dist/cjs/Editor.cjs.js.map +1 -1
- package/dist/cjs/FormikEditor.cjs.js +1 -1
- package/dist/cjs/Menu.cjs.js +1 -1
- package/dist/cjs/{chunk-D44ZMvgb.cjs.js → chunk-BCoa9xCZ.cjs.js} +1 -57
- package/dist/cjs/{chunk-D44ZMvgb.cjs.js.map → chunk-BCoa9xCZ.cjs.js.map} +1 -1
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/editor-stats.html +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -2
package/dist/Editor.js
CHANGED
|
@@ -4,7 +4,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
|
4
4
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import React__default, { memo, useEffect, useState, useRef, useCallback, createElement, forwardRef, useImperativeHandle } from 'react';
|
|
7
|
-
import { E as Extension, a as Mark, m as mergeAttributes, b as markInputRule, c as markPasteRule, D as DecorationSet, d as Decoration, g as getMarkAttributes, N as Node,
|
|
7
|
+
import { E as Extension, a as Mark, m as mergeAttributes, b as markInputRule, c as markPasteRule, D as DecorationSet, d as Decoration, g as getMarkAttributes, N as Node, w as wrappingInputRule, t as textblockTypeInputRule, k as keydownHandler, e as callOrReturn, f as getExtensionField, i as isNodeSelection, n as nodeInputRule, C as CALLOUT_TYPES, h as NodeViewWrapper, j as NodeViewContent, R as ReactNodeViewRenderer, l as findChildren, o as escapeForRegEx, p as ReactRenderer, q as EmojiPickerMenu, r as emojiPickerApi, s as combineTransactionSteps, u as getChangedRanges, v as findChildrenInRange, x as getMarksBetween, y as getAttributes, I as InputRule, z as highlightFocussedNode, A as resetFocussedNode, B as findParentNodeClosestToPos, P as PasteRule, F as BubbleMenu, G as getLinkPopoverPosition, H as getMarkType, J as getMarkRange, K as useEditor, L as useEditorState, M as Menu$3, O as EditorContent, Q as MediaUploader, S as LinkAddPopOver, T as EditorView } from './chunk-airIORki.js';
|
|
8
8
|
import classnames from 'classnames';
|
|
9
9
|
import { D as DIRECT_UPLOAD_ENDPOINT, E as EDITOR_OPTIONS, C as COMBINED_REGEX, a as EDITOR_SIZES } from './chunk-lTN1kwQ-.js';
|
|
10
10
|
import { isNotPresent, findBy, isNotEmpty, isPresent, noop as noop$1, slugify } from '@bigbinary/neeto-cist';
|
|
@@ -3018,268 +3018,6 @@ const Highlight = Mark.create({
|
|
|
3018
3018
|
},
|
|
3019
3019
|
});
|
|
3020
3020
|
|
|
3021
|
-
const findListItemPos = (typeOrName, state) => {
|
|
3022
|
-
const { $from } = state.selection;
|
|
3023
|
-
const nodeType = getNodeType(typeOrName, state.schema);
|
|
3024
|
-
let currentNode = null;
|
|
3025
|
-
let currentDepth = $from.depth;
|
|
3026
|
-
let currentPos = $from.pos;
|
|
3027
|
-
let targetDepth = null;
|
|
3028
|
-
while (currentDepth > 0 && targetDepth === null) {
|
|
3029
|
-
currentNode = $from.node(currentDepth);
|
|
3030
|
-
if (currentNode.type === nodeType) {
|
|
3031
|
-
targetDepth = currentDepth;
|
|
3032
|
-
}
|
|
3033
|
-
else {
|
|
3034
|
-
currentDepth -= 1;
|
|
3035
|
-
currentPos -= 1;
|
|
3036
|
-
}
|
|
3037
|
-
}
|
|
3038
|
-
if (targetDepth === null) {
|
|
3039
|
-
return null;
|
|
3040
|
-
}
|
|
3041
|
-
return { $pos: state.doc.resolve(currentPos), depth: targetDepth };
|
|
3042
|
-
};
|
|
3043
|
-
|
|
3044
|
-
const getNextListDepth = (typeOrName, state) => {
|
|
3045
|
-
const listItemPos = findListItemPos(typeOrName, state);
|
|
3046
|
-
if (!listItemPos) {
|
|
3047
|
-
return false;
|
|
3048
|
-
}
|
|
3049
|
-
const [, depth] = getNodeAtPosition(state, typeOrName, listItemPos.$pos.pos + 4);
|
|
3050
|
-
return depth;
|
|
3051
|
-
};
|
|
3052
|
-
|
|
3053
|
-
const hasListBefore = (editorState, name, parentListTypes) => {
|
|
3054
|
-
const { $anchor } = editorState.selection;
|
|
3055
|
-
const previousNodePos = Math.max(0, $anchor.pos - 2);
|
|
3056
|
-
const previousNode = editorState.doc.resolve(previousNodePos).node();
|
|
3057
|
-
if (!previousNode || !parentListTypes.includes(previousNode.type.name)) {
|
|
3058
|
-
return false;
|
|
3059
|
-
}
|
|
3060
|
-
return true;
|
|
3061
|
-
};
|
|
3062
|
-
|
|
3063
|
-
const hasListItemBefore = (typeOrName, state) => {
|
|
3064
|
-
var _a;
|
|
3065
|
-
const { $anchor } = state.selection;
|
|
3066
|
-
const $targetPos = state.doc.resolve($anchor.pos - 2);
|
|
3067
|
-
if ($targetPos.index() === 0) {
|
|
3068
|
-
return false;
|
|
3069
|
-
}
|
|
3070
|
-
if (((_a = $targetPos.nodeBefore) === null || _a === void 0 ? void 0 : _a.type.name) !== typeOrName) {
|
|
3071
|
-
return false;
|
|
3072
|
-
}
|
|
3073
|
-
return true;
|
|
3074
|
-
};
|
|
3075
|
-
|
|
3076
|
-
const listItemHasSubList = (typeOrName, state, node) => {
|
|
3077
|
-
if (!node) {
|
|
3078
|
-
return false;
|
|
3079
|
-
}
|
|
3080
|
-
const nodeType = getNodeType(typeOrName, state.schema);
|
|
3081
|
-
let hasSubList = false;
|
|
3082
|
-
node.descendants(child => {
|
|
3083
|
-
if (child.type === nodeType) {
|
|
3084
|
-
hasSubList = true;
|
|
3085
|
-
}
|
|
3086
|
-
});
|
|
3087
|
-
return hasSubList;
|
|
3088
|
-
};
|
|
3089
|
-
|
|
3090
|
-
const handleBackspace = (editor, name, parentListTypes) => {
|
|
3091
|
-
// this is required to still handle the undo handling
|
|
3092
|
-
if (editor.commands.undoInputRule()) {
|
|
3093
|
-
return true;
|
|
3094
|
-
}
|
|
3095
|
-
// if the selection is not collapsed
|
|
3096
|
-
// we can rely on the default backspace behavior
|
|
3097
|
-
if (editor.state.selection.from !== editor.state.selection.to) {
|
|
3098
|
-
return false;
|
|
3099
|
-
}
|
|
3100
|
-
// if the current item is NOT inside a list item &
|
|
3101
|
-
// the previous item is a list (orderedList or bulletList)
|
|
3102
|
-
// move the cursor into the list and delete the current item
|
|
3103
|
-
if (!isNodeActive(editor.state, name) && hasListBefore(editor.state, name, parentListTypes)) {
|
|
3104
|
-
const { $anchor } = editor.state.selection;
|
|
3105
|
-
const $listPos = editor.state.doc.resolve($anchor.before() - 1);
|
|
3106
|
-
const listDescendants = [];
|
|
3107
|
-
$listPos.node().descendants((node, pos) => {
|
|
3108
|
-
if (node.type.name === name) {
|
|
3109
|
-
listDescendants.push({ node, pos });
|
|
3110
|
-
}
|
|
3111
|
-
});
|
|
3112
|
-
const lastItem = listDescendants.at(-1);
|
|
3113
|
-
if (!lastItem) {
|
|
3114
|
-
return false;
|
|
3115
|
-
}
|
|
3116
|
-
const $lastItemPos = editor.state.doc.resolve($listPos.start() + lastItem.pos + 1);
|
|
3117
|
-
return editor.chain().cut({ from: $anchor.start() - 1, to: $anchor.end() + 1 }, $lastItemPos.end()).joinForward().run();
|
|
3118
|
-
}
|
|
3119
|
-
// if the cursor is not inside the current node type
|
|
3120
|
-
// do nothing and proceed
|
|
3121
|
-
if (!isNodeActive(editor.state, name)) {
|
|
3122
|
-
return false;
|
|
3123
|
-
}
|
|
3124
|
-
// if the cursor is not at the start of a node
|
|
3125
|
-
// do nothing and proceed
|
|
3126
|
-
if (!isAtStartOfNode(editor.state)) {
|
|
3127
|
-
return false;
|
|
3128
|
-
}
|
|
3129
|
-
const listItemPos = findListItemPos(name, editor.state);
|
|
3130
|
-
if (!listItemPos) {
|
|
3131
|
-
return false;
|
|
3132
|
-
}
|
|
3133
|
-
const $prev = editor.state.doc.resolve(listItemPos.$pos.pos - 2);
|
|
3134
|
-
const prevNode = $prev.node(listItemPos.depth);
|
|
3135
|
-
const previousListItemHasSubList = listItemHasSubList(name, editor.state, prevNode);
|
|
3136
|
-
// if the previous item is a list item and doesn't have a sublist, join the list items
|
|
3137
|
-
if (hasListItemBefore(name, editor.state) && !previousListItemHasSubList) {
|
|
3138
|
-
return editor.commands.joinItemBackward();
|
|
3139
|
-
}
|
|
3140
|
-
// otherwise in the end, a backspace should
|
|
3141
|
-
// always just lift the list item if
|
|
3142
|
-
// joining / merging is not possible
|
|
3143
|
-
return editor.chain().liftListItem(name).run();
|
|
3144
|
-
};
|
|
3145
|
-
|
|
3146
|
-
const nextListIsDeeper = (typeOrName, state) => {
|
|
3147
|
-
const listDepth = getNextListDepth(typeOrName, state);
|
|
3148
|
-
const listItemPos = findListItemPos(typeOrName, state);
|
|
3149
|
-
if (!listItemPos || !listDepth) {
|
|
3150
|
-
return false;
|
|
3151
|
-
}
|
|
3152
|
-
if (listDepth > listItemPos.depth) {
|
|
3153
|
-
return true;
|
|
3154
|
-
}
|
|
3155
|
-
return false;
|
|
3156
|
-
};
|
|
3157
|
-
|
|
3158
|
-
const nextListIsHigher = (typeOrName, state) => {
|
|
3159
|
-
const listDepth = getNextListDepth(typeOrName, state);
|
|
3160
|
-
const listItemPos = findListItemPos(typeOrName, state);
|
|
3161
|
-
if (!listItemPos || !listDepth) {
|
|
3162
|
-
return false;
|
|
3163
|
-
}
|
|
3164
|
-
if (listDepth < listItemPos.depth) {
|
|
3165
|
-
return true;
|
|
3166
|
-
}
|
|
3167
|
-
return false;
|
|
3168
|
-
};
|
|
3169
|
-
|
|
3170
|
-
const handleDelete = (editor, name) => {
|
|
3171
|
-
// if the cursor is not inside the current node type
|
|
3172
|
-
// do nothing and proceed
|
|
3173
|
-
if (!isNodeActive(editor.state, name)) {
|
|
3174
|
-
return false;
|
|
3175
|
-
}
|
|
3176
|
-
// if the cursor is not at the end of a node
|
|
3177
|
-
// do nothing and proceed
|
|
3178
|
-
if (!isAtEndOfNode(editor.state, name)) {
|
|
3179
|
-
return false;
|
|
3180
|
-
}
|
|
3181
|
-
// if the selection is not collapsed, or not within a single node
|
|
3182
|
-
// do nothing and proceed
|
|
3183
|
-
const { selection } = editor.state;
|
|
3184
|
-
const { $from, $to } = selection;
|
|
3185
|
-
if (!selection.empty && $from.sameParent($to)) {
|
|
3186
|
-
return false;
|
|
3187
|
-
}
|
|
3188
|
-
// check if the next node is a list with a deeper depth
|
|
3189
|
-
if (nextListIsDeeper(name, editor.state)) {
|
|
3190
|
-
return editor
|
|
3191
|
-
.chain()
|
|
3192
|
-
.focus(editor.state.selection.from + 4)
|
|
3193
|
-
.lift(name)
|
|
3194
|
-
.joinBackward()
|
|
3195
|
-
.run();
|
|
3196
|
-
}
|
|
3197
|
-
if (nextListIsHigher(name, editor.state)) {
|
|
3198
|
-
return editor.chain()
|
|
3199
|
-
.joinForward()
|
|
3200
|
-
.joinBackward()
|
|
3201
|
-
.run();
|
|
3202
|
-
}
|
|
3203
|
-
return editor.commands.joinItemForward();
|
|
3204
|
-
};
|
|
3205
|
-
|
|
3206
|
-
/**
|
|
3207
|
-
* This extension registers custom keymaps to change the behaviour of the backspace and delete keys.
|
|
3208
|
-
* By default Prosemirror keyhandling will always lift or sink items so paragraphs are joined into
|
|
3209
|
-
* the adjacent or previous list item. This extension will prevent this behaviour and instead will
|
|
3210
|
-
* try to join paragraphs from two list items into a single list item.
|
|
3211
|
-
* @see https://www.tiptap.dev/api/extensions/list-keymap
|
|
3212
|
-
*/
|
|
3213
|
-
const ListKeymap = Extension.create({
|
|
3214
|
-
name: 'listKeymap',
|
|
3215
|
-
addOptions() {
|
|
3216
|
-
return {
|
|
3217
|
-
listTypes: [
|
|
3218
|
-
{
|
|
3219
|
-
itemName: 'listItem',
|
|
3220
|
-
wrapperNames: ['bulletList', 'orderedList'],
|
|
3221
|
-
},
|
|
3222
|
-
{
|
|
3223
|
-
itemName: 'taskItem',
|
|
3224
|
-
wrapperNames: ['taskList'],
|
|
3225
|
-
},
|
|
3226
|
-
],
|
|
3227
|
-
};
|
|
3228
|
-
},
|
|
3229
|
-
addKeyboardShortcuts() {
|
|
3230
|
-
return {
|
|
3231
|
-
Delete: ({ editor }) => {
|
|
3232
|
-
let handled = false;
|
|
3233
|
-
this.options.listTypes.forEach(({ itemName }) => {
|
|
3234
|
-
if (editor.state.schema.nodes[itemName] === undefined) {
|
|
3235
|
-
return;
|
|
3236
|
-
}
|
|
3237
|
-
if (handleDelete(editor, itemName)) {
|
|
3238
|
-
handled = true;
|
|
3239
|
-
}
|
|
3240
|
-
});
|
|
3241
|
-
return handled;
|
|
3242
|
-
},
|
|
3243
|
-
'Mod-Delete': ({ editor }) => {
|
|
3244
|
-
let handled = false;
|
|
3245
|
-
this.options.listTypes.forEach(({ itemName }) => {
|
|
3246
|
-
if (editor.state.schema.nodes[itemName] === undefined) {
|
|
3247
|
-
return;
|
|
3248
|
-
}
|
|
3249
|
-
if (handleDelete(editor, itemName)) {
|
|
3250
|
-
handled = true;
|
|
3251
|
-
}
|
|
3252
|
-
});
|
|
3253
|
-
return handled;
|
|
3254
|
-
},
|
|
3255
|
-
Backspace: ({ editor }) => {
|
|
3256
|
-
let handled = false;
|
|
3257
|
-
this.options.listTypes.forEach(({ itemName, wrapperNames }) => {
|
|
3258
|
-
if (editor.state.schema.nodes[itemName] === undefined) {
|
|
3259
|
-
return;
|
|
3260
|
-
}
|
|
3261
|
-
if (handleBackspace(editor, itemName, wrapperNames)) {
|
|
3262
|
-
handled = true;
|
|
3263
|
-
}
|
|
3264
|
-
});
|
|
3265
|
-
return handled;
|
|
3266
|
-
},
|
|
3267
|
-
'Mod-Backspace': ({ editor }) => {
|
|
3268
|
-
let handled = false;
|
|
3269
|
-
this.options.listTypes.forEach(({ itemName, wrapperNames }) => {
|
|
3270
|
-
if (editor.state.schema.nodes[itemName] === undefined) {
|
|
3271
|
-
return;
|
|
3272
|
-
}
|
|
3273
|
-
if (handleBackspace(editor, itemName, wrapperNames)) {
|
|
3274
|
-
handled = true;
|
|
3275
|
-
}
|
|
3276
|
-
});
|
|
3277
|
-
return handled;
|
|
3278
|
-
},
|
|
3279
|
-
};
|
|
3280
|
-
},
|
|
3281
|
-
});
|
|
3282
|
-
|
|
3283
3021
|
/**
|
|
3284
3022
|
* This extension allows you to create table cells.
|
|
3285
3023
|
* @see https://www.tiptap.dev/api/nodes/table-cell
|
|
@@ -10942,7 +10680,7 @@ var ImageExtension = Node.create({
|
|
|
10942
10680
|
var currentPos = pos;
|
|
10943
10681
|
images.forEach( /*#__PURE__*/function () {
|
|
10944
10682
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(image) {
|
|
10945
|
-
var emptyImageNode, id, tr, url,
|
|
10683
|
+
var emptyImageNode, id, tr, url, imageNode, _view$state2, _tr, doc, nodePos, _doc, _tr2;
|
|
10946
10684
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
10947
10685
|
while (1) switch (_context2.prev = _context2.next) {
|
|
10948
10686
|
case 0:
|
|
@@ -10960,13 +10698,24 @@ var ImageExtension = Node.create({
|
|
|
10960
10698
|
case 7:
|
|
10961
10699
|
url = _context2.sent;
|
|
10962
10700
|
if (url) {
|
|
10963
|
-
|
|
10701
|
+
imageNode = schema.nodes.image.create({
|
|
10964
10702
|
id: id,
|
|
10965
10703
|
src: url,
|
|
10966
10704
|
alt: "image"
|
|
10967
10705
|
});
|
|
10968
|
-
view.
|
|
10969
|
-
|
|
10706
|
+
_view$state2 = view.state, _tr = _view$state2.tr, doc = _view$state2.doc;
|
|
10707
|
+
nodePos = -1;
|
|
10708
|
+
doc.descendants(function (node, pos) {
|
|
10709
|
+
if (node.type.name === "image" && node.attrs.id === id) {
|
|
10710
|
+
nodePos = pos;
|
|
10711
|
+
return false;
|
|
10712
|
+
}
|
|
10713
|
+
return true;
|
|
10714
|
+
});
|
|
10715
|
+
if (nodePos !== -1) {
|
|
10716
|
+
_tr.replaceWith(nodePos, nodePos + emptyImageNode.nodeSize, imageNode).setMeta("addToHistory", false);
|
|
10717
|
+
view.dispatch(_tr);
|
|
10718
|
+
}
|
|
10970
10719
|
}
|
|
10971
10720
|
_context2.next = 19;
|
|
10972
10721
|
break;
|
|
@@ -10975,16 +10724,16 @@ var ImageExtension = Node.create({
|
|
|
10975
10724
|
_context2.t0 = _context2["catch"](1);
|
|
10976
10725
|
// eslint-disable-next-line no-console
|
|
10977
10726
|
console.error("Failed to insert the image", _context2.t0);
|
|
10978
|
-
|
|
10979
|
-
|
|
10980
|
-
|
|
10727
|
+
_doc = view.state.doc;
|
|
10728
|
+
_tr2 = view.state.tr;
|
|
10729
|
+
_doc.descendants(function (node, pos) {
|
|
10981
10730
|
if (node.type.name === "image" && node.attrs.id === id) {
|
|
10982
|
-
|
|
10731
|
+
_tr2["delete"](pos, pos + emptyImageNode.nodeSize).setMeta("addToHistory", false);
|
|
10983
10732
|
return false;
|
|
10984
10733
|
}
|
|
10985
10734
|
return true;
|
|
10986
10735
|
});
|
|
10987
|
-
view.dispatch(
|
|
10736
|
+
view.dispatch(_tr2);
|
|
10988
10737
|
if (_context2.t0.message === LARGE_IMAGE_ERROR) {
|
|
10989
10738
|
Toastr.error(t("neetoEditor.error.imageSizeIsShouldBeLess", {
|
|
10990
10739
|
limit: globalProps.endUserUploadedFileSizeLimitInMb
|
|
@@ -19970,7 +19719,7 @@ var useCustomExtensions = function useCustomExtensions(_ref) {
|
|
|
19970
19719
|
onSubmit: onSubmit,
|
|
19971
19720
|
shortcuts: keyboardShortcuts,
|
|
19972
19721
|
isBlockQuoteActive: options.includes(EDITOR_OPTIONS.BLOCKQUOTE)
|
|
19973
|
-
}),
|
|
19722
|
+
}), EmojiSuggestion$1, EmojiPicker];
|
|
19974
19723
|
if (options.includes(EDITOR_OPTIONS.VIDEO_UPLOAD)) {
|
|
19975
19724
|
customExtensions.push(UnifiedVideoExtension);
|
|
19976
19725
|
}
|